Skip to content

Commit 95beefb

Browse files
committed
hide close button on first run dialog
The X button was visible but non-functional since the return value was ignored. Added closable parameter to DrawMaterialWindow and pass false for the first run dialog so users must pick a graphics profile.
1 parent 88393de commit 95beefb

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

src/ui.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ static void AdvancedTextBox(Rectangle bounds, char *text, int bufSize, bool *edi
983983
}
984984
}
985985

986-
static bool DrawMaterialWindow(Rectangle bounds, const char *title, AppConfig *cfg, Font font)
986+
static bool DrawMaterialWindow(Rectangle bounds, const char *title, AppConfig *cfg, Font font, bool closable)
987987
{
988988
float scale = cfg->ui_scale;
989989
float header_h = 24 * scale;
@@ -1009,19 +1009,21 @@ static bool DrawMaterialWindow(Rectangle bounds, const char *title, AppConfig *c
10091009

10101010
DrawLineEx((Vector2){bounds.x + 2 * scale, bounds.y + header_h}, (Vector2){bounds.x + bounds.width - 2 * scale, bounds.y + header_h}, 1.0f, cfg->window_border);
10111011

1012+
if (!closable) return false;
1013+
10121014
float btn_size = header_h - 8 * scale;
10131015
Rectangle closeBtn = {bounds.x + bounds.width - btn_size - 6 * scale, bounds.y + 4 * scale, btn_size, btn_size};
1014-
1016+
10151017
bool hover = CheckCollisionPointRec(GetMousePosition(), closeBtn);
10161018
bool clicked = false;
1017-
1019+
10181020
if (hover) {
10191021
DrawRectangleRounded(closeBtn, 0.3f, 8, ApplyAlpha(RED, 0.8f));
10201022
if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) clicked = true;
10211023
} else {
10221024
DrawRectangleRounded(closeBtn, 0.3f, 8, ApplyAlpha(cfg->window_border, 0.3f));
10231025
}
1024-
1026+
10251027
float pad = closeBtn.width * 0.3f;
10261028
DrawLineEx((Vector2){closeBtn.x + pad, closeBtn.y + pad}, (Vector2){closeBtn.x + closeBtn.width - pad, closeBtn.y + closeBtn.height - pad}, 2.0f, cfg->text_main);
10271029
DrawLineEx((Vector2){closeBtn.x + closeBtn.width - pad, closeBtn.y + pad}, (Vector2){closeBtn.x + pad, closeBtn.y + closeBtn.height - pad}, 2.0f, cfg->text_main);
@@ -1649,7 +1651,7 @@ void DrawGUI(UIContext *ctx, AppConfig *cfg, Font customFont)
16491651
tm_y = GetMousePosition().y - drag_tle_mgr_off.y;
16501652
SnapWindow(&tm_x, &tm_y, tmMgrWindow.width, tmMgrWindow.height, cfg);
16511653
}
1652-
if (DrawMaterialWindow(tmMgrWindow, "#1# TLE Manager", cfg, customFont))
1654+
if (DrawMaterialWindow(tmMgrWindow, "#1# TLE Manager", cfg, customFont, true))
16531655
show_tle_mgr_dialog = false;
16541656

16551657
char age_str[64] = "TLE Age: Unknown";
@@ -1882,7 +1884,7 @@ void DrawGUI(UIContext *ctx, AppConfig *cfg, Font customFont)
18821884
sm_y = GetMousePosition().y - drag_sat_mgr_off.y;
18831885
SnapWindow(&sm_x, &sm_y, smWindow.width, smWindow.height, cfg);
18841886
}
1885-
if (DrawMaterialWindow(smWindow, "#43# Satellite Manager", cfg, customFont))
1887+
if (DrawMaterialWindow(smWindow, "#43# Satellite Manager", cfg, customFont, true))
18861888
show_sat_mgr_dialog = false;
18871889

18881890
AdvancedTextBox((Rectangle){sm_x + 10 * cfg->ui_scale, sm_y + 35 * cfg->ui_scale, smWindow.width - 90 * cfg->ui_scale, 24 * cfg->ui_scale}, sat_search_text, 64, &edit_sat_search, false);
@@ -2012,7 +2014,7 @@ void DrawGUI(UIContext *ctx, AppConfig *cfg, Font customFont)
20122014
hw_y = GetMousePosition().y - drag_help_off.y;
20132015
SnapWindow(&hw_x, &hw_y, helpWindow.width, helpWindow.height, cfg);
20142016
}
2015-
if (DrawMaterialWindow(helpWindow, "#193# Help & Controls", cfg, customFont))
2017+
if (DrawMaterialWindow(helpWindow, "#193# Help & Controls", cfg, customFont, true))
20162018
show_help = false;
20172019

20182020
Rectangle contentRec = {0, 0, helpWindow.width - 32 * cfg->ui_scale, 620 * cfg->ui_scale};
@@ -2129,7 +2131,7 @@ void DrawGUI(UIContext *ctx, AppConfig *cfg, Font customFont)
21292131
sw_y = GetMousePosition().y - drag_settings_off.y;
21302132
SnapWindow(&sw_x, &sw_y, settingsWindow.width, settingsWindow.height, cfg);
21312133
}
2132-
if (DrawMaterialWindow(settingsWindow, "#142# Settings", cfg, customFont))
2134+
if (DrawMaterialWindow(settingsWindow, "#142# Settings", cfg, customFont, true))
21332135
show_settings = false;
21342136

21352137
float sy = sw_y + 40 * cfg->ui_scale;
@@ -2251,7 +2253,7 @@ void DrawGUI(UIContext *ctx, AppConfig *cfg, Font customFont)
22512253
td_y = GetMousePosition().y - drag_time_off.y;
22522254
SnapWindow(&td_x, &td_y, timeWindow.width, timeWindow.height, cfg);
22532255
}
2254-
if (DrawMaterialWindow(timeWindow, "#139# Set Date & Time (UTC)", cfg, customFont))
2256+
if (DrawMaterialWindow(timeWindow, "#139# Set Date & Time (UTC)", cfg, customFont, true))
22552257
show_time_dialog = false;
22562258

22572259
float cur_y = td_y + 35 * cfg->ui_scale;
@@ -2317,7 +2319,7 @@ void DrawGUI(UIContext *ctx, AppConfig *cfg, Font customFont)
23172319
pd_y = GetMousePosition().y - drag_passes_off.y;
23182320
SnapWindow(&pd_x, &pd_y, passesWindow.width, passesWindow.height, cfg);
23192321
}
2320-
if (DrawMaterialWindow(passesWindow, "#208# Upcoming Passes", cfg, customFont))
2322+
if (DrawMaterialWindow(passesWindow, "#208# Upcoming Passes", cfg, customFont, true))
23212323
show_passes_dialog = false;
23222324

23232325
if (GuiButton(
@@ -2449,7 +2451,7 @@ void DrawGUI(UIContext *ctx, AppConfig *cfg, Font customFont)
24492451
pl_y = GetMousePosition().y - drag_polar_off.y;
24502452
SnapWindow(&pl_x, &pl_y, polarWindow.width, polarWindow.height, cfg);
24512453
}
2452-
if (DrawMaterialWindow(polarWindow, "#64# Polar Tracking Plot", cfg, customFont))
2454+
if (DrawMaterialWindow(polarWindow, "#64# Polar Tracking Plot", cfg, customFont, true))
24532455
show_polar_dialog = false;
24542456

24552457
if (GuiButton((Rectangle){pl_x + 10 * cfg->ui_scale, pl_y + 30 * cfg->ui_scale, polarWindow.width - 20 * cfg->ui_scale, 24 * cfg->ui_scale}, polar_lunar_mode ? "Mode: Lunar Tracking" : "Mode: Satellite Pass")) {
@@ -2639,7 +2641,7 @@ void DrawGUI(UIContext *ctx, AppConfig *cfg, Font customFont)
26392641
dop_y = GetMousePosition().y - drag_doppler_off.y;
26402642
SnapWindow(&dop_x, &dop_y, dopplerWindow.width, dopplerWindow.height, cfg);
26412643
}
2642-
if (DrawMaterialWindow(dopplerWindow, "#125# Doppler Shift Analysis", cfg, customFont))
2644+
if (DrawMaterialWindow(dopplerWindow, "#125# Doppler Shift Analysis", cfg, customFont, true))
26432645
show_doppler_dialog = false;
26442646

26452647
if (selected_pass_idx >= 0 && selected_pass_idx < num_passes)
@@ -2790,7 +2792,7 @@ case WND_SCOPE:
27902792
sc_y = GetMousePosition().y - drag_scope_off.y;
27912793
SnapWindow(&sc_x, &sc_y, scopeWindow.width, scopeWindow.height, cfg);
27922794
}
2793-
if (DrawMaterialWindow(scopeWindow, "#103# Satellite Scope", cfg, customFont))
2795+
if (DrawMaterialWindow(scopeWindow, "#103# Satellite Scope", cfg, customFont, true))
27942796
show_scope_dialog = false;
27952797

27962798
/* auto-aim scope if locked to a satellite */
@@ -3128,7 +3130,7 @@ case WND_SCOPE:
31283130
si_y = GetMousePosition().y - drag_sat_info_off.y;
31293131
SnapWindow(&si_x, &si_y, satInfoWindow.width, satInfoWindow.height, cfg);
31303132
}
3131-
if (DrawMaterialWindow(satInfoWindow, TextFormat("#11# %s", (*ctx->selected_sat)->name), cfg, customFont))
3133+
if (DrawMaterialWindow(satInfoWindow, TextFormat("#11# %s", (*ctx->selected_sat)->name), cfg, customFont, true))
31323134
{
31333135
show_sat_info_dialog = false;
31343136
*ctx->selected_sat = NULL;
@@ -3268,7 +3270,7 @@ case WND_SCOPE:
32683270
if (show_tle_warning)
32693271
{
32703272
Rectangle tleWarnWindow = {(GetScreenWidth() - 480 * cfg->ui_scale) / 2.0f, (GetScreenHeight() - 160 * cfg->ui_scale) / 2.0f, 480 * cfg->ui_scale, 160 * cfg->ui_scale};
3271-
if (DrawMaterialWindow(tleWarnWindow, "#193# TLEs Outdated", cfg, customFont))
3273+
if (DrawMaterialWindow(tleWarnWindow, "#193# TLEs Outdated", cfg, customFont, true))
32723274
show_tle_warning = false;
32733275

32743276
long days_old = data_tle_epoch > 0 ? (time(NULL) - data_tle_epoch) / 86400 : 999;
@@ -3310,8 +3312,8 @@ case WND_SCOPE:
33103312
{
33113313
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), cfg->overlay_dim);
33123314
Rectangle frRec = {(GetScreenWidth() - 520 * cfg->ui_scale) / 2.0f, (GetScreenHeight() - 240 * cfg->ui_scale) / 2.0f, 520 * cfg->ui_scale, 240 * cfg->ui_scale};
3313-
DrawMaterialWindow(frRec, "#198# Welcome to TLEscope!", cfg, customFont);
3314-
3315+
DrawMaterialWindow(frRec, "#198# Welcome to TLEscope!", cfg, customFont, false);
3316+
33153317
const char* msg1 = "Please select a graphics profile for your first run:";
33163318
Vector2 msg1Size = MeasureTextEx(customFont, msg1, 16 * cfg->ui_scale, 1.0f);
33173319
DrawUIText(customFont, msg1, frRec.x + (frRec.width - msg1Size.x) / 2.0f, frRec.y + 45 * cfg->ui_scale, 16 * cfg->ui_scale, cfg->text_main);
@@ -3487,7 +3489,7 @@ case WND_SCOPE:
34873489
{
34883490
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), ApplyAlpha(cfg->overlay_dim, 150.0f / 180.0f));
34893491
Rectangle exitRec = {(GetScreenWidth() - 300 * cfg->ui_scale) / 2.0f, (GetScreenHeight() - 140 * cfg->ui_scale) / 2.0f, 300 * cfg->ui_scale, 140 * cfg->ui_scale};
3490-
if (DrawMaterialWindow(exitRec, "#159# Exit Application", cfg, customFont))
3492+
if (DrawMaterialWindow(exitRec, "#159# Exit Application", cfg, customFont, true))
34913493
show_exit_dialog = false;
34923494
DrawUIText(customFont, "Are you sure you want to exit?", exitRec.x + 25 * cfg->ui_scale, exitRec.y + 45 * cfg->ui_scale, 16 * cfg->ui_scale, cfg->text_main);
34933495
if (GuiButton((Rectangle){exitRec.x + 20 * cfg->ui_scale, exitRec.y + 85 * cfg->ui_scale, 120 * cfg->ui_scale, 30 * cfg->ui_scale}, "Yes"))

0 commit comments

Comments
 (0)