Author: cazfi
Date: Tue Dec 29 18:06:08 2015
New Revision: 31260

URL: http://svn.gna.org/viewcvs/freeciv?rev=31260&view=rev
Log:
Added zoom options to client rc file.

See patch #6473

Modified:
    branches/S2_6/client/options.c
    branches/S2_6/client/options.h
    branches/S2_6/utility/registry_ini.c
    branches/S2_6/utility/registry_ini.h

Modified: branches/S2_6/client/options.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/options.c?rev=31260&r1=31259&r2=31260&view=diff
==============================================================================
--- branches/S2_6/client/options.c      (original)
+++ branches/S2_6/client/options.c      Tue Dec 29 18:06:08 2015
@@ -177,6 +177,9 @@
     TRUE   /* u - MAPIMG_LAYER_UNITS */
   },
 /*  .mapimg_filename, */
+
+  .zoom_set = FALSE,
+  .zoom_default_level = 1.0,
 
 /* gui-gtk-2.0 client specific options. */
   .gui_gtk2_default_theme_name = FC_GTK2_DEFAULT_THEME_NAME,
@@ -5398,6 +5401,13 @@
     secfile_lookup_bool_default(sf, gui_options.gui_qt_migrated_from_2_5,
                                 "%s.migration_qt_from_2_5", prefix);
 
+  /* These are not gui-enabled yet */
+  gui_options.zoom_set =
+    secfile_lookup_bool_default(sf, FALSE, "%s.zoom_set", prefix);
+  gui_options.zoom_default_level =
+    secfile_lookup_float_default(sf, 1.0,
+                                 "%s.zoom_default_level", prefix);
+
   /* Backwards compatibility for removed options replaced by entirely "new"
    * options. The equivalent "new" option will override these, if set. */
 
@@ -5510,9 +5520,15 @@
   secfile_insert_bool(sf, gui_options.gui_qt_migrated_from_2_5,
                       "client.migration_qt_from_2_5");
 
+  /* gui-enabled options */
   client_options_iterate_all(poption) {
     client_option_save(poption, sf);
   } client_options_iterate_all_end;
+
+  /* These are not gui-enabled yet. */
+  secfile_insert_bool(sf, gui_options.zoom_set, "client.zoom_set");
+  secfile_insert_float(sf, gui_options.zoom_default_level,
+                         "client.zoom_default_level");
 
   message_options_save(sf, "client");
   options_dialogs_save(sf);

Modified: branches/S2_6/client/options.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/options.h?rev=31260&r1=31259&r2=31260&view=diff
==============================================================================
--- branches/S2_6/client/options.h      (original)
+++ branches/S2_6/client/options.h      Tue Dec 29 18:06:08 2015
@@ -189,6 +189,9 @@
   int mapimg_zoom;
   bool mapimg_layer[MAPIMG_LAYER_COUNT];
   char mapimg_filename[512];
+
+  bool zoom_set;
+  float zoom_default_level;
 
 /* gui-gtk-2.0 client specific options. */
 #define FC_GTK2_DEFAULT_THEME_NAME "Freeciv"

Modified: branches/S2_6/utility/registry_ini.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/utility/registry_ini.c?rev=31260&r1=31259&r2=31260&view=diff
==============================================================================
--- branches/S2_6/utility/registry_ini.c        (original)
+++ branches/S2_6/utility/registry_ini.c        Tue Dec 29 18:06:08 2015
@@ -1956,6 +1956,59 @@
 }
 
 /**************************************************************************
+  Lookup a floating point value in the secfile.  Returns TRUE on success.
+**************************************************************************/
+bool secfile_lookup_float(const struct section_file *secfile, float *fval,
+                          const char *path, ...)
+{
+  char fullpath[MAX_LEN_SECPATH];
+  const struct entry *pentry;
+  va_list args;
+
+  SECFILE_RETURN_VAL_IF_FAIL(secfile, NULL, NULL != secfile, FALSE);
+
+  va_start(args, path);
+  fc_vsnprintf(fullpath, sizeof(fullpath), path, args);
+  va_end(args);
+
+  if (!(pentry = secfile_entry_by_path(secfile, fullpath))) {
+    SECFILE_LOG(secfile, NULL, "\"%s\" entry doesn't exist.", fullpath);
+    return FALSE;
+  }
+
+  return entry_float_get(pentry, fval);
+}
+
+/**************************************************************************
+  Lookup a floating point value in the secfile. On failure, use the default
+  value.
+**************************************************************************/
+float secfile_lookup_float_default(const struct section_file *secfile,
+                                   float def, const char *path, ...)
+{
+  char fullpath[MAX_LEN_SECPATH];
+  const struct entry *pentry;
+  float fval;
+  va_list args;
+
+  SECFILE_RETURN_VAL_IF_FAIL(secfile, NULL, NULL != secfile, def);
+
+  va_start(args, path);
+  fc_vsnprintf(fullpath, sizeof(fullpath), path, args);
+  va_end(args);
+
+  if (!(pentry = secfile_entry_by_path(secfile, fullpath))) {
+    return def;
+  }
+
+  if (entry_float_get(pentry, &fval)) {
+    return fval;
+  }
+
+  return def;
+}
+
+/**************************************************************************
   Lookup a string value in the secfile.  Returns NULL on error.
 **************************************************************************/
 const char *secfile_lookup_str(const struct section_file *secfile,

Modified: branches/S2_6/utility/registry_ini.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/utility/registry_ini.h?rev=31260&r1=31259&r2=31260&view=diff
==============================================================================
--- branches/S2_6/utility/registry_ini.h        (original)
+++ branches/S2_6/utility/registry_ini.h        Tue Dec 29 18:06:08 2015
@@ -424,6 +424,13 @@
                             fc__warn_unused_result
                             fc__attribute((__format__ (__printf__, 3, 4)));
 
+bool secfile_lookup_float(const struct section_file *secfile, float *fval,
+                          const char *path, ...)
+                          fc__warn_unused_result
+                          fc__attribute((__format__ (__printf__, 3, 4)));
+float secfile_lookup_float_default(const struct section_file *secfile,
+                                   float def, const char *path, ...);
+
 const char *secfile_lookup_str(const struct section_file *secfile,
                                const char *path, ...)
                                fc__warn_unused_result


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to