From 1b10a73237f16f43728b61b24295161650218a05 Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Tue, 10 Jan 2023 07:26:44 -0800 Subject: [PATCH] Close flags and stop input on pick item modal --- main.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/main.c b/main.c index 358f393..1a4d20f 100644 --- a/main.c +++ b/main.c @@ -1064,9 +1064,12 @@ static void ui(bool draw, double dt, double width, double height) // draw pick new box type menu static double pick_opacity = 0.0; + static bool choosing_flags = false; // modifies choosing flags in pick box type modal { if (keypressed[SAPP_KEYCODE_ESCAPE].pressed) picking_new_boxtype = false; + if(picking_new_boxtype) + choosing_flags = false; AABB pick_modal = (AABB){ .x = width * 0.25, .y = height * 0.25, @@ -1074,19 +1077,10 @@ static void ui(bool draw, double dt, double width, double height) .height = height * 0.5, }; pick_opacity = lerp(pick_opacity, picking_new_boxtype ? 1.0 : 0.0, dt * 7.0); - if (picking_new_boxtype) + if (picking_new_boxtype && build_pressed && !has_point(pick_modal, mouse_pos)) { - if (build_pressed) - { - if (has_point(pick_modal, mouse_pos)) - { - } - else - { - build_pressed = false; - picking_new_boxtype = false; - } - } + build_pressed = false; + picking_new_boxtype = false; } static double item_scaling[ARRLEN(boxes)] = {1.0}; { @@ -1158,6 +1152,10 @@ static void ui(bool draw, double dt, double width, double height) cur_column++; } } + if (picking_new_boxtype && build_pressed && has_point(pick_modal, mouse_pos)) + { + build_pressed = false; // modal handles the input + } } // draw squad invite @@ -1294,7 +1292,6 @@ static void ui(bool draw, double dt, double width, double height) static cpVect flag_pos[SquadLast] = {0}; static double flag_rot[SquadLast] = {0}; static double flag_scaling_increase[SquadLast] = {0}; - static bool choosing_flags = false; const double flag_padding = 70.0; const double center_panel_height = 200.0; static double center_panel_width = 0.0;