3
0

UiCanvasLuaBus.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <LyShine/Bus/UiCanvasBus.h>
  10. #include <AzCore/Component/Component.h>
  11. //! \brief Mirrors the UiCanvasBus for use in Lua.
  12. class UiCanvasLuaInterface
  13. : public AZ::ComponentBus
  14. {
  15. public:
  16. virtual ~UiCanvasLuaInterface() {}
  17. // UiCanvasBus
  18. //! This flavor of FindElementById differs slightly from the UiCanvasBus version
  19. //! in that it returns an EntityId, which is a bit friendly for passing around in
  20. //! Lua.
  21. //! Use of the Element Id is discouraged as it will be deprecated soon.
  22. virtual AZ::EntityId FindElementById(LyShine::ElementId id) = 0;
  23. //! This flavor of FindElementByName differs slightly from the UiCanvasBus version
  24. //! in that it returns an EntityId, which is a bit friendly for passing around in
  25. //! Lua.
  26. virtual AZ::EntityId FindElementByName(const LyShine::NameType& name) = 0;
  27. virtual bool GetEnabled() = 0;
  28. virtual void SetEnabled(bool enabled) = 0;
  29. // ~UiCanvasBus
  30. };
  31. typedef AZ::EBus<UiCanvasLuaInterface> UiCanvasLuaBus;
  32. //! \brief This component serves as the bridge between UiCanvasBus and UiCanvasLuaBus
  33. class UiCanvasLuaProxy
  34. : public UiCanvasLuaBus::Handler
  35. {
  36. public:
  37. // UiCanvasLuaBus
  38. AZ::EntityId FindElementById(LyShine::ElementId id) override;
  39. AZ::EntityId FindElementByName(const LyShine::NameType& name) override;
  40. bool GetEnabled() override;
  41. void SetEnabled(bool enabled) override;
  42. // ~UiCanvasLuaBus
  43. //! \brief Adds this object as a handler for UiCanvasLuaBus
  44. void BusConnect(AZ::EntityId entityId);
  45. //! \brief Loads the canvas with the given filename
  46. AZ::EntityId LoadCanvas(const char* canvasFilename);
  47. //! \brief Unloads the canvas with the given canvas entity Id
  48. void UnloadCanvas(AZ::EntityId canvasEntityId);
  49. static void Reflect(AZ::ReflectContext* context);
  50. private:
  51. AZ::EntityId m_targetEntity;
  52. };