Skip to content

Commit

Permalink
Display: simplified a few things
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Mar 13, 2018
1 parent dc01127 commit 220b260
Showing 1 changed file with 9 additions and 30 deletions.
39 changes: 9 additions & 30 deletions src/display.cpp
Expand Up @@ -88,12 +88,10 @@ unsigned int display::last_zoom_ = SmallZoom;

void display::add_overlay(const map_location& loc, const std::string& img, const std::string& halo, const std::string& team_name, const std::string& item_id, bool visible_under_fog)
{
if (halo_man_) {
halo::handle halo_handle;
if(halo != "") {
halo_handle = halo_man_->add(get_location_x(loc) + hex_size() / 2,
get_location_y(loc) + hex_size() / 2, halo, loc);
}
if(halo_man_) {
const halo::handle halo_handle = halo_man_->add(
get_location_x(loc) + hex_size() / 2,
get_location_y(loc) + hex_size() / 2, halo, loc);

overlays_->emplace(loc, overlay(img, halo, halo_handle, team_name, item_id, visible_under_fog));
}
Expand Down Expand Up @@ -1848,13 +1846,7 @@ void display::bounds_check_position()
{
const unsigned int orig_zoom = zoom_;

if(zoom_ < MinZoom) {
zoom_ = MinZoom;
}

if(zoom_ > MaxZoom) {
zoom_ = MaxZoom;
}
zoom_ = utils::clamp(zoom_, MinZoom, MaxZoom);

bounds_check_position(xpos_, ypos_);

Expand All @@ -1868,24 +1860,11 @@ void display::bounds_check_position(int& xpos, int& ypos) const
const int tile_width = hex_width();

// Adjust for the border 2 times
const int xend = static_cast<int>(tile_width * (get_map().w() + 2 * theme_.border().size) + tile_width/3);
const int yend = static_cast<int>(zoom_ * (get_map().h() + 2 * theme_.border().size) + zoom_/2);

if(xpos > xend - map_area().w) {
xpos = xend - map_area().w;
}

if(ypos > yend - map_area().h) {
ypos = yend - map_area().h;
}
const int xend = static_cast<int>(tile_width * (get_map().w() + 2 * theme_.border().size) + tile_width / 3);
const int yend = static_cast<int>(zoom_ * (get_map().h() + 2 * theme_.border().size) + zoom_ / 2);

if(xpos < 0) {
xpos = 0;
}

if(ypos < 0) {
ypos = 0;
}
xpos = utils::clamp(xpos, 0, xend - map_area().w);
ypos = utils::clamp(ypos, 0, yend - map_area().h);
}

double display::turbo_speed() const
Expand Down

0 comments on commit 220b260

Please sign in to comment.