[Freeciv-Dev] (PR#2874) unification of put_one_tile_iso
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
[jdorje - Wed Jan 22 01:35:37 2003]:
> The attached patch moves the code of the function put_one_tile_iso into
> mapview_common. It removes this as a GUI function and adds two new GUI
> functions in its place.
At Mike's suggestion, I have renamed the GUI functions to gui_map_*
instead of mapview_*.
I've also changed the internal code of put_one_tile_iso slightly, to
have more intuitive if() checks.
jason
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.25
diff -u -r1.25 mapview_common.c
--- client/mapview_common.c 2003/01/27 22:00:34 1.25
+++ client/mapview_common.c 2003/01/29 07:54:16
@@ -403,9 +403,57 @@
int canvas_x, canvas_y;
if (get_canvas_xy(map_x, map_y, &canvas_x, &canvas_y)) {
+ int height, width, height_unit;
+ int offset_x, offset_y, offset_y_unit;
+
freelog(LOG_DEBUG, "putting (%d,%d) at (%d,%d), draw %x",
map_x, map_y, canvas_x, canvas_y, draw);
- put_one_tile_iso(map_x, map_y, canvas_x, canvas_y, draw);
+
+ if ((draw & D_TMB_L) && (draw & D_TMB_R)) {
+ width = NORMAL_TILE_WIDTH;
+ } else {
+ width = NORMAL_TILE_WIDTH / 2;
+ }
+
+ if (draw & D_TMB_L) {
+ offset_x = 0;
+ } else {
+ offset_x = NORMAL_TILE_WIDTH / 2;
+ }
+
+ height = 0;
+ if (draw & D_M_LR) {
+ height += NORMAL_TILE_HEIGHT / 2;
+ }
+ if (draw & D_B_LR) {
+ height += NORMAL_TILE_HEIGHT / 2;
+ }
+
+ height_unit = height;
+ if (draw & D_T_LR) {
+ height_unit += NORMAL_TILE_HEIGHT / 2;
+ }
+
+ offset_y = (draw & D_M_LR) ? 0 : NORMAL_TILE_HEIGHT / 2;
+
+ if (draw & D_T_LR) {
+ offset_y_unit = 0;
+ } else if (draw & D_M_LR) {
+ offset_y_unit = NORMAL_TILE_HEIGHT / 2;
+ } else {
+ offset_y_unit = NORMAL_TILE_HEIGHT;
+ }
+
+ if (normalize_map_pos(&map_x, &map_y)) {
+ gui_map_put_tile_iso(map_x, map_y, canvas_x, canvas_y,
+ offset_x, offset_y, offset_y_unit,
+ width, height, height_unit,
+ draw);
+ } else {
+ gui_map_put_black_tile_iso(canvas_x, canvas_y,
+ offset_x, offset_y,
+ width, height);
+ }
}
}
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.151
diff -u -r1.151 mapview.c
--- client/gui-gtk/mapview.c 2003/01/28 00:28:05 1.151
+++ client/gui-gtk/mapview.c 2003/01/29 07:54:18
@@ -887,45 +887,31 @@
}
/**************************************************************************
- Draw the given map tile at the given canvas position in isometric
- view.
+ Draw some or all of a tile onto the mapview canvas.
**************************************************************************/
-void put_one_tile_iso(int x, int y, int canvas_x, int canvas_y,
- enum draw_type draw)
+void gui_map_put_tile_iso(int map_x, int map_y,
+ int canvas_x, int canvas_y,
+ int offset_x, int offset_y, int offset_y_unit,
+ int width, int height, int height_unit,
+ enum draw_type draw)
{
- int height, width, height_unit;
- int offset_x, offset_y, offset_y_unit;
+ pixmap_put_tile_iso(map_canvas_store,
+ map_x, map_y, canvas_x, canvas_y,
+ FALSE,
+ offset_x, offset_y, offset_y_unit,
+ width, height, height_unit, draw);
+}
- width = (draw & D_TMB_L) && (draw & D_TMB_R) ? NORMAL_TILE_WIDTH :
NORMAL_TILE_WIDTH/2;
- if (!(draw & D_TMB_L))
- offset_x = NORMAL_TILE_WIDTH/2;
- else
- offset_x = 0;
-
- height = 0;
- if (draw & D_M_LR) height += NORMAL_TILE_HEIGHT/2;
- if (draw & D_B_LR) height += NORMAL_TILE_HEIGHT/2;
- if (draw & D_T_LR)
- height_unit = height + NORMAL_TILE_HEIGHT/2;
- else
- height_unit = height;
-
- offset_y = (draw & D_M_LR) ? 0 : NORMAL_TILE_HEIGHT/2;
- if (!(draw & D_T_LR))
- offset_y_unit = (draw & D_M_LR) ? NORMAL_TILE_HEIGHT/2 :
NORMAL_TILE_HEIGHT;
- else
- offset_y_unit = 0;
-
- if (normalize_map_pos(&x, &y)) {
- pixmap_put_tile_iso(map_canvas_store, x, y, canvas_x, canvas_y, 0,
- offset_x, offset_y, offset_y_unit,
- width, height, height_unit,
- draw);
- } else {
- pixmap_put_black_tile_iso(map_canvas_store, canvas_x, canvas_y,
- offset_x, offset_y,
- width, height);
- }
+/**************************************************************************
+ Draw some or all of a black tile onto the mapview canvas.
+**************************************************************************/
+void gui_map_put_black_tile_iso(int canvas_x, int canvas_y,
+ int offset_x, int offset_y,
+ int width, int height)
+{
+ pixmap_put_black_tile_iso(map_canvas_store, canvas_x, canvas_y,
+ offset_x, offset_y,
+ width, height);
}
/**************************************************************************
Index: client/gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.39
diff -u -r1.39 mapview.c
--- client/gui-gtk-2.0/mapview.c 2003/01/28 00:18:16 1.39
+++ client/gui-gtk-2.0/mapview.c 2003/01/29 07:54:19
@@ -916,45 +916,31 @@
}
/**************************************************************************
- Draw the given map tile at the given canvas position in isometric
- view.
+ Draw some or all of a tile onto the mapview canvas.
**************************************************************************/
-void put_one_tile_iso(int x, int y, int canvas_x, int canvas_y,
- enum draw_type draw)
+void gui_map_put_tile_iso(int map_x, int map_y,
+ int canvas_x, int canvas_y,
+ int offset_x, int offset_y, int offset_y_unit,
+ int width, int height, int height_unit,
+ enum draw_type draw)
{
- int height, width, height_unit;
- int offset_x, offset_y, offset_y_unit;
+ pixmap_put_tile_iso(map_canvas_store,
+ map_x, map_y, canvas_x, canvas_y,
+ FALSE,
+ offset_x, offset_y, offset_y_unit,
+ width, height, height_unit, draw);
+}
- width = (draw & D_TMB_L) && (draw & D_TMB_R) ? NORMAL_TILE_WIDTH :
NORMAL_TILE_WIDTH/2;
- if (!(draw & D_TMB_L))
- offset_x = NORMAL_TILE_WIDTH/2;
- else
- offset_x = 0;
-
- height = 0;
- if (draw & D_M_LR) height += NORMAL_TILE_HEIGHT/2;
- if (draw & D_B_LR) height += NORMAL_TILE_HEIGHT/2;
- if (draw & D_T_LR)
- height_unit = height + NORMAL_TILE_HEIGHT/2;
- else
- height_unit = height;
-
- offset_y = (draw & D_M_LR) ? 0 : NORMAL_TILE_HEIGHT/2;
- if (!(draw & D_T_LR))
- offset_y_unit = (draw & D_M_LR) ? NORMAL_TILE_HEIGHT/2 :
NORMAL_TILE_HEIGHT;
- else
- offset_y_unit = 0;
-
- if (normalize_map_pos(&x, &y)) {
- pixmap_put_tile_iso(map_canvas_store, x, y, canvas_x, canvas_y, 0,
- offset_x, offset_y, offset_y_unit,
- width, height, height_unit,
- draw);
- } else {
- pixmap_put_black_tile_iso(map_canvas_store, canvas_x, canvas_y,
- offset_x, offset_y,
- width, height);
- }
+/**************************************************************************
+ Draw some or all of a black tile onto the mapview canvas.
+**************************************************************************/
+void gui_map_put_black_tile_iso(int canvas_x, int canvas_y,
+ int offset_x, int offset_y,
+ int width, int height)
+{
+ pixmap_put_black_tile_iso(map_canvas_store, canvas_x, canvas_y,
+ offset_x, offset_y,
+ width, height);
}
/**************************************************************************
Index: client/gui-sdl/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/mapview.c,v
retrieving revision 1.11
diff -u -r1.11 mapview.c
--- client/gui-sdl/mapview.c 2003/01/29 05:00:04 1.11
+++ client/gui-sdl/mapview.c 2003/01/29 07:54:20
@@ -170,70 +170,43 @@
}
/**************************************************************************
- Draw the given map tile at the given canvas position in isometric
- view use with unification of update_mapcanvas(...).
+ Draw some or all of a tile onto the mapview canvas.
**************************************************************************/
-void put_one_tile_iso(int x, int y, int canvas_x, int canvas_y,
- enum draw_type draw)
+void gui_map_put_tile_iso(int map_x, int map_y,
+ int canvas_x, int canvas_y,
+ int offset_x, int offset_y, int offset_y_unit,
+ int width, int height, int height_unit,
+ enum draw_type draw)
{
- SDL_Rect dest;
- int height, width;
- int offset_x, offset_y;
+ if (draw == D_MB_LR || draw == D_FULL) {
+ draw_map_cell(Main.screen, canvas_x, canvas_y,
+ (Uint16)map_x, (Uint16)map_y, 0);
+ } else {
+ SDL_Rect dest;
-/*
- if (!tile_visible_mapcanvas(x, y)) {
- freelog(LOG_DEBUG, "dropping %d,%d", x, y);
- return;
- }
-*/
-
- if (!normalize_map_pos(&x, &y)) {
- blit_entire_src( (SDL_Surface *)sprites.black_tile ,
- Main.screen , canvas_x , canvas_y );
- return;
- }
+ dest.x = canvas_x + offset_x;
+ dest.y = canvas_y + offset_y;
+ dest.w = width;
+ dest.h = height;
+ SDL_SetClipRect(Main.screen, &dest);
- freelog(LOG_DEBUG, "putting %d,%d draw %x", x, y, draw);
-
- if ( draw == D_MB_LR || draw == D_FULL )
- {
draw_map_cell(Main.screen, canvas_x, canvas_y,
- (Uint16)x, (Uint16)y, 0);
-
- return;
- }
-
- width = (draw & D_TMB_L) && (draw & D_TMB_R)
- ? NORMAL_TILE_WIDTH : NORMAL_TILE_WIDTH>>1;
+ (Uint16)map_x, (Uint16)map_y, 0);
- if (!(draw & D_TMB_L))
- offset_x = NORMAL_TILE_WIDTH>>1;
- else
- offset_x = 0;
+ /* clear ClipRect */
+ SDL_SetClipRect(Main.screen, NULL);
+ }
+}
- height = 0;
- if (draw & D_M_LR) height += (NORMAL_TILE_HEIGHT>>1);
- if (draw & D_B_LR) height += (NORMAL_TILE_HEIGHT>>1);
- if (draw & D_T_LR) height += (NORMAL_TILE_HEIGHT>>1);
-
- if ((draw & D_T_LR))
- offset_y = - (NORMAL_TILE_HEIGHT>>1);
- else
- offset_y = (draw & D_M_LR) ? 0 : NORMAL_TILE_HEIGHT>>1;
-
- dest.x = canvas_x + offset_x;
- dest.y = canvas_y + offset_y;
- dest.w = width;
- dest.h = height;
- SDL_SetClipRect(Main.screen, &dest);
-
- draw_map_cell(Main.screen, canvas_x, canvas_y,
- (Uint16)x, (Uint16)y, 0 );
-
- /* clear ClipRect */
- SDL_SetClipRect(Main.screen, NULL);
-
- return;
+/**************************************************************************
+ Draw some or all of a black tile onto the mapview canvas.
+**************************************************************************/
+void gui_map_put_black_tile_iso(int canvas_x, int canvas_y,
+ int offset_x, int offset_y,
+ int width, int height)
+{
+ blit_entire_src((SDL_Surface *)sprites.black_tile,
+ Main.screen, canvas_x, canvas_y);
}
void flush_mapcanvas( int canvas_x , int canvas_y ,
Index: client/gui-stub/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-stub/mapview.c,v
retrieving revision 1.24
diff -u -r1.24 mapview.c
--- client/gui-stub/mapview.c 2003/01/17 20:20:56 1.24
+++ client/gui-stub/mapview.c 2003/01/29 07:54:21
@@ -193,11 +193,23 @@
}
/**************************************************************************
- Draw the given map tile at the given canvas position in isometric
- view.
+ Draw some or all of a tile onto the mapview canvas.
**************************************************************************/
-void put_one_tile_iso(int map_x, int map_y, int canvas_x, int canvas_y,
- enum draw_type draw)
+void gui_map_put_tile_iso(int map_x, int map_y,
+ int canvas_x, int canvas_y,
+ int offset_x, int offset_y, int offset_y_unit,
+ int width, int height, int height_unit,
+ enum draw_type draw)
+{
+ /* PORTME */
+}
+
+/**************************************************************************
+ Draw some or all of a black tile onto the mapview canvas.
+**************************************************************************/
+void gui_map_put_black_tile_iso(int canvas_x, int canvas_y,
+ int offset_x, int offset_y,
+ int width, int height)
{
/* PORTME */
}
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.52
diff -u -r1.52 mapview.c
--- client/gui-win32/mapview.c 2003/01/23 21:39:32 1.52
+++ client/gui-win32/mapview.c 2003/01/29 07:54:21
@@ -1325,54 +1325,48 @@
D_FULL);
}
+/**************************************************************************
+ Draw some or all of a tile onto the mapview canvas.
+**************************************************************************/
+void gui_map_put_tile_iso(int map_x, int map_y,
+ int canvas_x, int canvas_y,
+ int offset_x, int offset_y, int offset_y_unit,
+ int width, int height, int height_unit,
+ enum draw_type draw)
+{
+ HDC hdc;
+ HBITMAP old;
+ /* FIXME: we don't want to have to recreate the hdc each time! */
+ hdc = CreateCompatibleDC(NULL);
+ old = SelectObject(hdc, mapstorebitmap);
+
+ pixmap_put_tile_iso(hdc, map_x, map_y, canvas_x, canvas_y, 0,
+ offset_x, offset_y, offset_y_unit,
+ width, height, height_unit,
+ draw);
+ SelectObject(hdc, old);
+ DeleteDC(hdc);
+}
+
/**************************************************************************
- Draw the given map tile at the given canvas position in isometric
- view.
+ Draw some or all of a black tile onto the mapview canvas.
**************************************************************************/
-void put_one_tile_iso(int x, int y, int canvas_x, int canvas_y,
- enum draw_type draw)
+void gui_map_put_black_tile_iso(int canvas_x, int canvas_y,
+ int offset_x, int offset_y,
+ int width, int height)
{
HDC hdc;
HBITMAP old;
- int height, width, height_unit;
- int offset_x, offset_y, offset_y_unit;
/* FIXME: we don't want to have to recreate the hdc each time! */
hdc = CreateCompatibleDC(NULL);
old = SelectObject(hdc, mapstorebitmap);
-
- width = (draw & D_TMB_L) && (draw & D_TMB_R) ? NORMAL_TILE_WIDTH :
NORMAL_TILE_WIDTH/2;
- if (!(draw & D_TMB_L))
- offset_x = NORMAL_TILE_WIDTH/2;
- else
- offset_x = 0;
-
- height = 0;
- if (draw & D_M_LR) height += NORMAL_TILE_HEIGHT/2;
- if (draw & D_B_LR) height += NORMAL_TILE_HEIGHT/2;
- if (draw & D_T_LR)
- height_unit = height + NORMAL_TILE_HEIGHT/2;
- else
- height_unit = height;
-
- offset_y = (draw & D_M_LR) ? 0 : NORMAL_TILE_HEIGHT/2;
- if (!(draw & D_T_LR))
- offset_y_unit = (draw & D_M_LR) ? NORMAL_TILE_HEIGHT/2 :
NORMAL_TILE_HEIGHT;
- else
- offset_y_unit = 0;
-
- if (normalize_map_pos(&x, &y)) {
- pixmap_put_tile_iso(hdc, x, y, canvas_x, canvas_y, 0,
- offset_x, offset_y, offset_y_unit,
- width, height, height_unit,
- draw);
- } else {
- pixmap_put_black_tile_iso(hdc, canvas_x, canvas_y,
- offset_x, offset_y,
- width, height);
- }
+
+ pixmap_put_black_tile_iso(hdc, canvas_x, canvas_y,
+ offset_x, offset_y,
+ width, height);
SelectObject(hdc, old);
DeleteDC(hdc);
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.118
diff -u -r1.118 mapview.c
--- client/gui-xaw/mapview.c 2003/01/17 20:20:57 1.118
+++ client/gui-xaw/mapview.c 2003/01/29 07:54:22
@@ -608,11 +608,24 @@
}
/**************************************************************************
- Draw the given map tile at the given canvas position in isometric
- view.
+ Draw some or all of a tile onto the mapview canvas.
**************************************************************************/
-void put_one_tile_iso(int map_x, int map_y, int canvas_x, int canvas_y,
- enum draw_type draw)
+void gui_map_put_tile_iso(int map_x, int map_y,
+ int canvas_x, int canvas_y,
+ int offset_x, int offset_y, int offset_y_unit,
+ int width, int height, int height_unit,
+ enum draw_type draw)
+{
+ /* PORTME */
+ assert(0);
+}
+
+/**************************************************************************
+ Draw some or all of a black tile onto the mapview canvas.
+**************************************************************************/
+void gui_map_put_black_tile_iso(int canvas_x, int canvas_y,
+ int offset_x, int offset_y,
+ int width, int height)
{
/* PORTME */
assert(0);
Index: client/include/mapview_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/mapview_g.h,v
retrieving revision 1.29
diff -u -r1.29 mapview_g.h
--- client/include/mapview_g.h 2003/01/17 20:20:57 1.29
+++ client/include/mapview_g.h 2003/01/29 07:54:23
@@ -39,8 +39,14 @@
void show_city_desc(struct city *pcity, int canvas_x, int canvas_y);
void put_one_tile(int map_x, int map_y, int canvas_x, int canvas_y);
-void put_one_tile_iso(int map_x, int map_y, int canvas_x, int canvas_y,
- enum draw_type draw);
+void gui_map_put_tile_iso(int map_x, int map_y,
+ int canvas_x, int canvas_y,
+ int offset_x, int offset_y, int offset_y_unit,
+ int width, int height, int height_unit,
+ enum draw_type draw);
+void gui_map_put_black_tile_iso(int canvas_x, int canvas_y,
+ int offset_x, int offset_y,
+ int width, int height);
void flush_mapcanvas(int canvas_x, int canvas_y,
int pixel_width, int pixel_height);
|
|