Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-sdl2/mapview.c Source File

Freeciv-3.1

Loading...
Searching...
No Matches
mapview.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 mapview.c - description
16 -------------------
17 begin : Aug 10 2002
18 copyright : (C) 2002 by Rafał Bursig
19 email : Rafał 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 "astring.h"
35#include "bugs.h"
36#include "fcintl.h"
37#include "log.h"
38
39/* common */
40#include "calendar.h"
41#include "game.h"
42#include "goto.h"
43#include "government.h"
44#include "movement.h"
45#include "research.h"
46#include "unitlist.h"
47
48/* client */
49#include "citydlg_common.h"
50#include "client_main.h"
51#include "climisc.h"
52#include "overview_common.h"
53#include "pages_g.h"
54#include "text.h"
55
56/* gui-sdl2 */
57#include "colors.h"
58#include "dialogs.h"
59#include "graphics.h"
60#include "gui_id.h"
61#include "gui_main.h"
62#include "gui_mouse.h"
63#include "gui_tilespec.h"
64#include "mapctrl.h"
65#include "sprite.h"
66#include "themespec.h"
67#include "widget.h"
68
69#include "mapview.h"
70
71extern SDL_Rect *info_area;
72
73 int overview_start_x = 0;
74 int overview_start_y = 0;
75
76 static struct canvas *overview_canvas;
77 static struct canvas *city_map_canvas = NULL;
78 static struct canvas *terrain_canvas;
79
80/* ================================================================ */
81
82 void update_map_canvas_scrollbars_size(void)
83{
84 /* No scrollbars */
85}
86
87 static bool is_flush_queued = FALSE;
88
89/**********************************************************************/
92 static void flush_mapcanvas(int canvas_x, int canvas_y,
93 int pixel_width, int pixel_height)
94{
95 SDL_Rect rect = {canvas_x, canvas_y, pixel_width, pixel_height};
96
97 alphablit(mapview.store->surf, &rect, main_data.map, &rect, 255);
98}
99
100/**********************************************************************/
103 void flush_rect(SDL_Rect *rect, bool force_flush)
104{
105 if (is_flush_queued && !force_flush) {
106 dirty_sdl_rect(rect);
107 } else {
108 static SDL_Rect src, dst;
109
110 if (correct_rect_region(rect)) {
111 static int i = 0;
112
113 dst = *rect;
114 if (C_S_RUNNING == client_state()) {
115 flush_mapcanvas(dst.x, dst.y, dst.w, dst.h);
116 }
117 screen_blit(main_data.map, rect, &dst, 255);
118 if (main_data.guis) {
119 while ((i < main_data.guis_count) && main_data.guis[i]) {
120 src = *rect;
121 screen_rect_to_layer_rect(main_data.guis[i], &src);
122 dst = *rect;
123 screen_blit(main_data.guis[i++]->surface, &src, &dst, 255);
124 }
125 }
126 i = 0;
127
128 /* flush main buffer to framebuffer */
129#if 0
130 SDL_UpdateRect(main_data.screen, rect->x, rect->y, rect->w, rect->h);
131#endif /* 0 */
132 }
133 }
134}
135
136/**********************************************************************/
140 void unqueue_flush(void)
141{
142 flush_dirty();
143 redraw_selection_rectangle();
144 is_flush_queued = FALSE;
145}
146
147/**********************************************************************/
152 void queue_flush(void)
153{
154 if (!is_flush_queued) {
155 if (flush_event()) {
156 is_flush_queued = TRUE;
157 } else {
158 /* We don't want to set is_flush_queued in this case, since then
159 * the flush code would simply stop working. But this means the
160 * below message may be repeated many times. */
161 bugreport_request(_("Failed to add events to SDL2 event buffer: %s"),
162 SDL_GetError());
163 }
164 }
165}
166
167/**********************************************************************/
170 void dirty_rect(int canvas_x, int canvas_y,
171 int pixel_width, int pixel_height)
172{
173 SDL_Rect Rect = {canvas_x, canvas_y, pixel_width, pixel_height};
174
175 dirty_sdl_rect(&Rect);
176}
177
178/**********************************************************************/
181 void dirty_sdl_rect(SDL_Rect *Rect)
182{
183 if ((main_data.rects_count < RECT_LIMIT) && correct_rect_region(Rect)) {
184 main_data.rects[main_data.rects_count++] = *Rect;
185 queue_flush();
186 }
187}
188
189/**********************************************************************/
192 void dirty_all(void)
193{
194 main_data.rects_count = RECT_LIMIT;
195 queue_flush();
196}
197
198/**********************************************************************/
201 void flush_all(void)
202{
203 is_flush_queued = FALSE;
204 main_data.rects_count = RECT_LIMIT;
205 flush_dirty();
206}
207
208/**********************************************************************/
212 void flush_dirty(void)
213{
214 static int j = 0;
215
216 if (!main_data.rects_count) {
217 return;
218 }
219
220 if (main_data.rects_count >= RECT_LIMIT) {
221
222 if ((C_S_RUNNING == client_state())
223 && (get_client_page() == PAGE_GAME)) {
224 flush_mapcanvas(0, 0, main_window_width(), main_window_height());
225 refresh_overview();
226 }
227 screen_blit(main_data.map, NULL, NULL, 255);
228 if (main_data.guis) {
229 while ((j < main_data.guis_count) && main_data.guis[j]) {
230 SDL_Rect dst = main_data.guis[j]->dest_rect;
231
232 screen_blit(main_data.guis[j++]->surface, NULL, &dst, 255);
233 }
234 }
235 j = 0;
236
237 draw_mouse_cursor();
238
239 /* Render to screen */
240 update_main_screen();
241 } else {
242 static int i;
243 static SDL_Rect src, dst;
244
245 for (i = 0; i < main_data.rects_count; i++) {
246
247 dst = main_data.rects[i];
248 if (C_S_RUNNING == client_state()) {
249 flush_mapcanvas(dst.x, dst.y, dst.w, dst.h);
250 }
251 screen_blit(main_data.map, &main_data.rects[i], &dst, 255);
252
253 if (main_data.guis) {
254 while ((j < main_data.guis_count) && main_data.guis[j]) {
255 src = main_data.rects[i];
256 screen_rect_to_layer_rect(main_data.guis[j], &src);
257 dst = main_data.rects[i];
258 screen_blit(main_data.guis[j++]->surface, &src, &dst, 255);
259 }
260 }
261 j = 0;
262
263 /* restore widget info label if it overlaps with this area */
264 dst = main_data.rects[i];
265 if (info_area && !(((dst.x + dst.w) < info_area->x)
266 || (dst.x > (info_area->x + info_area->w))
267 || ((dst.y + dst.h) < info_area->y)
268 || (dst.y > (info_area->y + info_area->h)))) {
269 redraw_widget_info_label(&dst);
270 }
271 }
272
273 draw_mouse_cursor();
274
275 /* Render to screen */
276 update_main_screen();
277#if 0
278 SDL_UpdateRects(main_data.screen, main_data.rects_count, main_data.rects);
279#endif
280 }
281 main_data.rects_count = 0;
282}
283
284/**********************************************************************/
287 void gui_flush(void)
288{
289 if (C_S_RUNNING == client_state()) {
290 refresh_overview();
291 }
292}
293
294/* ===================================================================== */
295
296/**********************************************************************/
301 void set_indicator_icons(struct sprite *bulb, struct sprite *sol,
302 struct sprite *flake, struct sprite *gov)
303{
304 struct widget *buf = NULL;
305 char cbuf[128];
306
307 buf = get_widget_pointer_from_main_list(ID_WARMING_ICON);
308 FREESURFACE(buf->theme);
309 buf->theme = adj_surf(GET_SURF(sol));
310 widget_redraw(buf);
311 widget_mark_dirty(buf);
312
313 buf = get_widget_pointer_from_main_list(ID_COOLING_ICON);
314 FREESURFACE(buf->theme);
315 buf->theme = adj_surf(GET_SURF(flake));
316 widget_redraw(buf);
317 widget_mark_dirty(buf);
318
319 buf = get_revolution_widget();
320 set_new_icon2_theme(buf, adj_surf(GET_SURF(gov)), TRUE);
321
322 if (NULL != client.conn.playing) {
323 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)\n%s",
324 _("Revolution"), "Ctrl+Shift+G",
325 government_name_for_player(client.conn.playing));
326 } else {
327 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)\n%s",
328 _("Revolution"), "Ctrl+Shift+G",
329 Q_("?gov:None"));
330 }
331 copy_chars_to_utf8_str(buf->info_label, cbuf);
332
333 widget_redraw(buf);
334 widget_mark_dirty(buf);
335
336 buf = get_tax_rates_widget();
337 if (!buf->theme) {
338 set_new_icon2_theme(buf, get_tax_surface(O_GOLD), TRUE);
339 }
340
341 buf = get_research_widget();
342
343 if (NULL == client.conn.playing) {
344 /* TRANS: Research report action */
345 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)\n%s (%d/%d)", _("Research"), "F6",
346 Q_("?tech:None"), 0, 0);
347 } else {
348 const struct research *presearch = research_get(client_player());
349
350 if (A_UNSET != presearch->researching) {
351 /* TRANS: Research report action */
352 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)\n%s (%d/%d)",
353 _("Research"), "F6",
354 research_advance_name_translation(presearch,
355 presearch->researching),
356 presearch->bulbs_researched,
357 presearch->client.researching_cost);
358 } else {
359 /* TRANS: Research report action */
360 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)\n%s (%d/%d)",
361 _("Research"), "F6",
362 research_advance_name_translation(presearch,
363 presearch->researching),
364 presearch->bulbs_researched,
365 0);
366 }
367 }
368
369 copy_chars_to_utf8_str(buf->info_label, cbuf);
370
371 set_new_icon2_theme(buf, adj_surf(GET_SURF(bulb)), TRUE);
372
373 widget_redraw(buf);
374 widget_mark_dirty(buf);
375}
376
377/**********************************************************************/
383 void overview_size_changed(void)
384{
385 map_canvas_resized(main_window_width(), main_window_height());
386
387 if (overview_canvas) {
388 canvas_free(overview_canvas);
389 }
390 overview_canvas = canvas_create(gui_options.overview.width,
391 gui_options.overview.height);
392
393 resize_minimap();
394}
395
396/**********************************************************************/
401 void update_info_label(void)
402{
403 SDL_Color bg_color = {0, 0, 0, 80};
404 SDL_Surface *tmp = NULL;
405 char buffer[512];
406#ifdef SMALL_SCREEN
407 SDL_Rect area = {0, 0, 0, 0};
408#else
409 SDL_Rect area = {0, 3, 0, 0};
410#endif
411 struct utf8_str *ptext;
412
413 if (get_current_client_page() != PAGE_GAME) {
414 return;
415 }
416
417 ptext = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT);
418
419 /* Set text settings */
420 ptext->style |= TTF_STYLE_BOLD;
421 ptext->fgcol = *get_theme_color(COLOR_THEME_MAPVIEW_INFO_TEXT);
422 ptext->bgcol = (SDL_Color) {0, 0, 0, 0};
423
424 if (NULL != client.conn.playing) {
425#ifdef SMALL_SCREEN
426 fc_snprintf(buffer, sizeof(buffer),
427 _("%s Population: %s Year: %s "
428 "Gold %d "),
429 nation_adjective_for_player(client.conn.playing),
430 population_to_text(civ_population(client.conn.playing)),
431 calendar_text(),
432 client.conn.playing->economic.gold);
433#else /* SMALL_SCREEN */
434 fc_snprintf(buffer, sizeof(buffer),
435 _("%s Population: %s Year: %s "
436 "Gold %d Tax: %d Lux: %d Sci: %d "),
437 nation_adjective_for_player(client.conn.playing),
438 population_to_text(civ_population(client.conn.playing)),
439 calendar_text(),
440 client.conn.playing->economic.gold,
441 client.conn.playing->economic.tax,
442 client.conn.playing->economic.luxury,
443 client.conn.playing->economic.science);
444#endif /* SMALL_SCREEN */
445
446 /* Convert to utf8_str and create text surface */
447 copy_chars_to_utf8_str(ptext, buffer);
448 tmp = create_text_surf_from_utf8(ptext);
449
450 area.x = (main_window_width() - tmp->w) / 2 - adj_size(5);
451 area.w = tmp->w + adj_size(8);
452 area.h = tmp->h + adj_size(4);
453
454 SDL_FillRect(main_data.gui->surface, &area,
455 map_rgba(main_data.gui->surface->format, bg_color));
456
457 /* Horizontal lines */
458 create_line(main_data.gui->surface,
459 area.x + 1, area.y, area.x + area.w - 2, area.y,
460 get_theme_color(COLOR_THEME_MAPVIEW_INFO_FRAME));
461 create_line(main_data.gui->surface,
462 area.x + 1, area.y + area.h - 1, area.x + area.w - 2,
463 area.y + area.h - 1,
464 get_theme_color(COLOR_THEME_MAPVIEW_INFO_FRAME));
465
466 /* Vertical lines */
467 create_line(main_data.gui->surface,
468 area.x + area.w - 1, area.y + 1, area.x + area.w - 1,
469 area.y + area.h - 2,
470 get_theme_color(COLOR_THEME_MAPVIEW_INFO_FRAME));
471 create_line(main_data.gui->surface,
472 area.x, area.y + 1, area.x, area.y + area.h - 2,
473 get_theme_color(COLOR_THEME_MAPVIEW_INFO_FRAME));
474
475 /* Blit text to screen */
476 blit_entire_src(tmp, main_data.gui->surface, area.x + adj_size(5),
477 area.y + adj_size(2));
478
479 dirty_sdl_rect(&area);
480
481 FREESURFACE(tmp);
482 }
483
484 set_indicator_icons(client_research_sprite(),
485 client_warming_sprite(),
486 client_cooling_sprite(),
487 client_government_sprite());
488
489 update_timeout_label();
490
491 FREEUTF8STR(ptext);
492
493 queue_flush();
494}
495
496/**********************************************************************/
499 static int focus_units_info_callback(struct widget *pwidget)
500{
501 if (PRESSED_EVENT(main_data.event)) {
502 struct unit *punit = pwidget->data.unit;
503
504 if (punit) {
505 request_new_unit_activity(punit, ACTIVITY_IDLE);
506 unit_focus_set(punit);
507 }
508 }
509
510 return -1;
511}
512
513/**********************************************************************/
517 void redraw_unit_info_label(struct unit_list *punitlist)
518{
519 struct widget *info_window;
520 SDL_Rect src, area;
521 SDL_Rect dest;
522 SDL_Surface *buf_surf;
523 utf8_str *pstr;
524 struct canvas *destcanvas;
525 struct unit *punit;
526
527 if (punitlist != NULL && unit_list_size(punitlist) > 0) {
528 punit = unit_list_get(punitlist, 0);
529 } else {
530 punit = NULL;
531 }
532
533 if (sdl2_client_flags & CF_UNITINFO_SHOWN) {
534 info_window = get_unit_info_window_widget();
535
536 /* Blit theme surface */
537 widget_redraw(info_window);
538
539 if (punit) {
540 SDL_Surface *name, *vet_name = NULL, *info, *info2 = NULL;
541 int sy, y, width, height, n;
542 bool right;
543 char buffer[512];
544 struct tile *ptile = unit_tile(punit);
545 const char *vetname;
546
547 /* Get and draw unit name (with veteran status) */
548 pstr = create_utf8_from_char_fonto(unit_name_translation(punit),
549 FONTO_ATTENTION);
550 pstr->style |= TTF_STYLE_BOLD;
551 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
552 name = create_text_surf_from_utf8(pstr);
553
554 pstr->style &= ~TTF_STYLE_BOLD;
555
556 if (info_window->size.w > 1.8 *
557 ((info_window->size.w - info_window->area.w) + DEFAULT_UNITS_W)) {
558 width = info_window->area.w / 2;
559 right = TRUE;
560 } else {
561 width = info_window->area.w;
562 right = FALSE;
563 }
564
565 change_fonto_utf8(pstr, FONTO_DEFAULT);
566 vetname = utype_veteran_name_translation(unit_type_get(punit),
567 punit->veteran);
568 if (vetname != NULL) {
569 copy_chars_to_utf8_str(pstr, vetname);
570 pstr->fgcol = *get_theme_color(COLOR_THEME_MAPVIEW_UNITINFO_VETERAN_TEXT);
571 vet_name = create_text_surf_from_utf8(pstr);
572 pstr->fgcol = *get_theme_color(COLOR_THEME_MAPVIEW_UNITINFO_TEXT);
573 }
574
575 /* Get and draw other info (MP, terrain, city, etc.) */
576 pstr->style |= SF_CENTER;
577
578 copy_chars_to_utf8_str(pstr,
579 get_unit_info_label_text2(punitlist,
580 TILE_LB_RESOURCE_POLL));
581 info = create_text_surf_from_utf8(pstr);
582
583 if (info_window->size.h >
584 (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h)) || right) {
585 int h = TTF_FontHeight(info_window->string_utf8->font);
586
587 fc_snprintf(buffer, sizeof(buffer), "%s",
588 sdl_get_tile_defense_info_text(ptile));
589
590 if (info_window->size.h >
591 2 * h + (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h)) || right) {
592 struct city *pcity = tile_city(ptile);
593
594 if (BORDERS_DISABLED != game.info.borders && !pcity) {
595 const char *diplo_nation_plural_adjectives[DS_LAST] =
596 {"" /* unused, DS_ARMISTICE */, Q_("?nation:Hostile"),
597 "" /* unused, DS_CEASEFIRE */,
598 Q_("?nation:Peaceful"), Q_("?nation:Friendly"),
599 Q_("?nation:Mysterious")};
600
601 if (tile_owner(ptile) == client.conn.playing) {
602 cat_snprintf(buffer, sizeof(buffer), _("\nOur Territory"));
603 } else {
604 if (tile_owner(ptile)) {
605 struct player_diplstate *ds
606 = player_diplstate_get(client.conn.playing,
607 tile_owner(ptile));
608
609 if (DS_CEASEFIRE == ds->type) {
610 int turns = ds->turns_left;
611
612 cat_snprintf(buffer, sizeof(buffer),
613 PL_("\n%s territory (%d turn ceasefire)",
614 "\n%s territory (%d turn ceasefire)", turns),
615 nation_adjective_for_player(tile_owner(ptile)),
616 turns);
617 } else if (DS_ARMISTICE == ds->type) {
618 int turns = ds->turns_left;
619
620 cat_snprintf(buffer, sizeof(buffer),
621 PL_("\n%s territory (%d turn armistice)",
622 "\n%s territory (%d turn armistice)", turns),
623 nation_adjective_for_player(tile_owner(ptile)),
624 turns);
625 } else {
626 cat_snprintf(buffer, sizeof(buffer), _("\nTerritory of the %s %s"),
627 diplo_nation_plural_adjectives[ds->type],
628 nation_plural_for_player(tile_owner(ptile)));
629 }
630 } else { /* !tile_owner(ptile) */
631 cat_snprintf(buffer, sizeof(buffer), _("\nUnclaimed territory"));
632 }
633 }
634 } /* BORDERS_DISABLED != game.info.borders && !pcity */
635
636 if (pcity) {
637 /* Look at city owner, not tile owner (the two should be the same, if
638 * borders are in use). */
639 struct player *owner = city_owner(pcity);
640 const char *diplo_city_adjectives[DS_LAST] =
641 {Q_("?city:Neutral"), Q_("?city:Hostile"),
642 Q_("?city:Neutral"), Q_("?city:Peaceful"),
643 Q_("?city:Friendly"), Q_("?city:Mysterious")};
644
645 cat_snprintf(buffer, sizeof(buffer),
646 _("\nCity of %s"),
647 city_name_get(pcity));
648
649#if 0
650 /* This has hardcoded assumption that EFT_LAND_REGEN is always
651 * provided by *building* named *Barracks*. Similar assumptions for
652 * other effects. */
653 if (pplayers_allied(client.conn.playing, owner)) {
654 barrack = (get_city_bonus(pcity, EFT_LAND_REGEN) > 0);
655 airport = (get_city_bonus(pcity, EFT_AIR_VETERAN) > 0);
656 port = (get_city_bonus(pcity, EFT_SEA_VETERAN) > 0);
657 }
658
659 if (citywall || barrack || airport || port) {
660 cat_snprintf(buffer, sizeof(buffer), Q_("?blistbegin: with "));
661 if (barrack) {
662 cat_snprintf(buffer, sizeof(buffer), _("Barracks"));
663 if (port || airport || citywall) {
664 cat_snprintf(buffer, sizeof(buffer), Q_("?blistmore:, "));
665 }
666 }
667 if (port) {
668 cat_snprintf(buffer, sizeof(buffer), _("Port"));
669 if (airport || citywall) {
670 cat_snprintf(buffer, sizeof(buffer), Q_("?blistmore:, "));
671 }
672 }
673 if (airport) {
674 cat_snprintf(buffer, sizeof(buffer), _("Airport"));
675 if (citywall) {
676 cat_snprintf(buffer, sizeof(buffer), Q_("?blistmore:, "));
677 }
678 }
679 if (citywall) {
680 cat_snprintf(buffer, sizeof(buffer), _("City Walls"));
681 }
682
683 cat_snprintf(buffer, sizeof(buffer), Q_("?blistend:"));
684 }
685#endif /* 0 */
686
687 if (owner && owner != client.conn.playing) {
688 struct player_diplstate *ds
689 = player_diplstate_get(client.conn.playing, owner);
690
691 /* TRANS: (<nation>,<diplomatic_state>)" */
692 cat_snprintf(buffer, sizeof(buffer), _("\n(%s,%s)"),
693 nation_adjective_for_player(owner),
694 diplo_city_adjectives[ds->type]);
695 }
696 }
697 }
698
699 if (info_window->size.h >
700 4 * h + (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h)) || right) {
701 cat_snprintf(buffer, sizeof(buffer), _("\nFood/Prod/Trade: %s"),
702 get_tile_output_text(unit_tile(punit)));
703 }
704
705 copy_chars_to_utf8_str(pstr, buffer);
706
707 info2 = create_text_surf_smaller_than_w(pstr, width - BLOCKU_W - adj_size(4));
708 }
709
710 FREEUTF8STR(pstr);
711
712 /* ------------------------------------------- */
713
714 n = unit_list_size(ptile->units);
715 y = 0;
716
717 if (n > 1 && ((!right && info2
718 && (info_window->size.h - (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h)) -
719 info2->h > 52))
720 || (right && info_window->size.h - (DEFAULT_UNITS_H + (info_window->size.h -
721 info_window->area.h)) > 52))) {
722 height = (info_window->size.h - info_window->area.h) + DEFAULT_UNITS_H;
723 } else {
724 height = info_window->size.h;
725 if (info_window->size.h > (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h))) {
726 y = (info_window->size.h - (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h)) -
727 (!right && info2 ? info2->h : 0)) / 2;
728 }
729 }
730
731 sy = y + adj_size(3);
732 area.y = info_window->area.y + sy;
733 area.x = info_window->area.x + BLOCKU_W + (width - name->w - BLOCKU_W) / 2;
734 dest = area;
735 alphablit(name, NULL, info_window->dst->surface, &dest, 255);
736 sy += name->h;
737 if (vet_name) {
738 area.y += name->h - adj_size(3);
739 area.x = info_window->area.x + BLOCKU_W + (width - vet_name->w - BLOCKU_W) / 2;
740 alphablit(vet_name, NULL, info_window->dst->surface, &area, 255);
741 sy += vet_name->h - adj_size(3);
742 FREESURFACE(vet_name);
743 }
744 FREESURFACE(name);
745
746 /* draw unit sprite */
747 buf_surf = resize_surface_box(get_unittype_surface(unit_type_get(punit),
748 punit->facing),
749 adj_size(80), adj_size(80), 1, TRUE, TRUE);
750
751 src = (SDL_Rect){0, 0, buf_surf->w, buf_surf->h};
752
753 area.x = info_window->area.x + BLOCKU_W - adj_size(4) +
754 ((width - BLOCKU_W + adj_size(3) - src.w) / 2);
755 area.y = info_window->size.y + sy + (DEFAULT_UNITS_H - sy - src.h) / 2;
756 alphablit(buf_surf, &src, info_window->dst->surface, &area, 32);
757 FREESURFACE(buf_surf);
758
759 /* blit unit info text */
760 area.x = info_window->area.x + BLOCKU_W - adj_size(4) +
761 ((width - BLOCKU_W + adj_size(4) - info->w) / 2);
762 area.y = info_window->size.y + sy + (DEFAULT_UNITS_H - sy - info->h) / 2;
763
764 alphablit(info, NULL, info_window->dst->surface, &area, 255);
765 FREESURFACE(info);
766
767 if (info2) {
768 if (right) {
769 area.x = info_window->area.x + width + (width - info2->w) / 2;
770 area.y = info_window->area.y + (height - info2->h) / 2;
771 } else {
772 area.y = info_window->area.y + DEFAULT_UNITS_H + y;
773 area.x = info_window->area.x + BLOCKU_W +
774 (width - BLOCKU_W - info2->w) / 2;
775 }
776
777 /* blit unit info text */
778 alphablit(info2, NULL, info_window->dst->surface, &area, 255);
779
780 if (right) {
781 sy = (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h));
782 } else {
783 sy = area.y - info_window->size.y + info2->h;
784 }
785 FREESURFACE(info2);
786 } else {
787 sy = (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h));
788 }
789
790 if (n > 1 && (info_window->size.h - sy > 52)) {
791 struct advanced_dialog *dlg = info_window->private_data.adv_dlg;
792 struct widget *buf = NULL, *end = NULL, *dock;
793 struct city *home_city;
794 const struct unit_type *putype;
795 int num_w, num_h;
796
797 if (dlg->end_active_widget_list && dlg->begin_active_widget_list) {
798 del_group(dlg->begin_active_widget_list, dlg->end_active_widget_list);
799 }
800 num_w = (info_window->area.w - BLOCKU_W) / 68;
801 num_h = (info_window->area.h - sy) / 52;
802 dock = info_window;
803 n = 0;
804
805 unit_list_iterate(ptile->units, aunit) {
806 SDL_Surface *tmp_surf;
807 struct astring addition = ASTRING_INIT;
808
809 if (aunit == punit) {
810 continue;
811 }
812
813 putype = unit_type_get(aunit);
814 vetname = utype_veteran_name_translation(putype, aunit->veteran);
815 home_city = game_city_by_number(aunit->homecity);
816 unit_activity_astr(aunit, &addition);
817 fc_snprintf(buffer, sizeof(buffer),
818 "%s (%d,%d,%s)%s%s\n%s\n(%d/%d)\n%s",
819 utype_name_translation(putype),
820 putype->attack_strength,
821 putype->defense_strength,
822 move_points_text(putype->move_rate, FALSE),
823 (vetname != NULL ? "\n" : ""),
824 (vetname != NULL ? vetname : ""),
825 astr_str(&addition),
826 aunit->hp, putype->hp,
827 home_city ? city_name_get(home_city) : Q_("?homecity:None"));
828 astr_free(&addition);
829
830 buf_surf = create_surf(tileset_full_tile_width(tileset),
831 tileset_full_tile_height(tileset),
832 SDL_SWSURFACE);
833
834 destcanvas = canvas_create(tileset_full_tile_width(tileset),
835 tileset_full_tile_height(tileset));
836
837 put_unit(aunit, destcanvas, 1.0, 0, 0);
838
839 tmp_surf = adj_surf(destcanvas->surf);
840
841 alphablit(tmp_surf, NULL, buf_surf, NULL, 255);
842
843 FREESURFACE(tmp_surf);
844 canvas_free(destcanvas);
845
846 if (buf_surf->w > 64) {
847 float zoom = 64.0 / buf_surf->w;
848 SDL_Surface *zoomed = zoomSurface(buf_surf, zoom, zoom, 1);
849
850 FREESURFACE(buf_surf);
851 buf_surf = zoomed;
852 }
853
854 pstr = create_utf8_from_char(buffer, 10);
855 pstr->style |= SF_CENTER;
856
857 buf = create_icon2(buf_surf, info_window->dst,
858 WF_FREE_THEME | WF_RESTORE_BACKGROUND
859 | WF_WIDGET_HAS_INFO_LABEL);
860 buf->info_label = pstr;
861 buf->data.unit = aunit;
862 buf->id = ID_ICON;
863 widget_add_as_prev(buf, dock);
864 dock = buf;
865
866 if (!end) {
867 end = buf;
868 }
869
870 if (++n > num_w * num_h) {
871 set_wflag(buf, WF_HIDDEN);
872 }
873
874 if (unit_owner(aunit) == client.conn.playing) {
875 set_wstate(buf, FC_WS_NORMAL);
876 }
877
878 buf->action = focus_units_info_callback;
879
880 } unit_list_iterate_end;
881
882 dlg->begin_active_widget_list = buf;
883 dlg->end_active_widget_list = end;
884 dlg->active_widget_list = dlg->end_active_widget_list;
885
886 if (n > num_w * num_h) {
887 if (!dlg->scroll) {
888 create_vertical_scrollbar(dlg, num_w, num_h, FALSE, TRUE);
889 } else {
890 dlg->scroll->active = num_h;
891 dlg->scroll->step = num_w;
892 dlg->scroll->count = n;
893 show_scrollbar(dlg->scroll);
894 }
895
896 /* create up button */
897 buf = dlg->scroll->up_left_button;
898 buf->size.x = info_window->area.x + info_window->area.w - buf->size.w;
899 buf->size.y = info_window->area.y + sy +
900 (info_window->size.h - sy - num_h * 52) / 2;
901 buf->size.h = (num_h * 52) / 2;
902
903 /* create down button */
904 buf = dlg->scroll->down_right_button;
905 buf->size.x = dlg->scroll->up_left_button->size.x;
906 buf->size.y = dlg->scroll->up_left_button->size.y +
907 dlg->scroll->up_left_button->size.h;
908 buf->size.h = dlg->scroll->up_left_button->size.h;
909 } else {
910 if (dlg->scroll) {
911 hide_scrollbar(dlg->scroll);
912 }
913 num_h = (n + num_w - 1) / num_w;
914 }
915
916 setup_vertical_widgets_position(num_w,
917 info_window->area.x + BLOCKU_W + adj_size(2),
918 info_window->size.y + sy +
919 (info_window->size.h - sy - num_h * 52) / 2,
920 0, 0, dlg->begin_active_widget_list,
921 dlg->end_active_widget_list);
922 } else {
923 if (info_window->private_data.adv_dlg->end_active_widget_list) {
924 del_group(info_window->private_data.adv_dlg->begin_active_widget_list,
925 info_window->private_data.adv_dlg->end_active_widget_list);
926 }
927 if (info_window->private_data.adv_dlg->scroll) {
928 hide_scrollbar(info_window->private_data.adv_dlg->scroll);
929 }
930 }
931 } else { /* punit */
932
933 if (info_window->private_data.adv_dlg->end_active_widget_list) {
934 del_group(info_window->private_data.adv_dlg->begin_active_widget_list,
935 info_window->private_data.adv_dlg->end_active_widget_list);
936 }
937 if (info_window->private_data.adv_dlg->scroll) {
938 hide_scrollbar(info_window->private_data.adv_dlg->scroll);
939 }
940
941 if (!client_is_observer() && !client.conn.playing->phase_done
942 && (is_human(client.conn.playing)
943 || gui_options.ai_manual_turn_done)) {
944 char buf[256];
945
946 fc_snprintf(buf, sizeof(buf), "%s\n%s\n%s",
947 _("End of Turn"), _("Press"), _("Shift+Return"));
948 pstr = create_utf8_from_char_fonto(buf, FONTO_HEADING);
949 pstr->style = SF_CENTER;
950 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
951 buf_surf = create_text_surf_from_utf8(pstr);
952 area.x = info_window->size.x + BLOCKU_W +
953 (info_window->size.w - BLOCKU_W - buf_surf->w) / 2;
954 area.y = info_window->size.y + (info_window->size.h - buf_surf->h) / 2;
955 alphablit(buf_surf, NULL, info_window->dst->surface, &area, 255);
956 FREESURFACE(buf_surf);
957 FREEUTF8STR(pstr);
958 /* Fix the bug of child dialogs not showing up when player's turn ends */
959 flush_all();
960 }
961 }
962
963 /* Draw buttons */
964 redraw_group(info_window->private_data.adv_dlg->begin_widget_list,
965 info_window->private_data.adv_dlg->end_widget_list->prev, 0);
966
967 widget_mark_dirty(info_window);
968 }
969}
970
971/**********************************************************************/
974 static bool is_focus_anim_enabled(void)
975{
976 return (sdl2_client_flags & CF_FOCUS_ANIMATION) == CF_FOCUS_ANIMATION;
977}
978
979/**********************************************************************/
985 void set_unit_icon(int idx, struct unit *punit)
986{
987 /* FIXME */
988 /* update_unit_info_label(punit);*/
989}
990
991/**********************************************************************/
996 void set_unit_icons_more_arrow(bool onoff)
997{
998/* Balast */
999}
1000
1001/**********************************************************************/
1006 void real_focus_units_changed(void)
1007{
1008 /* Nothing to do */
1009}
1010
1011/**********************************************************************/
1023 void update_unit_info_label(struct unit_list *punitlist)
1024{
1025 if (C_S_RUNNING != client_state()) {
1026 return;
1027 }
1028
1029 /* draw unit info window */
1030 redraw_unit_info_label(punitlist);
1031
1032 if (punitlist) {
1033 if (!is_focus_anim_enabled()) {
1034 enable_focus_animation();
1035 }
1036 } else {
1037 disable_focus_animation();
1038 }
1039}
1040
1041/**********************************************************************/
1044 void update_timeout_label(void)
1045{
1046 log_debug("MAPVIEW: update_timeout_label : PORT ME");
1047}
1048
1049/**********************************************************************/
1052 void update_turn_done_button(bool do_restore)
1053{
1054 log_debug("MAPVIEW: update_turn_done_button : PORT ME");
1055}
1056
1057/* ===================================================================== */
1058/* ========================== City Descriptions ======================== */
1059/* ===================================================================== */
1060
1061/**********************************************************************/
1064 void update_city_descriptions(void)
1065{
1066 /* redraw buffer */
1067 show_city_descriptions(0, 0, mapview.store_width, mapview.store_height);
1068 dirty_all();
1069}
1070
1071/* ===================================================================== */
1072/* =============================== Mini Map ============================ */
1073/* ===================================================================== */
1074
1075/**********************************************************************/
1078 struct canvas *get_overview_window(void)
1079{
1080 return overview_canvas;
1081}
1082
1083/**********************************************************************/
1087 void get_overview_area_dimensions(int *width, int *height)
1088{
1089 /* calculate the dimensions in a way to always get a resulting
1090 overview with a height bigger than or equal to DEFAULT_OVERVIEW_H.
1091 First, the default dimensions are fed to the same formula that
1092 is used in overview_common.c. If the resulting height is
1093 smaller than DEFAULT_OVERVIEW_H, increase OVERVIEW_TILE_SIZE
1094 by 1 until the height condition is met.
1095 */
1096 int overview_tile_size_bak = OVERVIEW_TILE_SIZE;
1097 int xfact = MAP_IS_ISOMETRIC ? 2 : 1;
1098 int shift = (MAP_IS_ISOMETRIC && !current_topo_has_flag(TF_WRAPX)) ? -1 : 0;
1099
1100 OVERVIEW_TILE_SIZE = MIN((DEFAULT_OVERVIEW_W - 1) / (wld.map.xsize * xfact),
1101 (DEFAULT_OVERVIEW_H - 1) / wld.map.ysize) + 1;
1102
1103 do {
1104 *height = OVERVIEW_TILE_HEIGHT * wld.map.ysize;
1105 if (*height < DEFAULT_OVERVIEW_H) {
1106 OVERVIEW_TILE_SIZE++;
1107 }
1108 } while (*height < DEFAULT_OVERVIEW_H);
1109
1110 *width = OVERVIEW_TILE_WIDTH * wld.map.xsize + shift * OVERVIEW_TILE_SIZE;
1111
1112 OVERVIEW_TILE_SIZE = overview_tile_size_bak;
1113}
1114
1115/**********************************************************************/
1119 void refresh_overview(void)
1120{
1121 struct widget *minimap;
1122 SDL_Rect overview_area;
1123
1124 if (sdl2_client_flags & CF_OVERVIEW_SHOWN) {
1125 minimap = get_minimap_window_widget();
1126
1127 overview_area = (SDL_Rect) {
1128 minimap->area.x + overview_start_x, minimap->area.x + overview_start_y,
1129 overview_canvas->surf->w, overview_canvas->surf->h
1130 };
1131
1132 alphablit(overview_canvas->surf, NULL, minimap->dst->surface,
1133 &overview_area, 255);
1134
1135 widget_mark_dirty(minimap);
1136 }
1137}
1138
1139/**********************************************************************/
1143 void update_map_canvas_scrollbars(void)
1144{
1145 /* No scrollbars. */
1146}
1147
1148/**********************************************************************/
1151 void put_cross_overlay_tile(struct tile *ptile)
1152{
1153 log_debug("MAPVIEW: put_cross_overlay_tile : PORT ME");
1154}
1155
1156/**********************************************************************/
1159 void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
1160{
1161 /* PORTME */
1162 create_frame(main_data.map,
1163 canvas_x, canvas_y, w, h,
1164 get_theme_color(COLOR_THEME_SELECTIONRECTANGLE));
1165}
1166
1167/**********************************************************************/
1170 void tileset_changed(void)
1171{
1172 /* PORTME */
1173 /* Here you should do any necessary redraws (for instance, the city
1174 * dialogs usually need to be resized). */
1175 popdown_all_game_dialogs();
1176}
1177
1178/* =====================================================================
1179 City MAP
1180 ===================================================================== */
1181
1182/**********************************************************************/
1185 void city_map_canvas_free(void)
1186{
1187 if (city_map_canvas != NULL) {
1188 canvas_free(city_map_canvas);
1189 city_map_canvas = NULL;
1190 }
1191}
1192
1193/**********************************************************************/
1196 SDL_Surface *create_city_map(struct city *pcity)
1197{
1198 /* City map dimensions might have changed, so create a new canvas each time */
1199 city_map_canvas_free();
1200
1201 city_map_canvas = canvas_create(get_citydlg_canvas_width(),
1202 get_citydlg_canvas_height());
1203
1204 city_dialog_redraw_map(pcity, city_map_canvas);
1205
1206 return city_map_canvas->surf;
1207}
1208
1209/**********************************************************************/
1212 SDL_Surface *get_terrain_surface(struct tile *ptile)
1213{
1214 /* Tileset dimensions might have changed, so create a new canvas each time */
1215
1216 if (terrain_canvas) {
1217 canvas_free(terrain_canvas);
1218 }
1219
1220 terrain_canvas = canvas_create(tileset_full_tile_width(tileset),
1221 tileset_full_tile_height(tileset));
1222
1223 put_terrain(ptile, terrain_canvas, 1.0, 0, 0);
1224
1225 return terrain_canvas->surf;
1226}
1227
1228/**********************************************************************/
1231 void update_overview_scroll_window_pos(int x, int y)
1232{
1233 /* TODO: PORTME. */
1234}
1235
1236/**********************************************************************/
1239 void start_turn(void)
1240{}
1241
1242/**********************************************************************/
1245 void map_canvas_size_refresh(void)
1246{
1247 /* Needed only with full screen zoom mode.
1248 * Not needed, nor implemented, in this client. */
1249 fc_assert(FALSE);
1250}
astr_free
void astr_free(struct astring *astr)
Definition astring.c:153
n
#define n
Definition astring.c:77
astring.h
astr_str
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
ASTRING_INIT
#define ASTRING_INIT
Definition astring.h:44
bugreport_request
void bugreport_request(const char *reason_format,...)
Definition bugs.c:31
bugs.h
calendar_text
const char * calendar_text(void)
Definition calendar.c:141
calendar.h
height
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
canvas_y
struct canvas int int canvas_y
Definition canvas_g.h:43
canvas_x
struct canvas int canvas_x
Definition canvas_g.h:43
width
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
city_name_get
const char * city_name_get(const struct city *pcity)
Definition city.c:1106
city_owner
#define city_owner(_pcity_)
Definition city.h:543
get_citydlg_canvas_width
int get_citydlg_canvas_width(void)
Definition citydlg_common.c:51
city_dialog_redraw_map
void city_dialog_redraw_map(struct city *pcity, struct canvas *pcanvas)
Definition citydlg_common.c:187
get_citydlg_canvas_height
int get_citydlg_canvas_height(void)
Definition citydlg_common.c:59
citydlg_common.h
client_is_observer
bool client_is_observer(void)
Definition client_main.c:1086
client
struct civclient client
Definition client_main.c:149
client_state
enum client_states client_state(void)
Definition client_main.c:1029
client_main.h
client_player
#define client_player()
Definition client_main.h:106
C_S_RUNNING
@ C_S_RUNNING
Definition client_main.h:47
client_warming_sprite
struct sprite * client_warming_sprite(void)
Definition climisc.c:371
client_cooling_sprite
struct sprite * client_cooling_sprite(void)
Definition climisc.c:388
client_research_sprite
struct sprite * client_research_sprite(void)
Definition climisc.c:348
client_government_sprite
struct sprite * client_government_sprite(void)
Definition climisc.c:406
climisc.h
unit_focus_set
void unit_focus_set(struct unit *punit)
Definition control.c:502
request_new_unit_activity
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1828
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
get_city_bonus
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:789
O_GOLD
@ O_GOLD
Definition fc_types.h:91
BORDERS_DISABLED
@ BORDERS_DISABLED
Definition fc_types.h:891
fcintl.h
Q_
#define Q_(String)
Definition fcintl.h:70
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#define _(String)
Definition fcintl.h:67
population_to_text
const char * population_to_text(int thousand_citizen)
Definition game.c:714
game
struct civ_game game
Definition game.c:57
wld
struct world wld
Definition game.c:58
civ_population
int civ_population(const struct player *pplayer)
Definition game.c:69
game_city_by_number
struct city * game_city_by_number(int id)
Definition game.c:102
game.h
goto.h
government_name_for_player
const char * government_name_for_player(const struct player *pplayer)
Definition government.c:153
government.h
canvas_free
void canvas_free(struct canvas *store)
Definition canvas.c:44
canvas_create
struct canvas * canvas_create(int width, int height)
Definition canvas.c:28
owner
struct city * owner
Definition citydlg.c:219
popdown_all_game_dialogs
void popdown_all_game_dialogs(void)
Definition dialogs.c:1523
overview_canvas
GtkWidget * overview_canvas
Definition gui_main.c:110
update_timeout_label
void update_timeout_label(void)
Definition mapview.c:101
flush_dirty
void flush_dirty(void)
Definition mapview.c:450
update_info_label
void update_info_label(void)
Definition mapview.c:121
update_turn_done_button
void update_turn_done_button(bool do_restore)
Definition mapview.c:75
dirty_all
void dirty_all(void)
Definition mapview.c:438
tileset_changed
void tileset_changed(void)
Definition mapview.c:764
put_cross_overlay_tile
void put_cross_overlay_tile(struct tile *ptile)
Definition mapview.c:622
draw_selection_rectangle
void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
Definition mapview.c:728
update_map_canvas_scrollbars_size
void update_map_canvas_scrollbars_size(void)
Definition mapview.c:675
get_overview_area_dimensions
void get_overview_area_dimensions(int *width, int *height)
Definition mapview.c:300
start_turn
void start_turn(void)
Definition mapview.c:787
update_unit_info_label
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:258
update_overview_scroll_window_pos
void update_overview_scroll_window_pos(int x, int y)
Definition mapview.c:636
update_city_descriptions
void update_city_descriptions(void)
Definition mapview.c:470
gui_flush
void gui_flush(void)
Definition mapview.c:462
update_map_canvas_scrollbars
void update_map_canvas_scrollbars(void)
Definition mapview.c:660
overview_size_changed
void overview_size_changed(void)
Definition mapview.c:309
map_canvas_size_refresh
void map_canvas_size_refresh(void)
Definition mapview.c:397
get_overview_window
struct canvas * get_overview_window(void)
Definition mapview.c:320
set_indicator_icons
void set_indicator_icons(struct sprite *bulb, struct sprite *sol, struct sprite *flake, struct sprite *gov)
Definition mapview.c:285
get_current_client_page
enum client_pages get_current_client_page(void)
Definition pages.c:3329
get_theme_color
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:44
sdl_get_tile_defense_info_text
const char * sdl_get_tile_defense_info_text(struct tile *ptile)
Definition dialogs.c:1303
main_window_width
int main_window_width(void)
Definition graphics.c:685
update_main_screen
void update_main_screen(void)
Definition graphics.c:669
create_line
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
Definition graphics.c:1378
alphablit
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
screen_blit
int screen_blit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:223
main_data
struct sdl2_data main_data
Definition graphics.c:57
blit_entire_src
int blit_entire_src(SDL_Surface *psrc, SDL_Surface *pdest, Sint16 dest_x, Sint16 dest_y)
Definition graphics.c:417
create_surf
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
correct_rect_region
bool correct_rect_region(SDL_Rect *prect)
Definition graphics.c:888
screen_rect_to_layer_rect
void screen_rect_to_layer_rect(struct gui_layer *gui_layer, SDL_Rect *dest_rect)
Definition graphics.c:173
create_frame
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1347
main_window_height
int main_window_height(void)
Definition graphics.c:693
resize_surface_box
SDL_Surface * resize_surface_box(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth, bool scale_up, bool absolute_dimensions)
Definition graphics.c:1256
FREESURFACE
#define FREESURFACE(ptr)
Definition graphics.h:322
RECT_LIMIT
#define RECT_LIMIT
Definition graphics.h:45
adj_surf
#define adj_surf(surf)
Definition graphics.h:200
map_rgba
#define map_rgba(format, color)
Definition graphics.h:315
enable_focus_animation
void enable_focus_animation(void)
Definition gui_main.c:1177
flush_event
bool flush_event(void)
Definition gui_main.c:1321
disable_focus_animation
void disable_focus_animation(void)
Definition gui_main.c:1186
sdl2_client_flags
Uint32 sdl2_client_flags
Definition gui_main.c:97
CF_FOCUS_ANIMATION
#define CF_FOCUS_ANIMATION
Definition gui_main.h:48
CF_OVERVIEW_SHOWN
#define CF_OVERVIEW_SHOWN
Definition gui_main.h:45
adj_size
#define adj_size(size)
Definition gui_main.h:138
PRESSED_EVENT
#define PRESSED_EVENT(event)
Definition gui_main.h:68
CF_UNITINFO_SHOWN
#define CF_UNITINFO_SHOWN
Definition gui_main.h:44
get_minimap_window_widget
struct widget * get_minimap_window_widget(void)
Definition mapctrl.c:2203
get_research_widget
struct widget * get_research_widget(void)
Definition mapctrl.c:2219
resize_minimap
int resize_minimap(void)
Definition mapctrl.c:554
get_unit_info_window_widget
struct widget * get_unit_info_window_widget(void)
Definition mapctrl.c:2195
get_revolution_widget
struct widget * get_revolution_widget(void)
Definition mapctrl.c:2227
get_tax_rates_widget
struct widget * get_tax_rates_widget(void)
Definition mapctrl.c:2211
DEFAULT_UNITS_W
#define DEFAULT_UNITS_W
Definition mapctrl.h:55
DEFAULT_UNITS_H
#define DEFAULT_UNITS_H
Definition mapctrl.h:56
BLOCKU_W
#define BLOCKU_W
Definition mapctrl.h:52
DEFAULT_OVERVIEW_W
#define DEFAULT_OVERVIEW_W
Definition mapctrl.h:53
DEFAULT_OVERVIEW_H
#define DEFAULT_OVERVIEW_H
Definition mapctrl.h:54
real_focus_units_changed
void real_focus_units_changed(void)
Definition mapview.c:1006
set_unit_icons_more_arrow
void set_unit_icons_more_arrow(bool onoff)
Definition mapview.c:996
set_unit_icon
void set_unit_icon(int idx, struct unit *punit)
Definition mapview.c:985
is_focus_anim_enabled
static bool is_focus_anim_enabled(void)
Definition mapview.c:974
create_city_map
SDL_Surface * create_city_map(struct city *pcity)
Definition mapview.c:1196
flush_mapcanvas
static void flush_mapcanvas(int canvas_x, int canvas_y, int pixel_width, int pixel_height)
Definition mapview.c:92
refresh_overview
void refresh_overview(void)
Definition mapview.c:1119
is_flush_queued
static bool is_flush_queued
Definition mapview.c:87
flush_rect
void flush_rect(SDL_Rect *rect, bool force_flush)
Definition mapview.c:103
get_terrain_surface
SDL_Surface * get_terrain_surface(struct tile *ptile)
Definition mapview.c:1212
dirty_sdl_rect
void dirty_sdl_rect(SDL_Rect *Rect)
Definition mapview.c:181
queue_flush
void queue_flush(void)
Definition mapview.c:152
focus_units_info_callback
static int focus_units_info_callback(struct widget *pwidget)
Definition mapview.c:499
info_area
SDL_Rect * info_area
Definition widget.c:49
redraw_unit_info_label
void redraw_unit_info_label(struct unit_list *punitlist)
Definition mapview.c:517
overview_start_x
int overview_start_x
Definition mapview.c:73
unqueue_flush
void unqueue_flush(void)
Definition mapview.c:140
terrain_canvas
static struct canvas * terrain_canvas
Definition mapview.c:78
city_map_canvas_free
void city_map_canvas_free(void)
Definition mapview.c:1185
overview_start_y
int overview_start_y
Definition mapview.c:74
flush_all
void flush_all(void)
Definition mapview.c:201
GET_SURF
#define GET_SURF(m_sprite)
Definition sprite.h:29
colors.h
dialogs.h
graphics.h
gui_main.h
mapctrl.h
mapview.h
sprite.h
gui_id.h
ID_COOLING_ICON
@ ID_COOLING_ICON
Definition gui_id.h:139
ID_WARMING_ICON
@ ID_WARMING_ICON
Definition gui_id.h:140
ID_ICON
@ ID_ICON
Definition gui_id.h:33
draw_mouse_cursor
void draw_mouse_cursor(void)
Definition gui_mouse.c:100
gui_mouse.h
copy_chars_to_utf8_str
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
create_text_surf_from_utf8
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
change_fonto_utf8
void change_fonto_utf8(utf8_str *pstr, enum font_origin origin)
Definition gui_string.c:584
create_utf8_str_fonto
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
Definition gui_string.c:241
create_text_surf_smaller_than_w
SDL_Surface * create_text_surf_smaller_than_w(utf8_str *pstr, int w)
Definition gui_string.c:539
create_utf8_from_char
#define create_utf8_from_char(string_in, ptsize)
Definition gui_string.h:102
FREEUTF8STR
#define FREEUTF8STR(pstr)
Definition gui_string.h:92
SF_CENTER
#define SF_CENTER
Definition gui_string.h:40
FONTO_HEADING
@ FONTO_HEADING
Definition gui_string.h:68
FONTO_DEFAULT
@ FONTO_DEFAULT
Definition gui_string.h:64
FONTO_ATTENTION
@ FONTO_ATTENTION
Definition gui_string.h:66
create_utf8_from_char_fonto
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:107
gui_tilespec.h
get_tax_surface
static SDL_Surface * get_tax_surface(Output_type_id otype)
Definition gui_tilespec.h:269
get_unittype_surface
static SDL_Surface * get_unittype_surface(const struct unit_type *punittype, enum direction8 facing)
Definition gui_tilespec.h:260
name
const char * name
Definition inputfile.c:127
log.h
fc_assert
#define fc_assert(condition)
Definition log.h:176
log_debug
#define log_debug(message,...)
Definition log.h:115
current_topo_has_flag
#define current_topo_has_flag(flag)
Definition map.h:45
MAP_IS_ISOMETRIC
#define MAP_IS_ISOMETRIC
Definition map.h:40
redraw_selection_rectangle
void redraw_selection_rectangle(void)
Definition mapctrl_common.c:278
put_terrain
void put_terrain(struct tile *ptile, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
Definition mapview_common.c:1420
mapview
struct view mapview
Definition mapview_common.c:74
put_unit
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
Definition mapview_common.c:1374
show_city_descriptions
void show_city_descriptions(int canvas_base_x, int canvas_base_y, int width_base, int height_base)
Definition mapview_common.c:2345
map_canvas_resized
bool map_canvas_resized(int width, int height)
Definition mapview_common.c:3592
dirty_rect
dirty_rect
Definition mapview_g.h:47
pixel_width
int int int pixel_width
Definition mapview_g.h:48
move_points_text
const char * move_points_text(int mp, bool reduce)
Definition movement.c:973
movement.h
nation_adjective_for_player
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:168
nation_plural_for_player
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:177
gui_options
struct client_options gui_options
Definition options.c:71
OVERVIEW_TILE_SIZE
int OVERVIEW_TILE_SIZE
Definition overview_common.c:33
overview_common.h
OVERVIEW_TILE_WIDTH
#define OVERVIEW_TILE_WIDTH
Definition overview_common.h:32
OVERVIEW_TILE_HEIGHT
#define OVERVIEW_TILE_HEIGHT
Definition overview_common.h:33
pages_g.h
get_client_page
enum client_pages get_client_page(void)
Definition update_queue.c:520
player_diplstate_get
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:317
pplayers_allied
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1381
is_human
#define is_human(plr)
Definition player.h:233
research_advance_name_translation
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:271
research_get
struct research * research_get(const struct player *pplayer)
Definition research.c:126
research.h
MIN
#define MIN(x, y)
Definition shared.h:55
advanced_dialog
Definition widget.h:180
advanced_dialog::active_widget_list
struct widget * active_widget_list
Definition widget.h:186
advanced_dialog::end_widget_list
struct widget * end_widget_list
Definition widget.h:182
advanced_dialog::begin_widget_list
struct widget * begin_widget_list
Definition widget.h:181
advanced_dialog::begin_active_widget_list
struct widget * begin_active_widget_list
Definition widget.h:184
advanced_dialog::end_active_widget_list
struct widget * end_active_widget_list
Definition widget.h:185
advanced_dialog::scroll
struct scroll_bar * scroll
Definition widget.h:187
astring
Definition astring.h:36
canvas
Definition canvas.h:21
canvas::surf
SDL_Surface * surf
Definition canvas.h:27
city_map_canvas
Definition citydlg.c:130
city
Definition city.h:309
civ_game::info
struct packet_game_info info
Definition game.h:89
civ_map::xsize
int xsize
Definition map_types.h:77
civ_map::ysize
int ysize
Definition map_types.h:77
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::overview
struct overview overview
Definition options.h:402
client_options::ai_manual_turn_done
bool ai_manual_turn_done
Definition options.h:147
connection::playing
struct player * playing
Definition connection.h:156
gui_layer::surface
SDL_Surface * surface
Definition graphics.h:229
gui_layer::dest_rect
SDL_Rect dest_rect
Definition graphics.h:228
overview::width
int width
Definition options.h:93
overview::height
int height
Definition options.h:93
packet_game_info::borders
enum borders_mode borders
Definition packets_gen.h:133
player_diplstate
Definition player.h:200
player_diplstate::turns_left
char turns_left
Definition player.h:204
player_diplstate::type
enum diplstate_type type
Definition player.h:201
player_economic::luxury
int luxury
Definition player.h:73
player_economic::science
int science
Definition player.h:72
player_economic::tax
int tax
Definition player.h:71
player_economic::gold
int gold
Definition player.h:70
player
Definition player.h:249
player::economic
struct player_economic economic
Definition player.h:284
player::phase_done
bool phase_done
Definition player.h:263
research
Definition research.h:39
research::researching
Tech_type_id researching
Definition research.h:52
research::client
struct research::@75::@77 client
research::researching_cost
int researching_cost
Definition research.h:98
research::bulbs_researched
int bulbs_researched
Definition research.h:53
scroll_bar::up_left_button
struct widget * up_left_button
Definition widget_scrollbar.h:21
scroll_bar::active
Uint8 active
Definition widget_scrollbar.h:24
scroll_bar::step
Uint8 step
Definition widget_scrollbar.h:25
scroll_bar::count
Uint16 count
Definition widget_scrollbar.h:27
scroll_bar::down_right_button
struct widget * down_right_button
Definition widget_scrollbar.h:23
sdl2_data::guis_count
int guis_count
Definition graphics.h:207
sdl2_data::gui
struct gui_layer * gui
Definition graphics.h:215
sdl2_data::rects_count
int rects_count
Definition graphics.h:206
sdl2_data::event
SDL_Event event
Definition graphics.h:217
sdl2_data::rects
SDL_Rect rects[RECT_LIMIT]
Definition graphics.h:208
sdl2_data::guis
struct gui_layer ** guis
Definition graphics.h:216
sdl2_data::screen
SDL_Window * screen
Definition graphics.h:209
sdl2_data::map
SDL_Surface * map
Definition graphics.h:210
sprite
Definition sprite.h:22
tile
Definition tile.h:49
tile::units
struct unit_list * units
Definition tile.h:57
tileset
Definition tilespec.c:459
unit_type
Definition unittype.h:481
unit_type::defense_strength
int defense_strength
Definition unittype.h:496
unit_type::veteran
struct veteran_system * veteran
Definition unittype.h:525
unit_type::move_rate
int move_rate
Definition unittype.h:497
unit_type::hp
int hp
Definition unittype.h:505
unit_type::attack_strength
int attack_strength
Definition unittype.h:495
unit
Definition unit.h:138
unit::facing
enum direction8 facing
Definition unit.h:142
unit::veteran
int veteran
Definition unit.h:152
utf8_str
Definition gui_string.h:52
utf8_str::style
Uint8 style
Definition gui_string.h:53
utf8_str::bgcol
SDL_Color bgcol
Definition gui_string.h:58
utf8_str::fgcol
SDL_Color fgcol
Definition gui_string.h:57
utf8_str::font
TTF_Font * font
Definition gui_string.h:59
view::store_width
int store_width
Definition mapview_common.h:40
view::store_height
int store_height
Definition mapview_common.h:40
view::store
struct canvas * store
Definition mapview_common.h:42
widget
Definition widget.h:112
widget::info_label
utf8_str * info_label
Definition widget.h:122
widget::data
union widget::@214 data
widget::dst
struct gui_layer * dst
Definition widget.h:116
widget::prev
struct widget * prev
Definition widget.h:114
widget::action
int(* action)(struct widget *)
Definition widget.h:157
widget::unit
struct unit * unit
Definition widget.h:129
widget::cont
struct container * cont
Definition widget.h:127
widget::private_data
union widget::@215 private_data
widget::adv_dlg
struct advanced_dialog * adv_dlg
Definition widget.h:139
widget::string_utf8
utf8_str * string_utf8
Definition widget.h:121
widget::area
SDL_Rect area
Definition widget.h:149
widget::id
Uint16 id
Definition widget.h:155
widget::size
SDL_Rect size
Definition widget.h:145
world::map
struct civ_map map
Definition world_object.h:38
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
cat_snprintf
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:995
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
A_UNSET
#define A_UNSET
Definition tech.h:48
get_tile_output_text
const char * get_tile_output_text(const struct tile *ptile)
Definition text.c:62
get_unit_info_label_text2
const char * get_unit_info_label_text2(struct unit_list *punits, int linebreaks)
Definition text.c:1112
text.h
COLOR_THEME_MAPVIEW_UNITINFO_VETERAN_TEXT
@ COLOR_THEME_MAPVIEW_UNITINFO_VETERAN_TEXT
Definition themecolors.h:96
COLOR_THEME_MAPVIEW_INFO_TEXT
@ COLOR_THEME_MAPVIEW_INFO_TEXT
Definition themecolors.h:94
COLOR_THEME_MAPVIEW_INFO_FRAME
@ COLOR_THEME_MAPVIEW_INFO_FRAME
Definition themecolors.h:93
COLOR_THEME_SELECTIONRECTANGLE
@ COLOR_THEME_SELECTIONRECTANGLE
Definition themecolors.h:36
COLOR_THEME_MAPVIEW_UNITINFO_TEXT
@ COLOR_THEME_MAPVIEW_UNITINFO_TEXT
Definition themecolors.h:95
themespec.h
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
TILE_LB_RESOURCE_POLL
#define TILE_LB_RESOURCE_POLL
Definition tile.h:176
tile_owner
#define tile_owner(_tile)
Definition tile.h:95
tileset_full_tile_height
int tileset_full_tile_height(const struct tileset *t)
Definition tilespec.c:752
tileset_full_tile_width
int tileset_full_tile_width(const struct tileset *t)
Definition tilespec.c:739
unit_activity_astr
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1171
unit_tile
#define unit_tile(_pu)
Definition unit.h:388
unit_owner
#define unit_owner(_pu)
Definition unit.h:387
unitlist.h
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33
utype_veteran_name_translation
const char * utype_veteran_name_translation(const struct unit_type *punittype, int level)
Definition unittype.c:2646
unit_type_get
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
unit_name_translation
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1621
utype_name_translation
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
redraw_widget_info_label
void redraw_widget_info_label(SDL_Rect *rect)
Definition widget.c:466
get_widget_pointer_from_main_list
struct widget * get_widget_pointer_from_main_list(Uint16 id)
Definition widget.c:577
widget_add_as_prev
void widget_add_as_prev(struct widget *new_widget, struct widget *add_dock)
Definition widget.c:601
setup_vertical_widgets_position
int setup_vertical_widgets_position(int step, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h, struct widget *begin, struct widget *end)
Definition widget.c:1050
redraw_group
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:719
widget.h
FC_WS_NORMAL
@ FC_WS_NORMAL
Definition widget.h:96
widget_mark_dirty
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
set_wstate
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
WF_WIDGET_HAS_INFO_LABEL
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
WF_RESTORE_BACKGROUND
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
WF_HIDDEN
@ WF_HIDDEN
Definition widget.h:68
WF_FREE_THEME
@ WF_FREE_THEME
Definition widget.h:72
widget_redraw
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
set_wflag
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
del_group
#define del_group(begin_group_widget_list, end_group_widget_list)
Definition widget.h:389
create_icon2
struct widget * create_icon2(SDL_Surface *icon, struct gui_layer *pdest, Uint32 flags)
Definition widget_icon.c:333
set_new_icon2_theme
void set_new_icon2_theme(struct widget *icon_widget, SDL_Surface *new_theme, bool free_old_theme)
Definition widget_icon.c:317
create_vertical_scrollbar
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
Definition widget_scrollbar.c:491
hide_scrollbar
#define hide_scrollbar(scrollbar)
Definition widget_scrollbar.h:36
show_scrollbar
#define show_scrollbar(scrollbar)
Definition widget_scrollbar.h:59