[Freeciv-Dev] (PR#12135) make view options like other options
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12135 >
This patch moves view options into the options array. This puts them
into the options dialog and saves them automatically. With this change
it should be optional for the GUIs to include these on the menus.
This may conflict a bit with the fullscreen/save-on-exit patch.
-jason
? blend.png
? fog
? fog.c
? fog.png
? foo
? terrain1.png
? po/en.po
Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.118
diff -u -r1.118 options.c
--- client/options.c 5 Feb 2005 19:46:32 -0000 1.118
+++ client/options.c 5 Feb 2005 22:00:38 -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"
@@ -75,6 +76,27 @@
bool keyboardless_goto = TRUE;
bool show_task_icons = TRUE;
+/** View Options: **/
+
+bool draw_map_grid = FALSE;
+bool draw_city_names = TRUE;
+bool draw_city_growth = TRUE;
+bool draw_city_productions = FALSE;
+bool draw_terrain = TRUE;
+bool draw_coastline = FALSE;
+bool draw_roads_rails = TRUE;
+bool draw_irrigation = TRUE;
+bool draw_mines = TRUE;
+bool draw_fortress_airbase = TRUE;
+bool draw_specials = TRUE;
+bool draw_pollution = TRUE;
+bool draw_cities = TRUE;
+bool draw_units = TRUE;
+bool draw_focus_unit = FALSE;
+bool draw_fog_of_war = TRUE;
+bool draw_borders = TRUE;
+
+
/* This option is currently set by the client - not by the user. */
bool update_city_text_in_refresh_tile = TRUE;
@@ -200,61 +222,67 @@
N_("If this option is set then a newly-founded city will "
"havce its city dialog popped up automatically."),
COC_INTERFACE),
+ VIEW_BOOL_OPTION(draw_map_grid, N_("Draw the map grid"),
+ N_("Enabling this will draw a grid between the tiles on "
+ "the mapview.")),
+ VIEW_BOOL_OPTION(draw_city_names, N_("Draw city names"),
+ N_("Enabling this will draw city names underneath each "
+ "city on the mapview.")),
+ VIEW_BOOL_OPTION(draw_city_growth, N_("Draw city growth times"),
+ N_("Enabling this will cause the number of turns for "
+ "a city to grow to be drawn on the mapview below "
+ "the city.")),
+ VIEW_BOOL_OPTION(draw_city_productions, N_("Draw city production"),
+ N_("Enabling this will cause city production type and "
+ "time to be drawn on the mapview below the city.")),
+ VIEW_BOOL_OPTION(draw_terrain, N_("Draw terrain"),
+ N_("Disable this to turn off drawing of terrain.")),
+ VIEW_BOOL_OPTION(draw_coastline, N_("Draw coastline"),
+ N_("Disable this to turn off drawing of coastline.")),
+ VIEW_BOOL_OPTION(draw_roads_rails, N_("Draw roads and rails"),
+ N_("Disable this to turn off drawing of road and "
+ "railways on the mapview.")),
+ VIEW_BOOL_OPTION(draw_irrigation, N_("Draw irrigation"),
+ N_("Disable this to turn off drawing of irrigation "
+ "on the mapview.")),
+ VIEW_BOOL_OPTION(draw_mines, N_("Draw mines"),
+ N_("Disable this to turn off drawing of mines on "
+ "the mapview.")),
+ VIEW_BOOL_OPTION(draw_fortress_airbase, N_("Draw fortresses and airbases"),
+ N_("Disable this to turn off drawing of fortresses and "
+ "airbases on the mapview.")),
+ VIEW_BOOL_OPTION(draw_specials, N_("Draw specials"),
+ N_("Disable this to turn off drawing of regular tile "
+ "\"specials\" on the mapview.")),
+ VIEW_BOOL_OPTION(draw_pollution, N_("Draw pollution"),
+ N_("Disable this to turn off drawing of pollution and "
+ "fallout on the mapview.")),
+ VIEW_BOOL_OPTION(draw_cities, N_("Draw cities"),
+ N_("Disable this to turn off drawing of cities on "
+ "the mapview.")),
+ VIEW_BOOL_OPTION(draw_units, N_("Draw units"),
+ N_("Disable this to turn off drawing of inactive units "
+ "on the mapview. Drawing of the focus unit is "
+ "controlled separately.")),
+ VIEW_BOOL_OPTION(draw_focus_unit, N_("Draw focus unit"),
+ N_("Disable this to turn off drawing of the focus unit "
+ "(only) on the mapview.")),
+ VIEW_BOOL_OPTION(draw_fog_of_war, N_("Draw fog of war"),
+ N_("Disable this to turn off the fog of war. No tile "
+ "will ever be drawn fogged.")),
+ VIEW_BOOL_OPTION(draw_borders, N_("Draw national borders"),
+ N_("Disable this to turn off drawing of national "
+ "borders. The borders will still be active you "
+ "just won't see them.")),
};
#undef GEN_INT_OPTION
#undef GEN_BOOL_OPTION
#undef GEN_STR_OPTION
+#undef VIEW_BOOL_OPTION
int num_options;
client_option *options;
-/** View Options: **/
-
-bool draw_map_grid = FALSE;
-bool draw_city_names = TRUE;
-bool draw_city_growth = TRUE;
-bool draw_city_productions = FALSE;
-bool draw_terrain = TRUE;
-bool draw_coastline = FALSE;
-bool draw_roads_rails = TRUE;
-bool draw_irrigation = TRUE;
-bool draw_mines = TRUE;
-bool draw_fortress_airbase = TRUE;
-bool draw_specials = TRUE;
-bool draw_pollution = TRUE;
-bool draw_cities = TRUE;
-bool draw_units = TRUE;
-bool draw_focus_unit = FALSE;
-bool draw_fog_of_war = TRUE;
-bool draw_borders = TRUE;
-
-#define VIEW_OPTION(name) { #name, &name }
-#define VIEW_OPTION_TERMINATOR { NULL, NULL }
-
-view_option view_options[] = {
- VIEW_OPTION(draw_map_grid),
- VIEW_OPTION(draw_city_names),
- VIEW_OPTION(draw_city_growth),
- VIEW_OPTION(draw_city_productions),
- VIEW_OPTION(draw_terrain),
- VIEW_OPTION(draw_coastline),
- VIEW_OPTION(draw_roads_rails),
- VIEW_OPTION(draw_irrigation),
- VIEW_OPTION(draw_mines),
- VIEW_OPTION(draw_fortress_airbase),
- VIEW_OPTION(draw_specials),
- VIEW_OPTION(draw_pollution),
- VIEW_OPTION(draw_cities),
- VIEW_OPTION(draw_units),
- VIEW_OPTION(draw_focus_unit),
- VIEW_OPTION(draw_fog_of_war),
- VIEW_OPTION(draw_borders),
- VIEW_OPTION_TERMINATOR
-};
-
-#undef VIEW_OPTION
-#undef VIEW_OPTION_TERMINATOR
-
/** Message Options: **/
unsigned int messages_where[E_LAST];
@@ -513,7 +541,6 @@
const char * const prefix = "client";
char *name;
int i, num;
- view_option *v;
assert(options == NULL);
num_options = ARRAY_SIZE(common_options) + num_gui_options;
@@ -564,11 +591,6 @@
break;
}
}
- for (v = view_options; v->name; v++) {
- *(v->p_value) =
- secfile_lookup_bool_default(&sf, *(v->p_value), "%s.%s", prefix,
- v->name);
- }
for (i = 0; i < E_LAST; i++) {
messages_where[i] =
secfile_lookup_int_default(&sf, messages_where[i],
@@ -645,7 +667,6 @@
struct section_file sf;
char *name = option_file_name();
char output_buffer[256];
- view_option *v;
int i;
if(!name) {
@@ -675,10 +696,6 @@
}
}
- for (v = view_options; v->name; v++) {
- secfile_insert_bool(&sf, *(v->p_value), "client.%s", v->name);
- }
-
for (i = 0; i < E_LAST; i++) {
secfile_insert_int_comment(&sf, messages_where[i],
get_message_text(i),
@@ -895,3 +912,11 @@
return TRUE;
}
}
+
+/****************************************************************************
+ Callback to be made when a view option is changed.
+****************************************************************************/
+void view_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.47
diff -u -r1.47 options.h
--- client/options.h 5 Feb 2005 19:46:32 -0000 1.47
+++ client/options.h 5 Feb 2005 22:00:38 -0000
@@ -50,6 +50,26 @@
extern bool keyboardless_goto;
extern bool show_task_icons;
+/** View Options: **/
+
+extern bool draw_map_grid;
+extern bool draw_city_names;
+extern bool draw_city_growth;
+extern bool draw_city_productions;
+extern bool draw_terrain;
+extern bool draw_coastline;
+extern bool draw_roads_rails;
+extern bool draw_irrigation;
+extern bool draw_mines;
+extern bool draw_fortress_airbase;
+extern bool draw_specials;
+extern bool draw_pollution;
+extern bool draw_cities;
+extern bool draw_units;
+extern bool draw_focus_unit;
+extern bool draw_fog_of_war;
+extern bool draw_borders;
+
enum client_option_type {
COT_BOOL,
COT_INT,
@@ -92,6 +112,9 @@
#define GEN_INT_OPTION(oname, desc, help, category) \
{ #oname, desc, help, category, COT_INT, \
&oname, NULL, NULL, 0, NULL, NULL, NULL }
+#define VIEW_BOOL_OPTION(oname, desc, help) \
+ { #oname, desc, help, COC_GRAPHICS, COT_BOOL,
\
+ NULL, &oname, NULL, 0, view_callback, NULL, NULL}
#define GEN_BOOL_OPTION(oname, desc, help, category) \
{ #oname, desc, help, category, COT_BOOL, \
NULL, &oname, NULL, 0, NULL, NULL, NULL }
@@ -117,31 +140,6 @@
extern const int num_gui_options;
extern client_option gui_options[];
-/** View Options: **/
-
-extern bool draw_map_grid;
-extern bool draw_city_names;
-extern bool draw_city_growth;
-extern bool draw_city_productions;
-extern bool draw_terrain;
-extern bool draw_coastline;
-extern bool draw_roads_rails;
-extern bool draw_irrigation;
-extern bool draw_mines;
-extern bool draw_fortress_airbase;
-extern bool draw_specials;
-extern bool draw_pollution;
-extern bool draw_cities;
-extern bool draw_units;
-extern bool draw_focus_unit;
-extern bool draw_fog_of_war;
-extern bool draw_borders;
-
-typedef struct {
- const char *name;
- bool *p_value;
-} view_option;
-extern view_option view_options[];
/** Message Options: **/
@@ -164,4 +162,6 @@
const char *get_sound_tag_for_event(enum event_type event);
bool is_city_event(enum event_type event);
+void view_callback(struct client_option * option);
+
#endif /* FC__OPTIONS_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12135) make view options like other options,
Jason Short <=
|
|