Author: cazfi
Date: Tue Nov 17 23:45:49 2015
New Revision: 30665

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

See patch #6494

Modified:
    branches/S2_6/client/gui-gtk-3.0/gui_main.c
    branches/S2_6/client/gui-sdl/optiondlg.c
    branches/S2_6/client/gui-sdl2/optiondlg.c
    branches/S2_6/client/options.c
    branches/S2_6/client/options.h

Modified: branches/S2_6/client/gui-gtk-3.0/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/gui_main.c?rev=30665&r1=30664&r2=30665&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/gui_main.c (original)
+++ branches/S2_6/client/gui-gtk-3.0/gui_main.c Tue Nov 17 23:45:49 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: branches/S2_6/client/gui-sdl/optiondlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl/optiondlg.c?rev=30665&r1=30664&r2=30665&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl/optiondlg.c    (original)
+++ branches/S2_6/client/gui-sdl/optiondlg.c    Tue Nov 17 23:45:49 2015
@@ -424,24 +424,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)
@@ -452,8 +434,9 @@
   char buf[64];
 
   for (; NULL != *mode; mode++) {
-    if (video_mode_to_string(buf, sizeof(buf),
-                             video_mode_construct((*mode)->w, (*mode)->h))) {
+    struct video_mode vmode = {.width = (*mode)->w, .height = (*mode)->h };
+
+    if (video_mode_to_string(buf, sizeof(buf), &vmode)) {
       strvec_append(video_modes, buf);
     }
   }
@@ -565,12 +548,11 @@
   case OT_VIDEO_MODE:
     {
       char buf[64];
-
-      if (!video_mode_to_string(buf, sizeof(buf),
-                                option_video_mode_get(poption))) {
+      struct video_mode vmode = option_video_mode_get(poption);
+
+      if (!video_mode_to_string(buf, sizeof(buf), &vmode)) {
         /* Always fails. */
-        fc_assert(video_mode_to_string(buf, sizeof(buf),
-                                       option_video_mode_get(poption)));
+        fc_assert(video_mode_to_string(buf, sizeof(buf), &vmode));
       }
 
       widget = combo_new_from_chars(NULL, window->dst, adj_font(12),
@@ -651,14 +633,13 @@
   case OT_VIDEO_MODE:
     {
       char buf[64];
-
-      if (video_mode_to_string(buf, sizeof(buf),
-                               option_video_mode_get(poption))) {
+      struct video_mode vmode = option_video_mode_get(poption);
+
+      if (video_mode_to_string(buf, sizeof(buf), &vmode)) {
         copy_chars_to_string16(widget->string16, buf);
       } else {
         /* Always fails. */
-        fc_assert(video_mode_to_string(buf, sizeof(buf),
-                                       option_video_mode_get(poption)));
+        fc_assert(video_mode_to_string(buf, sizeof(buf), &vmode));
       }
     }
     break;

Modified: branches/S2_6/client/gui-sdl2/optiondlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl2/optiondlg.c?rev=30665&r1=30664&r2=30665&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl2/optiondlg.c   (original)
+++ branches/S2_6/client/gui-sdl2/optiondlg.c   Tue Nov 17 23:45:49 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: branches/S2_6/client/options.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/options.c?rev=30665&r1=30664&r2=30665&view=diff
==============================================================================
--- branches/S2_6/client/options.c      (original)
+++ branches/S2_6/client/options.c      Tue Nov 17 23:45:49 2015
@@ -5791,3 +5791,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: branches/S2_6/client/options.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/options.h?rev=30665&r1=30664&r2=30665&view=diff
==============================================================================
--- branches/S2_6/client/options.h      (original)
+++ branches/S2_6/client/options.h      Tue Nov 17 23:45:49 2015
@@ -486,6 +486,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