summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/util/art-data.pl
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-26 23:10:17 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-26 23:10:17 +0000
commit3cc681e30ac236f7b88adece29f194cb30138ec8 (patch)
treebae782db4d02ab3f5914bde72af2f64411a965ae /crawl-ref/source/util/art-data.pl
parent00ceeefaaee699285172941fde8fb0da51aefa5a (diff)
downloadcrawl-ref-3cc681e30ac236f7b88adece29f194cb30138ec8.tar.gz
crawl-ref-3cc681e30ac236f7b88adece29f194cb30138ec8.zip
* Also allow definition of equipment tiles in art-data.txt.
* Rename some tiles and tile folders. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10054 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/util/art-data.pl')
-rwxr-xr-xcrawl-ref/source/util/art-data.pl135
1 files changed, 133 insertions, 2 deletions
diff --git a/crawl-ref/source/util/art-data.pl b/crawl-ref/source/util/art-data.pl
index afb8dd93f2..bbe4f68cdb 100755
--- a/crawl-ref/source/util/art-data.pl
+++ b/crawl-ref/source/util/art-data.pl
@@ -49,6 +49,7 @@ my %field_type = (
DESC_END => "str",
DESC_ID => "str",
TILE => "str",
+ TILE_EQ => "str",
TILERIM => "bool",
plus => "num",
@@ -650,7 +651,7 @@ sub write_tiles
if ($artefact->{TILE} eq "")
{
- print STDERR "No tile defined for '$artefact->{NAME}'\n";
+ print STDERR "No TILE defined for '$artefact->{NAME}'\n";
next;
}
@@ -700,6 +701,13 @@ sub write_tiles
}
}
+ print TILES << "HEADER_END";
+# This file is automatically generated from source/art-data.txt via
+# util/art-data.pl. Do not directly edit this file, but rather change
+# art-data.txt.
+
+HEADER_END
+
# Output the tile definitions sorted by type (and thus path).
foreach my $type (keys %art_by_type)
{
@@ -718,6 +726,101 @@ sub write_tiles
}
close(TILES);
+ my %parts;
+ foreach my $artefact (@all_artefacts)
+ {
+ next if ($artefact->{NAME} =~ /DUMMY/);
+ if (not(defined $artefact->{TILE_EQ}) || $artefact->{TILE_EQ} eq "")
+ {
+ if ($artefact->{base_type} ne "OBJ_JEWELLERY")
+ {
+ print STDERR "TILE_EQ not defined for '$artefact->{NAME}'\n";
+ }
+ next;
+ }
+
+ my $part = "BODY";
+ if ($artefact->{base_type} eq "OBJ_WEAPONS")
+ {
+ $part = "HAND1";
+ }
+ elsif ($artefact->{base_type} ne "OBJ_ARMOUR")
+ {
+ next;
+ }
+ elsif ($artefact->{sub_type} =~ /_SHIELD/
+ || $artefact->{sub_type} =~ /_BUCKLER/)
+ {
+ $part = "HAND2";
+ }
+ elsif ($artefact->{sub_type} =~ /_CLOAK/)
+ {
+ $part = "CLOAK";
+ }
+ elsif ($artefact->{sub_type} =~ /_CAP/
+ || $artefact->{sub_type} =~ /_HAT/)
+ {
+ $part = "HELM";
+ }
+ elsif ($artefact->{sub_type} =~ /_SHIELD/)
+ {
+ $part = "HAND2";
+ }
+ elsif ($artefact->{sub_type} =~ /_BOOTS/)
+ {
+ $part = "BOOTS";
+ }
+ elsif ($artefact->{sub_type} =~ /_GLOVES/)
+ {
+ $part = "ARM";
+ }
+
+ if (defined $parts{$part})
+ {
+ push @{$parts{$part}}, $artefact;
+ }
+ else
+ {
+ $parts{$part} = [$artefact];
+ }
+ }
+
+ $tilefile = "dc-player.txt";
+ unless (open(TILES, "<$tilefile"))
+ {
+ die "Couldn't open '$tilefile' for reading: $!\n";
+ }
+
+ my $curr_part = "";
+ my $content = <TILES>;
+ my @lines = split "\n", $content;
+ foreach my $line (@lines)
+ {
+ if ($line =~ /parts_ctg\s+(\S+)/)
+ {
+ $curr_part = $1;
+ next;
+ }
+ next if (not defined $parts{$curr_part});
+
+ if ($line =~ /^(\S+)\s+(\S+)/)
+ {
+ my $name = $1;
+ my $enum = $2;
+
+ foreach my $art (@{$parts{$curr_part}})
+ {
+ if ($art->{TILE_EQ} eq $name)
+ {
+ $art->{TILE_EQ_ENUM} = "TILEP_".$curr_part."_".$enum;
+ # Don't break from the loop in case several artefacts
+ # share the same tile.
+ }
+ }
+ }
+ }
+ close(TILES);
+
# Create tiledef-unrand.cc for the function unrandart_to_tile().
# Should we also create tiledef-unrand.h this way?
$tilefile = "tiledef-unrand.cc";
@@ -730,7 +833,11 @@ sub write_tiles
}
print TILES << "HEADER_END";
-// This file has been automatically generated.
+/*
+ * This file is automatically generated from source/art-data.txt via
+ * util/art-data.pl. Do not directly edit this file, but rather change
+ * art-data.txt.
+ */
#include "AppHdr.h"
#include "tiledef-unrand.h"
@@ -765,6 +872,30 @@ HEADER_END
print TILES (" " x 4) . "default: return -1;\n";
print TILES (" " x 4) . "}\n";
print TILES "}\n\n";
+
+ print TILES "int unrandart_to_doll_tile(int unrand)\n{\n";
+ print TILES (" " x 4) . "switch (unrand)\n";
+ print TILES (" " x 4) . "{\n";
+ foreach my $part (sort keys %parts)
+ {
+ print TILES (" " x 4) . "// $part\n";
+ foreach my $artefact (@{$parts{$part}})
+ {
+ if (not defined $artefact->{TILE_EQ_ENUM})
+ {
+ print STDERR "Tile '$artefact->{TILE_EQ}' for part '$part' not "
+ . "found in 'dc-player.txt'.\n";
+ next;
+ }
+ my $enum = "UNRAND_$artefact->{_ENUM}";
+ my $t_enum = $artefact->{TILE_EQ_ENUM};
+ print TILES (" " x 4) . "case $enum:"
+ . " " x ($longest_enum - length($enum) + 2) . "return $t_enum;\n";
+ }
+ }
+ print TILES (" " x 4) . "default: return -1;\n";
+ print TILES (" " x 4) . "}\n";
+ print TILES "}\n\n";
close(TILES);
}