diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/scenery.c | 8 | ||||
| -rw-r--r-- | src/scenes/world_map.c | 4 | ||||
| -rw-r--r-- | src/world.c | 14 |
3 files changed, 24 insertions, 2 deletions
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};
|
