[Freeciv-Dev] (PR#7531) move put_red_frame_tile into mapview_common
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#7531) move put_red_frame_tile into mapview_common |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Wed, 25 Feb 2004 16:29:47 -0800 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=7531 >
This patch moves pixmap_frame_tile_red into mapview_common and renames
it as put_red_frame_tile.
This would be quite straightforward except for two things:
- In non-iso view we have to draw lines, not rectangles.
- This process is currently extremely buggy. This patch doesn't change
behavior, so all the bugs remain. I don't think the bug(s) are in this
function.
jason
? put_red_frame_tile.diff
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.82
diff -u -r1.82 mapview_common.c
--- client/mapview_common.c 2004/02/25 23:02:55 1.82
+++ client/mapview_common.c 2004/02/26 00:29:02
@@ -733,6 +733,41 @@
}
/****************************************************************************
+ Draw a red frame around the tile. (canvas_x, canvas_y) is the tile origin.
+****************************************************************************/
+void put_red_frame_tile(struct canvas_store *pcanvas_store,
+ int canvas_x, int canvas_y)
+{
+ if (is_isometric) {
+ gui_put_line(pcanvas_store, COLOR_STD_RED, LINE_TILE_FRAME,
+ canvas_x + NORMAL_TILE_WIDTH / 2 - 1, canvas_y,
+ NORMAL_TILE_WIDTH / 2, NORMAL_TILE_HEIGHT / 2 - 1);
+ gui_put_line(pcanvas_store, COLOR_STD_RED, LINE_TILE_FRAME,
+ canvas_x + NORMAL_TILE_WIDTH - 1,
+ canvas_y + NORMAL_TILE_HEIGHT / 2 - 1,
+ -NORMAL_TILE_WIDTH / 2, NORMAL_TILE_HEIGHT / 2);
+ gui_put_line(pcanvas_store, COLOR_STD_RED, LINE_TILE_FRAME,
+ canvas_x + NORMAL_TILE_WIDTH / 2 - 1,
+ canvas_y + NORMAL_TILE_HEIGHT - 1,
+ -(NORMAL_TILE_WIDTH / 2 - 1), -NORMAL_TILE_HEIGHT / 2);
+ gui_put_line(pcanvas_store, COLOR_STD_RED, LINE_TILE_FRAME,
+ canvas_x, canvas_y + NORMAL_TILE_HEIGHT / 2 - 1,
+ NORMAL_TILE_WIDTH / 2 - 1, -(NORMAL_TILE_HEIGHT / 2 - 1));
+ } else {
+ gui_put_line(pcanvas_store, COLOR_STD_RED, LINE_NORMAL,
+ canvas_x, canvas_y, NORMAL_TILE_WIDTH - 1, 0);
+ gui_put_line(pcanvas_store, COLOR_STD_RED, LINE_NORMAL,
+ canvas_x + NORMAL_TILE_WIDTH - 1, canvas_y,
+ 0, NORMAL_TILE_HEIGHT - 1);
+ gui_put_line(pcanvas_store, COLOR_STD_RED, LINE_NORMAL,
+ canvas_x, canvas_y, 0, NORMAL_TILE_HEIGHT - 1);
+ gui_put_line(pcanvas_store, COLOR_STD_RED, LINE_NORMAL,
+ canvas_x, canvas_y + NORMAL_TILE_HEIGHT - 1,
+ NORMAL_TILE_WIDTH - 1, 0);
+ }
+}
+
+/****************************************************************************
Animate the nuke explosion at map(x, y).
****************************************************************************/
void put_nuke_mushroom_pixmaps(int map_x, int map_y)
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.46
diff -u -r1.46 mapview_common.h
--- client/mapview_common.h 2004/02/25 23:02:56 1.46
+++ client/mapview_common.h 2004/02/26 00:29:02
@@ -172,6 +172,9 @@
void put_unit_city_overlays(struct unit *punit,
struct canvas_store *pcanvas_store,
int canvas_x, int canvas_y);
+void put_red_frame_tile(struct canvas_store *pcanvas_store,
+ int canvas_x, int canvas_y);
+
void put_nuke_mushroom_pixmaps(int map_x, int map_y);
void put_one_tile(struct canvas_store *pcanvas_store, 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.177
diff -u -r1.177 citydlg.c
--- client/gui-gtk/citydlg.c 2004/02/25 23:02:56 1.177
+++ client/gui-gtk/citydlg.c 2004/02/26 00:29:03
@@ -1807,7 +1807,7 @@
if (tile_get_known(map_x, map_y)
&& city_to_canvas_pos(&canvas_x, &canvas_y, x, y)
&& pcity->city_map[x][y] == C_TILE_UNAVAILABLE) {
- pixmap_frame_tile_red(pdialog->map_canvas_store, canvas_x, canvas_y);
+ put_red_frame_tile(&store, canvas_x, canvas_y);
}
}
city_map_checked_iterate_end;
@@ -1836,9 +1836,8 @@
x * NORMAL_TILE_WIDTH,
y * NORMAL_TILE_HEIGHT);
else if (pcity->city_map[x][y] == C_TILE_UNAVAILABLE)
- pixmap_frame_tile_red(pdialog->map_canvas_store,
- x * NORMAL_TILE_WIDTH,
- y * NORMAL_TILE_HEIGHT);
+ put_red_frame_tile(&store,
+ x * NORMAL_TILE_WIDTH, y * NORMAL_TILE_HEIGHT);
} else {
pixmap_put_black_tile(pdialog->map_canvas_store,
x * NORMAL_TILE_WIDTH,
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.198
diff -u -r1.198 mapview.c
--- client/gui-gtk/mapview.c 2004/02/25 23:02:56 1.198
+++ client/gui-gtk/mapview.c 2004/02/26 00:29:03
@@ -721,36 +721,6 @@
}
/**************************************************************************
-canvas_x, canvas_y is the top left corner of the pixmap.
-**************************************************************************/
-void pixmap_frame_tile_red(GdkDrawable *pm,
- int canvas_x, int canvas_y)
-{
- if (is_isometric) {
- gdk_gc_set_foreground(thick_line_gc, colors_standard[COLOR_STD_RED]);
-
- gdk_draw_line(pm, thick_line_gc,
- canvas_x+NORMAL_TILE_WIDTH/2-1, canvas_y,
- canvas_x+NORMAL_TILE_WIDTH-1,
canvas_y+NORMAL_TILE_HEIGHT/2-1);
- gdk_draw_line(pm, thick_line_gc,
- canvas_x+NORMAL_TILE_WIDTH-1, canvas_y+NORMAL_TILE_HEIGHT/2-1,
- canvas_x+NORMAL_TILE_WIDTH/2-1,
canvas_y+NORMAL_TILE_HEIGHT-1);
- gdk_draw_line(pm, thick_line_gc,
- canvas_x+NORMAL_TILE_WIDTH/2-1, canvas_y+NORMAL_TILE_HEIGHT-1,
- canvas_x, canvas_y + NORMAL_TILE_HEIGHT/2-1);
- gdk_draw_line(pm, thick_line_gc,
- canvas_x, canvas_y + NORMAL_TILE_HEIGHT/2-1,
- canvas_x+NORMAL_TILE_WIDTH/2-1, canvas_y);
- } else {
- gdk_gc_set_foreground(fill_bg_gc, colors_standard[COLOR_STD_RED]);
-
- gdk_draw_rectangle(pm, fill_bg_gc, FALSE,
- canvas_x, canvas_y,
- NORMAL_TILE_WIDTH-1, NORMAL_TILE_HEIGHT-1);
- }
-}
-
-/**************************************************************************
...
**************************************************************************/
static void pixmap_put_overlay_tile(GdkDrawable *pixmap,
@@ -856,9 +826,20 @@
enum line_type ltype, int start_x, int start_y,
int dx, int dy)
{
- GdkGC *gc;
+ GdkGC *gc = NULL;
+
+ switch (ltype) {
+ case LINE_NORMAL:
+ gc = civ_gc;
+ break;
+ case LINE_BORDER:
+ gc = border_line_gc;
+ break;
+ case LINE_TILE_FRAME:
+ gc = thick_line_gc;
+ break;
+ }
- gc = (ltype == LINE_BORDER ? border_line_gc : civ_gc);
gdk_gc_set_foreground(gc, colors_standard[color]);
gdk_draw_line(pcanvas_store->pixmap, gc,
start_x, start_y, start_x + dx, start_y + dy);
Index: client/gui-gtk/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.h,v
retrieving revision 1.24
diff -u -r1.24 mapview.h
--- client/gui-gtk/mapview.h 2004/02/25 23:02:56 1.24
+++ client/gui-gtk/mapview.h 2004/02/26 00:29:03
@@ -35,8 +35,6 @@
void put_unit_gpixmap_city_overlays(struct unit *punit, GtkPixcomm *p);
void put_one_tile_full(GdkDrawable *pm, int x, int y,
int canvas_x, int canvas_y, int citymode);
-void pixmap_frame_tile_red(GdkDrawable *pm,
- int canvas_x, int canvas_y);
void pixmap_put_black_tile(GdkDrawable *pm,
int canvas_x, int canvas_y);
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.74
diff -u -r1.74 citydlg.c
--- client/gui-gtk-2.0/citydlg.c 2004/02/25 23:02:56 1.74
+++ client/gui-gtk-2.0/citydlg.c 2004/02/26 00:29:04
@@ -1408,7 +1408,7 @@
if (tile_get_known(map_x, map_y)
&& city_to_canvas_pos(&canvas_x, &canvas_y, x, y)
&& pcity->city_map[x][y] == C_TILE_UNAVAILABLE) {
- pixmap_frame_tile_red(pdialog->map_canvas_store, canvas_x, canvas_y);
+ put_red_frame_tile(&store, canvas_x, canvas_y);
}
}
city_map_checked_iterate_end;
@@ -1437,9 +1437,8 @@
x * NORMAL_TILE_WIDTH,
y * NORMAL_TILE_HEIGHT);
else if (pcity->city_map[x][y] == C_TILE_UNAVAILABLE)
- pixmap_frame_tile_red(pdialog->map_canvas_store,
- x * NORMAL_TILE_WIDTH,
- y * NORMAL_TILE_HEIGHT);
+ put_red_frame_tile(&store,
+ x * NORMAL_TILE_WIDTH, y * NORMAL_TILE_HEIGHT);
} else {
pixmap_put_black_tile(pdialog->map_canvas_store,
x * NORMAL_TILE_WIDTH,
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.98
diff -u -r1.98 mapview.c
--- client/gui-gtk-2.0/mapview.c 2004/02/25 23:02:56 1.98
+++ client/gui-gtk-2.0/mapview.c 2004/02/26 00:29:04
@@ -791,36 +791,6 @@
}
/**************************************************************************
-canvas_x, canvas_y is the top left corner of the pixmap.
-**************************************************************************/
-void pixmap_frame_tile_red(GdkDrawable *pm,
- int canvas_x, int canvas_y)
-{
- if (is_isometric) {
- gdk_gc_set_foreground(thick_line_gc, colors_standard[COLOR_STD_RED]);
-
- gdk_draw_line(pm, thick_line_gc,
- canvas_x+NORMAL_TILE_WIDTH/2-1, canvas_y,
- canvas_x+NORMAL_TILE_WIDTH-1,
canvas_y+NORMAL_TILE_HEIGHT/2-1);
- gdk_draw_line(pm, thick_line_gc,
- canvas_x+NORMAL_TILE_WIDTH-1, canvas_y+NORMAL_TILE_HEIGHT/2-1,
- canvas_x+NORMAL_TILE_WIDTH/2-1,
canvas_y+NORMAL_TILE_HEIGHT-1);
- gdk_draw_line(pm, thick_line_gc,
- canvas_x+NORMAL_TILE_WIDTH/2-1, canvas_y+NORMAL_TILE_HEIGHT-1,
- canvas_x, canvas_y + NORMAL_TILE_HEIGHT/2-1);
- gdk_draw_line(pm, thick_line_gc,
- canvas_x, canvas_y + NORMAL_TILE_HEIGHT/2-1,
- canvas_x+NORMAL_TILE_WIDTH/2-1, canvas_y);
- } else {
- gdk_gc_set_foreground(fill_bg_gc, colors_standard[COLOR_STD_RED]);
-
- gdk_draw_rectangle(pm, fill_bg_gc, FALSE,
- canvas_x, canvas_y,
- NORMAL_TILE_WIDTH-1, NORMAL_TILE_HEIGHT-1);
- }
-}
-
-/**************************************************************************
...
**************************************************************************/
static void pixmap_put_overlay_tile(GdkDrawable *pixmap,
@@ -926,9 +896,20 @@
enum line_type ltype, int start_x, int start_y,
int dx, int dy)
{
- GdkGC *gc;
+ GdkGC *gc = NULL;
+
+ switch (ltype) {
+ case LINE_NORMAL:
+ gc = civ_gc;
+ break;
+ case LINE_BORDER:
+ gc = border_line_gc;
+ break;
+ case LINE_TILE_FRAME:
+ gc = thick_line_gc;
+ break;
+ }
- gc = (ltype == LINE_BORDER ? border_line_gc : civ_gc);
gdk_gc_set_foreground(gc, colors_standard[color]);
gdk_draw_line(pcanvas_store->pixmap, gc,
start_x, start_y, start_x + dx, start_y + dy);
Index: client/gui-gtk-2.0/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.h,v
retrieving revision 1.14
diff -u -r1.14 mapview.h
--- client/gui-gtk-2.0/mapview.h 2004/02/25 23:02:56 1.14
+++ client/gui-gtk-2.0/mapview.h 2004/02/26 00:29:04
@@ -38,8 +38,6 @@
void put_unit_gpixmap_city_overlays(struct unit *punit, GtkPixcomm *p);
void put_one_tile_full(GdkDrawable *pm, int x, int y,
int canvas_x, int canvas_y, int citymode);
-void pixmap_frame_tile_red(GdkDrawable *pm,
- int canvas_x, int canvas_y);
void pixmap_put_black_tile(GdkDrawable *pm,
int canvas_x, int canvas_y);
Index: client/gui-win32/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/citydlg.c,v
retrieving revision 1.71
diff -u -r1.71 citydlg.c
--- client/gui-win32/citydlg.c 2004/02/25 23:02:56 1.71
+++ client/gui-win32/citydlg.c 2004/02/26 00:29:04
@@ -537,7 +537,7 @@
if (tile_get_known(map_x, map_y)
&& city_to_canvas_pos(&canvas_x, &canvas_y, x, y)
&& pcity->city_map[x][y] == C_TILE_UNAVAILABLE) {
- pixmap_frame_tile_red(hdc, canvas_x, canvas_y);
+ put_red_frame_tile(&store, canvas_x, canvas_y);
}
} city_map_checked_iterate_end;
@@ -567,8 +567,8 @@
NORMAL_TILE_WIDTH * x,
NORMAL_TILE_HEIGHT * y);
else if(pcity->city_map[x][y]==C_TILE_UNAVAILABLE)
- pixmap_frame_tile_red(citydlgdc, x*NORMAL_TILE_WIDTH,
- y*NORMAL_TILE_HEIGHT);
+ put_red_frame_tile(&store,
+ x * NORMAL_TILE_WIDTH, y * NORMAL_TILE_HEIGHT);
}
else {
BitBlt(citydlgdc,x*NORMAL_TILE_WIDTH,
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.95
diff -u -r1.95 mapview.c
--- client/gui-win32/mapview.c 2004/02/25 23:02:56 1.95
+++ client/gui-win32/mapview.c 2004/02/26 00:29:04
@@ -246,27 +246,6 @@
}
/**************************************************************************
-
-**************************************************************************/
-void pixmap_frame_tile_red(HDC hdc, int canvas_x, int canvas_y)
-{
- HPEN old;
- old=SelectObject(hdc,pen_std[COLOR_STD_RED]);
- if (is_isometric) {
- MoveToEx(hdc, canvas_x+NORMAL_TILE_WIDTH/2-1, canvas_y, NULL);
- LineTo(hdc, canvas_x+NORMAL_TILE_WIDTH-1, canvas_y+NORMAL_TILE_HEIGHT/2-1);
- LineTo(hdc, canvas_x+NORMAL_TILE_WIDTH/2-1,
- canvas_y+NORMAL_TILE_HEIGHT-1);
- LineTo(hdc, canvas_x, canvas_y+NORMAL_TILE_HEIGHT/2-1);
- LineTo(hdc, canvas_x+NORMAL_TILE_WIDTH/2-1, canvas_y);
- } else {
- mydrawrect(hdc,canvas_x,canvas_y,
- NORMAL_TILE_WIDTH-1,NORMAL_TILE_HEIGHT-1);
- }
- SelectObject(hdc,old);
-}
-
-/**************************************************************************
hack to ensure that mapstorebitmap is usable.
On win95/win98 mapstorebitmap becomes somehow invalid.
**************************************************************************/
Index: client/gui-win32/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.h,v
retrieving revision 1.13
diff -u -r1.13 mapview.h
--- client/gui-win32/mapview.h 2004/02/25 23:02:56 1.13
+++ client/gui-win32/mapview.h 2004/02/26 00:29:04
@@ -15,7 +15,6 @@
#include "mapview_g.h"
-void pixmap_frame_tile_red(HDC hdc, int x, int y);
void put_one_tile_full(HDC hdc, int x, int y,
int canvas_x, int canvas_y, int citymode);
void check_mapstore(void);
Index: client/gui-xaw/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/citydlg.c,v
retrieving revision 1.110
diff -u -r1.110 citydlg.c
--- client/gui-xaw/citydlg.c 2004/02/25 23:02:56 1.110
+++ client/gui-xaw/citydlg.c 2004/02/26 00:29:05
@@ -1549,8 +1549,7 @@
if (pcity->city_map[x][y] == C_TILE_WORKER)
put_city_tile_output(pcity, x, y, &store, canvas_x, canvas_y);
else if (pcity->city_map[x][y] == C_TILE_UNAVAILABLE)
- pixmap_frame_tile_red(XtWindow(pdialog->map_canvas),
- canvas_x, canvas_y);
+ put_red_frame_tile(&store, canvas_x, canvas_y);
}
}
}
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.161
diff -u -r1.161 mapview.c
--- client/gui-xaw/mapview.c 2004/02/25 23:02:56 1.161
+++ client/gui-xaw/mapview.c 2004/02/26 00:29:05
@@ -790,25 +790,6 @@
NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
}
-
-/**************************************************************************
-...
-**************************************************************************/
-void pixmap_frame_tile_red(Pixmap pm, int canvas_x, int canvas_y)
-{
- XSetForeground(display, fill_bg_gc, colors_standard[COLOR_STD_RED]);
-
- XDrawRectangle(display, pm, fill_bg_gc,
- canvas_x, canvas_y,
- NORMAL_TILE_WIDTH-1, NORMAL_TILE_HEIGHT-1);
- XDrawRectangle(display, pm, fill_bg_gc,
- canvas_x+1, canvas_y+1,
- NORMAL_TILE_WIDTH-3, NORMAL_TILE_HEIGHT-3);
- XDrawRectangle(display, pm, fill_bg_gc,
- canvas_x+2, canvas_y+2,
- NORMAL_TILE_WIDTH-5, NORMAL_TILE_HEIGHT-5);
-}
-
/**************************************************************************
...
**************************************************************************/
Index: client/gui-xaw/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.h,v
retrieving revision 1.21
diff -u -r1.21 mapview.h
--- client/gui-xaw/mapview.h 2004/02/25 23:02:57 1.21
+++ client/gui-xaw/mapview.h 2004/02/26 00:29:05
@@ -36,7 +36,6 @@
void *client_data);
void pixmap_put_black_tile(Pixmap pm, int canvas_x, int canvas_y);
-void pixmap_frame_tile_red(Pixmap pm, int canvas_x, int canvas_y);
void scrollbar_jump_callback(Widget scrollbar, XtPointer client_data,
XtPointer percent_ptr);
Index: client/include/colors_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/colors_g.h,v
retrieving revision 1.7
diff -u -r1.7 colors_g.h
--- client/include/colors_g.h 2003/07/23 13:46:03 1.7
+++ client/include/colors_g.h 2004/02/26 00:29:05
@@ -28,7 +28,7 @@
};
enum line_type {
- LINE_NORMAL, LINE_BORDER
+ LINE_NORMAL, LINE_BORDER, LINE_TILE_FRAME
};
enum Display_color_type {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#7531) move put_red_frame_tile into mapview_common,
Jason Short <=
|
|