Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2005:
[Freeciv-Dev] Re: (PR#12895) Citybar option
Home

[Freeciv-Dev] Re: (PR#12895) Citybar option

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#12895) Citybar option
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 26 Apr 2005 14:18:09 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12895 >

Per I. Mathisen wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=12895 >
> 
> When the 'Draw large citybar' option is turned off (or on), the map view
> should be redrawn. Otherwise graphics corruption will occur until you have
> scrolled away completely from the current location.

And here's a patch.

Note that, contrary to what you may think, this is not insanely slow.
update_map_canvas_visible merely queues an update for later drawing so
the update is only done (at most) once.

-jason

Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.126
diff -u -r1.126 options.c
--- client/options.c    25 Apr 2005 06:19:31 -0000      1.126
+++ client/options.c    26 Apr 2005 21:13:37 -0000
@@ -35,6 +35,7 @@
 #include "civclient.h"
 #include "clinet.h"
 #include "cma_fec.h"
+#include "mapview_common.h"
 #include "plrdlg_common.h"
 #include "tilespec.h"
 
@@ -131,12 +132,12 @@
                 COC_GRAPHICS,
                 get_tileset_list, tilespec_reread_callback),
 
-  GEN_BOOL_OPTION(solid_color_behind_units,
-                 N_("Solid unit background color"),
-                 N_("Setting this option will cause units on the map "
-                    "view to be drawn with a solid background color "
-                    "instead of the flag backdrop."),
-                 COC_GRAPHICS),
+  GEN_BOOL_OPTION_CB(solid_color_behind_units,
+                    N_("Solid unit background color"),
+                    N_("Setting this option will cause units on the map "
+                       "view to be drawn with a solid background color "
+                       "instead of the flag backdrop."),
+                    COC_GRAPHICS, mapview_redraw_callback),
   GEN_BOOL_OPTION(sound_bell_at_new_turn, N_("Sound bell at new turn"),
                  N_("Set this option to have a \"bell\" event be generated "
                     "at the start of a new turn.  You can control the "
@@ -160,11 +161,11 @@
                  N_("If this option is disabled them combat animation "
                     "between units on the mapview will be turned off."),
                  COC_GRAPHICS),
-  GEN_BOOL_OPTION(draw_full_citybar, N_("Draw a larger citybar"),
-                 N_("If this option is set then instead of just the city "
-                    "name and attributes, a large amount of data will be "
-                    "drawn beneach each city in the 'citybar'."),
-                 COC_GRAPHICS),
+  GEN_BOOL_OPTION_CB(draw_full_citybar, N_("Draw a larger citybar"),
+                    N_("If this option is set then instead of just the "
+                       "city name and attributes, a large amount of data "
+                       "will be drawn beneach each city in the 'citybar'."),
+                    COC_GRAPHICS, mapview_redraw_callback),
   GEN_BOOL_OPTION(ai_manual_turn_done, N_("Manual Turn Done in AI Mode"),
                  N_("If this option is disabled, then you will not have "
                     "to press the turn done button manually when watching "
@@ -904,3 +905,11 @@
     return TRUE;
   }
 }
+
+/****************************************************************************
+  Callback when a mapview graphics option is changed (redraws the canvas).
+****************************************************************************/
+void mapview_redraw_callback(struct client_option *option)
+{
+  update_map_canvas_visible();
+}
Index: client/options.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.h,v
retrieving revision 1.49
diff -u -r1.49 options.h
--- client/options.h    25 Apr 2005 06:19:31 -0000      1.49
+++ client/options.h    26 Apr 2005 21:13:37 -0000
@@ -93,8 +93,10 @@
   { #oname, desc, help, category, COT_INT,                                 \
       &oname, NULL, NULL, 0, NULL, NULL, NULL }
 #define GEN_BOOL_OPTION(oname, desc, help, category)                       \
+  GEN_BOOL_OPTION_CB(oname, desc, help, category, NULL)
+#define GEN_BOOL_OPTION_CB(oname, desc, help, category, callback)          \
   { #oname, desc, help, category, COT_BOOL,                                \
-      NULL, &oname, NULL, 0, NULL, NULL, NULL }
+      NULL, &oname, NULL, 0, callback, NULL, NULL }
 #define GEN_STR_OPTION(oname, desc, help, category, str_defaults, callback) \
   { #oname, desc, help, category, COT_STR,                         \
       NULL, NULL, oname, sizeof(oname), callback, str_defaults, NULL }
@@ -166,4 +168,7 @@
 const char *get_sound_tag_for_event(enum event_type event);
 bool is_city_event(enum event_type event);
 
+/* Callback functions for changing options. */
+void mapview_redraw_callback(struct client_option *option);
+
 #endif  /* FC__OPTIONS_H */
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.118
diff -u -r1.118 gui_main.c
--- client/gui-gtk-2.0/gui_main.c       28 Mar 2005 16:59:14 -0000      1.118
+++ client/gui-gtk-2.0/gui_main.c       26 Apr 2005 21:13:37 -0000
@@ -165,12 +165,12 @@
                     "be shown as separate tabs rather than in popup "
                     "dialogs."),
                  COC_INTERFACE),
-  GEN_BOOL_OPTION(better_fog,
-                 N_("Better fog-of-war drawing"),
-                 N_("If this is enabled then a better method is used for "
-                    "drawing fog-of-war.  It is not any slower but will "
-                    "consume about twice as much memory."),
-                 COC_GRAPHICS)
+  GEN_BOOL_OPTION_CB(better_fog,
+                    N_("Better fog-of-war drawing"),
+                    N_("If this is enabled then a better method is used "
+                       "for drawing fog-of-war.  It is not any slower but "
+                       "will consume about twice as much memory."),
+                    COC_GRAPHICS, mapview_redraw_callback)
 };
 const int num_gui_options = ARRAY_SIZE(gui_options);
 
Index: client/gui-win32/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/gui_main.c,v
retrieving revision 1.49
diff -u -r1.49 gui_main.c
--- client/gui-win32/gui_main.c 28 Mar 2005 16:48:41 -0000      1.49
+++ client/gui-win32/gui_main.c 26 Apr 2005 21:13:38 -0000
@@ -105,19 +105,19 @@
 const bool gui_use_transliteration = TRUE;
 
 client_option gui_options[] = {
-  GEN_BOOL_OPTION(better_fog,
-                 N_("Better fog-of-war drawing"),
-                 N_("If this is enabled then a better method is used for "
-                    "drawing fog-of-war.  It is not any slower but will "
-                    "consume about twice as much memory."),
-                 COC_GRAPHICS),
-  GEN_BOOL_OPTION(enable_alpha,
-                 N_("Enable alpha blending"),
-                 N_("If this is enabled, then alpha blending will be used "
-                    "in rendering, instead of an ordered dither.  If there "
-                    "is no hardware support for alpha blending, this is "
-                    "much slower."),
-                 COC_GRAPHICS)
+  GEN_BOOL_OPTION_CB(better_fog,
+                    N_("Better fog-of-war drawing"),
+                    N_("If this is enabled then a better method is used for "
+                       "drawing fog-of-war.  It is not any slower but will "
+                       "consume about twice as much memory."),
+                    COC_GRAPHICS, mapview_redraw_callback),
+  GEN_BOOL_OPTION_CB(enable_alpha,
+                    N_("Enable alpha blending"),
+                    N_("If this is enabled, then alpha blending will be "
+                       "used in rendering, instead of an ordered dither.  "
+                       "If there is no hardware support for alpha "
+                       "blending, this is much slower."),
+                    COC_GRAPHICS, mapview_redraw_callback)
 };
 const int num_gui_options = ARRAY_SIZE(gui_options);
 

[Prev in Thread] Current Thread [Next in Thread]