Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2004:
[Freeciv-Dev] (PR#10714) In GTK2 unit list dialog, no choice to load uni
Home

[Freeciv-Dev] (PR#10714) In GTK2 unit list dialog, no choice to load uni

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: brett.albertson@xxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#10714) In GTK2 unit list dialog, no choice to load units
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Sun, 24 Oct 2004 20:15:44 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10714 >

> [vasc - Mon Oct 25 03:00:25 2004]:
>
> > [bretta - Mon Oct 25 02:46:40 2004]:
> > We should haver an option that says "Load unit".
> 
> Here is a patch.

This one also adds unload.


Index: client/gui-gtk-2.0/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/citydlg.c,v
retrieving revision 1.97
diff -u -r1.97 citydlg.c
--- client/gui-gtk-2.0/citydlg.c        23 Oct 2004 21:02:36 -0000      1.97
+++ client/gui-gtk-2.0/citydlg.c        25 Oct 2004 03:15:13 -0000
@@ -230,6 +230,8 @@
                                                   gpointer data);
 static void present_unit_activate_close_callback(GtkWidget * w,
                                                 gpointer data);
+static void unit_load_callback(GtkWidget * w, gpointer data);
+static void unit_unload_callback(GtkWidget * w, gpointer data);
 static void unit_sentry_callback(GtkWidget * w, gpointer data);
 static void unit_fortify_callback(GtkWidget * w, gpointer data);
 static void unit_disband_callback(GtkWidget * w, gpointer data);
@@ -1944,6 +1946,27 @@
       GINT_TO_POINTER(punit->id));
     gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 
+    item = gtk_menu_item_new_with_mnemonic(_("_Load unit"));
+    g_signal_connect(item, "activate",
+      G_CALLBACK(unit_load_callback),
+      GINT_TO_POINTER(punit->id));
+    gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+
+    if (!can_unit_load(punit, find_transporter_for_unit(punit, punit->tile))) {
+      gtk_widget_set_sensitive(item, FALSE);
+    }
+
+    item = gtk_menu_item_new_with_mnemonic(_("_Unload unit"));
+    g_signal_connect(item, "activate",
+      G_CALLBACK(unit_unload_callback),
+      GINT_TO_POINTER(punit->id));
+    gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+
+    if (!can_unit_unload(punit, find_unit_by_id(punit->transported_by))
+        || !can_unit_exist_at_tile(punit, punit->tile)) {
+      gtk_widget_set_sensitive(item, FALSE);
+    }
+
     item = gtk_menu_item_new_with_mnemonic(_("_Sentry unit"));
     g_signal_connect(item, "activate",
       G_CALLBACK(unit_sentry_callback),
@@ -1982,7 +2005,7 @@
       gtk_widget_set_sensitive(item, FALSE);
     }
 
-    item = gtk_menu_item_new_with_mnemonic(_("_Upgrade unit"));
+    item = gtk_menu_item_new_with_mnemonic(_("U_pgrade unit"));
     g_signal_connect(item, "activate",
       G_CALLBACK(unit_upgrade_callback),
       GINT_TO_POINTER(punit->id));
@@ -2109,6 +2132,30 @@
 /****************************************************************
 ...
 *****************************************************************/
+static void unit_load_callback(GtkWidget * w, gpointer data)
+{
+  struct unit *punit;
+
+  if ((punit = player_find_unit_by_id(game.player_ptr, (size_t) data))) {
+    request_unit_load(punit, NULL);
+  }
+}
+
+/****************************************************************
+...
+*****************************************************************/
+static void unit_unload_callback(GtkWidget * w, gpointer data)
+{
+  struct unit *punit;
+
+  if ((punit = player_find_unit_by_id(game.player_ptr, (size_t) data))) {
+    request_unit_unload(punit);
+  }
+}
+
+/****************************************************************
+...
+*****************************************************************/
 static void unit_sentry_callback(GtkWidget * w, gpointer data)
 {
   struct unit *punit;

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