ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra/bin/cffi-filter
Revision: 1.1
Committed: Wed Oct 20 06:22:13 2010 UTC (13 years, 7 months ago) by root
Branch: MAIN
CVS Tags: rel-2_01, rel-2_0, HEAD
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/opt/bin/perl
2    
3     # deliantra faceinfo filter, needs to be run in the arch directory
4     # works a bit like a lint and creates a new default.faceinfo in the current directory
5     # works only after cfutil --install-arch --cache
6    
7     {
8     no utf8; # == values are utf-8 encoded
9    
10     our @WALL_SUFFIX = ("⬤⬤", "╹ ", " ╺", "┗━", "╻ ", "┃ ", "┏━", "┣━", "━╸", "┛ ", "━━", "┻━", "┓ ", "┫ ", "┳━", "╋━");
11    
12     # used to create crude text glyphs for text-based clients
13     sub autoglyph {
14     my ($stem, $face) = @_;
15    
16     if ($stem =~ /^wall\/|Nimwall/) {
17     return $WALL_SUFFIX[hex $1]
18     if $stem =~ /(_[0-9A-F]).x11/;
19    
20     "██"
21    
22     } elsif ($stem =~ /^traps\//) {
23     "☠ "
24    
25     } elsif ($stem =~ /^armour\/shield/) {
26     "Ø "
27    
28     } elsif ($stem =~ /^armour\//) {
29     "A "
30    
31     } elsif ($stem =~ /^weapon\//) {
32     "† "
33    
34     } elsif ($stem =~ /^readable\//) {
35     "✉ "
36    
37     } elsif ($stem =~ /^river\//) {
38     "~ "
39    
40     } elsif ($stem =~ /^^ground\/|Nimfloor/) {
41     "· "
42    
43     } elsif ($stem =~ /^floor\//) {
44     "░░"
45    
46     } elsif ($stem =~ /^spells\//) {
47     "! "
48    
49     } elsif ($stem =~ /^exit\//) {
50     "⎆⎆"
51    
52     } elsif ($stem =~ /^construct\//) {
53     "⌂⌂"
54    
55     } elsif ($stem =~ /^player\//) {
56     "\@"
57    
58     } elsif ($stem =~ /^misc.*\/(.)/) {
59     " $1"
60    
61     } elsif ($stem =~ /^(?:monster|misc|class|connect|gods|indoor|inorganic|mining|music|skills).*\/(.)/) {
62     (substr $stem, 0, 1) . uc $1
63    
64     } else {
65     substr $stem, 0, 1
66     }
67     }
68     }
69    
70     our %PNG;
71    
72     open my $fiin, "<:raw", "default.faceinfo"
73     or die "default.faceinfo: $!\n";
74    
75     # make an inventory of all faces
76     {
77     open my $ts, "-|:raw", "treescan -f */ | sort"
78     or die "treescan: $!";
79    
80     while (<$ts>) {
81     chomp;
82     if (/^(.*)\/([^\/]+\....).64x64.png~?$/) { # normal
83     $PNG{$2} = "$1/$2";
84     } elsif (/^(.*)\/([^\/]+\....).64x64.png~?(\+\d+\+\d+)~$/) { # split
85     $PNG{"$2$3"} = "$1/$2";
86     # delete $PNG{$2}; used for +0+0
87     }
88     }
89     }
90    
91     open my $fiout, "|-:raw", "sort | unexpand -a >default.faceinfo~"
92     or die "default.faceinfo~: $!";
93    
94     while (<$fiin>) {
95     my ($face, $visibility, $fg, $bg, $glyph) = split /\s+/;
96     (my $xf = $face) =~ s/\+\d+\+\d+$//;
97    
98     $fg =~ y/A-Z_\-/a-z/d;
99     $bg =~ y/A-Z_\-/a-z/d;
100    
101     my $stem = delete $PNG{$face};
102    
103     $glyph = "?" . autoglyph $stem, $v
104     if $glyph =~ /^\?./;
105    
106     printf $fiout
107     "%-39s %3d\t%-15s %-15s %s\n",
108     $face,
109     $visibility || 0,
110     $fg // "none",
111     $bg // "none",
112     $glyph;
113     }
114