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: 17 Mar 1999 15:35:16 +0100

Hi,

this patch adds a special "goto" mouse cursor if you press 'g', so you 
don't send units accidentally when pressing it mistakenly.

It would be nice if somebody could test it and check it in.

The patch removes some lines that seem to be obsolete, namely an array 
XColor colors[MAX_COLORS]. I'm pretty sure the're not needed.


        Falk



diff -Nurd -X X.freeciv freeciv-03.07/client/colors.c 
freeciv-03.07-goto-cursor/client/colors.c
--- freeciv-03.07/client/colors.c       Thu Feb 11 10:13:27 1999
+++ freeciv-03.07-goto-cursor/client/colors.c   Tue Mar 16 21:49:10 1999
@@ -22,13 +22,13 @@
 #include <colors.h>
 
 Colormap cmap;
+XColor color_black, color_white;
+
 extern int screen_number;
 extern Display *display;
 extern Widget toplevel;
 extern Widget map_canvas;
 
-
-
 /* This is just so we can print the visual class intelligibly */
 /*static char *visual_class[] = {
    "StaticGray",
@@ -107,9 +107,12 @@
       colors_standard[i]=mycolor.pixel;
     else
       color_error();
-  
+
+    if (i == COLOR_STD_WHITE)
+      color_white = mycolor;
+    else if (i == COLOR_STD_BLACK)
+      color_black = mycolor;
   }
-  
 }
 
 /*************************************************************
diff -Nurd -X X.freeciv freeciv-03.07/client/colors.h 
freeciv-03.07-goto-cursor/client/colors.h
--- freeciv-03.07/client/colors.h       Fri May  1 05:35:36 1998
+++ freeciv-03.07-goto-cursor/client/colors.h   Tue Mar 16 21:50:06 1999
@@ -17,8 +17,6 @@
 #include <X11/Xutil.h>
 #include <X11/Xos.h>
 
-#define MAX_COLORS 256
-
 enum { 
   COLOR_STD_BLACK, COLOR_STD_WHITE, COLOR_STD_RED,
   COLOR_STD_YELLOW, COLOR_STD_CYAN,
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 Tue Mar 16 23:04:54 1999
@@ -30,10 +30,13 @@
 #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 XColor color_black, color_white;
 extern GC fill_bg_gc;
 extern GC civ_gc, font_gc;
 extern Colormap cmap;
@@ -55,6 +58,7 @@
 int ROAD_TILES;
 int RAIL_TILES;
 
+Cursor goto_cursor;
 
 /***************************************************************************
 ...
@@ -321,6 +325,23 @@
   free_sprite(flags_sprite);
 }
 
+/***************************************************************************
+...
+***************************************************************************/
+void load_cursors(void)
+{
+  Pixmap pixmap, mask;
+
+  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,
+                                   &color_white,
+                                   &color_black,
+                                   7, 8);
+}
 
 /***************************************************************************
 ...
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  Tue Mar 16 21:51:09 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,10 @@
            pcity ? pcity->name : "");
 
     xaw_set_label(unit_info_label, buffer);
+    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      Tue Mar 16 21:49:10 1999
@@ -0,0 +1,12 @@
+#define goto_cursor_width 32
+#define goto_cursor_height 32
+static char goto_cursor_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x80,0x07,0x00,0x00,0x80,0x03,0x00,0x00,0x80,0x07,0x00,0x00,0x80,
+ 0xfe,0x3f,0x00,0x00,0xfc,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x1e,0x00,
+ 0x00,0x66,0x33,0x00,0x00,0x06,0x33,0x00,0x00,0x06,0x33,0x00,0x00,0x76,0x33,
+ 0x00,0x00,0x66,0x33,0x00,0x00,0x66,0x33,0x00,0x00,0x66,0x33,0x00,0x00,0x7c,
+ 0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,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 Tue Mar 16 21:49:10 1999
@@ -0,0 +1,12 @@
+#define goto_cursor_mask_width 32
+#define goto_cursor_mask_height 32
+static char goto_cursor_mask_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x0f,
+ 0x00,0x00,0xc0,0x0f,0x00,0x00,0xc0,0x0f,0x00,0x00,0xc0,0xff,0x7f,0x00,0xc0,
+ 0xff,0xff,0x00,0xc0,0xff,0xff,0x00,0x00,0xfe,0xff,0x00,0x00,0xff,0x7f,0x00,
+ 0x00,0xff,0x7f,0x00,0x00,0xff,0x7f,0x00,0x00,0xff,0x7f,0x00,0x00,0xff,0x7f,
+ 0x00,0x00,0xff,0x7f,0x00,0x00,0xff,0x7f,0x00,0x00,0xff,0x7f,0x00,0x00,0xff,
+ 0x7f,0x00,0x00,0xfe,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

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