From cebbaa91a9a57a411736b4148706b6bad621140e Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 1 Dec 2024 14:12:42 +0100 Subject: close #30 --- src/scenes/place_detail.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/scenes') diff --git a/src/scenes/place_detail.c b/src/scenes/place_detail.c index d5c0790..e312650 100644 --- a/src/scenes/place_detail.c +++ b/src/scenes/place_detail.c @@ -984,6 +984,7 @@ static void draw_duration_of_scheduled_job_entry(scheduled_job job, scheduled_jo if (overflow_to_next_day > 0) renderer->render_rectangle(TILE_X(0), highlight_y, timeslot_w*overflow_to_next_day, timeslot_h, tile_color_bg); } +static bool termination_popup_active = false; static void place_detail_draw_schedule(platform_window* window) { float offset = scale * 40.0; @@ -1043,6 +1044,22 @@ static void place_detail_draw_schedule(platform_window* window) _active_schedule_state = RESCHEDULING_JOB; _active_scheduling_job = *_active_selected_scheduled_job; } + + btn_y += btn_pad + button_h; + char* terminate_txt = termination_popup_active ? "Confirm?" : "Cancel Job"; + s32 terminate_type = termination_popup_active ? BUTTON_HIGHLIGHTED : BUTTON_ENABLED; + if (button_render(scale, terminate_type, terminate_txt, x-button_w+w, btn_y, button_w, button_h)) { + + if (termination_popup_active) { + array_remove_by(&_active_location->schedule.jobs, _active_selected_scheduled_job); + audio_play_sound(snd_click3, AUDIO_CHANNEL_SFX_1); + _active_selected_scheduled_job = 0; + termination_popup_active = false; + } + else { + termination_popup_active = true; + } + } } s32 options_w = 230*scale; @@ -1752,6 +1769,7 @@ static void place_detail_draw_panel(platform_window* window) s32 back_y = panel_y + panel_h - (back_h/2) - 1; if (push_back_button(scale, back_x, back_y, back_w, back_h)) { + termination_popup_active = false; if (current_detail_state == PLACE_DETAIL_SHOW_MAIN) { game_set_active_scene(GAME_STATE_WORLD_MAP); } @@ -1815,6 +1833,7 @@ void place_detail_scene_update(platform_window* window) // world_update(window, _active_world, false); if (keyboard_is_key_pressed(KEY_ESCAPE)) { + termination_popup_active = false; if (current_detail_state == PLACE_DETAIL_SHOW_MAIN) { game_set_active_scene(GAME_STATE_WORLD_MAP); } -- cgit v1.2.3-70-g09d2