Complete.Org: Mailing Lists: Archives: freeciv-dev: August 1999:
[Freeciv-Dev] Civ1-like patch
Home

[Freeciv-Dev] Civ1-like patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Civ1-like patch
From: "Peter 'g00bER' Kosinar" <goober@xxxxxx>
Date: Wed, 4 Aug 1999 10:19:07 +0200 (CEST)

Hi !

As I've told, I made a patch that will allow moving the map with
Shift+<KeypadKey>. As this is my first patch, I'd like to hear
your comments about it (what should I change, what should I take
care of, etc.)

                                                Peter

diff -ur orig/client/gui-xaw/gui_main.c done/client/gui-xaw/gui_main.c
--- orig/client/gui-xaw/gui_main.c      Wed Jul 21 23:44:11 1999
+++ done/client/gui-xaw/gui_main.c      Wed Jul 21 22:15:48 1999
@@ -280,7 +280,15 @@
   { "close-helpdialog", close_help_dialog_action },
   { "close-meswindialog", close_meswin_dialog_action },
   { "close-playersdialog", close_players_dialog_action },
-  { "close-cityreport", close_city_report_action }
+  { "close-cityreport", close_city_report_action },
+  { "key-map-north", key_map_north },
+  { "key-map-north-east", key_map_north_east },
+  { "key-map-east", key_map_east },
+  { "key-map-south-east", key_map_south_east },
+  { "key-map-south", key_map_south },
+  { "key-map-south-west", key_map_south_west },
+  { "key-map-west", key_map_west },
+  { "key-map-north-west", key_map_north_west }
 };
 
 int myerr(Display *p, XErrorEvent *e)
diff -ur orig/client/gui-xaw/mapview.c done/client/gui-xaw/mapview.c
--- orig/client/gui-xaw/mapview.c       Wed Jul 21 23:44:11 1999
+++ done/client/gui-xaw/mapview.c       Wed Jul 21 23:39:08 1999
@@ -1527,7 +1527,81 @@
   refresh_overview_viewrect();
 }
 
+/**************************************************************************
+...
+**************************************************************************/
+void manual_scroll(int dx, int dy)
+ {
+  if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) return;
 
+  map_view_x0+=dx*5;
+  map_view_y0+=dy*5;
+  if (map_view_y0<=0 || map_view_y0>=map.ysize-map_canvas_store_theight) 
map_view_y0-=dy*5;
+
+  map_view_x0=map_adjust_x(map_view_x0);
+  map_view_y0=map_adjust_y(map_view_y0);
+
+  update_map_canvas(0, 0, map_canvas_store_twidth, map_canvas_store_theight, 
1);
+  update_map_canvas_scrollbars();
+  refresh_overview_viewrect();
+ }
+
+/**************************************************************************
+...
+**************************************************************************/
+void key_map_north(Widget w, XEvent *event, String *argv, Cardinal *argc)
+ {
+  manual_scroll(0,-1);
+ }
+/**************************************************************************
+...
+**************************************************************************/ 
+void key_map_north_east(Widget w, XEvent *event, String *argv, Cardinal *argc)
+ {
+  manual_scroll(1,-1);
+ }
+/**************************************************************************
+...
+**************************************************************************/ 
+void key_map_east(Widget w, XEvent *event, String *argv, Cardinal *argc)
+ {
+  manual_scroll(1,0);
+ }
+/**************************************************************************
+...
+**************************************************************************/ 
+void key_map_south_east(Widget w, XEvent *event, String *argv, Cardinal *argc)
+ {
+  manual_scroll(1,1);
+ }
+/**************************************************************************
+...
+**************************************************************************/ 
+void key_map_south(Widget w, XEvent *event, String *argv, Cardinal *argc)
+ {
+  manual_scroll(0,1);
+ }
+/**************************************************************************
+...
+**************************************************************************/ 
+void key_map_south_west(Widget w, XEvent *event, String *argv, Cardinal *argc)
+ {
+  manual_scroll(-1,1);
+ }
+/**************************************************************************
+...
+**************************************************************************/ 
+void key_map_west(Widget w, XEvent *event, String *argv, Cardinal *argc)
+ {
+  manual_scroll(-1,0);
+ }
+/**************************************************************************
+...
+**************************************************************************/ 
+void key_map_north_west(Widget w, XEvent *event, String *argv, Cardinal *argc)
+ {
+  manual_scroll(-1,-1);
+ }
 
 /**************************************************************************
 couldn't get the usual XawScrollbarSetThumb to work. tried everything.
diff -ur orig/client/gui-xaw/mapview.h done/client/gui-xaw/mapview.h
--- orig/client/gui-xaw/mapview.h       Wed Jul 21 23:44:11 1999
+++ done/client/gui-xaw/mapview.h       Wed Jul 21 23:34:33 1999
@@ -180,4 +180,13 @@
 Pixmap get_citizen_pixmap(int frame);
 void timer_callback(caddr_t client_data, XtIntervalId *id);
 
+void key_map_north(Widget w, XEvent *event, String *argv, Cardinal *argc);
+void key_map_north_east(Widget w, XEvent *event, String *argv, Cardinal *argc);
+void key_map_east(Widget w, XEvent *event, String *argv, Cardinal *argc);
+void key_map_south_east(Widget w, XEvent *event, String *argv, Cardinal *argc);
+void key_map_south(Widget w, XEvent *event, String *argv, Cardinal *argc);
+void key_map_south_west(Widget w, XEvent *event, String *argv, Cardinal *argc);
+void key_map_west(Widget w, XEvent *event, String *argv, Cardinal *argc);
+void key_map_north_west(Widget w, XEvent *event, String *argv, Cardinal *argc);
+
 #endif  /* FC__MAPVIEW_H */
diff -ur orig/data/Freeciv done/data/Freeciv
--- orig/data/Freeciv   Wed Jul 21 23:44:09 1999
+++ done/data/Freeciv   Wed Jul 21 23:28:05 1999
@@ -2335,6 +2335,14 @@
    Ctrl<Key>g:        key-map-grid()        \n\
    Shift<BtnDown>:    adjust-workers()      \n\
    <BtnDown>:         select-mapcanvas()    \n\
+   Shift<Key>KP_9:    key-map-north-east()  \n\
+   Shift<Key>KP_8:    key-map-north()       \n\
+   Shift<Key>KP_7:    key-map-north-west()  \n\
+   Shift<Key>KP_6:    key-map-east()        \n\
+   Shift<Key>KP_4:    key-map-west()        \n\
+   Shift<Key>KP_3:    key-map-south-east()  \n\
+   Shift<Key>KP_2:    key-map-south()       \n\
+   Shift<Key>KP_1:    key-map-south-west()  \n\
    <Key>Tab:          focus-to-next-unit()  \n\
    <Key>c:            center-on-unit()      \n\
    <Key>KP_8:         key-unit-north()      \n\
@@ -2392,6 +2400,14 @@
    <BtnDown>:         select-overviewcanvas() \n\
    <Key>g:            key-unit-goto()       \n\
    <Key>Tab:          focus-to-next-unit()  \n\
+   Shift<Key>KP_9:    key-map-north-east()  \n\
+   Shift<Key>KP_8:    key-map-north()       \n\
+   Shift<Key>KP_7:    key-map-north-west()  \n\
+   Shift<Key>KP_6:    key-map-east()        \n\
+   Shift<Key>KP_4:    key-map-west()        \n\
+   Shift<Key>KP_3:    key-map-south-east()  \n\
+   Shift<Key>KP_2:    key-map-south()       \n\
+   Shift<Key>KP_1:    key-map-south-west()  \n\
    <Key>KP_8:         key-unit-north()      \n\
    <Key>KP_9:         key-unit-north-east() \n\
    <Key>KP_6:         key-unit-east()       \n\

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