From 3606c84655eb2bfac76933bc15b68e954e9b3034 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Thu, 28 Nov 2024 20:04:59 +0100 Subject: checkin --- data/world/locations.json | 36 ++++++++++++++++++++++++++++++++++++ src/scenery.c | 8 ++++++++ src/scenes/world_map.c | 4 ++-- src/world.c | 14 ++++++++++++++ 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/data/world/locations.json b/data/world/locations.json index 7c256e1..fecaf24 100644 --- a/data/world/locations.json +++ b/data/world/locations.json @@ -136,5 +136,41 @@ "longitude": -8.6800902, "name": "Porto", "size": 1 + }, + { + "longitude": -120.443085, + "latitude": 32.073334, + "name": "San Diego", + "size": 1 + }, + { + "longitude": -125.733109, + "latitude": 37.520374, + "name": "San Francisco", + "size": 1 + }, + { + "longitude": -127.125214, + "latitude": 45.690937, + "name": "Seattle", + "size": 1 + }, + { + "longitude": -118.494125, + "latitude": 37.025188, + "name": "Las Vegas", + "size": 1 + }, + { + "longitude": -98.755829, + "latitude": 30.566299, + "name": "Houston", + "size": 1 + }, + { + "longitude": -98.447723, + "latitude": 33.311295, + "name": "Dallas", + "size": 1 } ] \ No newline at end of file diff --git a/src/scenery.c b/src/scenery.c index bf8afe6..aca9dfe 100644 --- a/src/scenery.c +++ b/src/scenery.c @@ -1,4 +1,5 @@ +vec2f px_to_coords(platform_window* window, double x, double y); static void update_render_path(world* world, boat_route *route) { @@ -43,6 +44,13 @@ void update_render_scenery(world* world) { } renderer->render_reset_scissor(); +#if 0 + if (is_left_clicked()) { + vec2f coords = px_to_coords(main_window, _global_mouse.x, _global_mouse.y); + printf("Location: %f %f\n", coords.y, coords.x); + } +#endif + #if 0 static s32 count = 0; diff --git a/src/scenes/world_map.c b/src/scenes/world_map.c index ac0d3b2..a4e9479 100644 --- a/src/scenes/world_map.c +++ b/src/scenes/world_map.c @@ -993,7 +993,7 @@ static void world_handle_scroll(platform_window* window) zoom-=0.1f; changed = true; } - if (zoom < 1.5f) zoom = 1.5f; + if (zoom < 1.0f) zoom = 1.0f; else if (zoom > 3.0f) zoom = 3.0f; float center_y = -((area.h * zoom) - area.h) / 8; @@ -1104,7 +1104,7 @@ void world_map_scene_render(platform_window* window) renderer->set_render_depth(0); vec4 area = camera_get_target_rectangle(window); - renderer->render_rectangle(area.x + camera_x, area.y + camera_y, area.w*zoom, area.h*zoom, COLOR_WORLD_MAP_BACKGROUND); + renderer->render_rectangle(area.x + camera_x, area.y + camera_y, area.w*zoom, area.h*zoom, map_bg_color); renderer->render_image(img_world_map, area.x + camera_x, area.y + camera_y, area.w*zoom, area.h*zoom); } diff --git a/src/world.c b/src/world.c index 3c3dbc8..4665a86 100644 --- a/src/world.c +++ b/src/world.c @@ -7,6 +7,7 @@ static void enable_insights_for_current_month(world* world); static vec2f get_world_location_for_job(platform_window* window, world* world, active_job* job); static employee* get_employee_by_id(world_location* location, u32 id); static void end_contract_with_employee(world* world, employee* emp); +vec2f px_to_coords(platform_window* window, double x, double y); float dotsize = 5; @@ -586,6 +587,19 @@ world* world_create_new() return new_world; } +vec2f px_to_coords(platform_window* window, double x, double y) +{ + vec2f extra = {9 * scale, 4 * scale}; + float orig_lon = x - extra.x - (area.x/zoom); + orig_lon = (orig_lon * 360.0f / area.w - 180.0f); + + float orig_lat = y - extra.y - (area.y/zoom); + orig_lat = (orig_lat * 180.0f / -area.h + 90.0f); + + vec2f map_pos = {orig_lon, orig_lat}; + return map_pos; +} + static vec2f coords_to_px(platform_window* window, double lon, double lat) { vec2f extra = {9 * scale, 4 * scale}; -- cgit v1.2.3-70-g09d2