Complete.Org: Mailing Lists: Archives: freeciv-dev: October 1999:
[Freeciv-Dev] Mouse selection
Home

[Freeciv-Dev] Mouse selection

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Mouse selection
From: Pierre de Mouveaux <p_de_mouveaux@xxxxxxxxxxx>
Date: Sun, 03 Oct 1999 02:31:49 +0200

Hello,

as I like to move units with the mouse, I did some minor mdifications to
the mapctrl.c file of the client, both GTK and XAW.

I did the patches agains ***1.8.1*** .

It's then possible to move units with the mouse, in all 8 directions,
attack enemies, etc.
As I did'nt want to change the exixting mouse buttons assignment , the
is a (minor) drawback.
When you click on your owened cities or units, there is already an
operation programed:
- on city, opens the city editor;
- on owened units, changes selected unit, or open a popup if multiple
units on the same tile.

In order to have an unit to enter one of yours cities, you just have to
hold the control key while clicking on the city tile: the unit will move
into the city, rater than opening the city editor popup.
The same way, if you want to mouve a unit on a tile where there is
already one (or more...) of your owned units, holding the control key
will move the unit, rather than changing the selected unit.
Other functions, lige "goto" etc... are not afected.

Here are the diffs (GNU diff - u) for GTK and for XAW.

All in the hope that other players who like playing with mouse will like
it...

Pierre.


Pierre de Mouveaux - Paris [France]

Diffs for XAW:

--------8<----------------------------------
--- mapctrl-orig.c Sun Oct  3 01:37:53 1999
+++ mapctrl.c Sun Oct  3 02:04:47 1999
@@ -917,31 +917,53 @@
     return;
   }

-  if(ev->button==Button1) {
-    if(unit_list_size(&ptile->units)==1) {
-      struct unit *punit=unit_list_get(&ptile->units, 0);
-      if(game.player_idx==punit->owner) {
- if(can_unit_do_activity(punit, ACTIVITY_IDLE)) {
-   /* struct unit *old_focus=get_unit_in_focus(); */
-   request_new_unit_activity(punit, ACTIVITY_IDLE);
-   /* this is now done in set_unit_focus: --dwp */
-   /* if(old_focus)
-      refresh_tile_mapcanvas(old_focus->x, old_focus->y, 1); */
-   set_unit_focus(punit);
- }
-      }
-
-    }
-    else if(unit_list_size(&ptile->units)>=2) {
-      if(unit_list_get(&ptile->units, 0)->owner==game.player_idx)
- popup_unit_select_dialog(ptile);
-    }
+ if(ev->button==Button1) {
+  if((unit_list_size(&ptile->units)==1) && !(ev->state&ControlMask))  {

+    struct unit *punit=unit_list_get(&ptile->units, 0);
+   if(game.player_idx==punit->owner) {
+    if(can_unit_do_activity(punit, ACTIVITY_IDLE)) {
+     /* struct unit *old_focus=get_unit_in_focus(); */
+      request_new_unit_activity(punit, ACTIVITY_IDLE);
+        /* this is now done in set_unit_focus: --dwp */
+        /* if(old_focus) refresh_tile_mapcanvas(old_focus->x,
old_focus->y, 1); */
+     set_unit_focus(punit);
+     return ;
+    }
+   }
+   }
+   if((unit_list_size(&ptile->units)>=2) && !(ev->state&ControlMask)) {

+     if(unit_list_get(&ptile->units, 0)->owner==game.player_idx) {
+    popup_unit_select_dialog(ptile);
+    return ;
+    }
+  }
+  {
+   struct unit *punit=get_unit_in_focus();
+    int dx = 0, dy=0;
+    if (!punit) return;
+   dy = ytile - punit->y;
+   if ((dy>1)||(dy<-1))
+    return;
+   if ((xtile==map.xsize-1)&&(punit->x==0)) {
+    dx = -1;
+   } else if ((punit->x==map.xsize-1)&&(xtile==0)) {
+    dx = 1;
+   } else {
+    dx = xtile - punit->x;
+    if ((dx>1)||(dx<-1)) return;
+   }
+   if ((dx==0)&&(dy==0))
+    return ;
+   request_move_unit_direction(punit,dx,dy);
+   return;
+   }
   }
-  else if(ev->button==Button2||ev->state&ControlMask)
-    popit(ev->x, ev->y, xtile, ytile);
+  else if((ev->button==Button2)||(ev->state&ControlMask))
+      popit(ev->x, ev->y, xtile, ytile);
   else
     center_tile_mapcanvas(xtile, ytile);
 }
+

 /**************************************************************************

 ...
------8<------------------------------------------------
END OF GTK DIFFS [mapctrl.c]


Diffs for GTK:

--------8<----------------------------------
--- mapctrl.orig.c Sat Oct  2 21:34:04 1999
+++ mapctrl.c Sun Oct  3 00:09:33 1999
@@ -926,30 +926,51 @@
     return TRUE;
   }

-  if(pcity && (event->button==1) && (game.player_idx==pcity->owner)) {
+  if(pcity && (event->button==1) && (game.player_idx==pcity->owner) &&
!(event->state &GDK_CONTROL_MASK)) {
     popup_city_dialog(pcity, 0);
     return TRUE;
   }

   if(event->button==1) {
-    if(unit_list_size(&ptile->units)==1) {
-      struct unit *punit=unit_list_get(&ptile->units, 0);
-      if(game.player_idx==punit->owner) {
- if(can_unit_do_activity(punit, ACTIVITY_IDLE)) {
-         /* struct unit *old_focus=get_unit_in_focus(); */
-   request_new_unit_activity(punit, ACTIVITY_IDLE);
-         /* this is now done in set_unit_focus: --dwp */
-         /* if(old_focus)
-            refresh_tile_mapcanvas(old_focus->x, old_focus->y, 1); */
-   set_unit_focus(punit);
- }
-      }
-
-    }
-    else if(unit_list_size(&ptile->units)>=2) {
-      if(unit_list_get(&ptile->units, 0)->owner==game.player_idx)
- popup_unit_select_dialog(ptile);
-    }
+  if((unit_list_size(&ptile->units)==1) && !(event->state
&GDK_CONTROL_MASK))  {
+    struct unit *punit=unit_list_get(&ptile->units, 0);
+   if(game.player_idx==punit->owner) {
+    if(can_unit_do_activity(punit, ACTIVITY_IDLE)) {
+     /* struct unit *old_focus=get_unit_in_focus(); */
+      request_new_unit_activity(punit, ACTIVITY_IDLE);
+        /* this is now done in set_unit_focus: --dwp */
+        /* if(old_focus) refresh_tile_mapcanvas(old_focus->x,
old_focus->y, 1); */
+     set_unit_focus(punit);
+     return TRUE;
+    }
+   }
+   }
+   if((unit_list_size(&ptile->units)>=2) && !(event->state
&GDK_CONTROL_MASK)) {
+     if(unit_list_get(&ptile->units, 0)->owner==game.player_idx) {
+    popup_unit_select_dialog(ptile);
+    return TRUE;
+    }
+  }
+  {
+   struct unit *punit=get_unit_in_focus();
+    int dx = 0, dy=0;
+    if (!punit) return TRUE;
+   dy = ytile - punit->y;
+   if ((dy>1)||(dy<-1))
+    return TRUE;
+   if ((xtile==map.xsize-1)&&(punit->x==0)) {
+    dx = -1;
+   } else if ((punit->x==map.xsize-1)&&(xtile==0)) {
+    dx = 1;
+   } else {
+    dx = xtile - punit->x;
+    if ((dx>1)||(dx<-1)) return TRUE;
+   }
+   if ((dx==0)&&(dy==0))
+    return TRUE;
+   request_move_unit_direction(punit,dx,dy);
+   return TRUE;
+   }
   }
   else if((event->button==2)||(event->state&GDK_CONTROL_MASK))
     popit(event, xtile, ytile);
------8<------------------------------------------------
END OF GTK DIFFS [mapctrl.c]




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