diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2023-12-14 16:47:34 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2023-12-23 11:41:03 -0500 |
| commit | b01009122151a61d831e8b71434df788b8ceb21f (patch) | |
| tree | 040cad0277cb3a936765acfa5a96920ad2b079bb /editor | |
| parent | 064e9ba16e390b13566d0007ef367dcb1adacc8d (diff) | |
new scene button
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/editor.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp index 2f3a7d4..53d8883 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -70,9 +70,11 @@ bool shouldCreateEntityType = false; EntityType entityTypeToCreate{}; CameraHandle selectedCamera = CameraHandle_MAX; -char *sceneName = nullptr; +const char* const newSceneName = "newScene.pstf"; +const char *sceneName = nullptr; bool shouldOpenLoadSceneDialog = false; bool shouldOpenSaveSceneDialog = false; +bool shouldOpenNewScene = false; bool shouldLoadScene = false; bool shouldSaveScene = false; bool shouldSaveProjectFile = false; @@ -123,6 +125,15 @@ void PkeEditor_Tick(double delta) { if (shouldDisableEditor) { PkeEditor_Teardown(); } + if (shouldOpenNewScene) { + shouldOpenNewScene = false; + if (levelHandle != LevelHandle_MAX) { + PkeLevel_Remove(levelHandle); + ActiveCamera = &NullCamera; + } + levelHandle = PkeLevel_Create("editorLevel"); + sceneName = newSceneName; + } if (shouldSaveProjectFile) { shouldSaveProjectFile = false; PkeProject_Save(); @@ -422,6 +433,15 @@ void RecordImGuiEditorWrapper() { ImGui::DockSpaceOverViewport(nullptr, ImGuiDockNodeFlags_PassthruCentralNode); ImGui::BeginMainMenuBar(); if (ImGui::BeginMenu("File")) { + if (ImGui::MenuItem("New Scene")) { + shouldOpenNewScene = true; + } + /* + * comparing pointer locations of c-strings is intentional + * - the goal is not to prevent a specific scene name, + * I just want to know if they clicked the "New Scene" button + */ + ImGui::BeginDisabled(sceneName == newSceneName); if (ImGui::MenuItem("Save")) { shouldSaveProjectFile = true; shouldSaveScene = true; @@ -436,6 +456,7 @@ void RecordImGuiEditorWrapper() { } ImGui::Text("%s", sceneName + offset); } + ImGui::EndDisabled(); if (ImGui::MenuItem("Save As...")) { shouldSaveProjectFile = true; shouldOpenSaveSceneDialog = true; |
