From 7c7b01a50676de67d805646ae2997f77d93cfb1e Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 30 Nov 2024 23:17:13 +0100 Subject: close #25 --- src/scenes/place_detail.c | 2 ++ src/scenes/world_map.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/scenes') diff --git a/src/scenes/place_detail.c b/src/scenes/place_detail.c index 372a659..01e7d71 100644 --- a/src/scenes/place_detail.c +++ b/src/scenes/place_detail.c @@ -625,6 +625,8 @@ static void place_detail_draw_active_dealer(platform_window* window, truck_deale btn_x += btn_size; s32 center_btn_w = 100*scale; button_type type2 = purchase_animation.started || swap_animation.started ? BUTTON_STATIC : BUTTON_ENABLED; + if (_active_world->money < tr_curr->price) + type2 = BUTTON_DISABLED; if (button_render(scale, type2, "purchase", btn_x, text_y, center_btn_w, btn_size)) { ADD_EXPENSE(_active_world, _active_location, expenses_from_trucks, tr_curr->price) add_truck_to_world_location(_active_world, _active_location, tr_curr); diff --git a/src/scenes/world_map.c b/src/scenes/world_map.c index 4dfef05..2cf7446 100644 --- a/src/scenes/world_map.c +++ b/src/scenes/world_map.c @@ -848,7 +848,8 @@ static void world_map_draw_purchase_location_panel(platform_window* window) s32 button_w = 178 * scale; s32 button_h = 37 * scale; - if (button_render(scale, true, "Purchase", screen_center_x - (button_w/2), panel_y + panel_h - button_h - vertical_pad, button_w, button_h)) + s32 state = (_active_world->money < world_location_get_price(scene_data.location_to_purchase)) ? BUTTON_DISABLED : BUTTON_ENABLED; + if (button_render(scale, state, "Purchase", screen_center_x - (button_w/2), panel_y + panel_h - button_h - vertical_pad, button_w, button_h)) { // Mark as owned. scene_data.location_to_purchase->is_owned = true; -- cgit v1.2.3-70-g09d2