From 738088522680603904ef0c542e995e53a6977725 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Thu, 19 Sep 2024 15:03:22 -0400 Subject: [PATCH] Display: add get_location_rect --- src/display.cpp | 15 +++++++-------- src/display.hpp | 3 +++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index 435e4045979..8f88a73d7cc 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -702,6 +702,12 @@ point display::get_location(const map_location& loc) const }; } +rect display::get_location_rect(const map_location& loc) const +{ + // TODO: evaluate how these functions should be defined in terms of each other + return { get_location(loc), point{hex_size(), hex_size()} }; +} + map_location display::minimap_location_on(int x, int y) { // TODO: don't return location for this, @@ -1266,14 +1272,7 @@ uint32_t generate_hex_key(const drawing_layer layer, const map_location& loc) void display::drawing_buffer_add(const drawing_layer layer, const map_location& loc, decltype(draw_helper::do_draw) draw_func) { - const rect dest { - get_location_x(loc), - get_location_y(loc), - int(zoom_), - int(zoom_) - }; - - drawing_buffer_.AGGREGATE_EMPLACE(generate_hex_key(layer, loc), draw_func, dest); + drawing_buffer_.AGGREGATE_EMPLACE(generate_hex_key(layer, loc), draw_func, get_location_rect(loc)); } void display::drawing_buffer_commit() diff --git a/src/display.hpp b/src/display.hpp index 07b7717a816..cd033935a9d 100644 --- a/src/display.hpp +++ b/src/display.hpp @@ -315,6 +315,9 @@ public: int get_location_y(const map_location& loc) const; point get_location(const map_location& loc) const; + /** Returns the on-screen rect corresponding to a @a loc */ + rect get_location_rect(const map_location& loc) const; + /** * Rectangular area of hexes, allowing to decide how the top and bottom * edges handles the vertical shift for each parity of the x coordinate