ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/item-worldmap.ext
Revision: 1.4
Committed: Sun Jul 22 17:10:06 2007 UTC (16 years, 10 months ago) by root
Branch: MAIN
Changes since 1.3: +22 -3 lines
Log Message:
fix mapinfo?

File Contents

# User Rev Content
1 root 1.1 #! perl # depends=widget
2 root 1.4
3     # this module implements a rather fancy worldmap
4    
5     our $WORLDMAP_UPDATE_INTERVAL = $cfg::CFG{worldmap_update_interval} || 10;
6    
7     cf::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     };
15 root 1.1
16     sub create_widgets {
17     my ($ns) = @_;
18    
19     my $info = { };
20    
21     $info->{ws} = my $ws = $ns->new_widgetset;
22    
23     $info->{toplevel} = my $w = $ws->new (Toplevel =>
24 root 1.2 title => "Worldmap",
25     name => "server_item_worldmap",
26 root 1.1 force_w => 400,
27     force_h => 400,
28     x => "center",
29     y => "center",
30     has_close_button => 1,
31     on_delete => sub { shift->hide },
32     );
33    
34     my $face = cf::face::find "res/worldmap.jpg";
35     $ns->send_face ($face);
36 root 1.3 $ns->flush_fx;
37 root 1.1
38     $w->add (my $sw = $ws->new (ScrolledWindow => scroll_x => 1, scroll_y => 1));
39 root 1.2 $sw->add (my $canvas = $ws->new (Canvas => expand => 1));
40     $canvas->add_fixed ($ws->new (Face => expand => 1, size_w => undef, size_h => undef, face => $face), abs => 0, 0, rel => 1, 1);
41     $canvas->add_fixed ($ws->new (Label => text => "lb1"), abs => 10, 10, rel => 1, 1);
42 root 1.1
43     $info
44     }
45    
46 root 1.4 sub update_worldmap {
47     my ($ns) = @_;
48    
49     my $ws = $ns->{ws_worldmap} or return;
50     }
51 root 1.1
52     cf::object::attachment item_worldmap =>
53     on_apply => sub {
54     my ($self, $who) = @_;
55    
56     my $ns = $who->contr->ns;
57    
58 root 1.2 if ($ns->{can_widget}) {
59     my $ws = $ns->{ws_worldmap} ||= create_widgets $ns;
60 root 1.4 $ws->{toplevel}->toggle_visibility;
61     $ws->{toplevel}->get (visible => sub {
62     update_worldmap $ns;
63     });
64 root 1.2 } else {
65     $ns->send_msg ("log", "Your client doesn't support the (required) widget extension. Try CFPlus at http://crossfire.schmorp.de/.", cf::NDI_RED);
66     }
67 root 1.1
68     cf::override 1;
69     },
70     ;
71