Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2006:
[Freeciv-Dev] (PR#15802) more commands for conn menu
Home

[Freeciv-Dev] (PR#15802) more commands for conn menu

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#15802) more commands for conn menu
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 7 Mar 2006 20:27:45 -0800
Reply-to: bugs@xxxxxxxxxxx

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

This patch adds some more entries to the pregame conn menu, to allow 
simple commands (/take, /hard, etc.) to be issued.

-jason

Index: client/gui-gtk-2.0/pages.c
===================================================================
--- client/gui-gtk-2.0/pages.c  (revision 11736)
+++ client/gui-gtk-2.0/pages.c  (working copy)
@@ -1058,14 +1058,17 @@
 }
 
 /****************************************************************************
-  Callback for when the "observe" entry is chosen from the conn menu.
+  Miscellaneous callback for the conn menu that allows an arbitrary command
+  (/observe, /take, /hard) to be run on the player.
 ****************************************************************************/
-static void conn_menu_observe_chosen(GtkMenuItem *menuitem, gpointer data)
+static void conn_menu_player_command(GtkMenuItem *menuitem, gpointer data)
 {
   char buf[1024];
+  char *command = data;
 
-  my_snprintf(buf, sizeof(buf), "/observe \"%s\"",
-             conn_menu_player->name);
+  /* FIXME: We should use quotes here, but because of a bug in the server
+   * it doesn't parse the quotes properly for some commands (e.g. "hard")! */
+  my_snprintf(buf, sizeof(buf), "/%s %s", command, conn_menu_player->name);
   send_chat(buf);
 }
 
@@ -1152,8 +1155,41 @@
                         (GtkDestroyNotify) gtk_widget_unref);
   gtk_container_add(GTK_CONTAINER(menu), entry);
   g_signal_connect(GTK_OBJECT(entry), "activate",
-                  GTK_SIGNAL_FUNC(conn_menu_observe_chosen), NULL);
+                  GTK_SIGNAL_FUNC(conn_menu_player_command), "observe");
 
+  entry = gtk_menu_item_new_with_label(_("Take this player"));
+  g_object_set_data_full(G_OBJECT(menu), "take", entry,
+                        (GtkDestroyNotify) gtk_widget_unref);
+  gtk_container_add(GTK_CONTAINER(menu), entry);
+  g_signal_connect(GTK_OBJECT(entry), "activate",
+                  GTK_SIGNAL_FUNC(conn_menu_player_command), "take");
+
+  if (pplayer && pplayer->ai.control) {
+    char *difficulty[] = {N_("novice"), N_("easy"),
+                         N_("normal"), N_("hard")};
+    int i;
+
+    entry = gtk_separator_menu_item_new();
+    g_object_set_data_full(G_OBJECT(menu),
+                          "sep-ai-skill", entry,
+                          (GtkDestroyNotify) gtk_widget_unref);
+    gtk_container_add(GTK_CONTAINER(menu), entry);
+
+    for (i = 0; i < ARRAY_SIZE(difficulty); i++) {
+      char text[128];
+
+      my_snprintf(text, sizeof(text), "%s", _(difficulty[i]));
+      entry = gtk_menu_item_new_with_label(text);
+      g_object_set_data_full(G_OBJECT(menu),
+                            difficulty[i], entry,
+                            (GtkDestroyNotify) gtk_widget_unref);
+      gtk_container_add(GTK_CONTAINER(menu), entry);
+      g_signal_connect(GTK_OBJECT(entry), "activate",
+                      GTK_SIGNAL_FUNC(conn_menu_player_command),
+                      difficulty[i]);
+    }
+  }
+
   if (pplayer && game.info.is_new_game) {
     const int count = pplayer->team ? pplayer->team->players : 0;
     bool need_empty_team = (count != 1);
@@ -1161,7 +1197,7 @@
 
     entry = gtk_separator_menu_item_new();
     g_object_set_data_full(G_OBJECT(menu),
-                          "sep1", entry,
+                          "sep-team", entry,
                           (GtkDestroyNotify) gtk_widget_unref);
     gtk_container_add(GTK_CONTAINER(menu), entry);
 

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