ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/item-worldmap.ext
(Generate patch)

Comparing deliantra/server/ext/item-worldmap.ext (file contents):
Revision 1.2 by root, Sat Jul 21 19:04:44 2007 UTC vs.
Revision 1.4 by root, Sun Jul 22 17:10:06 2007 UTC

1#! perl # depends=widget 1#! perl # depends=widget
2#! perl 2
3# this module implements a rather fancy worldmap
4
5our $WORLDMAP_UPDATE_INTERVAL = $cfg::CFG{worldmap_update_interval} || 10;
6
7cf::async_ext {
8 my $schedule_interval = Coro::Event->timer (after => 1);
9
10 while () {
11 $schedule_interval->interval ($WORLDMAP_UPDATE_INTERVAL);
12 $schedule_interval->next;
13 }
14};
3 15
4sub create_widgets { 16sub create_widgets {
5 my ($ns) = @_; 17 my ($ns) = @_;
6 18
7 my $info = { }; 19 my $info = { };
19 on_delete => sub { shift->hide }, 31 on_delete => sub { shift->hide },
20 ); 32 );
21 33
22 my $face = cf::face::find "res/worldmap.jpg"; 34 my $face = cf::face::find "res/worldmap.jpg";
23 $ns->send_face ($face); 35 $ns->send_face ($face);
36 $ns->flush_fx;
24 37
25 $w->add (my $sw = $ws->new (ScrolledWindow => scroll_x => 1, scroll_y => 1)); 38 $w->add (my $sw = $ws->new (ScrolledWindow => scroll_x => 1, scroll_y => 1));
26 $sw->add (my $canvas = $ws->new (Canvas => expand => 1)); 39 $sw->add (my $canvas = $ws->new (Canvas => expand => 1));
27 $canvas->add_fixed ($ws->new (Face => expand => 1, size_w => undef, size_h => undef, face => $face), abs => 0, 0, rel => 1, 1); 40 $canvas->add_fixed ($ws->new (Face => expand => 1, size_w => undef, size_h => undef, face => $face), abs => 0, 0, rel => 1, 1);
28 $canvas->add_fixed ($ws->new (Label => text => "lb1"), abs => 10, 10, rel => 1, 1); 41 $canvas->add_fixed ($ws->new (Label => text => "lb1"), abs => 10, 10, rel => 1, 1);
29 42
30 $info 43 $info
31} 44}
32 45
33# this module implements a rather fancy worldmap 46sub update_worldmap {
47 my ($ns) = @_;
48
49 my $ws = $ns->{ws_worldmap} or return;
50}
34 51
35cf::object::attachment item_worldmap => 52cf::object::attachment item_worldmap =>
36 on_apply => sub { 53 on_apply => sub {
37 my ($self, $who) = @_; 54 my ($self, $who) = @_;
38 55
39 my $ns = $who->contr->ns; 56 my $ns = $who->contr->ns;
40 57
41 if ($ns->{can_widget}) { 58 if ($ns->{can_widget}) {
42 my $ws = $ns->{ws_worldmap} ||= create_widgets $ns; 59 my $ws = $ns->{ws_worldmap} ||= create_widgets $ns;
43 $ws->{toplevel}->show; 60 $ws->{toplevel}->toggle_visibility;
61 $ws->{toplevel}->get (visible => sub {
62 update_worldmap $ns;
63 });
44 } else { 64 } else {
45 $ns->send_msg ("log", "Your client doesn't support the (required) widget extension. Try CFPlus at http://crossfire.schmorp.de/.", cf::NDI_RED); 65 $ns->send_msg ("log", "Your client doesn't support the (required) widget extension. Try CFPlus at http://crossfire.schmorp.de/.", cf::NDI_RED);
46 } 66 }
47 67
48 cf::override 1; 68 cf::override 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines