diff options
author | rtk0c <[email protected]> | 2022-05-07 17:27:01 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-05-07 17:27:01 -0700 |
commit | 9fcdfe312fd9809a1cd52c08e7d8d7bd991a9fb3 (patch) | |
tree | c9820ea29a0d38c2adb7464386233415bfcccc10 /source/EditorCorePrivate.hpp | |
parent | f348347f205f51800d0628021f193e63f5833f8d (diff) |
Changeset: 25 Reduce dependency between editor headers and main game headers
Diffstat (limited to 'source/EditorCorePrivate.hpp')
-rw-r--r-- | source/EditorCorePrivate.hpp | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/source/EditorCorePrivate.hpp b/source/EditorCorePrivate.hpp new file mode 100644 index 0000000..566131b --- /dev/null +++ b/source/EditorCorePrivate.hpp @@ -0,0 +1,111 @@ +#pragma once + +#include "EditorCore.hpp" + +#include "App.hpp" +#include "EditorAttachment.hpp" +#include "EditorCommandPalette.hpp" +#include "EditorUtils.hpp" +#include "GameObject.hpp" +#include "Ires.hpp" +#include "RcPtr.hpp" +#include "Sprite.hpp" +#include "World.hpp" + +#include <memory> +#include <string> + +// TODO move inspector drawing to this class +class EditorInspector final : public IEditorInspector { +public: + std::string renamingScratchBuffer; + void* selectedItPtr = nullptr; + TargetType selectedItt = ITT_None; + bool renaming = false; + + void SelectTarget(TargetType type, void* object) override; +}; + +class EditorContentBrowser final : public IEditorContentBrowser { +private: + enum Pane { + P_Settings, + P_Ires, + }; + + static constexpr float kSplitterThickness = 3.0f; + static constexpr float kPadding = 4.0f; + + // <root> + static constexpr float kLeftPaneMinWidth = 200.0f; + static constexpr float kRightPaneMinWidth = 200.0f; + + EditorInspector* mInspector; + Pane mPane = P_Settings; + float mBrowserHeight = 0.5f; + float mSplitterLeft = kLeftPaneMinWidth; + float mSplitterRight = 0.0f; + bool mDocked = true; + +public: + EditorContentBrowser(EditorInspector* inspector); + ~EditorContentBrowser() override; + + void Show(bool* open = nullptr); +}; + +struct GuizmoState { + ImGuizmo::OPERATION currOperation = ImGuizmo::TRANSLATE; + ImGuizmo::MODE currMode = ImGuizmo::LOCAL; + glm::mat4 cubeMatrix; + float snap[3] = { 1.f, 1.f, 1.f }; + float boundsSnap[3] = { 0.1f, 0.1f, 0.1f }; + bool useSnap = false; + bool boundSizing = false; + bool boundSizingSnap = false; +}; + +// TODO editor undo stack +class EditorInstance : public IEditor { +private: + App* mApp; + GameObject* mPopupCurrent_GameObject = nullptr; + Camera mEditorCamera; + RcPtr<SpriteDefinition> mSpriteView_Instance; + EditorCommandPalette mEdCommandPalette; + EditorInspector mEdInspector; + EditorContentBrowser mEdContentBrowser; + GuizmoState mGuizmo; + glm::vec3 mDragCam_CamInitial; + ImVec2 mDragCam_CursorInitial; + int mSpriteView_Frame; + bool mSpriteView_OpenNextFrame = false; + bool mWindowVisible_ImGuiDemo = false; + bool mWindowVisible_CommandPalette = false; + bool mWindowVisible_Inspector = true; + bool mWindowVisible_ContentBrowser = true; + bool mWindowVisible_WorldStructure = true; + bool mWindowVisible_WorldProperties = true; + bool mDragCam_Happening = false; + bool mMoveCamKeyboard = false; + +public: + EditorInstance(App* app); + ~EditorInstance() override; + + void OnGameStateChanged(bool running) override; + void Show() override; + + EditorInspector& GetInspector() override { return mEdInspector; } + EditorContentBrowser& GetContentBrowser() override { return mEdContentBrowser; } + + void OpenSpriteViewer(SpriteDefinition* sprite) override; + +private: + void ShowWorldProperties(); + + void ShowInspector(IresObject* ires); + void ShowInspector(GameObject* object); + + void ShowSpriteViewer(); +}; |