[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freeciv-dev
Subject:    [Freeciv-Dev] (PR#40724) [Patch] Option to not clear unit orders on
From:       "Madeline Book" <madeline.book () gmail ! com>
Date:       2009-02-15 2:15:54
Message-ID: 200902150215.n1F2Fsaa006607 () rt ! freeciv ! org
[Download RAW message or body]

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

Patch implements a client option to disable the behaviour
that makes units lose their orders/current activity when
they are selected. So when the option is not set to its
default value, clicking on a unit or selecting a group of
units with the selection rectangle or mass select
shortcuts (e.g. 'y') will not immediately make the units
stop what they are doing. Instead, the units' orders will
only be cleared when the user issues new orders (e.g.
goto somewhere else, a different activity, etc.) or when
<space> is pressed.


-----------------------------------------------------------------------
中断のせいで今何をするか忘れた。

["optional_unit_order_clear.patch" (text/x-diff)]

 client/control.c |   15 +++++++++++++++
 client/control.h |    1 +
 client/goto.c    |    1 +
 client/options.c |   10 ++++++++++
 client/options.h |    1 +
 5 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/client/control.c b/client/control.c
index 2925528..280c4ba 100644
--- a/client/control.c
+++ b/client/control.c
@@ -309,6 +309,20 @@ static void current_focus_append(struct unit *punit)
   punit->focus_status = FOCUS_AVAIL;
   refresh_unit_mapcanvas(punit, punit->tile, TRUE, FALSE);
 
+  if (unit_selection_clears_orders) {
+    clear_unit_orders(punit);
+  }
+}
+
+/**************************************************************************
+  Clear all orders for the given unit.
+**************************************************************************/
+void clear_unit_orders(struct unit *punit)
+{
+  if (!punit) {
+    return;
+  }
+
   if (unit_has_orders(punit)) {
     /* Clear the focus unit's orders. */
     request_orders_cleared(punit);
@@ -1828,6 +1842,7 @@ void request_unit_move_done(void)
 {
   if (get_num_units_in_focus() > 0) {
     unit_list_iterate(get_units_in_focus(), punit) {
+      clear_unit_orders(punit);
       punit->focus_status = FOCUS_DONE;
     } unit_list_iterate_end;
     advance_unit_focus();
diff --git a/client/control.h b/client/control.h
index 63b7f0c..4512d18 100644
--- a/client/control.h
+++ b/client/control.h
@@ -122,6 +122,7 @@ void request_toggle_focus_unit(void);
 void request_toggle_fog_of_war(void);
 
 void wakeup_sentried_units(struct tile *ptile);
+void clear_unit_orders(struct unit *punit);
 
 bool unit_is_in_focus(const struct unit *punit);
 struct unit *get_focus_unit_on_tile(const struct tile *ptile);
diff --git a/client/goto.c b/client/goto.c
index 07d0056..8115325 100644
--- a/client/goto.c
+++ b/client/goto.c
@@ -1181,6 +1181,7 @@ void send_goto_route(void)
       path = pft_concat(path, goto_map->parts[i].path);
     }
 
+    clear_unit_orders(punit);
     if (goto_last_order == ORDER_LAST) {
       send_goto_path(punit, path, NULL);
     } else {
diff --git a/client/options.c b/client/options.c
index e0b6fb5..536ede8 100644
--- a/client/options.c
+++ b/client/options.c
@@ -89,6 +89,7 @@ bool keyboardless_goto = TRUE;
 bool show_task_icons = TRUE;
 bool enable_cursor_changes = TRUE;
 bool separate_unit_selection = FALSE;
+bool unit_selection_clears_orders = TRUE;
 
 /* This option is currently set by the client - not by the user. */
 bool update_city_text_in_refresh_tile = TRUE;
@@ -256,6 +257,15 @@ static client_option common_options[] = {
                      "units are present in the selection rectangle, only "
                      "cities will be selected."),
                   COC_INTERFACE),
+  GEN_BOOL_OPTION(unit_selection_clears_orders,
+                  N_("Clear unit orders on selection"),
+                  N_("Enabling this option will cause unit orders to be "
+                     "cleared whenever one or more units are selected. If "
+                     "this option is disabled, selecting units will not "
+                     "cause them to stop their current activity. Instead, "
+                     "their orders will be cleared only when new orders "
+                     "are given or if you press <space>."),
+                  COC_INTERFACE),
 
   GEN_BOOL_OPTION(overview.layers[OLAYER_BACKGROUND],
 		  N_("Background layer"),
diff --git a/client/options.h b/client/options.h
index e3e3e75..fcbaae6 100644
--- a/client/options.h
+++ b/client/options.h
@@ -53,6 +53,7 @@ extern bool keyboardless_goto;
 extern bool show_task_icons;
 extern bool enable_cursor_changes;
 extern bool separate_unit_selection;
+extern bool unit_selection_clears_orders;
 
 enum client_option_type {
   COT_BOOL,


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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic