Skip to content

Commit d47af9c

Browse files
committed
Preparations for UI restart command
1 parent 4ab8854 commit d47af9c

File tree

6 files changed

+24
-1
lines changed

6 files changed

+24
-1
lines changed

src/xrGame/console_commands.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,16 @@ class CCC_MainMenu : public IConsole_Command
13151315
}
13161316
};
13171317

1318+
class CCC_UIRestart : public IConsole_Command
1319+
{
1320+
public:
1321+
CCC_UIRestart(pcstr name) : IConsole_Command(name) { bEmptyArgsHandled = true; }
1322+
1323+
void Execute(pcstr /*args*/) override
1324+
{
1325+
}
1326+
};
1327+
13181328
struct CCC_StartTimeSingle : public IConsole_Command
13191329
{
13201330
CCC_StartTimeSingle(LPCSTR N) : IConsole_Command(N){};
@@ -2098,6 +2108,7 @@ void CCC_RegisterCommands()
20982108
CMD4(CCC_Float, "con_sensitive", &g_console_sensitive, 0.01f, 1.0f);
20992109
CMD4(CCC_Integer, "wpn_aim_toggle", &b_toggle_weapon_aim, 0, 1);
21002110

2111+
CMD1(CCC_UIRestart, "ui_restart");
21012112
CMD3(CCC_Token, "ui_style", &UIStyleID, UIStyleToken.data());
21022113

21032114
#ifdef DEBUG

src/xrGame/ui/UIOptionsItem.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ void CUIOptionsItem::SaveOptValue()
7575
m_optionsManager.DoVidRestart();
7676
else if (m_dep == sdSndRestart)
7777
m_optionsManager.DoSndRestart();
78+
else if (m_dep == sdUIRestart)
79+
m_optionsManager.DoUIRestart();
7880
else if (m_dep == sdSystemRestart)
7981
m_optionsManager.DoSystemRestart();
8082
}

src/xrGame/ui/UIOptionsItem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class CUIOptionsItem
1212
sdNothing,
1313
sdVidRestart,
1414
sdSndRestart,
15+
sdUIRestart,
1516
sdSystemRestart,
1617
sdApplyOnChange
1718
};

src/xrGame/ui/UIOptionsManager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,15 @@ void CUIOptionsManager::OptionsPostAccept()
103103
if (m_restart_flags & e_snd_restart)
104104
Console->Execute("snd_restart");
105105

106+
if (m_restart_flags & e_ui_restart)
107+
Console->Execute("ui_restart");
108+
106109
m_restart_flags &= ~e_vid_restart;
107110
m_restart_flags &= ~e_snd_restart;
111+
m_restart_flags &= ~e_ui_restart;
108112
}
109113

110114
void CUIOptionsManager::DoVidRestart() { m_restart_flags |= e_vid_restart; }
111115
void CUIOptionsManager::DoSndRestart() { m_restart_flags |= e_snd_restart; }
116+
void CUIOptionsManager::DoUIRestart() { m_restart_flags |= e_ui_restart; }
112117
void CUIOptionsManager::DoSystemRestart() { m_restart_flags |= e_system_restart; }

src/xrGame/ui/UIOptionsManager.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class CUIOptionsManager
1818
void OptionsPostAccept();
1919
void DoVidRestart();
2020
void DoSndRestart();
21+
void DoUIRestart();
2122
void DoSystemRestart();
2223

2324
bool NeedSystemRestart() { return 0 != (m_restart_flags & e_system_restart); }
@@ -39,7 +40,8 @@ class CUIOptionsManager
3940
{
4041
e_vid_restart = (1 << 0),
4142
e_snd_restart = (1 << 1),
42-
e_system_restart = (1 << 2)
43+
e_ui_restart = (1 << 2),
44+
e_system_restart = (1 << 3)
4345
};
4446
u16 m_restart_flags;
4547
};

src/xrGame/ui/UIXmlInit.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ bool CUIXmlInit::InitOptionsItem(CUIXml& xml_doc, LPCSTR path, int index, CUIOpt
124124
d = CUIOptionsItem::sdVidRestart;
125125
else if (0 == xr_stricmp(depends, "snd"))
126126
d = CUIOptionsItem::sdSndRestart;
127+
else if (0 == xr_stricmp(depends, "ui"))
128+
d = CUIOptionsItem::sdUIRestart;
127129
else if (0 == xr_stricmp(depends, "restart"))
128130
d = CUIOptionsItem::sdSystemRestart;
129131
else if (0 == xr_stricmp(depends, "runtime"))

0 commit comments

Comments
 (0)