Skip to content

Commit 279c46d

Browse files
committed
* In save/exit confirmation, do not display the Cancel button if exiting the program or no longer in the asset editor.
1 parent c740330 commit 279c46d

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

TheForceEngine/TFE_Editor/LevelEditor/confirmDialogs.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ namespace LevelEditor
6262
editor_closeLevel(/*save*/false);
6363
exit = true;
6464
}
65-
ImGui::SameLine();
66-
if (ImGui::Button("Cancel"))
65+
if (TFE_Editor::isInAssetEditor() && !TFE_Editor::isProgramExiting())
6766
{
68-
exit = true;
67+
ImGui::SameLine();
68+
if (ImGui::Button("Cancel"))
69+
{
70+
exit = true;
71+
}
6972
}
7073
ImGui::EndPopup();
7174
}

TheForceEngine/TFE_Editor/editor.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ namespace TFE_Editor
7070
static u32 s_editorPopupUserData = 0;
7171
static void* s_editorPopupUserPtr = nullptr;
7272
static bool s_exitEditor = false;
73+
static bool s_programExiting = false;
7374
static bool s_configView = false;
7475
static WorkBuffer s_workBuffer;
7576
static char s_projectPath[TFE_MAX_PATH] = "";
@@ -115,6 +116,7 @@ namespace TFE_Editor
115116
// Ui begin/render is called so we have a "UI Frame" in which to setup UI state.
116117
s_editorMode = EDIT_ASSET_BROWSER;
117118
s_exitEditor = false;
119+
s_programExiting = false;
118120
loadFonts();
119121
loadIcons();
120122
loadConfig();
@@ -567,13 +569,14 @@ namespace TFE_Editor
567569
}
568570
}
569571

570-
bool update(bool consoleOpen, bool minimized)
572+
bool update(bool consoleOpen, bool minimized, bool exiting)
571573
{
572574
// If the program is minimized, the editor should skip any processing.
573575
if (minimized)
574576
{
575577
return s_exitEditor;
576578
}
579+
s_programExiting = exiting;
577580

578581
editor_clearUid();
579582
thumbnail_update();
@@ -663,6 +666,16 @@ namespace TFE_Editor
663666
ImGui::PopStyleVar();
664667
}
665668

669+
bool isInAssetEditor()
670+
{
671+
return s_editorMode == EDIT_ASSET;
672+
}
673+
674+
bool isProgramExiting()
675+
{
676+
return s_programExiting;
677+
}
678+
666679
void drawTitle()
667680
{
668681
DisplayInfo info;

TheForceEngine/TFE_Editor/editor.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ namespace TFE_Editor
118118

119119
void enable();
120120
bool disable();
121-
bool update(bool consoleOpen = false, bool minimized = false);
121+
bool update(bool consoleOpen = false, bool minimized = false, bool exiting = false);
122122
bool render();
123123
TextureGpu* getIconAtlas();
124124

@@ -179,4 +179,7 @@ namespace TFE_Editor
179179

180180
Vec2i getEditorVersion();
181181
bool mouseInsideItem();
182+
183+
bool isInAssetEditor();
184+
bool isProgramExiting();
182185
}

TheForceEngine/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ int main(int argc, char* argv[])
966966
TFE_Ui::begin();
967967
TFE_System::update();
968968

969-
TFE_Editor::update();
969+
TFE_Editor::update(false, false, /*exiting*/true);
970970
bool swap = TFE_Editor::render();
971971

972972
// Blit the frame to the window and draw UI.

0 commit comments

Comments
 (0)