[Freeciv-Dev] (PR#4753) some iso fixes for gui-xaw
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
This patch makes a few iso-view drawing fixes for gui-xaw:
- Use city_to_canvas_pos instead of manual conversions.
- Use UNIT_TILE_xxx instead of NORMAL_TILE_xxx in many places.
The only real advantage is that a bug or two is fixed in the process.
jason
Index: client/gui-xaw/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/citydlg.c,v
retrieving revision 1.102
diff -u -r1.102 citydlg.c
--- client/gui-xaw/citydlg.c 2003/08/04 20:57:15 1.102
+++ client/gui-xaw/citydlg.c 2003/08/05 06:12:03
@@ -734,8 +734,8 @@
pixcommWidgetClass,
pdialog->main_form,
XtNfromVert, pdialog->support_unit_label,
- XtNwidth, NORMAL_TILE_WIDTH,
- XtNheight, NORMAL_TILE_HEIGHT+NORMAL_TILE_HEIGHT/2,
+ XtNwidth, UNIT_TILE_WIDTH,
+ XtNheight, 3 * UNIT_TILE_HEIGHT / 2,
NULL);
pdialog->present_unit_label=
@@ -751,8 +751,8 @@
pixcommWidgetClass,
pdialog->main_form,
XtNfromVert, pdialog->present_unit_label,
- XtNwidth, NORMAL_TILE_WIDTH,
- XtNheight, NORMAL_TILE_HEIGHT,
+ XtNwidth, UNIT_TILE_WIDTH,
+ XtNheight, UNIT_TILE_HEIGHT,
NULL);
@@ -977,8 +977,8 @@
XtNfromVert, pdialog->support_unit_label,
XtNfromHoriz,
(XtArgVal)pdialog->support_unit_pixcomms[i-1],
- XtNwidth, NORMAL_TILE_WIDTH,
- XtNheight,
NORMAL_TILE_HEIGHT+NORMAL_TILE_HEIGHT/2,
+ XtNwidth, UNIT_TILE_WIDTH,
+ XtNheight, 3 * UNIT_TILE_HEIGHT / 2,
NULL);
}
@@ -1001,8 +1001,8 @@
XtNfromVert, pdialog->present_unit_label,
XtNfromHoriz,
(XtArgVal)pdialog->support_unit_pixcomms[i-1],
- XtNwidth, NORMAL_TILE_WIDTH,
- XtNheight, NORMAL_TILE_HEIGHT,
+ XtNwidth, UNIT_TILE_WIDTH,
+ XtNheight, UNIT_TILE_HEIGHT,
NULL);
}
@@ -1535,28 +1535,25 @@
for(y=0; y<CITY_MAP_SIZE; y++) {
for(x=0; x<CITY_MAP_SIZE; x++) {
- int map_x, map_y;
+ int map_x, map_y, canvas_x, canvas_y;
if (is_valid_city_coords(x, y)
&& city_map_to_map(&map_x, &map_y, pcity, x, y)
&& tile_get_known(map_x, map_y)) {
- put_one_tile(&store, map_x, map_y,
- x * NORMAL_TILE_WIDTH, y * NORMAL_TILE_HEIGHT, TRUE);
+ city_pos_to_canvas_pos(x, y, &canvas_x, &canvas_y);
+ put_one_tile(&store, map_x, map_y, canvas_x, canvas_y, TRUE);
if (pcity->city_map[x][y] == C_TILE_WORKER)
put_city_tile_output(XtWindow(pdialog->map_canvas),
- x * NORMAL_TILE_WIDTH,
- y * NORMAL_TILE_HEIGHT,
+ canvas_x, canvas_y,
city_get_food_tile(x, y, pcity),
city_get_shields_tile(x, y, pcity),
city_get_trade_tile(x, y, pcity));
else if (pcity->city_map[x][y] == C_TILE_UNAVAILABLE)
pixmap_frame_tile_red(XtWindow(pdialog->map_canvas),
- x * NORMAL_TILE_WIDTH,
- y * NORMAL_TILE_HEIGHT);
+ canvas_x, canvas_y);
} else {
pixmap_put_black_tile(XtWindow(pdialog->map_canvas),
- x * NORMAL_TILE_WIDTH,
- y * NORMAL_TILE_HEIGHT);
+ canvas_x, canvas_y);
}
}
}
Index: client/gui-xaw/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/dialogs.c,v
retrieving revision 1.88
diff -u -r1.88 dialogs.c
--- client/gui-xaw/dialogs.c 2003/08/04 15:42:47 1.88
+++ client/gui-xaw/dialogs.c 2003/08/05 06:12:03
@@ -1633,11 +1633,11 @@
unit_activity_text(punit));
unit_select_pixmaps[i]=XCreatePixmap(display, XtWindow(map_canvas),
- NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT,
+ UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT,
display_depth);
XFillRectangle(display, unit_select_pixmaps[i], fill_bg_gc,
- 0, 0, NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
+ 0, 0, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
store.pixmap = unit_select_pixmaps[i];
put_unit_full(punit, &store, 0, 0);
Index: client/gui-xaw/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/graphics.c,v
retrieving revision 1.49
diff -u -r1.49 graphics.c
--- client/gui-xaw/graphics.c 2003/07/15 01:04:54 1.49
+++ client/gui-xaw/graphics.c 2003/08/05 06:12:03
@@ -516,7 +516,7 @@
enum color_std bg_color;
pm=XCreatePixmap(display, root_window,
- NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT, display_depth);
+ UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, display_depth);
/* Give tile a background color, based on the type of unit */
switch (get_unit_type(i)->move_type) {
@@ -528,7 +528,7 @@
}
XSetForeground(display, fill_bg_gc, colors_standard[bg_color]);
XFillRectangle(display, pm, fill_bg_gc, 0,0,
- NORMAL_TILE_WIDTH,NORMAL_TILE_HEIGHT);
+ UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
/* If we're using flags, put one on the tile */
if(!solid_color_behind_units) {
Index: client/gui-xaw/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/gui_main.c,v
retrieving revision 1.82
diff -u -r1.82 gui_main.c
--- client/gui-xaw/gui_main.c 2003/07/23 13:46:03 1.82
+++ client/gui-xaw/gui_main.c 2003/08/05 06:12:03
@@ -402,7 +402,7 @@
}
/* 135 below is rough value (could be more intelligent) --dwp */
- num_units_below = 135/(int)NORMAL_TILE_WIDTH;
+ num_units_below = 135 / UNIT_TILE_WIDTH;
num_units_below = MIN(num_units_below,MAX_NUM_UNITS_BELOW);
num_units_below = MAX(num_units_below,1);
@@ -455,13 +455,13 @@
overview_canvas_store_width, overview_canvas_store_height);
single_tile_pixmap=XCreatePixmap(display, XtWindow(overview_canvas),
- NORMAL_TILE_WIDTH,
- NORMAL_TILE_HEIGHT,
+ UNIT_TILE_WIDTH,
+ UNIT_TILE_HEIGHT,
display_depth);
for(i=0; i<num_units_below; i++)
unit_below_pixmap[i]=XCreatePixmap(display, XtWindow(overview_canvas),
- NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT,
+ UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT,
display_depth);
set_indicator_icons(0, 0, 0, 0);
@@ -620,8 +620,8 @@
unit_pix_canvas = XtVaCreateManagedWidget("unitpixcanvas",
pixcommWidgetClass,
left_column_form,
- XtNwidth, NORMAL_TILE_WIDTH,
- XtNheight, NORMAL_TILE_HEIGHT,
+ XtNwidth, UNIT_TILE_WIDTH,
+ XtNheight, UNIT_TILE_HEIGHT,
NULL);
for(i=0; i<num_units_below; i++) {
@@ -631,8 +631,10 @@
unit_below_canvas[i] = XtVaCreateManagedWidget(unit_below_name,
pixcommWidgetClass,
left_column_form,
- XtNwidth, NORMAL_TILE_WIDTH,
- XtNheight,
NORMAL_TILE_HEIGHT,
+ XtNwidth,
+ UNIT_TILE_WIDTH,
+ XtNheight,
+ UNIT_TILE_HEIGHT,
NULL);
XtAddCallback(unit_below_canvas[i], XtNcallback, unit_icon_callback,
(XtPointer)i);
Index: client/gui-xaw/mapctrl.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapctrl.c,v
retrieving revision 1.75
diff -u -r1.75 mapctrl.c
--- client/gui-xaw/mapctrl.c 2003/07/17 18:56:51 1.75
+++ client/gui-xaw/mapctrl.c 2003/08/05 06:12:03
@@ -295,10 +295,9 @@
return;
}
- x = map_view_x0 + ev->x / NORMAL_TILE_WIDTH;
- y = map_view_y0 + ev->y / NORMAL_TILE_HEIGHT;
- is_real = normalize_map_pos(&x, &y);
- assert(is_real);
+ if (!canvas_to_map_pos(&x, &y, ev->x, ev->y)) {
+ return;
+ }
pcity = find_city_near_tile(x,y);
if(!pcity) return;
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.146
diff -u -r1.146 mapview.c
--- client/gui-xaw/mapview.c 2003/07/30 21:14:30 1.146
+++ client/gui-xaw/mapview.c 2003/08/05 06:12:03
@@ -107,7 +107,7 @@
XCopyArea(display, single_tile_pixmap, XtWindow(map_canvas), civ_gc,
0, 0,
- NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT,
+ UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT,
canvas_x, canvas_y);
XSync(display, 0);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#4753) some iso fixes for gui-xaw,
Jason Short <=
|
|