Finality Engine
Loading...
Searching...
No Matches
EditorLayer.h
Go to the documentation of this file.
1
6#pragma once
7#include <Finality.h>
8#include "EditorCameraScene.h"
9
10#include "Panels/Console.h"
12
13#include <chrono>
14#include <vector>
15#include <string>
16#include "AssetPicker.h"
18#include "EditorSession.h"
19#include "GameViewSettings.h"
20#include "Panels/BuildPanel.h"
21
22namespace FINALITY
23{
24
25
28 {
29 public:
30 void Configure(const std::string& initialProject, const std::filesystem::path& engineAssets)
31 { m_InitialProject = initialProject; m_EngineAssets = engineAssets; }
32 void Init();
33 void OnUpdate(float deltaTime);
35 void Shutdown();
36
37 void SetSceneFactory(std::function<std::unique_ptr<Scene>()> factory) { m_SceneFactory = factory; }
38
39 private:
40 void DrawToolbar();
41 void DrawSceneView();
42 void DrawGameView();
43 void DrawMenuBar();
44
45 void OnPlay();
46 void OnPause();
47 void OnResume();
48 void OnStop();
49 void NewScene();
50 bool OpenScene(const std::string& path);
51 void SaveScene(bool saveAs = false);
52 void HandleShortcuts();
53 void ExecuteEntityCommand(EditorAction action);
54 void DrawEntityCommandDialogs();
55 void DrawShortcutSettings();
56 void RecordHistory();
57 void RestoreHistory(size_t index);
58 void DrawContentBrowser(entt::entity selectedEntityHandle);
59 void DrawGizmo(entt::entity selectedEntityHandle);
60 bool OpenProject(const std::string& path);
61 void DrawProjectManager();
62 void DrawProjectSettings();
63 void ApplyProjectSettings();
64 void DrawCreateMenu();
65 void CreatePrimitive(const std::string& name, const std::string& meshReference = {});
66 void DrawHierarchy();
67 void SetupLayout();
68 void InitializeSceneTools();
69 void AppendSceneGrid(std::vector<RenderPacket>& queue, Camera& camera);
70 void PickSceneEntity(const ImVec2& minimum, const ImVec2& maximum);
71 void PlaceSceneAsset(uint64_t id, const glm::vec3& position);
72 void FrameSelected();
73
74 private:
75 std::shared_ptr<RenderTarget> m_SceneTarget;
76 std::shared_ptr<RenderTarget> m_GameTarget;
77
78 std::unique_ptr<EditorCameraScene> m_EditorCameraScene;
79 bool m_SceneViewActive = false;
80 GameViewSettings m_GameViewSettings;
81 bool m_ShowSceneStats = false;
82 bool m_CameraCaptured = false;
83 bool m_ContentBrowserFocused = false, m_ContentBrowserVisible = false;
84 std::string m_FocusSearch, m_EntityClipboard, m_RenameBuffer, m_ShortcutMessage;
85 entt::entity m_RenameTarget = entt::null;
86 bool m_RenamePending = false;
87 int m_ShortcutCapture = -1;
88 ImVec2 m_SceneImageMinimum{}, m_SceneImageMaximum{};
89
90 EditorSession m_Session;
91 BuildPanel m_BuildPanel;
92 AssetPicker m_AssetPicker;
93 AssetInspector m_AssetInspector;
94 ProjectSettings m_SettingsDraft;
95 std::string m_SettingsName, m_SettingsStartup, m_SettingsSearch;
96 int m_SettingsCategory = 0;
97 bool m_SettingsInitialized = false;
98 bool m_ThemePending = false;
99 std::string m_ThemeMessage;
100 float m_AssetScanClock = 0;
101 bool m_AssetRefreshPending = false;
102 std::string m_InitialProject;
103 std::string m_LayoutPath;
104 std::filesystem::path m_EngineAssets;
105 std::string m_ProjectName = "New Project";
106 std::string m_ProjectLocation;
107 std::vector<std::string> m_RecentProjects;
108 std::string m_ProjectError;
109 std::string m_AssetSearch;
110 std::string m_SelectedContentFolder;
111 bool m_ContentGrid = true;
112 float m_ContentThumbnailSize = 72;
113 std::string m_HierarchySearch;
114 bool m_ShowProjectManager = true;
115 bool m_ShowProjectSettings = false;
116 bool m_ShowHierarchy = true;
117 bool m_ShowInspector = true;
118 bool m_ShowScene = true;
119 bool m_ShowGame = true;
120 bool m_ShowConsole = true;
121 bool m_ShowContentBrowser = true;
122 bool m_ShowToolbar = true;
123 bool m_ShowPerformance = true;
124 std::string m_FocusWindow;
125 bool m_UseTemplate = true;
126 bool m_LayoutReady = false;
127 bool m_LoadProjectLayout = false;
128 bool m_LocalGizmo = false;
129 bool m_SnapToGrid = false;
130 float m_SnapDistance = 1.0f;
131 bool m_ShowGrid = true;
132 std::shared_ptr<Mesh> m_GridMesh;
133 std::shared_ptr<Material> m_GridMaterial;
134 std::string m_ContentDirectory = "assets";
135 float m_ShaderReloadClock = 0.0f;
136 int m_GizmoOperation = 0;
137 std::function<std::unique_ptr<Scene>()> m_SceneFactory;
138
139 float m_AccumulatedTime = 0.0f;
140 float m_UiFps = 0.0f;
141 float m_UiAvgFrameTimeMs = 0.0f;
142 float m_FrameTimeHistory[120]{};
143 int m_HistoryOffset = 0;
144 uint32_t m_FrameCount = 0;
145 std::chrono::steady_clock::time_point m_LastLogTime;
146 };
147}
void OnUpdate(float deltaTime)
void SetSceneFactory(std::function< std::unique_ptr< Scene >()> factory)
Definition EditorLayer.h:37
void Configure(const std::string &initialProject, const std::filesystem::path &engineAssets)
Definition EditorLayer.h:30