| 1 |
root |
1.1 |
#! perl # depends=widget |
| 2 |
|
|
#! perl |
| 3 |
|
|
|
| 4 |
|
|
sub create_widgets { |
| 5 |
|
|
my ($ns) = @_; |
| 6 |
|
|
|
| 7 |
|
|
my $info = { }; |
| 8 |
|
|
|
| 9 |
|
|
$info->{ws} = my $ws = $ns->new_widgetset; |
| 10 |
|
|
|
| 11 |
|
|
$info->{toplevel} = my $w = $ws->new (Toplevel => |
| 12 |
root |
1.2 |
title => "Worldmap", |
| 13 |
|
|
name => "server_item_worldmap", |
| 14 |
root |
1.1 |
force_w => 400, |
| 15 |
|
|
force_h => 400, |
| 16 |
|
|
x => "center", |
| 17 |
|
|
y => "center", |
| 18 |
|
|
has_close_button => 1, |
| 19 |
|
|
on_delete => sub { shift->hide }, |
| 20 |
|
|
); |
| 21 |
|
|
|
| 22 |
|
|
my $face = cf::face::find "res/worldmap.jpg"; |
| 23 |
|
|
$ns->send_face ($face); |
| 24 |
root |
1.3 |
$ns->flush_fx; |
| 25 |
root |
1.1 |
|
| 26 |
|
|
$w->add (my $sw = $ws->new (ScrolledWindow => scroll_x => 1, scroll_y => 1)); |
| 27 |
root |
1.2 |
$sw->add (my $canvas = $ws->new (Canvas => expand => 1)); |
| 28 |
|
|
$canvas->add_fixed ($ws->new (Face => expand => 1, size_w => undef, size_h => undef, face => $face), abs => 0, 0, rel => 1, 1); |
| 29 |
|
|
$canvas->add_fixed ($ws->new (Label => text => "lb1"), abs => 10, 10, rel => 1, 1); |
| 30 |
root |
1.1 |
|
| 31 |
|
|
$info |
| 32 |
|
|
} |
| 33 |
|
|
|
| 34 |
|
|
# this module implements a rather fancy worldmap |
| 35 |
|
|
|
| 36 |
|
|
cf::object::attachment item_worldmap => |
| 37 |
|
|
on_apply => sub { |
| 38 |
|
|
my ($self, $who) = @_; |
| 39 |
|
|
|
| 40 |
|
|
my $ns = $who->contr->ns; |
| 41 |
|
|
|
| 42 |
root |
1.2 |
if ($ns->{can_widget}) { |
| 43 |
|
|
my $ws = $ns->{ws_worldmap} ||= create_widgets $ns; |
| 44 |
|
|
$ws->{toplevel}->show; |
| 45 |
|
|
} else { |
| 46 |
|
|
$ns->send_msg ("log", "Your client doesn't support the (required) widget extension. Try CFPlus at http://crossfire.schmorp.de/.", cf::NDI_RED); |
| 47 |
|
|
} |
| 48 |
root |
1.1 |
|
| 49 |
|
|
cf::override 1; |
| 50 |
|
|
}, |
| 51 |
|
|
; |
| 52 |
|
|
|