LUAEditorContextMessages.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #ifndef LUAEDITOR_CONTEXTMESSAGES_H
  9. #define LUAEDITOR_CONTEXTMESSAGES_H
  10. #include <AzCore/base.h>
  11. #include <AzCore/EBus/EBus.h>
  12. #include <AzCore/Script/ScriptContextDebug.h>
  13. #include <AzCore/Asset/AssetCommon.h>
  14. #include <AzFramework/Script/ScriptRemoteDebugging.h>
  15. #pragma once
  16. namespace LUAEditor
  17. {
  18. //split these into different files later
  19. class Context_DocumentManagement
  20. : public AZ::EBusTraits
  21. {
  22. public:
  23. //////////////////////////////////////////////////////////////////////////
  24. // Bus configuration
  25. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; // we have one bus that we always broadcast to
  26. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ:: EBusHandlerPolicy::Multiple; // we can have multiple listeners.
  27. //////////////////////////////////////////////////////////////////////////
  28. typedef AZ::EBus<Context_DocumentManagement> Bus;
  29. typedef Bus::Handler Handler;
  30. virtual ~Context_DocumentManagement() {}
  31. virtual void OnNewDocument(const AZStd::string& assetId) = 0;
  32. virtual void OnLoadDocument(const AZStd::string& assetId, bool errorOnNotFound) = 0;
  33. virtual void OnCloseDocument(const AZStd::string& assetId) = 0;
  34. virtual void OnSaveDocument(const AZStd::string& assetId, bool bCloseAfterSave, bool bSaveAs) = 0;
  35. virtual bool OnSaveDocumentAs(const AZStd::string& assetId, bool bCloseAfterSave) = 0;
  36. virtual void OnReloadDocument(const AZStd::string assetId) = 0;
  37. virtual void DocumentCheckOutRequested(const AZStd::string& assetId) = 0;
  38. virtual void RefreshAllDocumentPerforceStat() = 0;
  39. virtual void UpdateDocumentData(const AZStd::string& assetId, const char* dataPtr, const AZStd::size_t dataLength) = 0;
  40. virtual void GetDocumentData(const AZStd::string& assetId, const char** dataPtr, AZStd::size_t& dataLength) = 0;
  41. virtual void NotifyDocumentModified(const AZStd::string& assetId, bool modified) = 0;
  42. };
  43. // These are messages that the context eats
  44. class Context_DebuggerManagement
  45. : public AZ::EBusTraits
  46. {
  47. public:
  48. virtual ~Context_DebuggerManagement() {}
  49. //////////////////////////////////////////////////////////////////////////
  50. // Bus configuration
  51. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; // we have one bus that we always broadcast to
  52. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ:: EBusHandlerPolicy::Multiple; // we can have multiple listeners.
  53. //////////////////////////////////////////////////////////////////////////
  54. typedef AZ::EBus<Context_DebuggerManagement> Bus;
  55. typedef Bus::Handler Handler;
  56. // execute the document as a script blob. Locally = true means that the document should be executed in the editor itself.
  57. virtual void ExecuteScriptBlob(const AZStd::string& fromAssetId, bool executeLocally) = 0;
  58. // Add or remove a breakpoint
  59. virtual void SynchronizeBreakpoints() = 0;
  60. virtual void CreateBreakpoint(const AZStd::string& fromAssetId, int lineNumber) = 0;
  61. virtual void MoveBreakpoint(const AZ::Uuid& breakpointUID, int lineNumber) = 0;
  62. virtual void DeleteBreakpoint(const AZ::Uuid& breakpointUID) = 0;
  63. virtual void CleanUpBreakpoints() = 0;
  64. // Debugger connection
  65. virtual void OnDebuggerAttached() = 0;
  66. virtual void OnDebuggerRefused() = 0;
  67. virtual void OnDebuggerDetached() = 0;
  68. // breakpoint replies
  69. virtual void OnBreakpointHit(const AZStd::string& assetIdString, int lineNumber) = 0;
  70. virtual void OnBreakpointAdded(const AZStd::string& assetIdString, int lineNumber) = 0;
  71. virtual void OnBreakpointRemoved(const AZStd::string& assetIdString, int lineNumber) = 0;
  72. // Replies to queries
  73. virtual void OnReceivedAvailableContexts(const AZStd::vector<AZStd::string>& contexts) = 0;
  74. virtual void OnReceivedRegisteredClasses(const AzFramework::ScriptUserClassList& classes) = 0;
  75. virtual void OnReceivedRegisteredEBuses(const AzFramework::ScriptUserEBusList& ebuses) = 0;
  76. virtual void OnReceivedRegisteredGlobals(const AzFramework::ScriptUserMethodList& methods, const AzFramework::ScriptUserPropertyList& properties) = 0;
  77. virtual void OnReceivedLocalVariables(const AZStd::vector<AZStd::string>& vars) = 0;
  78. virtual void OnReceivedCallstack(const AZStd::vector<AZStd::string>& callstack) = 0;
  79. // Replies to value operations
  80. virtual void OnReceivedValueState(const AZ::ScriptContextDebug::DebugValue& value) = 0;
  81. virtual void OnSetValueResult(const AZStd::string& name, bool success) = 0;
  82. // if the execution is resumed ('run') then this happens:
  83. virtual void OnExecutionResumed() = 0; // removes line number from the current line number and lets us know that execution has resumed
  84. // Script execution results
  85. virtual void OnExecuteScriptResult(bool success) = 0;
  86. // requested actions from subordinate systems
  87. virtual void RequestDetachDebugger() = 0;
  88. virtual void RequestAttachDebugger() = 0;
  89. };
  90. }
  91. #endif//LUAEDITOR_CONTEXTMESSAGES_H