From 7b565582f6daa03ff488798013ac720cc47b8a07 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Wed, 4 Dec 2024 16:09:50 +0100 Subject: small improvements, close #48 --- src/include/world.h | 2 +- src/scenes/world_map.c | 11 +++++++---- src/world.c | 17 +++++++++++++---- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/include/world.h b/src/include/world.h index 5d76991..4407fcb 100644 --- a/src/include/world.h +++ b/src/include/world.h @@ -408,7 +408,7 @@ world_location* get_world_location_by_name(world* world, char* str); float world_location_get_price(world_location* location); void add_truck_to_world_location(world* world, world_location* location, truck* tr); void world_update(platform_window* window, world* world); -world_update_result world_render(platform_window* window, world* world); +world_update_result world_render(platform_window* window, world* world, bool interactive); company* world_get_company_by_name(world* world, char* str); product* world_get_product_by_name(world* world, char* str); truck* world_get_truck_by_type(world* world, s32 type); diff --git a/src/scenes/world_map.c b/src/scenes/world_map.c index 3ef4cdb..792f5d0 100644 --- a/src/scenes/world_map.c +++ b/src/scenes/world_map.c @@ -27,6 +27,7 @@ void place_detail_show_schedule_with_highlighted_job(world_location* loc, schedu void world_map_set_active_world(world* world) { + scene_state = WORLD_SCENE_STATE_IDLE; _active_world = world; } @@ -1227,22 +1228,24 @@ static void world_map_draw_menu(platform_window* window) if (button_render(scale, BUTTON_ENABLED, "Save", panel_x + pad_x, vertical_pad + panel_y + pad_y*2 + button_h*1, button_w, button_h)) { game_set_active_scene(GAME_STATE_SELECT_SAVE); - scene_state = WORLD_SCENE_STATE_IDLE; + //scene_state = WORLD_SCENE_STATE_IDLE; is_selecting_save_location = true; } if (button_render(scale, BUTTON_ENABLED, "Settings", panel_x + pad_x, vertical_pad + panel_y + pad_y*3 + button_h*2, button_w, button_h)) { game_set_active_scene(GAME_STATE_SETTINGS); - scene_state = WORLD_SCENE_STATE_IDLE; + //scene_state = WORLD_SCENE_STATE_IDLE; is_editing_settings_from_ingame = true; } if (button_render(scale, BUTTON_ENABLED, "Quit", panel_x + pad_x, vertical_pad + panel_y + pad_y*4 + button_h*3, button_w, button_h)) { game_set_active_scene(GAME_STATE_MENU); - scene_state = WORLD_SCENE_STATE_IDLE; + //scene_state = WORLD_SCENE_STATE_IDLE; } + + is_left_clicked(); } void world_map_scene_render(platform_window* window) @@ -1283,7 +1286,7 @@ void world_map_scene_render(platform_window* window) if (currently_viewing_active_job.offerid != INVALID_ID) world_map_draw_viewing_job(window); if (_active_world) { - world_update_result click_result = world_render(window, _active_world); + world_update_result click_result = world_render(window, _active_world, scene_state == WORLD_SCENE_STATE_IDLE); if (click_result.clicked_location) { if (click_result.clicked_location->is_owned) { diff --git a/src/world.c b/src/world.c index 83ca6d9..14000d3 100644 --- a/src/world.c +++ b/src/world.c @@ -1454,6 +1454,8 @@ static float get_fine_multiplier(world* world) // $100 = 1% off of fine. float multiplier = 1.0f; multiplier -= (world->investments.legal / 100.0f) * 0.01f; + if (multiplier < 0.2f) multiplier = 0.2f; + if (multiplier > 1.0f) multiplier = 1.0f; return multiplier; } @@ -1836,7 +1838,7 @@ static void draw_dotted_line(float x1, float y1, float x2, float y2, color line_ } } -world_update_result world_render(platform_window* window, world* world) +world_update_result world_render(platform_window* window, world* world, bool interactive) { world_update_result result = {0,0}; @@ -1856,7 +1858,7 @@ world_update_result world_render(platform_window* window, world* world) s32 circle_x = location->map_position_x - dotsize/2; s32 circle_y = location->map_position_y - dotsize/2; - bool hovered = mouse_interacts(circle_x, circle_y, dotsize, dotsize); + bool hovered = mouse_interacts(circle_x, circle_y, dotsize, dotsize) && interactive; location->is_hovered = hovered; if (hovered && location->is_accessible) { @@ -1879,7 +1881,14 @@ world_update_result world_render(platform_window* window, world* world) renderer->render_image_tint(img_locationdot, circle_x, circle_y, dotsize, dotsize, tint); if (!world_map_location_is_in_sun(map_pos)) { - renderer->render_image_tint(img_locationdot, circle_x, circle_y, dotsize, dotsize, rgba(255, 255, 0, 110)); + renderer->render_image_tint(img_locationdot, circle_x, circle_y, dotsize, dotsize, rgba(255, 255, 0, 170)); + } + + if (location->is_owned) { + float size = dotsize/3.0f; + s32 circle_x = location->map_position_x - size/2; + s32 circle_y = location->map_position_y - size/2; + renderer->render_image_tint(img_locationdot, circle_x, circle_y, size, size, rgba(0,0,0,255)); } } @@ -1893,7 +1902,7 @@ world_update_result world_render(platform_window* window, world* world) s32 circle_x = job->px_pos.x - dotsize/2; s32 circle_y = job->px_pos.y - dotsize/2; - bool hovered = mouse_interacts(circle_x, circle_y, dotsize, dotsize); + bool hovered = mouse_interacts(circle_x, circle_y, dotsize, dotsize) && interactive; job->is_hovered = hovered; if (hovered) { platform_set_cursor(window, CURSOR_POINTER); -- cgit v1.2.3-70-g09d2