18 const QPoint &city_flag_offset,
19 const QPoint &occupied_offset)
20 :
freeciv::
layer(ts, LAYER_CITY1), m_city_offset(city_offset),
21 m_city_flag_offset(city_flag_offset),
22 m_occupied_offset(occupied_offset)
42 auto gfx_in_use = style.
graphic;
46 const auto buffer = QStringLiteral(
"%1_%2_%3")
47 .arg(gfx_in_use, tag, QString::number(
size));
48 if (
const auto sprite =
load_sprite({buffer},
true,
false)) {
49 sprites.push_back(std::make_unique<freeciv::colorizer>(
51 }
else if (
size == 0) {
52 if (gfx_in_use == style.
graphic) {
68 "Could not find any sprite matching %s_%s_0 or %s_%s_0",
71 }
else if (sprites.empty()) {
74 "Could not find any sprite matching %s_%s_0",
75 style.
graphic, qUtf8Printable(tag));
78 sprites.size(), gfx_in_use, qUtf8Printable(tag));
97 for (
int i = 0; i <
m_walls.size(); i++) {
102 if (
m_tile.back().empty()) {
104 _(
"City style \"%s\": no city graphics."),
109 _(
"City style \"%s\": no occupied graphics."),
121 static const QPixmap *
123 const struct city *pcity)
131 const auto num_thresholds = city_sprite[style].size();
132 const auto &thresholds = city_sprite[style];
134 if (num_thresholds == 0) {
152 auto color = QColor();
153 if (owner && owner->rgb) {
154 color.setRgb(owner->rgb->r, owner->rgb->g, owner->rgb->b);
156 return thresholds[
img_index]->pixmap(color);
164 std::vector<drawn_sprite>
167 const unit *punit)
const
178 std::vector<drawn_sprite> sprs;
189 sprs.insert(sprs.end(), more.begin(), more.end());
199 std::vector<drawn_sprite>
201 bool show_occupied)
const
203 auto walls = pcity->
client.walls;
208 std::vector<drawn_sprite> sprs;
216 sprs.emplace_back(
tileset(), get_city_sprite(
m_tile, pcity),
true,
221 auto sprite = get_city_sprite(
m_walls[walls - 1], pcity);
227 sprs.emplace_back(
tileset(), sprite,
true,
233 if (show_occupied && pcity->
client.occupied) {
241 auto sprite = get_city_sprite(
m_walls[walls - 1], pcity);
247 sprs.emplace_back(
tileset(), sprite,
true,
253 if (pcity->
client.unhappy) {
const char * city_style_rule_name(const int style)
Return the (untranslated) rule name of the city style.
static citybar_painter * current()
Returns the current painter (never null).
layer_city::styles load_city_size_sprites(const QString &tag, const citystyle &style)
Loads a set of size-dependent city sprites, with tags of the form graphic_tag_size.
constexpr static int NUM_WALL_TYPES
std::vector< std::unique_ptr< freeciv::colorizer > > styles
void initialize_city_style(const citystyle &style, int index) override
Loads all sprites for a city style.
std::array< city_sprite, NUM_WALL_TYPES > m_walls
std::vector< styles > city_sprite
QPoint m_city_flag_offset
layer_city(struct tileset *ts, const QPoint &city_offset, const QPoint &city_flag_offset, const QPoint &occupied_offset)
void reset_ruleset() override
All sprites depend on the ruleset-defined city styles and need to be reset.
city_sprite m_single_wall
void load_sprites() override
Loads the disorder and happy sprites.
std::vector< drawn_sprite > fill_sprite_array_no_flag(const city *pcity, bool show_occupied) const
Fill in the given sprite array with any city sprites.
std::vector< drawn_sprite > fill_sprite_array(const tile *ptile, const tile_edge *pedge, const tile_corner *pcorner, const unit *punit) const override
Fill in the given sprite array with any needed city sprites.
A layer when drawing the map.
QPixmap * load_sprite(const QStringList &possible_names, bool required=false, bool verbose=true) const
Shortcut to load a sprite from the tileset.
struct tileset * tileset() const
int get_city_bonus(const struct city *pcity, enum effect_type effect_type, enum vision_layer vlayer)
Returns the effect bonus at a city.
#define fc_assert_ret(condition)
#define fc_assert_ret_val(condition, val)
static int img_index(const int x, const int y, const struct img *pimg)
Get the index for an (x,y) image coordinate.
client_options * gui_options
#define CLIP(lower, current, upper)
static bool wall(char *str, bool check)
Send a message to all players.
struct city::@15::@18 client
char graphic_alt[MAX_LEN_NAME]
char graphic[MAX_LEN_NAME]
int style_of_city(const struct city *pcity)
Evaluate which style should be used to draw a city.
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
const QPixmap * get_city_flag_sprite(const struct tileset *t, const struct city *pcity)
Return the flag graphic to be used by the city.
bool tileset_is_isometric(const struct tileset *t)
Return whether the current tileset is isometric.
QPoint tileset_full_tile_offset(const struct tileset *t)
Return the x and y offsets of full tiles in the tileset.
int tileset_replaced_hue(const struct tileset *t)
Returns the hue (color) that should be replaced with the player color in player-dependent sprites.
void tileset_error(struct tileset *t, QtMsgType level, const char *format,...)
Called when ever there's problem in ruleset/tileset compatibility.