-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFrontendScreen.cpp
More file actions
106 lines (82 loc) · 2.6 KB
/
Copy pathFrontendScreen.cpp
File metadata and controls
106 lines (82 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "stdafx.h"
#include "FrontendScreen.h"
#include "FrontendController.h"
#include "GameMain.h"
#include "Version.h"
#include "UiTextBox.h"
//////////////////////////////////////////////////////////////////////////
static const std::string uiscreen_json_path = "ui/frontend_screen.json";
//////////////////////////////////////////////////////////////////////////
enum eMainMenuNotifictionId
{
eMainMenuNotifictionId_None = 0,
eMainMenuNotifictionId_SinglePlayer = 100,
eMainMenuNotifictionId_Quit,
};
//////////////////////////////////////////////////////////////////////////
FrontendScreen::FrontendScreen(FrontendController& frontend)
: mFrontend(frontend)
{
}
bool FrontendScreen::LoadContent()
{
if (!UiView::LoadContent())
{
if (mHierarchy.LoadFrom(uiscreen_json_path))
{
if (UiWidget* uiWidget = mHierarchy.FindWidgetWithName("single_player"))
{
uiWidget->Subscribe(this);
uiWidget->UserData().SetValue(eMainMenuNotifictionId_SinglePlayer);
}
if (UiWidget* uiWidget = mHierarchy.FindWidgetWithName("quit"))
{
uiWidget->Subscribe(this);
uiWidget->UserData().SetValue(eMainMenuNotifictionId_Quit);
}
if (UiWidget* uiWidget = mHierarchy.FindWidgetWithName("version_string"))
{
UiTextBox* textBox = (UiTextBox*) uiWidget;
// set version string
std::wstring versionNumber {GAME_VERSION_STRING, GAME_VERSION_STRING + sizeof(GAME_VERSION_STRING)};
versionNumber.insert(versionNumber.begin(), L'V');
textBox->SetText(versionNumber);
}
}
else
{
cxx_assert(false);
}
}
return IsHierarchyLoaded();
}
void FrontendScreen::Cleanup()
{
UiView::Cleanup();
}
void FrontendScreen::InputEvent(KeyInputEvent& inputEvent)
{
}
void FrontendScreen::UpdateFrame(float deltaTime)
{
}
void FrontendScreen::OnActivated()
{
}
void FrontendScreen::OnDeactivated()
{
}
void FrontendScreen::HandleUiEvent(UiWidget* sender, const UiEventDesc* eventDesc)
{
eMainMenuNotifictionId notificationId = sender->UserData().GetValue<eMainMenuNotifictionId>();
if (notificationId == eMainMenuNotifictionId_Quit)
{
mFrontend.OnQuitGameSelected();
return;
}
if (notificationId == eMainMenuNotifictionId_SinglePlayer)
{
mFrontend.OnStartSinglePlayerGameSelected();
return;
}
}