PythonEditorFuncs.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 <Include/SandboxAPI.h>
  10. #include <AzCore/Component/Component.h>
  11. #include "PythonEditorEventsBus.h"
  12. namespace AzToolsFramework
  13. {
  14. //! A component to reflect scriptable commands for the Editor
  15. class PythonEditorFuncsHandler
  16. : public AZ::Component
  17. {
  18. public:
  19. AZ_COMPONENT(PythonEditorFuncsHandler, "{0F470E7E-9741-4608-84B1-7E4735FDA526}")
  20. SANDBOX_API static void Reflect(AZ::ReflectContext* context);
  21. // AZ::Component ...
  22. void Activate() override {}
  23. void Deactivate() override {}
  24. };
  25. //! Component to access the PythonEditorFuncs
  26. class PythonEditorComponent final
  27. : public AZ::Component
  28. , public EditorLayerPythonRequestBus::Handler
  29. {
  30. public:
  31. AZ_COMPONENT(PythonEditorComponent, "{B06810A1-E3C0-4A63-8DDD-3A01C5299DD3}")
  32. PythonEditorComponent() = default;
  33. ~PythonEditorComponent() override = default;
  34. static void Reflect(AZ::ReflectContext* context);
  35. // Component...
  36. void Activate() override;
  37. void Deactivate() override;
  38. const char* GetCVar(const char* pName) override;
  39. void SetCVar(const char* pName, const AZStd::any& value) override;
  40. void SetCVarFromString(const char* pName, const char* pValue) override;
  41. void SetCVarFromInteger(const char* pName, int pValue) override;
  42. void SetCVarFromFloat(const char* pName, float pValue) override;
  43. void PyRunConsole(const char* text) override;
  44. void EnterGameMode() override;
  45. bool IsInGameMode() override;
  46. void ExitGameMode() override;
  47. void EnterSimulationMode() override;
  48. bool IsInSimulationMode() override;
  49. void ExitSimulationMode() override;
  50. void RunFile(const char* pFile) override;
  51. void RunFileParameters(const char* pFile, const char* pArguments) override;
  52. void ExecuteCommand(const char* cmdline) override;
  53. bool MessageBoxOkCancel(const char* pMessage) override;
  54. bool MessageBoxYesNo(const char* pMessage) override;
  55. bool MessageBoxOk(const char* pMessage) override;
  56. AZStd::string EditBox(AZStd::string_view pTitle) override;
  57. AZStd::any EditBoxCheckDataType(const char* pTitle) override;
  58. AZStd::string OpenFileBox() override;
  59. const char* GetAxisConstraint() override;
  60. void SetAxisConstraint(AZStd::string_view pConstrain) override;
  61. AZ::IO::Path GetPakFromFile(const char* filename) override;
  62. void Log(const char* pMessage) override;
  63. void Undo() override;
  64. void Redo() override;
  65. void DrawLabel(int x, int y, float size, float r, float g, float b, float a, const char* pLabel) override;
  66. AZStd::string ComboBox(AZStd::string title, AZStd::vector<AZStd::string> values, int selectedIdx = 0) override;
  67. };
  68. } // namespace AzToolsFramework