Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Re: Connection dialog version 13
Home

[Freeciv-Dev] Re: Connection dialog version 13

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Connection dialog version 13
From: Jason Short <vze2zq63@xxxxxxxxxxx>
Date: Sat, 16 Mar 2002 20:16:39 -0500
Reply-to: jdorje@xxxxxxxxxxxx

Per I. Mathisen wrote:
On Fri, 15 Mar 2002, Daniel L Speyer wrote:

Here is the next version of the game starting patch.


Furthermore, I still don't like the new buttons that only appear sometimes
(ie when you start the game using conndlg) to the right of the message
window. I would much rather have those options in the menues. If you must
put them there, then make it consistent and put them there always. Users
are going to wonder why it is there sometimes and sometimes not.

I agree.

The GUI controls of the server are independent of whether the server is spawned by the client or not. They all require some access rights on the server (be it ALLOW_INFO, ALLOW_CTRL, or ALLOW_HACK), but we'll always have at least some of these rights.

In short, I think they are quite independent of the connection dialog. Both work toward a similar goal: letting newbie players use the game easily, and making some tasks easier for veteran players. But they do different things.

I think (someone mentioned this some weeks ago) that the server controls should go into their own menu and always be present (perhaps cleverly de-activated when they wouldn't apply). Attached is a patch to provide such a menu.

jason
? crash
? jason-game.gz
? t
? test-alt.pl
? test.pl
? topology
? client/annotate
? data/README-isotrident
? data/isoengels
? data/isoengels.tilespec
? data/isotrident
? data/isotrident.tilespec
? data/lexxy
? data/lexxy.tilespec
? data/macroisotrident
? data/macroisotrident.tilespec
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.228
diff -u -r1.228 packhand.c
--- client/packhand.c   2002/03/08 15:38:18     1.228
+++ client/packhand.c   2002/03/12 15:02:08
@@ -1330,7 +1330,9 @@
     sz_strlcpy(pconn->addr, pinfo->addr);
     sz_strlcpy(pconn->capability, pinfo->capability);
   }
+
   update_players_dialog();
+  update_menus();
 }
 
 /**************************************************************************
Index: client/gui-gtk/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/menu.c,v
retrieving revision 1.66
diff -u -r1.66 menu.c
--- client/gui-gtk/menu.c       2002/02/17 22:40:42     1.66
+++ client/gui-gtk/menu.c       2002/03/12 15:02:08
@@ -71,6 +71,15 @@
   MENU_GAME_CLEAR_OUTPUT,
   MENU_GAME_DISCONNECT,
   MENU_GAME_QUIT,
+
+  MENU_SERVER_START_GAME,
+  MENU_SERVER_SAVE_GAME,
+  MENU_SERVER_LIST_PLAYERS,
+  MENU_SERVER_SET_EASY,
+  MENU_SERVER_SET_NORMAL,
+  MENU_SERVER_SET_HARD,
+  MENU_SERVER_GET_SCORE,
+  MENU_SERVER_END_GAME,
   
   MENU_KINGDOM_TAX_RATE,
   MENU_KINGDOM_FIND_CITY,
@@ -189,6 +198,91 @@
   }
 }
 
+static void send_server_command(const char *cmd)
+{
+  struct packet_generic_message apacket;
+
+  mystrlcpy(apacket.message, cmd, MAX_LEN_MSG - MAX_LEN_USERNAME + 1);
+  send_packet_generic_message(&aconnection, PACKET_CHAT_MSG, &apacket);
+}
+
+/*********************************************************************
+ Finishes saving a game (after the dialog)
+*********************************************************************/
+static void savegame_callback(GtkWidget *w, gpointer data)
+{
+  char buf[512];
+
+  /* TODO: perhaps we should append the .sav if necessary? */
+  snprintf(buf, sizeof(buf), "/save %s",
+         gtk_file_selection_get_filename(GTK_FILE_SELECTION(data)));
+  send_server_command(buf);
+  gtk_widget_destroy(data);
+}
+
+/****************************************************************
+  A callback that's invoked when an item from the "Server" menu
+  is chosen.
+*****************************************************************/
+static void server_menu_callback(gpointer callback_data,
+                              guint callback_action, GtkWidget *widget)
+{
+
+  switch(callback_action) {
+  case MENU_SERVER_START_GAME:
+    send_server_command("/start");
+    break;
+  case MENU_SERVER_SAVE_GAME:
+    if (strcmp(server_host, "localhost") == 0) {
+      /* For local games, we pop up a file selection window to
+         let the user choose the full path.  Note that the local
+         server _might_ not have the same permissions as the user,
+         but this should usually work out ok.  Is there any way
+         to check? */
+      /* Comparing server_host to localhost isn't failsafe either.  It could be
+         addressed as localhost.localdomain, with a real domain name, or by IP.
+         But it, too, should usually work out OK. */
+      GtkWidget *filesel = gtk_file_selection_new(_("Select a name to save 
under"));
+
+      gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button),
+                        "clicked", GTK_SIGNAL_FUNC(savegame_callback),
+                        filesel);
+      
gtk_signal_connect_object(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button),"clicked",
+                               GTK_SIGNAL_FUNC(gtk_widget_destroy),
+                               (gpointer)filesel);
+      
gtk_signal_connect_object(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button),"clicked",
+                               GTK_SIGNAL_FUNC(gtk_widget_destroy),
+                               (gpointer)filesel);
+      gtk_file_selection_complete(GTK_FILE_SELECTION(filesel), "*.sav.gz");
+      gtk_widget_show(filesel);
+    } else {
+      /* TODO: just ask the user for the name of the savefile */
+      send_server_command("/save");
+    }
+    break;
+  case MENU_SERVER_LIST_PLAYERS:
+    send_server_command("/list");
+    break;
+  case MENU_SERVER_SET_EASY:
+    send_server_command("/easy");
+    break;
+  case MENU_SERVER_SET_NORMAL:
+    send_server_command("/normal");
+    break;
+  case MENU_SERVER_SET_HARD:
+    send_server_command("/hard");
+    break;
+  case MENU_SERVER_GET_SCORE:
+    send_server_command("/score");
+    break;
+  case MENU_SERVER_END_GAME:
+    /* TODO: we should have a confirmation dialog. */
+    /* FIXME: we need cmdlevel hack to execute this... */
+    send_server_command("/quit");
+    break;
+  }
+}
+
 
 /****************************************************************
 ...
@@ -572,12 +666,37 @@
        game_menu_callback,     MENU_GAME_DISCONNECT                            
        },
   { "/" N_("Game") "/" N_("_Quit"),                    "<control>q",
        gtk_main_quit,          0                                               
        },
+  /* Server menu ... */
+  { "/" N_("_Server"),                                 NULL,
+       NULL,                   0,                                      
"<Branch>"      },
+  { "/" N_("Server") "/tearoff1",                              NULL,
+       NULL,                   0,                                      
"<Tearoff>"     },
+  { "/" N_("Server") "/" N_("_Start Game"),            NULL,
+       server_menu_callback,   MENU_SERVER_START_GAME                          
        },
+  { "/" N_("Server") "/" N_("Sa_ve Game"),             "<control>s",
+       server_menu_callback,   MENU_SERVER_SAVE_GAME                           
        },
+  { "/" N_("Server") "/" N_("_List Players"),          "<control>l",
+       server_menu_callback,   MENU_SERVER_LIST_PLAYERS                        
        },
+  { "/" N_("Server") "/" N_("Set AI Difficulty"),              NULL,
+       NULL,                   0,                                      
"<Branch>"      },
+  { "/" N_("Server") "/" N_("Set AI Difficulty") "/tearoff1",  NULL,
+       NULL,                   0,                                      
"<Tearoff>"     },
+  { "/" N_("Server") "/" N_("Set AI Difficulty") "/" N_("Easy"), NULL,
+       server_menu_callback,   MENU_SERVER_SET_EASY,                           
        },
+  { "/" N_("Server") "/" N_("Set AI Difficulty") "/" N_("Normal"), NULL,
+       server_menu_callback,   MENU_SERVER_SET_NORMAL,                         
        },
+  { "/" N_("Server") "/" N_("Set AI Difficulty") "/" N_("Hard"), NULL,
+       server_menu_callback,   MENU_SERVER_SET_HARD,                           
        },
+  { "/" N_("Server") "/" N_("_Get Score"),             NULL,
+       server_menu_callback,   MENU_SERVER_GET_SCORE                           
        },
+  { "/" N_("Server") "/" N_("_End Game"),              NULL,
+       server_menu_callback,   MENU_SERVER_END_GAME                            
        },
   /* Kingdom menu ... */
   { "/" N_("_Kingdom"),                                        NULL,
        NULL,                   0,                                      
"<Branch>"      },
   { "/" N_("Kingdom") "/tearoff1",                     NULL,
        NULL,                   0,                                      
"<Tearoff>"     },
-  { "/" N_("Kingdom") "/" N_("_Tax Rates"),            "<shift>t",
+  { "/" N_("Kingdom") "/" N_("_Tax Rates"),            NULL,
        kingdom_menu_callback,  MENU_KINGDOM_TAX_RATE                           
        },
   { "/" N_("Kingdom") "/sep1",                         NULL,
        NULL,                   0,                                      
"<Separator>"   },
@@ -951,7 +1070,50 @@
   gtk_label_parse_uline(GTK_LABEL(GTK_BIN(item)->child), s);
 }
 
+/****************************************************************
+  This does the work of update_menus for the server menu.
+  It seems cleaner to do it this way than to stick everything
+  into one function...
+*****************************************************************/
+static void update_server_menu(void)
+{
+#if 0
+  /* I'd like to toggle things based upon access level (although
+     this duplicates info held in the server structs), but I
+     aconnection does not contain the access_level! */
+
+  if (aconnection.access_level < ALLOW_INFO) {
+    menus_set_sensitive("<main>/_Server", FALSE);
+  } else{
+    menus_set_sensitive("<main>/_Server", TRUE);
+  }
 
+  if (aconnection.access_level < ALLOW_HACK) {
+    menus_set_sensitive("<main>/_Server/_End Game", FALSE);
+  } else {
+    menus_set_sensitive("<main>/_Server/_End Game", TRUE);
+  }
+
+#endif
+
+  if (get_client_state() == CLIENT_PRE_GAME_STATE) {
+    menus_set_sensitive("<main>/_Server/_Start Game", TRUE);
+  } else {
+    menus_set_sensitive("<main>/_Server/_Start Game", FALSE);
+  }
+
+  if (get_client_state() == CLIENT_GAME_RUNNING_STATE) {
+    menus_set_sensitive("<main>/_Server/Sa_ve Game", TRUE);
+    menus_set_sensitive("<main>/_Server/_Get Score", TRUE);
+    menus_set_sensitive("<main>/_Server/_End Game", TRUE);
+  } else {
+    menus_set_sensitive("<main>/_Server/Sa_ve Game", FALSE);
+    menus_set_sensitive("<main>/_Server/_Get Score", FALSE);
+    menus_set_sensitive("<main>/_Server/_End Game", FALSE);
+  }
+}
+
+
 /****************************************************************
 Note: the menu strings should contain underscores as in the
 menu_items struct. The underscores will be removed elsewhere if
@@ -1129,4 +1291,6 @@
     else
       menus_set_sensitive("<main>/_Orders", FALSE);
   }
+
+  update_server_menu();
 }
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.215
diff -u -r1.215 stdinhand.c
--- server/stdinhand.c  2002/03/08 15:32:02     1.215
+++ server/stdinhand.c  2002/03/12 15:02:11
@@ -57,8 +57,8 @@
 #include "stdinhand.h"
 
 
-static enum cmdlevel_id default_access_level = ALLOW_INFO;
-static enum cmdlevel_id   first_access_level = ALLOW_INFO;
+static enum cmdlevel_id default_access_level = ALLOW_CTRL;
+static enum cmdlevel_id   first_access_level = ALLOW_HACK;
 
 static void cut_client_connection(struct connection *caller, char *name);
 static void show_help(struct connection *caller, char *arg);

[Prev in Thread] Current Thread [Next in Thread]