Skip to content

Commit 9d5e0fc

Browse files
committed
Preparations for UI restart (Part III)
Second part: 685e47d
1 parent a4f3a0b commit 9d5e0fc

19 files changed

+68
-38
lines changed

src/xrEngine/CustomHUD.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ ENGINE_API CCustomHUD* g_hud = NULL;
99
CCustomHUD::CCustomHUD()
1010
{
1111
g_hud = this;
12-
Device.seqResolutionChanged.Add(this);
1312
}
1413

1514
CCustomHUD::~CCustomHUD()
1615
{
1716
g_hud = NULL;
18-
Device.seqResolutionChanged.Remove(this);
1917
}

src/xrEngine/CustomHUD.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ ENGINE_API extern Flags32 psHUD_Flags;
1919

2020
class IGameObject;
2121

22-
class ENGINE_API CCustomHUD : public FactoryObjectBase, public IEventReceiver, public pureScreenResolutionChanged
22+
class ENGINE_API CCustomHUD : public FactoryObjectBase, public IEventReceiver,
23+
public CUIResetAndResolutionNotifier
2324
{
2425
public:
2526
CCustomHUD();

src/xrEngine/XR_IOConsole.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ CConsole::CConsole() : m_hShader_back(NULL)
9696
m_cmd_history_max = cmd_history_max;
9797
m_disable_tips = false;
9898
Register_callbacks();
99-
Device.seqResolutionChanged.Add(this);
10099
}
101100

102101
void CConsole::Initialize()
@@ -134,7 +133,6 @@ CConsole::~CConsole()
134133
xr_delete(m_hShader_back);
135134
xr_delete(m_editor);
136135
Destroy();
137-
Device.seqResolutionChanged.Remove(this);
138136
}
139137

140138
void CConsole::Destroy()
@@ -203,7 +201,7 @@ void CConsole::OutFont(LPCSTR text, float& pos_y)
203201
}
204202
}
205203

206-
void CConsole::OnScreenResolutionChanged()
204+
void CConsole::OnUIReset()
207205
{
208206
xr_delete(pFont);
209207
xr_delete(pFont2);

src/xrEngine/XR_IOConsole.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ struct TipString
5050
IC bool operator==(shared_str const& tips_text) { return (text == tips_text); }
5151
};
5252

53-
class ENGINE_API CConsole : public pureRender, public pureFrame, public pureScreenResolutionChanged
53+
class ENGINE_API CConsole : public pureRender, public pureFrame,
54+
public CUIResetAndResolutionNotifier
5455
{
5556
public:
5657
struct str_pred
@@ -109,7 +110,9 @@ class ENGINE_API CConsole : public pureRender, public pureFrame, public pureScre
109110

110111
virtual void OnRender();
111112
virtual void OnFrame();
112-
virtual void OnScreenResolutionChanged();
113+
114+
void OnUIReset() override;
115+
113116
string64 ConfigFile;
114117
bool bVisible;
115118
vecCMD Commands;

src/xrEngine/device.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ class ENGINE_API CRenderDevice : public CRenderDeviceBase
203203

204204
MessageRegistry<pureFrame> seqFrameMT;
205205
MessageRegistry<pureDeviceReset> seqDeviceReset;
206+
MessageRegistry<pureUIReset> seqUIReset;
206207
xr_vector<fastdelegate::FastDelegate0<>> seqParallel;
207208
CSecondVPParams m_SecondViewport; //--#SM+#-- +SecondVP+
208209

@@ -347,4 +348,39 @@ class ENGINE_API CLoadScreenRenderer : public pureRender
347348
};
348349
extern ENGINE_API CLoadScreenRenderer load_screen_renderer;
349350

351+
class CDeviceResetNotifier : public pureDeviceReset
352+
{
353+
public:
354+
CDeviceResetNotifier() { Device.seqDeviceReset.Add(this, REG_PRIORITY_NORMAL); }
355+
virtual ~CDeviceResetNotifier() { Device.seqDeviceReset.Remove(this); }
356+
void OnDeviceReset() override {}
357+
};
358+
359+
class CUIResetNotifier : public pureUIReset
360+
{
361+
public:
362+
CUIResetNotifier() { Device.seqUIReset.Add(this, REG_PRIORITY_NORMAL); }
363+
virtual ~CUIResetNotifier() { Device.seqUIReset.Remove(this); }
364+
void OnUIReset() override {}
365+
};
366+
367+
class CUIResetAndResolutionNotifier : public pureUIReset, pureScreenResolutionChanged
368+
{
369+
public:
370+
CUIResetAndResolutionNotifier()
371+
{
372+
Device.seqUIReset.Add(this, REG_PRIORITY_NORMAL);
373+
Device.seqResolutionChanged.Add(this, REG_PRIORITY_NORMAL);
374+
}
375+
376+
virtual ~CUIResetAndResolutionNotifier()
377+
{
378+
Device.seqUIReset.Remove(this);
379+
Device.seqResolutionChanged.Remove(this);
380+
}
381+
382+
void OnUIReset() override {}
383+
void OnScreenResolutionChanged() override { OnUIReset(); }
384+
};
385+
350386
#endif

src/xrEngine/pure.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ DECLARE_MESSAGE(AppDeactivate);
3030
DECLARE_MESSAGE(AppStart);
3131
DECLARE_MESSAGE(AppEnd);
3232
DECLARE_MESSAGE(DeviceReset);
33+
DECLARE_MESSAGE(UIReset);
3334
DECLARE_MESSAGE(ScreenResolutionChanged);
3435

3536
struct MessageObject

src/xrGame/HUDManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void CHUDManager::Load()
227227
}
228228
}
229229

230-
void CHUDManager::OnScreenResolutionChanged()
230+
void CHUDManager::OnUIReset()
231231
{
232232
pUIGame->HideShownDialogs();
233233

src/xrGame/HUDManager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ class CHUDManager : public CCustomHUD
5151
void SetHitmarkType(LPCSTR tex_name);
5252
void SetGrenadeMarkType(LPCSTR tex_name);
5353

54-
virtual void OnScreenResolutionChanged();
54+
void OnUIReset() override;
55+
5556
virtual void Load();
5657
virtual void OnDisconnected();
5758
virtual void OnConnected();

src/xrGame/MainMenu.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,10 @@ CMainMenu::CMainMenu()
148148
}
149149

150150
Device.seqFrame.Add(this, REG_PRIORITY_LOW - 1000);
151-
Device.seqResolutionChanged.Add(this);
152151
}
153152

154153
CMainMenu::~CMainMenu()
155154
{
156-
Device.seqResolutionChanged.Remove(this);
157155
Device.seqFrame.Remove(this);
158156

159157
xr_delete(g_btnHint);
@@ -765,8 +763,9 @@ void CMainMenu::OnDeviceReset()
765763
SetNeedVidRestart();
766764
}
767765

768-
void CMainMenu::OnScreenResolutionChanged()
766+
void CMainMenu::OnUIReset()
769767
{
768+
CUIXmlInitBase::InitColorDefs();
770769
ReadTextureInfo();
771770
ReloadUI();
772771
}

src/xrGame/MainMenu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class CMainMenu : public IMainMenu,
5050
public CDialogHolder,
5151
public CUIWndCallback,
5252
public CDeviceResetNotifier,
53-
public pureScreenResolutionChanged
53+
public CUIResetNotifier
5454
{
5555
CUIDialogWnd* m_startDialog;
5656

@@ -193,7 +193,7 @@ class CMainMenu : public IMainMenu,
193193
void Hide_CTMS_Dialog();
194194
void SetNeedVidRestart();
195195
virtual void OnDeviceReset();
196-
void OnScreenResolutionChanged() override;
196+
void OnUIReset() override;
197197
LPCSTR GetGSVer();
198198

199199
bool IsCDKeyIsValid();

0 commit comments

Comments
 (0)