59 #include <boost/algorithm/string/trim.hpp> 61 #include <SDL2/SDL_image.h> 77 #define ERR_DP LOG_STREAM(err, log_display) 78 #define WRN_DP LOG_STREAM(warn, log_display) 79 #define LOG_DP LOG_STREAM(info, log_display) 80 #define DBG_DP LOG_STREAM(debug, log_display) 83 #define zoom_levels (game_config::zoom_levels) 84 #define final_zoom_index (static_cast<int>(zoom_levels.size()) - 1) 85 #define DefaultZoom (game_config::tile_size) 86 #define SmallZoom (DefaultZoom / 2) 87 #define MinZoom (zoom_levels.front()) 88 #define MaxZoom (zoom_levels.back()) 106 float diff = *iter - *(iter - 1);
107 float lower = (zoom_level - *(iter - 1)) / diff;
108 float upper = (*iter - zoom_level) / diff;
119 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,
float submerge,
float z_order)
128 auto it = std::find_if(overlays.begin(), overlays.end(), [z_order](
const overlay& ov) {
return ov.z_order > z_order; });
129 overlays.emplace(it, img, halo, halo_handle, team_name, item_id, visible_under_fog, submerge, z_order);
142 overlays.begin(), overlays.end(),
143 [&toDelete](
const overlay& ov) {
return ov.image == toDelete || ov.halo == toDelete || ov.id == toDelete; }
150 std::weak_ptr<wb::manager>
wb,
152 const std::string& theme_id,
224 if(tile_size < MinZoom || tile_size >
MaxZoom)
270 std::vector<std::string> side_colors;
271 side_colors.reserve(
dc_->
teams().size());
274 std::string side_color =
t.color();
275 side_colors.push_back(side_color);
287 assert(
dc_ !=
nullptr);
288 assert(n < dc_->teams().
size());
289 assert(n <
flags_.size());
293 std::string new_rgb = side_color;
299 LOG_DP <<
"Adding flag for team " << n <<
" from animation " <<
flag;
306 for(
const std::string&
item : items) {
308 std::string str =
item;
311 if(sub_items.size() > 1) {
312 str = sub_items.front();
314 time = std::max<int>(1, std::stoi(sub_items.back()));
315 }
catch(
const std::invalid_argument&) {
316 ERR_DP <<
"Invalid time value found when constructing flag for side " << n <<
": " << sub_items.back();
320 std::stringstream temp;
321 temp << str <<
"~RC(" << old_rgb <<
">"<< new_rgb <<
")";
334 ERR_DP <<
"missing flag for team" <<
n;
340 if(!
get_map().is_village(loc)) {
348 flag.update_last_draw_time();
350 flag.get_current_frame() :
flag.get_first_frame();
360 assert(teamindex < dc_->teams().
size());
362 if(!show_everything) {
370 if(std::shared_ptr<wb::manager>
w =
wb_.lock()) {
371 w->on_viewer_change(teamindex);
377 assert(teamindex < dc_->teams().
size());
437 std::ostringstream
s;
443 images.push_back(s.str());
448 images.emplace_back();
454 return variants[std::abs(loc.
x + loc.
y) % variants.size()];
504 rect max_area{0, 0, 0, 0};
530 if(max_area.w < res.w) {
532 res.x += (res.w - max_area.w) / 2;
536 if(max_area.h < res.h) {
538 res.y += (res.h - max_area.h) / 2;
558 return (x < area.x || x > area.x + area.w - x_thresh || y < area.y || y > area.y + area.h - y_thresh);
584 const int offset = y < 0 ? 1 : 0;
590 const int tesselation_x_size =
hex_width() * 2;
591 const int tesselation_y_size =
s;
592 const int x_base = x / tesselation_x_size * 2;
593 const int x_mod = x % tesselation_x_size;
594 const int y_base = y / tesselation_y_size;
595 const int y_mod = y % tesselation_y_size;
600 if (y_mod < tesselation_y_size / 2) {
601 if ((x_mod * 2 + y_mod) < (s / 2)) {
604 }
else if ((x_mod * 2 - y_mod) < (s * 3 / 2)) {
613 if ((x_mod * 2 - (y_mod - s / 2)) < 0) {
616 }
else if ((x_mod * 2 + (y_mod - s / 2)) < s * 2) {
625 return map_location(x_base + x_modifier - offset, y_base + y_modifier - offset);
654 if(r.w <= 0 || r.h <= 0) {
667 int x =
xpos_ - map_rect.x + r.x;
668 int y =
ypos_ - map_rect.y + r.y;
678 res.
left =
static_cast<int>(std::floor(-border + x / tile_width - 0.3333333));
681 res.
right =
static_cast<int>(std::floor(-border + (x + r.w - 1) / tile_width));
685 res.
top[0] =
static_cast<int>(std::floor(-border + y / tile_size));
686 res.
top[1] =
static_cast<int>(std::floor(-border + y / tile_size - 0.5));
687 res.
bottom[0] =
static_cast<int>(std::floor(-border + (y + r.h - 1) / tile_size));
688 res.
bottom[1] =
static_cast<int>(std::floor(-border + (y + r.h - 1) / tile_size - 0.5));
764 if (!map_screenshot) {
765 LOG_DP <<
"taking ordinary screenshot";
770 ERR_DP <<
"No map loaded, cannot create a map screenshot.";
775 int old_xpos =
xpos_;
776 int old_ypos =
ypos_;
782 if (area.w > 1 << 16 || area.h > 1 << 16) {
783 WRN_DP <<
"Excessively large map screenshot area";
785 LOG_DP <<
"creating " << area.w <<
" by " << area.h
786 <<
" texture for map screenshot";
787 texture output_texture(area.w, area.h, SDL_TEXTUREACCESS_TARGET);
828 DBG_DP <<
"positioning menu buttons...";
832 b->set_location(loc);
833 b->set_measurements(0,0);
834 b->set_label(menu.title());
835 b->set_image(menu.image());
839 DBG_DP <<
"positioning action buttons...";
843 b->set_location(loc);
844 b->set_measurements(0,0);
845 b->set_label(action.title());
846 b->set_image(action.image());
855 if(type ==
"checkbox") {
857 }
else if(type ==
"image") {
859 }
else if(type ==
"radiobox") {
861 }
else if(type ==
"turbo") {
868 const std::string& get_direction(std::size_t
n)
870 using namespace std::literals::string_literals;
871 static const std::array dirs{
"-n"s,
"-ne"s,
"-se"s,
"-s"s,
"-sw"s,
"-nw"s};
872 return dirs[n >= dirs.size() ? 0 :
n];
885 DBG_DP <<
"creating menu buttons...";
887 if(!menu.is_button()) {
894 DBG_DP <<
"drawing button " << menu.get_id();
895 b->set_id(menu.get_id());
896 if(!menu.tooltip().empty()) {
897 b->set_tooltip_string(menu.tooltip());
901 b->enable(b_prev->enabled());
907 DBG_DP <<
"creating action buttons...";
909 auto b = std::make_shared<gui::button>(action.title(), string_to_button_type(action.type()),
912 DBG_DP <<
"drawing button " << action.get_id();
913 b->set_id(action.get_id());
914 if(!action.tooltip(0).empty()) {
915 b->set_tooltip_string(action.tooltip(0));
919 b->enable(b_prev->enabled());
921 b->set_check(b_prev->checked());
929 DBG_DP <<
"buttons created";
956 std::vector<std::string>
names;
959 enum visibility { FOG = 0, SHROUD = 1, CLEAR = 2 };
960 std::array<visibility, 6> tiles;
964 for(
int i = 0;
i < 6; ++
i) {
974 for(
int v = FOG; v != CLEAR; ++v) {
977 for(start = 0; start != 6; ++
start) {
978 if(tiles[start] != v) {
986 const std::string name = *image_prefix[v] +
"-all.png";
988 names.push_back(name);
998 for(
int i = (start + 1) % 6, cap1 = 0;
i != start && cap1 != 6; ++cap1) {
1000 std::ostringstream stream;
1002 stream << *image_prefix[v];
1004 for(
int cap2 = 0; v == tiles[
i] && cap2 != 6;
i = (
i + 1) % 6, ++cap2) {
1005 stream << get_direction(
i);
1015 name = stream.str();
1020 names.push_back(name +
".png");
1029 std::vector<texture> res;
1031 for(
const std::string& name : names) {
1033 res.push_back(std::move(tex));
1049 std::array<
const time_of_day*, adjs.size()> atods;
1051 for(std::size_t
d = 0;
d < adjs.size(); ++
d) {
1055 for(
int d = 0;
d < 6; ++
d) {
1069 const time_of_day& atod1 = *atods[
d];
1070 const time_of_day& atod2 = *atods[(
d + 1) % 6];
1087 for(
int d = 0;
d < 6; ++
d) {
1101 const time_of_day& atod1 = *atods[
d];
1102 const time_of_day& atod2 = *atods[(
d + 1) % 6];
1119 for(
int d = 0;
d < 6; ++
d) {
1133 const time_of_day& atod1 = *atods[
d];
1134 const time_of_day& atod2 = *atods[(
d + 1) % 6];
1166 for(
const auto& terrain : *terrains) {
1174 const bool off_map = (image.
get_filename() == off_map_name
1179 }
else if(lt.empty()) {
1194 constexpr std::array layer_groups {
1209 BITS_FOR_LAYER_GROUP = 4,
1215 BITS_FOR_X_PARITY = 1,
1221 BITS_FOR_X_OVER_2 = 9,
1223 SHIFT_LAYER = BITS_FOR_X_OVER_2,
1225 SHIFT_X_PARITY = BITS_FOR_LAYER + SHIFT_LAYER,
1227 SHIFT_Y = BITS_FOR_X_PARITY + SHIFT_X_PARITY,
1229 SHIFT_LAYER_GROUP = BITS_FOR_Y + SHIFT_Y
1235 uint32_t group_i = layer_groups.size() - 1;
1238 while(layer < layer_groups[group_i]) {
1246 const uint32_t x_parity =
static_cast<uint32_t
>(loc.
x) & 1;
1249 static_assert(SHIFT_LAYER_GROUP + BITS_FOR_LAYER_GROUP ==
sizeof(key) * 8,
"Bit field too small");
1251 key = (group_i << SHIFT_LAYER_GROUP) | (static_cast<uint32_t>(loc.
y + MAX_BORDER) << SHIFT_Y);
1252 key |= (x_parity << SHIFT_X_PARITY);
1253 key |= (
static_cast<uint32_t
>(layer) << SHIFT_LAYER) |
static_cast<uint32_t
>(loc.
x + MAX_BORDER) / 2;
1270 drawing_buffer_.emplace_back(generate_hex_key(layer, loc), draw_func, dest);
1272 draw_helper temp{generate_hex_key(layer, loc), draw_func, dest};
1274 #endif // HAVE_CXX20 1297 std::invoke(helper.do_draw, helper.dest);
1300 drawing_buffer_.clear();
1306 return frametime != 0u ? 1000u / frametime : 999u;
1312 const int sample_freq = 10;
1331 *fps_log << std::get<0>(fps) <<
"," << std::get<1>(fps) <<
"," << std::get<2>(fps) <<
"\n";
1333 fps_history_.clear();
1340 std::ostringstream stream;
1341 stream <<
"<tt> min/avg/max/act</tt>\n";
1342 stream <<
"<tt>FPS: " << std::setfill(
' ') << std::setw(3) << min_fps <<
'/'<< std::setw(3) << avg_fps <<
'/' << std::setw(3) << max_fps <<
'/' << std::setw(3) <<
fps_actual_ <<
"</tt>\n";
1343 stream <<
"<tt>Time: " << std::setfill(
' ') << std::setw(3) << *minmax_it.first <<
'/' << std::setw(3) << render_avg <<
'/' << std::setw(3) << *minmax_it.second <<
" ms</tt>\n";
1355 flabel.set_position(10, 100);
1374 if (panel.
image().empty()) {
1384 DBG_DP <<
"drawing panel " << panel.
get_id() <<
' ' << loc;
1389 <<
" texture: " << panel.
image();
1404 const std::string& text = label.
text();
1406 const std::string& icon = label.
icon();
1408 DBG_DP <<
"drawing label " << label.
get_id() <<
' ' << loc;
1410 if(icon.empty() ==
false) {
1413 if(text.empty() ==
false) {
1416 }
else if(text.empty() ==
false) {
1418 text_color, text, loc.x, loc.y
1429 if(region.
overlaps(panel.location(game_canvas))) {
1447 const std::string& text,
1448 std::size_t font_size,
1453 if (text.empty())
return;
1459 renderer.set_maximum_height(-1,
false);
1460 renderer.set_foreground_color(color);
1465 dest.x - (res.w() / 2) + static_cast<int>(x_in_hex * dest.w),
1466 dest.y - (res.h() / 2) + static_cast<int>(y_in_hex * dest.h),
1479 image_path =
"misc/blank-hex.png~BLIT(" + image_path;
1493 if (submersion_amount > 0.0) {
1494 int submersion_line = image_height * (1.0 - submersion_amount);
1495 const std::string sl_string = std::to_string(submersion_line);
1496 image_path +=
"~ADJUST_ALPHA(if(y>";
1497 image_path += sl_string;
1498 image_path +=
",clamp((0.3-(y-";
1499 image_path += sl_string;
1500 image_path +=
")*0.015),0,1)*alpha,alpha))";
1509 image_path +=
",0,";
1510 image_path += std::to_string(shift);
1554 if(time_between_draws < 0) {
1560 using std::chrono::duration_cast;
1561 using std::chrono::seconds;
1562 using std::chrono::steady_clock;
1563 const seconds current_second = duration_cast<seconds>(steady_clock::now().time_since_epoch());
1576 if((*i)->pressed()) {
1592 if((*i)->pressed()) {
1655 ERR_DP <<
"trying to draw null minimap";
1688 double shift_x = -border *
hex_width() - (map_out_rect.w - map_rect.w) / 2;
1689 double shift_y = -(border + 0.25) *
hex_size() - (map_out_rect.h - map_rect.h) / 2;
1691 int view_x =
static_cast<int>((
xpos_ + shift_x) * xscaling);
1692 int view_y =
static_cast<int>((
ypos_ + shift_y) * yscaling);
1693 int view_w =
static_cast<int>(map_out_rect.w * xscaling);
1694 int view_h =
static_cast<int>(map_out_rect.h * yscaling);
1696 SDL_Rect outline_rect {
1713 for(
const auto& u :
dc_->
units()) {
1714 if (
fogged(u.get_location()) ||
1716 u.invisible(u.get_location())) ||
1721 int side = u.side();
1728 }
else if(
currentTeam_ + 1 == static_cast<unsigned>(side)) {
1736 double u_x = u.get_location().x * xscaling;
1737 double u_y = (u.get_location().y + (
is_odd(u.get_location().x) ? 1 : -1)/4.0) * yscaling;
1739 double u_w = 4.0 / 3.0 * xscaling;
1740 double u_h = yscaling;
1745 , int(std::round(u_w))
1746 , int(std::round(u_h))
1760 if(xmove == 0 && ymove == 0) {
1764 int new_x =
xpos_ + xmove;
1765 int new_y =
ypos_ + ymove;
1774 const int diff_x =
xpos_ - new_x;
1775 const int diff_y =
ypos_ - new_y;
1828 r.y = r.y + r.h + diff_y;
1831 r.h = std::abs(diff_y);
1839 r.x = r.x + r.w + diff_x;
1842 r.w = std::abs(diff_x);
1877 LOG_DP <<
"new_zoom = " << new_zoom;
1879 if(new_zoom ==
zoom_) {
1883 if(validate_value_and_set_index) {
1892 double zoom_factor =
static_cast<double>(new_zoom) / static_cast<double>(
zoom_);
1906 xpos_ = std::round(((
xpos_ + area.w / 2) * zoom_factor) - (area.w / 2));
1907 ypos_ = std::round(((
ypos_ + area.h / 2) * zoom_factor) - (area.h / 2));
1908 xpos_ -= (outside_area.w - area.w) / 2;
1909 ypos_ -= (outside_area.h - area.h) / 2;
1951 return x + hs >= area.x - hw && x < area.x + area.w + hw &&
1952 y + hs >= area.y - hs && y < area.y + area.h + hs;
1962 const int xmove_expected = screenxpos - (area.x + area.w/2);
1963 const int ymove_expected = screenypos - (area.y + area.h/2);
1965 int xpos =
xpos_ + xmove_expected;
1966 int ypos =
ypos_ + ymove_expected;
1968 int xmove = xpos -
xpos_;
1969 int ymove = ypos -
ypos_;
1972 scroll(xmove,ymove,
true);
1983 const double dist_total = std::hypot(xmove, ymove);
1984 double dist_moved = 0.0;
1986 int t_prev = SDL_GetTicks();
1988 double velocity = 0.0;
1989 while (dist_moved < dist_total) {
1992 int t = SDL_GetTicks();
1993 double dt = (t - t_prev) / 1000.0;
2005 double accel = velocity_max / accel_time;
2006 double decel = velocity_max / decel_time;
2009 double stop_time = velocity / decel;
2010 double dist_stop = dist_moved + velocity*stop_time - 0.5*decel*stop_time*stop_time;
2011 if (dist_stop > dist_total || velocity > velocity_max) {
2012 velocity -= decel * dt;
2013 if (velocity < 1.0) velocity = 1.0;
2015 velocity += accel * dt;
2016 if (velocity > velocity_max) velocity = velocity_max;
2019 dist_moved += velocity * dt;
2020 if (dist_moved > dist_total) dist_moved = dist_total;
2022 int x_new = std::round(xmove * dist_moved / dist_total);
2023 int y_new = std::round(ymove * dist_moved / dist_total);
2025 int dx = x_new - x_old;
2026 int dy = y_new - y_old;
2039 if(
get_map().on_board(loc) ==
false) {
2040 ERR_DP <<
"Tile at " << loc <<
" isn't on the map, can't scroll to the tile.";
2044 std::vector<map_location> locs;
2045 locs.push_back(loc);
2051 double add_spacing,
bool force)
2053 std::vector<map_location> locs;
2054 locs.push_back(loc1);
2055 locs.push_back(loc2);
2056 scroll_to_tiles(locs, scroll_type, check_fogged,
false, add_spacing,force);
2060 const std::vector<map_location>::const_iterator & end,
2062 bool only_if_possible,
double add_spacing,
bool force)
2071 for(std::vector<map_location>::const_iterator itor = begin; itor != end ; ++itor) {
2072 if(
get_map().on_board(*itor) ==
false)
continue;
2073 if(check_fogged &&
fogged(*itor))
continue;
2085 int minx_new = std::min<int>(minx,x);
2086 int miny_new = std::min<int>(miny,y);
2087 int maxx_new = std::max<int>(maxx,x);
2088 int maxy_new = std::max<int>(maxy,y);
2094 if (only_if_possible)
return;
2108 int spacing = std::round(add_spacing *
hex_size());
2122 locs_bbox.w = maxx - minx +
hex_size();
2123 locs_bbox.h = maxy - miny +
hex_size();
2126 int target_x = locs_bbox.x + locs_bbox.w/2;
2127 int target_y = locs_bbox.y + locs_bbox.h/2;
2132 int map_center_x = r.x + r.w/2;
2133 int map_center_y = r.y + r.h/2;
2139 double inside_frac = 0.5;
2140 w =
static_cast<int>(w * inside_frac);
2141 h =
static_cast<int>(h * inside_frac);
2151 r.x = target_x - w/2;
2152 r.y = target_y - h/2;
2160 if (map_center_x < r.x) {
2162 target_y = map_center_y;
2163 if (target_y < r.y) target_y = r.y;
2164 if (target_y > r.y+r.h-1) target_y = r.y+r.h-1;
2165 }
else if (map_center_x > r.x+r.w-1) {
2166 target_x = r.x+r.w-1;
2167 target_y = map_center_y;
2168 if (target_y < r.y) target_y = r.y;
2169 if (target_y >= r.y+r.h) target_y = r.y+r.h-1;
2170 }
else if (map_center_y < r.y) {
2172 target_x = map_center_x;
2173 if (target_x < r.x) target_x = r.x;
2174 if (target_x > r.x+r.w-1) target_x = r.x+r.w-1;
2175 }
else if (map_center_y > r.y+r.h-1) {
2176 target_y = r.y+r.h-1;
2177 target_x = map_center_x;
2178 if (target_x < r.x) target_x = r.x;
2179 if (target_x > r.x+r.w-1) target_x = r.x+r.w-1;
2181 ERR_DP <<
"Bug in the scrolling code? Looks like we would not need to scroll after all...";
2231 if(
keys_[SDLK_LSHIFT] ||
keys_[SDLK_RSHIFT]) {
2243 const std::string& old_mask,
2244 const std::string& new_mask)
2251 int start = SDL_GetTicks();
2252 for(
int now = start; now < start + duration; now = SDL_GetTicks()) {
2253 float prop_f = float(now - start) / float(duration);
2267 uint32_t
start = SDL_GetTicks();
2272 if(fade_start.a == 0) {
2273 fade_start.r = fade_end.r;
2274 fade_start.g = fade_end.g;
2275 fade_start.b = fade_end.b;
2279 if(fade_end.a == 0) {
2280 fade_end.r = fade_start.r;
2281 fade_end.g = fade_start.g;
2282 fade_end.b = fade_start.b;
2286 for(uint32_t now = start; now < start + duration; now = SDL_GetTicks()) {
2287 float prop_f = float(now - start) / float(duration);
2308 DBG_DP <<
"redrawing everything";
2331 if(command_executor !=
nullptr) {
2375 DBG_DP <<
"display::draw denied";
2386 DBG_DP <<
"display::draw redraw background";
2439 DBG_DP <<
"draw() with invalidateAll";
2464 DBG_DP <<
"render prevented";
2480 ERR_DP <<
"error creating minimap";
2489 DBG_DP <<
"draw prevented";
2524 DBG_DP <<
"display::expose " << region;
2554 bool raw_size_changed = size.x != oarea.w || size.y != oarea.h;
2555 bool draw_size_changed = dsize.x != darea.w || dsize.y != darea.h;
2556 if (!raw_size_changed && !draw_size_changed) {
2561 if(raw_size_changed) {
2562 LOG_DP <<
"regenerating render buffers as " << oarea;
2563 front_ =
texture(oarea.w, oarea.h, SDL_TEXTUREACCESS_TARGET);
2564 back_ =
texture(oarea.w, oarea.h, SDL_TEXTUREACCESS_TARGET);
2566 if(raw_size_changed || draw_size_changed) {
2567 LOG_DP <<
"updating render buffer draw size to " << darea;
2573 for(
int i = 0;
i < 2; ++
i) {
2590 for(
int i = 0;
i < 2; ++
i) {
2621 DBG_DP <<
"drawing " <<
invalidated_.size() <<
" invalidated hexes with clip " << clip_rect;
2624 std::optional<unit_drawer> drawer{};
2626 drawer.emplace(*
this);
2634 if(!hex_rect.
overlaps(clip_rect)) {
2646 drawer->redraw_unit(*u_it);
2661 int num_images_fg = 0;
2662 int num_images_bg = 0;
2706 std::vector<overlay>& overlays = it->second;
2707 if(overlays.size() != 0) {
2711 for(
const overlay& ov : overlays) {
2712 bool item_visible_for_team =
true;
2716 const std::vector<std::string>& current_team_names =
utils::split(current_team_name);
2717 const std::vector<std::string>& team_names =
utils::split(ov.team_name);
2719 item_visible_for_team = std::find_first_of(team_names.begin(), team_names.end(),
2720 current_team_names.begin(), current_team_names.end()) != team_names.end();
2723 if(item_visible_for_team && !(
fogged(loc) && !ov.visible_in_fog)) {
2725 std::string ipf = ov.image;
2729 double sub = submerge * ov.submerge;
2732 int shift = isize.y * (sub - submerge);
2736 const texture tex = ov.image.find(
"~NO_TOD_SHIFT()") == std::string::npos
2754 const std::string& tod_hex_mask = tod.
image_mask;
2763 }
else if(!tod_hex_mask.empty()) {
2769 arrows_map_t::const_iterator arrows_in_hex =
arrows_map_.find(loc);
2771 for (
arrow*
const a : arrows_in_hex->second) {
2816 std::ostringstream ss;
2826 ss << (num_images_bg + num_images_fg) <<
'\n';
2829 std::string
output = ss.str();
2832 if(output.empty()) {
2839 renderer.set_alignment(PANGO_ALIGN_CENTER);
2841 renderer.set_maximum_height(-1,
false);
2845 const rect text_dest {
2846 (dest.x + dest.w / 2) - (tex.w() / 2),
2847 (dest.y + dest.h / 2) - (tex.h() / 2),
2853 const rect bg_dest {
2892 if ( new_cfg ==
nullptr )
2893 new_cfg = &generated_cfg;
2897 config &report =
reports_[report_name];
2900 if (loc == new_loc && report == *new_cfg) {
2904 DBG_DP <<
"updating report: " << report_name;
2918 if (report.
empty())
return;
2923 std::string str = item->
prefix();
2927 e[
"tooltip"] = report.
child(
"element")[
"tooltip"];
2933 e[
"tooltip"] = report.
child(
"element", -1)[
"tooltip"];
2954 int x = loc.x, y = loc.y;
2958 int image_count = 0;
2959 bool used_ellipsis =
false;
2960 std::ostringstream ellipsis_tooltip;
2961 SDL_Rect ellipsis_area = loc;
2964 elements.begin() != elements.end(); elements.pop_front())
2966 SDL_Rect area {x, y, loc.w + loc.x - x, loc.h + loc.y - y};
2967 if (area.h <= 0)
break;
2969 std::string
t = elements.front()[
"text"];
2972 if (used_ellipsis)
goto skip_element;
2977 if (t[t.size() - 1] ==
'\n') {
2979 t = t.substr(0, t.size() - 1);
2995 .set_maximum_width(area.w)
3003 const int minimal_text = 12;
3005 if (!eol && loc.w - (x - loc.x + tsize.x) < minimal_text &&
3006 ++ee != elements.end() && !(*ee)[
"text"].empty())
3015 used_ellipsis =
true;
3016 ellipsis_area.x = x;
3017 ellipsis_area.y = y;
3018 ellipsis_area.w = tsize.x;
3019 ellipsis_area.h = tsize.y;
3024 if (!tooltip_test) {
3027 if (area.h > tallest) {
3038 else if (!(t = elements.front()[
"image"].str()).empty())
3040 if (used_ellipsis)
goto skip_element;
3046 ERR_DP <<
"could not find image for report: '" << t <<
"'";
3050 if (area.w < img.
w() && image_count) {
3053 used_ellipsis =
true;
3056 if (img.
w() < area.w) area.w = img.
w();
3057 if (img.
h() < area.h) area.h = img.
h();
3058 if (!tooltip_test) {
3063 if (area.h > tallest) {
3067 if (!used_ellipsis) {
3070 ellipsis_area = area;
3080 t = elements.front()[
"tooltip"].t_str().c_str();
3082 if (tooltip_test && !used_ellipsis) {
3088 ellipsis_tooltip <<
t;
3090 if (++ee != elements.end())
3091 ellipsis_tooltip <<
"\n _________\n\n";
3096 if (tooltip_test && used_ellipsis) {
3105 const std::string& name = it.first;
3117 DBG_DP <<
"invalidate_all()";
3151 bool result =
false;
3154 std::set<map_location>::const_iterator
i = locs.begin();
3155 for(; i != locs.end() &&
invalidated_.count(*i) == 0 ; ++
i) {}
3157 if (i != locs.end()) {
3180 DBG_DP <<
"invalidating locations in " <<
rect;
3182 bool result =
false;
3192 if(
get_map().is_village(loc)) {
3194 if(owner >= 0 &&
flags_[owner].need_update()
3210 if(
builder_->update_animation(loc)) {
3219 u.anim_comp().refresh();
3222 u->anim_comp().refresh();
3229 new_inval |= u.anim_comp().invalidate(*
this);
3231 for(
const unit* u : *fake_unit_man_) {
3232 new_inval |= u->anim_comp().invalidate(*
this);
3242 u.anim_comp().set_standing();
3303 if (reach == full.end()) {
3306 }
else if (reach->second != 1) {
3319 if (reach_old->second != reach->second) {
Drawing functions, for drawing things on the screen.
std::shared_ptr< gui::button > find_action_button(const std::string &id)
Retrieves a pointer to a theme UI button.
std::size_t font_size() const
play_controller * controller
TYPE
Used to specify the rendering format of images.
void drawing_buffer_commit()
Draws the drawing_buffer_ and clears it.
int village_owner(const map_location &loc) const
Given the location of a village, will return the 1-based number of the team that currently owns it...
virtual bool expose(const rect ®ion) override
Paint the indicated region to the screen.
void draw_minimap_units()
const std::string & get_modifications() const
void recalculate_shroud()
Reserve layers to be selected for WML.
bool discard_previous
An announcement according these options should replace the previous announce (typical of fast announc...
void draw_floating_labels()
const std::string & icon() const
virtual void select_hex(map_location hex)
config & child(config_key_type key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
::tod_manager * tod_manager
Arrows destined to be drawn on the map.
reports * reports_object_
bool minimap_draw_units()
void write(config &cfg) const
hotkey::command_executor * get_hotkey_command_executor() override
Optionally get a command executor to handle context menu events.
const rect & minimap_area() const
mapx is the width of the portion of the display which shows the game area.
void queue_rerender()
Marks everything for rendering including all tiles and sidebar.
const team & get_team(int side) const
void remove_floating_label(int handle, int fadeout)
removes the floating label given by 'handle' from the screen
surface read_pixels(SDL_Rect *r)
Copy back a portion of the render target that is already drawn.
void invalidate_game_status()
Function to invalidate the game status displayed on the sidebar.
Small struct to store and manipulate ToD color adjusts.
constexpr bool is_odd(T num)
int get_pixel_scale()
Get the current active pixel scale multiplier.
void adjust_color_overlay(int r, int g, int b)
Add r,g,b to the colors for all images displayed on the map.
const arrow_path_t & get_path() const
std::string image_mask
The image that is to be laid over all images while this time of day lasts.
void get_adjacent_tiles(const map_location &a, map_location *res)
Function which, given a location, will place all adjacent locations in res.
void set_alpha_mod(uint8_t alpha)
Alpha modifier.
void invalidate_animations()
Function to invalidate animated terrains and units which may have changed.
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
static int hex_size()
Function which returns the size of a hex in pixels (from top tip to bottom tip or left edge to right ...
This class represents a single unit of a specific type.
int w() const
The draw-space width of the texture, in pixels.
bool animate_water_
Local version of preferences::animate_water, used to detect when it's changed.
virtual void notify_observers()
tod_color color
The color modifications that should be made to the game board to reflect the time of day...
int current_frame_sample_
bool set_text(const std::string &text, const bool markedup)
Sets the text to render.
void set_clip_rect(const SDL_Rect &r)
bool set_zoom(bool increase)
Zooms the display in (true) or out (false).
void change_display_context(const display_context *dc)
const map_location hex_clicked_on(int x, int y) const
given x,y co-ordinates of an onscreen pixel, will return the location of the hex that this pixel corr...
boost::circular_buffer< unsigned > frametimes_
void pump_and_draw()
pump() then immediately draw()
static double get_zoom_factor()
Returns the current zoom factor.
texture render_and_get_texture()
Returns the cached texture, or creates a new one otherwise.
void set_playing_team(std::size_t team)
set_playing_team sets the team whose turn it currently is
const map_location pixel_position_to_hex(int x, int y) const
given x,y co-ordinates of a pixel on the map, will return the location of the hex that this pixel cor...
void scroll_floating_labels(double xmove, double ymove)
moves all floating labels that have 'scroll_mode' set to ANCHOR_LABEL_MAP
void clear_src()
Clear the source region.
double unit_submerge() const
std::function< void(const rect &)> do_draw
Handles the actual drawing at this location.
void set_src(const rect &r)
Set the source region of the texture used for drawing operations.
bool minimap_movement_coding()
int h() const
The draw-space height of the texture, in pixels.
point get_raw_size() const
The raw internal texture size.
constexpr uint8_t float_to_color(double n)
Convert a double in the range [0.0,1.0] to an 8-bit colour value.
virtual void draw_invalidated()
Only called when there's actual redrawing to do.
map_location mouseoverHex_
void init_flags()
Init the flag list and the team colors used by ~TC.
Manages a list of fake units for the display object.
const rect & mini_map_location(const SDL_Rect &screen) const
void update_floating_labels()
virtual void draw_hex(const map_location &hex)
child_itors child_range(config_key_type key)
const int SIZE_BUTTON_SMALL
int current_refresh_rate()
The refresh rate of the screen.
void set_lifetime(int lifetime, int fadeout=100)
static lg::log_domain log_display("display")
display(const display_context *dc, std::weak_ptr< wb::manager > wb, reports &reports_object, const std::string &theme_id, const config &level)
int fps_handle_
Handle for the label which displays frames per second.
pango_text & set_link_aware(bool b)
bool show_everything() const
const rect & palette_location(const SDL_Rect &screen) const
The class terrain_builder is constructed from a config object, and a gamemap object.
map_location minimap_location_on(int x, int y)
given x,y co-ordinates of the mouse, will return the location of the hex in the minimap that the mous...
const std::vector< std::string > items
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
const terrain_type & get_terrain_info(const t_translation::terrain_code &terrain) const
bool is_shrouded(const display *disp, const map_location &loc)
Our definition of map labels being obscured is if the tile is obscured, or the tile below is obscured...
void set_tile_size(const unsigned int size)
void update()
Process animations, remove deleted halos, and invalidate screen regions now requiring redraw...
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
iterator & operator++()
increment y first, then when reaching bottom, increment x
std::vector< std::function< void(display &)> > redraw_observers_
map_location selectedHex_
void set_font_size(int font_size)
std::list< draw_helper > drawing_buffer_
static display * singleton_
Belongs to a friendly side.
void draw()
Perform rendering of invalidated items.
Top half part of grid image.
void draw_panel(const theme::panel &panel)
rect map_area() const
Returns the area used for the map.
Rectangular area of hexes, allowing to decide how the top and bottom edges handles the vertical shift...
An object to leave the synced context during draw or unsynced wml items when we don’t know whether w...
surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::map< map_location, unsigned int > *reach_map, bool ignore_terrain_disabled)
function to create the minimap for a given map the surface returned must be freed by the user ...
const std::vector< label > & labels() const
point get_size()
Returns the size of the text, in drawing coordinates.
static unsigned int zoom_
The current zoom, in pixels (on screen) per 72 pixels (in the graphic assets), i.e., 72 means 100%.
Toggle to continuously redraw the whole map.
pango_text & get_text_renderer()
Returns a reference to a static pango_text object.
void clear_redraw_observers()
Clear the redraw observers.
Standard hexagonal tile mask applied, removing portions that don't fit.
point get_size(const locator &i_locator, bool skip_cache)
Returns the width and height of an image.
pango_text & set_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
drawing_layer
The layers to render something on.
Same as HEXED, but with Time of Day color tint applied.
std::vector< texture > terrain_image_vector_
void redraw_minimap()
Schedule the minimap to be redrawn.
virtual const gamemap & map() const =0
bool contains(int x, int y) const
Whether the given point lies within the rectangle.
void reset_standing_animations()
void remove_arrow(arrow &)
void add_frame(int duration, const T &value, bool force_change=false)
Adds a frame to an animation.
filesystem::scoped_ostream ostream_file(const std::string &fname, std::ios_base::openmode mode, bool create_directory)
Wrapper class to encapsulate creation and management of an SDL_Texture.
void rect(const SDL_Rect &rect)
Draw a rectangle.
void init_flags_for_side_internal(std::size_t side, const std::string &side_color)
Unit and team statistics.
void invalidate_all()
Mark the entire screen as requiring redraw.
void queue_repaint()
Queues repainting to the screen, but doesn't rerender.
very simple iterator to walk into the rect_of_hexes
const rect_of_hexes get_visible_hexes() const
Returns the rectangular area of visible hexes.
pango_text & set_alignment(const PangoAlignment alignment)
std::vector< std::shared_ptr< gui::button > > action_buttons_
std::map< std::string, rect > reportLocations_
bool contains(const Container &container, const Value &value)
Returns true iff value is found in container.
const theme::action * action_pressed()
clip_setter override_clip(const SDL_Rect &clip)
Override the clipping area.
static const config & get_theme_config(const std::string &id)
Returns the saved config for the theme with the given ID.
const std::string & text() const
rect game_canvas()
The game canvas area, in drawing coordinates.
std::vector< std::string > shroud_images_
Object which defines a time of day with associated bonuses, image, sounds etc.
bool exists(const image::locator &i_locator)
Returns true if the given image actually exists, without loading it.
Overlays x,y coords on tiles.
void blindfold(bool flag)
bool draw_reports(const rect ®ion)
Draw all reports in the given region.
void set_fade(const color_t &color)
This class stores all the data for a single 'side' (in game nomenclature).
point draw_size() const
The size of the texture in draw-space.
Belongs to a non-friendly side; normally visualised by not displaying an orb.
rect max_map_area() const
Returns the maximum area used for the map regardless to resolution and view size. ...
static std::ostream & output()
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
render_target_setter set_render_target(const texture &t)
Set the given texture as the active render target.
std::vector< texture > get_fog_shroud_images(const map_location &loc, image::TYPE image_type)
const std::string & id() const
Gets this unit's id.
uint32_t last_frame_finished_
void get_terrain_images(const map_location &loc, const std::string &timeid, TERRAIN_TYPE terrain_type)
const arrow_path_t & get_previous_path() const
double turbo_speed() const
static bool zoom_at_max()
void draw_minimap()
Actually draw the minimap.
light_string get_light_string(int op, int r, int g, int b)
Returns the light_string for one light operation.
const std::string & prefix() const
std::map< std::string, texture > reportSurfaces_
void new_animation_frame()
static unsigned calculate_fps(unsigned frametime)
std::string label
What to show in the filter's drop-down list.
static bool outside_area(const SDL_Rect &area, const int x, const int y)
Check if the bbox of the hex at x,y has pixels outside the area rectangle.
bool tile_fully_on_screen(const map_location &loc) const
Check if a tile is fully visible on screen.
const theme::menu * menu_pressed()
int w() const
Effective map width.
void drawing_buffer_add(const drawing_layer layer, const map_location &loc, decltype(draw_helper::do_draw) draw_func)
Add an item to the drawing buffer.
Arrows destined to be drawn on the map.
surface screenshot(bool map_screenshot=false)
Capture a (map-)screenshot into a surface.
EXIT_STATUS start(const std::string &filename, bool take_screenshot, const std::string &screenshot_filename)
Main interface for launching the editor from the title screen.
texture get_flag(const map_location &loc)
std::string get_orb_color(orb_status os)
Wrapper for the various preferences::unmoved_color(), moved_color(), etc methods, using the enum inst...
bool font_rgb_set() const
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
std::string get_user_data_dir()
bool invalidate_visible_locations_in_rect(const SDL_Rect &rect)
void recalculate_minimap()
Schedule the minimap for recalculation.
void scroll_to_xy(int screenxpos, int screenypos, SCROLL_TYPE scroll_type, bool force=true)
config & add_child_at(config_key_type key, const config &val, unsigned index)
const rect & unit_image_location(const SDL_Rect &screen) const
bool map_screenshot_
Used to indicate to drawing functions that we are doing a map screenshot.
arrows_map_t arrows_map_
Maps the list of arrows for each location.
const std::unique_ptr< map_labels > map_labels_
void clip(const SDL_Rect &r)
Clip this rectangle by the given rectangle.
int xpos_
Position of the top-left corner of the viewport, in pixels.
::rect get_clip()
Get the current clipping area, in draw coordinates.
config generate_report(const std::string &name, context &ct, bool only_static=false)
void update_tod(const time_of_day *tod_override=nullptr)
Applies r,g,b coloring to the map.
rect intersect(const SDL_Rect &r) const
Calculates the intersection of this rectangle and another; that is, the maximal rectangle that is con...
std::string background_image
SDL_Rect minimap_location_
pango_text & set_characters_per_line(const unsigned characters_per_line)
The basic class for representing 8-bit RGB or RGBA colour values.
TERRAIN_TYPE
Used as a parameter for the get_terrain_at function.
bool headless()
The game is running headless.
void reinit_flags_for_team(const team &)
Rebuild the flag list (not team colors) for a single side.
fake_unit_manager * fake_units
bool is_enemy(int n) const
void draw_text_in_hex(const map_location &loc, const drawing_layer layer, const std::string &text, std::size_t font_size, color_t color, double x_in_hex=0.5, double y_in_hex=0.5)
Draw text on a hex.
void bounds_check_position()
Modify, read and display user preferences.
bool font_rgb_set() const
bool invalidateGameStatus_
void set_position(double xpos, double ypos)
void update_arrow(arrow &a)
Called by arrow objects when they change.
map_display and display: classes which take care of displaying the map and game-data on the screen...
virtual const unit_map & units() const =0
std::string shroud_prefix
Separates background and foreground terrain layers.
const std::string & get_id() const
const color_t YELLOW_COLOR
void update_render_textures()
Ensure render textures are valid and correct.
const rect_of_hexes hexes_under_rect(const SDL_Rect &r) const
Return the rectangular area of hexes overlapped by r (r is in screen coordinates) ...
void swap(config &lhs, config &rhs)
Implement non-member swap function for std::swap (calls config::swap).
void invalidate_all()
Function to invalidate all tiles.
void set_draw_size(int w, int h)
Set the intended size of the texture, in draw-space.
int invalidated_hexes_
Count work done for the debug info displayed under fps.
bool overlaps(const SDL_Rect &r) const
Whether the given rectangle and this rectangle overlap.
void pump()
Process all events currently in the queue.
const color_t NORMAL_COLOR
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
pango_text & set_family_class(font::family_class fclass)
Generic locator abstracting the location of an image.
void render(const rect &r)
Render halos in region.
static int hex_width()
Function which returns the width of a hex in pixels, up to where the next hex starts.
static unsigned int last_zoom_
The previous value of zoom_.
void set_color_adjustment(int r, int g, int b)
Changes Time of Day color tint for all applicable image types.
bool empty() const
False if both w and h are > 0, true otherwise.
handle add(int x, int y, const std::string &image, const map_location &loc, halo::ORIENTATION orientation=NORMAL, bool infinite=true)
Add a haloing effect using 'image centered on (x,y).
virtual rect get_clip_rect() const
Get the clipping rectangle for drawing.
virtual rect screen_location() override
Return the current draw location of the display, on the screen.
Dummy entry to size the bitmask.
Encapsulates the map of the game.
void set_color(const color_t &color)
void set_team(const team *)
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
boost::iterator_range< const_child_iterator > const_child_itors
unit_iterator find(std::size_t id)
std::unique_ptr< std::ostream > scoped_ostream
void tiled(const texture &tex, const SDL_Rect &dst, bool centered=false, bool mirrored=false)
Tile a texture to fill a region.
void process_reachmap_changes()
const border_t & border() const
clip_setter reduce_clip(const SDL_Rect &clip)
Set the clipping area to the intersection of the current clipping area and the given rectangle...
void recalculate_labels()
void set_theme(const std::string &new_theme)
std::string id
Text to match against addon_info.tags()
bool draw_all_panels(const rect ®ion)
Redraws all panels intersecting the given region.
virtual overlay_map & get_overlays()=0
constexpr color_t smooth_blend(const color_t &c, uint8_t p) const
Blend smoothly with another color_t.
virtual const std::vector< team > & teams() const =0
bool is_blindfolded() const
void fade_tod_mask(const std::string &old, const std::string &new_)
ToD mask smooth fade.
void scroll_to_tile(const map_location &loc, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true, bool force=true)
Scroll such that location loc is on-screen.
void announce(const std::string &msg, const color_t &color=font::GOOD_COLOR, const announce_options &options=announce_options())
Announce a message prominently.
virtual void highlight_hex(map_location hex)
Holds options for calls to function 'announce' (announce).
default layer for drawing moving units
const std::string & postfix() const
std::vector< std::shared_ptr< gui::button > > menu_buttons_
void set_diagnostic(const std::string &msg)
void scroll_to_tiles(map_location loc1, map_location loc2, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true, double add_spacing=0.0, bool force=true)
Scroll such that location loc1 is on-screen.
void invalidate_animations_location(const map_location &loc)
Per-location invalidation called by invalidate_animations() Extra game per-location invalidation (vil...
default layer for drawing units
map_location get_middle_location() const
static map_location::DIRECTION s
pango_text & set_font_size(unsigned font_size)
std::vector< std::string > names
unsigned int fps_counter_
virtual void update() override
Update animations and internal state.
void read(const config &cfg)
int get_location_y(const map_location &loc) const
virtual void render() override
Update offscreen render buffers.
std::basic_string< signed char > light_string
Type used to store color information of central and adjacent hexes.
void start_animation(int start_time, bool cycles=false)
Starts an animation cycle.
rect pango_draw_text(bool actually_draw, const rect &area, int size, const color_t &color, const std::string &text, int x, int y, bool use_tooltips, pango_text::FONT_STYLE style)
Draws text on the screen.
void render_map_outside_area()
Draw/redraw the off-map background area.
An abstract description of a rectangle with integer coordinates.
int add_floating_label(const floating_label &flabel)
add a label floating on the screen above everything else.
const std::string & image() const
virtual void layout() override
Finalize screen layout.
static void add_submerge_ipf_mod(std::string &image_path, int image_height, double submersion_amount, int shift=0)
bool tile_nearly_on_screen(const map_location &loc) const
Checks if location loc or one of the adjacent tiles is visible on screen.
bool invalidate_locations_in_rect(const SDL_Rect &rect)
invalidate all hexes under the rectangle rect (in screen coordinates)
bool on_board(const map_location &loc) const
Tell if a location is on the map.
Layer for the terrain drawn in front of the unit.
bool add_exclusive_draw(const map_location &loc, unit &unit)
Allows a unit to request to be the only one drawn in its hex.
const rect & palette_area() const
virtual void draw_hex(const map_location &loc)
Redraws a single gamemap location.
Declarations for File-IO.
Represents terrains which are to be drawn in front of them.
static bool zoom_at_min()
const menu * get_menu_item(const std::string &key) const
Used for the bottom half part of grid image.
const std::vector< action > & actions() const
const std::string & get_filename() const
Definitions for the terrain builder.
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Represents terrains which are to be drawn behind unit sprites.
Layer for the terrain drawn behind the unit.
void draw_label(const theme::label &label)
static int get_zoom_levels_index(unsigned int zoom_level)
config & add_child(config_key_type key)
void blit(const texture &tex, const SDL_Rect &dst)
Draws a texture, or part of a texture, at the given location.
std::vector< std::string > fog_images_
std::chrono::seconds fps_start_
std::vector< animated< image::locator > > imagelist
A shorthand typedef for a list of animated image locators, the base data type returned by the get_ter...
void reset()
Releases ownership of the managed texture and resets the ptr to null.
void set_team(std::size_t team, bool observe=false)
Sets the team controlled by the player using the computer.
const status_item * get_status_item(const std::string &item) const
std::map< map_location, unsigned int > reach_map
Helper for rendering the map by ordering draw operations.
bool set_resolution(const SDL_Rect &screen)
virtual rect & location(const SDL_Rect &screen) const
void draw_report(const std::string &report_name, bool test_run=false)
Draw the specified report.
std::bitset< __NUM_DEBUG_FLAGS > debug_flags_
Currently set debug flags.
const std::vector< team > & get_teams() const
static color_t get_minimap_color(int side)
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
const gamemap & get_map() const
const std::string & color() const
events::mouse_handler & get_mouse_handler_base() override
Get a reference to a mouse handler member a derived class uses.
exclusive_unit_draw_requests_t exclusive_unit_draw_requests_
map of hexes where only one unit should be drawn, the one identified by the associated id string ...
Overlays number of bitmaps on tiles.
events::generic_event scroll_event_
Event raised when the map is being scrolled.
texture get_lighted_texture(const image::locator &i_locator, const light_string &ls)
int lifetime
Lifetime measured in milliseconds.
void reload_map()
Updates internals that cache map size.
color_t rep() const
High-contrast shade, intended for the minimap markers.
orb_status unit_orb_status(const unit &u) const
Returns an enumurated summary of whether this unit can move and/or attack.
constexpr const SDL_Rect empty_rect
std::set< map_location > invalidated_
std::vector< std::string > split(const config_attribute_value &val)
void toggle_default_zoom()
Sets the zoom amount to the default.
std::map< std::string, config > reports_
const display_context * dc_
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
virtual void set_button_state()
const color_range & color_info(const std::string &name)
Functions to load and save images from/to disk.
Standard logging facilities (interface).
void add_redraw_observer(std::function< void(display &)> f)
Adds a redraw observer, a function object to be called when a full rerender is queued.
Overlays terrain codes on tiles.
void trim(std::string_view &s)
std::size_t font_size() const
rect map_outside_area() const
Returns the available area for a map, this may differ from the above.
A RAII object to temporary leave the synced context like in wesnoth.synchronize_choice.
const int SIZE_FLOAT_LABEL
bool debug_flag_set(DEBUG_FLAG flag) const
point get_location(const map_location &loc) const
const std::vector< menu > & menus() const
static void fill_images_list(const std::string &prefix, std::vector< std::string > &images)
const std::unique_ptr< fake_unit_manager > fake_unit_man_
std::vector< animated< image::locator > > flags_
Animated flags for each team.
const config & child_or_empty(config_key_type key) const
Returns the first child with the given key, or an empty config if there is none.
pango_text & set_maximum_height(int height, bool multiline)
virtual const time_of_day & get_time_of_day(const map_location &loc=map_location::null_location()) const
A config object defines a single node in a WML file, with access to child nodes.
texture get_texture(const image::locator &i_locator, TYPE type, bool skip_cache)
Returns an image texture suitable for hardware-accelerated rendering.
std::vector< std::tuple< int, int, int > > fps_history_
void remove_single_overlay(const map_location &loc, const std::string &toDelete)
remove_single_overlay will remove a single overlay from a tile
pango_text & set_foreground_color(const color_t &color)
const rect & unit_image_area() const
static map_location::DIRECTION n
std::shared_ptr< halo_record > handle
void add_overlay(const map_location &loc, const std::string &image, const std::string &halo="", const std::string &team_name="", const std::string &item_id="", bool visible_under_fog=true, float submerge=0.0f, float z_order=0)
Functions to add and remove overlays from locations.
int h() const
Effective map height.
bool scroll(int xmov, int ymov, bool force=false)
Scrolls the display by xmov,ymov pixels.
void fade_to(const color_t &color, int duration)
Screen fade.
void remove_overlay(const map_location &loc)
remove_overlay will remove all overlays on a tile.
bool animate_map_
Local cache for preferences::animate_map, since it is constantly queried.
Transitional API for porting SDL_ttf-based code to Pango.
void fill(const SDL_Rect &rect, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
Fill an area with the given colour.
static rng & default_instance()
const std::vector< panel > & panels() const
const rect & main_map_location(const SDL_Rect &screen) const
const std::unique_ptr< terrain_builder > builder_
texture front_
Render textures, for intermediate rendering.
void draw()
Trigger a draw cycle.
static const std::string & get_variant(const std::vector< std::string > &variants, const map_location &loc)
void invalidate_region(const rect ®ion)
Mark a region of the screen as requiring redraw.
std::string::const_iterator iterator
void refresh_report(const std::string &report_name, const config *new_cfg=nullptr)
Update the given report.
std::weak_ptr< wb::manager > wb_
std::shared_ptr< gui::button > find_menu_button(const std::string &id)
std::vector< std::string > square_parenthetical_split(const std::string &val, const char separator, const std::string &left, const std::string &right, const int flags)
Similar to parenthetical_split, but also expands embedded square brackets.
std::string remove_exclusive_draw(const map_location &loc)
Cancels an exclusive draw request.
std::pair< std::string, unsigned > item
"black stripes" on unreachable hexes.
void rebuild_all()
Rebuild all dynamic terrain.
bool propagate_invalidation(const std::set< map_location > &locs)
If this set is partially invalidated, invalidate all its hexes.
static SDL_Renderer * renderer()
void write(config &cfg) const