[Freeciv-Dev] (PR#2890) get_citydlg_canvas_width() and get_citydlg_canva
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients:; |
Subject: |
[Freeciv-Dev] (PR#2890) get_citydlg_canvas_width() and get_citydlg_canvas_height() |
From: |
"Jason Short via RT" <rt@xxxxxxxxxxxxxx> |
Date: |
Thu, 23 Jan 2003 11:35:57 -0800 |
Reply-to: |
rt@xxxxxxxxxxxxxx |
The attached patch provides two new functions for querying the width and
height of a citydlg. This is helpful because (1) it abstracts the
is_isometric check and (2) if CITY_MAP_SIZE ever changes these values
will also change.
But, it is only a small part of the needed changes for #2 (even in the
citydlg code).
-----
It doesn't work for gui-sdl because this client uses a scaled tileset
for the city dialog. Although there are problems with this (the tileset
is arbitrarily scaled to 48x24, which may not be appropriate), I think
it can eventually be supported by use of a global tileset variable. So
in tileset.h we would have
struct tileset {
...
} tileset;
and the function would then become
int get_citydlg_canvas_width(struct tileset *tileset);
so gui-sdl could create its own scaled tileset, and use that instead.
Note that in this context, most of the theme graphics don't belong in
the tileset structure.
jason
Index: client/citydlg_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.c,v
retrieving revision 1.14
diff -u -r1.14 citydlg_common.c
--- client/citydlg_common.c 2003/01/17 03:17:43 1.14
+++ client/citydlg_common.c 2003/01/23 19:11:37
@@ -26,6 +26,30 @@
#include "tilespec.h" /* for is_isometric */
/**************************************************************************
+ Return the width of the city dialog canvas.
+**************************************************************************/
+int get_citydlg_canvas_width(void)
+{
+ if (is_isometric) {
+ return 4 * NORMAL_TILE_WIDTH;
+ } else {
+ return 5 * NORMAL_TILE_WIDTH;
+ }
+}
+
+/**************************************************************************
+ Return the height of the city dialog canvas.
+**************************************************************************/
+int get_citydlg_canvas_height(void)
+{
+ if (is_isometric) {
+ return 4 * NORMAL_TILE_HEIGHT;
+ } else {
+ return 5 * NORMAL_TILE_HEIGHT;
+ }
+}
+
+/**************************************************************************
This converts a city coordinate position to citymap canvas coordinates
(either isometric or overhead). It should be in cityview.c instead.
**************************************************************************/
Index: client/citydlg_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.h,v
retrieving revision 1.8
diff -u -r1.8 citydlg_common.h
--- client/citydlg_common.h 2003/01/17 03:17:43 1.8
+++ client/citydlg_common.h 2003/01/23 19:11:37
@@ -31,6 +31,9 @@
CITIZEN_LAST
};
+int get_citydlg_canvas_width(void);
+int get_citydlg_canvas_height(void);
+
void city_pos_to_canvas_pos(int city_x, int city_y, int *canvas_x, int
*canvas_y);
void canvas_pos_to_city_pos(int canvas_x, int canvas_y, int *map_x, int
*map_y);
Index: client/gui-gtk/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/citydlg.c,v
retrieving revision 1.152
diff -u -r1.152 citydlg.c
--- client/gui-gtk/citydlg.c 2003/01/17 03:17:43 1.152
+++ client/gui-gtk/citydlg.c 2003/01/23 19:11:38
@@ -323,13 +323,12 @@
*****************************************************************/
static void init_citydlg_dimensions(void)
{
+ canvas_width = get_citydlg_canvas_width();
+ canvas_height = get_citydlg_canvas_height();
+
if (is_isometric) {
- canvas_width = 4 * NORMAL_TILE_WIDTH;
- canvas_height = 4 * NORMAL_TILE_HEIGHT;
MAX_UNIT_ROWS = (int) (100 / (UNIT_TILE_HEIGHT));
} else {
- canvas_width = 5 * NORMAL_TILE_WIDTH;
- canvas_height = 5 * NORMAL_TILE_HEIGHT;
MAX_UNIT_ROWS = (int) (100 / (UNIT_TILE_HEIGHT + 6));
}
}
Index: client/gui-gtk-2.0/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/citydlg.c,v
retrieving revision 1.24
diff -u -r1.24 citydlg.c
--- client/gui-gtk-2.0/citydlg.c 2003/01/17 03:17:43 1.24
+++ client/gui-gtk-2.0/citydlg.c 2003/01/23 19:11:40
@@ -314,13 +314,12 @@
*****************************************************************/
static void init_citydlg_dimensions(void)
{
+ canvas_width = get_citydlg_canvas_width();
+ canvas_height = get_citydlg_canvas_height();
+
if (is_isometric) {
- canvas_width = 4 * NORMAL_TILE_WIDTH;
- canvas_height = 4 * NORMAL_TILE_HEIGHT;
MAX_UNIT_ROWS = (int) (100 / (UNIT_TILE_HEIGHT));
} else {
- canvas_width = 5 * NORMAL_TILE_WIDTH;
- canvas_height = 5 * NORMAL_TILE_HEIGHT;
MAX_UNIT_ROWS = (int) (100 / (UNIT_TILE_HEIGHT + 6));
}
}
Index: client/gui-sdl/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/mapview.c,v
retrieving revision 1.9
diff -u -r1.9 mapview.c
--- client/gui-sdl/mapview.c 2003/01/19 11:39:47 1.9
+++ client/gui-sdl/mapview.c 2003/01/23 19:11:41
@@ -2038,8 +2038,8 @@
Sint16 x0 = 3 * NORMAL_TILE_WIDTH / 2;
Sint16 y0 = -NORMAL_TILE_HEIGHT / 2;
SDL_Surface *pTile = NULL;
- SDL_Surface *pDest = create_surf(4 * NORMAL_TILE_WIDTH,
- 4 * NORMAL_TILE_HEIGHT,
+ SDL_Surface *pDest = create_surf(get_citydlg_canvas_width(),
+ get_citydlg_canvas_height(),
SDL_SWSURFACE);
real_col -= 2;
real_row -= 2;
Index: client/gui-win32/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/citydlg.c,v
retrieving revision 1.46
diff -u -r1.46 citydlg.c
--- client/gui-win32/citydlg.c 2003/01/17 03:17:43 1.46
+++ client/gui-win32/citydlg.c 2003/01/23 19:11:42
@@ -2009,13 +2009,8 @@
assert(!city_dialogs_have_been_initialised);
genlist_init(&dialog_list);
- if (is_isometric) {
- city_map_width=4*NORMAL_TILE_WIDTH;
- city_map_height=4*NORMAL_TILE_HEIGHT;
- } else {
- city_map_width=5*NORMAL_TILE_WIDTH;
- city_map_height=5*NORMAL_TILE_HEIGHT;
- }
+ city_map_width = get_citydlg_canvas_width();
+ city_map_height = get_citydlg_canvas_height();
city_dialogs_have_been_initialised=1;
}
@@ -2104,13 +2099,10 @@
struct genlist_iterator myiter;
if (!city_dialogs_have_been_initialised)
initialize_city_dialogs();
- if (is_isometric) {
- city_map_width = 4 * NORMAL_TILE_WIDTH;
- city_map_height = 4 * NORMAL_TILE_HEIGHT;
- } else {
- city_map_width = 5 * NORMAL_TILE_WIDTH;
- city_map_height = 5 * NORMAL_TILE_HEIGHT;
- }
+
+ city_map_width = get_citydlg_canvas_width();
+ city_map_height = get_citydlg_canvas_height();
+
genlist_iterator_init(&myiter, &dialog_list, 0);
for(; ITERATOR_PTR(myiter); ITERATOR_NEXT(myiter)) {
HDC hdc;
Index: client/gui-xaw/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/citydlg.c,v
retrieving revision 1.88
diff -u -r1.88 citydlg.c
--- client/gui-xaw/citydlg.c 2003/01/17 03:17:43 1.88
+++ client/gui-xaw/citydlg.c 2003/01/23 19:11:43
@@ -610,8 +610,8 @@
"exposeProc", (XtArgVal)city_map_canvas_expose,
"exposeProcData", (XtArgVal)pdialog,
XtNfromHoriz, (XtArgVal)pdialog->left_form,
- XtNwidth, NORMAL_TILE_WIDTH*5,
- XtNheight, NORMAL_TILE_HEIGHT*5,
+ XtNwidth, get_citydlg_canvas_width(),
+ XtNheight, get_citydlg_canvas_height(),
NULL);
- [Freeciv-Dev] (PR#2890) get_citydlg_canvas_width() and get_citydlg_canvas_height(),
Jason Short via RT <=
|
|