diff --git a/src/display.cpp b/src/display.cpp index 0a9a78bec27..10a88bbe5f3 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -679,21 +679,11 @@ bool display::fogged(const map_location& loc) const return is_blindfolded() || (dont_show_all_ && viewing_team().fogged(loc)); } -int display::get_location_x(const map_location& loc) const -{ - return static_cast(map_area().x + (loc.x + theme_.border().size) * hex_width() - viewport_origin_.x); -} - -int display::get_location_y(const map_location& loc) const -{ - return static_cast(map_area().y + (loc.y + theme_.border().size) * zoom_ - viewport_origin_.y + (is_odd(loc.x) ? zoom_/2 : 0)); -} - point display::get_location(const map_location& loc) const { return { - get_location_x(loc), - get_location_y(loc) + static_cast(map_area().x + (loc.x + theme_.border().size) * hex_width() - viewport_origin_.x), + static_cast(map_area().y + (loc.y + theme_.border().size) * zoom_ - viewport_origin_.y + (is_odd(loc.x) ? zoom_/2 : 0)) }; } diff --git a/src/display.hpp b/src/display.hpp index 7f4fa9b0f0d..c554c0a11a2 100644 --- a/src/display.hpp +++ b/src/display.hpp @@ -316,8 +316,6 @@ public: void invalidate_game_status() { invalidateGameStatus_ = true; } /** Functions to get the on-screen positions of hexes. */ - int get_location_x(const map_location& loc) const; - 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 */ diff --git a/src/game_display.cpp b/src/game_display.cpp index 86c0fe2a092..6e331d23fdd 100644 --- a/src/game_display.cpp +++ b/src/game_display.cpp @@ -579,10 +579,12 @@ void game_display::float_label(const map_location& loc, const std::string& text, return; } + rect loc_rect = get_location_rect(loc); + font::floating_label flabel(text); flabel.set_font_size(int(font::SIZE_FLOAT_LABEL * get_zoom_factor())); flabel.set_color(color); - flabel.set_position(get_location_x(loc)+zoom_/2, get_location_y(loc)); + flabel.set_position(loc_rect.center().x, loc_rect.y); // middle of top edge flabel.set_move(0, -0.1 * turbo_speed() * get_zoom_factor()); flabel.set_lifetime(1000/turbo_speed()); flabel.set_scroll_mode(font::ANCHOR_LABEL_MAP); diff --git a/src/map/label.cpp b/src/map/label.cpp index 754682d0c2f..9cf65bb5fc3 100644 --- a/src/map/label.cpp +++ b/src/map/label.cpp @@ -537,8 +537,8 @@ void terrain_label::recalculate() // Note: the y part of loc_nextx is not used at all. const map_location loc_nextx = loc_.get_direction(map_location::direction::north_east); const map_location loc_nexty = loc_.get_direction(map_location::direction::south); - const int xloc = (disp->get_location_x(loc_) + disp->get_location_x(loc_nextx) * 2) / 3; - const int yloc = disp->get_location_y(loc_nexty) - scale_to_map_zoom(font::SIZE_NORMAL); + const int xloc = (disp->get_location(loc_).x + disp->get_location(loc_nextx).x * 2) / 3; + const int yloc = disp->get_location(loc_nexty).y - scale_to_map_zoom(font::SIZE_NORMAL); // If a color is specified don't allow to override it with markup. (prevents faking map labels for example) // FIXME: @todo Better detect if it's team label and not provided by the scenario.