Complete.Org: Mailing Lists: Archives: freeciv-dev: March 1999:
[Freeciv-Dev] Patch: Goto mouse cursor
Home

[Freeciv-Dev] Patch: Goto mouse cursor

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Patch: Goto mouse cursor
From: Falk Hueffner <falk.hueffner@xxxxxxxxxxxxxxxxxxxxxxxx>
Date: 23 Mar 1999 17:40:33 +0100

Hi,

I've cleaned up my goto mouse cursor patch a bit.

Changes:
- doesn't use strange global variables any more
- cursors now 16x16
- some more error checking
- free initial pixmaps to regain a few bytes

I also considered using a predefined cursor, but my play-testers
didn't like any :), and there's no GUI consistency in X anyway.

        Falk



diff -Nurd -X X.freeciv freeciv-03.07/client/graphics.c 
freeciv-03.07-goto-cursor/client/graphics.c
--- freeciv-03.07/client/graphics.c     Sun Feb 21 12:33:04 1999
+++ freeciv-03.07-goto-cursor/client/graphics.c Thu Mar 18 21:22:58 1999
@@ -30,10 +30,12 @@
 #include <colors.h>
 #include <climisc.h>
 
+#include <../data/goto_cursor.xbm>
+#include <../data/goto_cursor_mask.xbm>
+
 extern int display_depth;
 extern Widget map_canvas;
 extern Display *display;
-extern XColor colors[MAX_COLORS];
 extern GC fill_bg_gc;
 extern GC civ_gc, font_gc;
 extern Colormap cmap;
@@ -55,6 +57,7 @@
 int ROAD_TILES;
 int RAIL_TILES;
 
+Cursor goto_cursor;
 
 /***************************************************************************
 ...
@@ -321,6 +324,31 @@
   free_sprite(flags_sprite);
 }
 
+/***************************************************************************
+...
+***************************************************************************/
+void load_cursors(void)
+{
+  Pixmap pixmap, mask;
+  XColor white, black;
+
+  white.pixel = colors_standard[COLOR_STD_WHITE];
+  black.pixel = colors_standard[COLOR_STD_BLACK];
+  XQueryColor(display, cmap, &white);
+  XQueryColor(display, cmap, &black);
+
+  pixmap = XCreateBitmapFromData(display, root_window, goto_cursor_bits,
+                                goto_cursor_width, goto_cursor_height);
+  mask   = XCreateBitmapFromData(display, root_window, goto_cursor_mask_bits,
+                                goto_cursor_mask_width, 
goto_cursor_mask_height);
+
+  goto_cursor = XCreatePixmapCursor(display, pixmap, mask,
+                                   &white, &black,
+                                   goto_cursor_x_hot, goto_cursor_y_hot);
+
+  XFreePixmap(display, pixmap);
+  XFreePixmap(display, mask);
+}
 
 /***************************************************************************
 ...
diff -Nurd -X X.freeciv freeciv-03.07/client/graphics.h 
freeciv-03.07-goto-cursor/client/graphics.h
--- freeciv-03.07/client/graphics.h     Sat Nov 21 12:31:49 1998
+++ freeciv-03.07-goto-cursor/client/graphics.h Tue Mar 16 21:49:10 1999
@@ -69,6 +69,7 @@
 struct Sprite *get_tile_sprite(int tileno);
 void load_tile_gfx(void);
 void load_intro_gfx(void);
+void load_cursors(void);
 
 struct Sprite *load_gfxfile(char *filename, int makemask);
 
diff -Nurd -X X.freeciv freeciv-03.07/client/mapview.c 
freeciv-03.07-goto-cursor/client/mapview.c
--- freeciv-03.07/client/mapview.c      Thu Mar  4 12:34:10 1999
+++ freeciv-03.07-goto-cursor/client/mapview.c  Thu Mar 18 21:20:39 1999
@@ -68,6 +68,7 @@
 
 extern struct Sprite *intro_gfx_sprite;
 extern struct Sprite *radar_gfx_sprite;
+extern Cursor goto_cursor;
 
 extern Pixmap map_canvas_store;
 extern int map_canvas_store_twidth, map_canvas_store_theight;
@@ -273,6 +274,12 @@
            pcity ? pcity->name : "");
 
     xaw_set_label(unit_info_label, buffer);
+    if (goto_cursor != (Cursor) None) {
+      if (goto_state == punit->id)
+       XDefineCursor(display, XtWindow(map_canvas), goto_cursor);
+      else
+       XUndefineCursor(display, XtWindow(map_canvas));
+    }
   }
   else
     xaw_set_label(unit_info_label, "");
diff -Nurd -X X.freeciv freeciv-03.07/client/xmain.c 
freeciv-03.07-goto-cursor/client/xmain.c
--- freeciv-03.07/client/xmain.c        Mon Feb 22 12:32:12 1999
+++ freeciv-03.07-goto-cursor/client/xmain.c    Tue Mar 16 21:49:10 1999
@@ -401,8 +401,9 @@
   num_units_below = MAX(num_units_below,1);
   
   setup_widgets();
-  load_intro_gfx(); 
-  
+  load_intro_gfx();
+  load_cursors();
+
   XtSetKeyboardFocus(bottom_form, inputline_text);
   XtSetKeyboardFocus(below_menu_form, map_canvas);
   
diff -Nurd -X X.freeciv freeciv-03.07/data/Makefile.am 
freeciv-03.07-goto-cursor/data/Makefile.am
--- freeciv-03.07/data/Makefile.am      Sun Feb 14 12:31:49 1999
+++ freeciv-03.07-goto-cursor/data/Makefile.am  Tue Mar 16 21:49:10 1999
@@ -10,6 +10,6 @@
        intro.xpm       \
        radar.xpm
 
-EXTRA_DIST = $(pkgdata_DATA)
+EXTRA_DIST = $(pkgdata_DATA) goto_cursor.xbm goto_cursor_mask.xbm
 
 SUBDIRS = default civ1 classic
diff -Nurd -X X.freeciv freeciv-03.07/data/goto_cursor.xbm 
freeciv-03.07-goto-cursor/data/goto_cursor.xbm
--- freeciv-03.07/data/goto_cursor.xbm  Thu Jan  1 01:00:00 1970
+++ freeciv-03.07-goto-cursor/data/goto_cursor.xbm      Thu Mar 18 21:22:30 1999
@@ -0,0 +1,8 @@
+#define goto_cursor_width 16
+#define goto_cursor_height 16
+#define goto_cursor_x_hot 1
+#define goto_cursor_y_hot 1
+static char goto_cursor_bits[] = {
+ 0x00,0x00,0x1e,0x00,0x0e,0x00,0x1e,0x00,0xfa,0x1f,0xf0,0x3f,0x00,0x00,0x3c,
+ 0x1e,0x66,0x33,0x06,0x33,0x06,0x33,0x76,0x33,0x66,0x33,0x66,0x33,0x3c,0x1e,
+ 0x00,0x00};
diff -Nurd -X X.freeciv freeciv-03.07/data/goto_cursor_mask.xbm 
freeciv-03.07-goto-cursor/data/goto_cursor_mask.xbm
--- freeciv-03.07/data/goto_cursor_mask.xbm     Thu Jan  1 01:00:00 1970
+++ freeciv-03.07-goto-cursor/data/goto_cursor_mask.xbm Thu Mar 18 20:48:05 1999
@@ -0,0 +1,6 @@
+#define goto_cursor_mask_width 16
+#define goto_cursor_mask_height 16
+static char goto_cursor_mask_bits[] = {
+ 0x3f,0x00,0x3f,0x00,0x3f,0x00,0xff,0x3f,0xff,0x7f,0xff,0x7f,0xfe,0x7f,0xff,
+ 0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,
+ 0x7e,0x3f};


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