feat: move editor to project / add post processing etc
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
#ifndef EDITOR_EDITOR_H
|
||||
#define EDITOR_EDITOR_H
|
||||
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
#include <destrum/AppLayer.h>
|
||||
|
||||
#include <editor/AssetBrowser.h>
|
||||
#include <editor/EditorCamera.h>
|
||||
#include <editor/PlayMode.h>
|
||||
#include <editor/RectGizmo.h>
|
||||
#include <editor/ResourcesInspector.h>
|
||||
#include <editor/SceneInspector.h>
|
||||
#include <editor/ShaderHotReload.h>
|
||||
#include <editor/TransformGizmo.h>
|
||||
#include <editor/UndoStack.h>
|
||||
|
||||
class App;
|
||||
class Scene;
|
||||
|
||||
struct EditorSettings {
|
||||
std::filesystem::path gameAssetsSource;
|
||||
std::string scenePath;
|
||||
bool startInEditMode{true};
|
||||
};
|
||||
|
||||
class Editor final : public AppLayer {
|
||||
public:
|
||||
Editor(App& app, EditorSettings settings);
|
||||
|
||||
void onAttach() override;
|
||||
void onBeginFrame() override;
|
||||
void onImGuiBegin(float dt) override;
|
||||
void onImGui(float dt) override;
|
||||
void onEndFrame() override;
|
||||
void onRender(GameRenderer& renderer) override;
|
||||
|
||||
[[nodiscard]] Camera* viewCamera() override;
|
||||
[[nodiscard]] bool hostsViewport() const override { return true; }
|
||||
[[nodiscard]] InputFocus gameInputFocus() const override;
|
||||
|
||||
bool OpenScene(std::string_view path);
|
||||
bool SaveScene();
|
||||
bool SaveSceneAs(std::string_view path);
|
||||
void NewScene();
|
||||
|
||||
[[nodiscard]] UndoStack& GetUndoStack() { return m_UndoStack; }
|
||||
[[nodiscard]] PlayMode& GetPlayMode() { return m_PlayMode; }
|
||||
|
||||
private:
|
||||
struct Panels {
|
||||
bool inspector{true};
|
||||
bool assets{true};
|
||||
bool stats{true};
|
||||
bool physics{false};
|
||||
bool imageCache{false};
|
||||
};
|
||||
|
||||
struct ViewOptions {
|
||||
bool colliders{false};
|
||||
bool gizmos{true};
|
||||
};
|
||||
|
||||
struct Viewport {
|
||||
glm::vec2 min{0.0f};
|
||||
glm::vec2 size{1.0f};
|
||||
glm::ivec2 desiredSize{0};
|
||||
bool hovered{false};
|
||||
bool focused{false};
|
||||
bool mouseClaimed{false};
|
||||
bool pickSelectsParent{false};
|
||||
std::optional<glm::ivec2> hoverPixel;
|
||||
};
|
||||
|
||||
// Editor.cpp
|
||||
[[nodiscard]] Scene* CurrentScene() const;
|
||||
[[nodiscard]] bool UsesEditorCamera();
|
||||
void HandleShortcuts();
|
||||
void Undo();
|
||||
void Redo();
|
||||
void RecordEdits();
|
||||
void AfterSceneReplaced(bool resetHistory);
|
||||
void DeleteSelection();
|
||||
void DuplicateSelection();
|
||||
void FocusSelection();
|
||||
void SetStatus(std::string status);
|
||||
bool WriteScene(Scene& scene, std::string_view path);
|
||||
|
||||
// EditorViewport.cpp
|
||||
void ApplyViewportResize();
|
||||
void DrawViewport();
|
||||
void DrawGizmos(Scene& scene);
|
||||
void RequestPick();
|
||||
void ApplyPick();
|
||||
void OnAssetDropped(std::string_view path);
|
||||
void SubmitColliderLines(Scene& scene) const;
|
||||
|
||||
// EditorMenus.cpp
|
||||
void DrawDockSpace();
|
||||
void DrawMainMenuBar();
|
||||
void DrawFileMenu();
|
||||
void DrawEditMenu();
|
||||
void DrawViewMenu();
|
||||
void DrawDisplayMenu();
|
||||
void DrawPlayControls();
|
||||
void DrawSceneDialogs();
|
||||
void DrawStatsPanel();
|
||||
void DrawPhysicsPanel();
|
||||
|
||||
App& m_App;
|
||||
EditorSettings m_Settings;
|
||||
|
||||
EditorCamera m_Camera;
|
||||
PlayMode m_PlayMode;
|
||||
UndoStack m_UndoStack;
|
||||
SceneInspector m_Inspector;
|
||||
AssetBrowser m_AssetBrowser;
|
||||
ResourcesInspector m_ResourcesInspector;
|
||||
TransformGizmo m_TransformGizmo;
|
||||
RectGizmo m_RectGizmo;
|
||||
ShaderHotReload m_ShaderHotReload;
|
||||
|
||||
Panels m_Panels;
|
||||
ViewOptions m_View;
|
||||
Viewport m_Viewport;
|
||||
|
||||
std::string m_ScenePath;
|
||||
std::string m_Status;
|
||||
std::string m_SaveAsPath;
|
||||
bool m_OpenSceneDialog{false};
|
||||
bool m_SaveAsDialog{false};
|
||||
bool m_ItemWasActive{false};
|
||||
bool m_EditPending{false};
|
||||
};
|
||||
|
||||
#endif // EDITOR_EDITOR_H
|
||||
Reference in New Issue
Block a user