3
3
#include " ../include/Config.h"
4
4
#include " ../include/Client.h"
5
5
6
+ // int current_profile = 0; // TODO:
7
+
6
8
bool done = false ;
7
9
bool failed_backup;
8
10
bool run_setup;
@@ -63,8 +65,9 @@ int gui_init() {
63
65
ImGui_ImplSDL3_NewFrame ();
64
66
ImGui::NewFrame ();
65
67
66
- if (run_setup && !have_ip) draw_setup ();
67
- if (!connected && have_ip || disconnected_modal) draw_disconnected_alert ();
68
+ if (run_setup && !have_ip) draw_setup ();
69
+ if ((!connected && have_ip) && !kill || disconnected_modal) draw_disconnected_alert ();
70
+ if (kill && !connected) draw_killed ();
68
71
69
72
im_window_flags |= ImGuiWindowFlags_NoDecoration
70
73
| ImGuiWindowFlags_NoDocking
@@ -141,9 +144,9 @@ ImGuiStyle& set_style(/*style parameters*/) {
141
144
142
145
void draw_main (screens current) { // TODO: Create window in main to display tabs, close button etc.
143
146
ImGuiIO& io = ImGui::GetIO ();
147
+ ImGui::SetNextWindowSize (ImVec2 (io.DisplaySize .x , io.DisplaySize .y ));
148
+ ImGui::SetNextWindowPos (ImVec2 (0 .0f , 0 .0f ));
144
149
ImGui::Begin (" main" , NULL , im_window_flags | ImGuiWindowFlags_NoBringToFrontOnFocus); // Allow performance info to always be on top
145
- ImGui::SetWindowSize (ImVec2 (io.DisplaySize .x , io.DisplaySize .y ));
146
- ImGui::SetWindowPos (ImVec2 (0 .0f , 0 .0f ));
147
150
switch (current) {
148
151
case screens::Home:
149
152
draw_home ();
@@ -163,8 +166,8 @@ void draw_button(string label, int index) {
163
166
void draw_home () {
164
167
ImGuiIO& io = ImGui::GetIO ();
165
168
if (!profiles.empty () && !reconfiguring) {
166
- for (int i = 1 ; i <= (profiles[0 ].columns * profiles[0 ].rows ); i++ ) {
167
- ImGui::BeginDisabled (profiles[0 ].buttons [i-1 ].action == " " );
169
+ for (int i = 1 ; i <= (profiles[0 ].columns * profiles[0 ].rows ); ++i ) {
170
+ ImGui::BeginDisabled (profiles[0 ].buttons [i-1 ].action . empty () );
168
171
if (profiles[0 ].buttons [i-1 ].default_label ) draw_button (to_string (i), i);
169
172
else if (profiles[0 ].buttons [i-1 ].label .empty ()) draw_button (" ##" , i);
170
173
else draw_button (profiles[0 ].buttons [i-1 ].label , i);
@@ -179,12 +182,12 @@ void draw_home() {
179
182
if (ImGui::BeginPopupModal (" Reconfiguring" , NULL , im_window_flags)) {
180
183
ImGui::SetNextWindowPos (ImVec2 (io.DisplaySize .x * 0 .5f , io.DisplaySize .y * 0 .5f ), ImGuiCond_Always, ImVec2 (0 .5f ,0 .5f ));
181
184
ImGui::SetWindowFontScale (2 .0f );
182
- ImGui::Text (" Reconfiguring...\n Olease Wait" );
185
+ ImGui::Text (" Reconfiguring...\n Please Wait" );
183
186
ImGui::EndPopup ();
184
187
}
185
188
}
186
189
ImGui::BeginDisabled ();
187
- for (int i = 1 ; i <= 24 ; i++ ) {
190
+ for (int i = 1 ; i <= 24 ; ++i ) {
188
191
ImGui::Button (to_string (i).c_str (), ImVec2 ((io.DisplaySize .x / 6 ), (io.DisplaySize .y / 4 )));
189
192
if (i % 6 != 0 ) ImGui::SameLine ();
190
193
}
@@ -197,8 +200,7 @@ screens get_default_screen() {
197
200
return screens::Home;
198
201
}
199
202
200
- void draw_setup () {
201
- ImGuiIO& io = ImGui::GetIO ();
203
+ void set_popup_style () {
202
204
ImGui::PushStyleVar (ImGuiStyleVar_ItemSpacing, default_style.ItemSpacing );
203
205
ImGui::PushStyleVar (ImGuiStyleVar_ItemInnerSpacing, default_style.ItemInnerSpacing );
204
206
ImGui::PushStyleVar (ImGuiStyleVar_FramePadding, default_style.FramePadding );
@@ -207,45 +209,60 @@ void draw_setup() {
207
209
ImGui::PushStyleVar (ImGuiStyleVar_ChildBorderSize, default_style.ChildBorderSize );
208
210
ImGui::PushStyleVar (ImGuiStyleVar_PopupBorderSize, default_style.PopupBorderSize );
209
211
ImGui::PushStyleVar (ImGuiStyleVar_FrameBorderSize, default_style.FrameBorderSize );
212
+ }
213
+
214
+ void draw_killed () {
215
+ set_popup_style ();
216
+ ImGui::OpenPopup (" Killed" );
217
+ ImVec2 center = ImGui::GetMainViewport ()->GetCenter ();
218
+ ImGui::SetNextWindowPos (center, ImGuiCond_Always, ImVec2 (0 .5f , 0 .5f ));
219
+ if (ImGui::BeginPopupModal (" Killed" , NULL , im_window_flags)) {
220
+ ImGui::SetWindowFontScale (2 .0f );
221
+ ImGui::Text (" Disconnected." );
222
+ ImGui::Text (kill_reason.c_str ());
223
+ if (ImGui::Button (" Reconnect" )) {
224
+ kill = false ;
225
+ disconnected_modal = true ;
226
+ }
227
+ ImGui::EndPopup ();
228
+ }
229
+ ImGui::PopStyleVar (8 );
230
+ }
231
+
232
+ void draw_setup () {
233
+ set_popup_style ();
210
234
ImGui::OpenPopup (" Setup" , im_window_flags);
235
+ ImVec2 center = ImGui::GetMainViewport ()->GetCenter ();
236
+ ImGui::SetNextWindowPos (center, ImGuiCond_Always, ImVec2 (0 .5f , 0 .5f ));
211
237
if (ImGui::BeginPopupModal (" Setup" , NULL , im_window_flags)) {
212
- ImGui::SetNextWindowPos (ImVec2 (io.DisplaySize .x * 0 .5f , io.DisplaySize .y * 0 .5f ), ImGuiCond_Always, ImVec2 (0 .5f ,0 .5f ));
213
238
ImGui::SetWindowFontScale (2 .0f );
214
239
ImGui::BeginDisabled (failed == failed_backup);
215
240
ImGui::Text (" Welcome to NexusShell!" );
216
241
ImGui::Separator ();
217
242
if (!hide_failed) {
218
- if (failed) ImGui::Text (" Connection failed." );
243
+ if (failed) ImGui::Text (" Connection failed." );
219
244
if (connected) run_setup = false ;
220
245
}
221
246
ImGui::Text (" Server IP address:" );
222
- ImGui::InputText (" ##" , ip_address, IM_ARRAYSIZE (ip_address) );
247
+ ImGui::InputText (" ##" , ip_address, 16 );
223
248
if (ImGui::Button (" Connect" )) {
224
249
failed = false ;
225
250
failed_backup = false ;
226
251
hide_failed = false ;
227
252
}
228
253
ImGui::EndDisabled ();
229
- // TODO: virtual_keyboard();
230
254
ImGui::EndPopup ();
231
255
}
232
256
ImGui::PopStyleVar (8 );
233
257
}
234
258
// FIXME: Sluggish font
235
259
void draw_disconnected_alert () {
236
260
if (connected) disconnected_modal = false ;
237
- ImGuiIO& io = ImGui::GetIO ();
238
- ImGui::PushStyleVar (ImGuiStyleVar_ItemSpacing, default_style.ItemSpacing );
239
- ImGui::PushStyleVar (ImGuiStyleVar_ItemInnerSpacing, default_style.ItemInnerSpacing );
240
- ImGui::PushStyleVar (ImGuiStyleVar_FramePadding, default_style.FramePadding );
241
- ImGui::PushStyleVar (ImGuiStyleVar_WindowPadding, default_style.WindowPadding );
242
- ImGui::PushStyleVar (ImGuiStyleVar_WindowBorderSize, default_style.WindowBorderSize );
243
- ImGui::PushStyleVar (ImGuiStyleVar_ChildBorderSize, default_style.ChildBorderSize );
244
- ImGui::PushStyleVar (ImGuiStyleVar_PopupBorderSize, default_style.PopupBorderSize );
245
- ImGui::PushStyleVar (ImGuiStyleVar_FrameBorderSize, default_style.FrameBorderSize );
261
+ set_popup_style ();
246
262
ImGui::OpenPopup (" Disconnected" , im_window_flags);
263
+ ImVec2 center = ImGui::GetMainViewport ()->GetCenter ();
264
+ ImGui::SetNextWindowPos (center, ImGuiCond_Always, ImVec2 (0 .5f , 0 .5f ));
247
265
if (ImGui::BeginPopupModal (" Disconnected" , NULL , im_window_flags)) {
248
- ImGui::SetNextWindowPos (ImVec2 (io.DisplaySize .x * 0 .5f , io.DisplaySize .y * 0 .5f ), ImGuiCond_Always, ImVec2 (0 .5f ,0 .5f ));
249
266
ImGui::SetWindowFontScale (2 .0f );
250
267
failed = false ;
251
268
ImGui::Text (" Disconnected." );
0 commit comments