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/* SDL2 */
27#ifdef SDL2_PLAIN_INCLUDE
28#include <SDL.h>
29#else /* SDL2_PLAIN_INCLUDE */
30#include <SDL2/SDL.h>
31#endif /* SDL2_PLAIN_INCLUDE */
32
33/* utility */
34#include "fcintl.h"
35#include "log.h"
36
37/* common */
38#include "research.h"
39#include "specialist.h"
40
41/* client */
42#include "client_main.h"
43
44/* gui-sdl2 */
45#include "colors.h"
46#include "graphics.h"
47#include "gui_main.h"
48#include "gui_string.h"
49#include "sprite.h"
50#include "themespec.h"
51
52#include "gui_tilespec.h"
53
56
58
62
63#define load_gui_surface(_spr_, _struct_, _surf_, _tag_) \
64do { \
65 _spr_ = theme_lookup_sprite_tag_alt(active_theme, LOG_FATAL, \
66 _tag_, "", "", ""); \
67 fc_assert_action(_spr_ != NULL, break); \
68 _struct_->_surf_ = GET_SURF_REAL(_spr_); \
69} while (FALSE)
70
71#define load_theme_surface(spr, surf, tag) \
72 load_gui_surface(spr, current_theme, surf, tag)
73
74#define load_city_icon_surface(spr, surf, tag) \
75 load_gui_surface(spr, icons, surf, tag)
76
77#define load_order_theme_surface(spr, surf, tag) \
78 load_gui_surface(spr, current_theme, surf, tag);
79
80/***************************************************************************/
117
118/* ================================================================================= */
119/* ===================================== Public ==================================== */
120/* ================================================================================= */
121
122/***************************************************************************/
131
132/***************************************************************************/
136{
137 struct sprite *spr =
139 "theme.city", "", "", "");
140
142
144}
145
146/***************************************************************************/
150{
151 /* There was two copies of this. One is freed from the sprite hash, but
152 * one created by adj_surf() in tilespec_setup_city_gfx() is freed here. */
154}
155
156/***************************************************************************/
161{
162 struct sprite *spr = NULL;
163
164 icons = (struct city_icon *)fc_calloc(1, sizeof(struct city_icon));
165
166 load_city_icon_surface(spr, big_food_corr, "city.food_waste");
167 load_city_icon_surface(spr, big_shield_corr, "city.shield_waste");
168 load_city_icon_surface(spr, big_trade_corr, "city.trade_waste");
169 load_city_icon_surface(spr, big_food, "city.food");
170
173
174 load_city_icon_surface(spr, big_shield, "city.shield");
175
178
179 load_city_icon_surface(spr, big_trade, "city.trade");
181 load_city_icon_surface(spr, big_coin, "city.coin");
182 load_city_icon_surface(spr, big_colb, "city.colb");
183 load_city_icon_surface(spr, pBIG_Face, "city.red_face");
184 load_city_icon_surface(spr, big_coin_corr, "city.dark_coin");
185 load_city_icon_surface(spr, big_coin_upkeep, "city.upkeep_coin");
186
187 /* Small icon */
188 load_city_icon_surface(spr, food, "city.small_food");
189 load_city_icon_surface(spr, shield, "city.small_shield");
190 load_city_icon_surface(spr, trade, "city.small_trade");
191 load_city_icon_surface(spr, face, "city.small_red_face");
192 load_city_icon_surface(spr, pLuxury, "city.small_lux");
193 load_city_icon_surface(spr, coint, "city.small_coin");
194 load_city_icon_surface(spr, pColb, "city.small_colb");
195
196 load_city_icon_surface(spr, pollution, "city.pollution");
197 /* ================================================================= */
198
199 load_city_icon_surface(spr, police, "city.police");
200 /* ================================================================= */
203 SDL_MapRGB(icons->worklist->format, 255, 255,255));
204
206 0, 0, icons->worklist->w - 1, icons->worklist->h - 1,
209 3, 2, 5, 2,
212 3, 4, 7, 4,
215 3, 6, 6, 6,
217
218 /* ================================================================= */
219
220 /* Force reload citizens icons */
221 icons->style = 999;
222}
223
224/***************************************************************************/
228{
229 int i;
230 int spe_max;
231
232 if (!icons) {
233 return;
234 }
235
236 /* small citizens */
245
247 for (i = 0; i < spe_max; i++) {
249 }
250
251 FC_FREE(icons);
252}
253
254/* =================================================== */
255/* ===================== THEME ======================= */
256/* =================================================== */
257
258/***************************************************************************/
262{
263 struct sprite *buf = NULL;
264
265 current_theme = fc_calloc(1, sizeof(struct theme_icons));
266
267 load_theme_surface(buf, fr_left, "theme.left_frame");
268 load_theme_surface(buf, fr_right, "theme.right_frame");
269 load_theme_surface(buf, fr_top, "theme.top_frame");
270 load_theme_surface(buf, fr_bottom, "theme.bottom_frame");
271 load_theme_surface(buf, button, "theme.button");
272 load_theme_surface(buf, edit, "theme.edit");
273 load_theme_surface(buf, cbox_sell_icon, "theme.sbox");
274 load_theme_surface(buf, cbox_unsell_icon, "theme.ubox");
275 load_theme_surface(buf, up_icon, "theme.UP_scroll");
276 load_theme_surface(buf, down_icon, "theme.DOWN_scroll");
277#if 0
278 load_theme_surface(buf, left_icon, "theme.LEFT_scroll");
279 load_theme_surface(buf, right_icon, "theme.RIGHT_scroll");
280#endif
281 load_theme_surface(buf, vertic, "theme.vertic_scrollbar");
282 load_theme_surface(buf, horiz, "theme.horiz_scrollbar");
283
284 /* ------------------- */
285 load_theme_surface(buf, ok_pact_icon, "theme.pact_ok");
286 load_theme_surface(buf, cancel_pact_icon, "theme.pact_cancel");
287 /* ------------------- */
288 load_theme_surface(buf, small_ok_icon, "theme.SMALL_OK_button");
289 load_theme_surface(buf, small_cancel_icon, "theme.SMALL_FAIL_button");
290 /* ------------------- */
291 load_theme_surface(buf, ok_icon, "theme.OK_button");
292 load_theme_surface(buf, cancel_icon, "theme.FAIL_button");
293 load_theme_surface(buf, FORWARD_Icon, "theme.NEXT_button");
294 load_theme_surface(buf, back_icon, "theme.BACK_button");
295 load_theme_surface(buf, l_arrow_icon, "theme.LEFT_ARROW_button");
296 load_theme_surface(buf, r_arrow_icon, "theme.RIGHT_ARROW_button");
297 load_theme_surface(buf, map_icon, "theme.MAP_button");
298 load_theme_surface(buf, find_city_icon, "theme.FIND_CITY_button");
299 load_theme_surface(buf, new_turn_icon, "theme.NEW_TURN_button");
300 load_theme_surface(buf, log_icon, "theme.LOG_button");
301 load_theme_surface(buf, units_icon, "theme.UNITS_INFO_button");
302 load_theme_surface(buf, options_icon, "theme.OPTIONS_button");
303 load_theme_surface(buf, block, "theme.block");
304 load_theme_surface(buf, info_icon, "theme.INFO_button");
305 load_theme_surface(buf, army_icon, "theme.ARMY_button");
306 load_theme_surface(buf, happy_icon, "theme.HAPPY_button");
307 load_theme_surface(buf, support_icon, "theme.HOME_button");
308 load_theme_surface(buf, buy_prod_icon, "theme.BUY_button");
309 load_theme_surface(buf, prod_icon, "theme.PROD_button");
310 load_theme_surface(buf, qprod_icon, "theme.WORK_LIST_button");
311 load_theme_surface(buf, cma_icon, "theme.CMA_button");
312 load_theme_surface(buf, lock_icon, "theme.LOCK_button");
313 load_theme_surface(buf, unlock_icon, "theme.UNLOCK_button");
314 load_theme_surface(buf, players_icon, "theme.PLAYERS_button");
315 load_theme_surface(buf, units2_icon, "theme.UNITS_button");
316 load_theme_surface(buf, save_icon, "theme.SAVE_button");
317 load_theme_surface(buf, load_icon, "theme.LOAD_button");
318 load_theme_surface(buf, delete_icon, "theme.DELETE_button");
319 /* ------------------------------ */
320 load_theme_surface(buf, tech_tree_icon, "theme.tech_tree");
321 /* ------------------------------ */
322
323 load_order_theme_surface(buf, order_icon, "theme.order_empty");
324 load_order_theme_surface(buf, o_autoconnect_icon, "theme.order_auto_connect");
325 load_order_theme_surface(buf, o_autoexp_icon, "theme.order_auto_explorer");
326 load_order_theme_surface(buf, o_autosett_icon, "theme.order_auto_settler");
327 load_order_theme_surface(buf, o_build_city_icon, "theme.order_build_city");
328 load_order_theme_surface(buf, OCutDownForest_Icon, "theme.order_cutdown_forest");
329 load_order_theme_surface(buf, OPlantForest_Icon, "theme.order_plant_forest");
330 load_order_theme_surface(buf, o_mine_icon, "theme.order_build_mining");
331 load_order_theme_surface(buf, o_irrigation_icon, "theme.order_irrigation");
332 load_order_theme_surface(buf, o_cultivate_icon, "theme.order_cutdown_forest");
333 load_order_theme_surface(buf, o_plant_icon, "theme.order_plant_forest");
334 load_order_theme_surface(buf, o_done_icon, "theme.order_done");
335 load_order_theme_surface(buf, o_disband_icon, "theme.order_disband");
336 load_order_theme_surface(buf, o_fortify_icon, "theme.order_fortify");
337 load_order_theme_surface(buf, o_goto_icon, "theme.order_goto");
338 load_order_theme_surface(buf, o_goto_city_icon, "theme.order_goto_city");
339 load_order_theme_surface(buf, o_homecity_icon, "theme.order_home");
340 load_order_theme_surface(buf, o_nuke_icon, "theme.order_nuke");
341 load_order_theme_surface(buf, o_paradrop_icon, "theme.order_paradrop");
342 load_order_theme_surface(buf, o_patrol_icon, "theme.order_patrol");
343 load_order_theme_surface(buf, o_pillage_icon, "theme.order_pillage");
344 load_order_theme_surface(buf, o_railroad_icon, "theme.order_build_railroad");
345 load_order_theme_surface(buf, o_road_icon, "theme.order_build_road");
346 load_order_theme_surface(buf, o_sentry_icon, "theme.order_sentry");
347 load_order_theme_surface(buf, o_unload_icon, "theme.order_unload");
348 load_order_theme_surface(buf, o_wait_icon, "theme.order_wait");
349 load_order_theme_surface(buf, o_fortress_icon, "theme.order_build_fortress");
350 load_order_theme_surface(buf, o_clean_icon, "theme.order_clean");
351 load_order_theme_surface(buf, o_airbase_icon, "theme.order_build_airbase");
352 load_order_theme_surface(buf, o_transform_icon, "theme.order_transform");
353 load_order_theme_surface(buf, OAddCity_Icon, "theme.order_add_to_city");
354 load_order_theme_surface(buf, o_wonder_icon, "theme.order_carravan_wonder");
355 load_order_theme_surface(buf, o_trade_icon, "theme.order_carravan_trade_route");
356 load_order_theme_surface(buf, o_spy_icon, "theme.order_spying");
357 load_order_theme_surface(buf, o_wakeup_icon, "theme.order_wakeup");
358 load_order_theme_surface(buf, o_return_icon, "theme.order_return");
359 load_order_theme_surface(buf, OAirLift_Icon, "theme.order_airlift");
360 load_order_theme_surface(buf, o_load_icon, "theme.order_load");
361}
362
363/***************************************************************************/
367{
368 if (!current_theme) {
369 return;
370 }
371
374}
375
376/***************************************************************************/
380{
381 SDL_Color bg_color = {255, 255, 255, 136};
382 SDL_Surface *surf;
384
385 pstr->style |= (TTF_STYLE_BOLD | SF_CENTER);
386
387 /* Create icons */
388 surf = create_surf(adj_size(50), adj_size(50), SDL_SWSURFACE);
389 SDL_FillRect(surf, NULL, map_rgba(surf->format, bg_color));
390 create_frame(surf,
391 0 , 0, surf->w - 1, surf->h - 1,
393
396 future_tech_icon = surf;
397
398 /* None */
401 (adj_size(50) - surf->w) / 2 , (adj_size(50) - surf->h) / 2);
402
403 FREESURFACE(surf);
404
405 /* TRANS: Future Technology */
409 (adj_size(50) - surf->w) / 2 , (adj_size(50) - surf->h) / 2);
410
411 FREESURFACE(surf);
412
414}
415
416/***************************************************************************/
425
426/***************************************************************************/
430{
431 switch (tech) {
432 case A_NONE:
433 case A_UNSET:
434 case A_UNKNOWN:
435 case A_LAST:
436 return adj_surf(none_tech_icon);
437 case A_FUTURE:
439 default:
440 if (get_tech_sprite(tileset, tech)) {
442 } else {
444 }
445 }
446
447 return NULL;
448}
449
450/***************************************************************************/
472
473/***************************************************************************/
477{
478 return city_surf;
479}
480
481/***************************************************************************/
485{
487
488 if (intro->w != main_window_width()) {
490 main_window_height(), 1);
491
493 intro = tmp;
494 }
495
496 /* draw intro gfx center in screen */
498
500}
@ 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