Skip to content

Commit 16fb0af

Browse files
Closing Ligth/Particle and Script editors now properly resets the com editors state
1 parent 9c796f8 commit 16fb0af

File tree

6 files changed

+59
-17
lines changed

6 files changed

+59
-17
lines changed

neo/tools/imgui/lighteditor/LightEditor.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ static float* vecToArr( idVec3& v )
564564

565565
void LightEditor::Draw()
566566
{
567-
bool showTool = isShown;
567+
showTool = isShown;
568568
if( ImGui::Begin( title, &showTool ) ) //, ImGuiWindowFlags_ShowBorders ) )
569569
{
570570
bool changes = false;
@@ -781,9 +781,20 @@ void LightEditor::Draw()
781781
if( isShown && !showTool )
782782
{
783783
isShown = showTool;
784-
impl::SetReleaseToolMouse( false );
785-
D3::ImGuiHooks::CloseWindow( D3::ImGuiHooks::D3_ImGuiWin_LightEditor );
784+
Exit();
786785
}
787786
}
788787

788+
void LightEditor::Exit( void )
789+
{
790+
// close this tool, release mouse, clear editor flags and reset edit mode
791+
showTool = false;
792+
LightEditor::Instance().ShowIt( false );
793+
impl::SetReleaseToolMouse( false );
794+
D3::ImGuiHooks::CloseWindow( D3::ImGuiHooks::D3_ImGuiWin_LightEditor );
795+
// clear editor flag and reset edit mode cvar
796+
com_editors &= ~EDITOR_LIGHT;
797+
cvarSystem->SetCVarInteger( "g_editEntityMode", 0 );
798+
}
799+
789800
} //namespace ImGuiTools

neo/tools/imgui/lighteditor/LightEditor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class LightInfo
8484
class LightEditor
8585
{
8686
private:
87+
bool showTool;
8788
bool isShown;
8889

8990
idStr title;
@@ -110,6 +111,7 @@ class LightEditor
110111
#endif
111112

112113
void Init( const idDict* dict, idEntity* light );
114+
void Exit( void );
113115
void Reset();
114116

115117
void LoadLightTextures();

neo/tools/imgui/particleeditor/ParticleEditor.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ ParticleEditor::ParticleEditor()
7878
void ParticleEditor::Draw()
7979
{
8080
int i, num;
81-
bool showTool;
82-
bool clickedNew = false, clickedSelect = false;
83-
8481
showTool = isShown;
82+
bool clickedNew = false, clickedSelect = false;
8583

8684
if ( ImGui::Begin( "Particle Editor", &showTool, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_MenuBar ) ) {
8785
impl::SetReleaseToolMouse( true );
@@ -105,9 +103,11 @@ void ParticleEditor::Draw()
105103
OnBnClickedButtonSave();
106104
}
107105

108-
if( ImGui::MenuItem( "Close", "Ctrl+W" ) )
106+
ImGui::Separator();
107+
108+
if ( ImGui::MenuItem( "Exit" ) )
109109
{
110-
showTool = false;
110+
Exit();
111111
}
112112

113113
ImGui::EndMenu();
@@ -706,11 +706,22 @@ void ParticleEditor::Draw()
706706
if ( isShown && !showTool )
707707
{
708708
isShown = showTool;
709-
impl::SetReleaseToolMouse( false );
710-
D3::ImGuiHooks::CloseWindow( D3::ImGuiHooks::D3_ImGuiWin_ParticleEditor );
709+
Exit();
711710
}
712711
}
713712

713+
void ParticleEditor::Exit( void )
714+
{
715+
// close this tool, release mouse, clear editor flags and reset edit mode
716+
showTool = false;
717+
ParticleEditor::Instance().ShowIt( false );
718+
impl::SetReleaseToolMouse( false );
719+
D3::ImGuiHooks::CloseWindow( D3::ImGuiHooks::D3_ImGuiWin_ParticleEditor );
720+
// clear editor flag and reset edit mode cvar
721+
com_editors &= ~EDITOR_PARTICLE;
722+
cvarSystem->SetCVarInteger( "g_editEntityMode", 0 );
723+
}
724+
714725
// ParticleEditor message handlers
715726

716727
void ParticleEditor::OnBnClickedParticleMode() {

neo/tools/imgui/particleeditor/ParticleEditor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ class ParticleEditor {
121121
void Reset();
122122
void Draw();
123123

124+
void Exit( void );
125+
124126
void ShowIt(bool show) {
125127
isShown = show;
126128
}
@@ -152,6 +154,7 @@ class ParticleEditor {
152154
void OnBtnZdn();
153155

154156
private:
157+
bool showTool;
155158
bool isShown;
156159

157160
DeclNewSelect particleNewDlg;

neo/tools/imgui/scripteditor/ScriptEditor.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,8 @@ void ScriptEditor::Reset() {
7777

7878
void ScriptEditor::Draw()
7979
{
80-
bool showTool;
81-
bool clickedNew = false, clickedSelect = false;
82-
8380
showTool = isShown;
81+
bool clickedNew = false, clickedSelect = false;
8482

8583
if ( ImGui::Begin( windowText.c_str(), &showTool, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_MenuBar ) ) {
8684
impl::SetReleaseToolMouse(true);
@@ -104,9 +102,9 @@ void ScriptEditor::Draw()
104102
OnBnClickedOk();
105103
}
106104

107-
if (ImGui::MenuItem("Close", "Ctrl+W"))
105+
if (ImGui::MenuItem("Exit"))
108106
{
109-
showTool = false;
107+
Exit();
110108
}
111109

112110
ImGui::EndMenu();
@@ -146,11 +144,26 @@ void ScriptEditor::Draw()
146144
if ( isShown && !showTool )
147145
{
148146
isShown = showTool;
149-
impl::SetReleaseToolMouse( false );
150-
D3::ImGuiHooks::CloseWindow( D3::ImGuiHooks::D3_ImGuiWin_ScriptEditor );
147+
Exit();
151148
}
152149
}
153150

151+
/*
152+
================
153+
ScriptEditor::Exit
154+
================
155+
*/
156+
void ScriptEditor::Exit( void )
157+
{
158+
// close this tool, release mouse, clear editor flags and reset edit mode
159+
showTool = false;
160+
ScriptEditor::Instance().ShowIt( false );
161+
impl::SetReleaseToolMouse( false );
162+
D3::ImGuiHooks::CloseWindow( D3::ImGuiHooks::D3_ImGuiWin_ScriptEditor );
163+
// clear editor flag
164+
com_editors &= ~EDITOR_SCRIPT;
165+
}
166+
154167
/*
155168
================
156169
ScriptEditor::UpdateStatusBar

neo/tools/imgui/scripteditor/ScriptEditor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class ScriptEditor {
4545

4646
void Reset();
4747
void Draw();
48+
void Exit( void );
4849

4950
void ShowIt(bool show) {
5051
isShown = show;
@@ -58,6 +59,7 @@ class ScriptEditor {
5859
void OnBnClickedCancel();
5960

6061
private:
62+
bool showTool;
6163
bool isShown;
6264
idStr windowText;
6365
idStr errorText;

0 commit comments

Comments
 (0)