[Freeciv-Dev] (PR#7449) put_unit_city_overlays in mapview_common
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#7449) put_unit_city_overlays in mapview_common |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Thu, 19 Feb 2004 23:46:57 -0800 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=7449 >
This patch makes a new function put_unit_city_overlays in
mapview_common. It is called from the GUI code to draw the unit
overlays (support, food, etc.) in the city dialog.
Tested under gtk-2.0. gtk, xaw, and win32 clients successfully compiled.
jason
? confdefs.h
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.78
diff -u -r1.78 mapview_common.c
--- client/mapview_common.c 2004/02/18 02:20:51 1.78
+++ client/mapview_common.c 2004/02/20 07:45:44
@@ -663,6 +663,40 @@
0, 0, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
}
+/****************************************************************************
+ Draw food, gold, and shield upkeep values on the unit.
+
+ The proper way to do this is probably something like what Civ II does
+ (one sprite drawn N times on top of itself), but we just use separate
+ sprites (limiting the number of combinations).
+****************************************************************************/
+void put_unit_city_overlays(struct unit *punit,
+ struct canvas_store *pcanvas_store,
+ int canvas_x, int canvas_y)
+{
+ int upkeep_food = CLIP(0, punit->upkeep_food, 2);
+ int upkeep_gold = CLIP(0, punit->upkeep_gold, 2);
+ int unhappy = CLIP(0, punit->unhappiness, 2);
+
+ /* draw overlay pixmaps */
+ if (punit->upkeep > 0) {
+ gui_put_sprite_full(pcanvas_store, canvas_x, canvas_y,
+ sprites.upkeep.shield);
+ }
+ if (upkeep_food > 0) {
+ gui_put_sprite_full(pcanvas_store, canvas_x, canvas_y,
+ sprites.upkeep.food[upkeep_food - 1]);
+ }
+ if (upkeep_gold > 0) {
+ gui_put_sprite_full(pcanvas_store, canvas_x, canvas_y,
+ sprites.upkeep.gold[upkeep_gold - 1]);
+ }
+ if (unhappy > 0) {
+ gui_put_sprite_full(pcanvas_store, canvas_x, canvas_y,
+ sprites.upkeep.unhappy[unhappy - 1]);
+ }
+}
+
/**************************************************************************
Draw the borders of the given map tile at the given canvas position
in non-isometric view.
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.43
diff -u -r1.43 mapview_common.h
--- client/mapview_common.h 2004/02/18 02:20:51 1.43
+++ client/mapview_common.h 2004/02/20 07:45:44
@@ -165,6 +165,9 @@
int unit_width, int unit_height);
void put_unit_full(struct unit *punit, struct canvas_store *pcanvas_store,
int canvas_x, int canvas_y);
+void put_unit_city_overlays(struct unit *punit,
+ struct canvas_store *pcanvas_store,
+ int canvas_x, int canvas_y);
void put_one_tile(struct canvas_store *pcanvas_store, int map_x, int map_y,
int canvas_x, int canvas_y, bool citymode);
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.195
diff -u -r1.195 mapview.c
--- client/gui-gtk/mapview.c 2004/02/19 00:47:15 1.195
+++ client/gui-gtk/mapview.c 2004/02/20 07:45:45
@@ -55,9 +55,6 @@
static void pixmap_put_overlay_tile(GdkDrawable *pixmap,
int canvas_x, int canvas_y,
struct Sprite *ssprite);
-static void put_overlay_tile_gpixmap(GtkPixcomm *p,
- int canvas_x, int canvas_y,
- struct Sprite *ssprite);
static void put_line(GdkDrawable *pm, int x, int y, int dir);
static void pixmap_put_overlay_tile_draw(GdkDrawable *pixmap,
@@ -731,26 +728,9 @@
**************************************************************************/
void put_unit_gpixmap_city_overlays(struct unit *punit, GtkPixcomm *p)
{
- int upkeep_food = CLIP(0, punit->upkeep_food, 2);
- int upkeep_gold = CLIP(0, punit->upkeep_gold, 2);
- int unhappy = CLIP(0, punit->unhappiness, 2);
-
- /* draw overlay pixmaps */
- if (punit->upkeep > 0) {
- put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT, sprites.upkeep.shield);
- }
- if (upkeep_food > 0) {
- put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT,
- sprites.upkeep.food[upkeep_food-1]);
- }
- if (upkeep_gold > 0) {
- put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT,
- sprites.upkeep.gold[upkeep_gold - 1]);
- }
- if (unhappy > 0) {
- put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT,
- sprites.upkeep.unhappy[unhappy-1]);
- }
+ struct canvas_store store = {NULL, p};
+
+ put_unit_city_overlays(punit, &store, 0, NORMAL_TILE_HEIGHT);
}
/**************************************************************************
@@ -830,19 +810,6 @@
canvas_x, canvas_y,
NORMAL_TILE_WIDTH-1, NORMAL_TILE_HEIGHT-1);
}
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-static void put_overlay_tile_gpixmap(GtkPixcomm *p, int canvas_x, int canvas_y,
- struct Sprite *ssprite)
-{
- if (!ssprite)
- return;
-
- gtk_pixcomm_copyto (p, ssprite, canvas_x, canvas_y,
- FALSE);
}
/**************************************************************************
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.95
diff -u -r1.95 mapview.c
--- client/gui-gtk-2.0/mapview.c 2004/02/19 00:47:15 1.95
+++ client/gui-gtk-2.0/mapview.c 2004/02/20 07:45:45
@@ -56,9 +56,6 @@
static void pixmap_put_overlay_tile(GdkDrawable *pixmap,
int canvas_x, int canvas_y,
struct Sprite *ssprite);
-static void put_overlay_tile_gpixmap(GtkPixcomm *p,
- int canvas_x, int canvas_y,
- struct Sprite *ssprite);
static void put_line(GdkDrawable *pm, int x, int y, int dir);
static void pixmap_put_overlay_tile_draw(GdkDrawable *pixmap,
@@ -797,21 +794,11 @@
**************************************************************************/
void put_unit_gpixmap_city_overlays(struct unit *punit, GtkPixcomm *p)
{
- int upkeep_food = CLIP(0, punit->upkeep_food, 2);
- int upkeep_gold = CLIP(0, punit->upkeep_gold, 2);
- int unhappy = CLIP(0, punit->unhappiness, 2);
+ struct canvas_store store = {NULL, p};
gtk_pixcomm_freeze(p);
- /* draw overlay pixmaps */
- if (punit->upkeep > 0)
- put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT, sprites.upkeep.shield);
- if (upkeep_food > 0)
- put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT,
sprites.upkeep.food[upkeep_food-1]);
- if (upkeep_gold > 0)
- put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT,
sprites.upkeep.gold[upkeep_gold-1]);
- if (unhappy > 0)
- put_overlay_tile_gpixmap(p, 0, NORMAL_TILE_HEIGHT,
sprites.upkeep.unhappy[unhappy-1]);
+ put_unit_city_overlays(punit, &store, 0, NORMAL_TILE_HEIGHT);
gtk_pixcomm_thaw(p);
}
@@ -896,18 +883,6 @@
canvas_x, canvas_y,
NORMAL_TILE_WIDTH-1, NORMAL_TILE_HEIGHT-1);
}
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-static void put_overlay_tile_gpixmap(GtkPixcomm *p, int canvas_x, int canvas_y,
- struct Sprite *ssprite)
-{
- if (!ssprite)
- return;
-
- gtk_pixcomm_copyto(p, ssprite, canvas_x, canvas_y);
}
/**************************************************************************
Index: client/gui-mui/mapclass.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/mapclass.c,v
retrieving revision 1.96
diff -u -r1.96 mapclass.c
--- client/gui-mui/mapclass.c 2004/01/04 00:42:24 1.96
+++ client/gui-mui/mapclass.c 2004/02/20 07:45:47
@@ -2827,6 +2827,7 @@
int x = _mleft(o);
/* draw overlay pixmaps */
+ /* FIXME: call put_unit_city_overlays here. */
if (punit->upkeep > 0)
put_sprite_overlay_height(_rp(o), sprites.upkeep.shield, x, y,
get_normal_tile_height() / 2);
if (upkeep_food > 0)
Index: client/gui-win32/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/citydlg.c,v
retrieving revision 1.67
diff -u -r1.67 citydlg.c
--- client/gui-win32/citydlg.c 2004/01/06 08:11:34 1.67
+++ client/gui-win32/citydlg.c 2004/02/20 07:45:48
@@ -368,6 +368,8 @@
for(i=0; i<NUM_UNITS_SHOWN&&ITERATOR_PTR(myiter); ITERATOR_NEXT(myiter),i++)
{
RECT rc;
+ struct canvas_store store = {hdc, NULL};
+
punit=(struct unit*)ITERATOR_PTR(myiter);
if(unitid && punit->id!=unitid)
continue;
@@ -379,9 +381,9 @@
put_unit_full(punit,&canvas_store,
pdialog->pop_x+i*(SMALL_TILE_WIDTH+NORMAL_TILE_WIDTH),
pdialog->supported_y);
- put_unit_city_overlays(punit,hdc,
- pdialog->pop_x+i*(SMALL_TILE_WIDTH+NORMAL_TILE_WIDTH),
- pdialog->supported_y);
+ put_unit_city_overlays(punit, &store,
+ pdialog->pop_x + i * (SMALL_TILE_WIDTH + NORMAL_TILE_WIDTH),
+ pdialog->supported_y + NORMAL_TILE_HEIGHT);
pdialog->support_unit_ids[i]=punit->id;
}
for(; i<NUM_UNITS_SHOWN; i++) {
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.90
diff -u -r1.90 mapview.c
--- client/gui-win32/mapview.c 2004/02/19 14:11:43 1.90
+++ client/gui-win32/mapview.c 2004/02/20 07:45:49
@@ -238,22 +238,6 @@
/**************************************************************************
**************************************************************************/
-void put_unit_city_overlays(struct unit *punit, HDC hdc, int x, int y)
-{
- int upkeep_food = CLIP(0, punit->upkeep_food, 2);
- int unhappy = CLIP(0, punit->unhappiness, 2);
-
- if (punit->upkeep > 0)
- draw_sprite(sprites.upkeep.shield,hdc,x,y+NORMAL_TILE_HEIGHT);
- if (upkeep_food > 0)
- draw_sprite(sprites.upkeep.food[upkeep_food-1],hdc,x,y+NORMAL_TILE_HEIGHT);
- if (unhappy > 0)
- draw_sprite(sprites.upkeep.unhappy[unhappy-1],hdc,x,y+NORMAL_TILE_HEIGHT);
-}
-
-/**************************************************************************
-
-**************************************************************************/
void pixmap_frame_tile_red(HDC hdc, int canvas_x, int canvas_y)
{
HPEN old;
Index: client/gui-win32/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.h,v
retrieving revision 1.11
diff -u -r1.11 mapview.h
--- client/gui-win32/mapview.h 2003/11/09 16:45:01 1.11
+++ client/gui-win32/mapview.h 2004/02/20 07:45:49
@@ -18,7 +18,6 @@
void put_city_tile_output(HDC hdc, int x, int y,
int food, int shield, int trade);
void pixmap_frame_tile_red(HDC hdc, int x, int y);
-void put_unit_city_overlays(struct unit *punit, 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/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.158
diff -u -r1.158 mapview.c
--- client/gui-xaw/mapview.c 2004/02/18 02:20:52 1.158
+++ client/gui-xaw/mapview.c 2004/02/20 07:45:49
@@ -773,24 +773,14 @@
**************************************************************************/
void put_unit_pixmap_city_overlays(struct unit *punit, Pixmap pm)
{
- int upkeep_food = CLIP(0, punit->upkeep_food, 2);
- int unhappy = CLIP(0, punit->unhappiness, 2);
+ struct canvas_store store = {pm};
/* wipe the slate clean */
XSetForeground(display, fill_bg_gc, colors_standard[COLOR_STD_WHITE]);
XFillRectangle(display, pm, fill_bg_gc, 0, NORMAL_TILE_WIDTH,
NORMAL_TILE_HEIGHT, NORMAL_TILE_HEIGHT+SMALL_TILE_HEIGHT);
- /* draw overlay pixmaps */
- if (punit->upkeep > 0)
- pixmap_put_overlay_tile(pm, 0, NORMAL_TILE_HEIGHT,
- sprites.upkeep.shield);
- if (upkeep_food > 0)
- pixmap_put_overlay_tile(pm, 0, NORMAL_TILE_HEIGHT,
- sprites.upkeep.food[upkeep_food-1]);
- if (unhappy > 0)
- pixmap_put_overlay_tile(pm, 0, NORMAL_TILE_HEIGHT,
- sprites.upkeep.unhappy[unhappy-1]);
+ put_unit_city_overlays(punit, &store, 0, NORMAL_TILE_HEIGHT);
}
/**************************************************************************
- [Freeciv-Dev] (PR#7449) put_unit_city_overlays in mapview_common,
Jason Short <=
|
|