Author: cazfi
Date: Tue Nov 17 23:45:43 2015
New Revision: 30664

URL: http://svn.gna.org/viewcvs/freeciv?rev=30664&view=rev
Log:
Added gtk3-client commandline option to control what freeciv code (does not 
affect gtk+) considers screen size. 

See patch #6494

Modified:
    trunk/client/gui-gtk-3.0/gui_main.c
    trunk/client/gui-sdl2/optiondlg.c
    trunk/client/options.c
    trunk/client/options.h

Modified: trunk/client/gui-gtk-3.0/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/gui_main.c?rev=30664&r1=30663&r2=30664&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/gui_main.c (original)
+++ trunk/client/gui-gtk-3.0/gui_main.c Tue Nov 17 23:45:43 2015
@@ -181,6 +181,8 @@
 
 static bool gui_up = FALSE;
 
+static struct video_mode vmode = { -1, -1 };
+
 static gboolean show_info_button_release(GtkWidget *w, GdkEventButton *ev, 
gpointer data);
 static gboolean show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer 
data);
 
@@ -271,6 +273,8 @@
              _("Other gui-specific options are:\n"));
 
   fc_fprintf(stderr,
+             _("-r, --resolution MODE\tAssume given resolution screen\n"));
+  fc_fprintf(stderr,
              _("-z, --zoom LEVEL\tSet zoom level\n\n"));
 
   /* TRANS: No full stop after the URL, could cause confusion. */
@@ -295,6 +299,11 @@
       char *endptr;
 
       zoom_set(strtof(option, &endptr));
+    } else if ((option = get_option_malloc("--resolution", argv, &i, argc))) {
+      if (!string_to_video_mode(option, &vmode)) {
+        fc_fprintf(stderr, _("Illegal video mode '%s'"), option);
+        exit(EXIT_FAILURE);
+      }
     }
     /* Can't check against unknown options, as those might be gtk options */
 
@@ -2226,7 +2235,13 @@
 **************************************************************************/
 int screen_width(void)
 {
-  GdkScreen *screen = gdk_screen_get_default();
+  GdkScreen *screen;
+
+  if (vmode.width > 0) {
+    return vmode.width;
+  }
+
+  screen = gdk_screen_get_default();
 
   if (screen == NULL) {
     return 0;
@@ -2240,7 +2255,13 @@
 **************************************************************************/
 int screen_height(void)
 {
-  GdkScreen *screen = gdk_screen_get_default();
+  GdkScreen *screen;
+
+  if (vmode.height > 0) {
+    return vmode.height;
+  }
+
+  screen = gdk_screen_get_default();
 
   if (screen == NULL) {
     return 0;

Modified: trunk/client/gui-sdl2/optiondlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/optiondlg.c?rev=30664&r1=30663&r2=30664&view=diff
==============================================================================
--- trunk/client/gui-sdl2/optiondlg.c   (original)
+++ trunk/client/gui-sdl2/optiondlg.c   Tue Nov 17 23:45:43 2015
@@ -433,24 +433,6 @@
 }
 
 /****************************************************************************
-  Convert a video mode to string. Returns TRUE on success.
-****************************************************************************/
-static inline bool video_mode_to_string(char *buf, size_t buf_len,
-                                        struct video_mode *mode)
-{
-  return (2 < fc_snprintf(buf, buf_len, "%dx%d", mode->width, mode->height));
-}
-
-/****************************************************************************
-  Convert a string to video mode. Returns TRUE on success.
-****************************************************************************/
-static inline bool string_to_video_mode(const char *buf,
-                                        struct video_mode *mode)
-{
-  return (2 == sscanf(buf, "%dx%d", &mode->width, &mode->height));
-}
-
-/****************************************************************************
   Return a string vector containing all video modes.
 ****************************************************************************/
 static struct strvec *video_mode_list(void)

Modified: trunk/client/options.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/options.c?rev=30664&r1=30663&r2=30664&view=diff
==============================================================================
--- trunk/client/options.c      (original)
+++ trunk/client/options.c      Tue Nov 17 23:45:43 2015
@@ -5795,3 +5795,19 @@
 {
   adjust_default_options();
 }
+
+/****************************************************************************
+  Convert a video mode to string. Returns TRUE on success.
+****************************************************************************/
+bool video_mode_to_string(char *buf, size_t buf_len, struct video_mode *mode)
+{
+  return (2 < fc_snprintf(buf, buf_len, "%dx%d", mode->width, mode->height));
+}
+
+/****************************************************************************
+  Convert a string to video mode. Returns TRUE on success.
+****************************************************************************/
+bool string_to_video_mode(const char *buf, struct video_mode *mode)
+{
+  return (2 == sscanf(buf, "%dx%d", &mode->width, &mode->height));
+}

Modified: trunk/client/options.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/options.h?rev=30664&r1=30663&r2=30664&view=diff
==============================================================================
--- trunk/client/options.h      (original)
+++ trunk/client/options.h      Tue Nov 17 23:45:43 2015
@@ -489,6 +489,9 @@
 
 #define GUI_DEFAULT_MAPIMG_FILENAME     "freeciv"
 
+bool video_mode_to_string(char *buf, size_t buf_len, struct video_mode *mode);
+bool string_to_video_mode(const char *buf, struct video_mode *mode);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */


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

Reply via email to