Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2006:
[Freeciv-Dev] (PR#15856) Editor: Edit nation info
Home

[Freeciv-Dev] (PR#15856) Editor: Edit nation info

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#15856) Editor: Edit nation info
From: "Mike Kaufman" <kaufman@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 10 Mar 2006 21:37:16 -0800
Reply-to: bugs@xxxxxxxxxxx

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

  Add ability to change name, nation, sex, citystyle of players during the
  game.

  Also add a message that the server is leaving edit mode.

  Also begin code for the "active" player. Active means that an edit action
  create city or create unit will create cities or units owned by that
  player. Eventually to be changed in the players dialog.

  -mike

Index: server/srv_main.c
===================================================================
--- server/srv_main.c   (revision 11757)
+++ server/srv_main.c   (working copy)
@@ -1276,7 +1276,9 @@
   struct nation_type *old_nation, *new_nation;
   struct player *pplayer = get_player(player_no);
 
-  if (server_state != PRE_GAME_STATE || !pplayer) {
+  if (!(requestor->current_conn->access_level == ALLOW_HACK 
+        && game.info.is_edit_mode) 
+      && (server_state != PRE_GAME_STATE || !pplayer)) {
     return;
   }
 
Index: server/edithand.c
===================================================================
--- server/edithand.c   (revision 11757)
+++ server/edithand.c   (working copy)
@@ -51,6 +51,10 @@
     notify_conn(NULL, NULL, E_SETTING,
                _(" *** Server set to edit mode! *** "));
   }
+  if (game.info.is_edit_mode && !is_edit_mode) {
+    notify_conn(NULL, NULL, E_SETTING,
+               _(" *** Server is leaving edit mode. *** "));
+  }
   if (!EQ(game.info.is_edit_mode, is_edit_mode)) {
     game.info.is_edit_mode = is_edit_mode;
     send_game_info(NULL);
Index: common/nation.c
===================================================================
--- common/nation.c     (revision 11757)
+++ common/nation.c     (working copy)
@@ -396,7 +396,8 @@
 bool can_conn_edit_players_nation(const struct connection *pconn,
                                  const struct player *pplayer)
 {
-  return (game.info.is_new_game
-         && ((!pconn->observer && pconn->player == pplayer)
-             || pconn->access_level >= ALLOW_CTRL));
+  return ((pconn->access_level == ALLOW_HACK && game.info.is_edit_mode) 
+          || (game.info.is_new_game
+             && ((!pconn->observer && pconn->player == pplayer)
+                  || pconn->access_level >= ALLOW_CTRL)));
 }
Index: client/gui-gtk-2.0/dialogs.c
===================================================================
--- client/gui-gtk-2.0/dialogs.c        (revision 11757)
+++ client/gui-gtk-2.0/dialogs.c        (working copy)
@@ -760,11 +760,15 @@
   int i;
   
   shell =
-    gtk_dialog_new_with_buttons(_("What Nation Will You Be?"),
+    gtk_dialog_new_with_buttons(game.info.is_edit_mode 
+                                  ?  _("Edit Nation") 
+                                  :  _("What Nation Will You Be?"),
                                NULL,
                                0,
+                               GTK_STOCK_CANCEL,
+                               GTK_RESPONSE_CANCEL,
                                _("Random Nation"),
-                               GTK_RESPONSE_CANCEL,
+                                GTK_RESPONSE_NO, /* for lack of a better */
                                GTK_STOCK_OK,
                                GTK_RESPONSE_ACCEPT,
                                NULL);
@@ -925,8 +929,18 @@
   selected_nation = -1;
 
   /* Finish up. */
-  gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_ACCEPT);
+  gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_CANCEL);
 
+  /* Don't allow ok without a selection */
+  gtk_dialog_set_response_sensitive(GTK_DIALOG(shell), GTK_RESPONSE_ACCEPT,
+                                    FALSE);                                    
      
+  /* don't allow random nation selection in edit mode, since assigning
+   * NO_NATION while game is running is very bad */
+  if (game.info.is_edit_mode) {
+    gtk_dialog_set_response_sensitive(GTK_DIALOG(shell), GTK_RESPONSE_NO,
+                                      FALSE);
+  }
+
   gtk_widget_show_all(GTK_DIALOG(shell)->vbox);
 }
 
@@ -1144,6 +1158,9 @@
       gtk_text_buffer_set_text(races_text, nation->legend , -1);
     }
 
+    /* Once we've made a selection, allow user to ok */
+    gtk_dialog_set_response_sensitive(GTK_DIALOG(races_shell), 
+                                      GTK_RESPONSE_ACCEPT, TRUE);
   } else {
     selected_nation = -1;
   }
@@ -1212,11 +1229,8 @@
   if (response == GTK_RESPONSE_ACCEPT) {
     const char *s;
 
+    /* can this even happen? */
     if (selected_nation == -1) {
-      dsend_packet_nation_select_req(&aconnection,
-                                    races_player->player_no,
-                                    -1, FALSE, "", 0);
-      popdown_races_dialog();
       return;
     }
 
@@ -1242,11 +1256,12 @@
     dsend_packet_nation_select_req(&aconnection,
                                   races_player->player_no, selected_nation,
                                   selected_sex, s, selected_city_style);
-  } else if (response == GTK_RESPONSE_CANCEL) {
+  } else if (response == GTK_RESPONSE_NO) {
     dsend_packet_nation_select_req(&aconnection,
                                   races_player->player_no,
                                   -1, FALSE, "", 0);
   }
+
   popdown_races_dialog();
 }
 
Index: client/gui-gtk-2.0/plrdlg.c
===================================================================
--- client/gui-gtk-2.0/plrdlg.c (revision 11757)
+++ client/gui-gtk-2.0/plrdlg.c (working copy)
@@ -36,6 +36,7 @@
 #include "climisc.h"
 #include "clinet.h"
 #include "connectdlg_common.h"
+#include "dialogs.h"
 #include "gui_main.h"
 #include "gui_stuff.h"
 #include "inteldlg.h"
@@ -205,7 +206,9 @@
       plr = get_player(id);
 
       if (ev->button == 1) {
-       if (can_intel_with_player(plr)) {
+        if (game.info.is_edit_mode) {
+          popup_races_dialog(plr);
+        } else if (can_intel_with_player(plr)) {
          popup_intel_dialog(plr);
        }
       } else {
@@ -313,6 +316,7 @@
   GtkWidget *menu = gtk_menu_new();
   GtkWidget *item;    
   
+  /* index starting at one here to force playername to always be shown */
   for (i = 1; i < num_player_dlg_columns; i++) {
     struct player_dlg_column *pcol;
     
Index: client/plrdlg_common.c
===================================================================
--- client/plrdlg_common.c      (revision 11757)
+++ client/plrdlg_common.c      (working copy)
@@ -23,6 +23,7 @@
 #include "support.h"
 
 #include "climisc.h"
+#include "editor.h"
 #include "text.h"
 
 #include "plrdlg_g.h"
@@ -69,6 +70,14 @@
 }
 
 /******************************************************************
+  TRUE if we are in edit mode and this player is active (editable).
+*******************************************************************/
+static bool col_edit(const struct player *plr)
+{
+  return game.info.is_edit_mode && plr == editor_active_player;
+}
+
+/******************************************************************
   The player-name (aka nation leader) column of the plrdlg.
 *******************************************************************/
 static const char *col_name(const struct player *player)
@@ -247,6 +256,7 @@
 *******************************************************************/
 struct player_dlg_column player_dlg_columns[] = {
   {TRUE, COL_TEXT, N_("?Player:Name"), col_name, NULL, NULL, "name"},
+  {FALSE, COL_BOOLEAN, N_("Active"), NULL, col_edit, NULL,  "active"},
   {FALSE, COL_TEXT, N_("Username"), col_username, NULL, NULL, "username"},
   {TRUE, COL_FLAG, N_("Flag"), NULL, NULL, NULL,  "flag"},
   {TRUE, COL_TEXT, N_("Nation"), col_nation, NULL, NULL,  "nation"},
Index: client/editor.c
===================================================================
--- client/editor.c     (revision 11757)
+++ client/editor.c     (working copy)
@@ -31,6 +31,9 @@
 #include "control.h"
 #include "editor.h"
 
+/* a pointer to the player and his structures that can be currently edited */
+struct player *editor_active_player = &game.players[0];
+
 /* where the selected terrain and specials for editing are stored */
 static enum editor_tool_type selected_tool = ETOOL_PAINT;
 static enum tile_special_type selected_special = S_LAST;
Index: client/editor.h
===================================================================
--- client/editor.h     (revision 11757)
+++ client/editor.h     (working copy)
@@ -31,6 +31,8 @@
   EPAINT_LAST
 };
 
+extern struct player *editor_active_player;
+
 typedef void (*ToolFunction)(struct tile *ptile);
 
 void editor_init_tools(void);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#15856) Editor: Edit nation info, Mike Kaufman <=