When mixer is not available, recommend SDL2_mixer instead of SDL1.2 mixer
[freeciv.git] / client / gui-sdl / mapctrl.c
blob06e0857b2c7959f53fb09df20ad38871a116215a
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.
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 ***********************************************************************/
14 /***********************************************************************
15 mapctrl.c - description
16 -------------------
17 begin : Thu Sep 05 2002
18 copyright : (C) 2002 by Rafał Bursig
19 email : Rafał Bursig <bursig@poczta.fm>
20 ***********************************************************************/
21 #ifdef HAVE_CONFIG_H
22 #include <fc_config.h>
23 #endif
25 /* SDL */
26 #include <SDL/SDL.h>
28 /* utility */
29 #include "fcintl.h"
30 #include "log.h"
32 /* common */
33 #include "unit.h"
34 #include "unitlist.h"
36 /* client */
37 #include "client_main.h"
38 #include "climisc.h"
39 #include "overview_common.h"
40 #include "update_queue.h"
42 /* client/gui-sdl */
43 #include "citydlg.h"
44 #include "cityrep.h"
45 #include "colors.h"
46 #include "dialogs.h"
47 #include "finddlg.h"
48 #include "graphics.h"
49 #include "gui_iconv.h"
50 #include "gui_id.h"
51 #include "gui_main.h"
52 #include "gui_mouse.h"
53 #include "gui_tilespec.h"
54 #include "mapview.h"
55 #include "menu.h"
56 #include "messagewin.h"
57 #include "optiondlg.h"
58 #include "pages.h"
59 #include "plrdlg.h"
60 #include "repodlgs.h"
61 #include "sprite.h"
62 #include "themespec.h"
63 #include "widget.h"
64 #include "wldlg.h"
66 #include "mapctrl.h"
68 #undef SCALE_MINIMAP
69 #undef SCALE_UNITINFO
71 extern int overview_start_x;
72 extern int overview_start_y;
73 extern bool is_unit_move_blocked;
75 static char *pSuggestedCityName = NULL;
76 static struct SMALL_DLG *pNewCity_Dlg = NULL;
78 #ifdef SCALE_MINIMAP
79 static struct SMALL_DLG *pScale_MiniMap_Dlg = NULL;
80 static int popdown_scale_minmap_dlg_callback(struct widget *pWidget);
81 #endif
83 #ifdef SCALE_UNITINFO
84 static struct SMALL_DLG *pScale_UnitInfo_Dlg = NULL;
85 static int INFO_WIDTH, INFO_HEIGHT = 0, INFO_WIDTH_MIN, INFO_HEIGHT_MIN;
86 static int popdown_scale_unitinfo_dlg_callback(struct widget *pWidget);
87 static void Remake_UnitInfo(int w, int h);
88 #endif
90 static struct ADVANCED_DLG *pMiniMap_Dlg = NULL;
91 static struct ADVANCED_DLG *pUnitInfo_Dlg = NULL;
93 int overview_w = 0;
94 int overview_h = 0;
95 int unitinfo_w = 0;
96 int unitinfo_h = 0;
98 bool draw_goto_patrol_lines = FALSE;
99 static struct widget *pNew_Turn_Button = NULL;
100 static struct widget *pUnits_Info_Window = NULL;
101 static struct widget *pMiniMap_Window = NULL;
102 static struct widget *pFind_City_Button = NULL;
103 static struct widget *pRevolution_Button = NULL;
104 static struct widget *pTax_Button = NULL;
105 static struct widget *pResearch_Button = NULL;
107 static void enable_minimap_widgets(void);
108 static void disable_minimap_widgets(void);
109 static void enable_unitinfo_widgets(void);
110 static void disable_unitinfo_widgets(void);
112 /* ================================================================ */
114 static int players_action_callback(struct widget *pWidget)
116 set_wstate(pWidget, FC_WS_NORMAL);
117 widget_redraw(pWidget);
118 widget_mark_dirty(pWidget);
119 if (Main.event.type == SDL_MOUSEBUTTONDOWN) {
120 switch(Main.event.button.button) {
121 #if 0
122 case SDL_BUTTON_LEFT:
124 break;
125 case SDL_BUTTON_MIDDLE:
127 break;
128 #endif
129 case SDL_BUTTON_RIGHT:
130 popup_players_nations_dialog();
131 break;
132 default:
133 popup_players_dialog(true);
134 break;
136 } else {
137 popup_players_dialog(true);
139 return -1;
143 static int units_action_callback(struct widget *pWidget)
145 if (Main.event.button.button == SDL_BUTTON_LEFT) {
146 set_wstate(pWidget, FC_WS_NORMAL);
147 widget_redraw(pWidget);
148 widget_mark_dirty(pWidget);
149 units_report_dialog_popup(FALSE);
151 return -1;
154 /**************************************************************************
156 **************************************************************************/
157 static int cities_action_callback(struct widget *pButton)
159 set_wstate(pButton, FC_WS_DISABLED);
160 widget_redraw(pButton);
161 widget_mark_dirty(pButton);
162 if (Main.event.type == SDL_MOUSEBUTTONDOWN) {
163 switch(Main.event.button.button) {
164 #if 0
165 case SDL_BUTTON_LEFT:
167 break;
168 case SDL_BUTTON_MIDDLE:
170 break;
171 #endif
172 case SDL_BUTTON_RIGHT:
173 popup_find_dialog();
174 break;
175 default:
176 city_report_dialog_popup(FALSE);
177 break;
179 } else {
180 popup_find_dialog();
183 return -1;
186 /**************************************************************************
188 **************************************************************************/
189 static int end_turn_callback(struct widget *pButton)
191 if (Main.event.button.button == SDL_BUTTON_LEFT) {
192 widget_redraw(pButton);
193 widget_flush(pButton);
194 disable_focus_animation();
195 key_end_turn();
197 return -1;
200 /**************************************************************************
202 **************************************************************************/
203 static int revolution_callback(struct widget *pButton)
205 if (Main.event.button.button == SDL_BUTTON_LEFT) {
206 set_wstate(pButton, FC_WS_DISABLED);
207 widget_redraw(pButton);
208 widget_mark_dirty(pButton);
209 popup_revolution_dialog();
211 return -1;
214 /**************************************************************************
216 **************************************************************************/
217 static int research_callback(struct widget *pButton)
219 if (Main.event.button.button == SDL_BUTTON_LEFT) {
220 science_report_dialog_popup(TRUE);
222 return -1;
225 /**************************************************************************
227 **************************************************************************/
228 static int economy_callback(struct widget *pButton)
230 if (Main.event.button.button == SDL_BUTTON_LEFT) {
231 economy_report_dialog_popup(FALSE);
233 return -1;
236 /* ====================================== */
238 /**************************************************************************
239 Show/Hide Units Info Window
240 **************************************************************************/
241 static int toggle_unit_info_window_callback(struct widget *pIcon_Widget)
243 if (Main.event.button.button == SDL_BUTTON_LEFT) {
244 struct widget *pBuf = NULL;
246 clear_surface(pIcon_Widget->theme, NULL);
247 alphablit(current_theme->MAP_Icon, NULL, pIcon_Widget->theme, NULL);
249 if (get_num_units_in_focus() > 0) {
250 undraw_order_widgets();
253 if (SDL_Client_Flags & CF_UNITINFO_SHOWN) {
254 /* HIDE */
255 SDL_Surface *pBuf_Surf;
256 SDL_Rect src, window_area;
258 set_wstate(pIcon_Widget, FC_WS_NORMAL);
259 pSellected_Widget = NULL;
261 if (pUnits_Info_Window->private_data.adv_dlg->pEndActiveWidgetList) {
262 del_group(pUnits_Info_Window->private_data.adv_dlg->pBeginActiveWidgetList,
263 pUnits_Info_Window->private_data.adv_dlg->pEndActiveWidgetList);
265 if (pUnits_Info_Window->private_data.adv_dlg->pScroll) {
266 hide_scrollbar(pUnits_Info_Window->private_data.adv_dlg->pScroll);
269 /* clear area under old unit info window */
270 widget_undraw(pUnits_Info_Window);
271 widget_mark_dirty(pUnits_Info_Window);
273 /* new button direction */
274 alphablit(current_theme->L_ARROW_Icon, NULL, pIcon_Widget->theme, NULL);
276 copy_chars_to_string16(pIcon_Widget->info_label,
277 _("Show Unit Info Window"));
279 SDL_Client_Flags &= ~CF_UNITINFO_SHOWN;
281 set_new_unitinfo_window_pos();
283 /* blit part of map window */
284 src.x = 0;
285 src.y = 0;
286 src.w = (pUnits_Info_Window->size.w - pUnits_Info_Window->area.w) + BLOCKU_W;
287 src.h = pUnits_Info_Window->theme->h;
289 window_area = pUnits_Info_Window->size;
290 alphablit(pUnits_Info_Window->theme, &src, pUnits_Info_Window->dst->surface, &window_area);
292 /* blit right vertical frame */
293 pBuf_Surf = ResizeSurface(current_theme->FR_Right, current_theme->FR_Right->w,
294 pUnits_Info_Window->area.h, 1);
296 window_area.y = pUnits_Info_Window->area.y;
297 window_area.x = pUnits_Info_Window->area.x + pUnits_Info_Window->area.w;
298 alphablit(pBuf_Surf, NULL , pUnits_Info_Window->dst->surface, &window_area);
299 FREESURFACE(pBuf_Surf);
301 /* redraw widgets */
303 /* ID_ECONOMY */
304 pBuf = pUnits_Info_Window->prev;
305 widget_redraw(pBuf);
307 /* ===== */
308 /* ID_RESEARCH */
309 pBuf = pBuf->prev;
310 widget_redraw(pBuf);
312 /* ===== */
313 /* ID_REVOLUTION */
314 pBuf = pBuf->prev;
315 widget_redraw(pBuf);
317 /* ===== */
318 /* ID_TOGGLE_UNITS_WINDOW_BUTTON */
319 pBuf = pBuf->prev;
320 widget_redraw(pBuf);
322 #ifdef SCALE_UNITINFO
323 popdown_scale_unitinfo_dlg_callback(NULL);
324 #endif
325 } else {
326 if (Main.screen->w - pUnits_Info_Window->size.w >=
327 pMiniMap_Window->dst->dest_rect.x + pMiniMap_Window->size.w) {
329 set_wstate(pIcon_Widget, FC_WS_NORMAL);
330 pSellected_Widget = NULL;
332 /* SHOW */
333 copy_chars_to_string16(pIcon_Widget->info_label,
334 _("Hide Unit Info Window"));
336 alphablit(current_theme->R_ARROW_Icon, NULL, pIcon_Widget->theme, NULL);
338 SDL_Client_Flags |= CF_UNITINFO_SHOWN;
340 set_new_unitinfo_window_pos();
342 widget_mark_dirty(pUnits_Info_Window);
344 redraw_unit_info_label(get_units_in_focus());
345 } else {
346 alphablit(current_theme->L_ARROW_Icon, NULL, pIcon_Widget->theme, NULL);
347 widget_redraw(pIcon_Widget);
348 widget_mark_dirty(pIcon_Widget);
352 if (get_num_units_in_focus() > 0) {
353 update_order_widgets();
356 flush_dirty();
358 return -1;
361 /**************************************************************************
362 Show/Hide Mini Map
363 **************************************************************************/
364 static int toggle_map_window_callback(struct widget *pMap_Button)
366 if (Main.event.button.button == SDL_BUTTON_LEFT) {
367 struct unit *pFocus = head_of_units_in_focus();
368 struct widget *pWidget;
370 /* make new map icon */
371 clear_surface(pMap_Button->theme, NULL);
372 alphablit(current_theme->MAP_Icon, NULL, pMap_Button->theme, NULL);
374 set_wstate(pMiniMap_Window, FC_WS_NORMAL);
376 if (pFocus) {
377 undraw_order_widgets();
380 if (SDL_Client_Flags & CF_OVERVIEW_SHOWN) {
381 /* Hide MiniMap */
382 SDL_Surface *pBuf_Surf;
383 SDL_Rect src, map_area = pMiniMap_Window->size;
385 set_wstate(pMap_Button, FC_WS_NORMAL);
386 pSellected_Widget = NULL;
388 copy_chars_to_string16(pMap_Button->info_label, _("Show Mini Map"));
390 /* make new map icon */
391 alphablit(current_theme->R_ARROW_Icon, NULL, pMap_Button->theme, NULL);
393 SDL_Client_Flags &= ~CF_OVERVIEW_SHOWN;
395 /* clear area under old map window */
396 widget_undraw(pMiniMap_Window);
397 widget_mark_dirty(pMiniMap_Window);
399 pMiniMap_Window->size.w = (pMiniMap_Window->size.w - pMiniMap_Window->area.w) + BLOCKM_W;
400 pMiniMap_Window->area.w = BLOCKM_W;
402 set_new_minimap_window_pos();
404 /* blit part of map window */
405 src.x = pMiniMap_Window->theme->w - BLOCKM_W - current_theme->FR_Right->w;
406 src.y = 0;
407 src.w = BLOCKM_W + current_theme->FR_Right->w;
408 src.h = pMiniMap_Window->theme->h;
410 alphablit(pMiniMap_Window->theme, &src , pMiniMap_Window->dst->surface, &map_area);
412 /* blit left vertical frame theme */
413 pBuf_Surf = ResizeSurface(current_theme->FR_Left, current_theme->FR_Left->w,
414 pMiniMap_Window->area.h, 1);
416 map_area.y += adj_size(2);
417 alphablit(pBuf_Surf, NULL, pMiniMap_Window->dst->surface, &map_area);
418 FREESURFACE(pBuf_Surf);
420 /* redraw widgets */
421 /* ID_NEW_TURN */
422 pWidget = pMiniMap_Window->prev;
423 widget_redraw(pWidget);
425 /* ID_PLAYERS */
426 pWidget = pWidget->prev;
427 widget_redraw(pWidget);
429 /* ID_CITIES */
430 pWidget = pWidget->prev;
431 widget_redraw(pWidget);
433 /* ID_UNITS */
434 pWidget = pWidget->prev;
435 widget_redraw(pWidget);
437 /* ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON */
438 pWidget = pWidget->prev;
439 widget_redraw(pWidget);
441 /* Toggle Minimap mode */
442 pWidget = pWidget->prev;
443 widget_redraw(pWidget);
445 #ifdef SMALL_SCREEN
446 /* options */
447 pWidget = pWidget->prev;
448 widget_redraw(pWidget);
449 #endif
451 /* ID_TOGGLE_MAP_WINDOW_BUTTON */
452 pWidget = pWidget->prev;
453 widget_redraw(pWidget);
455 #ifdef SCALE_MINIMAP
456 popdown_scale_minmap_dlg_callback(NULL);
457 #endif
458 } else {
459 if (((pMiniMap_Window->size.w - pMiniMap_Window->area.w) +
460 overview_w + BLOCKM_W) <= pUnits_Info_Window->dst->dest_rect.x) {
462 set_wstate(pMap_Button, FC_WS_NORMAL);
463 pSellected_Widget = NULL;
465 /* show MiniMap */
466 copy_chars_to_string16(pMap_Button->info_label, _("Hide Mini Map"));
468 alphablit(current_theme->L_ARROW_Icon, NULL, pMap_Button->theme, NULL);
469 SDL_Client_Flags |= CF_OVERVIEW_SHOWN;
471 pMiniMap_Window->size.w =
472 (pMiniMap_Window->size.w - pMiniMap_Window->area.w) + overview_w + BLOCKM_W;
473 pMiniMap_Window->area.w = overview_w + BLOCKM_W;
475 set_new_minimap_window_pos();
477 widget_redraw(pMiniMap_Window);
478 redraw_minimap_window_buttons();
479 refresh_overview();
480 } else {
481 alphablit(current_theme->R_ARROW_Icon, NULL, pMap_Button->theme, NULL);
482 widget_redraw(pMap_Button);
483 widget_mark_dirty(pMap_Button);
487 if (pFocus) {
488 update_order_widgets();
491 flush_dirty();
493 return -1;
496 /* ====================================================================== */
499 static int toggle_minimap_mode_callback(struct widget *pWidget)
501 if (Main.event.button.button == SDL_BUTTON_LEFT) {
502 if (pWidget) {
503 pSellected_Widget = pWidget;
504 set_wstate(pWidget, FC_WS_SELLECTED);
506 toggle_overview_mode();
507 refresh_overview();
508 flush_dirty();
510 return -1;
513 static int toggle_msg_window_callback(struct widget *pWidget)
515 if (Main.event.button.button == SDL_BUTTON_LEFT) {
516 if (meswin_dialog_is_open()) {
517 meswin_dialog_popdown();
518 copy_chars_to_string16(pWidget->info_label, _("Show Messages (F9)"));
519 } else {
520 meswin_dialog_popup(TRUE);
521 copy_chars_to_string16(pWidget->info_label, _("Hide Messages (F9)"));
524 pSellected_Widget = pWidget;
525 set_wstate(pWidget, FC_WS_SELLECTED);
526 widget_redraw(pWidget);
527 widget_mark_dirty(pWidget);
529 flush_dirty();
531 return -1;
534 int resize_minimap(void)
536 overview_w = gui_options.overview.width;
537 overview_h = gui_options.overview.height;
538 overview_start_x = (overview_w - gui_options.overview.width) / 2;
539 overview_start_y = (overview_h - gui_options.overview.height) / 2;
541 if (C_S_RUNNING == client_state()) {
542 popdown_minimap_window();
543 popup_minimap_window();
544 refresh_overview();
545 menus_update();
548 return 0;
551 #ifdef SCALE_MINIMAP
552 /* ============================================================== */
553 static int move_scale_minmap_dlg_callback(struct widget *pWindow)
555 if (Main.event.button.button == SDL_BUTTON_LEFT) {
556 move_window_group(pScale_MiniMap_Dlg->pBeginWidgetList, pWindow);
558 return -1;
561 static int popdown_scale_minmap_dlg_callback(struct widget *pWidget)
563 if (Main.event.button.button == SDL_BUTTON_LEFT) {
564 if (pScale_MiniMap_Dlg) {
565 popdown_window_group_dialog(pScale_MiniMap_Dlg->pBeginWidgetList,
566 pScale_MiniMap_Dlg->pEndWidgetList);
567 FC_FREE(pScale_MiniMap_Dlg);
568 if (pWidget) {
569 flush_dirty();
573 return -1;
576 static int up_width_callback(struct widget *pWidget)
578 if (Main.event.button.button == SDL_BUTTON_LEFT) {
579 widget_redraw(pWidget);
580 widget_mark_dirty(pWidget);
581 if ((((OVERVIEW_TILE_WIDTH + 1) * map.xsize) +
582 (pMiniMap_Window->size.w - pMiniMap_Window->area.w) + BLOCKM_W) <=
583 pUnits_Info_Window->dst->dest_rect.x) {
584 char cBuf[4];
585 fc_snprintf(cBuf, sizeof(cBuf), "%d", OVERVIEW_TILE_WIDTH);
586 copy_chars_to_string16(pWidget->next->string16, cBuf);
587 widget_redraw(pWidget->next);
588 widget_mark_dirty(pWidget->next);
590 calculate_overview_dimensions();
591 resize_minimap();
593 flush_dirty();
595 return -1;
598 static int down_width_callback(struct widget *pWidget)
600 if (Main.event.button.button == SDL_BUTTON_LEFT) {
601 widget_redraw(pWidget);
602 widget_mark_dirty(pWidget);
603 if (OVERVIEW_TILE_WIDTH > 1) {
604 char cBuf[4];
605 fc_snprintf(cBuf, sizeof(cBuf), "%d", OVERVIEW_TILE_WIDTH);
606 copy_chars_to_string16(pWidget->prev->string16, cBuf);
607 widget_redraw(pWidget->prev);
608 widget_mark_dirty(pWidget->prev);
610 resize_minimap();
612 flush_dirty();
614 return -1;
617 static int up_height_callback(struct widget *pWidget)
619 if (Main.event.button.button == SDL_BUTTON_LEFT) {
620 widget_redraw(pWidget);
621 widget_mark_dirty(pWidget);
622 if (Main.screen->h -
623 ((OVERVIEW_TILE_HEIGHT + 1) * map.ysize + (current_theme->FR_Bottom->h * 2)) >= 40) {
624 char cBuf[4];
626 OVERVIEW_TILE_HEIGHT++;
627 fc_snprintf(cBuf, sizeof(cBuf), "%d", OVERVIEW_TILE_HEIGHT);
628 copy_chars_to_string16(pWidget->next->string16, cBuf);
629 widget_redraw(pWidget->next);
630 widget_mark_dirty(pWidget->next);
631 resize_minimap();
633 flush_dirty();
635 return -1;
638 static int down_height_callback(struct widget *pWidget)
640 if (Main.event.button.button == SDL_BUTTON_LEFT) {
641 widget_redraw(pWidget);
642 widget_mark_dirty(pWidget);
643 if (OVERVIEW_TILE_HEIGHT > 1) {
644 char cBuf[4];
646 OVERVIEW_TILE_HEIGHT--;
647 fc_snprintf(cBuf, sizeof(cBuf), "%d", OVERVIEW_TILE_HEIGHT);
648 copy_chars_to_string16(pWidget->prev->string16, cBuf);
649 widget_redraw(pWidget->prev);
650 widget_mark_dirty(pWidget->prev);
652 resize_minimap();
654 flush_dirty();
656 return -1;
659 static void popup_minimap_scale_dialog(void)
661 SDL_Surface *pText1, *pText2;
662 SDL_String16 *pStr = NULL;
663 struct widget *pWindow = NULL;
664 struct widget *pBuf = NULL;
665 char cBuf[4];
666 int window_x = 0, window_y = 0;
667 SDL_Rect area;
669 if (pScale_MiniMap_Dlg || !(SDL_Client_Flags & CF_OVERVIEW_SHOWN)) {
670 return;
673 pScale_MiniMap_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
675 /* create window */
676 pStr = create_str16_from_char(_("Scale Mini Map"), adj_font(12));
677 pStr->style |= TTF_STYLE_BOLD;
678 pWindow = create_window_skeleton(NULL, pStr, 0);
679 pWindow->action = move_scale_minmap_dlg_callback;
680 set_wstate(pWindow, FC_WS_NORMAL);
681 add_to_gui_list(ID_WINDOW, pWindow);
682 pScale_MiniMap_Dlg->pEndWidgetList = pWindow;
684 area = pWindow->area;
686 /* ----------------- */
687 pStr = create_str16_from_char(_("Single Tile Width"), adj_font(12));
688 pText1 = create_text_surf_from_str16(pStr);
689 area.w = MAX(area.w, pText1->w + adj_size(30));
691 copy_chars_to_string16(pStr, _("Single Tile Height"));
692 pText2 = create_text_surf_from_str16(pStr);
693 area.w = MAX(area.w, pText2->w + adj_size(30));
694 FREESTRING16(pStr);
696 pBuf = create_themeicon_button(current_theme->L_ARROW_Icon, pWindow->dst, NULL, 0);
697 pBuf->action = down_width_callback;
698 set_wstate(pBuf, FC_WS_NORMAL);
699 add_to_gui_list(ID_BUTTON, pBuf);
701 fc_snprintf(cBuf, sizeof(cBuf), "%d" , OVERVIEW_TILE_WIDTH);
702 pStr = create_str16_from_char(cBuf, adj_font(24));
703 pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
704 pBuf = create_iconlabel(NULL, pWindow->dst, pStr, WF_RESTORE_BACKGROUND);
705 pBuf->size.w = MAX(adj_size(50), pBuf->size.w);
706 area.h += pBuf->size.h + adj_size(5);
707 add_to_gui_list(ID_LABEL, pBuf);
709 pBuf = create_themeicon_button(current_theme->R_ARROW_Icon, pWindow->dst, NULL, 0);
710 pBuf->action = up_width_callback;
711 set_wstate(pBuf, FC_WS_NORMAL);
712 add_to_gui_list(ID_BUTTON, pBuf);
715 /* ------------ */
716 pBuf = create_themeicon_button(current_theme->L_ARROW_Icon, pWindow->dst, NULL, 0);
717 pBuf->action = down_height_callback;
718 set_wstate(pBuf, FC_WS_NORMAL);
719 add_to_gui_list(ID_BUTTON, pBuf);
721 fc_snprintf(cBuf, sizeof(cBuf), "%d" , OVERVIEW_TILE_HEIGHT);
722 pStr = create_str16_from_char(cBuf, adj_font(24));
723 pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
724 pBuf = create_iconlabel(NULL, pWindow->dst, pStr, WF_RESTORE_BACKGROUND);
725 pBuf->size.w = MAX(adj_size(50), pBuf->size.w);
726 area.h += pBuf->size.h + adj_size(20);
727 add_to_gui_list(ID_LABEL, pBuf);
729 pBuf = create_themeicon_button(current_theme->R_ARROW_Icon, pWindow->dst, NULL, 0);
730 pBuf->action = up_height_callback;
731 set_wstate(pBuf, FC_WS_NORMAL);
732 add_to_gui_list(ID_BUTTON, pBuf);
733 area.w = MAX(area.w , pBuf->size.w * 2 + pBuf->next->size.w + adj_size(20));
735 /* ------------ */
736 pStr = create_str16_from_char(_("Exit"), adj_font(12));
737 pBuf = create_themeicon_button(current_theme->CANCEL_Icon, pWindow->dst, pStr, 0);
738 pBuf->action = popdown_scale_minmap_dlg_callback;
739 set_wstate(pBuf, FC_WS_NORMAL);
740 pScale_MiniMap_Dlg->pBeginWidgetList = pBuf;
741 add_to_gui_list(ID_BUTTON, pBuf);
742 area.h += pBuf->size.h + adj_size(10);
743 area.w = MAX(area.w, pBuf->size.w + adj_size(20));
744 /* ------------ */
746 area.h += adj_size(20);
748 resize_window(pWindow, NULL, get_theme_color(COLOR_THEME_BACKGROUND),
749 (pWindow->size.w - pWindow->area.w) + area.w,
750 (pWindow->size.h - pWindow->area.h) + area.h);
752 area = pWindow->area;
754 if (Main.event.motion.x + pWindow->size.w > Main.screen->w) {
755 if (Main.event.motion.x - pWindow->size.w >= 0) {
756 window_x = Main.event.motion.x - pWindow->size.w;
757 } else {
758 window_x = (Main.screen->w -pWindow->size. w) / 2;
760 } else {
761 window_x = Main.event.motion.x;
764 if (Main.event.motion.y + pWindow->size.h >= Main.screen->h) {
765 if (Main.event.motion.y - pWindow->size.h >= 0) {
766 window_y = Main.event.motion.y - pWindow->size.h;
767 } else {
768 window_y = (Main.screen->h - pWindow->size.h) / 2;
770 } else {
771 window_y = Main.event.motion.y;
774 widget_set_position(pWindow, window_x, window_y);
776 blit_entire_src(pText1, pWindow->theme, 15, area.y + 1);
777 FREESURFACE(pText1);
779 /* width label */
780 pBuf = pWindow->prev->prev;
781 pBuf->size.y = area.y + adj_size(16);
782 pBuf->size.x = area.x + (area.w - pBuf->size.w) / 2;
784 /* width left button */
785 pBuf->next->size.y = pBuf->size.y + pBuf->size.h - pBuf->next->size.h;
786 pBuf->next->size.x = pBuf->size.x - pBuf->next->size.w;
788 /* width right button */
789 pBuf->prev->size.y = pBuf->size.y + pBuf->size.h - pBuf->prev->size.h;
790 pBuf->prev->size.x = pBuf->size.x + pBuf->size.w;
792 /* height label */
793 pBuf = pBuf->prev->prev->prev;
794 pBuf->size.y = pBuf->next->next->next->size.y + pBuf->next->next->next->size.h + adj_size(20);
795 pBuf->size.x = area.x + (area.w - pBuf->size.w) / 2;
797 blit_entire_src(pText2, pWindow->theme, adj_size(15), pBuf->size.y - pText2->h - adj_size(2));
798 FREESURFACE(pText2);
800 /* height left button */
801 pBuf->next->size.y = pBuf->size.y + pBuf->size.h - pBuf->next->size.h;
802 pBuf->next->size.x = pBuf->size.x - pBuf->next->size.w;
804 /* height right button */
805 pBuf->prev->size.y = pBuf->size.y + pBuf->size.h - pBuf->prev->size.h;
806 pBuf->prev->size.x = pBuf->size.x + pBuf->size.w;
808 /* exit button */
809 pBuf = pBuf->prev->prev;
810 pBuf->size.x = area.x + (area.w - pBuf->size.w) / 2;
811 pBuf->size.y = area.y + area.h - pBuf->size.h - adj_size(7);
813 /* -------------------- */
814 redraw_group(pScale_MiniMap_Dlg->pBeginWidgetList, pWindow, 0);
815 widget_flush(pWindow);
818 #endif
820 /* ==================================================================== */
821 #ifdef SCALE_UNITINFO
822 static int move_scale_unitinfo_dlg_callback(struct widget *pWindow)
824 if (Main.event.button.button == SDL_BUTTON_LEFT) {
825 move_window_group(pScale_UnitInfo_Dlg->pBeginWidgetList, pWindow);
827 return -1;
830 static int popdown_scale_unitinfo_dlg_callback(struct widget *pWidget)
832 if (Main.event.button.button == SDL_BUTTON_LEFT) {
833 if(pScale_UnitInfo_Dlg) {
834 popdown_window_group_dialog(pScale_UnitInfo_Dlg->pBeginWidgetList,
835 pScale_UnitInfo_Dlg->pEndWidgetList);
836 FC_FREE(pScale_UnitInfo_Dlg);
837 if(pWidget) {
838 flush_dirty();
842 return -1;
845 static void Remake_UnitInfo(int w, int h)
847 SDL_Color bg_color = {255, 255, 255, 128};
849 SDL_Surface *pSurf;
850 SDL_Rect area = {pUnits_Info_Window->area.x + BLOCKU_W,
851 pUnits_Info_Window->area.y, 0, 0};
853 struct widget *pWidget = pUnits_Info_Window;
855 if(w < DEFAULT_UNITS_W - BLOCKU_W) {
856 w = (pUnits_Info_Window->size.w - pUnits_Info_Window->area.w) + DEFAULT_UNITS_W;
857 } else {
858 w += (pUnits_Info_Window->size.w - pUnits_Info_Window->area.w) + BLOCKU_W;
861 if(h < DEFAULT_UNITS_H) {
862 h = (pUnits_Info_Window->size.h - pUnits_Info_Window->area.h) + DEFAULT_UNITS_H;
863 } else {
864 h += (pUnits_Info_Window->size.h - pUnits_Info_Window->area.h);
867 /* clear area under old map window */
868 clear_surface(pWidget->dst->surface, &pWidget->size);
869 widget_mark_dirty(pWidget);
871 pWidget->size.w = w;
872 pWidget->size.h = h;
874 pWidget->size.x = Main.screen->w - w;
875 pWidget->size.y = Main.screen->h - h;
877 FREESURFACE(pWidget->theme);
878 pWidget->theme = create_surf_alpha(w, h, SDL_SWSURFACE);
880 draw_frame(pWidget->theme, 0, 0, pWidget->size.w, pWidget->size.h);
882 pSurf = ResizeSurface(current_theme->Block, BLOCKU_W,
883 pWidget->size.h - ((pUnits_Info_Window->size.h - pUnits_Info_Window->area.h)), 1);
885 blit_entire_src(pSurf, pWidget->theme, pUnits_Info_Window->area.x,
886 pUnits_Info_Window->area.y);
887 FREESURFACE(pSurf);
889 area.w = w - BLOCKU_W - (pUnits_Info_Window->size.w - pUnits_Info_Window->area.w);
890 area.h = h - (pUnits_Info_Window->size.h - pUnits_Info_Window->area.h);
891 SDL_FillRect(pWidget->theme, &area, map_rgba(pWidget->theme->format, bg_color));
893 /* economy button */
894 pWidget = pTax_Button;
895 FREESURFACE(pWidget->gfx);
896 pWidget->size.x = pWidget->dst->surface->w - w + pUnits_Info_Window->area.x
897 + (BLOCKU_W - pWidget->size.w)/2;
898 pWidget->size.y = pWidget->dst->surface->h - h + pWidget->area.y + 2;
900 /* research button */
901 pWidget = pWidget->prev;
902 FREESURFACE(pWidget->gfx);
903 pWidget->size.x = pWidget->dst->surface->w - w + pUnits_Info_Window->area.x
904 + (BLOCKU_W - pWidget->size.w)/2;
905 pWidget->size.y = pWidget->dst->surface->h - h + pUnits_Info_Window->area.y +
906 pWidget->size.h + 2;
908 /* revolution button */
909 pWidget = pWidget->prev;
910 FREESURFACE(pWidget->gfx);
911 pWidget->size.x = pWidget->dst->surface->w - w + pUnits_Info_Window->area.x
912 + (BLOCKU_W - pWidget->size.w)/2;
913 pWidget->size.y = pWidget->dst->surface->h - h + pUnits_Info_Window->area.y +
914 pWidget->size.h * 2 + 2;
916 /* show/hide unit's window button */
917 pWidget = pWidget->prev;
918 FREESURFACE(pWidget->gfx);
919 pWidget->size.x = pWidget->dst->surface->w - w + pUnits_Info_Window->area.x
920 + (BLOCKU_W - pWidget->size.w)/2;
921 pWidget->size.y = pUnits_Info_Window->area.y + pUnits_Info_Window->area.h -
922 pWidget->size.h - 2;
924 unitinfo_w = w;
925 unitinfo_h = h;
929 int resize_unit_info(void)
931 struct widget *pInfo_Window = get_unit_info_window_widget();
933 int w = INFO_WIDTH * map.xsize;
934 int h = INFO_HEIGHT * map.ysize;
935 int current_w = pUnits_Info_Window->size.w - BLOCKU_W -
936 (pInfo_Window->size.w - pInfo_Window->area.w);
937 int current_h = pUnits_Info_Window->size.h -
938 (pInfo_Window->size.h - pInfo_Window->area.h);
940 if ((((current_w > DEFAULT_UNITS_W - BLOCKU_W)
941 || (w > DEFAULT_UNITS_W - BLOCKU_W)) && (current_w != w)) ||
942 (((current_h > DEFAULT_UNITS_H) || (h > DEFAULT_UNITS_H)) && (current_h != h))) {
943 Remake_UnitInfo(w, h);
946 if (C_S_RUNNING == client_state()) {
947 menus_update();
949 update_unit_info_label(get_units_in_focus());
951 return 0;
954 static int up_info_width_callback(struct widget *pWidget)
956 if (Main.event.button.button == SDL_BUTTON_LEFT) {
957 widget_redraw(pWidget);
958 widget_mark_dirty(pWidget);
959 if (Main.screen->w - ((INFO_WIDTH + 1) * map.xsize + BLOCKU_W +
960 (pMiniMap_Window->size.w - pMiniMap_Window->area.w)) >=
961 pMiniMap_Window->size.x + pMiniMap_Window->size.w) {
962 INFO_WIDTH++;
963 resize_unit_info();
965 flush_dirty();
967 return -1;
970 static int down_info_width_callback(struct widget *pWidget)
972 if (Main.event.button.button == SDL_BUTTON_LEFT) {
973 widget_redraw(pWidget);
974 widget_mark_dirty(pWidget);
975 if(INFO_WIDTH > INFO_WIDTH_MIN) {
976 INFO_WIDTH--;
977 resize_unit_info();
979 flush_dirty();
981 return -1;
984 static int up_info_height_callback(struct widget *pWidget)
986 if (Main.event.button.button == SDL_BUTTON_LEFT) {
987 widget_redraw(pWidget);
988 widget_mark_dirty(pWidget);
989 if(Main.screen->h - ((INFO_HEIGHT + 1) * map.ysize +
990 (pUnits_Info_Window->size.h - pUnits_Info_Window->area.h)) >= adj_size(40)) {
991 INFO_HEIGHT++;
992 resize_unit_info();
994 flush_dirty();
996 return -1;
999 static int down_info_height_callback(struct widget *pWidget)
1001 if (Main.event.button.button == SDL_BUTTON_LEFT) {
1002 widget_redraw(pWidget);
1003 widget_mark_dirty(pWidget);
1004 if(INFO_HEIGHT > INFO_HEIGHT_MIN) {
1005 INFO_HEIGHT--;
1006 resize_unit_info();
1008 flush_dirty();
1010 return -1;
1013 static void popup_unitinfo_scale_dialog(void)
1016 #ifndef SCALE_UNITINFO
1017 return;
1018 #endif
1020 SDL_Surface *pText1, *pText2;
1021 SDL_String16 *pStr = NULL;
1022 struct widget *pWindow = NULL;
1023 struct widget *pBuf = NULL;
1024 int window_x = 0, window_y = 0;
1025 SDL_Rect area;
1027 if(pScale_UnitInfo_Dlg || !(SDL_Client_Flags & CF_UNITINFO_SHOWN)) {
1028 return;
1031 pScale_UnitInfo_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
1033 /* create window */
1034 pStr = create_str16_from_char(_("Scale Unit Info"), adj_font(12));
1035 pStr->style |= TTF_STYLE_BOLD;
1036 pWindow = create_window_skeleton(NULL, pStr, 0);
1037 pWindow->action = move_scale_unitinfo_dlg_callback;
1038 set_wstate(pWindow, FC_WS_NORMAL);
1039 add_to_gui_list(ID_WINDOW, pWindow);
1040 pScale_UnitInfo_Dlg->pEndWidgetList = pWindow;
1042 area = pWindow->area;
1044 pStr = create_str16_from_char(_("Width"), adj_font(12));
1045 pText1 = create_text_surf_from_str16(pStr);
1046 area.w = MAX(area.w, pText1->w + adj_size(30));
1047 area.h += MAX(adj_size(20), pText1->h + adj_size(4));
1048 copy_chars_to_string16(pStr, _("Height"));
1049 pText2 = create_text_surf_from_str16(pStr);
1050 area.w = MAX(area.w, pText2->w + adj_size(30));
1051 area.h += MAX(adj_size(20), pText2->h + adj_size(4));
1052 FREESTRING16(pStr);
1054 /* ----------------- */
1055 pBuf = create_themeicon_button(current_theme->L_ARROW_Icon, pWindow->dst, NULL, 0);
1056 pBuf->action = down_info_width_callback;
1057 set_wstate(pBuf, FC_WS_NORMAL);
1058 add_to_gui_list(ID_BUTTON, pBuf);
1059 area.h += pBuf->size.h;
1061 pBuf = create_themeicon_button(current_theme->R_ARROW_Icon, pWindow->dst, NULL, 0);
1062 pBuf->action = up_info_width_callback;
1063 set_wstate(pBuf, FC_WS_NORMAL);
1064 add_to_gui_list(ID_BUTTON, pBuf);
1066 /* ------------ */
1067 pBuf = create_themeicon_button(current_theme->L_ARROW_Icon, pWindow->dst, NULL, 0);
1068 pBuf->action = down_info_height_callback;
1069 set_wstate(pBuf, FC_WS_NORMAL);
1070 add_to_gui_list(ID_BUTTON, pBuf);
1071 area.h += pBuf->size.h + adj_size(10);
1073 pBuf = create_themeicon_button(current_theme->R_ARROW_Icon, pWindow->dst, NULL, 0);
1074 pBuf->action = up_info_height_callback;
1075 set_wstate(pBuf, FC_WS_NORMAL);
1076 add_to_gui_list(ID_BUTTON, pBuf);
1077 area.w = MAX(area.w , pBuf->size.w * 2 + adj_size(20));
1079 /* ------------ */
1080 pStr = create_str16_from_char(_("Exit"), adj_font(12));
1081 pBuf = create_themeicon_button(current_theme->CANCEL_Icon,
1082 pWindow->dst, pStr, 0);
1083 pBuf->action = popdown_scale_unitinfo_dlg_callback;
1084 set_wstate(pBuf, FC_WS_NORMAL);
1085 pScale_UnitInfo_Dlg->pBeginWidgetList = pBuf;
1086 add_to_gui_list(ID_BUTTON, pBuf);
1087 area.h += pBuf->size.h + adj_size(10);
1088 area.w = MAX(area.w, pBuf->size.w + adj_size(20));
1090 resize_window(pWindow, NULL, get_theme_color(COLOR_THEME_BACKGROUND),
1091 (pWindow->size.w - pWindow->area.w) + area.w,
1092 (pWindow->size.h - pWindow->area.h) + area.h);
1094 area = pWindow->area;
1096 /* ------------ */
1098 if (Main.event.motion.x + pWindow->size.w > Main.screen->w) {
1099 if (Main.event.motion.x - pWindow->size.w >= 0) {
1100 window_x = Main.event.motion.x - pWindow->size.w;
1101 } else {
1102 window_x = (Main.screen->w - pWindow->size.w) / 2;
1104 } else {
1105 window_x = Main.event.motion.x;
1108 if (Main.event.motion.y + pWindow->size.h >= Main.screen->h) {
1109 if (Main.event.motion.y - pWindow->size.h >= 0) {
1110 window_y = Main.event.motion.y - pWindow->size.h;
1111 } else {
1112 window_y = (pWindow->dst->surface->h - pWindow->size.h) / 2;
1114 } else {
1115 window_y = Main.event.motion.y;
1118 widget_set_position(pWindow, window_x, window_y);
1120 /* width left button */
1121 pBuf = pWindow->prev;
1122 pBuf->size.y = area.y + MAX(adj_size(20), pText1->h + adj_size(4));
1123 pBuf->size.x = area.x + (area.w - pBuf->size.w * 2) / 2;
1124 blit_entire_src(pText1, pWindow->theme, adj_size(15), pBuf->size.y
1125 - area.y - pText1->h - adj_size(2));
1126 FREESURFACE(pText1);
1128 /* width right button */
1129 pBuf->prev->size.y = pBuf->size.y;
1130 pBuf->prev->size.x = pBuf->size.x + pBuf->size.w;
1132 /* height left button */
1133 pBuf = pBuf->prev->prev;
1134 pBuf->size.y = pBuf->next->next->size.y +
1135 pBuf->next->next->size.h + MAX(adj_size(20), pText2->h + adj_size(4));
1136 pBuf->size.x = area.x + (area.w - pBuf->size.w * 2) / 2;
1138 blit_entire_src(pText2, pWindow->theme, adj_size(15), pBuf->size.y - area.y - pText2->h - adj_size(2));
1139 FREESURFACE(pText2);
1141 /* height right button */
1142 pBuf->prev->size.y = pBuf->size.y;
1143 pBuf->prev->size.x = pBuf->size.x + pBuf->size.w;
1145 /* exit button */
1146 pBuf = pBuf->prev->prev;
1147 pBuf->size.x = area.x + (area.w - pBuf->size.w) / 2;
1148 pBuf->size.y = area.y + area.h - pBuf->size.h - adj_size(7);
1150 if (!INFO_HEIGHT) {
1151 INFO_WIDTH_MIN = (DEFAULT_UNITS_W - BLOCKU_W) / map.xsize;
1152 if (INFO_WIDTH_MIN == 1) {
1153 INFO_WIDTH_MIN = 0;
1155 INFO_HEIGHT_MIN = DEFAULT_UNITS_H / map.ysize;
1156 if (!INFO_HEIGHT_MIN) {
1157 INFO_HEIGHT_MIN = 1;
1159 INFO_WIDTH = INFO_WIDTH_MIN;
1160 INFO_HEIGHT = INFO_HEIGHT_MIN;
1163 /* -------------------- */
1164 redraw_group(pScale_UnitInfo_Dlg->pBeginWidgetList, pWindow, 0);
1165 widget_flush(pWindow);
1168 #endif
1170 /* ==================================================================== */
1171 static int minimap_window_callback(struct widget *pWidget)
1173 int mouse_x, mouse_y;
1175 switch(Main.event.button.button) {
1176 case SDL_BUTTON_RIGHT:
1177 mouse_x = Main.event.motion.x - pMiniMap_Window->dst->dest_rect.x -
1178 pMiniMap_Window->area.x - overview_start_x;
1179 mouse_y = Main.event.motion.y - pMiniMap_Window->dst->dest_rect.y -
1180 pMiniMap_Window->area.y - overview_start_y;
1181 if ((SDL_Client_Flags & CF_OVERVIEW_SHOWN) &&
1182 (mouse_x >= 0) && (mouse_x < overview_w) &&
1183 (mouse_y >= 0) && (mouse_y < overview_h)) {
1185 int map_x, map_y;
1187 overview_to_map_pos(&map_x, &map_y, mouse_x, mouse_y);
1188 center_tile_mapcanvas(map_pos_to_tile(map_x, map_y));
1191 break;
1192 case SDL_BUTTON_MIDDLE:
1193 /* FIXME: scaling needs to be fixed */
1194 #ifdef SCALE_MINIMAP
1195 popup_minimap_scale_dialog();
1196 #endif
1197 break;
1198 default:
1199 break;
1201 return -1;
1204 static int unit_info_window_callback(struct widget *pWidget)
1206 switch(Main.event.button.button) {
1207 #if 0
1208 case SDL_BUTTON_LEFT:
1210 break;
1211 #endif
1212 case SDL_BUTTON_MIDDLE:
1213 request_center_focus_unit();
1214 break;
1215 case SDL_BUTTON_RIGHT:
1216 #ifdef SCALE_UNITINFO
1217 popup_unitinfo_scale_dialog();
1218 #endif
1219 break;
1220 default:
1221 key_unit_wait();
1222 break;
1225 return -1;
1228 /* ============================== Public =============================== */
1230 /**************************************************************************
1231 This Function is used when resize Main.screen.
1232 We must set new Units Info Win. start position.
1233 **************************************************************************/
1234 void set_new_unitinfo_window_pos(void)
1236 struct widget *pUnit_Window = pUnits_Info_Window;
1237 struct widget *pWidget;
1238 SDL_Rect area;
1240 if (SDL_Client_Flags & CF_UNITINFO_SHOWN) {
1241 widget_set_position(pUnits_Info_Window,
1242 Main.screen->w - pUnits_Info_Window->size.w,
1243 Main.screen->h - pUnits_Info_Window->size.h);
1244 } else {
1245 widget_set_position(pUnit_Window,
1246 Main.screen->w - BLOCKU_W - current_theme->FR_Right->w,
1247 Main.screen->h - pUnits_Info_Window->size.h);
1250 area.x = pUnits_Info_Window->area.x;
1251 area.y = pUnits_Info_Window->area.y;
1252 area.w = BLOCKU_W;
1253 area.h = DEFAULT_UNITS_H;
1255 /* ID_ECONOMY */
1256 pWidget = pTax_Button;
1257 widget_set_area(pWidget, area);
1258 widget_set_position(pWidget,
1259 area.x + (area.w - pWidget->size.w)/2,
1260 area.y + 2);
1262 /* ID_RESEARCH */
1263 pWidget = pWidget->prev;
1264 widget_set_area(pWidget, area);
1265 widget_set_position(pWidget,
1266 area.x + (area.w - pWidget->size.w)/2,
1267 area.y + 2 + pWidget->size.h);
1269 /* ID_REVOLUTION */
1270 pWidget = pWidget->prev;
1271 widget_set_area(pWidget, area);
1272 widget_set_position(pWidget,
1273 area.x + (area.w - pWidget->size.w)/2,
1274 area.y + 2 + (pWidget->size.h * 2));
1276 /* ID_TOGGLE_UNITS_WINDOW_BUTTON */
1277 pWidget = pWidget->prev;
1278 widget_set_area(pWidget, area);
1279 widget_set_position(pWidget,
1280 area.x + (area.w - pWidget->size.w)/2,
1281 area.y + area.h - pWidget->size.h - 2);
1284 /**************************************************************************
1285 This Function is used when resize Main.screen.
1286 We must set new MiniMap start position.
1287 **************************************************************************/
1288 void set_new_minimap_window_pos(void)
1290 struct widget *pWidget;
1291 SDL_Rect area;
1293 widget_set_position(pMiniMap_Window,
1295 Main.screen->h - pMiniMap_Window->size.h);
1297 area.x = pMiniMap_Window->size.w - current_theme->FR_Right->w - BLOCKM_W;
1298 area.y = pMiniMap_Window->area.y;
1299 area.w = BLOCKM_W;
1300 area.h = pMiniMap_Window->area.h;
1303 /* ID_NEW_TURN */
1304 pWidget = pMiniMap_Window->prev;
1305 widget_set_area(pWidget, area);
1306 widget_set_position(pWidget,
1307 area.x + adj_size(2) + pWidget->size.w,
1308 area.y + 2);
1310 /* PLAYERS BUTTON */
1311 pWidget = pWidget->prev;
1312 widget_set_area(pWidget, area);
1313 widget_set_position(pWidget,
1314 area.x + adj_size(2) + pWidget->size.w,
1315 area.y + pWidget->size.h + 2);
1317 /* ID_FIND_CITY */
1318 pWidget = pWidget->prev;
1319 widget_set_area(pWidget, area);
1320 widget_set_position(pWidget,
1321 area.x + adj_size(2) + pWidget->size.w,
1322 area.y + pWidget->size.h * 2 + 2);
1324 /* UNITS BUTTON */
1325 pWidget = pWidget->prev;
1326 widget_set_area(pWidget, area);
1327 widget_set_position(pWidget,
1328 area.x + adj_size(2),
1329 area.y + 2);
1331 /* ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON */
1332 pWidget = pWidget->prev;
1333 widget_set_area(pWidget, area);
1334 widget_set_position(pWidget,
1335 area.x + adj_size(2),
1336 area.y + pWidget->size.h + 2);
1338 /* Toggle minimap mode */
1339 pWidget = pWidget->prev;
1340 widget_set_area(pWidget, area);
1341 widget_set_position(pWidget,
1342 area.x + adj_size(2),
1343 area.y + pWidget->size.h * 2 + 2);
1345 #ifdef SMALL_SCREEN
1346 /* ID_TOGGLE_MAP_WINDOW_BUTTON */
1347 pWidget = pWidget->prev;
1348 widget_set_area(pWidget, area);
1349 widget_set_position(pWidget,
1350 area.x + adj_size(2),
1351 area.y + area.h - pWidget->size.h - 2);
1352 #endif
1354 /* ID_TOGGLE_MAP_WINDOW_BUTTON */
1355 pWidget = pWidget->prev;
1356 widget_set_area(pWidget, area);
1357 widget_set_position(pWidget,
1358 area.x + adj_size(2) + pWidget->size.w,
1359 area.y + area.h - pWidget->size.h - 2);
1362 void popup_unitinfo_window(void) {
1363 struct widget *pWidget, *pWindow;
1364 SDL_Surface *pIcon_theme = NULL;
1365 char buf[256];
1367 if (pUnitInfo_Dlg) {
1368 return;
1371 pUnitInfo_Dlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
1373 /* pUnits_Info_Window */
1374 pWindow = create_window_skeleton(NULL, NULL, 0);
1376 resize_window(pWindow, NULL, NULL,
1377 (pWindow->size.w - pWindow->area.w) + DEFAULT_UNITS_W,
1378 (pWindow->size.h - pWindow->area.h) + DEFAULT_UNITS_H);
1380 draw_frame(pWindow->theme, 0, 0, pWindow->size.w, pWindow->size.h);
1382 unitinfo_w = pWindow->size.w;
1383 unitinfo_h = pWindow->size.h;
1385 pIcon_theme = ResizeSurface(current_theme->Block,
1386 pWindow->area.w, pWindow->area.h, 1);
1388 blit_entire_src(pIcon_theme, pWindow->theme, pWindow->area.x, pWindow->area.y);
1389 FREESURFACE(pIcon_theme);
1391 pWindow->action = unit_info_window_callback;
1393 add_to_gui_list(ID_UNITS_WINDOW, pWindow);
1395 pUnits_Info_Window = pWindow;
1397 pUnitInfo_Dlg->pEndWidgetList = pUnits_Info_Window;
1398 pUnits_Info_Window->private_data.adv_dlg = pUnitInfo_Dlg;
1400 /* economy button */
1401 pWidget = create_icon2(get_tax_surface(O_GOLD), pUnits_Info_Window->dst,
1402 WF_FREE_GFX | WF_WIDGET_HAS_INFO_LABEL
1403 | WF_RESTORE_BACKGROUND | WF_FREE_THEME);
1405 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Economy"), "F5");
1406 pWidget->info_label = create_str16_from_char(buf, adj_font(12));
1407 pWidget->action = economy_callback;
1408 pWidget->key = SDLK_F5;
1410 add_to_gui_list(ID_ECONOMY, pWidget);
1412 pTax_Button = pWidget;
1414 /* research button */
1415 pWidget = create_icon2(adj_surf(GET_SURF(client_research_sprite())),
1416 pUnits_Info_Window->dst,
1417 WF_FREE_GFX | WF_WIDGET_HAS_INFO_LABEL
1418 | WF_RESTORE_BACKGROUND | WF_FREE_THEME);
1419 /* TRANS: Research report action */
1420 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Research"), "F6");
1421 pWidget->info_label = create_str16_from_char(buf, adj_font(12));
1422 pWidget->action = research_callback;
1423 pWidget->key = SDLK_F6;
1425 add_to_gui_list(ID_RESEARCH, pWidget);
1427 pResearch_Button = pWidget;
1429 /* revolution button */
1430 pWidget = create_icon2(adj_surf(GET_SURF(client_government_sprite())),
1431 pUnits_Info_Window->dst,
1432 WF_FREE_GFX | WF_WIDGET_HAS_INFO_LABEL
1433 | WF_RESTORE_BACKGROUND | WF_FREE_THEME);
1434 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Revolution"), "Ctrl+Shift+R");
1435 pWidget->info_label = create_str16_from_char(buf, adj_font(12));
1436 pWidget->action = revolution_callback;
1437 pWidget->key = SDLK_r;
1438 pWidget->mod = KMOD_CTRL | KMOD_SHIFT;
1440 add_to_gui_list(ID_REVOLUTION, pWidget);
1442 pRevolution_Button = pWidget;
1444 /* show/hide unit's window button */
1446 /* make UNITS Icon */
1447 pIcon_theme = create_surf_alpha(current_theme->MAP_Icon->w,
1448 current_theme->MAP_Icon->h, SDL_SWSURFACE);
1449 alphablit(current_theme->MAP_Icon, NULL, pIcon_theme, NULL);
1450 alphablit(current_theme->R_ARROW_Icon, NULL, pIcon_theme, NULL);
1452 pWidget = create_themeicon(pIcon_theme, pUnits_Info_Window->dst,
1453 WF_FREE_GFX | WF_FREE_THEME |
1454 WF_RESTORE_BACKGROUND
1455 | WF_WIDGET_HAS_INFO_LABEL);
1456 pWidget->info_label = create_str16_from_char(_("Hide Unit Info Window"),
1457 adj_font(12));
1459 pWidget->action = toggle_unit_info_window_callback;
1461 add_to_gui_list(ID_TOGGLE_UNITS_WINDOW_BUTTON, pWidget);
1463 pUnitInfo_Dlg->pBeginWidgetList = pWidget;
1465 SDL_Client_Flags |= CF_UNITINFO_SHOWN;
1467 set_new_unitinfo_window_pos();
1469 widget_redraw(pUnits_Info_Window);
1472 void show_unitinfo_window_buttons(void)
1474 struct widget *pWidget = get_unit_info_window_widget();
1476 /* economy button */
1477 pWidget = pWidget->prev;
1478 clear_wflag(pWidget, WF_HIDDEN);
1480 /* research button */
1481 pWidget = pWidget->prev;
1482 clear_wflag(pWidget, WF_HIDDEN);
1484 /* revolution button */
1485 pWidget = pWidget->prev;
1486 clear_wflag(pWidget, WF_HIDDEN);
1488 /* show/hide unit's window button */
1489 pWidget = pWidget->prev;
1490 clear_wflag(pWidget, WF_HIDDEN);
1493 void hide_unitinfo_window_buttons(void)
1495 struct widget *pWidget = get_unit_info_window_widget();
1497 /* economy button */
1498 pWidget = pWidget->prev;
1499 set_wflag(pWidget, WF_HIDDEN);
1501 /* research button */
1502 pWidget = pWidget->prev;
1503 set_wflag(pWidget, WF_HIDDEN);
1505 /* revolution button */
1506 pWidget = pWidget->prev;
1507 set_wflag(pWidget, WF_HIDDEN);
1509 /* show/hide unit's window button */
1510 pWidget = pWidget->prev;
1511 set_wflag(pWidget, WF_HIDDEN);
1514 void disable_unitinfo_window_buttons(void)
1516 struct widget *pWidget = get_unit_info_window_widget();
1518 /* economy button */
1519 pWidget = pWidget->prev;
1520 set_wstate(pWidget, FC_WS_DISABLED);
1522 /* research button */
1523 pWidget = pWidget->prev;
1524 set_wstate(pWidget, FC_WS_DISABLED);
1526 /* revolution button */
1527 pWidget = pWidget->prev;
1528 set_wstate(pWidget, FC_WS_DISABLED);
1531 void popdown_unitinfo_window(void)
1533 if (pUnitInfo_Dlg) {
1534 popdown_window_group_dialog(pUnitInfo_Dlg->pBeginWidgetList, pUnitInfo_Dlg->pEndWidgetList);
1535 FC_FREE(pUnitInfo_Dlg);
1536 SDL_Client_Flags &= ~CF_UNITINFO_SHOWN;
1540 void popup_minimap_window(void) {
1541 struct widget *pWidget, *pWindow;
1542 SDL_Surface *pIcon_theme = NULL;
1543 SDL_Color black = {0, 0, 0, 255};
1544 char buf[256];
1546 if (pMiniMap_Dlg) {
1547 return;
1550 pMiniMap_Dlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
1552 /* pMiniMap_Window */
1553 pWindow = create_window_skeleton(NULL, NULL, 0);
1555 resize_window(pWindow, NULL, &black,
1556 (pWindow->size.w - pWindow->area.w) + overview_w + BLOCKM_W,
1557 (pWindow->size.h - pWindow->area.h) + overview_h);
1559 draw_frame(pWindow->theme, 0, 0, pWindow->size.w, pWindow->size.h);
1561 pIcon_theme = ResizeSurface(current_theme->Block, BLOCKM_W, pWindow->area.h, 1);
1562 blit_entire_src(pIcon_theme, pWindow->theme,
1563 pWindow->area.x + pWindow->area.w - pIcon_theme->w, pWindow->area.y);
1564 FREESURFACE(pIcon_theme);
1566 pWindow->action = minimap_window_callback;
1568 add_to_gui_list(ID_MINI_MAP_WINDOW, pWindow);
1570 pMiniMap_Window = pWindow;
1571 pMiniMap_Dlg->pEndWidgetList = pMiniMap_Window;
1573 /* new turn button */
1574 pWidget = create_themeicon(current_theme->NEW_TURN_Icon, pMiniMap_Window->dst,
1575 WF_WIDGET_HAS_INFO_LABEL
1576 | WF_RESTORE_BACKGROUND);
1577 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Turn Done"), _("Shift+Return"));
1578 pWidget->info_label = create_str16_from_char(buf, adj_font(12));
1579 pWidget->action = end_turn_callback;
1580 pWidget->key = SDLK_RETURN;
1581 pWidget->mod = KMOD_SHIFT;
1583 add_to_gui_list(ID_NEW_TURN, pWidget);
1585 pNew_Turn_Button = pWidget;
1587 /* players button */
1588 pWidget = create_themeicon(current_theme->PLAYERS_Icon, pMiniMap_Window->dst,
1589 WF_WIDGET_HAS_INFO_LABEL
1590 | WF_RESTORE_BACKGROUND);
1591 /* TRANS: Nations report action */
1592 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Nations"), "F3");
1593 pWidget->info_label = create_str16_from_char(buf, adj_font(12));
1594 pWidget->action = players_action_callback;
1595 pWidget->key = SDLK_F3;
1597 add_to_gui_list(ID_PLAYERS, pWidget);
1599 /* find city button */
1600 pWidget = create_themeicon(current_theme->FindCity_Icon, pMiniMap_Window->dst,
1601 WF_WIDGET_HAS_INFO_LABEL
1602 | WF_RESTORE_BACKGROUND);
1603 fc_snprintf(buf, sizeof(buf), "%s (%s)\n%s\n%s (%s)", _("Cities Report"),
1604 "F4", _("or"), _("Find City"), "Ctrl+F");
1605 pWidget->info_label = create_str16_from_char(buf, adj_font(12));
1606 pWidget->info_label->style |= SF_CENTER;
1607 pWidget->action = cities_action_callback;
1608 pWidget->key = SDLK_f;
1609 pWidget->mod = KMOD_CTRL;
1611 add_to_gui_list(ID_CITIES, pWidget);
1613 pFind_City_Button = pWidget;
1615 /* units button */
1616 pWidget = create_themeicon(current_theme->UNITS2_Icon, pMiniMap_Window->dst,
1617 WF_WIDGET_HAS_INFO_LABEL
1618 | WF_RESTORE_BACKGROUND);
1619 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Units"), "F2");
1620 pWidget->info_label = create_str16_from_char(buf, adj_font(12));
1621 pWidget->action = units_action_callback;
1622 pWidget->key = SDLK_F2;
1624 add_to_gui_list(ID_UNITS, pWidget);
1626 /* show/hide log window button */
1627 pWidget = create_themeicon(current_theme->LOG_Icon, pMiniMap_Window->dst,
1628 WF_WIDGET_HAS_INFO_LABEL
1629 | WF_RESTORE_BACKGROUND);
1630 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Hide Messages"), "F9");
1631 pWidget->info_label = create_str16_from_char(buf, adj_font(12));
1632 pWidget->action = toggle_msg_window_callback;
1633 pWidget->key = SDLK_F9;
1635 add_to_gui_list(ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON, pWidget);
1637 /* toggle minimap mode button */
1638 pWidget = create_themeicon(current_theme->BORDERS_Icon, pMiniMap_Window->dst,
1639 WF_WIDGET_HAS_INFO_LABEL
1640 | WF_RESTORE_BACKGROUND);
1641 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Toggle Mini Map Mode"), "Shift+\\");
1642 pWidget->info_label = create_str16_from_char(buf, adj_font(12));
1643 pWidget->action = toggle_minimap_mode_callback;
1644 pWidget->key = SDLK_BACKSLASH;
1645 pWidget->mod = KMOD_SHIFT;
1647 add_to_gui_list(ID_TOGGLE_MINIMAP_MODE, pWidget);
1649 #ifdef SMALL_SCREEN
1650 /* options button */
1651 pOptions_Button = create_themeicon(current_theme->Options_Icon,
1652 pMiniMap_Window->dst,
1653 WF_WIDGET_HAS_INFO_LABEL
1654 | WF_RESTORE_BACKGROUND);
1655 fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Options"), "Esc");
1656 pOptions_Button->info_label = create_str16_from_char(buf, adj_font(12));
1658 pOptions_Button->action = optiondlg_callback;
1659 pOptions_Button->key = SDLK_ESCAPE;
1661 add_to_gui_list(ID_CLIENT_OPTIONS, pOptions_Button);
1662 #endif
1664 /* show/hide minimap button */
1666 /* make Map Icon */
1667 pIcon_theme =
1668 create_surf_alpha(current_theme->MAP_Icon->w,
1669 current_theme->MAP_Icon->h, SDL_SWSURFACE);
1670 alphablit(current_theme->MAP_Icon, NULL, pIcon_theme, NULL);
1671 alphablit(current_theme->L_ARROW_Icon, NULL, pIcon_theme, NULL);
1673 pWidget = create_themeicon(pIcon_theme, pMiniMap_Window->dst,
1674 WF_FREE_GFX | WF_FREE_THEME |
1675 WF_WIDGET_HAS_INFO_LABEL
1676 | WF_RESTORE_BACKGROUND);
1678 pWidget->info_label = create_str16_from_char(_("Hide Mini Map"),
1679 adj_font(12));
1680 pWidget->action = toggle_map_window_callback;
1682 add_to_gui_list(ID_TOGGLE_MAP_WINDOW_BUTTON, pWidget);
1684 pMiniMap_Dlg->pBeginWidgetList = pWidget;
1686 SDL_Client_Flags |= CF_OVERVIEW_SHOWN;
1688 set_new_minimap_window_pos();
1690 widget_redraw(pMiniMap_Window);
1693 void show_minimap_window_buttons(void)
1695 struct widget *pWidget = get_minimap_window_widget();
1697 /* new turn button */
1698 pWidget = pWidget->prev;
1699 clear_wflag(pWidget, WF_HIDDEN);
1701 /* players button */
1702 pWidget = pWidget->prev;
1703 clear_wflag(pWidget, WF_HIDDEN);
1705 /* find city button */
1706 pWidget = pWidget->prev;
1707 clear_wflag(pWidget, WF_HIDDEN);
1709 /* units button */
1710 pWidget = pWidget->prev;
1711 clear_wflag(pWidget, WF_HIDDEN);
1713 /* show/hide log window button */
1714 pWidget = pWidget->prev;
1715 clear_wflag(pWidget, WF_HIDDEN);
1717 /* toggle minimap mode button */
1718 pWidget = pWidget->prev;
1719 clear_wflag(pWidget, WF_HIDDEN);
1721 #ifdef SMALL_SCREEN
1722 /* options button */
1723 pWidget = pWidget->prev;
1724 clear_wflag(pWidget, WF_HIDDEN);
1725 #endif
1727 /* show/hide minimap button */
1728 pWidget = pWidget->prev;
1729 clear_wflag(pWidget, WF_HIDDEN);
1732 void hide_minimap_window_buttons(void)
1734 struct widget *pWidget = get_minimap_window_widget();
1736 /* new turn button */
1737 pWidget = pWidget->prev;
1738 set_wflag(pWidget, WF_HIDDEN);
1740 /* players button */
1741 pWidget = pWidget->prev;
1742 set_wflag(pWidget, WF_HIDDEN);
1744 /* find city button */
1745 pWidget = pWidget->prev;
1746 set_wflag(pWidget, WF_HIDDEN);
1748 /* units button */
1749 pWidget = pWidget->prev;
1750 set_wflag(pWidget, WF_HIDDEN);
1752 /* show/hide log window button */
1753 pWidget = pWidget->prev;
1754 set_wflag(pWidget, WF_HIDDEN);
1756 /* toggle minimap mode button */
1757 pWidget = pWidget->prev;
1758 set_wflag(pWidget, WF_HIDDEN);
1760 #ifdef SMALL_SCREEN
1761 /* options button */
1762 pWidget = pWidget->prev;
1763 set_wflag(pWidget, WF_HIDDEN);
1764 #endif
1766 /* show/hide minimap button */
1767 pWidget = pWidget->prev;
1768 set_wflag(pWidget, WF_HIDDEN);
1771 void redraw_minimap_window_buttons(void)
1773 struct widget *pWidget = get_minimap_window_widget();
1775 /* new turn button */
1776 pWidget = pWidget->prev;
1777 widget_redraw(pWidget);
1779 /* players button */
1780 pWidget = pWidget->prev;
1781 widget_redraw(pWidget);
1783 /* find city button */
1784 pWidget = pWidget->prev;
1785 widget_redraw(pWidget);
1787 /* units button */
1788 pWidget = pWidget->prev;
1789 widget_redraw(pWidget);
1790 /* show/hide log window button */
1791 pWidget = pWidget->prev;
1792 widget_redraw(pWidget);
1794 /* toggle minimap mode button */
1795 pWidget = pWidget->prev;
1796 widget_redraw(pWidget);
1798 #ifdef SMALL_SCREEN
1799 /* options button */
1800 pWidget = pWidget->prev;
1801 widget_redraw(pWidget);
1802 #endif
1804 /* show/hide minimap button */
1805 pWidget = pWidget->prev;
1806 widget_redraw(pWidget);
1809 void disable_minimap_window_buttons(void)
1811 struct widget *pWidget = get_minimap_window_widget();
1813 /* new turn button */
1814 pWidget = pWidget->prev;
1815 set_wstate(pWidget, FC_WS_DISABLED);
1817 /* players button */
1818 pWidget = pWidget->prev;
1819 set_wstate(pWidget, FC_WS_DISABLED);
1821 /* find city button */
1822 pWidget = pWidget->prev;
1823 set_wstate(pWidget, FC_WS_DISABLED);
1825 /* units button */
1826 pWidget = pWidget->prev;
1827 set_wstate(pWidget, FC_WS_DISABLED);
1829 /* show/hide log window button */
1830 pWidget = pWidget->prev;
1831 set_wstate(pWidget, FC_WS_DISABLED);
1833 #ifdef SMALL_SCREEN
1834 /* options button */
1835 pWidget = pWidget->prev;
1836 set_wstate(pWidget, FC_WS_DISABLED);
1837 #endif
1840 void popdown_minimap_window(void)
1842 if (pMiniMap_Dlg) {
1843 popdown_window_group_dialog(pMiniMap_Dlg->pBeginWidgetList, pMiniMap_Dlg->pEndWidgetList);
1844 FC_FREE(pMiniMap_Dlg);
1845 SDL_Client_Flags &= ~CF_OVERVIEW_SHOWN;
1849 void show_game_page(void)
1851 struct widget *pWidget;
1852 SDL_Surface *pIcon_theme = NULL;
1854 if (SDL_Client_Flags & CF_MAP_UNIT_W_CREATED) {
1855 return;
1858 popup_minimap_window();
1859 popup_unitinfo_window();
1860 SDL_Client_Flags |= CF_MAP_UNIT_W_CREATED;
1862 #ifndef SMALL_SCREEN
1863 init_options_button();
1864 #endif
1866 /* cooling icon */
1867 pIcon_theme = adj_surf(GET_SURF(client_cooling_sprite()));
1868 fc_assert(pIcon_theme != NULL);
1869 pWidget = create_iconlabel(pIcon_theme, Main.gui, NULL, WF_FREE_THEME);
1871 #ifdef SMALL_SCREEN
1872 widget_set_position(pWidget,
1873 pWidget->dst->surface->w - pWidget->size.w - adj_size(10),
1875 #else
1876 widget_set_position(pWidget,
1877 pWidget->dst->surface->w - pWidget->size.w - adj_size(10),
1878 adj_size(10));
1879 #endif
1881 add_to_gui_list(ID_COOLING_ICON, pWidget);
1883 /* warming icon */
1884 pIcon_theme = adj_surf(GET_SURF(client_warming_sprite()));
1885 fc_assert(pIcon_theme != NULL);
1887 pWidget = create_iconlabel(pIcon_theme, Main.gui, NULL, WF_FREE_THEME);
1889 #ifdef SMALL_SCREEN
1890 widget_set_position(pWidget,
1891 pWidget->dst->surface->w - pWidget->size.w * 2 - adj_size(10),
1893 #else
1894 widget_set_position(pWidget,
1895 pWidget->dst->surface->w - pWidget->size.w * 2 - adj_size(10),
1896 adj_size(10));
1897 #endif
1899 add_to_gui_list(ID_WARMING_ICON, pWidget);
1901 /* create order buttons */
1902 create_units_order_widgets();
1904 /* enable options button and order widgets */
1905 enable_options_button();
1906 enable_order_buttons();
1909 void close_game_page(void)
1911 struct widget *pWidget;
1913 del_widget_from_gui_list(pOptions_Button);
1915 pWidget = get_widget_pointer_form_main_list(ID_COOLING_ICON);
1916 del_widget_from_gui_list(pWidget);
1918 pWidget = get_widget_pointer_form_main_list(ID_WARMING_ICON);
1919 del_widget_from_gui_list(pWidget);
1921 delete_units_order_widgets();
1923 popdown_minimap_window();
1924 popdown_unitinfo_window();
1925 SDL_Client_Flags &= ~CF_MAP_UNIT_W_CREATED;
1928 static void disable_minimap_widgets(void)
1930 struct widget *pBuf, *pEnd;
1932 pBuf = pMiniMap_Window;
1933 set_wstate(pBuf, FC_WS_DISABLED);
1935 /* new turn button */
1936 pBuf = pBuf->prev;
1937 pEnd = pBuf;
1938 set_wstate(pBuf, FC_WS_DISABLED);
1940 /* players button */
1941 pBuf = pBuf->prev;
1942 set_wstate(pBuf, FC_WS_DISABLED);
1944 /* find city button */
1945 pBuf = pBuf->prev;
1946 set_wstate(pBuf, FC_WS_DISABLED);
1948 /* units button */
1949 pBuf = pBuf->prev;
1950 set_wstate(pBuf, FC_WS_DISABLED);
1952 /* show/hide log window button */
1953 pBuf = pBuf->prev;
1954 set_wstate(pBuf, FC_WS_DISABLED);
1956 /* toggle minimap mode button */
1957 pBuf = pBuf->prev;
1958 set_wstate(pBuf, FC_WS_DISABLED);
1960 #ifdef SMALL_SCREEN
1961 /* options button */
1962 pBuf = pBuf->prev;
1963 set_wstate(pBuf, FC_WS_DISABLED);
1964 #endif
1966 /* show/hide minimap button */
1967 pBuf = pBuf->prev;
1968 set_wstate(pBuf, FC_WS_DISABLED);
1970 redraw_group(pBuf, pEnd, TRUE);
1973 static void disable_unitinfo_widgets(void)
1975 struct widget *pBuf = pUnits_Info_Window->private_data.adv_dlg->pBeginWidgetList;
1976 struct widget *pEnd = pUnits_Info_Window->private_data.adv_dlg->pEndWidgetList;
1978 set_group_state(pBuf, pEnd, FC_WS_DISABLED);
1979 pEnd = pEnd->prev;
1980 redraw_group(pBuf, pEnd, TRUE);
1983 void disable_main_widgets(void)
1985 if (C_S_RUNNING == client_state()) {
1986 disable_minimap_widgets();
1987 disable_unitinfo_widgets();
1989 disable_options_button();
1991 disable_order_buttons();
1995 static void enable_minimap_widgets(void)
1997 struct widget *pBuf, *pEnd;
1999 if (can_client_issue_orders()) {
2001 pBuf = pMiniMap_Window;
2002 set_wstate(pBuf, FC_WS_NORMAL);
2004 /* new turn button */
2005 pBuf = pBuf->prev;
2006 pEnd = pBuf;
2007 set_wstate(pBuf, FC_WS_NORMAL);
2009 /* players button */
2010 pBuf = pBuf->prev;
2011 set_wstate(pBuf, FC_WS_NORMAL);
2013 /* find city button */
2014 pBuf = pBuf->prev;
2015 set_wstate(pBuf, FC_WS_NORMAL);
2017 /* units button */
2018 pBuf = pBuf->prev;
2019 set_wstate(pBuf, FC_WS_NORMAL);
2021 /* show/hide log window button */
2022 pBuf = pBuf->prev;
2023 set_wstate(pBuf, FC_WS_NORMAL);
2025 /* toggle minimap mode button */
2026 pBuf = pBuf->prev;
2027 set_wstate(pBuf, FC_WS_NORMAL);
2029 #ifdef SMALL_SCREEN
2030 /* options button */
2031 pBuf = pBuf->prev;
2032 set_wstate(pBuf, FC_WS_NORMAL);
2033 #endif
2035 /* show/hide minimap button */
2036 pBuf = pBuf->prev;
2037 set_wstate(pBuf, FC_WS_NORMAL);
2039 redraw_group(pBuf, pEnd, TRUE);
2043 static void enable_unitinfo_widgets(void)
2045 struct widget *pBuf, *pEnd;
2047 if (can_client_issue_orders()) {
2048 pBuf = pUnits_Info_Window->private_data.adv_dlg->pBeginWidgetList;
2049 pEnd = pUnits_Info_Window->private_data.adv_dlg->pEndWidgetList;
2051 set_group_state(pBuf, pEnd, FC_WS_NORMAL);
2052 pEnd = pEnd->prev;
2053 redraw_group(pBuf, pEnd, TRUE);
2057 void enable_main_widgets(void)
2059 if (C_S_RUNNING == client_state()) {
2061 enable_minimap_widgets();
2062 enable_unitinfo_widgets();
2064 enable_options_button();
2066 enable_order_buttons();
2070 struct widget * get_unit_info_window_widget(void)
2072 return pUnits_Info_Window;
2075 struct widget * get_minimap_window_widget(void)
2077 return pMiniMap_Window;
2080 struct widget * get_tax_rates_widget(void)
2082 return pTax_Button;
2085 struct widget * get_research_widget(void)
2087 return pResearch_Button;
2090 struct widget * get_revolution_widget(void)
2092 return pRevolution_Button;
2095 void enable_and_redraw_find_city_button(void)
2097 set_wstate(pFind_City_Button, FC_WS_NORMAL);
2098 widget_redraw(pFind_City_Button);
2099 widget_mark_dirty(pFind_City_Button);
2102 void enable_and_redraw_revolution_button(void)
2104 set_wstate(pRevolution_Button, FC_WS_NORMAL);
2105 widget_redraw(pRevolution_Button);
2106 widget_mark_dirty(pRevolution_Button);
2109 /**************************************************************************
2110 mouse click handler
2111 **************************************************************************/
2112 void button_down_on_map(struct mouse_button_behavior *button_behavior)
2114 struct tile *ptile;
2116 if (C_S_RUNNING != client_state()) {
2117 return;
2120 if (button_behavior->event->button == SDL_BUTTON_LEFT) {
2121 switch(button_behavior->hold_state) {
2122 case MB_HOLD_SHORT:
2123 break;
2124 case MB_HOLD_MEDIUM:
2125 /* switch to goto mode */
2126 key_unit_goto();
2127 update_mouse_cursor(CURSOR_GOTO);
2128 break;
2129 case MB_HOLD_LONG:
2130 #ifdef UNDER_CE
2131 /* cancel goto mode and open context menu on Pocket PC since we have
2132 * only one 'mouse button' */
2133 key_cancel_action();
2134 draw_goto_patrol_lines = FALSE;
2135 update_mouse_cursor(CURSOR_DEFAULT);
2136 /* popup context menu */
2137 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2138 (int) button_behavior->event->y))) {
2139 popup_advanced_terrain_dialog(ptile, button_behavior->event->x,
2140 button_behavior->event->y);
2142 #endif
2143 break;
2144 default:
2145 break;
2147 } else if (button_behavior->event->button == SDL_BUTTON_MIDDLE) {
2148 switch(button_behavior->hold_state) {
2149 case MB_HOLD_SHORT:
2150 break;
2151 case MB_HOLD_MEDIUM:
2152 break;
2153 case MB_HOLD_LONG:
2154 break;
2155 default:
2156 break;
2158 } else if (button_behavior->event->button == SDL_BUTTON_RIGHT) {
2159 switch (button_behavior->hold_state) {
2160 case MB_HOLD_SHORT:
2161 break;
2162 case MB_HOLD_MEDIUM:
2163 /* popup context menu */
2164 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2165 (int) button_behavior->event->y))) {
2166 popup_advanced_terrain_dialog(ptile, button_behavior->event->x,
2167 button_behavior->event->y);
2169 break;
2170 case MB_HOLD_LONG:
2171 break;
2172 default:
2173 break;
2179 void button_up_on_map(struct mouse_button_behavior *button_behavior)
2181 struct tile *ptile;
2182 struct city *pCity;
2184 if (C_S_RUNNING != client_state()) {
2185 return;
2188 draw_goto_patrol_lines = FALSE;
2190 if (button_behavior->event->button == SDL_BUTTON_LEFT) {
2191 switch(button_behavior->hold_state) {
2192 case MB_HOLD_SHORT:
2193 if(LSHIFT || LALT || LCTRL) {
2194 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2195 (int) button_behavior->event->y))) {
2196 if(LSHIFT) {
2197 popup_advanced_terrain_dialog(ptile, button_behavior->event->x,
2198 button_behavior->event->y);
2199 } else {
2200 if(((pCity = tile_city(ptile)) != NULL) &&
2201 (city_owner(pCity) == client.conn.playing)) {
2202 if(LCTRL) {
2203 popup_worklist_editor(pCity, NULL);
2204 } else {
2205 /* LALT - this work only with fullscreen mode */
2206 popup_hurry_production_dialog(pCity, NULL);
2211 } else {
2212 update_mouse_cursor(CURSOR_DEFAULT);
2213 action_button_pressed(button_behavior->event->x,
2214 button_behavior->event->y, SELECT_POPUP);
2216 break;
2217 case MB_HOLD_MEDIUM:
2218 /* finish goto */
2219 update_mouse_cursor(CURSOR_DEFAULT);
2220 action_button_pressed(button_behavior->event->x,
2221 button_behavior->event->y, SELECT_POPUP);
2222 break;
2223 case MB_HOLD_LONG:
2224 #ifndef UNDER_CE
2225 /* finish goto */
2226 update_mouse_cursor(CURSOR_DEFAULT);
2227 action_button_pressed(button_behavior->event->x,
2228 button_behavior->event->y, SELECT_POPUP);
2229 #endif
2230 break;
2231 default:
2232 break;
2234 } else if (button_behavior->event->button == SDL_BUTTON_MIDDLE) {
2235 switch(button_behavior->hold_state) {
2236 case MB_HOLD_SHORT:
2237 /* break;*/
2238 case MB_HOLD_MEDIUM:
2239 /* break;*/
2240 case MB_HOLD_LONG:
2241 /* break;*/
2242 default:
2243 /* popup context menu */
2244 if ((ptile = canvas_pos_to_tile((int) button_behavior->event->x,
2245 (int) button_behavior->event->y))) {
2246 popup_advanced_terrain_dialog(ptile, button_behavior->event->x,
2247 button_behavior->event->y);
2249 break;
2251 } else if (button_behavior->event->button == SDL_BUTTON_RIGHT) {
2252 switch (button_behavior->hold_state) {
2253 case MB_HOLD_SHORT:
2254 /* recenter map */
2255 recenter_button_pressed(button_behavior->event->x, button_behavior->event->y);
2256 flush_dirty();
2257 break;
2258 case MB_HOLD_MEDIUM:
2259 break;
2260 case MB_HOLD_LONG:
2261 break;
2262 default:
2263 break;
2269 /**************************************************************************
2270 Toggle map drawing stuff.
2271 **************************************************************************/
2272 bool map_event_handler(SDL_keysym Key)
2274 if (C_S_RUNNING == client_state()) {
2275 switch (Key.sym) {
2277 /* cancel action */
2278 case SDLK_ESCAPE:
2279 key_cancel_action();
2280 draw_goto_patrol_lines = FALSE;
2281 update_mouse_cursor(CURSOR_DEFAULT);
2282 return FALSE;
2284 /* *** unit movement *** */
2286 /* move north */
2287 case SDLK_UP:
2288 case SDLK_KP8:
2289 if(!is_unit_move_blocked) {
2290 key_unit_move(DIR8_NORTH);
2292 return FALSE;
2294 /* move northeast */
2295 case SDLK_PAGEUP:
2296 case SDLK_KP9:
2297 if(!is_unit_move_blocked) {
2298 key_unit_move(DIR8_NORTHEAST);
2300 return FALSE;
2302 /* move east */
2303 case SDLK_RIGHT:
2304 case SDLK_KP6:
2305 if(!is_unit_move_blocked) {
2306 key_unit_move(DIR8_EAST);
2308 return FALSE;
2310 /* move southeast */
2311 case SDLK_PAGEDOWN:
2312 case SDLK_KP3:
2313 if(!is_unit_move_blocked) {
2314 key_unit_move(DIR8_SOUTHEAST);
2316 return FALSE;
2318 /* move south */
2319 case SDLK_DOWN:
2320 case SDLK_KP2:
2321 if(!is_unit_move_blocked) {
2322 key_unit_move(DIR8_SOUTH);
2324 return FALSE;
2326 /* move southwest */
2327 case SDLK_END:
2328 case SDLK_KP1:
2329 if(!is_unit_move_blocked) {
2330 key_unit_move(DIR8_SOUTHWEST);
2332 return FALSE;
2334 /* move west */
2335 case SDLK_LEFT:
2336 case SDLK_KP4:
2337 if(!is_unit_move_blocked) {
2338 key_unit_move(DIR8_WEST);
2340 return FALSE;
2342 /* move northwest */
2343 case SDLK_HOME:
2344 case SDLK_KP7:
2345 if(!is_unit_move_blocked) {
2346 key_unit_move(DIR8_NORTHWEST);
2348 return FALSE;
2350 case SDLK_KP5:
2351 key_recall_previous_focus_unit();
2352 return FALSE;
2354 /* *** map view settings *** */
2356 /* show city outlines - Ctrl+y */
2357 case SDLK_y:
2358 if(LCTRL || RCTRL) {
2359 key_city_outlines_toggle();
2361 return FALSE;
2363 /* show map grid - Ctrl+g */
2364 case SDLK_g:
2365 if(LCTRL || RCTRL) {
2366 key_map_grid_toggle();
2368 return FALSE;
2370 /* show national borders - Ctrl+b */
2371 case SDLK_b:
2372 if(LCTRL || RCTRL) {
2373 key_map_borders_toggle();
2375 return FALSE;
2377 case SDLK_n:
2378 /* show native tiles - Ctrl+Shift+n */
2379 if ((LCTRL || RCTRL) && (LSHIFT || RSHIFT)) {
2380 key_map_native_toggle();
2381 } else if (LCTRL || RCTRL) {
2382 /* show city names - Ctrl+n */
2383 key_city_names_toggle();
2385 return FALSE;
2387 /* show city growth Ctrl+r */
2388 case SDLK_r:
2389 if (LCTRL || RCTRL) {
2390 key_city_growth_toggle();
2392 return FALSE;
2394 /* show city productions - Ctrl+p */
2395 case SDLK_p:
2396 if (LCTRL || RCTRL) {
2397 key_city_productions_toggle();
2399 return FALSE;
2401 /* show city trade routes - Ctrl+d */
2402 case SDLK_d:
2403 if (LCTRL || RCTRL) {
2404 key_city_trade_routes_toggle();
2406 return FALSE;
2408 /* *** some additional shortcuts that work in the SDL client only *** */
2410 /* show terrain - Ctrl+Shift+t */
2411 case SDLK_t:
2412 if ((LCTRL || RCTRL) && (LSHIFT || RSHIFT)) {
2413 key_terrain_toggle();
2415 return FALSE;
2417 /* (show coastline) */
2419 /* (show roads and rails) */
2421 /* show irrigation - Ctrl+i */
2422 case SDLK_i:
2423 if (LCTRL || RCTRL) {
2424 key_irrigation_toggle();
2426 return FALSE;
2428 /* show mines - Ctrl+m */
2429 case SDLK_m:
2430 if (LCTRL || RCTRL) {
2431 key_mines_toggle();
2433 return FALSE;
2435 /* show bases - Ctrl+Shift+f */
2436 case SDLK_f:
2437 if ((LCTRL || RCTRL) && (LSHIFT || RSHIFT)) {
2438 request_toggle_bases();
2440 return FALSE;
2442 /* show resources - Ctrl+s */
2443 case SDLK_s:
2444 if (LCTRL || RCTRL) {
2445 key_resources_toggle();
2447 return FALSE;
2449 /* show huts - Ctrl+s */
2450 case SDLK_h:
2451 if (LCTRL || RCTRL) {
2452 key_huts_toggle();
2454 return FALSE;
2456 /* show pollution - Ctrl+o */
2457 case SDLK_o:
2458 if (LCTRL || RCTRL) {
2459 key_pollution_toggle();
2461 return FALSE;
2463 /* show cities - Ctrl+c */
2464 case SDLK_c:
2465 if (LCTRL || RCTRL) {
2466 request_toggle_cities();
2467 } else {
2468 request_center_focus_unit();
2470 return FALSE;
2472 /* show units - Ctrl+u */
2473 case SDLK_u:
2474 if (LCTRL || RCTRL) {
2475 key_units_toggle();
2477 return FALSE;
2479 /* (show focus unit) */
2481 /* show city output - Ctrl+w
2482 * show fog of war - Ctrl+Shift+w */
2483 case SDLK_w:
2484 if (LCTRL || RCTRL) {
2485 if (LSHIFT || RSHIFT) {
2486 key_fog_of_war_toggle();
2487 } else {
2488 key_city_output_toggle();
2491 return FALSE;
2493 /* toggle minimap mode - currently without effect */
2494 case SDLK_BACKSLASH:
2495 if (LSHIFT || RSHIFT) {
2496 toggle_minimap_mode_callback(NULL);
2498 return FALSE;
2500 default:
2501 break;
2505 return TRUE;
2508 /**************************************************************************
2510 **************************************************************************/
2511 static int newcity_ok_edit_callback(struct widget *pEdit) {
2512 if (Main.event.button.button == SDL_BUTTON_LEFT) {
2513 char *input =
2514 convert_to_chars(pNewCity_Dlg->pBeginWidgetList->string16->text);
2516 if (input) {
2517 FC_FREE(input);
2518 } else {
2519 /* empty input -> restore previous content */
2520 copy_chars_to_string16(pEdit->string16, pSuggestedCityName);
2521 widget_redraw(pEdit);
2522 widget_mark_dirty(pEdit);
2523 flush_dirty();
2526 return -1;
2528 /**************************************************************************
2530 **************************************************************************/
2531 static int newcity_ok_callback(struct widget *pOk_Button)
2533 if (Main.event.button.button == SDL_BUTTON_LEFT) {
2534 char *input =
2535 convert_to_chars(pNewCity_Dlg->pBeginWidgetList->string16->text);
2537 finish_city(pOk_Button->data.tile, input);
2539 FC_FREE(input);
2541 popdown_window_group_dialog(pNewCity_Dlg->pBeginWidgetList,
2542 pNewCity_Dlg->pEndWidgetList);
2543 FC_FREE(pNewCity_Dlg);
2545 FC_FREE(pSuggestedCityName);
2547 flush_dirty();
2549 return -1;
2552 /**************************************************************************
2554 **************************************************************************/
2555 static int newcity_cancel_callback(struct widget *pCancel_Button)
2557 if (Main.event.button.button == SDL_BUTTON_LEFT) {
2558 popdown_window_group_dialog(pNewCity_Dlg->pBeginWidgetList,
2559 pNewCity_Dlg->pEndWidgetList);
2561 cancel_city(pCancel_Button->data.tile);
2563 FC_FREE(pNewCity_Dlg);
2565 FC_FREE(pSuggestedCityName);
2567 flush_dirty();
2569 return -1;
2572 /**************************************************************************
2574 **************************************************************************/
2575 static int move_new_city_dlg_callback(struct widget *pWindow)
2577 if (Main.event.button.button == SDL_BUTTON_LEFT) {
2578 move_window_group(pNewCity_Dlg->pBeginWidgetList, pWindow);
2580 return -1;
2583 /* ============================== Native =============================== */
2586 /**************************************************************************
2587 Popup a dialog to ask for the name of a new city. The given string
2588 should be used as a suggestion.
2589 **************************************************************************/
2590 void popup_newcity_dialog(struct unit *pUnit, const char *pSuggestname)
2592 SDL_Surface *pBackground;
2593 struct SDL_String16 *pStr = NULL;
2594 struct widget *pLabel = NULL;
2595 struct widget *pWindow = NULL;
2596 struct widget *pCancel_Button = NULL;
2597 struct widget *pOK_Button;
2598 struct widget *pEdit;
2599 SDL_Rect area;
2601 if(pNewCity_Dlg) {
2602 return;
2605 pSuggestedCityName = fc_calloc(1, strlen(pSuggestname) + 1);
2606 fc_strlcpy(pSuggestedCityName, pSuggestname, strlen(pSuggestname) + 1);
2608 pNewCity_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
2610 /* create window */
2611 pStr = create_str16_from_char(_("Build City"), adj_font(12));
2612 pStr->style |= TTF_STYLE_BOLD;
2613 pWindow = create_window_skeleton(NULL, pStr, 0);
2614 pWindow->action = move_new_city_dlg_callback;
2616 area = pWindow->area;
2618 /* create ok button */
2619 pOK_Button =
2620 create_themeicon_button_from_chars(current_theme->Small_OK_Icon, pWindow->dst,
2621 _("OK"), adj_font(10), 0);
2622 pOK_Button->action = newcity_ok_callback;
2623 pOK_Button->key = SDLK_RETURN;
2624 pOK_Button->data.tile = unit_tile(pUnit);
2626 area.h += pOK_Button->size.h;
2628 /* create cancel button */
2629 pCancel_Button =
2630 create_themeicon_button_from_chars(current_theme->Small_CANCEL_Icon,
2631 pWindow->dst, _("Cancel"), adj_font(10), 0);
2632 pCancel_Button->action = newcity_cancel_callback;
2633 pCancel_Button->key = SDLK_ESCAPE;
2634 pCancel_Button->data.tile = unit_tile(pUnit);
2636 /* correct sizes */
2637 pCancel_Button->size.w += adj_size(5);
2638 pOK_Button->size.w = pCancel_Button->size.w;
2640 /* create text label */
2641 pStr = create_str16_from_char(_("What should we call our new city?"), adj_font(10));
2642 pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
2643 pStr->fgcol = *get_theme_color(COLOR_THEME_NEWCITYDLG_TEXT);
2644 pLabel = create_iconlabel(NULL, pWindow->dst, pStr, WF_DRAW_TEXT_LABEL_WITH_SPACE);
2646 area.h += pLabel->size.h;
2648 pEdit = create_edit(NULL, pWindow->dst, create_str16_from_char(pSuggestname, adj_font(12)),
2649 (pOK_Button->size.w + pCancel_Button->size.w + adj_size(15)), WF_RESTORE_BACKGROUND);
2650 pEdit->action = newcity_ok_edit_callback;
2652 area.w = MAX(area.w, pEdit->size.w + adj_size(20));
2653 area.h += pEdit->size.h + adj_size(25);
2655 /* I make this hack to center label on window */
2656 if (pLabel->size.w < area.w)
2658 pLabel->size.w = area.w;
2659 } else {
2660 area.w = MAX(pWindow->area.w, pLabel->size.w + adj_size(10));
2663 pEdit->size.w = area.w - adj_size(20);
2665 /* create window background */
2666 pBackground = theme_get_background(theme, BACKGROUND_NEWCITYDLG);
2667 if (resize_window(pWindow, pBackground, NULL,
2668 (pWindow->size.w - pWindow->area.w) + area.w,
2669 (pWindow->size.h - pWindow->area.h) + area.h)) {
2670 FREESURFACE(pBackground);
2673 area = pWindow->area;
2675 /* set start positions */
2676 widget_set_position(pWindow,
2677 (Main.screen->w - pWindow->size.w) / 2,
2678 (Main.screen->h - pWindow->size.h) / 2);
2680 pOK_Button->size.x = area.x + adj_size(10);
2681 pOK_Button->size.y = area.y + area.h - pOK_Button->size.h - adj_size(10);
2683 pCancel_Button->size.y = pOK_Button->size.y;
2684 pCancel_Button->size.x = area.x + area.w - pCancel_Button->size.w - adj_size(10);
2686 pEdit->size.x = area.x + adj_size(10);
2687 pEdit->size.y = area.y + adj_size(4) + pLabel->size.h + adj_size(3);
2689 pLabel->size.x = area.x + adj_size(3);
2690 pLabel->size.y = area.y + adj_size(4);
2692 /* enable widgets */
2693 set_wstate(pCancel_Button, FC_WS_NORMAL);
2694 set_wstate(pOK_Button, FC_WS_NORMAL);
2695 set_wstate(pEdit, FC_WS_NORMAL);
2696 set_wstate(pWindow, FC_WS_NORMAL);
2698 /* add widgets to main list */
2699 pNewCity_Dlg->pEndWidgetList = pWindow;
2700 add_to_gui_list(ID_NEWCITY_NAME_WINDOW, pWindow);
2701 add_to_gui_list(ID_NEWCITY_NAME_LABEL, pLabel);
2702 add_to_gui_list(ID_NEWCITY_NAME_CANCEL_BUTTON, pCancel_Button);
2703 add_to_gui_list(ID_NEWCITY_NAME_OK_BUTTON, pOK_Button);
2704 add_to_gui_list(ID_NEWCITY_NAME_EDIT, pEdit);
2705 pNewCity_Dlg->pBeginWidgetList = pEdit;
2707 /* redraw */
2708 redraw_group(pEdit, pWindow, 0);
2710 widget_flush(pWindow);
2713 /**************************************************************************
2715 **************************************************************************/
2716 void popdown_newcity_dialog(void)
2718 if(pNewCity_Dlg) {
2719 popdown_window_group_dialog(pNewCity_Dlg->pBeginWidgetList,
2720 pNewCity_Dlg->pEndWidgetList);
2721 FC_FREE(pNewCity_Dlg);
2722 flush_dirty();
2726 /**************************************************************************
2727 A turn done button should be provided for the player. This function
2728 is called to toggle it between active/inactive.
2729 **************************************************************************/
2730 void set_turn_done_button_state(bool state)
2732 if (PAGE_GAME == get_current_client_page()
2733 && !update_queue_is_switching_page()) {
2734 if (state) {
2735 set_wstate(pNew_Turn_Button, FC_WS_NORMAL);
2736 } else {
2737 set_wstate(pNew_Turn_Button, FC_WS_DISABLED);
2739 widget_redraw(pNew_Turn_Button);
2740 widget_flush(pNew_Turn_Button);
2741 redraw_unit_info_label(get_units_in_focus());
2745 /**************************************************************************
2746 Draw a goto or patrol line at the current mouse position.
2747 **************************************************************************/
2748 void create_line_at_mouse_pos(void)
2750 int pos_x, pos_y;
2752 SDL_GetMouseState(&pos_x, &pos_y);
2753 update_line(pos_x, pos_y);
2754 draw_goto_patrol_lines = TRUE;
2757 /**************************************************************************
2758 The Area Selection rectangle. Called by center_tile_mapcanvas() and
2759 when the mouse pointer moves.
2760 **************************************************************************/
2761 void update_rect_at_mouse_pos(void)
2763 /* PORTME */