Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] (PR#18599) gui-xaw: editor implementation
Home

[Freeciv-Dev] (PR#18599) gui-xaw: editor implementation

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#18599) gui-xaw: editor implementation
From: "Egor Vyscrebentsov" <evyscr@xxxxxxxxx>
Date: Fri, 14 Jul 2006 07:23:01 -0700
Reply-to: bugs@xxxxxxxxxxx

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

Good daytime!

First patch on making gui-xaw possible to edit a game/scenario
is attached.
Now it just allows gui-xaw to send toggle edit mode request,
and shows unit commands menu from city dialog for global observer
in edit mode like for regular player.
(Was tested and used with 'None' palette patch and several others.)

-- 
Thanks, evyscr

Index: data/Freeciv.in
===================================================================
--- data/Freeciv.in     (revision 12086)
+++ data/Freeciv.in     (working copy)
@@ -2028,6 +2028,7 @@
 Freeciv*viewmenu.label:                 _("View")
 Freeciv*ordersmenu.label:               _("Orders")
 Freeciv*reportsmenu.label:              _("Reports")
+Freeciv*editormenu.label:               _("Editor")
 Freeciv*helpmenu.label:                 _("Help")
 Freeciv*gamemenu.background:            gray84
 Freeciv*gamemenu.foreground:            black
@@ -2039,6 +2040,8 @@
 Freeciv*ordersmenu.foreground:          black
 Freeciv*reportsmenu.background:         gray84
 Freeciv*reportsmenu.foreground:         black
+Freeciv*editormenu.background:          gray84
+Freeciv*editormenu.foreground:          black
 Freeciv*helpmenu.background:            gray84
 Freeciv*helpmenu.foreground:            black
 Freeciv*gamemenu.borderWidth:           0
@@ -2046,6 +2049,7 @@
 Freeciv*viewmenu.borderWidth:           0
 Freeciv*ordersmenu.borderWidth:         0
 Freeciv*reportsmenu.borderWidth:        0
+Freeciv*editormenu.borderWidth:         0
 Freeciv*helpmenu.borderWidth:           0
 Freeciv*gamemenu.left:                  chainLeft
 Freeciv*gamemenu.right:                 chainLeft
@@ -2061,7 +2065,10 @@
 Freeciv*reportsmenu.fromHoriz:          ordersmenu
 Freeciv*reportsmenu.left:               chainLeft
 Freeciv*reportsmenu.right:              chainLeft
-Freeciv*helpmenu.fromHoriz:             reportsmenu
+Freeciv*editormenu.fromHoriz:           reportsmenu
+Freeciv*editormenu.left:                chainLeft
+Freeciv*editormenu.right:               chainLeft
+Freeciv*helpmenu.fromHoriz:             editormenu
 Freeciv*helpmenu.left:                  chainLeft
 Freeciv*helpmenu.right:                 chainLeft
 Freeciv*menu.background:                gray84
Index: client/gui-xaw/citydlg.c
===================================================================
--- client/gui-xaw/citydlg.c    (revision 12086)
+++ client/gui-xaw/citydlg.c    (working copy)
@@ -40,23 +40,28 @@
 #include "support.h"
 
 #include "city.h"
+#include "connection.h"        /* can_conn_edit */
 #include "game.h"
 #include "map.h"
 #include "packets.h"
 #include "player.h"
 #include "unitlist.h"
 
+#include "civclient.h"
+#include "climap.h"
+#include "climisc.h"
+#include "clinet.h"
+#include "control.h"   /* request_xxx and set_unit_focus */
+#include "options.h"
+#include "text.h"
+#include "tilespec.h"
+
 #include "cma_fec.h"
 
-#include "pixcomm.h"
 #include "canvas.h"
-
 #include "cityrep.h"
-#include "citydlg.h"
-#include "civclient.h"
 #include "cma_fe.h"
 #include "colors.h"
-#include "control.h" /* request_xxx and set_unit_focus */
 #include "dialogs.h"
 #include "graphics.h"
 #include "gui_main.h"
@@ -65,17 +70,13 @@
 #include "inputdlg.h"
 #include "mapctrl.h"
 #include "mapview.h"
-#include "optiondlg.h"         /* for toggle_callback */
+#include "optiondlg.h" /* for toggle_callback */
+#include "pixcomm.h"
 #include "repodlgs.h"
 #include "wldlg.h"
 
 #include "citydlg_common.h"
-#include "climap.h"
-#include "climisc.h"
-#include "clinet.h"
-#include "options.h"
-#include "text.h"
-#include "tilespec.h"
+#include "citydlg.h"
 
 #define MIN_NUM_CITIZENS       22
 #define MAX_NUM_CITIZENS       50
@@ -1301,9 +1302,11 @@
   Widget wd;
   XEvent *e = (XEvent*)call_data;
   
-  if((punit=player_find_unit_by_id(game.player_ptr, (size_t)client_data)) &&
-     (pcity=tile_get_city(punit->tile)) &&
-     (pdialog=get_city_dialog(pcity))) {
+  if (((punit = player_find_unit_by_id(game.player_ptr, (size_t)client_data))
+       || (can_conn_edit(&aconnection) && !game.player_ptr
+          && (punit = find_unit_by_id((size_t)client_data))))
+      && (pcity = tile_get_city(punit->tile))
+      && (pdialog = get_city_dialog(pcity))) {
     
     if(e->type==ButtonRelease && e->xbutton.button==Button2)  {
       set_unit_focus(punit);
Index: client/gui-xaw/menu.c
===================================================================
--- client/gui-xaw/menu.c       (revision 12086)
+++ client/gui-xaw/menu.c       (working copy)
@@ -229,6 +229,12 @@
     { { 0,                            },       0, MENU_END_OF_LIST, 0 }
 };
 
+static struct MenuEntry editor_menu_entries[] = {
+    { { N_("Editing Mode"), 0         },      "", MENU_EDITOR_TOGGLE, 0 },
+    { { N_("Tools"), 0                },      "", MENU_EDITOR_TOOLS, 0 },
+    { { 0,                            },       0, MENU_END_OF_LIST, 0 }
+};
+
 static struct MenuEntry help_menu_entries[]={
     { { N_("Languages"), 0            },      "", MENU_HELP_LANGUAGES, 0 },
     { { N_("Connecting"), 0           },      "", MENU_HELP_CONNECTING, 0 },
@@ -829,6 +835,23 @@
 }
 
 /****************************************************************
+  Callback for Editor menu entries.
+*****************************************************************/
+static void editor_menu_callback(Widget w, XtPointer client_data,
+                                XtPointer garbage)
+{
+  size_t pane_num = (size_t)client_data;
+
+  switch(pane_num) {
+  case MENU_EDITOR_TOGGLE:
+    key_editor_toggle();
+    break;
+  case MENU_EDITOR_TOOLS:
+    break;
+  }
+}
+
+/****************************************************************
 ...
 *****************************************************************/
 static void help_menu_callback(Widget w, XtPointer client_data,
@@ -911,6 +934,9 @@
   create_menu(MENU_REPORT, "reportsmenu", 
              reports_menu_entries, reports_menu_callback, 
              parent_form);
+  create_menu(MENU_EDITOR, "editormenu",
+             editor_menu_entries, editor_menu_callback,
+             parent_form);
   create_menu(MENU_HELP, "helpmenu", 
              help_menu_entries, help_menu_callback, 
              parent_form);
Index: client/gui-xaw/menu.h
===================================================================
--- client/gui-xaw/menu.h       (revision 12086)
+++ client/gui-xaw/menu.h       (working copy)
@@ -24,6 +24,7 @@
   MENU_VIEW,
   MENU_ORDER,
   MENU_REPORT,
+  MENU_EDITOR,
   MENU_HELP,
 
   MENU_LAST
@@ -114,6 +115,9 @@
   MENU_REPORT_DEMOGRAPHIC,
   MENU_REPORT_SPACESHIP,
 
+  MENU_EDITOR_TOGGLE,
+  MENU_EDITOR_TOOLS,
+
   MENU_HELP_LANGUAGES,
   MENU_HELP_CONNECTING,
   MENU_HELP_CONTROLS,

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#18599) gui-xaw: editor implementation, Egor Vyscrebentsov <=