59 #include <boost/algorithm/string/trim.hpp>
72 using namespace std::chrono_literals;
76 #define ERR_DP LOG_STREAM(err, log_display)
77 #define WRN_DP LOG_STREAM(warn, log_display)
78 #define LOG_DP LOG_STREAM(info, log_display)
79 #define DBG_DP LOG_STREAM(debug, log_display)
82 #define zoom_levels (game_config::zoom_levels)
83 #define final_zoom_index (static_cast<int>(zoom_levels.size()) - 1)
84 #define DefaultZoom (game_config::tile_size)
85 #define SmallZoom (DefaultZoom / 2)
86 #define MinZoom (zoom_levels.front())
87 #define MaxZoom (zoom_levels.back())
105 float diff = *iter - *(iter - 1);
106 float lower = (zoom_level - *(iter - 1)) / diff;
107 float upper = (*iter - zoom_level) / diff;
120 std::vector<overlay>& overlays = get_overlays()[
loc];
121 auto pos =
std::find_if(overlays.begin(), overlays.end(),
122 [new_order = ov.z_order](
const overlay& existing) { return existing.z_order > new_order; });
124 auto inserted = overlays.emplace(pos, std::move(ov));
125 if(
const std::string&
halo = inserted->halo; !
halo.empty()) {
126 auto [x, y] = get_location_rect(
loc).center();
127 inserted->halo_handle = halo_man_.add(x, y,
halo,
loc);
133 get_overlays().erase(
loc);
139 [&toDelete](
const overlay& ov) {
return ov.
image == toDelete || ov.
halo == toDelete || ov.
id == toDelete; });
143 std::weak_ptr<wb::manager>
wb,
145 const std::string& theme_id,
150 , exclusive_unit_draw_requests_()
151 , viewing_team_index_(0)
152 , dont_show_all_(false)
153 , viewport_origin_(0, 0)
154 , view_locked_(false)
159 , minimap_renderer_(nullptr)
160 , minimap_location_()
161 , redraw_background_(false)
162 , invalidateAll_(true)
163 , diagnostic_label_(0)
164 , invalidateGameStatus_(true)
166 , reports_object_(&reports_object)
167 , scroll_event_(
"scrolled")
174 , tod_hex_mask1(nullptr)
175 , tod_hex_mask2(nullptr)
182 , animate_water_(true)
184 , playing_team_index_(0)
186 , map_screenshot_(false)
189 , reach_map_changed_(true)
190 , reach_map_team_index_(0)
191 , invalidated_hexes_(0)
193 , redraw_observers_()
212 if(tile_size < MinZoom || tile_size >
MaxZoom)
265 std::string
flag =
t.flag();
267 std::string new_rgb =
t.color();
273 LOG_DP <<
"Adding flag for side " <<
t.side() <<
" from animation " <<
flag;
279 const std::vector<std::string> sub_items =
utils::split(item,
':');
280 std::string img_path = item;
283 if(sub_items.size() > 1) {
284 img_path = sub_items.front();
286 time = std::max(1ms, std::chrono::milliseconds{
std::stoi(sub_items.back())});
287 }
catch(
const std::invalid_argument&) {
288 ERR_DP <<
"Invalid time value found when constructing flag for side " <<
t.side() <<
": " << sub_items.back();
298 auto time =
f.get_end_time();
301 f.start_animation(std::chrono::milliseconds{start_time},
true);
304 ERR_DP <<
"missing flag for side " <<
t.side();
313 if(
flag.need_update()) {
314 flag.advance_to_current_frame();
317 ?
flag.get_current_frame()
318 :
flag.get_first_frame();
349 if(std::shared_ptr<wb::manager>
w =
wb_.lock()) {
350 w->on_viewer_change(teamindex);
409 std::ostringstream
s;
415 images.push_back(
s.str());
420 images.emplace_back();
470 rect max_area{0, 0, 0, 0};
496 if(max_area.w < res.w) {
498 res.x += (res.w - max_area.w) / 2;
502 if(max_area.h < res.h) {
504 res.y += (res.h - max_area.h) / 2;
524 return (x < area.x || x > area.x + area.w - x_thresh || y < area.y || y > area.y + area.h - y_thresh);
550 const int offset = y < 0 ? 1 : 0;
556 const int tesselation_x_size =
hex_width() * 2;
557 const int tesselation_y_size =
s;
558 const int x_base = x / tesselation_x_size * 2;
559 const int x_mod = x % tesselation_x_size;
560 const int y_base = y / tesselation_y_size;
561 const int y_mod = y % tesselation_y_size;
566 if (y_mod < tesselation_y_size / 2) {
567 if ((x_mod * 2 + y_mod) < (
s / 2)) {
570 }
else if ((x_mod * 2 - y_mod) < (
s * 3 / 2)) {
579 if ((x_mod * 2 - (y_mod -
s / 2)) < 0) {
582 }
else if ((x_mod * 2 + (y_mod -
s / 2)) <
s * 2) {
591 return map_location(x_base + x_modifier - offset, y_base + y_modifier - offset);
618 if(r.w <= 0 || r.h <= 0) {
620 return {0, -1, {0, 0}, {0, 0}};
636 static_cast<int>(std::floor(-
border + x / tile_width - 0.3333333)),
640 static_cast<int>(std::floor(-
border + (x + r.w - 1) / tile_width)),
650 static_cast<int>(std::floor(-
border + (y + r.h - 1) /
tile_size - 0.5))
720 if (!map_screenshot) {
721 LOG_DP <<
"taking ordinary screenshot";
726 ERR_DP <<
"No map loaded, cannot create a map screenshot.";
736 if (area.w > 1 << 16 || area.h > 1 << 16) {
737 WRN_DP <<
"Excessively large map screenshot area";
739 LOG_DP <<
"creating " << area.w <<
" by " << area.h
740 <<
" texture for map screenshot";
741 texture output_texture(area.w, area.h, SDL_TEXTUREACCESS_TARGET);
747 DBG_DP <<
"invalidating region for map screenshot";
750 DBG_DP <<
"drawing map screenshot";
759 LOG_DP <<
"reading pixels for map screenshot";
785 DBG_DP <<
"positioning menu buttons...";
789 b->set_location(
loc);
790 b->set_measurements(0,0);
791 b->set_label(menu.title());
792 b->set_image(menu.image());
796 DBG_DP <<
"positioning action buttons...";
800 b->set_location(
loc);
801 b->set_measurements(0,0);
802 b->set_label(action.title());
803 b->set_image(action.image());
812 if(
type ==
"checkbox") {
814 }
else if(
type ==
"image") {
816 }
else if(
type ==
"radiobox") {
818 }
else if(
type ==
"turbo") {
833 std::vector<std::shared_ptr<gui::button>> menu_work;
834 std::vector<std::shared_ptr<gui::button>> action_work;
836 DBG_DP <<
"creating menu buttons...";
838 if(!menu.is_button()) {
845 DBG_DP <<
"drawing button " << menu.get_id();
846 b->set_id(menu.get_id());
847 if(!menu.tooltip().empty()) {
848 b->set_tooltip_string(menu.tooltip());
852 b->enable(b_prev->enabled());
855 menu_work.push_back(std::move(
b));
858 DBG_DP <<
"creating action buttons...";
860 auto b = std::make_shared<gui::button>(action.title(), string_to_button_type(action.type()),
863 DBG_DP <<
"drawing button " << action.get_id();
864 b->set_id(action.get_id());
865 if(!action.tooltip(0).empty()) {
866 b->set_tooltip_string(action.tooltip(0));
870 b->enable(b_prev->enabled());
872 b->set_check(b_prev->checked());
876 action_work.push_back(std::move(
b));
888 DBG_DP <<
"buttons created";
935 std::vector<std::string>
names;
938 enum visibility { FOG = 0, SHROUD = 1, CLEAR = 2 };
939 std::array<visibility, 6> tiles;
943 for(
int i = 0;
i < 6; ++
i) {
953 for(
int v = FOG; v != CLEAR; ++v) {
963 const std::string name = *image_prefix[v] +
"-all.png";
965 names.push_back(name);
975 for(
int i = (
start + 1) % 6, cap1 = 0;
i !=
start && cap1 != 6; ++cap1) {
977 std::ostringstream stream;
979 stream << *image_prefix[v];
981 for(
int cap2 = 0; v == tiles[
i] && cap2 != 6;
i = (
i + 1) % 6, ++cap2) {
997 names.push_back(name +
".png");
1006 std::vector<texture> res;
1008 for(
const std::string& name :
names) {
1010 res.push_back(std::move(tex));
1021 std::vector<image::light_adjust> lighting;
1026 std::array<
const time_of_day*, adjs.size()> atods;
1028 for(std::size_t
d = 0;
d < adjs.size(); ++
d) {
1032 for(
int d = 0;
d < 6; ++
d) {
1053 if(lighting.empty()) {
1056 lighting.emplace_back(0, col.
r, col.
g, col.
b);
1061 lighting.emplace_back(
d + 1, acol.
r, acol.
g, acol.
b);
1064 for(
int d = 0;
d < 6; ++
d) {
1085 if(lighting.empty()) {
1088 lighting.emplace_back(0, col.
r, col.
g, col.
b);
1093 lighting.emplace_back(
d + 7, acol.
r, acol.
g, acol.
b);
1096 for(
int d = 0;
d < 6; ++
d) {
1117 if(lighting.empty()) {
1120 lighting.emplace_back(0, col.
r, col.
g, col.
b);
1125 lighting.emplace_back(
d + 13, acol.
r, acol.
g, acol.
b);
1128 if(lighting.empty()){
1132 lighting.emplace_back(-1, col.
r, col.
g, col.
b);
1143 for(
const auto& terrain : *terrains) {
1151 const bool off_map = (
image.get_filename() == off_map_name
1152 ||
image.get_modifications().find(
"NO_TOD_SHIFT()") != std::string::npos);
1156 }
else if(lighting.empty()) {
1171 constexpr std::array layer_groups {
1185 BITS_FOR_LAYER_GROUP = 4,
1191 BITS_FOR_X_PARITY = 1,
1197 BITS_FOR_X_OVER_2 = 9,
1199 SHIFT_LAYER = BITS_FOR_X_OVER_2,
1201 SHIFT_X_PARITY = BITS_FOR_LAYER + SHIFT_LAYER,
1203 SHIFT_Y = BITS_FOR_X_PARITY + SHIFT_X_PARITY,
1205 SHIFT_LAYER_GROUP = BITS_FOR_Y + SHIFT_Y
1211 uint32_t group_i = layer_groups.size() - 1;
1214 while(layer < layer_groups[group_i]) {
1222 const uint32_t x_parity =
static_cast<uint32_t
>(
loc.
x) & 1;
1225 static_assert(SHIFT_LAYER_GROUP + BITS_FOR_LAYER_GROUP ==
sizeof(key) * 8,
"Bit field too small");
1227 key = (group_i << SHIFT_LAYER_GROUP) | (static_cast<uint32_t>(
loc.
y + MAX_BORDER) << SHIFT_Y);
1228 key |= (x_parity << SHIFT_X_PARITY);
1229 key |= (
static_cast<uint32_t
>(layer) << SHIFT_LAYER) |
static_cast<uint32_t
>(
loc.
x + MAX_BORDER) / 2;
1242 DBG_DP <<
"committing drawing buffer"
1263 std::invoke(helper.do_draw, helper.dest);
1272 if (panel.
image().empty()) {
1287 <<
" texture: " << panel.
image();
1302 const std::string& text =
label.text();
1304 const std::string& icon =
label.icon();
1308 if(icon.empty() ==
false) {
1311 if(text.empty() ==
false) {
1314 }
else if(text.empty() ==
false) {
1320 renderer.set_foreground_color(text_color);
1321 renderer.set_ellipse_mode(PANGO_ELLIPSIZE_END);
1325 auto t =
renderer.render_and_get_texture();
1354 const std::string& text,
1355 std::size_t font_size,
1360 if (text.empty())
return;
1366 renderer.set_maximum_height(-1,
false);
1367 renderer.set_foreground_color(color);
1371 draw::blit(tex, rect{ dest.point_at(x_in_hex, y_in_hex) - tex.draw_size() / 2, tex.draw_size() });
1414 if((*i)->pressed()) {
1430 if((*i)->pressed()) {
1518 double shift_x = -
border *
hex_width() - (map_out_rect.w - map_rect.w) / 2;
1519 double shift_y = -(
border + 0.25) *
hex_size() - (map_out_rect.h - map_rect.h) / 2;
1523 int view_w =
static_cast<int>(map_out_rect.w * xscaling);
1524 int view_h =
static_cast<int>(map_out_rect.h * yscaling);
1543 for(
const auto& u :
context().units()) {
1544 if (
fogged(u.get_location()) ||
1546 u.invisible(u.get_location())) ||
1551 int side = u.side();
1554 if(!
prefs::get().minimap_movement_coding()) {
1566 double u_x = u.get_location().x * xscaling;
1567 double u_y = (u.get_location().y + (
is_odd(u.get_location().x) ? 1 : -1)/4.0) * yscaling;
1569 double u_w = 4.0 / 3.0 * xscaling;
1570 double u_h = yscaling;
1575 , int(std::round(u_w))
1576 , int(std::round(u_h))
1590 if(amount ==
point{}) {
1651 r.y = r.y + r.h + diff.y;
1654 r.h = std::abs(diff.y);
1662 r.x = r.x + r.w + diff.x;
1665 r.w = std::abs(diff.x);
1700 LOG_DP <<
"new_zoom = " << new_zoom;
1702 if(new_zoom ==
zoom_) {
1706 if(validate_value_and_set_index) {
1711 if((new_zoom / 4) * 4 != new_zoom) {
1712 WRN_DP <<
"set_zoom forcing zoom " << new_zoom
1713 <<
" which is not a multiple of 4."
1714 <<
" This will likely cause graphical glitches.";
1721 double zoom_factor =
static_cast<double>(new_zoom) /
static_cast<double>(
zoom_);
1776 return x + hs >= area.x - hw && x < area.x + area.w + hw &&
1777 y + hs >= area.y - hs && y < area.y + area.h + hs;
1804 const double dist_total = std::hypot(move.x, move.y);
1805 double dist_moved = 0.0;
1807 using fractional_seconds = std::chrono::duration<double>;
1808 auto prev_time = std::chrono::steady_clock::now();
1810 double velocity = 0.0;
1811 while (dist_moved < dist_total) {
1814 auto time = std::chrono::steady_clock::now();
1815 auto dt = fractional_seconds{time - prev_time};
1818 dt = std::min<fractional_seconds>(dt, 200ms);
1821 const double dt_as_double = dt.count();
1827 double accel = velocity_max / accel_time;
1828 double decel = velocity_max / decel_time;
1831 double stop_time = velocity / decel;
1832 double dist_stop = dist_moved + velocity*stop_time - 0.5*decel*stop_time*stop_time;
1833 if (dist_stop > dist_total || velocity > velocity_max) {
1834 velocity -= decel * dt_as_double;
1835 if (velocity < 1.0) velocity = 1.0;
1837 velocity += accel * dt_as_double;
1838 if (velocity > velocity_max) velocity = velocity_max;
1841 dist_moved += velocity * dt_as_double;
1842 if (dist_moved > dist_total) dist_moved = dist_total;
1845 std::round(move.x * dist_moved / dist_total),
1846 std::round(move.y * dist_moved / dist_total)
1849 point diff = next_pos - prev_pos;
1861 ERR_DP <<
"Tile at " <<
loc <<
" isn't on the map, can't scroll to the tile.";
1870 double add_spacing,
bool force)
1872 scroll_to_tiles({loc1, loc2}, scroll_type, check_fogged,
false, add_spacing, force);
1877 bool only_if_possible,
double add_spacing,
bool force)
1887 if(
context().map().on_board(
loc) ==
false)
continue;
1888 if(check_fogged &&
fogged(
loc))
continue;
1899 int minx_new = std::min<int>(minx,x);
1900 int miny_new = std::min<int>(miny,y);
1901 int maxx_new = std::max<int>(maxx,x);
1902 int maxy_new = std::max<int>(maxy,y);
1908 if (only_if_possible)
return;
1921 int spacing = std::round(add_spacing *
hex_size());
1932 locs_bbox.w = maxx - minx +
hex_size();
1933 locs_bbox.h = maxy - miny +
hex_size();
1941 auto [map_center_x, map_center_y] = r.
center();
1947 double inside_frac = 0.5;
1948 w =
static_cast<int>(
w * inside_frac);
1949 h =
static_cast<int>(
h * inside_frac);
1959 r.x = target.x -
w/2;
1960 r.y = target.y -
h/2;
1968 if (map_center_x < r.x) {
1970 target.y = std::clamp(map_center_y, r.y, r.y + r.h - 1);
1971 }
else if (map_center_x > r.x+r.w-1) {
1972 target.x = r.x + r.w - 1;
1973 target.y = std::clamp(map_center_y, r.y, r.y + r.h - 1);
1974 }
else if (map_center_y < r.y) {
1976 target.x = std::clamp(map_center_x, r.x, r.x + r.w - 1);
1977 }
else if (map_center_y > r.y+r.h-1) {
1978 target.y = r.y + r.h - 1;
1979 target.x = std::clamp(map_center_x, r.x, r.x + r.w - 1);
1981 ERR_DP <<
"Bug in the scrolling code? Looks like we would not need to scroll after all...";
2004 xpos = std::clamp(xpos, 0, xend -
map_area().
w);
2005 ypos = std::clamp(ypos, 0, yend -
map_area().
h);
2011 if(
keys_[SDLK_LSHIFT] ||
keys_[SDLK_RSHIFT]) {
2039 if(submerge <= 0.0) {
2044 data.unsub_dest = dest;
2045 const int dest_sub_h = dest.h * submerge;
2046 data.unsub_dest.h -= dest_sub_h;
2047 const int dest_y_mid = dest.y +
data.unsub_dest.h;
2050 const int submersion_line =
size.y * (1.0 - submerge);
2051 data.unsub_src = {0, 0,
size.x, submersion_line};
2056 const SDL_FColor c_mid{1.0, 1.0, 1.0, mid_alpha};
2057 const int pixels_submerged =
size.y * submerge;
2058 float bot_alpha = 1.0;
2060 bot_alpha -= (pixels_submerged * 0.035) * (alpha/
ALPHA_OPAQUE);
2063 const SDL_FColor c_bot{1.0, 1.0, 1.0, std::max(bot_alpha, -1.0f)};
2064 const SDL_FPoint pML{float(dest.x), float(dest_y_mid)};
2065 const SDL_FPoint pMR{float(dest.x + dest.w), float(dest_y_mid)};
2066 const SDL_FPoint pBL{float(dest.x), float(dest.y + dest.h)};
2067 const SDL_FPoint pBR{float(dest.x + dest.w), float(dest.y + dest.h)};
2068 data.alpha_verts = {
2069 SDL_Vertex{pML, c_mid, {0.0, float(1.0 - submerge)}},
2070 SDL_Vertex{pMR, c_mid, {1.0, float(1.0 - submerge)}},
2071 SDL_Vertex{pBL, c_bot, {0.0, 1.0}},
2072 SDL_Vertex{pBR, c_bot, {1.0, 1.0}},
2076 for(SDL_Vertex& v :
data.alpha_verts) {
2077 v.tex_coord.x = 1.0 - v.tex_coord.x;
2081 for(SDL_Vertex& v :
data.alpha_verts) {
2082 v.tex_coord.y = 1.0 - v.tex_coord.y;
2090 const std::string& old_mask,
2091 const std::string& new_mask)
2098 auto start = std::chrono::steady_clock::now();
2099 for(
auto now =
start; now <
start + duration; now = std::chrono::steady_clock::now()) {
2113 auto start = std::chrono::steady_clock::now();
2118 if(fade_start.a == 0) {
2119 fade_start.r = fade_end.r;
2120 fade_start.g = fade_end.g;
2121 fade_start.b = fade_end.b;
2125 if(fade_end.a == 0) {
2126 fade_end.r = fade_start.r;
2127 fade_end.g = fade_start.g;
2128 fade_end.b = fade_start.b;
2132 for(
auto now =
start; now <
start + duration; now = std::chrono::steady_clock::now()) {
2153 DBG_DP <<
"redrawing everything";
2176 if(command_executor !=
nullptr) {
2220 DBG_DP <<
"display::draw denied";
2231 DBG_DP <<
"display::draw redraw background";
2237 if(!
context().map().empty()) {
2272 if (!
context().map().empty()) {
2277 DBG_DP <<
"draw() with invalidateAll";
2302 DBG_DP <<
"render prevented";
2307 tracked_drawable::update_count();
2324 DBG_DP <<
"draw prevented";
2359 DBG_DP <<
"display::expose " << region;
2389 bool raw_size_changed =
size.x != oarea.w ||
size.y != oarea.h;
2390 bool draw_size_changed = dsize.x != darea.w || dsize.y != darea.h;
2391 if (!raw_size_changed && !draw_size_changed) {
2396 if(raw_size_changed) {
2397 LOG_DP <<
"regenerating render buffers as " << oarea;
2398 front_ =
texture(oarea.w, oarea.h, SDL_TEXTUREACCESS_TARGET);
2399 back_ =
texture(oarea.w, oarea.h, SDL_TEXTUREACCESS_TARGET);
2401 if(raw_size_changed || draw_size_changed) {
2402 LOG_DP <<
"updating render buffer draw size to " << darea;
2408 for(
int i = 0;
i < 2; ++
i) {
2425 for(
int i = 0;
i < 2; ++
i) {
2456 DBG_DP <<
"drawing " <<
invalidated_.size() <<
" invalidated hexes with clip " << clip_rect;
2459 utils::optional<unit_drawer> drawer{};
2460 if(!
context().teams().empty()) {
2461 drawer.emplace(*
this);
2466 if(!hex_rect.
overlaps(clip_rect)) {
2476 drawer->redraw_unit(*u_it);
2491 int num_images_fg = 0;
2492 int num_images_bg = 0;
2540 const std::string& tod_hex_mask = tod.
image_mask;
2549 }
else if(!tod_hex_mask.empty()) {
2556 std::vector<texture> to_draw;
2557 for(
const arrow* a : arrows_in_hex->second) {
2572 const auto get_variant = [&
loc](
const std::vector<std::string>& variants) ->
const auto& {
2573 return variants[std::abs(
loc.
x +
loc.
y) % variants.size()];
2590 using namespace std::string_literals;
2605 std::ostringstream ss;
2615 ss << (num_images_bg + num_images_fg) <<
'\n';
2618 std::string
output = ss.str();
2628 renderer.set_alignment(PANGO_ALIGN_CENTER);
2630 renderer.set_maximum_height(-1,
false);
2635 const rect text_dest { dest.center() - tex.draw_size() / 2, tex.draw_size() };
2653 std::vector<overlay>& overlays = it->second;
2654 if(overlays.empty()) {
2663 for(
const overlay& ov : overlays) {
2672 bool item_visible_for_team = std::find_first_of(team_names.begin(), team_names.end(),
2673 current_team_names.begin(), current_team_names.end()) != team_names.end();
2675 if(!item_visible_for_team) {
2680 texture tex = ov.image.find(
"~NO_TOD_SHIFT()") == std::string::npos
2689 if(ovr_sub > 0.0 && ter_sub > 0.0) {
2691 double submerge = ter_sub * ovr_sub;
2694 = display::get_submerge_data(dest, submerge, tex.draw_size(), ALPHA_OPAQUE, false, false);
2699 tex.set_src(data.unsub_src);
2702 draw::smooth_shaded(tex, data.alpha_verts);
2705 draw::blit(tex, data.unsub_dest);
2708 draw::blit(tex, dest);
2740 if ( new_cfg ==
nullptr )
2741 new_cfg = &generated_cfg;
2748 if (
loc == new_loc && report == *new_cfg) {
2752 DBG_DP <<
"updating report: " << report_name;
2766 if (report.
empty())
return;
2771 std::string str = item->
prefix();
2806 int image_count = 0;
2807 bool used_ellipsis =
false;
2808 std::ostringstream ellipsis_tooltip;
2812 elements.begin() != elements.end(); elements.pop_front())
2815 if (area.h <= 0)
break;
2817 std::string
t = elements.front()[
"text"];
2820 if (used_ellipsis)
goto skip_element;
2825 if (
t[
t.size() - 1] ==
'\n') {
2827 t =
t.substr(0,
t.size() - 1);
2851 const int minimal_text = 12;
2853 if (!eol &&
loc.w - (x -
loc.
x + tsize.x) < minimal_text &&
2854 ++ee != elements.end() && !(*ee)[
"text"].empty())
2863 used_ellipsis =
true;
2864 ellipsis_area.x = x;
2865 ellipsis_area.y = y;
2866 ellipsis_area.w = tsize.x;
2867 ellipsis_area.h = tsize.y;
2872 if (!tooltip_test) {
2875 if (area.h > tallest) {
2886 else if (!(
t = elements.front()[
"image"].str()).empty())
2888 if (used_ellipsis)
goto skip_element;
2894 ERR_DP <<
"could not find image for report: '" <<
t <<
"'";
2898 if (area.w <
img.w() && image_count) {
2901 used_ellipsis =
true;
2904 if (
img.w() < area.w) area.w =
img.w();
2905 if (
img.h() < area.h) area.h =
img.h();
2906 if (!tooltip_test) {
2911 if (area.h > tallest) {
2915 if (!used_ellipsis) {
2918 ellipsis_area = area;
2928 t = elements.front()[
"tooltip"].t_str().c_str();
2930 if (tooltip_test && !used_ellipsis) {
2936 ellipsis_tooltip <<
t;
2938 if (++ee != elements.end())
2939 ellipsis_tooltip <<
"\n _________\n\n";
2944 if (tooltip_test && used_ellipsis) {
2953 const std::string& name = it.first;
2955 if(
loc.overlaps(region)) {
2965 DBG_DP <<
"invalidate_all()";
2999 bool result =
false;
3002 std::set<map_location>::const_iterator
i = locs.begin();
3005 if (
i != locs.end()) {
3028 DBG_DP <<
"invalidating locations in " <<
rect;
3030 bool result =
false;
3042 if(owner >= 0 &&
flags_[owner].need_update()
3066 u.anim_comp().refresh();
3069 u->anim_comp().refresh();
3076 new_inval |= u.anim_comp().invalidate(*
this);
3079 new_inval |= u->anim_comp().invalidate(*
this);
3089 u.anim_comp().set_standing();
3150 if (reach != full.end()) {
3169 if(!
context().teams().empty()){
static bool is_enemy(std::size_t side, std::size_t other_side)
void update_animation_timers(double acceleration)
Updates both animation timelines.
Arrows destined to be drawn on the map.
std::vector< std::string > names
Definitions for the terrain builder.
void add_frame(const std::chrono::milliseconds &duration, const T &value, bool force_change=false)
Appends a frame, starting where the previous one ends (or at start_time, if first).
Arrows destined to be drawn on the map.
const arrow_path_t & get_previous_path() const
const arrow_path_t & get_path() const
image::locator get_image_for_loc(const map_location &hex) const
color_t rep() const
High-contrast shade, intended for the minimap markers.
A config object defines a single node in a WML file, with access to child nodes.
config & add_child(std::string_view key)
child_itors child_range(std::string_view key)
config & add_child_at(std::string_view key, const config &val, std::size_t index)
boost::iterator_range< const_child_iterator > const_child_itors
config & mandatory_child(std::string_view key, int n=0)
Returns the nth child with the given key, or throws an error if there is none.
Abstract class for exposing game data that doesn't depend on the GUI, however which for historical re...
orb_status unit_orb_status(const unit &u) const
Returns an enumurated summary of whether this unit can move and/or attack.
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,...
const unit * get_visible_unit(const map_location &loc, const team ¤t_team, bool see_all=false) const
virtual const gamemap & map() const =0
virtual const std::vector< team > & teams() const =0
virtual const unit_map & units() const =0
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
const team & viewing_team() const
void unhide_buttons()
Unhide theme buttons so they draw again.
void set_viewing_team_index(std::size_t team, bool observe=false)
Sets the team controlled by the player using the computer.
bool map_screenshot_
Used to indicate to drawing functions that we are doing a map screenshot.
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 update_render_textures()
Ensure render textures are valid and correct.
bool invalidate_locations_in_rect(const rect &rect)
invalidate all hexes under the rectangle rect (in screen coordinates)
static unsigned int last_zoom_
The previous value of zoom_.
std::size_t viewing_team_index_
void write(config &cfg) const
static bool zoom_at_min()
void get_terrain_images(const map_location &loc, const std::string &timeid, TERRAIN_TYPE terrain_type)
void remove_overlay(const map_location &loc)
remove_overlay will remove all overlays on a tile.
map_location selectedHex_
void recalculate_minimap()
Schedule the minimap for recalculation.
bool unit_can_draw_here(const map_location &loc, const unit &unit) const
Returns true if there is no exclusive draw request for loc, or if there is, that it's for unit.
void redraw_minimap()
Schedule the minimap to be redrawn.
point get_location(const map_location &loc) const
Functions to get the on-screen positions of hexes.
virtual void render() override
Update offscreen render buffers.
void remove_single_overlay(const map_location &loc, const std::string &toDelete)
remove_single_overlay will remove a single overlay from a tile
void fade_tod_mask(const std::string &old, const std::string &new_)
ToD mask smooth fade.
bool add_exclusive_draw(const map_location &loc, const unit &unit)
Allows a unit to request to be the only one drawn in its hex.
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
void set_playing_team_index(std::size_t team)
sets the team whose turn it currently is
const team & playing_team() const
void announce(const std::string &msg, const color_t &color=font::GOOD_COLOR, const announce_options &options=announce_options())
Announce a message prominently.
double turbo_speed() const
void scroll_to_xy(const point &screen_coordinates, SCROLL_TYPE scroll_type, bool force=true)
int invalidated_hexes_
Count work done for the debug info displayed under fps.
void adjust_color_overlay(int r, int g, int b)
Add r,g,b to the colors for all images displayed on the map.
void set_fade(const color_t &color)
void queue_repaint()
Queues repainting to the screen, but doesn't rerender.
static int hex_size()
Function which returns the size of a hex in pixels (from left tip to right tip or top edge to bottom ...
static double get_zoom_factor()
Returns the current zoom factor.
const rect & unit_image_area() const
bool propagate_invalidation(const std::set< map_location > &locs)
If this set is partially invalidated, invalidate all its hexes.
void clear_redraw_observers()
Clear the redraw observers.
void invalidate_game_status()
Function to invalidate the game status displayed on the sidebar.
const theme::action * action_pressed()
static submerge_data get_submerge_data(const rect &dest, double submerge, const point &size, uint8_t alpha, bool hreverse, bool vreverse)
std::shared_ptr< gui::button > find_action_button(const std::string &id)
Retrieves a pointer to a theme UI button.
void set_theme(const std::string &new_theme)
void rebuild_all()
Rebuild all dynamic terrain.
void change_display_context(const display_context *dc)
void set_prevent_draw(bool pd=true)
Prevent the game display from drawing.
virtual overlay_map & get_overlays()=0
virtual void layout() override
Finalize screen layout.
virtual void highlight_hex(map_location hex)
void update_tod(const time_of_day *tod_override=nullptr)
Applies r,g,b coloring to the map.
void add_redraw_observer(const std::function< void(display &)> &f)
Adds a redraw observer, a function object to be called when a full rerender is queued.
bool invalidate_visible_locations_in_rect(const rect &rect)
static bool zoom_at_max()
static display * singleton_
std::shared_ptr< gui::button > find_menu_button(const std::string &id)
void render_map_outside_area()
Draw/redraw the off-map background area.
std::size_t playing_team_index() const
The playing team is the team whose turn it is.
void remove_arrow(arrow &)
@ DEBUG_COORDINATES
Overlays x,y coords on tiles.
@ DEBUG_BENCHMARK
Toggle to continuously redraw the whole map.
@ DEBUG_NUM_BITMAPS
Overlays number of bitmaps on tiles.
@ NUM_DEBUG_FLAGS
Dummy entry to size the bitmask.
@ DEBUG_FOREGROUND
Separates background and foreground terrain layers.
@ DEBUG_TERRAIN_CODES
Overlays terrain codes on tiles.
void process_reachmap_changes()
void draw_minimap_units()
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.
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 invalidate_animations_location(const map_location &loc)
Per-location invalidation called by invalidate_animations() Extra game per-location invalidation (vil...
map_location mouseoverHex_
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
bool set_zoom(bool increase)
Zooms the display in (true) or out (false).
std::map< std::string, rect > reportLocations_
const rect_of_hexes get_visible_hexes() const
Returns the rectangular area of visible hexes.
void draw_overlays_at(const map_location &loc)
texture get_flag(const map_location &loc)
void invalidate_all()
Function to invalidate all tiles.
std::map< std::string, config > reports_
point viewport_origin_
Position of the top-left corner of the viewport, in pixels.
map_location get_middle_location() const
void bounds_check_position()
std::function< rect(rect)> minimap_renderer_
surface screenshot(bool map_screenshot=false)
Capture a (map-)screenshot into a surface.
void init_flags()
Init the flag list and the team colors used by ~TC.
std::vector< std::shared_ptr< gui::button > > action_buttons_
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.
rect map_outside_area() const
Returns the available area for a map, this may differ from the above.
std::size_t reach_map_team_index_
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
bool tile_nearly_on_screen(const map_location &loc) const
Checks if location loc or one of the adjacent tiles is visible on screen.
void reload_map()
Updates internals that cache map size.
rect max_map_area() const
Returns the maximum area used for the map regardless to resolution and view size.
bool tile_fully_on_screen(const map_location &loc) const
Check if a tile is fully visible on screen.
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...
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.
bool is_blindfolded() const
std::vector< texture > terrain_image_vector_
std::vector< std::string > fog_images_
void fade_to(const color_t &color, const std::chrono::milliseconds &duration)
Screen fade.
const display_context & context() const
std::map< map_location, std::list< arrow * > > arrows_map_
Maps the list of arrows for each location.
void add_overlay(const map_location &loc, overlay &&ov)
Functions to add and remove overlays from locations.
std::vector< std::function< void(display &)> > redraw_observers_
void read(const config &cfg)
const theme::menu * menu_pressed()
const rect_of_hexes hexes_under_rect(const rect &r) const
Return the rectangular area of hexes overlapped by r (r is in screen coordinates)
const std::unique_ptr< terrain_builder > builder_
std::vector< animated< image::locator > > flags_
Animated flags for each team.
rect get_location_rect(const map_location &loc) const
Returns the on-screen rect corresponding to a loc.
static void fill_images_list(const std::string &prefix, std::vector< std::string > &images)
void draw_report(const std::string &report_name, bool test_run=false)
Draw the specified report.
std::set< map_location > invalidated_
virtual const time_of_day & get_time_of_day(const map_location &loc=map_location::null_location()) const =0
std::vector< texture > get_fog_shroud_images(const map_location &loc, image::TYPE image_type)
void queue_rerender()
Marks everything for rendering including all tiles and sidebar.
std::string remove_exclusive_draw(const map_location &loc)
Cancels an exclusive draw request.
bool invalidateGameStatus_
virtual void draw_invalidated()
Only called when there's actual redrawing to do.
void drawing_buffer_commit()
Draws the drawing_buffer_ and clears it.
rect map_area() const
Returns the area used for the map.
void draw_panel(const theme::panel &panel)
static int hex_width()
Function which returns the "average" width of a hex in pixels, up to where the next hex starts (half ...
void reset_standing_animations()
bool animate_water_
Local version of prefs::get().animate_water, used to detect when it's changed.
bool debug_flag_set(DEBUG_FLAG flag) const
void toggle_default_zoom()
Sets the zoom amount to the default.
virtual rect get_clip_rect() const
Get the clipping rectangle for drawing.
reports * reports_object_
bool draw_reports(const rect ®ion)
Draw all reports in the given region.
void invalidate_animations()
Function to invalidate animated terrains and units which may have changed.
virtual rect screen_location() override
Return the current draw location of the display, on the screen.
void hide_buttons()
Hide theme buttons so they don't draw.
virtual bool expose(const rect ®ion) override
Paint the indicated region to the screen.
std::list< draw_helper > drawing_buffer_
std::vector< std::shared_ptr< gui::button > > menu_buttons_
virtual void update() override
Update animations and internal state.
void draw()
Perform rendering of invalidated items.
const rect & minimap_area() const
mapx is the width of the portion of the display which shows the game area.
events::generic_event scroll_event_
Event raised when the map is being scrolled.
bool show_everything() const
virtual void draw_hex(const map_location &loc)
Redraws a single gamemap location.
const rect & palette_area() const
std::map< map_location, unsigned int > reach_map
std::size_t playing_team_index_
void reinit_flags_for_team(const team &)
Rebuild the flag list (not team colors) for a single side.
void draw_minimap()
Actually draw the minimap.
texture front_
Render textures, for intermediate rendering.
std::size_t viewing_team_index() const
The viewing team is the team currently viewing the game.
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...
void update_arrow(arrow &a)
Called by arrow objects when they change.
void draw_label(const theme::label &label)
const std::unique_ptr< fake_unit_manager > fake_unit_man_
const display_context * dc_
static bool outside_area(const 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 animate_map_
Local cache for prefs::get().animate_map, since it is constantly queried.
std::vector< std::string > shroud_images_
bool scroll(const point &amount, bool force=false)
Scrolls the display by amount pixels.
static unsigned int zoom_
The current zoom, in pixels (on screen) per 72 pixels (in the graphic assets), i.e....
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
std::bitset< NUM_DEBUG_FLAGS > debug_flags_
Currently set debug flags.
void blindfold(bool flag)
void refresh_report(const std::string &report_name, const config *new_cfg=nullptr)
Update the given report.
std::weak_ptr< wb::manager > wb_
const std::unique_ptr< map_labels > map_labels_
void set_diagnostic(const std::string &msg)
virtual void select_hex(map_location hex)
std::map< std::string, texture > reportSurfaces_
bool draw_all_panels(const rect ®ion)
Redraws all panels intersecting the given region.
display(const display_context *dc, std::weak_ptr< wb::manager > wb, reports &reports_object, const std::string &theme_id, const config &level)
virtual void notify_observers()
Manages a list of fake units for the display object.
void set_position(double xpos, double ypos)
void set_lifetime(const std::chrono::milliseconds &lifetime, const std::chrono::milliseconds &fadeout=std::chrono::milliseconds{100})
void set_color(const color_t &color)
void set_clip_rect(const rect &r)
void set_font_size(int font_size)
pango_text & set_font_style(const FONT_STYLE font_style)
point get_size()
Returns the size of the text, in drawing coordinates.
pango_text & set_characters_per_line(const unsigned characters_per_line)
pango_text & set_foreground_color(const color_t &color)
pango_text & set_family_class(font::family_class fclass)
pango_text & set_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
pango_text & set_alignment(const PangoAlignment alignment)
pango_text & set_font_size(unsigned font_size)
pango_text & set_link_aware(bool b)
bool set_text(const std::string &text, const bool markedup)
Sets the text to render.
pango_text & set_maximum_height(int height, bool multiline)
pango_text & set_maximum_width(int width)
texture render_and_get_texture()
Returns the cached texture, or creates a new one otherwise.
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
int w() const
Effective map width.
int h() const
Effective map height.
bool on_board(const map_location &loc) const
Tell if a location is on the map.
const terrain_type & get_terrain_info(const t_translation::terrain_code &terrain) const
void update()
Process animations, remove deleted halos, and invalidate screen regions now requiring redraw.
void render(const rect &r)
Render halos in region.
virtual void set_button_state()
Generic locator abstracting the location of an image.
A RAII object to temporary leave the synced context like in wesnoth.synchronize_choice.
void recalculate_shroud()
void set_team(const team *)
void recalculate_labels()
events::mouse_handler & get_mouse_handler_base() override
Get a reference to a mouse handler member a derived class uses.
hotkey::command_executor * get_hotkey_command_executor() override
Optionally get a command executor to handle context menu events.
static rng & default_instance()
int get_random_int(int min, int max)
config generate_report(const std::string &name, const context &ct)
Generate the specified report using the given context.
An object to leave the synced context during draw or unsynced wml items when we don’t know whether we...
This class stores all the data for a single 'side' (in game nomenclature).
static color_t get_minimap_color(int side)
bool shrouded(const map_location &loc) const
bool fogged(const map_location &loc) const
The class terrain_builder is constructed from a config object, and a gamemap object.
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...
TERRAIN_TYPE
Used as a parameter for the get_terrain_at function.
@ BACKGROUND
Represents terrains which are to be drawn behind unit sprites.
@ FOREGROUND
Represents terrains which are to be drawn in front of them.
double unit_submerge() const
Wrapper class to encapsulate creation and management of an SDL_Texture.
void reset()
Releases ownership of the managed texture and resets the ptr to null.
void set_src(const rect &r)
Set the source region of the texture used for drawing operations.
point draw_size() const
The size of the texture in draw-space.
void set_draw_size(int w, int h)
Set the intended size of the texture, in draw-space.
point get_raw_size() const
The raw internal texture size.
void set_alpha_mod(uint8_t alpha)
Alpha modifier.
void clear_src()
Clear the source region.
const std::string & get_id() const
virtual rect & location(const rect &screen) const
const std::string & image() const
std::size_t font_size() const
const std::string & postfix() const
bool font_rgb_set() const
virtual rect & location(const rect &screen) const
const std::string & prefix() const
const border_t & border() const
static NOT_DANGLING const config & get_theme_config(const std::string &id)
Returns the saved config for the theme with the given ID.
bool set_resolution(const rect &screen)
const menu * get_menu_item(const std::string &key) const
const rect & unit_image_location(const rect &screen) const
const std::vector< action > & actions() const
const std::vector< menu > & menus() const
const std::vector< panel > & panels() const
const rect & mini_map_location(const rect &screen) const
const rect & palette_location(const rect &screen) const
const status_item * get_status_item(const std::string &item) const
const rect & main_map_location(const rect &screen) const
const std::vector< label > & labels() const
unit_iterator find(std::size_t id)
This class represents a single unit of a specific type.
constexpr uint8_t ALPHA_OPAQUE
constexpr uint8_t float_to_color(double n)
Convert a double in the range [0.0,1.0] to an 8-bit colour value.
void swap(config &lhs, config &rhs) noexcept
Implement non-member swap function for std::swap (calls config::swap).
static int get_zoom_levels_index(unsigned int zoom_level)
static lg::log_domain log_display("display")
map_display and display: classes which take care of displaying the map and game-data on the screen.
static SDL_Renderer * renderer()
Drawing functions, for drawing things on the screen.
@ border
The border of the map.
@ terrain_bg
Terrain drawn behind the unit.
@ grid_bottom
Bottom half part of grid image.
@ unit_default
Default layer for drawing units.
@ unit_first
Reserve layers to be selected for wml.
@ terrain_fg
Terrain drawn in front of the unit.
@ fog_shroud
Fog and shroud.
@ unit_move_default
Default layer for drawing moving units.
@ arrows
Arrows from the arrows framework.
@ grid_top
Top half part of grid image.
Declarations for File-IO.
const std::string & id() const
Gets this unit's id.
int side() const
The side this unit belongs to.
std::string label
What to show in the filter's drop-down list.
std::string id
Text to match against addon_info.tags()
void get_adjacent_tiles(const map_location &a, utils::span< map_location, 6 > res)
Function which, given a location, will place all adjacent locations in res.
static std::ostream & output()
Standard logging facilities (interface).
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...
constexpr bool is_odd(T num)
constexpr double normalize_progress(const std::chrono::duration< RepE, PeriodE > &elapsed, const std::chrono::duration< RepD, PeriodD > &duration)
void invalidate_region(const rect ®ion)
Mark a region of the screen as requiring redraw.
void invalidate_all()
Mark the entire screen as requiring redraw.
render_target_setter set_render_target(const texture &t)
Set the given texture as the active render target.
void tiled(const texture &tex, const ::rect &dst, bool centered=false, bool mirrored=false)
Tile a texture to fill a region.
void rect(const ::rect &rect)
Draw a rectangle.
clip_setter reduce_clip(const ::rect &clip)
Set the clipping area to the intersection of the current clipping area and the given rectangle.
clip_setter override_clip(const ::rect &clip)
Override the clipping area.
void fill(const ::rect &rect, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
Fill an area with the given colour.
::rect get_clip()
Get the current clipping area, in draw coordinates.
void blit(const texture &tex, const ::rect &dst)
Draws a texture, or part of a texture, at the given location.
EXIT_STATUS start(bool clear_id, const std::string &filename, bool take_screenshot, const std::string &screenshot_filename)
Main interface for launching the editor from the title screen.
void draw()
Trigger a draw cycle.
void pump_and_draw()
pump() then immediately draw()
void pump()
Process all events currently in the queue.
const int SIZE_FLOAT_LABEL
const color_t YELLOW_COLOR
pango_text & get_text_renderer()
Returns a reference to a static pango_text object.
int add_floating_label(const floating_label &flabel)
add a label floating on the screen above everything else.
const int SIZE_BUTTON_SMALL
void scroll_floating_labels(double xmove, double ymove)
moves all floating labels that have 'scroll_mode' set to ANCHOR_LABEL_MAP
void remove_floating_label(int handle, const std::chrono::milliseconds &fadeout)
removes the floating label given by 'handle' from the screen
void update_floating_labels()
void draw_floating_labels()
const color_t NORMAL_COLOR
const color_range & color_info(std::string_view name)
std::string shroud_prefix
bool is_in_dialog()
Is a dialog open?
Functions to load and save images from/to disk.
bool exists(const image::locator &i_locator)
Returns true if the given image actually exists, without loading it.
std::function< rect(rect)> prep_minimap_for_rendering(const gamemap &map, const team *vw, const unit_map *units, const std::map< map_location, unsigned int > *reach_map, bool ignore_terrain_disabled)
Prepares the minimap texture and returns a function which will render it to the current rendering tar...
TYPE
Used to specify the rendering format of images.
@ HEXED
Standard hexagonal tile mask applied, removing portions that don't fit.
@ TOD_COLORED
Same as HEXED, but with Time of Day color tint applied.
texture get_texture(const image::locator &i_locator, TYPE type, bool skip_cache)
Returns an image texture suitable for hardware-accelerated rendering.
texture get_lighted_texture(const image::locator &i_locator, const std::vector< light_adjust > &ls)
void set_color_adjustment(int r, int g, int b)
Changes Time of Day color tint for all applicable image types.
std::string img(const std::string &src, const std::string &align, bool floating)
Generates a Help markup tag corresponding to an image.
std::string get_orb_color(orb_status os)
Wrapper for the various prefs::get().unmoved_color(), moved_color(), etc methods, using the enum inst...
Unit and team statistics.
::tod_manager * tod_manager
fake_unit_manager * fake_units
play_controller * controller
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
std::size_t index(std::string_view str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
std::vector< std::string_view > split_view(std::string_view s, const char sep, const int flags)
void trim(std::string_view &s)
int stoi(std::string_view str)
Same interface as std::stoi and meant as a drop in replacement, except:
bool contains(const Container &container, const Value &value)
Returns true iff value is found in container.
auto * find_if(Container &container, const Predicate &predicate)
Convenience wrapper for using find_if on a container without needing to comare to end()
void erase_if(Container &container, const Predicate &predicate)
Convenience wrapper for using std::remove_if on a container.
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::vector< std::string > split(const config_attribute_value &val)
bool headless()
The game is running headless.
rect game_canvas()
The game canvas area, in drawing coordinates.
int get_pixel_scale()
Get the current active pixel scale multiplier.
surface read_pixels(rect *r)
Copy back a portion of the render target that is already drawn.
std::string to_string(const Range &range, const Func &op)
std::string::const_iterator iterator
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
@ allied
Belongs to a friendly side.
@ enemy
Belongs to a non-friendly side; normally visualised by not displaying an orb.
static const unit * get_visible_unit(const reports::context &rc)
Transitional API for porting SDL_ttf-based code to Pango.
rect dst
Location on the final composed sheet.
rect src
Non-transparent portion of the surface to compose.
The basic class for representing 8-bit RGB or RGBA colour values.
constexpr color_t smooth_blend(const color_t &c, uint8_t p) const
Blend smoothly with another color_t.
Holds options for calls to function 'announce' (announce).
bool discard_previous
An announcement according these options should replace the previous announce (typical of fast announc...
std::chrono::milliseconds lifetime
Lifetime measured in milliseconds.
Helper for rendering the map by ordering draw operations.
std::function< void(const rect &)> do_draw
Handles the actual drawing at this location.
very simple iterator to walk into the rect_of_hexes
iterator & operator++()
increment y first, then when reaching bottom, increment x
const rect_of_hexes & rect_
Rectangular area of hexes, allowing to decide how the top and bottom edges handles the vertical shift...
Type used to store color information of central and adjacent hexes.
Encapsulates the map of the game.
static std::string write_direction(direction dir)
direction
Valid directions which can be moved in our hexagonal world.
void write(config &cfg) const
An abstract description of a rectangle with integer coordinates.
void clip(const rect &r)
Clip this rectangle by the given rectangle.
constexpr point center() const
The center point of the rectangle, accounting for origin.
bool empty() const
False if both w and h are > 0, true otherwise.
constexpr point origin() const
bool contains(int x, int y) const
Whether the given point lies within the rectangle.
constexpr rect padded_by(int dx, int dy) const
Returns a new rectangle with dx horizontal padding and dy vertical padding.
rect intersect(const rect &r) const
Calculates the intersection of this rectangle and another; that is, the maximal rectangle that is con...
constexpr point size() const
void shift(const point &p)
Shift the rectangle by the given relative position.
bool overlaps(const rect &r) const
Whether the given rectangle and this rectangle overlap.
std::string background_image
Object which defines a time of day with associated bonuses, image, sounds etc.
tod_color color
The color modifications that should be made to the game board to reflect the time of day.
std::string image_mask
The image that is to be laid over all images while this time of day lasts.
Small struct to store and manipulate ToD color adjusts.
static map_location::direction s