Freeciv-3.2
Loading...
Searching...
No Matches
gui_tilespec.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14/***********************************************************************
15 gui_tilespec.c - description
16 -------------------
17 begin : Dec. 2 2002
18 copyright : (C) 2002 by RafaƂ Bursig
19 email : Rafal Bursig <bursig@poczta.fm>
20***********************************************************************/
21
22#ifdef HAVE_CONFIG_H
23#include <fc_config.h>
24#endif
25
26/* SDL3 */
27#include <SDL3/SDL.h>
28
29/* utility */
30#include "fcintl.h"
31#include "log.h"
32
33/* common */
34#include "research.h"
35#include "specialist.h"
36
37/* client */
38#include "client_main.h"
39
40/* gui-sdl3 */
41#include "colors.h"
42#include "graphics.h"
43#include "gui_main.h"
44#include "gui_string.h"
45#include "sprite.h"
46#include "themespec.h"
47
48#include "gui_tilespec.h"
49
52
54
58
59#define load_gui_surface(_spr_, _struct_, _surf_, _tag_) \
60do { \
61 _spr_ = theme_lookup_sprite_tag_alt(active_theme, LOG_FATAL, \
62 _tag_, "", "", ""); \
63 fc_assert_action(_spr_ != NULL, break); \
64 _struct_->_surf_ = GET_SURF_REAL(_spr_); \
65} while (FALSE)
66
67#define load_theme_surface(spr, surf, tag) \
68 load_gui_surface(spr, current_theme, surf, tag)
69
70#define load_city_icon_surface(spr, surf, tag) \
71 load_gui_surface(spr, icons, surf, tag)
72
73#define load_order_theme_surface(spr, surf, tag) \
74 load_gui_surface(spr, current_theme, surf, tag);
75
76/***************************************************************************/
113
114/* ================================================================================= */
115/* ===================================== Public ==================================== */
116/* ================================================================================= */
117
118/***************************************************************************/
127
128/***************************************************************************/
132{
133 struct sprite *spr =
135 "theme.city", "", "", "");
136
138
140}
141
142/***************************************************************************/
146{
147 /* There was two copies of this. One is freed from the sprite hash, but
148 * one created by adj_surf() in tilespec_setup_city_gfx() is freed here. */
150}
151
152/***************************************************************************/
157{
158 struct sprite *spr = NULL;
159
160 icons = (struct city_icon *)fc_calloc(1, sizeof(struct city_icon));
161
162 load_city_icon_surface(spr, big_food_corr, "city.food_waste");
163 load_city_icon_surface(spr, big_shield_corr, "city.shield_waste");
164 load_city_icon_surface(spr, big_trade_corr, "city.trade_waste");
165 load_city_icon_surface(spr, big_food, "city.food");
166
169
170 load_city_icon_surface(spr, big_shield, "city.shield");
171
174
175 load_city_icon_surface(spr, big_trade, "city.trade");
177 load_city_icon_surface(spr, big_coin, "city.coin");
178 load_city_icon_surface(spr, big_colb, "city.colb");
179 load_city_icon_surface(spr, pBIG_Face, "city.red_face");
180 load_city_icon_surface(spr, big_coin_corr, "city.dark_coin");
181 load_city_icon_surface(spr, big_coin_upkeep, "city.upkeep_coin");
182
183 /* Small icon */
184 load_city_icon_surface(spr, food, "city.small_food");
185 load_city_icon_surface(spr, shield, "city.small_shield");
186 load_city_icon_surface(spr, trade, "city.small_trade");
187 load_city_icon_surface(spr, face, "city.small_red_face");
188 load_city_icon_surface(spr, pLuxury, "city.small_lux");
189 load_city_icon_surface(spr, coint, "city.small_coin");
190 load_city_icon_surface(spr, pColb, "city.small_colb");
191
192 load_city_icon_surface(spr, pollution, "city.pollution");
193 /* ================================================================= */
194
195 load_city_icon_surface(spr, police, "city.police");
196 /* ================================================================= */
197 icons->worklist = create_surf(9, 9);
200 NULL, 255, 255,255));
201
203 0, 0, icons->worklist->w - 1, icons->worklist->h - 1,
206 3, 2, 5, 2,
209 3, 4, 7, 4,
212 3, 6, 6, 6,
214
215 /* ================================================================= */
216
217 /* Force reload citizens icons */
218 icons->style = 999;
219}
220
221/***************************************************************************/
225{
226 int i;
227 int spe_max;
228
229 if (!icons) {
230 return;
231 }
232
233 /* small citizens */
242
244 for (i = 0; i < spe_max; i++) {
246 }
247
248 FC_FREE(icons);
249}
250
251/* =================================================== */
252/* ===================== THEME ======================= */
253/* =================================================== */
254
255/***************************************************************************/
259{
260 struct sprite *buf = NULL;
261
262 current_theme = fc_calloc(1, sizeof(struct theme_icons));
263
264 load_theme_surface(buf, fr_left, "theme.left_frame");
265 load_theme_surface(buf, fr_right, "theme.right_frame");
266 load_theme_surface(buf, fr_top, "theme.top_frame");
267 load_theme_surface(buf, fr_bottom, "theme.bottom_frame");
268 load_theme_surface(buf, button, "theme.button");
269 load_theme_surface(buf, edit, "theme.edit");
270 load_theme_surface(buf, cbox_sell_icon, "theme.sbox");
271 load_theme_surface(buf, cbox_unsell_icon, "theme.ubox");
272 load_theme_surface(buf, up_icon, "theme.UP_scroll");
273 load_theme_surface(buf, down_icon, "theme.DOWN_scroll");
274#if 0
275 load_theme_surface(buf, left_icon, "theme.LEFT_scroll");
276 load_theme_surface(buf, right_icon, "theme.RIGHT_scroll");
277#endif
278 load_theme_surface(buf, vertic, "theme.vertic_scrollbar");
279 load_theme_surface(buf, horiz, "theme.horiz_scrollbar");
280
281 /* ------------------- */
282 load_theme_surface(buf, ok_pact_icon, "theme.pact_ok");
283 load_theme_surface(buf, cancel_pact_icon, "theme.pact_cancel");
284 /* ------------------- */
285 load_theme_surface(buf, small_ok_icon, "theme.SMALL_OK_button");
286 load_theme_surface(buf, small_cancel_icon, "theme.SMALL_FAIL_button");
287 /* ------------------- */
288 load_theme_surface(buf, ok_icon, "theme.OK_button");
289 load_theme_surface(buf, cancel_icon, "theme.FAIL_button");
290 load_theme_surface(buf, FORWARD_Icon, "theme.NEXT_button");
291 load_theme_surface(buf, back_icon, "theme.BACK_button");
292 load_theme_surface(buf, l_arrow_icon, "theme.LEFT_ARROW_button");
293 load_theme_surface(buf, r_arrow_icon, "theme.RIGHT_ARROW_button");
294 load_theme_surface(buf, map_icon, "theme.MAP_button");
295 load_theme_surface(buf, find_city_icon, "theme.FIND_CITY_button");
296 load_theme_surface(buf, new_turn_icon, "theme.NEW_TURN_button");
297 load_theme_surface(buf, log_icon, "theme.LOG_button");
298 load_theme_surface(buf, units_icon, "theme.UNITS_INFO_button");
299 load_theme_surface(buf, options_icon, "theme.OPTIONS_button");
300 load_theme_surface(buf, block, "theme.block");
301 load_theme_surface(buf, info_icon, "theme.INFO_button");
302 load_theme_surface(buf, army_icon, "theme.ARMY_button");
303 load_theme_surface(buf, happy_icon, "theme.HAPPY_button");
304 load_theme_surface(buf, support_icon, "theme.HOME_button");
305 load_theme_surface(buf, buy_prod_icon, "theme.BUY_button");
306 load_theme_surface(buf, prod_icon, "theme.PROD_button");
307 load_theme_surface(buf, qprod_icon, "theme.WORK_LIST_button");
308 load_theme_surface(buf, cma_icon, "theme.CMA_button");
309 load_theme_surface(buf, lock_icon, "theme.LOCK_button");
310 load_theme_surface(buf, unlock_icon, "theme.UNLOCK_button");
311 load_theme_surface(buf, players_icon, "theme.PLAYERS_button");
312 load_theme_surface(buf, units2_icon, "theme.UNITS_button");
313 load_theme_surface(buf, save_icon, "theme.SAVE_button");
314 load_theme_surface(buf, load_icon, "theme.LOAD_button");
315 load_theme_surface(buf, delete_icon, "theme.DELETE_button");
316 /* ------------------------------ */
317 load_theme_surface(buf, tech_tree_icon, "theme.tech_tree");
318 /* ------------------------------ */
319
320 load_order_theme_surface(buf, order_icon, "theme.order_empty");
321 load_order_theme_surface(buf, o_autoconnect_icon, "theme.order_auto_connect");
322 load_order_theme_surface(buf, o_autoexp_icon, "theme.order_auto_explorer");
323 load_order_theme_surface(buf, o_autosett_icon, "theme.order_auto_settler");
324 load_order_theme_surface(buf, o_build_city_icon, "theme.order_build_city");
325 load_order_theme_surface(buf, OCutDownForest_Icon, "theme.order_cutdown_forest");
326 load_order_theme_surface(buf, OPlantForest_Icon, "theme.order_plant_forest");
327 load_order_theme_surface(buf, o_mine_icon, "theme.order_build_mining");
328 load_order_theme_surface(buf, o_irrigation_icon, "theme.order_irrigation");
329 load_order_theme_surface(buf, o_cultivate_icon, "theme.order_cutdown_forest");
330 load_order_theme_surface(buf, o_plant_icon, "theme.order_plant_forest");
331 load_order_theme_surface(buf, o_done_icon, "theme.order_done");
332 load_order_theme_surface(buf, o_disband_icon, "theme.order_disband");
333 load_order_theme_surface(buf, o_fortify_icon, "theme.order_fortify");
334 load_order_theme_surface(buf, o_goto_icon, "theme.order_goto");
335 load_order_theme_surface(buf, o_goto_city_icon, "theme.order_goto_city");
336 load_order_theme_surface(buf, o_homecity_icon, "theme.order_home");
337 load_order_theme_surface(buf, o_nuke_icon, "theme.order_nuke");
338 load_order_theme_surface(buf, o_paradrop_icon, "theme.order_paradrop");
339 load_order_theme_surface(buf, o_patrol_icon, "theme.order_patrol");
340 load_order_theme_surface(buf, o_pillage_icon, "theme.order_pillage");
341 load_order_theme_surface(buf, o_railroad_icon, "theme.order_build_railroad");
342 load_order_theme_surface(buf, o_road_icon, "theme.order_build_road");
343 load_order_theme_surface(buf, o_sentry_icon, "theme.order_sentry");
344 load_order_theme_surface(buf, o_unload_icon, "theme.order_unload");
345 load_order_theme_surface(buf, o_wait_icon, "theme.order_wait");
346 load_order_theme_surface(buf, o_fortress_icon, "theme.order_build_fortress");
347 load_order_theme_surface(buf, o_clean_icon, "theme.order_clean");
348 load_order_theme_surface(buf, o_airbase_icon, "theme.order_build_airbase");
349 load_order_theme_surface(buf, o_transform_icon, "theme.order_transform");
350 load_order_theme_surface(buf, OAddCity_Icon, "theme.order_add_to_city");
351 load_order_theme_surface(buf, o_wonder_icon, "theme.order_carravan_wonder");
352 load_order_theme_surface(buf, o_trade_icon, "theme.order_carravan_trade_route");
353 load_order_theme_surface(buf, o_spy_icon, "theme.order_spying");
354 load_order_theme_surface(buf, o_wakeup_icon, "theme.order_wakeup");
355 load_order_theme_surface(buf, o_return_icon, "theme.order_return");
356 load_order_theme_surface(buf, OAirLift_Icon, "theme.order_airlift");
357 load_order_theme_surface(buf, o_load_icon, "theme.order_load");
358}
359
360/***************************************************************************/
364{
365 if (!current_theme) {
366 return;
367 }
368
371}
372
373/***************************************************************************/
377{
378 SDL_Color bg_color = {255, 255, 255, 136};
379 SDL_Surface *surf;
381
382 pstr->style |= (TTF_STYLE_BOLD | SF_CENTER);
383
384 /* Create icons */
385 surf = create_surf(adj_size(50), adj_size(50));
386 SDL_FillSurfaceRect(surf, NULL, map_rgba(surf->format, bg_color));
387 create_frame(surf,
388 0 , 0, surf->w - 1, surf->h - 1,
390
393 future_tech_icon = surf;
394
395 /* None */
398 (adj_size(50) - surf->w) / 2 , (adj_size(50) - surf->h) / 2);
399
400 FREESURFACE(surf);
401
402 /* TRANS: Future Technology */
406 (adj_size(50) - surf->w) / 2 , (adj_size(50) - surf->h) / 2);
407
408 FREESURFACE(surf);
409
411}
412
413/***************************************************************************/
422
423/***************************************************************************/
427{
428 switch (tech) {
429 case A_NONE:
430 case A_UNSET:
431 case A_UNKNOWN:
432 case A_LAST:
433 return adj_surf(none_tech_icon);
434 case A_FUTURE:
436 default:
437 if (get_tech_sprite(tileset, tech)) {
439 } else {
441 }
442 }
443
444 return NULL;
445}
446
447/***************************************************************************/
469
470/***************************************************************************/
474{
475 return city_surf;
476}
477
478/***************************************************************************/
482{
484
485 if (intro->w != main_window_width()) {
487 main_window_height(), 1);
488
490 intro = tmp;
491 }
492
493 /* draw intro gfx center in screen */
495
497}
@ CITIZEN_SPECIALIST
Definition city.h:273
@ CITIZEN_ANGRY
Definition city.h:271
@ CITIZEN_HAPPY
Definition city.h:268
@ CITIZEN_CONTENT
Definition city.h:269
@ CITIZEN_UNHAPPY
Definition city.h:270
#define client_player()
char * incite_cost
Definition comments.c:75
int Tech_type_id
Definition fc_types.h:377
#define Q_(String)
Definition fcintl.h:70
#define _(String)
Definition fcintl.h:67
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
SDL_Color * get_game_color(enum color_std stdcolor)
Definition colors.c:55
SDL_Surface * resize_surface(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth)
Definition graphics.c:1237
int main_window_width(void)
Definition graphics.c:685
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
Definition graphics.c:1379
SDL_Surface * copy_surface(SDL_Surface *src)
Definition graphics.c:1309
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
Definition graphics.c:236
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
struct sdl2_data main_data
Definition graphics.c:57
int blit_entire_src(SDL_Surface *psrc, SDL_Surface *pdest, Sint16 dest_x, Sint16 dest_y)
Definition graphics.c:417
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1348
int main_window_height(void)
Definition graphics.c:693
#define FREESURFACE(ptr)
Definition graphics.h:322
#define adj_surf(surf)
Definition graphics.h:200
#define map_rgba(format, color)
Definition graphics.h:315
#define adj_size(size)
Definition gui_main.h:141
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
#define FREEUTF8STR(pstr)
Definition gui_string.h:93
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_DEFAULT
Definition gui_string.h:65
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
struct city_icon * icons
void setup_auxiliary_tech_icons(void)
#define load_city_icon_surface(spr, surf, tag)
struct theme_icons * current_theme
void tilespec_setup_city_gfx(void)
static SDL_Surface * neutral_tech_icon
#define load_order_theme_surface(spr, surf, tag)
static void reload_small_citizens_icons(int style)
SDL_Color * get_tech_color(Tech_type_id tech_id)
void draw_intro_gfx(void)
static SDL_Surface * none_tech_icon
void tilespec_free_city_icons(void)
void tilespec_setup_theme(void)
void tilespec_free_city_gfx(void)
static SDL_Surface * city_surf
static SDL_Surface * future_tech_icon
void tilespec_setup_city_icons(void)
#define load_theme_surface(spr, surf, tag)
void tilespec_free_theme(void)
SDL_Surface * get_tech_icon(Tech_type_id tech)
void reload_citizens_icons(int style)
SDL_Surface * get_city_gfx(void)
void free_auxiliary_tech_icons(void)
static SDL_Surface * get_citizen_surface(enum citizen_category type, int citizen_index)
#define GET_SURF(m_sprite)
Definition sprite.h:29
#define GET_SURF_REAL(m_sprite)
Definition sprite.h:26
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
@ BACKGROUND_MAINPAGE
@ COLOR_THEME_CITYREP_FRAME
Definition themecolors.h:70
@ COLOR_THEME_SCIENCEDLG_FRAME
struct sprite * theme_lookup_sprite_tag_alt(struct theme *t, enum log_level level, const char *tag, const char *alt, const char *what, const char *name)
Definition themespec.c:1000
struct theme * active_theme
Definition themespec.c:154
#define edit(pedit)
Definition widget_edit.h:34
#define fc_assert(condition)
Definition log.h:176
@ LOG_FATAL
Definition log.h:29
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
Specialist_type_id specialist_count(void)
Definition specialist.c:71
SDL_Surface * pollution
SDL_Surface * shield
SDL_Surface * coint
SDL_Surface * big_trade_corr
SDL_Surface * trade
SDL_Surface * big_shield_corr
SDL_Surface * big_trade
SDL_Surface * face
SDL_Surface * food
SDL_Surface * female_angry
SDL_Surface * big_shield
SDL_Surface * specialists[SP_MAX]
SDL_Surface * female_happy
SDL_Surface * big_luxury
SDL_Surface * female_content
SDL_Surface * police
SDL_Surface * pBIG_Face
SDL_Surface * big_colb
SDL_Surface * big_coin_upkeep
SDL_Surface * pLuxury
SDL_Surface * female_unhappy
SDL_Surface * male_unhappy
SDL_Surface * male_content
SDL_Surface * big_food
SDL_Surface * big_coin_corr
SDL_Surface * male_happy
SDL_Surface * big_coin
SDL_Surface * big_food_corr
SDL_Surface * male_angry
SDL_Surface * big_food_surplus
SDL_Surface * pColb
SDL_Surface * worklist
SDL_Surface * big_shield_surplus
SDL_Surface * map
Definition graphics.h:210
#define TRUE
Definition support.h:46
#define A_FUTURE
Definition tech.h:46
#define A_NONE
Definition tech.h:43
#define A_UNSET
Definition tech.h:48
#define A_UNKNOWN
Definition tech.h:49
#define A_LAST
Definition tech.h:45
struct sprite * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
Definition tilespec.c:6774