… | |
… | |
209 | $self->{tip}->remove ($self->{tip}->get_children) |
209 | $self->{tip}->remove ($self->{tip}->get_children) |
210 | if $self->{tip}->get_children; |
210 | if $self->{tip}->get_children; |
211 | |
211 | |
212 | $self->{tip}->add (my $frame = new Gtk2::Frame "($x|$y)"); |
212 | $self->{tip}->add (my $frame = new Gtk2::Frame "($x|$y)"); |
213 | |
213 | |
214 | $frame->set_shadow_type ("none"); |
214 | # $frame->set_shadow_type ("none"); |
215 | |
215 | |
216 | if ($x < 0 || $x >= $self->{map}{width} |
216 | if ($x < 0 || $x >= $self->{map}{width} |
217 | || $y < 0 || $y >= $self->{map}{height}) { |
217 | || $y < 0 || $y >= $self->{map}{height}) { |
218 | $frame->add (new Gtk2::Label "<off-map>"); |
218 | $frame->add (new Gtk2::Label "<off-map>"); |
219 | } else { |
219 | } else { |
220 | $frame->add (my $vbox = new Gtk2::VBox 1, 2); |
220 | $frame->add (my $vbox = new Gtk2::VBox 1, 1); |
221 | |
221 | |
222 | #TODO: fill tooltip via signal, defaulting to this: |
222 | #TODO: fill tooltip via signal, defaulting to this: |
223 | |
223 | |
224 | # fill tooltip with info about $x, $y |
224 | # fill tooltip with info about $x, $y |
225 | my $as = $self->{map}{map}[$x][$y] || []; |
225 | my $as = $self->{map}{map}[$x][$y] || []; |
226 | for my $a (@$as) { |
226 | for my $a (@$as) { |
|
|
227 | $vbox->add (my $hbox = new Gtk2::HBox 0, 2); |
|
|
228 | |
|
|
229 | my $tile = $Crossfire::Tilecache::TILECACHE{ $a->{face} || $ARCH->{$a->{_name}}{face} }; |
|
|
230 | |
|
|
231 | # this is awful, is this really the best way? |
|
|
232 | my $pb = new Gtk2::Gdk::Pixbuf 'rgb', 1, 8, TILESIZE, TILESIZE; |
|
|
233 | $pb->fill (0x00000000); |
|
|
234 | |
|
|
235 | $Crossfire::Tilecache::TILECACHE->composite ($pb, |
|
|
236 | 0, 0, |
|
|
237 | TILESIZE, TILESIZE, |
|
|
238 | - ($tile->{idx} % 64) * TILESIZE, - TILESIZE * int $tile->{idx} / 64, |
|
|
239 | 1, 1, 'nearest', 255 |
|
|
240 | ); |
|
|
241 | |
|
|
242 | $hbox->add (my $img = new_from_pixbuf Gtk2::Image $pb); |
|
|
243 | $img->set_alignment (0, 0.5); |
|
|
244 | |
227 | $vbox->add (my $label = new Gtk2::Label $a->{_name}); |
245 | $hbox->add (my $label = new Gtk2::Label $a->{_name}); |
228 | $label->set_alignment (0, 0.5); |
246 | $label->set_alignment (0, 0.5); |
229 | } |
247 | } |
230 | } |
248 | } |
231 | } |
249 | } |
232 | |
250 | |