… | |
… | |
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 | |
20 | |
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); |
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); |
22 | |
22 | |
23 | sub new_arch_pb { |
23 | sub new_arch_pb { |
24 | # this is awful, is this really the best way? |
24 | # this is awful, is this really the best way? |
25 | my $pb = new Gtk2::Gdk::Pixbuf 'rgb', 1, 8, TILESIZE, TILESIZE; |
25 | my $pb = new Gtk2::Gdk::Pixbuf 'rgb', 1, 8, TILESIZE, TILESIZE; |
26 | return $pb; |
26 | return $pb; |
… | |
… | |
162 | } |
162 | } |
163 | |
163 | |
164 | return \@outstack; |
164 | return \@outstack; |
165 | } |
165 | } |
166 | |
166 | |
|
|
167 | sub add_table_widget { |
|
|
168 | my ($table, $row, $data, $type, $cb) = @_; |
|
|
169 | my $edwid; |
|
|
170 | |
|
|
171 | if ($type eq 'string') { |
|
|
172 | $table->attach_defaults (my $lbl = Gtk2::Label->new ($data->[0]), 0, 1, $row, $row + 1); |
|
|
173 | $edwid = Gtk2::Entry->new; |
|
|
174 | $edwid->set_text ($data->[1]); |
|
|
175 | $edwid->signal_connect (changed => sub { |
|
|
176 | $data->[1] = $_[0]->get_text; |
|
|
177 | $cb->($data->[1]) if $cb; |
|
|
178 | }); |
|
|
179 | $table->attach_defaults ($edwid, 1, 2, $row, $row + 1); |
|
|
180 | |
|
|
181 | } elsif ($type eq 'button') { |
|
|
182 | $table->attach_defaults (my $b = Gtk2::Button->new_with_label ($data), 0, 2, $row, $row + 1); |
|
|
183 | $b->signal_connect (clicked => ($cb || sub {})); |
|
|
184 | |
|
|
185 | } elsif ($type eq 'label') { |
|
|
186 | $table->attach_defaults (my $lbl = Gtk2::Label->new ($data->[0]), 0, 1, $row, $row + 1); |
|
|
187 | $edwid = Gtk2::Label->new ($data->[1]); |
|
|
188 | $table->attach_defaults ($edwid, 1, 2, $row, $row + 1); |
|
|
189 | |
|
|
190 | } else { |
|
|
191 | $edwid = Gtk2::Label->new ("FOO"); |
|
|
192 | } |
|
|
193 | } |
|
|
194 | |
167 | sub replace_arch_stack_layer { |
195 | sub replace_arch_stack_layer { |
168 | my ($stack, $arch) = @_; |
196 | my ($stack, $arch) = @_; |
169 | |
197 | |
170 | my @outstack; |
198 | my @outstack; |
171 | |
199 | |