[Freeciv-Dev] Re: (PR#4576) remove sprite padding for flags
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Mike Kaufman wrote:
> On Thu, Aug 07, 2003 at 07:09:34AM -0700, Jason Short wrote:
>
>>Here's an updated version.
>
> flags should go into misc/ if this is the case. We can't depend on trident/
> existing...
Yes. I'd like to get the code changes finished first, though (the
tileset changes are only for testing at this point).
Here's a full patch that uses drawn_sprites instead of Sprites
everywhere. This is the "clean" solution, as originally discussed by
myself and ESR. Eventually all sprites can be cropped and only
minimally drawn.
jason
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.57
diff -u -r1.57 mapview_common.c
--- client/mapview_common.c 2003/08/06 16:10:07 1.57
+++ client/mapview_common.c 2003/08/07 14:39:53
@@ -416,7 +416,7 @@
int unit_offset_x, int unit_offset_y,
int unit_width, int unit_height)
{
- struct Sprite *sprites[40];
+ struct drawn_sprite sprites[40];
bool solid_bg;
int count = fill_unit_sprite_array(sprites, punit, &solid_bg), i;
@@ -426,12 +426,14 @@
}
for (i = 0; i < count; i++) {
- if (sprites[i]) {
+ if (sprites[i].sprite) {
+ int ox = sprites[i].offset_x, oy = sprites[i].offset_y;
+
/* units are never fogged */
- gui_put_sprite(pcanvas_store,
- canvas_x, canvas_y, sprites[i],
- unit_offset_x, unit_offset_y,
- unit_width, unit_height);
+ gui_put_sprite(pcanvas_store, canvas_x + ox, canvas_y + oy,
+ sprites[i].sprite,
+ unit_offset_x - ox, unit_offset_y - oy,
+ unit_width - ox, unit_height - oy);
}
}
}
@@ -508,7 +510,7 @@
void put_one_tile(struct canvas_store *pcanvas_store, int map_x, int map_y,
int canvas_x, int canvas_y, bool citymode)
{
- struct Sprite *tile_sprs[80];
+ struct drawn_sprite tile_sprs[80];
bool solid_bg;
struct player *pplayer;
bool is_real = normalize_map_pos(&map_x, &map_y);
@@ -526,8 +528,11 @@
}
for (i = 0; i < count; i++) {
- if (tile_sprs[i]) {
- gui_put_sprite_full(pcanvas_store, canvas_x, canvas_y, tile_sprs[i]);
+ if (tile_sprs[i].sprite) {
+ gui_put_sprite_full(pcanvas_store,
+ canvas_x + tile_sprs[i].offset_x,
+ canvas_y + tile_sprs[i].offset_y,
+ tile_sprs[i].sprite);
}
}
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.127
diff -u -r1.127 tilespec.c
--- client/tilespec.c 2003/08/06 16:10:07 1.127
+++ client/tilespec.c 2003/08/07 14:39:53
@@ -80,6 +80,7 @@
static bool is_mountainous = FALSE;
static int roadstyle;
+static int flag_offset_x, flag_offset_y;
struct specfile;
@@ -627,6 +628,10 @@
"tilespec.is_mountainous");
roadstyle = secfile_lookup_int_default(file, is_isometric ? 0 : 1,
"tilespec.roadstyle");
+ flag_offset_x = secfile_lookup_int_default(file, 0,
+ "tilespec.flag_offset_x");
+ flag_offset_y = secfile_lookup_int_default(file, 0,
+ "tilespec.flag_offset_y");
c = secfile_lookup_str_default(file, "10x20", "tilespec.city_names_font");
city_names_font = mystrdup(c);
@@ -1252,51 +1257,60 @@
return sprites.city.tile[style][city_styles[style].tiles_num+1];
}
+#define ADD_SPRITE(s, x_offset, y_offset) \
+ (sprs->sprite = s, \
+ sprs->offset_x = x_offset, \
+ sprs->offset_y = y_offset, \
+ sprs++)
+
+#define ADD_SPRITE_SIMPLE(s) ADD_SPRITE(s, 0, 0)
+
/**********************************************************************
Fill in the sprite array for the city
***********************************************************************/
-static int fill_city_sprite_array(struct Sprite **sprs, struct city *pcity,
- bool *solid_bg)
+static int fill_city_sprite_array(struct drawn_sprite *sprs,
+ struct city *pcity, bool *solid_bg)
{
- struct Sprite **save_sprs=sprs;
+ struct drawn_sprite *save_sprs = sprs;
*solid_bg = FALSE;
if (!no_backdrop) {
- if(!solid_color_behind_units) {
- *sprs++ = get_city_nation_flag_sprite(pcity);
+ if (is_isometric || !solid_color_behind_units) {
+ ADD_SPRITE(get_city_nation_flag_sprite(pcity),
+ flag_offset_x, flag_offset_y);
} else {
*solid_bg = TRUE;
}
}
if (pcity->client.occupied) {
- *sprs++ = get_city_occupied_sprite(pcity);
+ ADD_SPRITE_SIMPLE(get_city_occupied_sprite(pcity));
}
- *sprs++ = get_city_sprite(pcity);
+ ADD_SPRITE_SIMPLE(get_city_sprite(pcity));
if (city_got_citywalls(pcity))
- *sprs++ = get_city_wall_sprite(pcity);
+ ADD_SPRITE_SIMPLE(get_city_wall_sprite(pcity));
if(map_has_special(pcity->x, pcity->y, S_POLLUTION))
- *sprs++ = sprites.tx.pollution;
+ ADD_SPRITE_SIMPLE(sprites.tx.pollution);
if(map_has_special(pcity->x, pcity->y, S_FALLOUT))
- *sprs++ = sprites.tx.fallout;
+ ADD_SPRITE_SIMPLE(sprites.tx.fallout);
if (pcity->client.unhappy) {
- *sprs++ = sprites.city.disorder;
+ ADD_SPRITE_SIMPLE(sprites.city.disorder);
}
if(tile_get_known(pcity->x, pcity->y) == TILE_KNOWN_FOGGED &&
draw_fog_of_war)
- *sprs++ = sprites.tx.fog;
+ ADD_SPRITE_SIMPLE(sprites.tx.fog);
/* Put the size sprites last, so that they are not obscured
* (and because they can be hard to read if fogged).
*/
if (pcity->size>=10)
- *sprs++ = sprites.city.size_tens[pcity->size/10];
+ ADD_SPRITE_SIMPLE(sprites.city.size_tens[pcity->size/10]);
- *sprs++ = sprites.city.size[pcity->size%10];
+ ADD_SPRITE_SIMPLE(sprites.city.size[pcity->size%10]);
return sprs - save_sprs;
}
@@ -1305,22 +1319,23 @@
Fill in the sprite array for the city
(small because things have to be done later in isometric view.)
***********************************************************************/
-int fill_city_sprite_array_iso(struct Sprite **sprs, struct city *pcity)
+int fill_city_sprite_array_iso(struct drawn_sprite *sprs, struct city *pcity)
{
- struct Sprite **save_sprs=sprs;
+ struct drawn_sprite *save_sprs = sprs;
if (!no_backdrop) {
- *sprs++ = get_city_nation_flag_sprite(pcity);
+ ADD_SPRITE(get_city_nation_flag_sprite(pcity),
+ flag_offset_x, flag_offset_y);
}
if (pcity->client.occupied) {
- *sprs++ = get_city_occupied_sprite(pcity);
+ ADD_SPRITE_SIMPLE(get_city_occupied_sprite(pcity));
}
- *sprs++ = get_city_sprite(pcity);
+ ADD_SPRITE_SIMPLE(get_city_sprite(pcity));
if (pcity->client.unhappy) {
- *sprs++ = sprites.city.disorder;
+ ADD_SPRITE_SIMPLE(sprites.city.disorder);
}
return sprs - save_sprs;
@@ -1379,28 +1394,30 @@
/**********************************************************************
Fill in the sprite array for the unit
***********************************************************************/
-int fill_unit_sprite_array(struct Sprite **sprs, struct unit *punit,
- bool *solid_bg)
+int fill_unit_sprite_array(struct drawn_sprite *sprs,
+ struct unit *punit, bool *solid_bg)
{
- struct Sprite **save_sprs=sprs;
+ struct drawn_sprite *save_sprs = sprs;
int ihp;
*solid_bg = FALSE;
if (is_isometric) {
if (!no_backdrop) {
- *sprs++ = get_unit_nation_flag_sprite(punit);
+ ADD_SPRITE(get_unit_nation_flag_sprite(punit),
+ flag_offset_x, flag_offset_y);
}
} else {
if (!no_backdrop) {
if (!solid_color_behind_units) {
- *sprs++ = get_unit_nation_flag_sprite(punit);
+ ADD_SPRITE(get_unit_nation_flag_sprite(punit),
+ flag_offset_x, flag_offset_y);
} else {
*solid_bg = TRUE;
}
}
}
- *sprs++ = unit_type(punit)->sprite;
+ ADD_SPRITE_SIMPLE(unit_type(punit)->sprite);
if(punit->activity!=ACTIVITY_IDLE) {
struct Sprite *s = NULL;
@@ -1452,28 +1469,28 @@
break;
}
- *sprs++ = s;
+ ADD_SPRITE_SIMPLE(s);
}
if (punit->ai.control && punit->activity != ACTIVITY_EXPLORE) {
if (is_military_unit(punit)) {
- *sprs++ = sprites.unit.auto_attack;
+ ADD_SPRITE_SIMPLE(sprites.unit.auto_attack);
} else {
- *sprs++ = sprites.unit.auto_settler;
+ ADD_SPRITE_SIMPLE(sprites.unit.auto_settler);
}
}
if (punit->connecting) {
- *sprs++ = sprites.unit.connect;
+ ADD_SPRITE_SIMPLE(sprites.unit.connect);
}
if (punit->activity == ACTIVITY_PATROL) {
- *sprs++ = sprites.unit.patrol;
+ ADD_SPRITE_SIMPLE(sprites.unit.patrol);
}
ihp = ((NUM_TILES_HP_BAR-1)*punit->hp) / unit_type(punit)->hp;
ihp = CLIP(0, ihp, NUM_TILES_HP_BAR-1);
- *sprs++ = sprites.unit.hp_bar[ihp];
+ ADD_SPRITE_SIMPLE(sprites.unit.hp_bar[ihp]);
return sprs - save_sprs;
}
@@ -1521,11 +1538,11 @@
/**************************************************************************
Add any corner road sprites to the sprite array.
**************************************************************************/
-static int fill_road_corner_sprites(struct Sprite **sprs,
+static int fill_road_corner_sprites(struct drawn_sprite *sprs,
bool road, bool *road_near,
bool rail, bool *rail_near)
{
- struct Sprite **saved_sprs = sprs;
+ struct drawn_sprite *saved_sprs = sprs;
assert(draw_roads_rails);
if (!(draw_diagonal_roads || is_isometric)) {
@@ -1550,28 +1567,28 @@
&& !(rail_near[DIR8_NORTH] && rail_near[DIR8_EAST]))
&& !(road && road_near[DIR8_NORTHEAST]
&& !(rail && rail_near[DIR8_NORTHEAST]))) {
- *sprs++ = sprites.road.corner[DIR8_NORTHEAST];
+ ADD_SPRITE_SIMPLE(sprites.road.corner[DIR8_NORTHEAST]);
}
if (sprites.road.corner[DIR8_NORTHWEST]
&& (road_near[DIR8_NORTH] && road_near[DIR8_WEST]
&& !(rail_near[DIR8_NORTH] && rail_near[DIR8_WEST]))
&& !(road && road_near[DIR8_NORTHWEST]
&& !(rail && rail_near[DIR8_NORTHWEST]))) {
- *sprs++ = sprites.road.corner[DIR8_NORTHWEST];
+ ADD_SPRITE_SIMPLE(sprites.road.corner[DIR8_NORTHWEST]);
}
if (sprites.road.corner[DIR8_SOUTHEAST]
&& (road_near[DIR8_SOUTH] && road_near[DIR8_EAST]
&& !(rail_near[DIR8_SOUTH] && rail_near[DIR8_EAST]))
&& !(road && road_near[DIR8_SOUTHEAST]
&& !(rail && rail_near[DIR8_SOUTHEAST]))) {
- *sprs++ = sprites.road.corner[DIR8_SOUTHEAST];
+ ADD_SPRITE_SIMPLE(sprites.road.corner[DIR8_SOUTHEAST]);
}
if (sprites.road.corner[DIR8_SOUTHWEST]
&& (road_near[DIR8_SOUTH] && road_near[DIR8_WEST]
&& !(rail_near[DIR8_SOUTH] && rail_near[DIR8_WEST]))
&& !(road && road_near[DIR8_SOUTHWEST]
&& !(rail && rail_near[DIR8_SOUTHWEST]))) {
- *sprs++ = sprites.road.corner[DIR8_SOUTHWEST];
+ ADD_SPRITE_SIMPLE(sprites.road.corner[DIR8_SOUTHWEST]);
}
return sprs - saved_sprs;
@@ -1580,10 +1597,10 @@
/**************************************************************************
Add any corner rail sprites to the sprite array.
**************************************************************************/
-static int fill_rail_corner_sprites(struct Sprite **sprs,
+static int fill_rail_corner_sprites(struct drawn_sprite *sprs,
bool rail, bool *rail_near)
{
- struct Sprite **saved_sprs = sprs;
+ struct drawn_sprite *saved_sprs = sprs;
assert(draw_roads_rails);
if (!(draw_diagonal_roads || is_isometric)) {
@@ -1598,22 +1615,22 @@
if (sprites.rail.corner[DIR8_NORTHEAST]
&& rail_near[DIR8_NORTH] && rail_near[DIR8_EAST]
&& !(rail && rail_near[DIR8_NORTHEAST])) {
- *sprs++ = sprites.rail.corner[DIR8_NORTHEAST];
+ ADD_SPRITE_SIMPLE(sprites.rail.corner[DIR8_NORTHEAST]);
}
if (sprites.rail.corner[DIR8_NORTHWEST]
&& rail_near[DIR8_NORTH] && rail_near[DIR8_WEST]
&& !(rail && rail_near[DIR8_NORTHWEST])) {
- *sprs++ = sprites.rail.corner[DIR8_NORTHWEST];
+ ADD_SPRITE_SIMPLE(sprites.rail.corner[DIR8_NORTHWEST]);
}
if (sprites.rail.corner[DIR8_SOUTHEAST]
&& rail_near[DIR8_SOUTH] && rail_near[DIR8_EAST]
&& !(rail && rail_near[DIR8_SOUTHEAST])) {
- *sprs++ = sprites.rail.corner[DIR8_SOUTHEAST];
+ ADD_SPRITE_SIMPLE(sprites.rail.corner[DIR8_SOUTHEAST]);
}
if (sprites.rail.corner[DIR8_SOUTHWEST]
&& rail_near[DIR8_SOUTH] && rail_near[DIR8_WEST]
&& !(rail && rail_near[DIR8_SOUTHWEST])) {
- *sprs++ = sprites.rail.corner[DIR8_SOUTHWEST];
+ ADD_SPRITE_SIMPLE(sprites.rail.corner[DIR8_SOUTHWEST]);
}
return sprs - saved_sprs;
@@ -1622,12 +1639,12 @@
/**************************************************************************
Fill all road and rail sprites into the sprite array.
**************************************************************************/
-static int fill_road_rail_sprite_array(struct Sprite **sprs,
+static int fill_road_rail_sprite_array(struct drawn_sprite *sprs,
enum tile_special_type tspecial,
enum tile_special_type *tspecial_near,
struct city *pcity)
{
- struct Sprite **saved_sprs = sprs;
+ struct drawn_sprite *saved_sprs = sprs;
bool road, road_near[8], rail, rail_near[8];
bool draw_road[8], draw_single_road, draw_rail[8], draw_single_rail;
enum direction8 dir;
@@ -1680,7 +1697,7 @@
if (road) {
for (dir = 0; dir < 8; dir++) {
if (draw_road[dir]) {
- *sprs++ = sprites.road.dir[dir];
+ ADD_SPRITE_SIMPLE(sprites.road.dir[dir]);
}
}
}
@@ -1689,7 +1706,7 @@
if (rail) {
for (dir = 0; dir < 8; dir++) {
if (draw_rail[dir]) {
- *sprs++ = sprites.rail.dir[dir];
+ ADD_SPRITE_SIMPLE(sprites.rail.dir[dir]);
}
}
}
@@ -1713,10 +1730,10 @@
/* Draw the cardinal roads first. */
if (road_cardinal_tileno != 0) {
- *sprs++ = sprites.road.cardinal[road_cardinal_tileno];
+ ADD_SPRITE_SIMPLE(sprites.road.cardinal[road_cardinal_tileno]);
}
if (road_diagonal_tileno != 0) {
- *sprs++ = sprites.road.diagonal[road_diagonal_tileno];
+ ADD_SPRITE_SIMPLE(sprites.road.diagonal[road_diagonal_tileno]);
}
}
@@ -1733,19 +1750,19 @@
/* Draw the cardinal rails first. */
if (rail_cardinal_tileno != 0) {
- *sprs++ = sprites.rail.cardinal[rail_cardinal_tileno];
+ ADD_SPRITE_SIMPLE(sprites.rail.cardinal[rail_cardinal_tileno]);
}
if (rail_diagonal_tileno != 0) {
- *sprs++ = sprites.rail.diagonal[rail_diagonal_tileno];
+ ADD_SPRITE_SIMPLE(sprites.rail.diagonal[rail_diagonal_tileno]);
}
}
}
/* Draw isolated rail/road separately (styles 0 and 1). */
if (draw_single_rail) {
- *sprs++ = sprites.rail.isolated;
+ ADD_SPRITE_SIMPLE(sprites.rail.isolated);
} else if (draw_single_road) {
- *sprs++ = sprites.road.isolated;
+ ADD_SPRITE_SIMPLE(sprites.road.isolated);
}
/* Draw rail corners over roads (styles 0 and 1). */
@@ -1777,12 +1794,12 @@
/**************************************************************************
Fill in the farmland/irrigation sprite for the tile.
**************************************************************************/
-static int fill_irrigation_sprite_array(struct Sprite **sprs,
+static int fill_irrigation_sprite_array(struct drawn_sprite *sprs,
enum tile_special_type tspecial,
enum tile_special_type *tspecial_near,
struct city *pcity)
{
- struct Sprite **saved_sprs = sprs;
+ struct drawn_sprite *saved_sprs = sprs;
/* Tiles with S_FARMLAND also have S_IRRIGATION set. */
assert(!contains_special(tspecial, S_FARMLAND)
@@ -1793,10 +1810,11 @@
if (draw_irrigation
&& contains_special(tspecial, S_IRRIGATION)
&& !(pcity && draw_cities)) {
+ int index = get_irrigation_index(tspecial_near);
if (contains_special(tspecial, S_FARMLAND)) {
- *sprs++ = sprites.tx.farmland[get_irrigation_index(tspecial_near)];
+ ADD_SPRITE_SIMPLE(sprites.tx.farmland[index]);
} else {
- *sprs++ = sprites.tx.irrigation[get_irrigation_index(tspecial_near)];
+ ADD_SPRITE_SIMPLE(sprites.tx.irrigation[index]);
}
}
@@ -1817,7 +1835,8 @@
4) mine
5) huts
***********************************************************************/
-int fill_tile_sprite_array_iso(struct Sprite **sprs, struct Sprite **coasts,
+int fill_tile_sprite_array_iso(struct drawn_sprite *sprs,
+ struct Sprite **coasts,
struct Sprite **dither,
int x, int y, bool citymode,
bool *solid_bg)
@@ -1826,7 +1845,7 @@
enum tile_special_type tspecial, tspecial_near[8];
int tileno, dir, i;
struct city *pcity;
- struct Sprite **save_sprs = sprs;
+ struct drawn_sprite *save_sprs = sprs;
*solid_bg = FALSE;
@@ -1843,10 +1862,10 @@
for (dir = 0; dir < 4; dir++) {
if (contains_special(tspecial_near[DIR4_TO_DIR8[dir]], S_RIVER))
- *sprs++ = sprites.tx.river_outlet[dir];
+ ADD_SPRITE_SIMPLE(sprites.tx.river_outlet[dir]);
}
} else {
- *sprs++ = get_tile_type(ttype)->sprite[0];
+ ADD_SPRITE_SIMPLE(get_tile_type(ttype)->sprite[0]);
switch (ttype) {
case T_HILLS:
@@ -1858,7 +1877,7 @@
ttype_near[DIR8_EAST]),
can_blend_hills_and_mountains(T_HILLS,
ttype_near[DIR8_WEST]));
- *sprs++ = sprites.tx.spec_hill[tileno];
+ ADD_SPRITE_SIMPLE(sprites.tx.spec_hill[tileno]);
break;
case T_FOREST:
@@ -1866,7 +1885,7 @@
ttype_near[DIR8_SOUTH] == T_FOREST,
ttype_near[DIR8_EAST] == T_FOREST,
ttype_near[DIR8_WEST] == T_FOREST);
- *sprs++ = sprites.tx.spec_forest[tileno];
+ ADD_SPRITE_SIMPLE(sprites.tx.spec_forest[tileno]);
break;
case T_MOUNTAINS:
@@ -1878,7 +1897,7 @@
ttype_near[DIR8_EAST]),
can_blend_hills_and_mountains(T_MOUNTAINS,
ttype_near[DIR8_WEST]));
- *sprs++ = sprites.tx.spec_mountain[tileno];
+ ADD_SPRITE_SIMPLE(sprites.tx.spec_mountain[tileno]);
break;
default:
@@ -1897,7 +1916,7 @@
|| is_ocean(ttype_near[DIR8_EAST]),
contains_special(tspecial_near[DIR8_WEST], S_RIVER)
|| is_ocean(ttype_near[DIR8_WEST]));
- *sprs++ = sprites.tx.spec_river[tileno];
+ ADD_SPRITE_SIMPLE(sprites.tx.spec_river[tileno]);
}
}
} else {
@@ -1932,9 +1951,9 @@
if (draw_specials) {
if (contains_special(tspecial, S_SPECIAL_1)) {
- *sprs++ = tile_types[ttype].special[0].sprite;
+ ADD_SPRITE_SIMPLE(tile_types[ttype].special[0].sprite);
} else if (contains_special(tspecial, S_SPECIAL_2)) {
- *sprs++ = tile_types[ttype].special[1].sprite;
+ ADD_SPRITE_SIMPLE(tile_types[ttype].special[1].sprite);
}
}
@@ -1944,31 +1963,31 @@
if (draw_specials) {
if (contains_special(tspecial, S_SPECIAL_1)) {
- *sprs++ = tile_types[ttype].special[0].sprite;
+ ADD_SPRITE_SIMPLE(tile_types[ttype].special[0].sprite);
} else if (contains_special(tspecial, S_SPECIAL_2)) {
- *sprs++ = tile_types[ttype].special[1].sprite;
+ ADD_SPRITE_SIMPLE(tile_types[ttype].special[1].sprite);
}
}
if (contains_special(tspecial, S_FORTRESS) && draw_fortress_airbase) {
- *sprs++ = sprites.tx.fortress_back;
+ ADD_SPRITE_SIMPLE(sprites.tx.fortress_back);
}
if (contains_special(tspecial, S_MINE) && draw_mines
&& (ttype == T_HILLS || ttype == T_MOUNTAINS)) {
/* Oil mines come later. */
- *sprs++ = sprites.tx.mine;
+ ADD_SPRITE_SIMPLE(sprites.tx.mine);
}
if (contains_special(tspecial, S_MINE) && draw_mines
&& ttype != T_HILLS && ttype != T_MOUNTAINS) {
/* Must be Glacier or Dessert. The mine sprite looks better on top
* of special. */
- *sprs++ = sprites.tx.oil_mine;
+ ADD_SPRITE_SIMPLE(sprites.tx.oil_mine);
}
if (contains_special(tspecial, S_HUT) && draw_specials)
- *sprs++ = sprites.tx.village;
+ ADD_SPRITE_SIMPLE(sprites.tx.village);
/* These are drawn later in isometric view (on top of city.)
if (contains_special(tspecial, S_POLLUTION)) *sprs++ =
sprites.tx.pollution;
@@ -2011,7 +2030,7 @@
11) fallout
12) FoW
***********************************************************************/
-int fill_tile_sprite_array(struct Sprite **sprs, int abs_x0, int abs_y0,
+int fill_tile_sprite_array(struct drawn_sprite *sprs, int abs_x0, int abs_y0,
bool citymode, bool *solid_bg,
struct player **pplayer)
{
@@ -2026,8 +2045,7 @@
struct unit *pfocus;
struct unit *punit;
int den_y=map.ysize*.24;
-
- struct Sprite **save_sprs=sprs;
+ struct drawn_sprite *save_sprs = sprs;
*solid_bg = FALSE;
*pplayer = NULL;
@@ -2046,12 +2064,12 @@
sprs += fill_unit_sprite_array(sprs, punit, solid_bg);
*pplayer = unit_owner(punit);
if (unit_list_size(&ptile->units) > 1)
- *sprs++ = sprites.unit.stack;
+ ADD_SPRITE_SIMPLE(sprites.unit.stack);
return sprs - save_sprs;
}
if (pcity && draw_cities) {
- sprs+=fill_city_sprite_array(sprs, pcity, solid_bg);
+ sprs += fill_city_sprite_array(sprs, pcity, solid_bg);
*pplayer = city_owner(pcity);
return sprs - save_sprs;
}
@@ -2078,7 +2096,7 @@
}
if (draw_terrain)
- *sprs++=mysprite;
+ ADD_SPRITE_SIMPLE(mysprite);
else
*solid_bg = TRUE;
@@ -2098,12 +2116,12 @@
&& is_ocean(ttype_near[DIR8_WEST])
&& !is_ocean(ttype_near[DIR8_NORTHWEST]));
if(tileno!=0)
- *sprs++ = sprites.tx.coast_cape[tileno];
+ ADD_SPRITE_SIMPLE(sprites.tx.coast_cape[tileno]);
for (dir = 0; dir < 4; dir++) {
if (contains_special(tspecial_near[DIR4_TO_DIR8[dir]], S_RIVER) ||
ttype_near[DIR4_TO_DIR8[dir]] == T_RIVER) {
- *sprs++ = sprites.tx.river_outlet[dir];
+ ADD_SPRITE_SIMPLE(sprites.tx.river_outlet[dir]);
}
}
}
@@ -2117,7 +2135,7 @@
|| is_ocean(ttype_near[DIR8_EAST]),
contains_special(tspecial_near[DIR8_WEST], S_RIVER)
|| is_ocean(ttype_near[DIR8_WEST]));
- *sprs++=sprites.tx.spec_river[tileno];
+ ADD_SPRITE_SIMPLE(sprites.tx.spec_river[tileno]);
}
sprs += fill_irrigation_sprite_array(sprs, tspecial, tspecial_near, pcity);
@@ -2125,25 +2143,35 @@
if(draw_specials) {
if (contains_special(tspecial, S_SPECIAL_1))
- *sprs++ = tile_types[ttype].special[0].sprite;
+ ADD_SPRITE_SIMPLE(tile_types[ttype].special[0].sprite);
else if (contains_special(tspecial, S_SPECIAL_2))
- *sprs++ = tile_types[ttype].special[1].sprite;
+ ADD_SPRITE_SIMPLE(tile_types[ttype].special[1].sprite);
}
if(contains_special(tspecial, S_MINE) && draw_mines) {
if(ttype==T_HILLS || ttype==T_MOUNTAINS)
- *sprs++ = sprites.tx.mine;
+ ADD_SPRITE_SIMPLE(sprites.tx.mine);
else /* desert */
- *sprs++ = sprites.tx.oil_mine;
+ ADD_SPRITE_SIMPLE(sprites.tx.oil_mine);
}
- if(contains_special(tspecial, S_HUT) && draw_specials) *sprs++ =
sprites.tx.village;
- if(contains_special(tspecial, S_FORTRESS) && draw_fortress_airbase) *sprs++
= sprites.tx.fortress;
- if(contains_special(tspecial, S_AIRBASE) && draw_fortress_airbase) *sprs++ =
sprites.tx.airbase;
- if(contains_special(tspecial, S_POLLUTION) && draw_pollution) *sprs++ =
sprites.tx.pollution;
- if(contains_special(tspecial, S_FALLOUT) && draw_pollution) *sprs++ =
sprites.tx.fallout;
- if(tile_get_known(abs_x0,abs_y0) == TILE_KNOWN_FOGGED && draw_fog_of_war)
- *sprs++ = sprites.tx.fog;
+ if (contains_special(tspecial, S_HUT) && draw_specials) {
+ ADD_SPRITE_SIMPLE(sprites.tx.village);
+ }
+ if (contains_special(tspecial, S_FORTRESS) && draw_fortress_airbase) {
+ ADD_SPRITE_SIMPLE(sprites.tx.fortress);
+ }
+ if (contains_special(tspecial, S_AIRBASE) && draw_fortress_airbase) {
+ ADD_SPRITE_SIMPLE(sprites.tx.airbase);
+ }
+ if (contains_special(tspecial, S_POLLUTION) && draw_pollution) {
+ ADD_SPRITE_SIMPLE(sprites.tx.pollution);
+ }
+ if (contains_special(tspecial, S_FALLOUT) && draw_pollution) {
+ ADD_SPRITE_SIMPLE(sprites.tx.fallout);
+ }
+ if (tile_get_known(abs_x0,abs_y0) == TILE_KNOWN_FOGGED && draw_fog_of_war)
+ ADD_SPRITE_SIMPLE(sprites.tx.fog);
if (!citymode) {
/*
@@ -2169,12 +2197,11 @@
!known[DIR4_EAST], !known[DIR4_WEST]);
if (tileno != 0)
- *sprs++ = sprites.tx.darkness[tileno];
+ ADD_SPRITE_SIMPLE(sprites.tx.darkness[tileno]);
}
if (pcity && draw_cities) {
bool dummy;
-
sprs += fill_city_sprite_array(sprs, pcity, &dummy);
}
@@ -2188,9 +2215,10 @@
no_backdrop = (pcity != NULL);
sprs += fill_unit_sprite_array(sprs, punit, &dummy);
+
no_backdrop = FALSE;
if (unit_list_size(&ptile->units) > 1) {
- *sprs++ = sprites.unit.stack;
+ ADD_SPRITE_SIMPLE(sprites.unit.stack);
}
}
}
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.46
diff -u -r1.46 tilespec.h
--- client/tilespec.h 2003/08/06 16:10:07 1.46
+++ client/tilespec.h 2003/08/07 14:39:53
@@ -28,6 +28,11 @@
struct unit;
struct player;
+struct drawn_sprite {
+ struct Sprite *sprite;
+ int offset_x, offset_y; /* offset from tile origin */
+};
+
const char **get_tileset_list(void);
void tilespec_read_toplevel(const char *tileset_name);
@@ -49,16 +54,18 @@
/* Gfx support */
-int fill_tile_sprite_array_iso(struct Sprite **sprs, struct Sprite **coasts,
+int fill_tile_sprite_array_iso(struct drawn_sprite *sprs,
+ struct Sprite **coasts,
struct Sprite **dither,
int x, int y, bool citymode,
bool *solid_bg);
-int fill_tile_sprite_array(struct Sprite **sprs, int abs_x0, int abs_y0,
+int fill_tile_sprite_array(struct drawn_sprite *sprs, int abs_x0, int abs_y0,
bool citymode, bool *solid_bg,
struct player **pplayer);
-int fill_unit_sprite_array(struct Sprite **sprs, struct unit *punit,
- bool *solid_bg);
-int fill_city_sprite_array_iso(struct Sprite **sprs, struct city *pcity);
+int fill_unit_sprite_array(struct drawn_sprite *sprs,
+ struct unit *punit, bool *solid_bg);
+int fill_city_sprite_array_iso(struct drawn_sprite *sprs,
+ struct city *pcity);
enum color_std player_color(struct player *pplayer);
enum color_std overview_tile_color(int x, int y);
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.179
diff -u -r1.179 mapview.c
--- client/gui-gtk/mapview.c 2003/08/06 16:10:07 1.179
+++ client/gui-gtk/mapview.c 2003/08/07 14:39:53
@@ -1302,6 +1302,25 @@
}
/**************************************************************************
+ Put a drawn sprite (with given offset) onto the pixmap.
+**************************************************************************/
+static void pixmap_put_drawn_sprite(GdkDrawable *pixmap,
+ int canvas_x, int canvas_y,
+ struct drawn_sprite *pdsprite,
+ int offset_x, int offset_y,
+ int width, int height,
+ bool fog)
+{
+ int ox = pdsprite->offset_x, oy = pdsprite->offset_y;
+
+ pixmap_put_overlay_tile_draw(pixmap, canvas_x + ox, canvas_y + oy,
+ pdsprite->sprite,
+ offset_x - ox, offset_y - oy,
+ width - ox, height - oy,
+ fog);
+}
+
+/**************************************************************************
Only used for isometric view.
**************************************************************************/
static void put_city_pixmap_draw(struct city *pcity, GdkPixmap *pm,
@@ -1310,16 +1329,15 @@
int width, int height_unit,
bool fog)
{
- struct Sprite *sprites[80];
+ struct drawn_sprite sprites[80];
int count = fill_city_sprite_array_iso(sprites, pcity);
int i;
for (i=0; i<count; i++) {
- if (sprites[i]) {
- pixmap_put_overlay_tile_draw(pm, canvas_x, canvas_y, sprites[i],
- offset_x, offset_y_unit,
- width, height_unit,
- fog);
+ if (sprites[i].sprite) {
+ pixmap_put_drawn_sprite(pm, canvas_x, canvas_y, &sprites[i],
+ offset_x, offset_y_unit, width, height_unit,
+ fog);
}
}
}
@@ -1429,7 +1447,7 @@
int width, int height, int height_unit,
enum draw_type draw)
{
- struct Sprite *tile_sprs[80];
+ struct drawn_sprite tile_sprs[80];
struct Sprite *coasts[4];
struct Sprite *dither[4];
struct city *pcity;
@@ -1527,8 +1545,8 @@
MAX(0, height-MAX(0, -dy)),
fog);
} else {
- pixmap_put_overlay_tile_draw(pm, canvas_x, canvas_y, tile_sprs[0],
- offset_x, offset_y, width, height, fog);
+ pixmap_put_drawn_sprite(pm, canvas_x, canvas_y, &tile_sprs[0],
+ offset_x, offset_y, width, height, fog);
i++;
}
@@ -1540,9 +1558,9 @@
/*** Rest of terrain and specials ***/
for (; i<count; i++) {
- if (tile_sprs[i])
- pixmap_put_overlay_tile_draw(pm, canvas_x, canvas_y, tile_sprs[i],
- offset_x, offset_y, width, height, fog);
+ if (tile_sprs[i].sprite)
+ pixmap_put_drawn_sprite(pm, canvas_x, canvas_y, &tile_sprs[i],
+ offset_x, offset_y, width, height, fog);
else
freelog(LOG_ERROR, "sprite is NULL");
}
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.73
diff -u -r1.73 mapview.c
--- client/gui-gtk-2.0/mapview.c 2003/08/06 16:10:08 1.73
+++ client/gui-gtk-2.0/mapview.c 2003/08/07 14:39:53
@@ -1385,6 +1385,25 @@
}
/**************************************************************************
+ Put a drawn sprite (with given offset) onto the pixmap.
+**************************************************************************/
+static void pixmap_put_drawn_sprite(GdkDrawable *pixmap,
+ int canvas_x, int canvas_y,
+ struct drawn_sprite *pdsprite,
+ int offset_x, int offset_y,
+ int width, int height,
+ bool fog)
+{
+ int ox = pdsprite->offset_x, oy = pdsprite->offset_y;
+
+ pixmap_put_overlay_tile_draw(pixmap, canvas_x + ox, canvas_y + oy,
+ pdsprite->sprite,
+ offset_x - ox, offset_y - oy,
+ width - ox, height - oy,
+ fog);
+}
+
+/**************************************************************************
Only used for isometric view.
**************************************************************************/
static void put_city_pixmap_draw(struct city *pcity, GdkPixmap *pm,
@@ -1393,16 +1412,15 @@
int width, int height_unit,
bool fog)
{
- struct Sprite *sprites[80];
+ struct drawn_sprite sprites[80];
int count = fill_city_sprite_array_iso(sprites, pcity);
int i;
for (i=0; i<count; i++) {
- if (sprites[i]) {
- pixmap_put_overlay_tile_draw(pm, canvas_x, canvas_y, sprites[i],
- offset_x, offset_y_unit,
- width, height_unit,
- fog);
+ if (sprites[i].sprite) {
+ pixmap_put_drawn_sprite(pm, canvas_x, canvas_y, &sprites[i],
+ offset_x, offset_y_unit, width, height_unit,
+ fog);
}
}
}
@@ -1512,7 +1530,7 @@
int width, int height, int height_unit,
enum draw_type draw)
{
- struct Sprite *tile_sprs[80];
+ struct drawn_sprite tile_sprs[80];
struct Sprite *coasts[4];
struct Sprite *dither[4];
struct city *pcity;
@@ -1610,8 +1628,8 @@
MAX(0, height-MAX(0, -dy)),
fog);
} else {
- pixmap_put_overlay_tile_draw(pm, canvas_x, canvas_y, tile_sprs[0],
- offset_x, offset_y, width, height, fog);
+ pixmap_put_drawn_sprite(pm, canvas_x, canvas_y, &tile_sprs[0],
+ offset_x, offset_y, width, height, fog);
i++;
}
@@ -1623,9 +1641,9 @@
/*** Rest of terrain and specials ***/
for (; i<count; i++) {
- if (tile_sprs[i])
- pixmap_put_overlay_tile_draw(pm, canvas_x, canvas_y, tile_sprs[i],
- offset_x, offset_y, width, height, fog);
+ if (tile_sprs[i].sprite)
+ pixmap_put_drawn_sprite(pm, canvas_x, canvas_y, &tile_sprs[i],
+ offset_x, offset_y, width, height, fog);
else
freelog(LOG_ERROR, "sprite is NULL");
}
Index: data/isotrident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident.tilespec,v
retrieving revision 1.8
diff -u -r1.8 isotrident.tilespec
--- data/isotrident.tilespec 2003/02/02 00:15:53 1.8
+++ data/isotrident.tilespec 2003/08/07 14:39:53
@@ -24,6 +24,10 @@
; Use roadstyle 0 (old iso style)
roadstyle = 0
+; offset the flags by this amount when drawing units
+flag_offset_x = 17
+flag_offset_y = 11
+
; Font to use to draw city names:
city_names_font = "9x15bold"
@@ -45,7 +49,7 @@
"isotrident/tiles.spec",
"isotrident/small.spec",
"isotrident/units.spec",
- "isotrident/flags.spec",
+ "trident/flags.spec",
"misc/buildings.spec",
"misc/space.spec",
; "misc/techs.spec",
|
|