-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUI.cpp
More file actions
166 lines (135 loc) · 4.16 KB
/
UI.cpp
File metadata and controls
166 lines (135 loc) · 4.16 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#include "UI.h"
#include "imgui.h"
#include "imgui_stdlib.h"
#include "ViewModel.h"
#include "PartyUI.h"
#include "GameFinderUI.h"
#include "GameSessionUI.h"
#include "FriendsUI.h"
void ShowUI(AppViewModel& vm)
{
ShowMainMenu(vm);
if (vm.showSettingsWindow)
{
ShowSettings(vm.settings);
}
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
if (vm.showDemoWindow)
{
::ImGui::ShowDemoWindow(&vm.showDemoWindow);
}
for (auto clientVm : vm.clients)
{
ShowClient(*clientVm);
}
}
void ShowMainMenu(AppViewModel& vm)
{
ImGui::BeginMainMenuBar();
if (ImGui::BeginMenu("Clients"))
{
ImGui::MenuItem("Add", nullptr, &vm.addClientCmd);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Windows"))
{
ImGui::MenuItem("Settings", nullptr, &vm.showSettingsWindow);
ImGui::MenuItem("Imgui Demo", nullptr, &vm.showDemoWindow);
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
void ShowSettings(SettingsViewModel& vm)
{
ImGui::Begin("Settings", &vm.parent->showSettingsWindow);
ImGui::InputTextWithHint("Endpoint", "Server endpoint.", &vm.endpoint);
ImGui::InputTextWithHint("Account", "Application's account.", &vm.account);
ImGui::InputTextWithHint("Application", "Application's name.", &vm.application);
ImGui::InputTextWithHint("Game version", "game version.", &vm.gameVersion);
#if defined(ENABLE_EPIC)
if (ImGui::CollapsingHeader("Epic Online Services", ImGuiTreeNodeFlags_None))
{
ImGui::Checkbox("Enabled", &vm.epicSettings.enabled);
ImGui::InputTextWithHint("Product name", "Product name", &vm.epicSettings.productName);
ImGui::InputTextWithHint("Product version", "Product version", &vm.epicSettings.productVersion);
ImGui::InputTextWithHint("Login mode", "Login mode", &vm.epicSettings.loginMode);
ImGui::InputTextWithHint("DevAuth host", "DevAuth host", &vm.epicSettings.devAuthHost);
ImGui::InputTextWithHint("DevAuth credentials name", "DevAuth credentials name", &vm.epicSettings.devAuthCredentialsName);
ImGui::InputTextWithHint("Product Id", "Product Id", &vm.epicSettings.productId);
ImGui::InputTextWithHint("Sandbox Id", "Sandbox Id", &vm.epicSettings.sandboxId);
ImGui::InputTextWithHint("Deployment Id", "Deployment Id", &vm.epicSettings.deploymentId);
ImGui::InputTextWithHint("Client Id", "Client Id", &vm.epicSettings.clientId);
ImGui::InputTextWithHint("Client Secret", "Client Secret", &vm.epicSettings.clientSecret);
}
#endif
ImGui::End();
}
void ShowClient(ClientViewModel& vm)
{
auto title = "Client " + std::to_string(vm.id);
ImGui::Begin(title.c_str(), &vm.running);
ImGui::Text(vm.getServerApp().c_str());
ImGui::Text(vm.getConnectionStatus());
ImGui::Text(vm.getSessionId().c_str());
if (ImGui::Button("Show logs"))
{
vm.showLogsWindow = true;
}
if (vm.showLogsWindow)
{
vm.logs.Draw(("logs " + title).c_str(), &vm.showLogsWindow);
}
bool processing = vm.isProcessing;
if (processing)
{
ImGui::BeginDisabled();
}
if (ImGui::CollapsingHeader("Connection", ImGuiTreeNodeFlags_None))
{
ImGui::InputTextWithHint("Device identifier", "Device identifier", &vm.deviceIdentifier);
std::vector<std::string> providers = vm.authenticationProviders;
if (ImGui::BeginCombo("Authentication Provider", vm.authenticationProvider.c_str()))
{
for (auto provider : providers)
{
const bool is_selected = provider == vm.authenticationProvider;
if (ImGui::Selectable(provider.c_str(), is_selected))
{
vm.authenticationProvider = provider;
}
}
ImGui::EndCombo();
}
if (ImGui::Button("Connect"))
{
vm.connect();
}
if (ImGui::Button("Disconnect"))
{
vm.disconnect();
}
}
if (ImGui::CollapsingHeader("Party", ImGuiTreeNodeFlags_None))
{
ShowUI(vm.party);
}
if (ImGui::CollapsingHeader("GameFinder", ImGuiTreeNodeFlags_None))
{
ShowUI(vm.gameFinder);
}
if (ImGui::CollapsingHeader("GameSession", ImGuiTreeNodeFlags_None))
{
float deltaTime = vm.deltaTime;
ShowUI(vm.gameSession,deltaTime);
}
if (ImGui::CollapsingHeader("Friends", ImGuiTreeNodeFlags_None))
{
float deltaTime = vm.deltaTime;
ShowUI(vm.friends);
}
if (processing)
{
ImGui::EndDisabled();
}
ImGui::End();
}