Complete.Org: Mailing Lists: Archives: freeciv-dev: July 1999:
[Freeciv-Dev] PATCH: select multiple units at city report (take2)
Home

[Freeciv-Dev] PATCH: select multiple units at city report (take2)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] PATCH: select multiple units at city report (take2)
From: Markus Linnala <maage@xxxxxxxxx>
Date: 04 Jul 1999 02:12:49 +0300
Reply-to: Markus Linnala <maage@xxxxxxxxx>

With this patch you can select arbiturary amount of cities and
issue buy and changes commands on them. Try pointing shift or
alt pressed.

Examples:
- select 1 city and issue command, works as before
- select 2 or more cities and issue buy, client tries to buy
  improvement or unit at all cities, you can easily use all your
  money
- select 2 or more cities and issue change, select one, client
  tries to change production to the one you selected, if you
  select building and city already has building, there is no
  change, if you have 10 cities with all buildings, 10 without
  supermarket and one brand new, you can select all, then press
  alt and mouse on brand new twice and select supermarket on a
  list
- select all cities and deselect one which is building wonder,
  select another city again, change to caravan
- game just sold your barracks', select all and change to
  barracks N+1, issue buy, you have barracks again
- you have lot of money, more than you can use, select all and
  buy, too bad you don't buy capitalization
- pollution is not your friend, select every city with pollution
  and change them to build recycling

Another part of the patch adds same idea to the trade dialog.
Select all buildings and push 'Sell obsolete'. You get lot of
popups with confusing messages, but don't be alarmed. You just
sold all possible obsolete buildings. You can also easily sell
all buildings. Beware.

Comments:
User interface is not the best one. But this patch sure helps to
manage lot cities and lessens micromanagement. I hope you'll
include it to the main distribution. No Xaw version, sorry.

Patch is agains latest cvs-version.

------------------------------------------------------------------------
diff -u --ignore-space-change --recursive --new-file --exclude-from=.diffignore 
freeciv-cvs/client/gui-gtk/cityrep.c m/freeciv/client/gui-gtk/cityrep.c
--- freeciv-cvs/client/gui-gtk/cityrep.c        Sat Jun 12 15:03:21 1999
+++ m/freeciv/client/gui-gtk/cityrep.c  Sun Jul  4 01:52:26 1999
@@ -396,6 +396,7 @@
   city_list = gtk_clist_new_with_titles(NUM_CREPORT_COLS,titles);
   gtk_clist_column_titles_passive(GTK_CLIST(city_list));
   gtk_clist_set_auto_sort (GTK_CLIST (city_list), TRUE);
+  gtk_clist_set_selection_mode(GTK_CLIST (city_list), GTK_SELECTION_EXTENDED);
   scrolled = gtk_scrolled_window_new(NULL, NULL);
   gtk_container_add(GTK_CONTAINER(scrolled), city_list);
   gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled ),
@@ -545,10 +546,13 @@
 
 void city_list_ucallback(GtkWidget *w, gint row, gint column)
 {
+  if (!GTK_CLIST( city_list )->selection)
+  {
       gtk_widget_set_sensitive(city_change_command, FALSE);
       gtk_widget_set_sensitive(city_center_command, FALSE);
       gtk_widget_set_sensitive(city_popup_command, FALSE);
       gtk_widget_set_sensitive(city_buy_command, FALSE);
+  }
 }
 
 /****************************************************************
@@ -587,9 +591,8 @@
   gint                row;
   struct city *pcity;
 
-  if ( !( selection = GTK_CLIST( city_list )->selection ) )
-      return;
-
+  while((selection = GTK_CLIST(city_list)->selection) != NULL)
+  {
   row = (gint)selection->data;
 
   if((pcity=gtk_clist_get_row_data(GTK_CLIST(city_list),row)))
@@ -613,6 +616,9 @@
       packet.build_id=build_nr;
       packet.is_build_id_unit_id=unit;
       send_packet_city_request(&aconnection, &packet, PACKET_CITY_CHANGE);
+
+    }
+    gtk_clist_unselect_row(GTK_CLIST(city_list),row,0);
   }
 }
 
@@ -625,9 +631,8 @@
   gint                row;
   struct city *pcity;
 
-  if ( !( selection = GTK_CLIST( city_list )->selection ) )
-      return;
-
+  while ((selection = GTK_CLIST(city_list)->selection) != NULL)
+  {
   row = (gint)selection->data;
 
   if((pcity=gtk_clist_get_row_data(GTK_CLIST(city_list),row)))
@@ -656,6 +661,8 @@
          append_output_window(buf);
        }
   }
+    gtk_clist_unselect_row(GTK_CLIST(city_list),row,0);
+  }
 }
 
 /****************************************************************
@@ -697,14 +704,15 @@
   gint                row;
   struct city        *pcity;
 
-  if ( !( selection = GTK_CLIST( city_list )->selection ) )
-      return;
-
+  while((selection = GTK_CLIST(city_list)->selection) != NULL)
+  {
   row = (gint)selection->data;
 
   if((pcity=gtk_clist_get_row_data(GTK_CLIST(city_list),row))){
     center_tile_mapcanvas(pcity->x, pcity->y);
     popup_city_dialog(pcity, 0);
+  }
+    gtk_clist_unselect_row(GTK_CLIST(city_list),row,0);
   }
 }
 
diff -u --ignore-space-change --recursive --new-file --exclude-from=.diffignore 
freeciv-cvs/client/gui-gtk/repodlgs.c m/freeciv/client/gui-gtk/repodlgs.c
--- freeciv-cvs/client/gui-gtk/repodlgs.c       Sat Jun 12 15:03:23 1999
+++ m/freeciv/client/gui-gtk/repodlgs.c Sat Jul  3 16:03:27 1999
@@ -506,6 +506,7 @@
   trade_list = gtk_clist_new_with_titles( 4, titles );
   gtk_clist_column_titles_passive(GTK_CLIST(trade_list));
   scrolled = gtk_scrolled_window_new(NULL,NULL);
+  gtk_clist_set_selection_mode(GTK_CLIST (trade_list), GTK_SELECTION_EXTENDED);
   gtk_container_add(GTK_CONTAINER(scrolled), trade_list);
   gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled ),
                          GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
@@ -609,9 +610,8 @@
   GList              *selection;
   gint                row;
 
-  if ( !( selection = GTK_CLIST( trade_list )->selection ) )
-      return;
-
+  while((selection = GTK_CLIST(trade_list)->selection) != NULL)
+  {
   row = (gint)selection->data;
 
   i=trade_improvement_type[row];
@@ -635,7 +635,9 @@
   } else {
     sprintf(str,"No %s could be sold",get_improvement_name(i));
   };
+    gtk_clist_unselect_row(GTK_CLIST(trade_list),row,0);
   popup_notify_dialog("Sell-Off Results",str);
+  }
   return;
 }

-- 
//Markus

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