Author: sveinung
Date: Wed Aug 10 16:45:04 2016
New Revision: 33542

URL: http://svn.gna.org/viewcvs/freeciv?rev=33542&view=rev
Log:
Support user specified target tile for "Do...".

Common client code support for letting the user specify the tile "Do..."
should target. No client uses it yet. The user specifies the target tile by
selecting it on the map.

See patch #7572

Modified:
    trunk/client/control.c
    trunk/client/control.h
    trunk/client/goto.c
    trunk/client/mapctrl_common.c
    trunk/client/mapview_common.c

Modified: trunk/client/control.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/control.c?rev=33542&r1=33541&r2=33542&view=diff
==============================================================================
--- trunk/client/control.c      (original)
+++ trunk/client/control.c      Wed Aug 10 16:45:04 2016
@@ -1260,6 +1260,10 @@
   case HOVER_PARADROP:
     /* FIXME: check for invalid tiles. */
     mouse_cursor_type = CURSOR_PARADROP;
+    break;
+  case HOVER_ACT_SEL_TGT:
+    /* Select a tile to target / find targets on. */
+    mouse_cursor_type = CURSOR_SELECT;
     break;
   };
 
@@ -2622,6 +2626,22 @@
 }
 
 /**************************************************************************
+  An action selection dialog for the selected units against the specified
+  tile is wanted.
+**************************************************************************/
+static void do_unit_act_sel_vs(struct tile *ptile)
+{
+  unit_list_iterate(get_units_in_focus(), punit) {
+    if (utype_may_act_at_all(unit_type_get(punit))) {
+      /* Have the server record that an action decision is wanted for
+       * this unit against this tile. */
+      dsend_packet_unit_sscs_set(&client.conn, punit->id,
+                                 USSDT_QUEUE, tile_index(ptile));
+    }
+  } unit_list_iterate_end;
+}
+
+/**************************************************************************
  Handles everything when the user clicked a tile
 **************************************************************************/
 void do_map_click(struct tile *ptile, enum quickselect_type qtype)
@@ -2648,6 +2668,9 @@
     case HOVER_PATROL:
       do_unit_patrol_to(ptile);
       break;   
+    case HOVER_ACT_SEL_TGT:
+      do_unit_act_sel_vs(ptile);
+      break;
     }
 
     set_hover_state(NULL, HOVER_NONE,
@@ -2905,6 +2928,7 @@
     }
     /* else fall through: */
   case HOVER_PARADROP:
+  case HOVER_ACT_SEL_TGT:
     set_hover_state(NULL, HOVER_NONE,
                     ACTIVITY_LAST, NULL,
                     EXTRA_NONE, ACTION_COUNT, ORDER_LAST);
@@ -3029,6 +3053,18 @@
                                  USSDT_QUEUE, tile_index(ptile));
     }
   } unit_list_iterate_end;
+}
+
+/**************************************************************************
+  Have the user select what action the unit(s) in focus should perform to
+  the targets at the tile the user will specify by clicking on it.
+**************************************************************************/
+void key_unit_action_select_tgt(void)
+{
+  struct unit_list *punits = get_units_in_focus();
+
+  set_hover_state(punits, HOVER_ACT_SEL_TGT, ACTIVITY_LAST, NULL,
+                  EXTRA_NONE, ACTION_COUNT, ORDER_LAST);
 }
 
 /**************************************************************************

Modified: trunk/client/control.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/control.h?rev=33542&r1=33541&r2=33542&view=diff
==============================================================================
--- trunk/client/control.h      (original)
+++ trunk/client/control.h      Wed Aug 10 16:45:04 2016
@@ -27,7 +27,8 @@
   HOVER_GOTO,
   HOVER_PARADROP,
   HOVER_CONNECT,
-  HOVER_PATROL
+  HOVER_PATROL,
+  HOVER_ACT_SEL_TGT
 };
 
 /* Selecting unit from a stack without popup. */
@@ -229,6 +230,7 @@
 void key_unit_connect(enum unit_activity activity,
                       struct extra_type *tgt);
 void key_unit_action_select(void);
+void key_unit_action_select_tgt(void);
 void key_unit_convert(void);
 void key_unit_done(void);
 void key_unit_fallout(void);

Modified: trunk/client/goto.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/goto.c?rev=33542&r1=33541&r2=33542&view=diff
==============================================================================
--- trunk/client/goto.c (original)
+++ trunk/client/goto.c Wed Aug 10 16:45:04 2016
@@ -967,9 +967,12 @@
     break;
   case HOVER_NONE:
   case HOVER_PARADROP:
+  case HOVER_ACT_SEL_TGT:
     fc_assert_msg(hover_state != HOVER_NONE, "Goto with HOVER_NONE?");
     fc_assert_msg(hover_state != HOVER_PARADROP,
                   "Goto with HOVER_PARADROP?");
+    fc_assert_msg(hover_state != HOVER_ACT_SEL_TGT,
+                  "Goto with HOVER_ACT_SEL_TGT?");
     break;
   };
 }

Modified: trunk/client/mapctrl_common.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/mapctrl_common.c?rev=33542&r1=33541&r2=33542&view=diff
==============================================================================
--- trunk/client/mapctrl_common.c       (original)
+++ trunk/client/mapctrl_common.c       Wed Aug 10 16:45:04 2016
@@ -657,6 +657,7 @@
     is_valid_goto_draw_line(ptile);
   case HOVER_NONE:
   case HOVER_PARADROP:
+  case HOVER_ACT_SEL_TGT:
     break;
   };
 }
@@ -679,6 +680,7 @@
     is_valid_goto_draw_line(ptile);
   case HOVER_NONE:
   case HOVER_PARADROP:
+  case HOVER_ACT_SEL_TGT:
     break;
   };
 }

Modified: trunk/client/mapview_common.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/mapview_common.c?rev=33542&r1=33541&r2=33542&view=diff
==============================================================================
--- trunk/client/mapview_common.c       (original)
+++ trunk/client/mapview_common.c       Wed Aug 10 16:45:04 2016
@@ -588,6 +588,7 @@
     create_line_at_mouse_pos();
   case HOVER_NONE:
   case HOVER_PARADROP:
+  case HOVER_ACT_SEL_TGT:
     break;
   };
   if (rectangle_active) {


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

Reply via email to