Freeciv-3.2
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/* SDL3 */
27#include <SDL3/SDL.h>
28
29/* utility */
30#include "astring.h"
31#include "bugs.h"
32#include "fcintl.h"
33#include "log.h"
34
35/* common */
36#include "calendar.h"
37#include "game.h"
38#include "goto.h"
39#include "government.h"
40#include "movement.h"
41#include "research.h"
42#include "unitlist.h"
43
44/* client */
45#include "citydlg_common.h"
46#include "client_main.h"
47#include "climisc.h"
48#include "overview_common.h"
49#include "pages_g.h"
50#include "text.h"
51
52/* gui-sdl3 */
53#include "colors.h"
54#include "dialogs.h"
55#include "graphics.h"
56#include "gui_id.h"
57#include "gui_main.h"
58#include "gui_mouse.h"
59#include "gui_tilespec.h"
60#include "mapctrl.h"
61#include "sprite.h"
62#include "themespec.h"
63#include "widget.h"
64
65#include "mapview.h"
66
67extern SDL_Rect *info_area;
68
71
72static struct canvas *overview_canvas;
73static struct canvas *city_map_canvas = NULL;
74static struct canvas *terrain_canvas;
75
76/* ================================================================ */
77
79{
80 /* No scrollbars */
81}
82
83static bool is_flush_queued = FALSE;
84
85/**********************************************************************/
88static void flush_mapcanvas(int canvas_x, int canvas_y,
90{
92
93 alphablit(mapview.store->surf, &rect, main_data.map, &rect, 255);
94}
95
96/**********************************************************************/
100{
102 dirty_sdl_rect(rect);
103 } else {
104 static SDL_Rect src, dst;
105
106 if (correct_rect_region(rect)) {
107 static int i = 0;
108
109 dst = *rect;
110 if (C_S_RUNNING == client_state()) {
111 flush_mapcanvas(dst.x, dst.y, dst.w, dst.h);
112 }
113 screen_blit(main_data.map, rect, &dst, 255);
114 if (main_data.guis) {
115 while ((i < main_data.guis_count) && main_data.guis[i]) {
116 src = *rect;
118 dst = *rect;
119 screen_blit(main_data.guis[i++]->surface, &src, &dst, 255);
120 }
121 }
122 i = 0;
123
124 /* flush main buffer to framebuffer */
125#if 0
126 SDL_UpdateRect(main_data.screen, rect->x, rect->y, rect->w, rect->h);
127#endif /* 0 */
128 }
129 }
130}
131
132/**********************************************************************/
142
143/**********************************************************************/
148void queue_flush(void)
149{
150 if (!is_flush_queued) {
151 if (flush_event()) {
153 } else {
154 /* We don't want to set is_flush_queued in this case, since then
155 * the flush code would simply stop working. But this means the
156 * below message may be repeated many times. */
157 bugreport_request(_("Failed to add events to SDL3 event buffer: %s"),
158 SDL_GetError());
159 }
160 }
161}
162
163/**********************************************************************/
173
174/**********************************************************************/
184
185/**********************************************************************/
188void dirty_all(void)
189{
191 queue_flush();
192}
193
194/**********************************************************************/
203
204/**********************************************************************/
208void flush_dirty(void)
209{
210 static int j = 0;
211
212 if (!main_data.rects_count) {
213 return;
214 }
215
217
218 if ((C_S_RUNNING == client_state())
219 && (get_client_page() == PAGE_GAME)) {
222 }
224 if (main_data.guis) {
225 while ((j < main_data.guis_count) && main_data.guis[j]) {
227
228 screen_blit(main_data.guis[j++]->surface, NULL, &dst, 255);
229 }
230 }
231 j = 0;
232
234
235 /* Render to screen */
237 } else {
238 static int i;
239 static SDL_Rect src, dst;
240
241 for (i = 0; i < main_data.rects_count; i++) {
242
243 dst = main_data.rects[i];
244 if (C_S_RUNNING == client_state()) {
245 flush_mapcanvas(dst.x, dst.y, dst.w, dst.h);
246 }
247 screen_blit(main_data.map, &main_data.rects[i], &dst, 255);
248
249 if (main_data.guis) {
250 while ((j < main_data.guis_count) && main_data.guis[j]) {
251 src = main_data.rects[i];
253 dst = main_data.rects[i];
254 screen_blit(main_data.guis[j++]->surface, &src, &dst, 255);
255 }
256 }
257 j = 0;
258
259 /* restore widget info label if it overlaps with this area */
260 dst = main_data.rects[i];
261 if (info_area && !(((dst.x + dst.w) < info_area->x)
262 || (dst.x > (info_area->x + info_area->w))
263 || ((dst.y + dst.h) < info_area->y)
264 || (dst.y > (info_area->y + info_area->h)))) {
266 }
267 }
268
270
271 /* Render to screen */
273#if 0
275#endif
276 }
278}
279
280/**********************************************************************/
283void gui_flush(void)
284{
285 if (C_S_RUNNING == client_state()) {
287 }
288}
289
290/* ===================================================================== */
291
292/**********************************************************************/
298 struct sprite *flake, struct sprite *gov)
299{
300 struct widget *buf = NULL;
301 char cbuf[128];
302
304 FREESURFACE(buf->theme);
305 buf->theme = adj_surf(GET_SURF(sol));
308
310 FREESURFACE(buf->theme);
311 buf->theme = adj_surf(GET_SURF(flake));
314
317
318 if (NULL != client.conn.playing) {
319 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)\n%s",
320 _("Revolution"), "Ctrl+Shift+G",
322 } else {
323 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)\n%s",
324 _("Revolution"), "Ctrl+Shift+G",
325 Q_("?gov:None"));
326 }
327 copy_chars_to_utf8_str(buf->info_label, cbuf);
328
331
333 if (!buf->theme) {
335 }
336
338
339 if (NULL == client.conn.playing) {
340 /* TRANS: Research report action */
341 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)\n%s (%d/%d)", _("Research"), "F6",
342 Q_("?tech:None"), 0, 0);
343 } else {
344 const struct research *presearch = research_get(client_player());
345
346 if (A_UNSET != presearch->researching) {
347 /* TRANS: Research report action */
348 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)\n%s (%d/%d)",
349 _("Research"), "F6",
351 presearch->researching),
352 presearch->bulbs_researched,
353 presearch->client.researching_cost);
354 } else {
355 /* TRANS: Research report action */
356 fc_snprintf(cbuf, sizeof(cbuf), "%s (%s)\n%s (%d/%d)",
357 _("Research"), "F6",
359 presearch->researching),
360 presearch->bulbs_researched,
361 0);
362 }
363 }
364
365 copy_chars_to_utf8_str(buf->info_label, cbuf);
366
368
371}
372
373/**********************************************************************/
391
392/**********************************************************************/
398{
399 SDL_Color bg_color = {0, 0, 0, 80};
401 char buffer[512];
402#ifdef SMALL_SCREEN
403 SDL_Rect area = {0, 0, 0, 0};
404#else
405 SDL_Rect area = {0, 3, 0, 0};
406#endif
407 struct utf8_str *ptext;
408
410 return;
411 }
412
414
415 /* Set text settings */
416 ptext->style |= TTF_STYLE_BOLD;
418 ptext->bgcol = (SDL_Color) {0, 0, 0, 0};
419
420 if (client_player() != NULL) {
421#ifdef SMALL_SCREEN
422 fc_snprintf(buffer, sizeof(buffer),
423 /* TRANS: "(Obs) Egyptian..." */
424 _("%s%s Population: %s Year: %s "
425 "Gold %d "),
426 /* TRANS: Observer */
427 client.conn.observer ? _("(Obs) ") : "",
432#else /* SMALL_SCREEN */
433 fc_snprintf(buffer, sizeof(buffer),
434 /* TRANS: "(Observer) Egyptian..." */
435 _("%s%s Population: %s Year: %s "
436 "Gold %d Tax: %d Lux: %d Sci: %d "),
437 client.conn.observer ? _("(Observer) ") : "",
445#endif /* SMALL_SCREEN */
446
447 /* Convert to utf8_str and create text surface */
450
451 area.x = (main_window_width() - tmp->w) / 2 - adj_size(5);
452 area.w = tmp->w + adj_size(8);
453 area.h = tmp->h + adj_size(4);
454
457
458 /* Horizontal lines */
460 area.x + 1, area.y, area.x + area.w - 2, area.y,
463 area.x + 1, area.y + area.h - 1, area.x + area.w - 2,
464 area.y + area.h - 1,
466
467 /* Vertical lines */
469 area.x + area.w - 1, area.y + 1, area.x + area.w - 1,
470 area.y + area.h - 2,
473 area.x, area.y + 1, area.x, area.y + area.h - 2,
475
476 /* Blit text to screen */
478 area.y + adj_size(2));
479
480 dirty_sdl_rect(&area);
481
483 }
484
489
491
493
494 queue_flush();
495}
496
497/**********************************************************************/
500static int focus_units_info_callback(struct widget *pwidget)
501{
503 struct unit *punit = pwidget->data.unit;
504
505 if (punit) {
508 }
509 }
510
511 return -1;
512}
513
514/**********************************************************************/
518void redraw_unit_info_label(struct unit_list *punitlist)
519{
520 struct widget *info_window;
521 SDL_Rect src, area;
522 SDL_Rect dest;
524 utf8_str *pstr;
525 struct canvas *destcanvas;
526 struct unit *punit;
527
528 if (punitlist != NULL && unit_list_size(punitlist) > 0) {
530 } else {
531 punit = NULL;
532 }
533
536
537 /* Blit theme surface */
539
540 if (punit) {
541 SDL_Surface *name, *vet_name = NULL, *info, *info2 = NULL;
542 int sy, y, width, height, n;
543 bool right;
544 char buffer[512];
545 struct tile *ptile = unit_tile(punit);
546 const char *vetname;
547
548 /* Get and draw unit name (with veteran status) */
551 pstr->style |= TTF_STYLE_BOLD;
552 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
554
555 pstr->style &= ~TTF_STYLE_BOLD;
556
557 if (info_window->size.w > 1.8 *
558 ((info_window->size.w - info_window->area.w) + DEFAULT_UNITS_W)) {
559 width = info_window->area.w / 2;
560 right = TRUE;
561 } else {
562 width = info_window->area.w;
563 right = FALSE;
564 }
565
568 punit->veteran);
569 if (vetname != NULL) {
574 }
575
576 /* Get and draw other info (MP, terrain, city, etc.) */
577 pstr->style |= SF_CENTER;
578
583
584 if (info_window->size.h >
585 (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h))
586 || right) {
587 int h = TTF_GetFontHeight(info_window->string_utf8->font);
588
589 fc_snprintf(buffer, sizeof(buffer), "%s",
591
592 if (info_window->size.h >
593 2 * h + (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h)) || right) {
594 struct city *pcity = tile_city(ptile);
595
596 if (BORDERS_DISABLED != game.info.borders && !pcity) {
598 {"" /* unused, DS_ARMISTICE */, Q_("?nation:Hostile"),
599 "" /* unused, DS_CEASEFIRE */,
600 Q_("?nation:Peaceful"), Q_("?nation:Friendly"),
601 Q_("?nation:Mysterious")};
602
603 if (tile_owner(ptile) == client.conn.playing) {
604 cat_snprintf(buffer, sizeof(buffer), _("\nOur Territory"));
605 } else {
606 if (tile_owner(ptile)) {
607 struct player_diplstate *ds
609 tile_owner(ptile));
610
611 if (DS_CEASEFIRE == ds->type) {
612 int turns = ds->turns_left;
613
614 cat_snprintf(buffer, sizeof(buffer),
615 PL_("\n%s territory (%d turn ceasefire)",
616 "\n%s territory (%d turn ceasefire)", turns),
618 turns);
619 } else if (DS_ARMISTICE == ds->type) {
620 int turns = ds->turns_left;
621
622 cat_snprintf(buffer, sizeof(buffer),
623 PL_("\n%s territory (%d turn armistice)",
624 "\n%s territory (%d turn armistice)", turns),
626 turns);
627 } else {
628 cat_snprintf(buffer, sizeof(buffer), _("\nTerritory of the %s %s"),
631 }
632 } else { /* !tile_owner(ptile) */
633 cat_snprintf(buffer, sizeof(buffer), _("\nUnclaimed territory"));
634 }
635 }
636 } /* BORDERS_DISABLED != game.info.borders && !pcity */
637
638 if (pcity) {
639 /* Look at city owner, not tile owner (the two should be the same, if
640 * borders are in use). */
641 struct player *owner = city_owner(pcity);
642 const char *diplo_city_adjectives[DS_LAST] =
643 {Q_("?city:Neutral"), Q_("?city:Hostile"),
644 Q_("?city:Neutral"), Q_("?city:Peaceful"),
645 Q_("?city:Friendly"), Q_("?city:Mysterious")};
646
647 cat_snprintf(buffer, sizeof(buffer),
648 _("\nCity of %s"),
649 city_name_get(pcity));
650
651#if 0
652 /* This has hardcoded assumption that EFT_LAND_REGEN is always
653 * provided by *building* named *Barracks*. Similar assumptions for
654 * other effects. */
656 barrack = (get_city_bonus(pcity, EFT_LAND_REGEN) > 0);
657 airport = (get_city_bonus(pcity, EFT_AIR_VETERAN) > 0);
658 port = (get_city_bonus(pcity, EFT_SEA_VETERAN) > 0);
659 }
660
661 if (citywall || barrack || airport || port) {
662 cat_snprintf(buffer, sizeof(buffer), Q_("?blistbegin: with "));
663 if (barrack) {
664 cat_snprintf(buffer, sizeof(buffer), _("Barracks"));
665 if (port || airport || citywall) {
666 cat_snprintf(buffer, sizeof(buffer), Q_("?blistmore:, "));
667 }
668 }
669 if (port) {
670 cat_snprintf(buffer, sizeof(buffer), _("Port"));
671 if (airport || citywall) {
672 cat_snprintf(buffer, sizeof(buffer), Q_("?blistmore:, "));
673 }
674 }
675 if (airport) {
676 cat_snprintf(buffer, sizeof(buffer), _("Airport"));
677 if (citywall) {
678 cat_snprintf(buffer, sizeof(buffer), Q_("?blistmore:, "));
679 }
680 }
681 if (citywall) {
682 cat_snprintf(buffer, sizeof(buffer), _("City Walls"));
683 }
684
685 cat_snprintf(buffer, sizeof(buffer), Q_("?blistend:"));
686 }
687#endif /* 0 */
688
689 if (owner && owner != client.conn.playing) {
690 struct player_diplstate *ds
692
693 /* TRANS: (<nation>,<diplomatic_state>)" */
694 cat_snprintf(buffer, sizeof(buffer), _("\n(%s,%s)"),
697 }
698 }
699 }
700
701 if (info_window->size.h >
702 4 * h + (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h)) || right) {
703 cat_snprintf(buffer, sizeof(buffer), _("\nFood/Prod/Trade: %s"),
705 }
706
708
710 }
711
713
714 /* ------------------------------------------- */
715
716 n = unit_list_size(ptile->units);
717 y = 0;
718
719 if (n > 1 && ((!right && info2
720 && (info_window->size.h - (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h)) -
721 info2->h > 52))
722 || (right && info_window->size.h - (DEFAULT_UNITS_H + (info_window->size.h -
723 info_window->area.h)) > 52))) {
724 height = (info_window->size.h - info_window->area.h) + DEFAULT_UNITS_H;
725 } else {
726 height = info_window->size.h;
727 if (info_window->size.h > (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h))) {
728 y = (info_window->size.h - (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h)) -
729 (!right && info2 ? info2->h : 0)) / 2;
730 }
731 }
732
733 sy = y + adj_size(3);
734 area.y = info_window->area.y + sy;
735 area.x = info_window->area.x + BLOCKU_W + (width - name->w - BLOCKU_W) / 2;
736 dest = area;
737 alphablit(name, NULL, info_window->dst->surface, &dest, 255);
738 sy += name->h;
739 if (vet_name) {
740 area.y += name->h - adj_size(3);
741 area.x = info_window->area.x + BLOCKU_W + (width - vet_name->w - BLOCKU_W) / 2;
742 alphablit(vet_name, NULL, info_window->dst->surface, &area, 255);
743 sy += vet_name->h - adj_size(3);
745 }
747
748 /* draw unit sprite */
750 punit->facing),
751 adj_size(80), adj_size(80), 1, TRUE, TRUE);
752
753 src = (SDL_Rect){0, 0, buf_surf->w, buf_surf->h};
754
755 area.x = info_window->area.x + BLOCKU_W - adj_size(4) +
756 ((width - BLOCKU_W + adj_size(3) - src.w) / 2);
757 area.y = info_window->size.y + sy + (DEFAULT_UNITS_H - sy - src.h) / 2;
758 alphablit(buf_surf, &src, info_window->dst->surface, &area, 32);
760
761 /* blit unit info text */
762 area.x = info_window->area.x + BLOCKU_W - adj_size(4) +
763 ((width - BLOCKU_W + adj_size(4) - info->w) / 2);
764 area.y = info_window->size.y + sy + (DEFAULT_UNITS_H - sy - info->h) / 2;
765
766 alphablit(info, NULL, info_window->dst->surface, &area, 255);
767 FREESURFACE(info);
768
769 if (info2) {
770 if (right) {
771 area.x = info_window->area.x + width + (width - info2->w) / 2;
772 area.y = info_window->area.y + (height - info2->h) / 2;
773 } else {
774 area.y = info_window->area.y + DEFAULT_UNITS_H + y;
775 area.x = info_window->area.x + BLOCKU_W +
776 (width - BLOCKU_W - info2->w) / 2;
777 }
778
779 /* blit unit info text */
780 alphablit(info2, NULL, info_window->dst->surface, &area, 255);
781
782 if (right) {
783 sy = (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h));
784 } else {
785 sy = area.y - info_window->size.y + info2->h;
786 }
788 } else {
789 sy = (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h));
790 }
791
792 if (n > 1 && (info_window->size.h - sy > 52)) {
793 struct advanced_dialog *dlg = info_window->private_data.adv_dlg;
794 struct widget *buf = NULL, *end = NULL, *dock;
795 struct city *home_city;
796 const struct unit_type *putype;
797 int num_w, num_h;
798
801 }
802 num_w = (info_window->area.w - BLOCKU_W) / 68;
803 num_h = (info_window->area.h - sy) / 52;
804 dock = info_window;
805 n = 0;
806
807 unit_list_iterate(ptile->units, aunit) {
810
811 if (aunit == punit) {
812 continue;
813 }
814
819 fc_snprintf(buffer, sizeof(buffer),
820 "%s (%d,%d,%s)%s%s\n%s\n(%d/%d)\n%s",
822 putype->attack_strength,
823 putype->defense_strength,
824 move_points_text(putype->move_rate, FALSE),
825 (vetname != NULL ? "\n" : ""),
826 (vetname != NULL ? vetname : ""),
828 aunit->hp, putype->hp,
829 home_city ? city_name_get(home_city) : Q_("?homecity:None"));
831
834
837
838 put_unit(aunit, destcanvas, 1.0, 0, 0);
839
841
843
846
847 if (buf_surf->w > 64) {
848 float zoom = 64.0 / buf_surf->w;
849 SDL_Surface *zoomed = zoomSurface(buf_surf, zoom, zoom, 1);
850
853 }
854
855 pstr = create_utf8_from_char(buffer, 10);
856 pstr->style |= SF_CENTER;
857
861 buf->info_label = pstr;
862 buf->data.unit = aunit;
863 buf->id = ID_ICON;
864 widget_add_as_prev(buf, dock);
865 dock = buf;
866
867 if (!end) {
868 end = buf;
869 }
870
871 if (++n > num_w * num_h) {
873 }
874
877 }
878
880
882
884 dlg->end_active_widget_list = end;
886
887 if (n > num_w * num_h) {
888 if (!dlg->scroll) {
890 } else {
891 dlg->scroll->active = num_h;
892 dlg->scroll->step = num_w;
893 dlg->scroll->count = n;
895 }
896
897 /* create up button */
898 buf = dlg->scroll->up_left_button;
899 buf->size.x = info_window->area.x + info_window->area.w - buf->size.w;
900 buf->size.y = info_window->area.y + sy +
901 (info_window->size.h - sy - num_h * 52) / 2;
902 buf->size.h = (num_h * 52) / 2;
903
904 /* create down button */
906 buf->size.x = dlg->scroll->up_left_button->size.x;
907 buf->size.y = dlg->scroll->up_left_button->size.y +
908 dlg->scroll->up_left_button->size.h;
909 buf->size.h = dlg->scroll->up_left_button->size.h;
910 } else {
911 if (dlg->scroll) {
913 }
914 num_h = (n + num_w - 1) / num_w;
915 }
916
918 info_window->area.x + BLOCKU_W + adj_size(2),
919 info_window->size.y + sy +
920 (info_window->size.h - sy - num_h * 52) / 2,
921 0, 0, dlg->begin_active_widget_list,
923 } else {
924 if (info_window->private_data.adv_dlg->end_active_widget_list) {
925 del_group(info_window->private_data.adv_dlg->begin_active_widget_list,
926 info_window->private_data.adv_dlg->end_active_widget_list);
927 }
928 if (info_window->private_data.adv_dlg->scroll) {
929 hide_scrollbar(info_window->private_data.adv_dlg->scroll);
930 }
931 }
932 } else { /* punit */
933
934 if (info_window->private_data.adv_dlg->end_active_widget_list) {
935 del_group(info_window->private_data.adv_dlg->begin_active_widget_list,
936 info_window->private_data.adv_dlg->end_active_widget_list);
937 }
938 if (info_window->private_data.adv_dlg->scroll) {
939 hide_scrollbar(info_window->private_data.adv_dlg->scroll);
940 }
941
945 char buf[256];
946
947 fc_snprintf(buf, sizeof(buf), "%s\n%s\n%s",
948 _("End of Turn"), _("Press"), _("Shift+Return"));
950 pstr->style = SF_CENTER;
951 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
953 area.x = info_window->size.x + BLOCKU_W +
954 (info_window->size.w - BLOCKU_W - buf_surf->w) / 2;
955 area.y = info_window->size.y + (info_window->size.h - buf_surf->h) / 2;
956 alphablit(buf_surf, NULL, info_window->dst->surface, &area, 255);
959 /* Fix the bug of child dialogs not showing up when player's turn ends */
960 flush_all();
961 }
962 }
963
964 /* Draw buttons */
965 redraw_group(info_window->private_data.adv_dlg->begin_widget_list,
966 info_window->private_data.adv_dlg->end_widget_list->prev, 0);
967
969 }
970}
971
972/**********************************************************************/
979
980/**********************************************************************/
986void set_unit_icon(int idx, struct unit *punit)
987{
988 /* FIXME */
989 /* update_unit_info_label(punit);*/
990}
991
992/**********************************************************************/
998{
999/* Balast */
1000}
1001
1002/**********************************************************************/
1008{
1009 /* Nothing to do */
1010}
1011
1012/**********************************************************************/
1024void update_unit_info_label(struct unit_list *punitlist)
1025{
1026 if (C_S_RUNNING != client_state()) {
1027 return;
1028 }
1029
1030 /* draw unit info window */
1032
1033 if (punitlist) {
1034 if (!is_focus_anim_enabled()) {
1036 }
1037 } else {
1039 }
1040}
1041
1042/**********************************************************************/
1046{
1047 log_debug("MAPVIEW: update_timeout_label : PORT ME");
1048}
1049
1050/**********************************************************************/
1054{
1055 log_debug("MAPVIEW: update_turn_done_button : PORT ME");
1056}
1057
1058/* ===================================================================== */
1059/* ========================== City Descriptions ======================== */
1060/* ===================================================================== */
1061
1062/**********************************************************************/
1066{
1067 /* redraw buffer */
1069 dirty_all();
1070}
1071
1072/* ===================================================================== */
1073/* =============================== Mini Map ============================ */
1074/* ===================================================================== */
1075
1076/**********************************************************************/
1080{
1081 return overview_canvas;
1082}
1083
1084/**********************************************************************/
1089{
1090 /* calculate the dimensions in a way to always get a resulting
1091 overview with a height bigger than or equal to DEFAULT_OVERVIEW_H.
1092 First, the default dimensions are fed to the same formula that
1093 is used in overview_common.c. If the resulting height is
1094 smaller than DEFAULT_OVERVIEW_H, increase OVERVIEW_TILE_SIZE
1095 by 1 until the height condition is met.
1096 */
1098 int xfact = MAP_IS_ISOMETRIC ? 2 : 1;
1099 int shift = (MAP_IS_ISOMETRIC && !current_wrap_has_flag(WRAP_X)) ? -1 : 0;
1100
1102 (DEFAULT_OVERVIEW_H - 1) / wld.map.ysize) + 1;
1103
1104 do {
1106 if (*height < DEFAULT_OVERVIEW_H) {
1108 }
1109 } while (*height < DEFAULT_OVERVIEW_H);
1110
1112
1114}
1115
1116/**********************************************************************/
1121{
1122 struct widget *minimap;
1124
1127
1129 minimap->area.x + overview_start_x, minimap->area.x + overview_start_y,
1130 overview_canvas->surf->w, overview_canvas->surf->h
1131 };
1132
1133 alphablit(overview_canvas->surf, NULL, minimap->dst->surface,
1134 &overview_area, 255);
1135
1137 }
1138}
1139
1140/**********************************************************************/
1145{
1146 /* No scrollbars. */
1147}
1148
1149/**********************************************************************/
1152void put_cross_overlay_tile(struct tile *ptile)
1153{
1154 log_debug("MAPVIEW: put_cross_overlay_tile : PORT ME");
1155}
1156
1157/**********************************************************************/
1160void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
1161{
1162 /* PORTME */
1164 canvas_x, canvas_y, w, h,
1166}
1167
1168/**********************************************************************/
1172{
1173 /* PORTME */
1174 /* Here you should do any necessary redraws (for instance, the city
1175 * dialogs usually need to be resized). */
1177}
1178
1179/* =====================================================================
1180 City MAP
1181 ===================================================================== */
1182
1183/**********************************************************************/
1187{
1188 if (city_map_canvas != NULL) {
1191 }
1192}
1193
1194/**********************************************************************/
1198{
1199 /* City map dimensions might have changed, so create a new canvas each time */
1201
1204
1206
1207 return city_map_canvas->surf;
1208}
1209
1210/**********************************************************************/
1214{
1215 /* Tileset dimensions might have changed, so create a new canvas each time */
1216
1217 if (terrain_canvas) {
1219 }
1220
1223
1224 put_terrain(ptile, terrain_canvas, 1.0, 0, 0);
1225
1226 return terrain_canvas->surf;
1227}
1228
1229/**********************************************************************/
1233{
1234 /* TODO: PORTME. */
1235}
1236
1237/**********************************************************************/
1240void start_turn(void)
1241{}
1242
1243/**********************************************************************/
1247{
1248 /* Needed only with full screen zoom mode.
1249 * Not needed, nor implemented, in this client. */
1251}
SDL_Surface * zoomSurface(SDL_Surface *src, double zoomx, double zoomy, int smooth)
Zoom a surface by independent horizontal and vertical factors with optional smoothing.
void astr_free(struct astring *astr)
Definition astring.c:153
#define n
Definition astring.c:77
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
void bugreport_request(const char *reason_format,...)
Definition bugs.c:31
const char * calendar_text(void)
Definition calendar.c:141
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int canvas_y
Definition canvas_g.h:43
struct canvas int canvas_x
Definition canvas_g.h:43
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
#define city_owner(_pcity_)
Definition city.h:563
int get_citydlg_canvas_width(void)
void city_dialog_redraw_map(struct city *pcity, struct canvas *pcanvas)
int get_citydlg_canvas_height(void)
bool client_is_observer(void)
struct civclient client
enum client_states client_state(void)
#define client_player()
@ C_S_RUNNING
Definition client_main.h:47
struct sprite * client_warming_sprite(void)
Definition climisc.c:377
struct sprite * client_cooling_sprite(void)
Definition climisc.c:394
struct sprite * client_research_sprite(void)
Definition climisc.c:354
struct sprite * client_government_sprite(void)
Definition climisc.c:412
char * incite_cost
Definition comments.c:75
void unit_focus_set(struct unit *punit)
Definition control.c:506
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1929
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:74
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:846
@ O_GOLD
Definition fc_types.h:101
@ BORDERS_DISABLED
Definition fc_types.h:1037
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
const char * population_to_text(int thousand_citizen)
Definition game.c:734
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
int civ_population(const struct player *pplayer)
Definition game.c:74
struct city * game_city_by_number(int id)
Definition game.c:107
const char * government_name_for_player(const struct player *pplayer)
Definition government.c:154
void canvas_free(struct canvas *store)
Definition canvas.c:44
struct canvas * canvas_create(int width, int height)
Definition canvas.c:28
struct city * owner
Definition citydlg.c:226
void popdown_all_game_dialogs(void)
Definition dialogs.c:1514
GtkWidget * overview_canvas
Definition gui_main.c:111
void update_timeout_label(void)
Definition mapview.c:118
void flush_dirty(void)
Definition mapview.c:468
void update_info_label(void)
Definition mapview.c:138
void update_turn_done_button(bool do_restore)
Definition mapview.c:76
void dirty_all(void)
Definition mapview.c:456
void tileset_changed(void)
Definition mapview.c:782
void put_cross_overlay_tile(struct tile *ptile)
Definition mapview.c:643
void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
Definition mapview.c:749
void update_map_canvas_scrollbars_size(void)
Definition mapview.c:696
void get_overview_area_dimensions(int *width, int *height)
Definition mapview.c:317
void start_turn(void)
Definition mapview.c:805
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
void update_overview_scroll_window_pos(int x, int y)
Definition mapview.c:657
void update_city_descriptions(void)
Definition mapview.c:488
void gui_flush(void)
Definition mapview.c:480
void update_map_canvas_scrollbars(void)
Definition mapview.c:681
void overview_size_changed(void)
Definition mapview.c:326
void map_canvas_size_refresh(void)
Definition mapview.c:414
struct canvas * get_overview_window(void)
Definition mapview.c:337
void set_indicator_icons(struct sprite *bulb, struct sprite *sol, struct sprite *flake, struct sprite *gov)
Definition mapview.c:302
enum client_pages get_current_client_page(void)
Definition pages.c:3345
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
const char * sdl_get_tile_defense_info_text(struct tile *ptile)
Definition dialogs.c:1306
int main_window_width(void)
Definition graphics.c:685
void update_main_screen(void)
Definition graphics.c:669
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
Definition graphics.c:1379
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
int screen_blit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:223
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
bool correct_rect_region(SDL_Rect *prect)
Definition graphics.c:888
void screen_rect_to_layer_rect(struct gui_layer *gui_layer, SDL_Rect *dest_rect)
Definition graphics.c:173
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
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:1257
#define FREESURFACE(ptr)
Definition graphics.h:322
#define RECT_LIMIT
Definition graphics.h:45
#define adj_surf(surf)
Definition graphics.h:200
#define map_rgba(format, color)
Definition graphics.h:315
@ ID_COOLING_ICON
Definition gui_id.h:138
@ ID_WARMING_ICON
Definition gui_id.h:139
@ ID_ICON
Definition gui_id.h:33
void enable_focus_animation(void)
Definition gui_main.c:1195
bool flush_event(void)
Definition gui_main.c:1340
void disable_focus_animation(void)
Definition gui_main.c:1204
#define CF_FOCUS_ANIMATION
Definition gui_main.h:51
#define CF_OVERVIEW_SHOWN
Definition gui_main.h:48
#define adj_size(size)
Definition gui_main.h:141
#define PRESSED_EVENT(event)
Definition gui_main.h:71
#define CF_UNITINFO_SHOWN
Definition gui_main.h:47
void draw_mouse_cursor(void)
Definition gui_mouse.c:100
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
void change_fonto_utf8(utf8_str *pstr, enum font_origin origin)
Definition gui_string.c:584
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
Definition gui_string.c:241
SDL_Surface * create_text_surf_smaller_than_w(utf8_str *pstr, int w)
Definition gui_string.c:539
#define create_utf8_from_char(string_in, ptsize)
Definition gui_string.h:103
#define FREEUTF8STR(pstr)
Definition gui_string.h:93
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_HEADING
Definition gui_string.h:69
@ FONTO_DEFAULT
Definition gui_string.h:65
@ FONTO_ATTENTION
Definition gui_string.h:67
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
static SDL_Surface * get_tax_surface(Output_type_id otype)
static SDL_Surface * get_unittype_surface(const struct unit_type *punittype, enum direction8 facing)
struct widget * get_minimap_window_widget(void)
Definition mapctrl.c:2203
struct widget * get_research_widget(void)
Definition mapctrl.c:2219
int resize_minimap(void)
Definition mapctrl.c:554
struct widget * get_unit_info_window_widget(void)
Definition mapctrl.c:2195
struct widget * get_revolution_widget(void)
Definition mapctrl.c:2227
struct widget * get_tax_rates_widget(void)
Definition mapctrl.c:2211
#define DEFAULT_UNITS_W
Definition mapctrl.h:55
#define DEFAULT_UNITS_H
Definition mapctrl.h:56
#define BLOCKU_W
Definition mapctrl.h:52
#define DEFAULT_OVERVIEW_W
Definition mapctrl.h:53
#define DEFAULT_OVERVIEW_H
Definition mapctrl.h:54
void real_focus_units_changed(void)
Definition mapview.c:1011
void set_unit_icons_more_arrow(bool onoff)
Definition mapview.c:1001
void set_unit_icon(int idx, struct unit *punit)
Definition mapview.c:990
static bool is_focus_anim_enabled(void)
Definition mapview.c:979
SDL_Surface * create_city_map(struct city *pcity)
Definition mapview.c:1201
static void flush_mapcanvas(int canvas_x, int canvas_y, int pixel_width, int pixel_height)
Definition mapview.c:92
void refresh_overview(void)
Definition mapview.c:1124
static bool is_flush_queued
Definition mapview.c:87
void flush_rect(SDL_Rect *rect, bool force_flush)
Definition mapview.c:103
SDL_Surface * get_terrain_surface(struct tile *ptile)
Definition mapview.c:1217
void dirty_sdl_rect(SDL_Rect *Rect)
Definition mapview.c:181
void queue_flush(void)
Definition mapview.c:152
static int focus_units_info_callback(struct widget *pwidget)
Definition mapview.c:504
SDL_Rect * info_area
Definition widget.c:49
void redraw_unit_info_label(struct unit_list *punitlist)
Definition mapview.c:522
int overview_start_x
Definition mapview.c:73
void unqueue_flush(void)
Definition mapview.c:140
static struct canvas * terrain_canvas
Definition mapview.c:78
void city_map_canvas_free(void)
Definition mapview.c:1190
int overview_start_y
Definition mapview.c:74
void flush_all(void)
Definition mapview.c:201
#define GET_SURF(m_sprite)
Definition sprite.h:29
@ COLOR_THEME_MAPVIEW_UNITINFO_VETERAN_TEXT
Definition themecolors.h:96
@ COLOR_THEME_MAPVIEW_INFO_TEXT
Definition themecolors.h:94
@ COLOR_THEME_MAPVIEW_INFO_FRAME
Definition themecolors.h:93
@ COLOR_THEME_SELECTIONRECTANGLE
Definition themecolors.h:36
@ COLOR_THEME_MAPVIEW_UNITINFO_TEXT
Definition themecolors.h:95
void redraw_widget_info_label(SDL_Rect *rect)
Definition widget.c:467
struct widget * get_widget_pointer_from_main_list(Uint16 id)
Definition widget.c:578
void widget_add_as_prev(struct widget *new_widget, struct widget *add_dock)
Definition widget.c:602
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:1051
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:720
@ FC_WS_NORMAL
Definition widget.h:96
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
@ WF_HIDDEN
Definition widget.h:68
@ WF_FREE_THEME
Definition widget.h:72
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
#define del_group(begin_group_widget_list, end_group_widget_list)
Definition widget.h:389
struct widget * create_icon2(SDL_Surface *icon, struct gui_layer *pdest, Uint32 flags)
void set_new_icon2_theme(struct widget *icon_widget, SDL_Surface *new_theme, bool free_old_theme)
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
#define hide_scrollbar(scrollbar)
#define show_scrollbar(scrollbar)
Uint32 sdl3_client_flags
Definition gui_main.c:97
const char * name
Definition inputfile.c:127
#define fc_assert(condition)
Definition log.h:176
#define log_debug(message,...)
Definition log.h:115
#define MAP_IS_ISOMETRIC
Definition map.h:42
#define current_wrap_has_flag(flag)
Definition map.h:51
void redraw_selection_rectangle(void)
void put_terrain(struct tile *ptile, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
struct view mapview
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void show_city_descriptions(int canvas_base_x, int canvas_base_y, int width_base, int height_base)
bool map_canvas_resized(int width, int height)
dirty_rect
Definition mapview_g.h:47
int int int pixel_width
Definition mapview_g.h:48
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1015
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:178
struct client_options gui_options
Definition options.c:71
int OVERVIEW_TILE_SIZE
#define OVERVIEW_TILE_WIDTH
#define OVERVIEW_TILE_HEIGHT
enum client_pages get_client_page(void)
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:324
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1405
#define is_human(plr)
Definition player.h:229
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
struct research * research_get(const struct player *pplayer)
Definition research.c:128
#define MIN(x, y)
Definition shared.h:55
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
struct widget * begin_active_widget_list
Definition widget.h:184
struct widget * end_active_widget_list
Definition widget.h:185
struct widget * active_widget_list
Definition widget.h:186
struct scroll_bar * scroll
Definition widget.h:187
SDL_Surface * surf
Definition canvas.h:27
Definition city.h:320
struct packet_game_info info
Definition game.h:89
int xsize
Definition map_types.h:78
int ysize
Definition map_types.h:78
struct connection conn
Definition client_main.h:96
struct overview overview
Definition options.h:425
bool ai_manual_turn_done
Definition options.h:154
struct player * playing
Definition connection.h:151
bool observer
Definition connection.h:147
SDL_Surface * surface
Definition graphics.h:229
SDL_Rect dest_rect
Definition graphics.h:228
int width
Definition options.h:94
int height
Definition options.h:94
enum borders_mode borders
struct player_economic economic
Definition player.h:282
bool phase_done
Definition player.h:261
struct widget * up_left_button
struct widget * down_right_button
int guis_count
Definition graphics.h:207
struct gui_layer * gui
Definition graphics.h:215
int rects_count
Definition graphics.h:206
SDL_Event event
Definition graphics.h:217
SDL_Rect rects[RECT_LIMIT]
Definition graphics.h:208
struct gui_layer ** guis
Definition graphics.h:216
SDL_Window * screen
Definition graphics.h:209
SDL_Surface * map
Definition graphics.h:210
Definition tile.h:50
struct unit_list * units
Definition tile.h:58
Definition unit.h:138
enum direction8 facing
Definition unit.h:142
int veteran
Definition unit.h:152
int store_width
int store_height
struct canvas * store
union widget::@194 data
struct unit * unit
Definition widget.h:129
SDL_Rect area
Definition widget.h:149
SDL_Rect size
Definition widget.h:145
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:1000
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define A_UNSET
Definition tech.h:48
const char * get_tile_output_text(const struct tile *ptile)
Definition text.c:63
const char * get_unit_info_label_text2(struct unit_list *punits, int linebreaks)
Definition text.c:1079
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define TILE_LB_RESOURCE_POLL
Definition tile.h:177
#define tile_owner(_tile)
Definition tile.h:96
int tileset_full_tile_height(const struct tileset *t)
Definition tilespec.c:789
int tileset_full_tile_width(const struct tileset *t)
Definition tilespec.c:776
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1155
#define unit_tile(_pu)
Definition unit.h:397
#define unit_owner(_pu)
Definition unit.h:396
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const char * utype_veteran_name_translation(const struct unit_type *punittype, int level)
Definition unittype.c:2610
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1569
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560