Author: jtn
Date: Tue Sep 27 23:16:25 2016
New Revision: 33917

URL: http://svn.gna.org/viewcvs/freeciv?rev=33917&view=rev
Log:
In transport selection dialog, select what we think is the best
transport by default.

See patch #7728.

Modified:
    trunk/client/gui-gtk-3.0/action_dialog.c
    trunk/client/gui-gtk-3.0/transportdlg.c
    trunk/client/gui-gtk-3.0/unitselunitdlg.c
    trunk/client/gui-gtk-3.0/unitselunitdlg.h
    trunk/client/gui-gtk-3.x/action_dialog.c
    trunk/client/gui-gtk-3.x/transportdlg.c
    trunk/client/gui-gtk-3.x/unitselunitdlg.c
    trunk/client/gui-gtk-3.x/unitselunitdlg.h

Modified: trunk/client/gui-gtk-3.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/action_dialog.c?rev=33917&r1=33916&r2=33917&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.0/action_dialog.c    Tue Sep 27 23:16:25 2016
@@ -1229,7 +1229,7 @@
 
   if ((punit = game_unit_by_number(args->actor_unit_id))
       && (ptile = index_to_tile(args->target_tile_id))) {
-    select_tgt_unit(punit, ptile, ptile->units,
+    select_tgt_unit(punit, ptile, ptile->units, NULL,
                     _("Target unit selection"),
                     _("Looking for target unit:"),
                     _("Units at tile:"),

Modified: trunk/client/gui-gtk-3.0/transportdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/transportdlg.c?rev=33917&r1=33916&r2=33917&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/transportdlg.c     (original)
+++ trunk/client/gui-gtk-3.0/transportdlg.c     Tue Sep 27 23:16:25 2016
@@ -83,6 +83,7 @@
 {
   int tcount;
   struct unit_list *potential_transports = unit_list_new();
+  struct unit *best_transport = transporter_for_unit(cargo);
 
   unit_list_iterate(ptile->units, ptransport) {
     if (can_unit_transport(ptransport, cargo)
@@ -94,11 +95,13 @@
   tcount = unit_list_size(potential_transports);
 
   if (tcount == 0) {
+    fc_assert(best_transport == NULL);
     unit_list_destroy(potential_transports);
 
     return FALSE; /* Unit was not handled here. */
   } else if (tcount == 1) {
     /* There's exactly one potential transport - use it automatically */
+    fc_assert(unit_list_get(potential_transports, 0) == best_transport);
     request_unit_load(cargo, unit_list_get(potential_transports, 0), ptile);
 
     unit_list_destroy(potential_transports);
@@ -106,7 +109,7 @@
     return TRUE;
   }
 
-  return select_tgt_unit(cargo, ptile, potential_transports,
+  return select_tgt_unit(cargo, ptile, potential_transports, best_transport,
                          _("Transport selection"),
                          _("Looking for transport:"),
                          _("Transports available:"),

Modified: trunk/client/gui-gtk-3.0/unitselunitdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/unitselunitdlg.c?rev=33917&r1=33916&r2=33917&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/unitselunitdlg.c   (original)
+++ trunk/client/gui-gtk-3.0/unitselunitdlg.c   Tue Sep 27 23:16:25 2016
@@ -69,6 +69,7 @@
 ****************************************************************************/
 bool select_tgt_unit(struct unit *actor, struct tile *ptile,
                      struct unit_list *potential_tgt_units,
+                     struct unit *suggested_tgt_unit,
                      const gchar *dlg_title,
                      const gchar *actor_label,
                      const gchar *tgt_label,
@@ -145,6 +146,9 @@
                      G_CALLBACK(unit_sel_unit_toggled), cbdata);
     g_signal_connect(radio, "destroy",
                      G_CALLBACK(unit_sel_unit_destroyed), cbdata);
+    if (ptgt == suggested_tgt_unit) {
+      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE);
+    }
     gtk_grid_attach(GTK_GRID(box), radio, 0, tcount, 1, 1);
 
     tubuf = usdlg_get_unit_image(ptgt);

Modified: trunk/client/gui-gtk-3.0/unitselunitdlg.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/unitselunitdlg.h?rev=33917&r1=33916&r2=33917&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/unitselunitdlg.h   (original)
+++ trunk/client/gui-gtk-3.0/unitselunitdlg.h   Tue Sep 27 23:16:25 2016
@@ -15,6 +15,7 @@
 
 bool select_tgt_unit(struct unit *actor, struct tile *ptile,
                      struct unit_list *potential_tgt_units,
+                     struct unit *suggested_tgt_unit,
                      const gchar *dlg_title,
                      const gchar *actor_label,
                      const gchar *tgt_label,

Modified: trunk/client/gui-gtk-3.x/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/action_dialog.c?rev=33917&r1=33916&r2=33917&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.x/action_dialog.c    Tue Sep 27 23:16:25 2016
@@ -1223,7 +1223,7 @@
 
   if ((punit = game_unit_by_number(args->actor_unit_id))
       && (ptile = index_to_tile(args->target_tile_id))) {
-    select_tgt_unit(punit, ptile, ptile->units,
+    select_tgt_unit(punit, ptile, ptile->units, NULL,
                     _("Target unit selection"),
                     _("Looking for target unit:"),
                     _("Units at tile:"),

Modified: trunk/client/gui-gtk-3.x/transportdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/transportdlg.c?rev=33917&r1=33916&r2=33917&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/transportdlg.c     (original)
+++ trunk/client/gui-gtk-3.x/transportdlg.c     Tue Sep 27 23:16:25 2016
@@ -83,6 +83,7 @@
 {
   int tcount;
   struct unit_list *potential_transports = unit_list_new();
+  struct unit *best_transport = transporter_for_unit(cargo);
 
   unit_list_iterate(ptile->units, ptransport) {
     if (can_unit_transport(ptransport, cargo)
@@ -94,11 +95,13 @@
   tcount = unit_list_size(potential_transports);
 
   if (tcount == 0) {
+    fc_assert(best_transport == NULL);
     unit_list_destroy(potential_transports);
 
     return FALSE; /* Unit was not handled here. */
   } else if (tcount == 1) {
     /* There's exactly one potential transport - use it automatically */
+    fc_assert(unit_list_get(potential_transports, 0) == best_transport);
     request_unit_load(cargo, unit_list_get(potential_transports, 0), ptile);
 
     unit_list_destroy(potential_transports);
@@ -106,7 +109,7 @@
     return TRUE;
   }
 
-  return select_tgt_unit(cargo, ptile, potential_transports,
+  return select_tgt_unit(cargo, ptile, potential_transports, best_transport,
                          _("Transport selection"),
                          _("Looking for transport:"),
                          _("Transports available:"),

Modified: trunk/client/gui-gtk-3.x/unitselunitdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/unitselunitdlg.c?rev=33917&r1=33916&r2=33917&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/unitselunitdlg.c   (original)
+++ trunk/client/gui-gtk-3.x/unitselunitdlg.c   Tue Sep 27 23:16:25 2016
@@ -69,6 +69,7 @@
 ****************************************************************************/
 bool select_tgt_unit(struct unit *actor, struct tile *ptile,
                      struct unit_list *potential_tgt_units,
+                     struct unit *suggested_tgt_unit,
                      const gchar *dlg_title,
                      const gchar *actor_label,
                      const gchar *tgt_label,
@@ -145,6 +146,9 @@
                      G_CALLBACK(unit_sel_unit_toggled), cbdata);
     g_signal_connect(radio, "destroy",
                      G_CALLBACK(unit_sel_unit_destroyed), cbdata);
+    if (ptgt == suggested_tgt_unit) {
+      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE);
+    }
     gtk_grid_attach(GTK_GRID(box), radio, 0, tcount, 1, 1);
 
     tubuf = usdlg_get_unit_image(ptgt);

Modified: trunk/client/gui-gtk-3.x/unitselunitdlg.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/unitselunitdlg.h?rev=33917&r1=33916&r2=33917&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/unitselunitdlg.h   (original)
+++ trunk/client/gui-gtk-3.x/unitselunitdlg.h   Tue Sep 27 23:16:25 2016
@@ -15,6 +15,7 @@
 
 bool select_tgt_unit(struct unit *actor, struct tile *ptile,
                      struct unit_list *potential_tgt_units,
+                     struct unit *suggested_tgt_unit,
                      const gchar *dlg_title,
                      const gchar *actor_label,
                      const gchar *tgt_label,


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to