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

On 14/03/07, Daniel Markstedt <[EMAIL PROTECTED]> wrote:
>
> On 3/12/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
> >
> >  As a usability issue,  maybe we should backport this to S2_1.
> >
>
> Agreed. We just got yet another confused user at
> http://forum.freeciv.org/viewtopic.php?t=2880
>

 Untested S2_1 version


 - ML

diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/Makefile.am freeciv/client/gui-gtk-2.0/Makefile.am
--- freeciv/client/gui-gtk-2.0/Makefile.am	2007-03-05 19:14:31.000000000 +0200
+++ freeciv/client/gui-gtk-2.0/Makefile.am	2007-08-04 02:05:47.000000000 +0300
@@ -90,6 +90,6 @@
 	sprite.c	\
 	sprite.h	\
 	themes.c	\
+	tileset_dlg.c	\
 	wldlg.c		\
 	wldlg.h	
-
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/tileset_dlg.c freeciv/client/gui-gtk-2.0/tileset_dlg.c
--- freeciv/client/gui-gtk-2.0/tileset_dlg.c	1970-01-01 02:00:00.000000000 +0200
+++ freeciv/client/gui-gtk-2.0/tileset_dlg.c	2007-08-04 02:05:47.000000000 +0300
@@ -0,0 +1,82 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+
+#include "fcintl.h"
+
+#include "game.h"
+#include "unitlist.h"
+
+#include "tilespec.h"
+
+#include "dialogs_g.h"
+
+static void tileset_suggestion_callback(GtkWidget *dlg, gint arg);
+
+/****************************************************************
+  Callback either loading suggested tileset or doing nothing
+*****************************************************************/
+static void tileset_suggestion_callback(GtkWidget *dlg, gint arg)
+{
+  if (arg == GTK_RESPONSE_YES) {
+    /* User accepted tileset loading */
+    tilespec_reread(game.control.prefered_tileset);
+  }
+}
+
+/****************************************************************
+  Popup dialog asking if ruleset suggested tileset should be
+  used.
+*****************************************************************/
+void popup_tileset_suggestion_dialog(void)
+{
+  GtkWidget *dialog, *label;
+  char buf[1024];
+
+  dialog = gtk_dialog_new_with_buttons(_("Prefered tileset"),
+                                       NULL,
+                                       0,
+                                       _("Load tileset"),
+                                       GTK_RESPONSE_YES,
+                                       _("Keep current tileset"),
+                                       GTK_RESPONSE_NO,
+                                       NULL);
+  gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES);
+  gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+
+  sprintf(buf,
+          _("Modpack suggest using %s tileset.\n"
+            "It might not work with other tilesets.\n"
+            "You are currently using tileset %s."),
+          game.control.prefered_tileset, tileset_get_name(tileset));
+
+  label = gtk_label_new(buf);
+  gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
+  gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
+  gtk_widget_show(label);
+
+  g_signal_connect(dialog, "response",
+                   G_CALLBACK(tileset_suggestion_callback), NULL);
+
+  /* In case incoming rulesets are incompatible with current tileset
+   * we need to block their receive before user has accepted loading
+   * of the correct tileset. */
+  gtk_dialog_run(GTK_DIALOG(dialog));
+
+  gtk_widget_destroy(dialog);
+}
diff -Nurd -X.diff_ignore freeciv/client/gui-sdl/dialogs.c freeciv/client/gui-sdl/dialogs.c
--- freeciv/client/gui-sdl/dialogs.c	2007-08-01 19:21:39.000000000 +0300
+++ freeciv/client/gui-sdl/dialogs.c	2007-08-04 02:05:47.000000000 +0300
@@ -3075,3 +3075,11 @@
   redraw_group(pNationDlg->pBeginWidgetList, pNationDlg->pEndWidgetList, 0);
   widget_flush(pNationDlg->pEndWidgetList);
 }
+
+/**************************************************************************
+  Ruleset (modpack) has suggested loading certain tileset. Confirm from
+  user and load.
+**************************************************************************/
+void popup_tileset_suggestion_dialog(void)
+{
+}
diff -Nurd -X.diff_ignore freeciv/client/gui-stub/dialogs.c freeciv/client/gui-stub/dialogs.c
--- freeciv/client/gui-stub/dialogs.c	2007-03-05 19:14:35.000000000 +0200
+++ freeciv/client/gui-stub/dialogs.c	2007-08-04 02:05:47.000000000 +0300
@@ -151,6 +151,15 @@
 }
 
 /**************************************************************************
+  Ruleset (modpack) has suggested loading certain tileset. Confirm from
+  user and load.
+**************************************************************************/
+void popup_tileset_suggestion_dialog(void)
+{
+  /* PORTME */
+}
+
+/**************************************************************************
   This function is called when the client disconnects or the game is
   over.  It should close all dialog windows for that game.
 **************************************************************************/
diff -Nurd -X.diff_ignore freeciv/client/gui-win32/dialogs.c freeciv/client/gui-win32/dialogs.c
--- freeciv/client/gui-win32/dialogs.c	2007-07-04 14:04:26.000000000 +0300
+++ freeciv/client/gui-win32/dialogs.c	2007-08-04 02:05:47.000000000 +0300
@@ -1906,3 +1906,11 @@
   return (0);  
   
 }
+
+/**************************************************************************
+  Ruleset (modpack) has suggested loading certain tileset. Confirm from
+  user and load.
+**************************************************************************/
+void popup_tileset_suggestion_dialog(void)
+{
+}
diff -Nurd -X.diff_ignore freeciv/client/gui-xaw/dialogs.c freeciv/client/gui-xaw/dialogs.c
--- freeciv/client/gui-xaw/dialogs.c	2007-07-04 14:04:26.000000000 +0300
+++ freeciv/client/gui-xaw/dialogs.c	2007-08-04 02:05:47.000000000 +0300
@@ -1547,6 +1547,14 @@
   common_taxrates_callback((size_t) client_data);
 }
 
+/**************************************************************************
+  Ruleset (modpack) has suggested loading certain tileset. Confirm from
+  user and load.
+**************************************************************************/
+void popup_tileset_suggestion_dialog(void)
+{
+}
+
 /********************************************************************** 
   This function is called when the client disconnects or the game is
   over.  It should close all dialog windows for that game.
diff -Nurd -X.diff_ignore freeciv/client/include/dialogs_g.h freeciv/client/include/dialogs_g.h
--- freeciv/client/include/dialogs_g.h	2007-03-05 19:14:31.000000000 +0200
+++ freeciv/client/include/dialogs_g.h	2007-08-04 02:05:47.000000000 +0300
@@ -46,6 +46,7 @@
 void popup_sabotage_dialog(struct city *pcity);
 void popup_pillage_dialog(struct unit *punit, bv_special may_pillage);
 void popup_upgrade_dialog(struct unit_list *punits);
+void popup_tileset_suggestion_dialog(void);
 
 void popdown_all_game_dialogs(void);
 
diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c	2007-08-01 19:21:39.000000000 +0300
+++ freeciv/client/packhand.c	2007-08-04 02:15:12.000000000 +0300
@@ -2133,6 +2133,16 @@
   governments_alloc(packet->government_count);
   nations_alloc(packet->nation_count);
   city_styles_alloc(packet->styles_count);
+
+  if (has_capability("PreferedTileset", aconnection.capability)) {
+    if (packet->prefered_tileset[0] != '\0') {
+      /* There is tileset suggestion */
+      if (strcmp(packet->prefered_tileset, tileset_get_name(tileset))) {
+        /* It's not currently in use */
+        popup_tileset_suggestion_dialog();
+      }
+    }
+  }
 }
 
 /**************************************************************************
diff -Nurd -X.diff_ignore freeciv/common/game.c freeciv/common/game.c
--- freeciv/common/game.c	2007-08-01 19:21:30.000000000 +0300
+++ freeciv/common/game.c	2007-08-04 02:05:47.000000000 +0300
@@ -279,6 +279,8 @@
   game.control.nation_count = 0;
   game.control.government_count = 0;
 
+  game.control.prefered_tileset[0] = '\0';
+
   sz_strlcpy(game.demography, GAME_DEFAULT_DEMOGRAPHY);
   sz_strlcpy(game.allow_take, GAME_DEFAULT_ALLOW_TAKE);
 
diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def	2007-03-19 09:57:33.000000000 +0200
+++ freeciv/common/packets.def	2007-08-04 02:08:50.000000000 +0300
@@ -1273,6 +1273,8 @@
   UINT8 terrain_count;
   UINT8 resource_count;
   UINT8 num_specialist_types;
+
+  STRING prefered_tileset[MAX_LEN_NAME]; add-cap(PreferedTileset)
 end
 
 
diff -Nurd -X.diff_ignore freeciv/server/ruleset.c freeciv/server/ruleset.c
--- freeciv/server/ruleset.c	2007-08-03 22:01:12.000000000 +0300
+++ freeciv/server/ruleset.c	2007-08-04 02:05:47.000000000 +0300
@@ -2532,12 +2532,22 @@
   const char *filename;
   int *food_ini;
   int i;
+  char *tileset;
 
   openload_ruleset_file(&file, "game");
   filename = secfile_filename(&file);
   (void) check_ruleset_capabilities(&file, "+1.11.1", filename);
   (void) section_file_lookup(&file, "datafile.description");	/* unused */
 
+  tileset = secfile_lookup_str_default(&file, "", "tileset.prefered");
+  if (tileset[0] != '\0') {
+    /* There was tileset suggestion */
+    sz_strlcpy(game.control.prefered_tileset, tileset);
+  } else {
+    /* No tileset suggestions */
+    game.control.prefered_tileset[0] = '\0';
+  }
+
   game.info.base_pollution = 
         secfile_lookup_int_default(&file, -20, "civstyle.base_pollution");
   game.info.happy_cost =
diff -Nurd -X.diff_ignore freeciv/version.in freeciv/version.in
--- freeciv/version.in	2007-06-28 20:19:41.000000000 +0300
+++ freeciv/version.in	2007-08-04 02:06:16.000000000 +0300
@@ -27,4 +27,4 @@
 #   - Avoid adding a new manditory capbility to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-FREECIV_NETWORK_CAPSTRING(["+2.1c, CitywallFix"])
+FREECIV_NETWORK_CAPSTRING(["+2.1c, CitywallFix, PreferedTileset"])
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to