20 #include <QApplication>
22 #include <QImageReader>
87 #define TILESPEC_CAPSTR \
88 "+Freeciv-tilespec-Devel-2019-Jul-03 duplicates_ok precise-hp-bars " \
89 "unlimited-unit-select-frames unlimited-upkeep-sprites hex_corner " \
90 "terrain-specific-extras options"
118 #define SPEC_CAPSTR "+Freeciv-spec-Devel-2019-Jul-03 options"
128 #define TILESPEC_SUFFIX ".tilespec"
129 #define TILE_SECTION_PREFIX "tile_"
134 #define MAX_NUM_LAYERS 3
231 std::vector<tileset_log_entry>
log;
235 std::vector<std::unique_ptr<freeciv::layer>>
layers;
281 bool verbose,
int topology_id);
296 va_start(args, format);
297 auto buf = QString::vasprintf(format, args);
306 qFatal(
"%s", qUtf8Printable(buf));
309 qCCritical(tileset_category).noquote() << buf;
312 qCWarning(tileset_category).noquote() << buf;
315 qCInfo(tileset_category).noquote() << buf;
318 qCDebug(tileset_category).noquote() << buf;
338 return t->
type == TS_ISOMETRIC;
447 max = std::max(max, sprite->height());
453 max = std::max(max, sprite->height());
479 return MAX(uk_bottom, u_bottom);
533 return t->
fogstyle == freeciv::FOG_AUTO;
617 return QStringLiteral(
"n");
619 return QStringLiteral(
"ne");
621 return QStringLiteral(
"e");
623 return QStringLiteral(
"se");
625 return QStringLiteral(
"s");
627 return QStringLiteral(
"sw");
629 return QStringLiteral(
"w");
631 return QStringLiteral(
"nw");
633 qCCritical(tileset_category,
"Wrong direction8 variant: %d.", dir);
634 return QLatin1String(
"");
644 for (dir = direction8_begin(); dir != direction8_end();
645 dir = direction8_next(dir)) {
651 return direction8_invalid();
661 return dir != DIR8_NORTHEAST && dir != DIR8_SOUTHWEST;
663 return dir != DIR8_NORTHWEST && dir != DIR8_SOUTHEAST;
680 return (dir == DIR8_NORTH || dir == DIR8_EAST || dir == DIR8_SOUTH
681 || dir == DIR8_WEST);
693 if ((actual_topology & TF_HEX) && (actual_topology & TF_ISO)) {
695 }
else if (actual_topology & TF_ISO) {
697 }
else if (actual_topology & TF_HEX) {
711 const auto type = QEvent::registerEventType();
737 tilesets[idx]->clear();
738 for (
const auto &file : qAsConst(*list)) {
742 tilesets[idx]->append(file);
748 return tilesets[idx];
760 if (!tileset_name.isEmpty()) {
767 if (!dname.isEmpty()) {
782 const char *us_capstr,
783 const char *filename,
bool verbose)
789 if (
nullptr == file_capstr) {
790 log_base(
level,
"\"%s\": %s file doesn't have a capability string",
795 log_base(
level,
"\"%s\": %s file appears incompatible:", filename,
803 "\"%s\": %s file requires option(s) "
804 "that client doesn't support:",
865 if (tileset_name.isEmpty()
871 for (
const auto &file : qAsConst(*list)) {
893 _(
"No usable default tileset found, aborting!"));
896 qCDebug(tileset_category,
"Trying tileset \"%s\".",
tileset->
name);
920 bool new_tileset_in_use;
922 qCInfo(tileset_category,
_(
"Loading tileset \"%s\"."),
923 qUtf8Printable(
name));
935 const char *old_name =
nullptr;
947 new_tileset_in_use =
true;
949 new_tileset_in_use =
false;
955 "Failed to re-read the currently loaded tileset.");
960 if (game_fully_initialized) {
986 return new_tileset_in_use;
992 _(
"Map topology and tileset incompatible."));
1010 for (
auto &pnation :
nations) {
1026 for (
id = 0;
id <
game.
control.styles_count;
id++) {
1032 return new_tileset_in_use;
1048 auto widgets = QApplication::allWidgets();
1049 for (
auto *w : qAsConst(widgets)) {
1050 if (w->windowType() != Qt::Desktop) {
1052 QApplication::sendEvent(w, &e);
1056 return new_tileset_in_use;
1065 const char *tileset_name;
1078 fc_assert_ret(
nullptr != tileset_name && tileset_name[0] !=
'\0');
1104 auto s =
new QPixmap(20, 20);
1116 auto supported = QImageReader::supportedImageFormats();
1120 supported.prepend(
"png");
1122 for (
auto gfx_fileext : qAsConst(supported)) {
1123 QString real_full_name;
1125 QStringLiteral(
"%1.%2").arg(gfx_filename, gfx_fileext.data());
1129 if (!real_full_name.isEmpty()) {
1130 log_debug(
"trying to load gfx file \"%s\".",
1131 qUtf8Printable(real_full_name));
1132 if (
const auto s =
load_gfxfile(qUtf8Printable(real_full_name)); s) {
1138 qCCritical(tileset_category,
"Could not load gfx file \"%s\".",
1149 const char *gfx_filename;
1175 _(
"Could not load gfx file for the spec file \"%s\"."),
1190 struct section_list *sections;
1200 _(
"Specfile %s has incompatible capabilities"),
1214 int x_top_left, y_top_left, dx, dy;
1222 file, pixel_border_x,
"%s.pixel_border_y", sec_name);
1224 file, pixel_border_x,
"%s.pixel_border_x", sec_name);
1230 qCCritical(tileset_category,
"Grid \"%s\" invalid: %s", sec_name,
1250 file, &num_tags,
"%s.tiles%d.tag", sec_name, j))) {
1251 qCCritical(tileset_category,
1252 "Small sprite \"%s.tiles%d\" invalid: %s", sec_name, j,
1265 file,
"",
"%s.tiles%d.option", sec_name, j));
1270 t, QtWarningMsg,
"%s: unknown option %s for sprite %s",
1281 xr = x_top_left + (dx + pixel_border_x) * column;
1282 yb = y_top_left + (dy + pixel_border_y) * row;
1298 if (!duplicates_ok) {
1299 for (k = 0; k < num_tags; k++) {
1303 qCCritical(tileset_category,
1304 "warning: %s: already have a sprite for \"%s\".",
1310 for (k = 0; k < num_tags; k++) {
1320 section_list_destroy(sections);
1328 const char *filename;
1333 "extra.sprites%d.tag", i))
1336 qCCritical(tileset_category,
1337 "Extra sprite \"extra.sprites%d\" invalid: %s", i,
1347 auto option = QString::fromUtf8(
1352 tileset_error(t, QtWarningMsg,
"%s: unknown option %s for sprite %s",
1370 if (!duplicates_ok) {
1371 for (k = 0; k < num_tags; k++) {
1373 qCWarning(tileset_category,
1374 "%s: already have a sprite for \"%s\".", t->
name,
1380 for (k = 0; k < num_tags; k++) {
1409 qCCritical(tileset_category,
"[%s] unknown sprite_type \"%s\".",
1410 tile_section, sprite_type);
1418 "tilespec.unit_flag_offset_x")
1420 "tilespec.unit_flag_offset_y")
1422 "tilespec.city_flag_offset_x")
1424 "tilespec.city_flag_offset_y")
1426 "tilespec.unit_offset_x")
1428 "tilespec.unit_offset_y")
1430 "tilespec.activity_offset_x")
1432 "tilespec.activity_offset_y")
1434 "tilespec.select_offset_x")
1436 "tilespec.select_offset_y")
1438 "tilespec.city_offset_x")
1440 "tilespec.city_offset_y")
1442 "tilespec.city_size_offset_x")
1444 "tilespec.city_size_offset_y")
1446 "tilespec.citybar_offset_y")
1448 "tilespec.tilelabel_offset_y")
1450 "tilespec.occupied_offset_x")
1452 "tilespec.occupied_offset_y");
1464 char *fname,
struct section_list *sections,
1465 const char **layer_order)
1469 delete[] layer_order;
1471 if (
nullptr != sections) {
1472 section_list_destroy(sections);
1483 case LAYER_BACKGROUND:
1484 t->
layers.push_back(std::make_unique<freeciv::layer_background>(t));
1487 t->
layers.emplace_back(std::make_unique<freeciv::layer_city>(
1491 t->
layers.emplace_back(std::make_unique<freeciv::layer_city_size>(
1494 case LAYER_DARKNESS: {
1496 std::make_unique<freeciv::layer_darkness>(t, t->
darkness_style));
1498 case LAYER_EDITOR: {
1499 t->
layers.emplace_back(std::make_unique<freeciv::layer_editor>(t));
1502 t->
layers.emplace_back(std::make_unique<freeciv::layer_fog>(
1506 t->
layers.emplace_back(std::make_unique<freeciv::layer_goto>(t));
1510 t->
layers.emplace_back(std::make_unique<freeciv::layer_grid>(t, layer));
1512 case LAYER_INFRAWORK: {
1516 case LAYER_OVERLAYS: {
1517 t->
layers.emplace_back(std::make_unique<freeciv::layer_overlays>(t));
1519 case LAYER_TERRAIN1: {
1520 auto l = std::make_unique<freeciv::layer_terrain>(t, 0);
1522 t->
layers.emplace_back(std::move(l));
1524 case LAYER_TERRAIN2: {
1525 auto l = std::make_unique<freeciv::layer_terrain>(t, 1);
1527 t->
layers.emplace_back(std::move(l));
1529 case LAYER_TERRAIN3: {
1530 auto l = std::make_unique<freeciv::layer_terrain>(t, 2);
1532 t->
layers.emplace_back(std::move(l));
1534 case LAYER_SPECIAL1:
1535 case LAYER_SPECIAL2:
1536 case LAYER_SPECIAL3: {
1538 std::make_unique<freeciv::layer_special>(t, layer));
1541 t->
layers.emplace_back(std::make_unique<freeciv::layer_roads>(t));
1543 case LAYER_BASE_FLAGS: {
1544 auto l = std::make_unique<freeciv::layer_base_flags>(
1546 t->
layers.emplace_back(std::move(l));
1549 t->
layers.emplace_back(std::make_unique<freeciv::layer_units>(
1553 case LAYER_FOCUS_UNIT: {
1554 auto l = std::make_unique<freeciv::layer_units>(
1558 t->
layers.emplace_back(move(l));
1561 t->
layers.emplace_back(std::make_unique<freeciv::layer_water>(t));
1563 case LAYER_WORKERTASK: {
1568 t->
layers.push_back(std::make_unique<freeciv::layer>(t, layer));
1580 bool verbose,
int topology_id)
1586 size_t num_spec_files;
1587 const char **spec_filenames;
1589 const char **layer_order =
nullptr;
1590 struct section_list *sections =
nullptr;
1591 const char *file_capstr;
1592 bool duplicates_ok, is_hex;
1593 enum direction8 dir;
1595 const char *extraname;
1602 qCCritical(tileset_category,
"Can't find tileset \"%s\".",
1603 qUtf8Printable(tileset_name));
1607 qCDebug(tileset_category,
"tilespec file is \"%s\".", fname);
1610 qCCritical(tileset_category,
"Could not open '%s':\n%s", fname,
1626 duplicates_ok = (
nullptr != file_capstr
1633 if (tstr[0] !=
'\0') {
1642 if (tstr[0] !=
'\0') {
1646 len = qstrlen(tstr);
1656 if (tstr[0] !=
'\0') {
1660 len = qstrlen(tstr);
1674 qCCritical(tileset_category,
"Tileset \"%s\" invalid: %s", t->
name,
1681 if (tstr ==
nullptr) {
1682 qCCritical(tileset_category,
"Tileset \"%s\": no tileset type", t->
name);
1688 if (!ts_type_is_valid(t->
type)) {
1689 qCCritical(tileset_category,
1690 "Tileset \"%s\": unknown tileset type \"%s\"", t->
name, tstr);
1696 if (t->
type == TS_ISOMETRIC) {
1706 qCCritical(tileset_category,
"Tileset \"%s\" invalid: %s", t->
name,
1711 if (t->
type == TS_ISOMETRIC) {
1722 t->
type = TS_ISOMETRIC;
1725 if (topology_id >= 0) {
1726 if (((topology_id & TF_HEX) && topology_id != (topo & (TF_ISO | TF_HEX)))
1727 || (!(topology_id & TF_HEX) && (topo & TF_HEX))) {
1752 }
while (dir != DIR8_NORTH);
1758 "tilespec.normal_tile_width")
1760 "tilespec.normal_tile_height")) {
1761 qCCritical(tileset_category,
"Tileset \"%s\" invalid: %s", t->
name,
1766 if (t->
type == TS_ISOMETRIC) {
1785 "tilespec.small_tile_width")
1787 "tilespec.small_tile_height")) {
1788 qCCritical(tileset_category,
"Tileset \"%s\" invalid: %s", t->
name,
1793 qCDebug(tileset_category,
"tile sizes %dx%d, %dx%d unit, %dx%d small",
1799 if (tstr ==
nullptr) {
1800 qCCritical(tileset_category,
"Tileset \"%s\": no fog_style", t->
name);
1806 if (!fog_style_is_valid(t->
fogstyle)) {
1807 qCCritical(tileset_category,
"Tileset \"%s\": unknown fog_style \"%s\"",
1814 file, 100, 1, 1000,
"tilespec.preferred_scale")
1818 file, 100, 1, 10000,
"tilespec.select_step_ms");
1821 qCCritical(tileset_category,
"Tileset \"%s\" invalid: %s", t->
name,
1829 "tilespec.unit_default_orientation");
1836 if (!direction8_is_valid(dir)) {
1838 "Tileset \"%s\": unknown "
1839 "unit_default_orientation \"%s\"",
1851 if (tstr ==
nullptr) {
1852 qCCritical(tileset_category,
"Tileset \"%s\": no darkness_style",
1860 qCCritical(tileset_category,
1861 "Tileset \"%s\": unknown darkness_style \"%s\"", t->
name,
1869 qCCritical(tileset_category,
1870 "Invalid darkness style set in tileset \"%s\".", t->
name);
1879 if (layer_order !=
nullptr) {
1880 mapview_layer order[LAYER_COUNT];
1881 for (i = 0; i < num_layers; i++) {
1883 enum mapview_layer layer =
1887 if (!mapview_layer_is_valid(layer)) {
1888 qCCritical(tileset_category,
"layer_order: Invalid layer \"%s\"",
1894 for (j = 0; j < i; j++) {
1895 if (order[j] == layer) {
1896 qCCritical(tileset_category,
"layer_order: Duplicate layer \"%s\"",
1907 for (i = 0; i < LAYER_COUNT; i++) {
1911 for (j = 0; j < num_layers; j++) {
1912 if (i == order[j]) {
1918 qCCritical(tileset_category,
"layer_order: Missing layer \"%s\"",
1919 mapview_layer_name(
static_cast<mapview_layer
>(i)));
1925 for (
auto layer : order) {
1930 for (i = 0; i < LAYER_COUNT; ++i) {
1937 std::size_t count = 0;
1940 for (
int j = 0; j < count; j++) {
1941 if (!t->
terrain_layers[i]->create_matching_group(match_types[j])) {
1950 if (
nullptr == sections || 0 == section_list_size(sections)) {
1952 _(
"No [%s] sections supported by tileset \"%s\"."),
1965 if (c_tag !=
nullptr) {
1969 _(
"No terrain tag given in section [%s]."), sec_name);
1980 for (
int l = 0; l < num_layers; l++) {
1990 file,
false,
"%s.layer%d_is_tall", sec_name, l);
1993 file, 0,
"%s.layer%d_offset_x", sec_name, l);
1999 file, 0,
"%s.layer%d_offset_y", sec_name, l);
2014 file,
"whole",
"%s.layer%d_sprite_type", sec_name, l);
2025 file,
nullptr,
"%s.layer%d_match_type", sec_name, l);
2027 if (matching_group) {
2029 tag, matching_group)) {
2035 std::size_t count = 0;
2037 file, &count,
"%s.layer%d_match_with", sec_name, l);
2039 for (std::size_t j = 0; j < count; ++j) {
2041 tag, match_with[j])) {
2054 ->enable_blending(tag);
2060 section_list_destroy(sections);
2067 t->
estyle_hash =
new QHash<QString, extrastyle_id>;
2070 file,
nullptr,
"extras.styles%d.name", i));
2072 const char *style_name;
2075 "extras.styles%d.style", i);
2076 auto style = extrastyle_id_by_name(style_name,
fc_strcasecmp);
2079 qCCritical(tileset_category,
2080 "warning: duplicate extrastyle entry [%s].", extraname);
2089 if (
nullptr == spec_filenames || 0 == num_spec_files) {
2090 qCCritical(tileset_category,
2091 "No tile graphics files specified in \"%s\"", fname);
2097 t->
sprite_hash =
new QHash<QString, struct small_sprite *>;
2098 for (i = 0; i < num_spec_files; i++) {
2102 log_debug(
"spec file %s", spec_filenames[i]);
2106 if (dname.isEmpty()) {
2108 qCCritical(tileset_category,
"Can't find spec file \"%s\".",
2120 delete[] spec_filenames;
2126 qCDebug(tileset_category,
"finished reading \"%s\".", fname);
2128 delete[] layer_order;
2149 std::set<QString> all_names;
2159 if (qstrlen(
name) == 0) {
2160 tileset_error(t, QtCriticalMsg,
"Option \"%s\" has no name", sec_name);
2165 if (all_names.count(
name)) {
2169 all_names.insert(
name);
2173 if (qstrlen(description) == 0) {
2174 tileset_error(t, QtCriticalMsg,
"Option \"%s\" has no description",
2178 option.description = QString::fromUtf8(description);
2180 option.enabled_by_default =
2192 for (
const auto &[
name, value] :
2223 qCCritical(tileset_category,
"Unknown citizen type: %d.",
2224 static_cast<int>(citizen));
2237 int value = (idx >> i) & 1;
2239 c += QStringLiteral(
"%1%2").arg(
2241 QString::number(value));
2255 int value = (idx >> i) & 1;
2257 c += QStringLiteral(
"%1%2").arg(
2259 QString::number(value));
2289 _(
"Couldn't load gfx file \"%s\" for sprite '%s'."),
2298 if (ss->
x < 0 || ss->
x + ss->
width > sf_w || ss->
y < 0
2299 || ss->
y + ss->
height > sf_h) {
2302 _(
"Sprite '%s' in file \"%s\" isn't within the image!"),
2307 ss->
height,
nullptr, -1, -1);
2323 bool required,
bool verbose)
2327 for (
const auto &
name : possible_names) {
2342 _(
"Could not find required sprite matching %s"),
2346 _(
"Could not find optional sprite matching %s"),
2381 const QStringList &possible_names,
bool required)
2392 const QStringList &patterns,
2393 const QString &suffix,
bool required)
2397 for (
const auto &pattern : patterns) {
2398 names.append(pattern.arg(QString::number(i)) + suffix);
2412 const QStringList &patterns)
2434 buffer = QStringLiteral(
"%1_%2").arg(tag, QString::number(j));
2456 buffer = QStringLiteral(
"%1_%2").arg(
graphic_alt, QString::number(j));
2497 buffer = QStringLiteral(
"citizen.%1_%2").arg(
name, QString::number(j));
2517 QString buffer, buffer2;
2523 {
"treaty.disagree_thumb_down"},
true);
2528 const char *names[] = {
"science_bulb",
"warming_sun",
"cooling_flake"};
2531 buffer = QStringLiteral(
"s.%1_%2").arg(names[j], QString::number(i));
2539 if (t->
type == TS_ISOMETRIC) {
2557 "solar_panels",
"life_support",
"habitation",
"structural",
2558 "fuel",
"propulsion",
"exhaust"};
2560 buffer = QStringLiteral(
"spaceship.%1").arg(names[i]);
2567 "goto",
"patrol",
"paradrop",
"nuke",
"select",
2568 "invalid",
"attack",
"edit_paint",
"edit_add",
"wait"};
2573 QStringLiteral(
"cursor.%1%2").arg(names[i], QString::number(f));
2583 for (i = 0; i < E_COUNT; i++) {
2584 const char *tag =
get_event_tag(
static_cast<event_type
>(i));
2593 buffer = QStringLiteral(
"explode.unit_%1").arg(QString::number(i));
2610 buffer = QStringLiteral(
"citybar.occupancy_%1").arg(QString::number(i));
2619 _(
"Missing necessary citybar.occupancy_N sprites."));
2630 {
"editor.terrain_resource"},
true);
2632 {
"editor.terrain_special"},
true);
2645 buffer = QStringLiteral(
"upkeep.unhappy");
2652 buffer = QStringLiteral(
"upkeep.unhappy%1").arg(QString::number(i));
2661 buffer = QStringLiteral(
"upkeep.%1")
2669 QStringLiteral(
"upkeep.%1%2")
2671 QString::number(i));
2687 for (
auto &layer : t->
layers) {
2688 layer->load_sprites();
2725 const char *tag,
const char *alt,
2726 const char *what,
const char *
name,
2733 "attempt to lookup for %s \"%s\" before "
2734 "sprite_hash setup",
2744 qCDebug(tileset_category,
2745 "Using alternate graphic \"%s\" "
2746 "(instead of \"%s\") for %s \"%s\".",
2747 alt, tag, what,
name);
2753 _(
"Don't have graphics tags \"%s\" or \"%s\" for %s \"%s\"."), tag,
2764 const char *base_str,
2765 enum direction8 dir,
bool has_icon)
2768 enum direction8 loaddir = dir;
2783 loaddir =
dir_cw(loaddir);
2810 bool has_icon, facing_sprites =
true;
2813 has_icon = icon !=
nullptr;
2816 std::make_unique<freeciv::colorizer>(*icon, t->
replaced_hue);
2819 #define LOAD_FACING_SPRITE(dir) \
2820 if (!tileset_setup_unit_direction(t, uidx, tag, dir, has_icon)) { \
2821 facing_sprites = false; \
2833 if (!has_icon && !facing_sprites) {
2840 #undef LOAD_FACING_SPRITE
2854 _(
"Missing %s unit sprite for tags \"%s\" and "
2855 "alternative \"%s\"."),
2862 "Unit type %s has no unoriented sprite and "
2863 "tileset has no unit_default_orientation.",
2915 const QString &suffix,
2916 const struct terrain *pterrain)
2919 || pterrain->
graphic_alt == QStringLiteral(
"-")) {
2921 QStringLiteral(
"%1_%2%3").arg(prefix, pterrain->
graphic_str, suffix),
2922 QStringLiteral(
"%1%2").arg(prefix, suffix),
2926 QStringLiteral(
"%1_%2%3").arg(prefix, pterrain->
graphic_str, suffix),
2927 QStringLiteral(
"%1_%2%3").arg(prefix, pterrain->
graphic_alt, suffix),
2928 QStringLiteral(
"%1%2").arg(prefix, suffix),
2951 _(
"No extra style for \"%s\" or \"%s\"."),
2954 qCDebug(tileset_category,
2955 "Using alternate graphic \"%s\" "
2956 "(instead of \"%s\") for extra \"%s\".",
2964 for (
auto &layer : t->
layers) {
2965 layer->initialize_extra(pextra, tag, extrastyle);
2972 QStringList tags = {
2983 QStringList tags = {
2996 const struct terrain *pterrain)
2998 for (
auto &layer : t->
layers) {
2999 layer->initialize_terrain(pterrain);
3023 "unknown",
nullptr};
3025 QPixmap *flag =
nullptr, *shield =
nullptr;
3028 for (i = 0; tags[i] && !flag; i++) {
3029 buf = QStringLiteral(
"f.%1").arg(tags[i]);
3032 for (i = 0; tags[i] && !shield; i++) {
3033 buf = QStringLiteral(
"f.shield.%1").arg(tags[i]);
3036 if (!flag || !shield) {
3053 const struct city *pcity)
3062 const struct unit *punit)
3081 struct terrain **tterrain_near, bv_extras *textras_near)
3086 for (dir = 0; dir < 8; dir++) {
3087 struct tile *tile1 =
3093 if (
nullptr != terrain1) {
3094 tterrain_near[dir] = terrain1;
3098 qCCritical(tileset_category,
3099 "build_tile_data() tile (%d,%d) has no terrain!",
3104 tterrain_near[dir] = pterrain;
3135 bool no_disable =
true;
3190 for (
auto &&layer : t->
layers) {
3191 layer->initialize_city_style(
city_styles[style], style);
3250 if (punit ==
nullptr) {
3270 QHash<QString, small_sprite *>::const_iterator i =
3273 QByteArray qba = i.key().toLocal8Bit();
3274 while (i.value()->ref_count > 0) {
3305 for (
auto *sf : qAsConst(*t->
specfiles)) {
3306 delete[] sf->file_name;
3307 if (sf->big_sprite) {
3308 delete sf->big_sprite;
3309 sf->big_sprite =
nullptr;
3340 const struct city *pcity)
3343 int gfx_index = citizen_index;
3345 if (pcity !=
nullptr) {
3346 gfx_index += pcity->
client.first_citizen_index;
3357 if (graphic->
count == 0) {
3361 return graphic->
sprite[gfx_index % graphic->
count];
3418 enum direction8 facing,
3419 const QColor &replace)
3422 bool icon = !direction8_is_valid(facing);
3426 if (!direction8_is_valid(facing) || !
is_valid_dir(facing)) {
3470 enum event_type
event)
3504 const std::vector<QPixmap *> &
3544 int *hot_y,
int frame)
3583 const struct unit *punit,
3605 const struct unit *punit,
3606 const int *upkeep_cost)
3641 std::vector<drawn_sprite>
3651 auto sprs = std::vector<drawn_sprite>();
3652 for (
const auto &layer : t->
layers) {
3654 layer->fill_sprite_array(
tile,
nullptr,
nullptr,
nullptr);
3655 sprs.insert(sprs.end(), lsprs.begin(), lsprs.end());
3667 for (
const auto &layer : t->
layers) {
3678 std::vector<drawn_sprite>
3688 auto sprs = std::vector<drawn_sprite>();
3689 for (
const auto &layer : t->
layers) {
3691 layer->fill_sprite_array(
tile,
nullptr,
nullptr,
nullptr);
3692 sprs.insert(sprs.end(), lsprs.begin(), lsprs.end());
3699 const std::vector<std::unique_ptr<freeciv::layer>> &
3719 for (
auto &&layer : t->
layers) {
3720 layer->initialize_player(pplayer);
3732 for (
auto &&layer : t->
layers) {
3733 layer->free_player(plrid);
3742 for (
auto &layer : t->
layers) {
3743 layer->reset_ruleset();
3765 return std::any_of(t->
log.begin(), t->
log.end(),
3766 [](
auto &
entry) { return entry.level == LOG_ERROR; });
3788 std::map<QString, tileset_option>
3817 if (it->second.enabled != enabled) {
3874 if (description !=
nullptr) {
3875 desc_len = qstrlen(
"\n\n") + qstrlen(description);
3879 if (summary !=
nullptr) {
3880 if (version[0] !=
'\0') {
3881 len = qstrlen(
_(ts_name)) + qstrlen(
" ") + qstrlen(version)
3882 + qstrlen(
"\n\n") + qstrlen(
_(summary)) + 1;
3884 pitem->text =
new char[
len + desc_len];
3888 len = qstrlen(
_(ts_name)) + qstrlen(
"\n\n") + qstrlen(
_(summary)) + 1;
3890 pitem->text =
new char[
len + desc_len];
3894 const char *nodesc =
_(
"Current tileset contains no summary.");
3896 if (version[0] !=
'\0') {
3897 len = qstrlen(
_(ts_name)) + qstrlen(
" ") + qstrlen(version)
3898 + qstrlen(
"\n\n") + qstrlen(nodesc) + 1;
3900 pitem->text =
new char[
len + desc_len];
3904 len = qstrlen(
_(ts_name)) + qstrlen(
"\n\n") + qstrlen(nodesc) + 1;
3906 pitem->text =
new char[
len + desc_len];
3910 if (description !=
nullptr) {
QString strvec_to_or_list(const QVector< QString > &psv)
QPixmap crop_sprite(const QPixmap *sprite)
Helper function to crop a sprite.
bool has_capabilities(const char *us, const char *them)
This routine returns true if all the mandatory capabilities in us appear in them.
struct citystyle * city_styles
bool city_can_be_built_here(const struct tile *ptile, const struct unit *punit)
Returns TRUE if the given unit can build a city at the given map coordinates.
const char * get_output_identifier(Output_type_id output)
Return an id string for the output type.
#define output_type_iterate(output)
#define output_type_iterate_end
void generate_citydlg_dimensions()
Calculate the citydlg width and height.
sprite_type
Indicates how many sprites are used to draw a tile.
@ CELL_WHOLE
One sprite for the entire tile.
@ CELL_HEX_CORNER
One sprite for each hexagonal corner of the tile.
@ CELL_CORNER
One sprite for each corner of the tile.
int focus_unit_state() const
Returns the current state of the focused unit animation.
auto focus_unit_state_count() const
Returns the number of steps in the focused unit animation.
void center_on_tile(tile *tile, bool animate=true)
Centers the view on a tile.
enum client_states client_state()
Return current client state.
enum known_type client_tile_get_known(const struct tile *ptile)
A tile's "known" field is used by the server to store whether each player knows the tile.
struct nation_set * client_current_nation_set()
Returns the nation set in use.
void color_system_free(struct color_system *colors)
Called when the client first starts to free any allocated colors.
struct color_system * color_system_read(struct section_file *file)
Called when the client first starts to allocate the default colors.
bool unit_is_in_focus(const struct unit *punit)
Return TRUE iff this unit is in focus.
unit * find_visible_unit(const ::tile *ptile)
Return a pointer to a visible unit, if there is one.
const char * get_event_tag(enum event_type event)
Returns a string for the sound to be used for this message type.
#define MAX_NUM_PLAYER_SLOTS
enum output_type_id Output_type_id
const char * government_rule_name(const struct government *pgovern)
Return the (untranslated) rule name of the government.
std::vector< government > governments
Government_type_id government_index(const struct government *pgovern)
Return the government index.
struct help_item * new_help_item(help_page_type type)
Allocate and initialize new help item.
void boot_help_texts(const nation_set *nations_to_show, help_item *tileset_help)
pplayer may be nullptr.
void popdown_help_dialog(void)
Close the help dialog.
const char * improvement_rule_name(const struct impr_type *pimprove)
Return the (untranslated) rule name of the improvement.
Impr_type_id improvement_index(const struct impr_type *pimprove)
Return the improvement index.
#define improvement_iterate_end
#define improvement_iterate(_p)
#define fc_assert_ret(condition)
#define fc_assert_exit_msg(condition, message,...)
constexpr auto LOG_VERBOSE
#define fc_assert(condition)
constexpr auto LOG_NORMAL
#define fc_assert_ret_val(condition, val)
#define fc_assert_action(condition, action)
#define log_debug(message,...)
#define log_base(level, message,...)
#define fc_assert_ret_val_msg(condition, val, message,...)
bool is_valid_dir(enum direction8 dir)
Returns TRUE iff the given direction is a valid one.
enum direction8 dir_cw(enum direction8 dir)
Returns the next direction clock-wise.
struct tile * mapstep(const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
Step from the given tile in the given direction.
void tileset_changed(void)
This function is called when the tileset is changed.
struct nation_type * nation_of_city(const struct city *pcity)
Return the nation of the player who owns the city.
const char * nation_rule_name(const struct nation_type *pnation)
Return the (untranslated) rule name of the nation (adjective form).
std::vector< nation_type > nations
struct nation_type * nation_of_unit(const struct unit *punit)
Return the nation of the player who owns the unit.
Nation_type_id nation_index(const struct nation_type *pnation)
Return the nation index.
const char * option_str_get(const struct option *poption)
Returns the current value of this string option.
client_options * gui_options
int option_get_cb_data(const struct option *poption)
Returns the callback data of this option.
pageGame * queen()
Return game instandce.
int player_index(const struct player *pplayer)
Return the player index.
#define players_iterate_end
#define players_iterate(_pplayer)
struct section_file * secfile_load(const QString &filename, bool allow_duplicates)
Create a section file from a file.
const char * secfile_error()
Returns the last error which occurred in a string.
const char * section_name(const struct section *psection)
Returns the section name.
void secfile_destroy(struct section_file *secfile)
Free a section file.
void secfile_check_unused(const struct section_file *secfile)
Print log messages for any entries in the file which have not been looked up – ie,...
bool secfile_lookup_int(const struct section_file *secfile, int *ival, const char *path,...)
Lookup a integer value in the secfile.
struct entry * secfile_entry_lookup(const struct section_file *secfile, const char *path,...)
Returns the entry at "fullpath" or nullptr if not matched.
const char * secfile_lookup_str(const struct section_file *secfile, const char *path,...)
Lookup a string value in the secfile.
const char ** secfile_lookup_str_vec(const struct section_file *secfile, size_t *dim, const char *path,...)
Lookup a string vector in the secfile.
bool secfile_lookup_bool_default(const struct section_file *secfile, bool def, const char *path,...)
Lookup a boolean value in the secfile.
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
Lookup a string value in the secfile.
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
Lookup a integer value in the secfile.
struct section_list * secfile_sections_by_name_prefix(const struct section_file *secfile, const char *prefix)
Returns the list of sections which match the name prefix.
bool secfile_lookup_bool(const struct section_file *secfile, bool *bval, const char *path,...)
Lookup a boolean value in the secfile.
int secfile_lookup_int_def_min_max(const struct section_file *secfile, int defval, int minval, int maxval, const char *path,...)
Lookup a integer value in the secfile.
#define section_list_iterate(seclist, psection)
#define section_list_iterate_end
struct setting_list * level[OLEVELS_NUM]
const QStringList & get_data_dirs()
Returns a list of data directory paths, in the order in which they should be searched.
QString fileinfoname(const QStringList &dirs, const QString &filename)
Returns a filename to access the specified file from a directory by searching all specified directori...
QVector< QString > * fileinfolist(const QStringList &dirs, const char *suffix)
Returns a string vector storing the filenames in the data directories matching the given suffix.
#define CLIP(lower, current, upper)
struct specialist * specialist_by_number(const Specialist_type_id id)
Return the specialist pointer for the given number.
#define specialist_type_iterate_end
#define specialist_type_iterate(sp)
QPixmap * load_gfxfile(const char *filename)
Load the given graphics file into a sprite.
char graphic_str[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
QPixmap * sprite[MAX_NUM_CITIZEN_SPRITES]
struct city::@15::@18 client
std::vector< QPixmap * > occupancy
struct packet_ruleset_control control
struct civ_game::@28::@31 client
std::map< QString, std::map< QString, bool > > tileset_options
Saved tileset options.
bool draw_fortress_airbase
QPixmap * terrain_resource
QPixmap * terrain_special
char graphic_alt[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
std::vector< QPixmap * > unit
const QPixmap * government[G_LAST]
struct citizen_graphic specialist[SP_MAX]
struct named_sprites::@149 upkeep
const QPixmap * tech[A_LAST]
struct citizen_graphic citizen[CITIZEN_LAST]
QPixmap * frame[NUM_CURSOR_FRAMES]
QPixmap * events[E_COUNT]
std::vector< QPixmap * > nation_shield
struct named_sprites::@147 cursor[CURSOR_LAST]
struct named_sprites::@151 extras[MAX_EXTRA_TYPES]
const QPixmap * building[B_LAST]
QPixmap * spaceship[SPACESHIP_COUNT]
std::vector< QPixmap * > nation_flag
QPixmap * borders[EDGE_COUNT][2]
struct citybar_sprites citybar
std::vector< QPixmap * > output[O_LAST]
struct named_sprites::@150 user
struct named_sprites::@152 grid
std::unique_ptr< freeciv::colorizer > facing[U_LAST][DIR8_MAGIC_MAX]
QPixmap * treaty_thumb[2]
struct named_sprites::@146 units
struct editor_sprites editor
std::vector< QPixmap * > unhappy
struct named_sprites::@145 mask
struct named_sprites::@148 explode
QPixmap * indicator[INDICATOR_COUNT][NUM_TILES_PROGRESS]
QPixmap * arrow[ARROW_LAST]
std::unique_ptr< freeciv::colorizer > icon[U_LAST]
char flag_graphic_str[MAX_LEN_NAME]
char flag_graphic_alt[MAX_LEN_NAME]
The base class for options.
Information about an individual sprite.
char graphic_alt[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
Tileset options allow altering the behavior of a tileset.
char given_name[MAX_LEN_NAME]
int num_cardinal_tileset_dirs
std::vector< std::unique_ptr< freeciv::layer > > layers
struct named_sprites sprites
std::array< freeciv::layer_terrain *, MAX_NUM_LAYERS > terrain_layers
char version[MAX_LEN_NAME]
freeciv::layer_units * focus_units_layer
QHash< QString, extrastyle_id > * estyle_hash
QSet< struct small_sprite * > * small_sprites
std::map< QString, tileset_option > options
freeciv::fog_style fogstyle
freeciv::darkness_style darkness_style
QSet< specfile * > * specfiles
std::array< direction8, 8 > cardinal_tileset_dirs
enum direction8 unit_default_orientation
int unit_upkeep_small_offset_y
QHash< QString, struct small_sprite * > * sprite_hash
struct color_system * color_system
std::array< direction8, 8 > valid_tileset_dirs
int num_valid_tileset_dirs
std::vector< tileset_log_entry > log
char graphic_alt[MAX_LEN_NAME]
char graphic_str[MAX_LEN_NAME]
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
size_t fc_strlcpy(char *dest, const char *src, size_t n)
fc_strlcpy() provides utf-8 version of (non-standard) function strlcpy() It is intended as more user-...
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
size_t fc_strlcat(char *dest, const char *src, size_t n)
fc_strlcat() provides utf-8 version of (non-standard) function strlcat() It is intended as more user-...
#define sz_strlcpy(dest, src)
struct advance * valid_advance(struct advance *padvance)
Returns pointer when the advance "exists" in this game, returns nullptr otherwise.
const char * advance_rule_name(const struct advance *padvance)
Return the (untranslated) rule name of the advance/technology.
Tech_type_id advance_index(const struct advance *padvance)
Return the advance index.
Tech_type_id advance_count()
Return the number of advances/technologies.
#define advance_iterate(_start, _p)
#define advance_iterate_end
#define terrain_type_iterate(_p)
#define terrain_type_iterate_end
void tile_virtual_destroy(struct tile *vtile)
Frees all memory used by the virtual tile, including freeing virtual units in the tile's unit list an...
struct tile * tile_virtual_new(const struct tile *ptile)
Returns a virtual tile.
#define tile_terrain(_tile)
static const bv_extras * tile_extras(const struct tile *ptile)
void tileset_load_tiles(struct tileset *t)
Load the tiles; requires tilespec_read_toplevel() called previously.
const QPixmap * get_nuke_explode_sprite(const struct tileset *t)
Return a sprite contining the single nuke graphic.
int tileset_hex_width(const struct tileset *t)
Return the hex_width of the current tileset.
void tilespec_init()
Initializes the tilespec system.
const char * tileset_name_get(const struct tileset *t)
Return tileset name.
int tileset_unit_width(const struct tileset *t)
Return the unit tile width of the current tileset.
static void assign_sprite(struct tileset *t, QPixmap *&field, const QStringList &possible_names, bool required)
finds the first sprite matching a list of possible names and returns it to the field argument.
static void tileset_setup_citizen_types(struct tileset *t)
Setup the graphics for (non-specialist) citizen types.
bool tilespec_reread(const QString &name, bool game_fully_initialized)
Read a new tilespec in from scratch.
std::vector< drawn_sprite > fill_basic_terrain_layer_sprite_array(struct tileset *t, int layer, struct terrain *pterrain)
Fill the sprite array with sprites that together make a representative image of the given terrain typ...
int tileset_unit_height(const struct tileset *t)
Return the unit tile height of the current tileset.
const QPixmap * get_citizen_sprite(const struct tileset *t, enum citizen_category type, int citizen_index, const struct city *pcity)
Return a sprite for the given citizen.
void tileset_setup_unit_type(struct tileset *t, struct unit_type *ut)
Set unit_type sprite value; should only happen after tilespec_load_tiles().
static bool check_tilespec_capabilities(struct section_file *file, const char *which, const char *us_capstr, const char *filename, bool verbose)
Checks options in filename match what we require and support.
static char * tilespec_fullname(QString tileset_name)
Gets full filename for tilespec file, based on input name.
int tileset_num_cardinal_dirs(const struct tileset *t)
Returns the number of cardinal directions used by the tileset.
int tileset_small_sprite_width(const struct tileset *t)
Return the small sprite width of the current tileset.
const freeciv::layer_city * tileset_layer_city(const struct tileset *t)
Returns the layer_city of the tileset.
const char * tileset_basename(const struct tileset *t)
Return the name of the given tileset.
const QPixmap * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Return the sprite for the nation.
const char * tileset_summary(const struct tileset *t)
Return tileset description summary.
const std::vector< std::unique_ptr< freeciv::layer > > & tileset_get_layers(const struct tileset *t)
void tileset_setup_government(struct tileset *t, struct government *gov)
Set government sprite value; should only happen after tilespec_load_tiles().
std::array< direction8, 8 > tileset_cardinal_dirs(const struct tileset *t)
Returns the cardinal directions used by the tileset.
static bool is_valid_tileset_dir(const struct tileset *t, enum direction8 dir)
Return TRUE iff the dir is valid in this tileset.
const QPixmap * get_unit_upkeep_sprite(const struct tileset *t, Output_type_id otype, const struct unit *punit, const int *upkeep_cost)
Return a sprite for the upkeep of the unit - to be shown as an overlay on the unit in the city suppor...
static QPixmap * load_sprite(struct tileset *t, const QString &tag_name)
Loads the sprite.
int tileset_full_tile_height(const struct tileset *t)
Return the full tile height of the current tileset.
static bool tileset_setup_unit_type_from_tag(struct tileset *t, int uidx, const char *tag)
Try to setup all unit type sprites from single tag.
static QPixmap * make_error_pixmap()
Makes a dummy "error" pixmap to prevent crashes.
const QPixmap * get_attention_crosshair_sprite(const struct tileset *t)
Returns a sprite with the "user-attention" crosshair graphic.
void tileset_setup_specialist_type(struct tileset *t, Specialist_type_id id)
Setup the graphics for specialist types.
void tileset_setup_tile_type(struct tileset *t, const struct terrain *pterrain)
Set tile_type sprite values; should only happen after tilespec_load_tiles().
int get_focus_unit_toggle_timeout(const struct tileset *t)
Return the amount of time between calls to toggle_focus_unit_state.
void tileset_player_init(struct tileset *t, struct player *pplayer)
Setup tiles for one player using the player color.
int tileset_unit_layout_offset_y(const struct tileset *t)
Offset to layout extra unit sprites, such as upkeep.
int tileset_citybar_offset_y(const struct tileset *t)
Return the offset from the origin of the city tile at which to place the city bar text.
bool unit_drawn_with_city_outline(const struct unit *punit, bool check_focus)
Indicate whether a unit is to be drawn with a surrounding city outline under current conditions.
static int calculate_max_upkeep_height(const struct tileset *t)
Calculate the height of a unit upkeep icons.
static const char * citizen_rule_name(enum citizen_category citizen)
Returns a text name for the citizen, as used in the tileset.
#define TILE_SECTION_PREFIX
const QPixmap * get_indicator_sprite(const struct tileset *t, enum indicator_type indicator, int idx)
Returns a sprite for the given indicator with the given index.
void tileset_free_tiles(struct tileset *t)
Free all sprites from tileset.
void tileset_setup_impr_type(struct tileset *t, struct impr_type *pimprove)
Set improvement_type sprite value; should only happen after tilespec_load_tiles().
const QPixmap * get_city_flag_sprite(const struct tileset *t, const struct city *pcity)
Return the flag graphic to be used by the city.
int tileset_topo_index(const struct tileset *t)
Return tileset topology index.
const QPixmap * get_event_sprite(const struct tileset *t, enum event_type event)
Return event icon sprite.
static void unload_all_sprites(struct tileset *t)
This patch unloads all sprites from the sprite hash (the hash itself is left intact).
QString valid_index_str(const struct tileset *t, int idx)
Do the same thing as cardinal_str, except including all valid directions.
void tileset_setup_tech_type(struct tileset *t, struct advance *padvance)
Set tech_type sprite value; should only happen after tilespec_load_tiles().
Q_LOGGING_CATEGORY(tileset_category, "freeciv.tileset")
Functions for handling the tilespec files which describe the files and contents of tilesets.
static QPixmap * load_gfx_file(const char *gfx_filename)
Loads the given graphics file (found in the data path) into a newly allocated sprite.
const std::vector< QPixmap * > & get_unit_explode_animation(const struct tileset *t)
Return a sprite_vector containing the animation sprites for a unit explosion.
const QPixmap * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
Return the sprite for the technology/advance.
static void tileset_player_free(struct tileset *t, int plrid)
Free tiles for one player using the player color.
const struct citybar_sprites * get_citybar_sprites(const struct tileset *t)
Return all the sprites used for city bar drawing.
std::vector< drawn_sprite > fill_basic_extra_sprite_array(const struct tileset *t, const struct extra_type *pextra)
Return a representative sprite for the given extra type.
static bool tileset_invalid_offsets(struct tileset *t, struct section_file *file)
struct color_system * get_color_system(const struct tileset *t)
Return the tileset's color system.
bool tileset_option_is_enabled(const struct tileset *t, const QString &name)
Checks if an user-settable tileset option is enabled.
bool tileset_is_isometric(const struct tileset *t)
Return whether the current tileset is isometric.
bool tileset_use_hard_coded_fog(const struct tileset *t)
Return TRUE if the client will use the code to generate the fog.
static bool tileset_setup_unit_direction(struct tileset *t, int uidx, const char *base_str, enum direction8 dir, bool has_icon)
Helper function to load sprite for one unit orientation.
QPoint tileset_full_tile_offset(const struct tileset *t)
Return the x and y offsets of full tiles in the tileset.
void tileset_setup_city_tiles(struct tileset *t, int style)
Set city tiles sprite values; should only happen after tilespec_load_tiles().
static freeciv::layer_terrain::sprite_type check_sprite_type(const char *sprite_type, const char *tile_section)
Determine the sprite_type string.
void build_tile_data(const struct tile *ptile, struct terrain *pterrain, struct terrain **tterrain_near, bv_extras *textras_near)
Assemble some data that is used in building the tile sprite arrays.
const char * tileset_version(const struct tileset *t)
Return tileset version.
std::map< QString, tileset_option > tileset_get_options(const struct tileset *t)
Gets the user-settable options of the tileset.
void toggle_focus_unit_state(struct tileset *t)
Toggle/increment the focus unit state.
int tileset_small_sprite_height(const struct tileset *t)
Return the small sprite height of the current tileset.
void tileset_free(struct tileset *t)
Clean up.
void focus_unit_in_combat(struct tileset *t)
Setup tileset for showing combat where focus unit participates.
static int tileset_upkeep_height(const struct tileset *t)
Get the height of a unit upkeep icons.
bool tileset_has_option(const struct tileset *t, const QString &option)
Checks if the tileset has supports the given user-settable option.
const QPixmap * get_mask_sprite(const struct tileset *t)
Return tile mask sprite.
const QPixmap * get_dither_sprite(const struct tileset *t)
Return dither sprite.
bool is_cardinal_tileset_dir(const struct tileset *t, enum direction8 dir)
Return TRUE iff the dir is cardinal in this tileset.
static bool tileset_update
QEvent::Type TilesetChanged
An event type sent to all widgets when the current tileset changes.
static void tileset_set_offsets(struct tileset *t, struct section_file *file)
void tileset_setup_extra(struct tileset *t, struct extra_type *pextra)
Set extra sprite values; should only happen after tilespec_load_tiles().
bool tileset_is_fully_loaded()
Is tileset in sane state?
const QPixmap * get_treaty_thumb_sprite(const struct tileset *t, bool on_off)
Return a thumbs-up/thumbs-down sprite to show treaty approval or disapproval.
void tileset_init(struct tileset *t)
Initialize tileset structure.
const QPixmap * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum direction8 facing, const QColor &replace)
Return the sprite for the unit type (the base "unit" sprite).
int tileset_tile_height(const struct tileset *t)
Return the tile height of the current tileset.
#define LOAD_FACING_SPRITE(dir)
bool tileset_set_option(struct tileset *t, const QString &name, bool enabled)
Enable or disable a user-settable tileset option.
struct tileset * get_tileset()
Returns the tileset.
void assign_digit_sprites(struct tileset *t, QPixmap *units[NUM_TILES_DIGITS], QPixmap *tens[NUM_TILES_DIGITS], QPixmap *hundreds[NUM_TILES_DIGITS], const QStringList &patterns)
Assigns the digits for city or go-to orders, for units, tens, and hundreds (i.e.
int tileset_unit_with_upkeep_height(const struct tileset *t)
Suitable canvas height for a unit icon that includes upkeep sprites.
static struct tileset * tileset_new()
Initialize.
static void tileset_free_toplevel(struct tileset *t)
Frees the tilespec toplevel data, in preparation for re-reading it.
int tileset_replaced_hue(const struct tileset *t)
Returns the hue (color) that should be replaced with the player color in player-dependent sprites.
const QPixmap * get_government_sprite(const struct tileset *t, const struct government *gov)
Return the sprite for the government.
int tileset_hex_height(const struct tileset *t)
Return the hex_height of the current tileset.
void reset_focus_unit_state(struct tileset *t)
Reset the focus unit state.
static const char *const OPTION_SECTION_PREFIX
The prefix for option sections in the tilespec file.
const QVector< QString > * get_tileset_list(const struct option *poption)
Returns a static list of tilesets available on the system by searching all data directories for files...
static void tileset_lookup_sprite_tags(struct tileset *t)
Initialize 'sprites' structure based on hardwired tags which freeciv always requires.
QPixmap * tiles_lookup_sprite_tag_alt(struct tileset *t, QtMsgType level, const char *tag, const char *alt, const char *what, const char *name, bool scale)
Lookup sprite to match tag, or else to match alt if don't find, or else return nullptr,...
bool tileset_has_options(const struct tileset *t)
Checks if the tileset has any user-settable options.
void finish_loading_sprites(struct tileset *t)
Frees any internal buffers which are created by load_sprite.
const QPixmap * get_unit_unhappy_sprite(const struct tileset *t, const struct unit *punit, int happy_cost)
Return a sprite for the unhappiness of the unit - to be shown as an overlay on the unit in the city s...
int tileset_num_valid_dirs(const struct tileset *t)
Returns the number of valid directions in the tileset.
void tileset_error(struct tileset *t, QtMsgType level, const char *format,...)
Called when ever there's problem in ruleset/tileset compatibility.
void tilespec_reread_callback(struct option *poption)
This is merely a wrapper for tilespec_reread (above) for use in options.c and the client local option...
const char * tileset_description(const struct tileset *t)
Return tileset description body.
static bool tileset_setup_options(struct tileset *t, const section_file *file)
Loads tileset options.
static void assign_digit_sprites_helper(struct tileset *t, QPixmap *sprites[NUM_TILES_DIGITS], const QStringList &patterns, const QString &suffix, bool required)
Goes through the possible digits and assigns them.
static void tileset_add_layer(struct tileset *t, mapview_layer layer)
Creates a layer object for the given enumerated type and appends it to the layers of t.
int tileset_full_tile_width(const struct tileset *t)
Return the full tile width of the current tileset.
QString cardinal_index_str(const struct tileset *t, int idx)
Return a directional string for the cardinal directions.
help_item * tileset_help(const struct tileset *t)
Creates the help item for the given tileset.
int tileset_num_index_cardinals(const struct tileset *t)
Returns the number of cardinal indices used by the tileset.
const QPixmap * get_spaceship_sprite(const struct tileset *t, enum spaceship_part part)
Return the sprite for drawing the given spaceship part.
const QPixmap * get_tax_sprite(const struct tileset *t, Output_type_id otype)
Return a tax sprite for the given output type (usually gold/lux/sci).
const QPixmap * get_cursor_sprite(const struct tileset *t, enum cursor_type cursor, int *hot_x, int *hot_y, int frame)
Returns a sprite for the given cursor.
QPixmap * get_unit_nation_flag_sprite(const struct tileset *t, const struct unit *punit)
Return a sprite for the national flag for this unit.
bool is_extra_drawing_enabled(const extra_type *pextra)
Should the given extra be drawn FIXME: Some extras can not be switched.
void tilespec_reread_frozen_refresh(const QString &name)
Read a new tilespec in from scratch.
std::array< direction8, 8 > tileset_valid_dirs(const struct tileset *t)
Returns the valid directions for the tileset.
static int ts_topology_index(int actual_topology)
Convert properties of the actual topology to an index of different tileset topology types.
double tileset_preferred_scale(const struct tileset *t)
Returns the preferred scale (zoom level) of the tileset.
struct unit * get_drawable_unit(const struct tileset *t, const ::tile *ptile)
Find unit that we can display from given tile.
QStringList make_tag_terrain_list(const QString &prefix, const QString &suffix, const struct terrain *pterrain)
Make the list of possible tag names for the extras which may vary depending on the terrain they're on...
static enum direction8 dir_by_tileset_name(const QString &str)
Parse a direction name as a direction8.
const QPixmap * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Return the sprite for the building/improvement.
QString dir_get_tileset_name(enum direction8 dir)
Return the tileset name of the direction.
bool tileset_has_error(const struct tileset *t)
Checks if the tileset had any error message (LOG_ERROR).
int tileset_tile_width(const struct tileset *t)
Return the tile width of the current tileset.
int tileset_tilelabel_offset_y(const struct tileset *t)
Return the offset from the origin of the tile at which to place the label text.
static void tileset_stop_read(struct tileset *t, struct section_file *file, char *fname, struct section_list *sections, const char **layer_order)
const struct editor_sprites * get_editor_sprites(const struct tileset *t)
Return all the sprites used for editor icons, images, etc.
static void unload_sprite(struct tileset *t, const QString &tag_name)
Unloads the sprite.
bool tilespec_try_read(const QString &tileset_name, bool verbose, int topo_id)
Read a new tilespec in when first starting the game.
static void ensure_big_sprite(struct tileset *t, struct specfile *sf)
Ensure that the big sprite of the given spec file is loaded.
std::vector< tileset_log_entry > tileset_log(const struct tileset *t)
Get tileset log (warnings, errors, etc.)
const QPixmap * get_nation_shield_sprite(const struct tileset *t, const struct nation_type *pnation)
Return the shield sprite for the nation.
void tileset_setup_nation_flag(struct tileset *t, struct nation_type *nation)
Set nation flag sprite value; should only happen after tilespec_load_tiles().
void tileset_ruleset_reset(struct tileset *t)
Reset tileset data specific to ruleset.
static struct tileset * tileset_read_toplevel(const QString &tileset_name, bool verbose, int topology_id)
Finds and reads the toplevel tilespec file based on given name.
static void scan_specfile(struct tileset *t, struct specfile *sf, bool duplicates_ok)
Scan all sprites declared in the given specfile.
#define NUM_CURSOR_FRAMES
#define NUM_TILES_PROGRESS
#define MAX_NUM_CITIZEN_SPRITES
bool unit_is_cityfounder(const struct unit *punit)
Is a cityfounder unit?
bool unit_has_orders(const struct unit *punit)
Return TRUE iff the unit is following client-side orders.
const char * utype_rule_name(const struct unit_type *punittype)
Return the (untranslated) rule name of the unit type.
Unit_type_id utype_index(const struct unit_type *punittype)
Return the unit type index.
#define unit_type_iterate(_p)
#define unit_type_iterate_end
struct tile * get_center_tile_mapcanvas()
Finds the current center tile of the mapcanvas.
enum topo_comp_lvl tileset_map_topo_compatible(int topology_id, struct tileset *tset)
Are the topology and tileset compatible?
void update_map_canvas_visible()
Schedules an update of (only) the visible part of the map at the next unqueue_mapview_update().