git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6910 c06c8d41-db1a-0410-9941-cceddc491573
U4EZJ7TIJLEYKFYGH6T4MHHDTN3JTO4KGCI3BLZKDNVKV3TVHUUQC
3SQQ4MM6YO4I37CQ6GIBIX6BXAEVHNVNHPVMR3PPBBNO454D6XWQC
Q3B3UVMYEVC4YJUPYVSNTR4DJH4E6J4JJDHZNT5LNOCHCPPMEMXAC
HBXWZNXAJ7LUX7FYUIHQYBTRMWVJC6CAQQL3NNZHK5ETLIFEZJ7QC
25CH7HH4LKXFIZ75YNMXS3TSXO6O27DYSOPLOD45K4OCNFWLS4LQC
7G4KWTOOBRLHOZZGFGAXGTUCDF3FGSZOXVHUZZ3V2KVWYSFE7EKAC
U6ILMKBXTQZYT62IGD2CALYNU4VQGRSTHN6QBFBU7BVUBHWYOEQQC
HWYCA6OHOSVFTVIEDSNB2UJG6EQ2Y7FF5DWCKWAUSDUEVKAJADPAC
M27JU3PI7UXV4S4LTHOCGVASHX2RBXL5ZU4MLFWCQCSMGQC53IAAC
HRAL36C7UUL7V6TFXQ76FZ3VVVFEJYF7YWOP2EXYXP6C27XME2PAC
LDBTCT5WIPLJPZWXS2RUQ26QKISCUUTLO77M464WOE6VSYSNPKYAC
F7X6HVUKHZXYURABYAZJHRYBV7UZTIPOWJMGCMDK26FQ66WGKFZAC
O6ZMFKDI3XO2SWPNEYHIPYFDWJR4TVDP5BAATK6LVCVETQID6E7AC
5HRXXWHM5JHDZBCSUD65GYSQIFRD77DYV5PDAJZU4JTE4ZPH3LQAC
RB4PNFZOBEPUJM6PH4J4IPKF2WYYSQ2DINHZHOGDPA4ZN6E4RJAAC
OCGSM3TA4KYVM4JXHTHPA2SLY7EF6NPSIU4LJDRSQ2PJ6X7BP6CQC
OTVV4KBC5LVECK5B2Y7ORMRV7K4OXRZMYPCAMWJCUGZCQIBVRTXQC
success &= _copy_under(pixels, width, height, tile0, tile1);
}
for (int i = RING_FIRST_RING; i < NUM_RINGS; i++)
{
int special = you.item_description[IDESC_RINGS][i];
int tile0 = TILE_RING_NORMAL_OFFSET + special % 13;
int tile1 = TILE_RING_REGENERATION + i - RING_FIRST_RING;
success &= _copy_under(pixels, width, height, tile0, tile1, -5, -6);
}
for (int i = AMU_FIRST_AMULET; i < NUM_JEWELLERY; i++)
{
int special = you.item_description[IDESC_RINGS][i];
int tile0 = TILE_AMU_NORMAL_OFFSET + special % 13;
int tile1 = TILE_AMU_RAGE + i - AMU_FIRST_AMULET;
static int _tileidx_monster_base(const monsters* mon, bool detected)
// Special case for *taurs which have a different tile
// for when they have a bow.
static int _bow_offset(const monsters *mon)
{
int mon_wep = mon->inv[MSLOT_WEAPON];
if (mon_wep == NON_ITEM)
return 1;
switch (mitm[mon_wep].sub_type)
{
case WPN_BOW:
case WPN_LONGBOW:
case WPN_CROSSBOW:
case WPN_HAND_CROSSBOW:
return 0;
default:
return 1;
}
}
static int _tileidx_monster_base(const monsters *mon, bool detected)
static const int etable[4][4] = {
{0, 0, 0, 0}, // No ego tile
{0, 1, 1, 1}, // One ego tile
{0, 1, 1, 2}, // Two ego tile
{0, 1, 2, 3}
static const int etable[5][5] =
{
{0, 0, 0, 0, 0},
{0, 1, 1, 1, 1},
{0, 1, 1, 1, 2},
{0, 1, 1, 2, 3},
{0, 1, 2, 3, 4}
case WPN_FALCHION:
return TILE_WPN_FALCHION;
case WPN_KATANA:
return TILE_WPN_KATANA + etable[1][etype];
case WPN_QUICK_BLADE: return TILE_WPN_QUICK_BLADE;
case WPN_SABRE: return TILE_WPN_SABRE;
case WPN_FALCHION: return TILE_WPN_FALCHION;
case WPN_KATANA: return TILE_WPN_KATANA;
int etype = _get_etype(item);
static const int etable[5][5] = {
{0, 0, 0, 0, 0}, // No ego tile
{0, 1, 1, 1, 1}, // One ego tile
{0, 1, 1, 1, 2}, // Two ego tile
{0, 1, 1, 2, 3},
{0, 1, 2, 3, 4}
};
#include <png.h>
static bool write_png(const char *filename, tile_colour *pixels,
int width, int height)
{
FILE *fp = fopen(filename, "wb");
if (!fp)
{
fprintf(stderr, "Error: Can't open file '%s' for write.\n", filename);
return false;
}
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
NULL, NULL, NULL);
if (!png_ptr)
return false;
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
return false;
}
png_init_io(png_ptr, fp);
int bit_depth = 8;
int colour_type = PNG_COLOR_TYPE_RGB_ALPHA;
int interlace_type = PNG_INTERLACE_NONE;
int compression_type = PNG_COMPRESSION_TYPE_DEFAULT;
int filter_method = PNG_FILTER_TYPE_DEFAULT;
png_set_IHDR(png_ptr, info_ptr, width, height,
bit_depth, colour_type, interlace_type,
compression_type, filter_method);
png_bytep* row_pointers = (png_bytep*)malloc(sizeof(png_bytep) * height);
for (unsigned int y = 0; y < height; y++)
row_pointers[y] = (png_byte*)&pixels[y * width];
png_set_rows(png_ptr, info_ptr, row_pointers);
int png_transforms = PNG_TRANSFORM_IDENTITY;
png_write_png(png_ptr, info_ptr, png_transforms, NULL);
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
free(row_pointers);
fclose(fp);
return true;
}
#include <stdio.h>
#include <string.h>
// This is a standalone utility to convert old-style palettized BMPs
// to transparent PNGs.
#include "tile.h"
int main(int argc, char **argv)
{
if (argc < 2)
{
printf("Usage: %s (filename.bmp)\n", argv[0]);
return -1;
}
char dest[1024];
strcpy(dest, argv[1]);
size_t len = strlen(dest);
if (strcmp(&dest[len-4], ".bmp"))
{
printf("File '%s' does not end in bmp.\n", argv[1]);
return -2;
}
dest[len-3] = 'p';
dest[len-2] = 'n';
dest[len-1] = 'g';
tile conv;
if (!conv.load(argv[1]))
{
printf("Failed to load '%s'.\n", argv[1]);
return -3;
}
conv.replace_colour(tile_colour::background, tile_colour::transparent);
if (!write_png(dest, &conv.get_pixel(0,0), conv.width(), conv.height()))
{
printf("Failed to write dest '%s'.\n", dest);
return -4;
}
printf("Converted '%s'.\n", argv[1]);
return 0;
}
bool write_png(const char *filename, tile_colour *pixels,
int width, int height)
{
FILE *fp = fopen(filename, "wb");
if (!fp)
{
fprintf(stderr, "Error: Can't open file '%s' for write.\n", filename);
return false;
}
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
NULL, NULL, NULL);
if (!png_ptr)
return false;
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
return false;
}
png_init_io(png_ptr, fp);
int bit_depth = 8;
int colour_type = PNG_COLOR_TYPE_RGB_ALPHA;
int interlace_type = PNG_INTERLACE_NONE;
int compression_type = PNG_COMPRESSION_TYPE_DEFAULT;
int filter_method = PNG_FILTER_TYPE_DEFAULT;
png_set_IHDR(png_ptr, info_ptr, width, height,
bit_depth, colour_type, interlace_type,
compression_type, filter_method);
png_bytep* row_pointers = (png_bytep*)malloc(sizeof(png_bytep) * height);
for (unsigned int y = 0; y < height; y++)
row_pointers[y] = (png_byte*)&pixels[y * width];
png_set_rows(png_ptr, info_ptr, row_pointers);
int png_transforms = PNG_TRANSFORM_IDENTITY;
png_write_png(png_ptr, info_ptr, png_transforms, NULL);
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
free(row_pointers);
fclose(fp);
return true;
}
# A note on variations. To create additional variations for weapons or armour,
# simply create 1-5 images, e.g.:
#
# weapon_normal WEP_SOME_WEAPON
# weapon_shiny
# weapon_runed
# weapon_glowing
# weapon_randart
#
# If only the first line has a define on it, then the following images will be
# considered as variations. If you don't have five, images will be reused for
# multiple types. Orcish/elven/dwarven equipment are considered separate items
# with respect to variations and will not share variations with the base
# equipment. See tilepick.cc for more details.
#########ID-ed
%rim 0
%shrink 0
i-regeneration RING_REGENERATION
i-protection RING_PROTECTION
i-r-fire RING_PROTECTION_FROM_FIRE
i-r-poison RING_POISON_RESISTANCE
i-r-cold RING_PROTECTION_FROM_COLD
i-str RING_STRENGTH
i-slaying RING_SLAYING
i-see-invis RING_SEE_INVISIBLE
i-invisibility RING_INVISIBILITY
i-hunger RING_HUNGER
i-teleport RING_TELEPORTATION
i-evasion RING_EVASION
i-s-abil RING_SUSTAIN_ABILITIES
i-sustenance RING_SUSTENANCE
i-dex RING_DEXTERITY
i-int RING_INTELLIGENCE
i-wizardry RING_WIZARDRY
i-magical-power RING_MAGICAL_POWER
i-levitation RING_LEVITATION
i-life-protection RING_LIFE_PROTECTION
i-r-magic RING_PROTECTION_FROM_MAGIC
i-fire RING_FIRE
i-ice RING_ICE
i-c-teleport RING_TELEPORT_CONTROL
%rim 1
%shrink 1
%rim 0
%shrink 0
### ID-ed amulet
i-rage AMU_RAGE
i-r-slow AMU_RESIST_SLOW
i-clarity AMU_CLARITY
i-warding AMU_WARDING
i-r-corrosion AMU_RESIST_CORROSION
i-gourmand AMU_THE_GOURMAND
i-conservation AMU_CONSERVATION
i-c-flight AMU_CONTROLLED_FLIGHT
i-inaccuracy AMU_INACCURACY
i-r-mutation AMU_RESIST_MUTATION
%rim 1
%shrink 1