Complete.Org: Mailing Lists: Archives: freeciv-dev: February 1999:
[Freeciv-Dev] patch num_units_below for main window layout
Home

[Freeciv-Dev] patch num_units_below for main window layout

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] patch num_units_below for main window layout
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Thu, 18 Feb 1999 18:54:34 +1100

There is a problem using the 45x45 tiles that there is a big gap
between the information on the left of the main window, and the
large map view.  This is due to the larger units pixmaps on the 
left hand side (those showning units on the same square as the
current unit).

The attached patch adjusts the number of those pixmaps depending
on the tiles size.

Of course if game.xsize is too large, you'll get a gap anyway
due to the minimap, but this patch gets rid of the gap when 
using a sensible map size.

Regards,
-- David
diff -u -r --exclude-from exclude freeciv-cvs/client/Freeciv.h 
freeciv-mod/client/Freeciv.h
--- freeciv-cvs/client/Freeciv.h        Tue Feb 16 22:38:06 1999
+++ freeciv-mod/client/Freeciv.h        Thu Feb 18 18:18:18 1999
@@ -1568,7 +1568,6 @@
 "Freeciv*morearrowlabel.internalWidth:              0",
 "Freeciv*morearrowlabel.internalHeight:             0",
 "Freeciv*morearrowlabel.fromVert:                   unitpixcanvas",
-"Freeciv*morearrowlabel.fromHoriz:                  unitbelowcanvas3",
 "Freeciv*morearrowlabel.top:                        chainTop",
 "Freeciv*morearrowlabel.bottom:                     chainTop",
 "Freeciv*morearrowlabel.left:                       chainLeft",
diff -u -r --exclude-from exclude freeciv-cvs/client/mapview.c 
freeciv-mod/client/mapview.c
--- freeciv-cvs/client/mapview.c        Sat Feb 13 14:42:28 1999
+++ freeciv-mod/client/mapview.c        Thu Feb 18 18:25:07 1999
@@ -51,11 +51,10 @@
 extern Widget econ_label[10];
 extern Widget bulb_label, sun_label, government_label, timeout_label;
 extern Widget unit_info_label;
-extern Widget unit_pix_canvas, unit_below_canvas[4];
+extern Widget unit_pix_canvas, unit_below_canvas[MAX_NUM_UNITS_BELOW];
 extern Widget more_arrow_label;
 extern int display_depth;
 extern Pixmap single_tile_pixmap;
-/*extern Pixmap unit_below_pixmap[4];*/
 
 extern int seconds_to_turndone;
 
@@ -78,6 +77,9 @@
 /* used by map_canvas expose func */ 
 int force_full_repaint;
 
+/* adjusted depending on tile size: */
+int num_units_below = MAX_NUM_UNITS_BELOW;
+
 extern int goto_state;
 
 void pixmap_put_overlay_tile(Pixmap pixmap, int x, int y, int tileno);
@@ -284,7 +286,7 @@
   /* what initialises these statics? */
   static enum unit_activity uactivity = ACTIVITY_UNKNOWN;
   static int utemplate = U_LAST;
-  static int unit_ids[4];
+  static int unit_ids[MAX_NUM_UNITS_BELOW];
   static int showing_arrow=0;
   struct genlist_iterator myiter;
   
@@ -300,7 +302,7 @@
     genlist_iterator_init(&myiter, 
                          &(map_get_tile(punit->x, punit->y)->units.list), 0);
     
-    for(i=0; i<4 && ITERATOR_PTR(myiter); i++) {
+    for(i=0; i<num_units_below && ITERATOR_PTR(myiter); i++) {
       int id;
       id=ITERATOR_PTR(myiter) ? ((struct unit *)ITERATOR_PTR(myiter))->id : 0;
       if(id==punit->id) {
@@ -328,7 +330,7 @@
     }
 
     
-    for(; i<4; i++) {
+    for(; i<num_units_below; i++) {
       XawPixcommClear(unit_below_canvas[i]);
       unit_ids[i]=0;
     }
@@ -352,7 +354,7 @@
     XawPixcommClear(unit_pix_canvas);
     utemplate=U_LAST;
     uactivity=ACTIVITY_UNKNOWN;
-    for(i=0; i<4; i++) {
+    for(i=0; i<num_units_below; i++) {
       XawPixcommClear(unit_below_canvas[i]);
       unit_ids[i]=0;
     }
diff -u -r --exclude-from exclude freeciv-cvs/client/mapview.h 
freeciv-mod/client/mapview.h
--- freeciv-cvs/client/mapview.h        Sat Feb 13 14:42:29 1999
+++ freeciv-mod/client/mapview.h        Thu Feb 18 18:03:47 1999
@@ -18,6 +18,9 @@
 struct unit;
 struct city;
 
+/* don't change this unless you also put more entries in data/Freeciv */
+#define MAX_NUM_UNITS_BELOW 4
+
 #define CORNER_TILES     0
 
 #define NUKE_TILE0        1*20+17
diff -u -r --exclude-from exclude freeciv-cvs/client/xmain.c 
freeciv-mod/client/xmain.c
--- freeciv-cvs/client/xmain.c  Sat Feb 13 14:42:33 1999
+++ freeciv-mod/client/xmain.c  Thu Feb 18 18:31:22 1999
@@ -67,6 +67,8 @@
 extern int  server_port;
 extern char *tile_set_dir;
 
+extern int num_units_below;
+
 /**************************************************************************
 ...
 **************************************************************************/
@@ -168,9 +170,9 @@
 Widget info_command, bulb_label, sun_label, government_label, timeout_label;
 Widget unit_info_label;
 Widget unit_pix_canvas;
-Widget unit_below_canvas[4];
+Widget unit_below_canvas[MAX_NUM_UNITS_BELOW];
 Widget main_vpane;
-Pixmap unit_below_pixmap[4];
+Pixmap unit_below_pixmap[MAX_NUM_UNITS_BELOW];
 Widget more_arrow_label;
 Window root_window;
 
@@ -392,6 +394,11 @@
 
   load_tile_gfx();
 
+  /* 135 below is rough value (could be more intelligent) --dwp */
+  num_units_below = 135/(int)NORMAL_TILE_WIDTH;
+  num_units_below = MIN(num_units_below,MAX_NUM_UNITS_BELOW);
+  num_units_below = MAX(num_units_below,1);
+  
   setup_widgets();
   load_intro_gfx(); 
   
@@ -447,7 +454,7 @@
                                   display_depth);
 
 
-  for(i=0; i<4; i++)
+  for(i=0; i<num_units_below; i++)
     unit_below_pixmap[i]=XCreatePixmap(display, XtWindow(overview_canvas), 
                                       NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT, 
                                       display_depth);  
@@ -592,35 +599,24 @@
                                           XtNheight, NORMAL_TILE_HEIGHT,
                                           NULL);
 
-  unit_below_canvas[0] = XtVaCreateManagedWidget("unitbelowcanvas0",
-                                               pixcommWidgetClass,
-                                               left_column_form, 
-                                               XtNwidth, NORMAL_TILE_WIDTH,
-                                               XtNheight, NORMAL_TILE_HEIGHT,
-                                               NULL);
-  unit_below_canvas[1] = XtVaCreateManagedWidget("unitbelowcanvas1",
-                                               pixcommWidgetClass,
-                                               left_column_form, 
-                                               XtNwidth, NORMAL_TILE_WIDTH,
-                                               XtNheight, NORMAL_TILE_HEIGHT,
-                                               NULL);
-  unit_below_canvas[2] = XtVaCreateManagedWidget("unitbelowcanvas2",
-                                               pixcommWidgetClass,
-                                               left_column_form, 
-                                               XtNwidth, NORMAL_TILE_WIDTH,
-                                               XtNheight, NORMAL_TILE_HEIGHT,
-                                               NULL);
-  unit_below_canvas[3] = XtVaCreateManagedWidget("unitbelowcanvas3",
-                                               pixcommWidgetClass,
-                                               left_column_form, 
-                                               XtNwidth, NORMAL_TILE_WIDTH,
-                                               XtNheight, NORMAL_TILE_HEIGHT,
-                                               NULL);
+  for(i=0; i<num_units_below; i++) {
+    char unit_below_name[32] = "\0";
+    sprintf(unit_below_name, "unitbelowcanvas%ld", i);
+    unit_below_canvas[i] = XtVaCreateManagedWidget(unit_below_name,
+                                                  pixcommWidgetClass,
+                                                  left_column_form, 
+                                                  XtNwidth, NORMAL_TILE_WIDTH,
+                                                  XtNheight, 
NORMAL_TILE_HEIGHT,
+                                                  NULL);
+  }
 
-  more_arrow_label = XtVaCreateManagedWidget("morearrowlabel", 
-                                            labelWidgetClass, 
-                                            left_column_form,
-                                            NULL);
+  more_arrow_label =
+    XtVaCreateManagedWidget("morearrowlabel", 
+                           labelWidgetClass,
+                           left_column_form,
+                           XtNfromHoriz,
+                           (XtArgVal)unit_below_canvas[num_units_below-1],
+                           NULL);
 
   map_vertical_scrollbar = XtVaCreateManagedWidget("mapvertiscrbar", 
                                                   scrollbarWidgetClass, 
diff -u -r --exclude-from exclude freeciv-cvs/data/Freeciv 
freeciv-mod/data/Freeciv
--- freeciv-cvs/data/Freeciv    Tue Feb 16 22:37:21 1999
+++ freeciv-mod/data/Freeciv    Thu Feb 18 18:16:10 1999
@@ -2037,7 +2037,7 @@
 Freeciv*morearrowlabel.internalWidth:              0
 Freeciv*morearrowlabel.internalHeight:             0
 Freeciv*morearrowlabel.fromVert:                   unitpixcanvas
-Freeciv*morearrowlabel.fromHoriz:                  unitbelowcanvas3
+!Freeciv*morearrowlabel.fromHoriz:                  unitbelowcanvas3
 Freeciv*morearrowlabel.top:                        chainTop
 Freeciv*morearrowlabel.bottom:                     chainTop
 Freeciv*morearrowlabel.left:                       chainLeft

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