[Freeciv-Dev] (PR#7334) remove mapview macros from gui-gtk
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#7334) remove mapview macros from gui-gtk |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Tue, 27 Jan 2004 18:28:02 -0800 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=7334 >
When the mapview unification was done we just wrote wrappers for the new
values in mapview.h, rather than rename them throughout the code.
This patch removes these wrappers from gui-gtk. There are some
cleanups done in the process: many callers did not check the value of
get_canvas_xy (map_to_canvas_pos), and did unnecessary work.
jason
Index: client/gui-gtk/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v
retrieving revision 1.142
diff -u -r1.142 gui_main.c
--- client/gui-gtk/gui_main.c 2004/01/24 02:58:55 1.142
+++ client/gui-gtk/gui_main.c 2004/01/28 02:27:00
@@ -952,12 +952,13 @@
timer_id = gtk_timeout_add(TIMER_INTERVAL, timer_callback, NULL);
/* Start with a 1x1 window (GTK doesn't like 0x0). */
- map_canvas_store_twidth = 1;
- map_canvas_store_theight = 1;
+ mapview_canvas.tile_width = 1;
+ mapview_canvas.tile_height = 1;
+ mapview_canvas.width = mapview_canvas.tile_width * NORMAL_TILE_WIDTH;
+ mapview_canvas.height = mapview_canvas.tile_height * NORMAL_TILE_HEIGHT;
map_canvas_store = gdk_pixmap_new(root_window,
- map_canvas_store_twidth * NORMAL_TILE_WIDTH,
- map_canvas_store_theight * NORMAL_TILE_HEIGHT,
- -1);
+ mapview_canvas.width,
+ mapview_canvas.height, -1);
mapview_canvas.store = fc_malloc(sizeof(*mapview_canvas.store));
mapview_canvas.store->pixmap = map_canvas_store;
mapview_canvas.store->pixcomm = NULL;
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.187
diff -u -r1.187 mapview.c
--- client/gui-gtk/mapview.c 2004/01/11 17:45:03 1.187
+++ client/gui-gtk/mapview.c 2004/01/28 02:27:00
@@ -93,8 +93,14 @@
{
static struct timer *anim_timer = NULL;
struct unit *losing_unit = (hp0 == 0 ? punit0 : punit1);
- int i;
+ int canvas_x, canvas_y, i;
+ if (!map_to_canvas_pos(&canvas_x, &canvas_y,
+ losing_unit->x, losing_unit->y)) {
+ /* No drawing needed. */
+ return;
+ }
+
set_units_in_combat(punit0, punit1);
do {
@@ -117,8 +123,6 @@
} while (punit0->hp > hp0 || punit1->hp > hp1);
for (i = 0; i < num_tiles_explode_unit; i++) {
- int canvas_x, canvas_y;
- get_canvas_xy(losing_unit->x, losing_unit->y, &canvas_x, &canvas_y);
anim_timer = renew_timer_start(anim_timer, TIMER_USER, TIMER_ACTIVE);
if (is_isometric) {
/* We first draw the explosion onto the unit and draw draw the
@@ -514,16 +518,16 @@
tile_height=(height+NORMAL_TILE_HEIGHT-1)/NORMAL_TILE_HEIGHT;
map_resized=FALSE;
- if(map_canvas_store_twidth !=tile_width ||
- map_canvas_store_theight!=tile_height) { /* resized? */
+ if(mapview_canvas.tile_width != tile_width
+ || mapview_canvas.tile_height != tile_height) { /* resized? */
gdk_pixmap_unref(map_canvas_store);
- map_canvas_store_twidth=tile_width;
- map_canvas_store_theight=tile_height;
+ mapview_canvas.tile_width = tile_width;
+ mapview_canvas.tile_height = tile_height;
/*
gtk_drawing_area_size(GTK_DRAWING_AREA(map_canvas),
- map_canvas_store_twidth,
- map_canvas_store_theight);
+ mapview_canvas.tile_width,
+ mapview_canvas.tile_height);
*/
map_canvas_store= gdk_pixmap_new( map_canvas->window,
tile_width*NORMAL_TILE_WIDTH,
@@ -534,8 +538,8 @@
gdk_gc_set_foreground(fill_bg_gc, colors_standard[COLOR_STD_BLACK]);
gdk_draw_rectangle(map_canvas_store, fill_bg_gc, TRUE,
0, 0,
- NORMAL_TILE_WIDTH*map_canvas_store_twidth,
- NORMAL_TILE_HEIGHT*map_canvas_store_theight);
+ NORMAL_TILE_WIDTH * mapview_canvas.tile_width,
+ NORMAL_TILE_HEIGHT * mapview_canvas.tile_height);
update_map_canvas_scrollbars_size();
map_resized=TRUE;
}
@@ -861,7 +865,7 @@
int canvas_x, canvas_y;
struct Sprite *mysprite = sprites.explode.iso_nuke;
- get_canvas_xy(x, y, &canvas_x, &canvas_y);
+ (void) map_to_canvas_pos(&canvas_x, &canvas_y, x, y);
canvas_x += NORMAL_TILE_WIDTH/2 - mysprite->width/2;
canvas_y += NORMAL_TILE_HEIGHT/2 - mysprite->height/2;
@@ -879,7 +883,10 @@
for (y_itr=0; y_itr<3; y_itr++) {
for (x_itr=0; x_itr<3; x_itr++) {
struct Sprite *mysprite = sprites.explode.nuke[y_itr][x_itr];
- get_canvas_xy(x + x_itr - 1, y + y_itr - 1, &canvas_x, &canvas_y);
+ if (!map_to_canvas_pos(&canvas_x, &canvas_y,
+ x + x_itr - 1, y + y_itr - 1)) {
+ continue;
+ }
gdk_draw_pixmap(single_tile_pixmap, civ_gc, map_canvas_store,
canvas_x, canvas_y, 0, 0,
@@ -1094,9 +1101,8 @@
void put_cross_overlay_tile(int x, int y)
{
int canvas_x, canvas_y;
- get_canvas_xy(x, y, &canvas_x, &canvas_y);
- if (tile_visible_mapcanvas(x, y)) {
+ if (map_to_canvas_pos(&canvas_x, &canvas_y, x, y)) {
pixmap_put_overlay_tile(map_canvas->window,
canvas_x, canvas_y,
sprites.user.attention);
@@ -1121,7 +1127,9 @@
city_map_checked_iterate(pcity->x, pcity->y, i, j, x, y) {
enum city_tile_type worked = get_worker_city(pcity, i, j);
- get_canvas_xy(x, y, &canvas_x, &canvas_y);
+ if (!map_to_canvas_pos(&canvas_x, &canvas_y, x, y)) {
+ continue;
+ }
/* stipple the area */
if (!is_city_center(i, j)) {
@@ -1247,8 +1255,10 @@
/* Find middle of tiles. y-1 to not undraw the the middle pixel of a
horizontal line when we refresh the tile below-between. */
- get_canvas_xy(src_x, src_y, &canvas_start_x, &canvas_start_y);
- get_canvas_xy(dest_x, dest_y, &canvas_end_x, &canvas_end_y);
+ if (!map_to_canvas_pos(&canvas_start_x, &canvas_start_y, src_x, src_y)
+ && !map_to_canvas_pos(&canvas_end_x, &canvas_end_y, dest_x, dest_y)) {
+ return;
+ }
canvas_start_x += NORMAL_TILE_WIDTH/2;
canvas_start_y += NORMAL_TILE_HEIGHT/2-1;
canvas_end_x += NORMAL_TILE_WIDTH/2;
@@ -1322,7 +1332,7 @@
static void put_line(GdkDrawable *pm, int x, int y, int dir)
{
int canvas_src_x, canvas_src_y, canvas_dest_x, canvas_dest_y;
- get_canvas_xy(x, y, &canvas_src_x, &canvas_src_y);
+ (void) map_to_canvas_pos(&canvas_src_x, &canvas_src_y, x, y);
canvas_src_x += NORMAL_TILE_WIDTH/2;
canvas_src_y += NORMAL_TILE_HEIGHT/2;
DIRSTEP(canvas_dest_x, canvas_dest_y, dir);
Index: client/gui-gtk/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.h,v
retrieving revision 1.22
diff -u -r1.22 mapview.h
--- client/gui-gtk/mapview.h 2003/04/04 15:47:46 1.22
+++ client/gui-gtk/mapview.h 2004/01/28 02:27:00
@@ -49,14 +49,4 @@
void scrollbar_jump_callback(GtkAdjustment *adj, gpointer hscrollbar);
void update_map_canvas_scrollbars_size(void);
-/* These values are stored in the mapview_canvas struct now. */
-#define map_view_x0 mapview_canvas.map_x0
-#define map_view_y0 mapview_canvas.map_y0
-#define map_canvas_store_twidth mapview_canvas.tile_width
-#define map_canvas_store_theight mapview_canvas.tile_height
-
-/* Use of these wrapper functions is deprecated. */
-#define get_canvas_xy(map_x, map_y, canvas_x, canvas_y) \
- map_to_canvas_pos(canvas_x, canvas_y, map_x, map_y)
-
#endif /* FC__MAPVIEW_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#7334) remove mapview macros from gui-gtk,
Jason Short <=
|
|