… | |
… | |
15 | use Storable; |
15 | use Storable; |
16 | use List::Util qw(min max); |
16 | use List::Util qw(min max); |
17 | |
17 | |
18 | use Crossfire; |
18 | use Crossfire; |
19 | use Crossfire::MapWidget; |
19 | use Crossfire::MapWidget; |
|
|
20 | use File::Spec::Functions; |
20 | |
21 | |
21 | our @EXPORT = qw(insert_arch_stack_layer replace_arch_stack_layer new_arch_pb fill_pb_from_arch arch_is_floor stack_find_floor stack_find_wall stack_find arch_is_wall arch_is_monster add_table_widget quick_msg def); |
22 | our @EXPORT = qw(insert_arch_stack_layer replace_arch_stack_layer new_arch_pb fill_pb_from_arch arch_is_floor stack_find_floor stack_find_wall stack_find arch_is_wall arch_is_monster add_table_widget quick_msg def arch_is_exit map2abs); |
|
|
23 | |
|
|
24 | sub map2abs { |
|
|
25 | my ($dest, $mape) = @_; |
|
|
26 | |
|
|
27 | my $dir; |
|
|
28 | if (File::Spec->file_name_is_absolute($dest)) { |
|
|
29 | $dir = catdir ($Crossfire::LIB, 'maps', $dest); |
|
|
30 | } else { |
|
|
31 | my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); |
|
|
32 | $dir = File::Spec->rel2abs ($dest, File::Spec->catpath ($v, $p)); |
|
|
33 | } |
|
|
34 | return $dir; |
|
|
35 | } |
22 | |
36 | |
23 | sub def($$) { |
37 | sub def($$) { |
24 | return defined ($_[0]) ? $_[0] : $_[1]; |
38 | return defined ($_[0]) ? $_[0] : $_[1]; |
25 | } |
39 | } |
26 | |
40 | |
… | |
… | |
52 | my $pb = new Gtk2::Gdk::Pixbuf 'rgb', 1, 8, TILESIZE, TILESIZE; |
66 | my $pb = new Gtk2::Gdk::Pixbuf 'rgb', 1, 8, TILESIZE, TILESIZE; |
53 | return $pb; |
67 | return $pb; |
54 | } |
68 | } |
55 | |
69 | |
56 | sub fill_pb_from_arch { |
70 | sub fill_pb_from_arch { |
57 | my ($pb, $arch) = @_; |
71 | my ($pb, $a) = @_; |
|
|
72 | |
|
|
73 | my $o = $Crossfire::ARCH{$a->{_name}}; |
|
|
74 | my $face = $Crossfire::FACE{$a->{face} || $o->{face} || "blank.111"} |
|
|
75 | or warn "no gfx found for arch '$a->{_name}' at ($x|$y)\n"; |
|
|
76 | |
|
|
77 | $face or return; |
58 | |
78 | |
59 | $pb->fill (0x00000000); |
79 | $pb->fill (0x00000000); |
60 | $TILE->composite ($pb, |
80 | $TILE->composite ($pb, |
61 | 0, 0, |
81 | 0, 0, |
62 | TILESIZE, TILESIZE, |
82 | TILESIZE, TILESIZE, |
63 | - ($arch->{_face} % 64) * TILESIZE, - TILESIZE * int $arch->{_face} / 64, |
83 | - ($face->{idx} % 64) * TILESIZE, - TILESIZE * int $face->{idx} / 64, |
64 | 1, 1, 'nearest', 255 |
84 | 1, 1, 'nearest', 255 |
65 | ); |
85 | ); |
66 | } |
86 | } |
67 | |
87 | |
68 | sub classify_arch_layer { |
88 | sub classify_arch_layer { |
… | |
… | |
78 | |
98 | |
79 | } else { # $arch->{is_floor} and all other arches are 'between' monsters and floor |
99 | } else { # $arch->{is_floor} and all other arches are 'between' monsters and floor |
80 | |
100 | |
81 | return 'between'; |
101 | return 'between'; |
82 | } |
102 | } |
|
|
103 | } |
|
|
104 | |
|
|
105 | sub arch_is_exit { |
|
|
106 | my ($a) = @_; |
|
|
107 | my $type = $Crossfire::ARCH{$a->{_name}}->{type}; |
|
|
108 | return $type eq '66' || $type eq '41'; |
83 | } |
109 | } |
84 | |
110 | |
85 | sub arch_is_floor { |
111 | sub arch_is_floor { |
86 | my ($a) = @_; |
112 | my ($a) = @_; |
87 | return $Crossfire::ARCH{$a->{_name}}->{is_floor}; |
113 | return $Crossfire::ARCH{$a->{_name}}->{is_floor}; |