Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12320) crosshairs as mapview decorations
Home

[Freeciv-Dev] (PR#12320) crosshairs as mapview decorations

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12320) crosshairs as mapview decorations
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 21 Feb 2005 13:05:57 -0800
Reply-to: bugs@xxxxxxxxxxx

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

This patch turns crosshairs into mapview decorations, and draws them in 
the tilespec code.

This means if you middle-click on the focus unit the cross-hair won't be 
overwritten when the unit is animated.  The goto line for 
middle-clicking is still drawn straight to the canvas so it can still be 
overwritten.

Only the gtk2 client uses the new functionality.

-jason

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.193
diff -u -r1.193 mapview_common.c
--- client/mapview_common.c     19 Feb 2005 17:15:13 -0000      1.193
+++ client/mapview_common.c     21 Feb 2005 21:02:14 -0000
@@ -2758,6 +2758,7 @@
   map_deco = fc_realloc(map_deco, MAP_INDEX_SIZE * sizeof(*map_deco));
   whole_map_iterate(ptile) {
     map_deco[ptile->index].hilite = HILITE_NONE;
+    map_deco[ptile->index].crosshair = 0;
   } whole_map_iterate_end;
 }
 
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.95
diff -u -r1.95 mapview_common.h
--- client/mapview_common.h     19 Feb 2005 17:15:13 -0000      1.95
+++ client/mapview_common.h     21 Feb 2005 21:02:14 -0000
@@ -30,6 +30,8 @@
   enum tile_hilite {
     HILITE_NONE, HILITE_CITY
   } hilite;
+
+  int crosshair; /* A refcount */
 };
 
 struct view {
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.237
diff -u -r1.237 tilespec.c
--- client/tilespec.c   17 Feb 2005 22:11:37 -0000      1.237
+++ client/tilespec.c   21 Feb 2005 21:02:15 -0000
@@ -2964,6 +2964,12 @@
     }
     break;
 
+  case LAYER_OVERLAYS:
+    if (ptile && map_deco[ptile->index].crosshair > 0) {
+      ADD_SPRITE_SIMPLE(sprites.user.attention);
+    }
+    break;
+
   case LAYER_COUNT:
     assert(0);
     break;
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.104
diff -u -r1.104 tilespec.h
--- client/tilespec.h   17 Feb 2005 22:11:37 -0000      1.104
+++ client/tilespec.h   21 Feb 2005 21:02:15 -0000
@@ -91,6 +91,7 @@
   LAYER_UNIT,
   LAYER_SPECIAL3,
   LAYER_GRID2,
+  LAYER_OVERLAYS,
   LAYER_COUNT
 };
 
Index: client/gui-gtk-2.0/mapctrl.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapctrl.c,v
retrieving revision 1.46
diff -u -r1.46 mapctrl.c
--- client/gui-gtk-2.0/mapctrl.c        14 Feb 2005 17:52:56 -0000      1.46
+++ client/gui-gtk-2.0/mapctrl.c        21 Feb 2005 21:02:15 -0000
@@ -110,7 +110,7 @@
 static void popit(GdkEventButton *event, struct tile *ptile)
 {
   GtkWidget *p;
-  static struct tile *cross_list[2 + 1];
+  struct tile *cross_list[2 + 1];
   struct tile **cross_head = cross_list;
   int i;
   static struct tmousepos mousepos;
@@ -128,9 +128,11 @@
     is_orders = show_unit_orders(punit);
 
     if (punit && punit->goto_tile) {
+      map_deco[punit->goto_tile->index].crosshair++;
       *cross_head = punit->goto_tile;
       cross_head++;
     }
+    map_deco[ptile->index].crosshair++;
     *cross_head = ptile;
     cross_head++;
 
@@ -139,8 +141,7 @@
       put_cross_overlay_tile(cross_list[i]);
     }
     g_signal_connect(p, "destroy",
-                    G_CALLBACK(popupinfo_popdown_callback),
-                    GINT_TO_POINTER(is_orders));
+                    G_CALLBACK(popupinfo_popdown_callback), NULL);
 
     mousepos.x = event->x;
     mousepos.y = event->y;
@@ -164,13 +165,13 @@
 **************************************************************************/
 void popupinfo_popdown_callback(GtkWidget *w, gpointer data)
 {
-  bool full = GPOINTER_TO_INT(data);
+  /* We could just remove the crosshairs that we placed earlier, but
+   * this is easier. */
+  whole_map_iterate(ptile) {
+    map_deco[ptile->index].crosshair = 0;
+  } whole_map_iterate_end;
 
-  if (full) {
-    update_map_canvas_visible();
-  } else {
-    dirty_all();
-  }
+  update_map_canvas_visible();
 }
 
  /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12320) crosshairs as mapview decorations, Jason Short <=