Skip to content

Commit

Permalink
Preparations for UI restart command
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Jul 27, 2018
1 parent 4ab8854 commit d47af9c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/xrGame/console_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,16 @@ class CCC_MainMenu : public IConsole_Command
}
};

class CCC_UIRestart : public IConsole_Command
{
public:
CCC_UIRestart(pcstr name) : IConsole_Command(name) { bEmptyArgsHandled = true; }

void Execute(pcstr /*args*/) override
{
}
};

struct CCC_StartTimeSingle : public IConsole_Command
{
CCC_StartTimeSingle(LPCSTR N) : IConsole_Command(N){};
Expand Down Expand Up @@ -2098,6 +2108,7 @@ void CCC_RegisterCommands()
CMD4(CCC_Float, "con_sensitive", &g_console_sensitive, 0.01f, 1.0f);
CMD4(CCC_Integer, "wpn_aim_toggle", &b_toggle_weapon_aim, 0, 1);

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

#ifdef DEBUG
Expand Down
2 changes: 2 additions & 0 deletions src/xrGame/ui/UIOptionsItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ void CUIOptionsItem::SaveOptValue()
m_optionsManager.DoVidRestart();
else if (m_dep == sdSndRestart)
m_optionsManager.DoSndRestart();
else if (m_dep == sdUIRestart)
m_optionsManager.DoUIRestart();
else if (m_dep == sdSystemRestart)
m_optionsManager.DoSystemRestart();
}
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/ui/UIOptionsItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class CUIOptionsItem
sdNothing,
sdVidRestart,
sdSndRestart,
sdUIRestart,
sdSystemRestart,
sdApplyOnChange
};
Expand Down
5 changes: 5 additions & 0 deletions src/xrGame/ui/UIOptionsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,15 @@ void CUIOptionsManager::OptionsPostAccept()
if (m_restart_flags & e_snd_restart)
Console->Execute("snd_restart");

if (m_restart_flags & e_ui_restart)
Console->Execute("ui_restart");

m_restart_flags &= ~e_vid_restart;
m_restart_flags &= ~e_snd_restart;
m_restart_flags &= ~e_ui_restart;
}

void CUIOptionsManager::DoVidRestart() { m_restart_flags |= e_vid_restart; }
void CUIOptionsManager::DoSndRestart() { m_restart_flags |= e_snd_restart; }
void CUIOptionsManager::DoUIRestart() { m_restart_flags |= e_ui_restart; }
void CUIOptionsManager::DoSystemRestart() { m_restart_flags |= e_system_restart; }
4 changes: 3 additions & 1 deletion src/xrGame/ui/UIOptionsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CUIOptionsManager
void OptionsPostAccept();
void DoVidRestart();
void DoSndRestart();
void DoUIRestart();
void DoSystemRestart();

bool NeedSystemRestart() { return 0 != (m_restart_flags & e_system_restart); }
Expand All @@ -39,7 +40,8 @@ class CUIOptionsManager
{
e_vid_restart = (1 << 0),
e_snd_restart = (1 << 1),
e_system_restart = (1 << 2)
e_ui_restart = (1 << 2),
e_system_restart = (1 << 3)
};
u16 m_restart_flags;
};
2 changes: 2 additions & 0 deletions src/xrGame/ui/UIXmlInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ bool CUIXmlInit::InitOptionsItem(CUIXml& xml_doc, LPCSTR path, int index, CUIOpt
d = CUIOptionsItem::sdVidRestart;
else if (0 == xr_stricmp(depends, "snd"))
d = CUIOptionsItem::sdSndRestart;
else if (0 == xr_stricmp(depends, "ui"))
d = CUIOptionsItem::sdUIRestart;
else if (0 == xr_stricmp(depends, "restart"))
d = CUIOptionsItem::sdSystemRestart;
else if (0 == xr_stricmp(depends, "runtime"))
Expand Down

0 comments on commit d47af9c

Please sign in to comment.