ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Protocol.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Protocol.pm (file contents):
Revision 1.109 by root, Mon Jun 25 05:43:37 2007 UTC vs.
Revision 1.113 by root, Thu Jul 12 17:56:51 2007 UTC

21 21
22 my $self = $class->SUPER::new (%arg, 22 my $self = $class->SUPER::new (%arg,
23 setup_req => { 23 setup_req => {
24 extmap => 1, 24 extmap => 1,
25 excmd => 1, 25 excmd => 1,
26 xwidget => 1, 26 ywidget => 1,
27 %{$arg{setup_req} || {}}, 27 %{$arg{setup_req} || {}},
28 }, 28 },
29 ); 29 );
30 30
31 $self->{map_widget}->clr_commands; 31 $self->{map_widget}->clr_commands;
48 sort { (length $a) <=> (length $b) } 48 sort { (length $a) <=> (length $b) }
49 @args 49 @args
50 } sort { $a->{par} <=> $b->{par} } 50 } sort { $a->{par} <=> $b->{par} }
51 CFPlus::Pod::find command => "*"; 51 CFPlus::Pod::find command => "*";
52 52
53 $self->connect_ext (event_music => sub {
54 my ($ev) = @_;
55
56 return unless $::CFG->{bgm_enable};
57
58 my $faces = $ev->{faces};
59 my @songs;
60
61 # request music from server if appropriate
62 my $pri = -100;
63 for my $face (@$faces) {
64 if (defined (my $chksum = $ev->{chksum}{$face})) {
65 utf8::downgrade $chksum;
66
67 $chksum = unpack "H*", $chksum;
68 $self->{music_map}{$face} = $chksum;
69
70 ::message ({ markup => "starting to download song #$face, check your output-rate setting if your connection gets laggy." });
71 $self->ask_face ($face, $pri, undef, sub {
72 my $num = $_[0];
73 my $len = length $_[1];
74 my ($meta, $data) = unpack "(w/a*)*", $_[1];
75
76 CFPlus::DB::write_file $chksum, $data, sub { };
77 CFPlus::DB::put resmap => $chksum => $meta, sub { };
78
79 $self->{music_meta}{$chksum} = $self->{json_coder}->decode ($meta);
80 ::message ({ markup => "downloaded song #$face, size $len octets" });
81
82 &::audio_music_set ($self->{songs});
83 });
84 }
85
86 push @songs, $self->{music_map}{$face};
87 --$pri;
88 }
89
90 &::audio_music_set ($self->{songs} = \@songs);
91 });
92
53 $self->connect_ext (event_capabilities => sub { 93 $self->connect_ext (event_capabilities => sub {
54 my ($cap) = @_; 94 my ($cap) = @_;
55 95
56 if (my $ts = $cap->{tileset}) { 96 if (my $ts = $cap->{tileset}) {
57 if (my ($default) = grep $_->[2] & 1, @$ts) { 97 if (my ($default) = grep $_->[2] & 1, @$ts) {
65 $self->setup_req (mapsize => "${w}x${h}"); 105 $self->setup_req (mapsize => "${w}x${h}");
66 } 106 }
67 } 107 }
68 }); 108 });
69 109
110 $self->{json_coder}
111 ->convert_blessed
112 ->filter_json_single_key_object (__widget_ref__ => sub {
113 $self->{widget}{$_[0]}
114 });
115
70 $self->connect_ext (ws_n => sub { 116 $self->connect_ext (ws_n => sub {
71 my ($arg) = @_; 117 my ($arg) = @_;
72 118
73 $self->{widgetset}{$arg{id}} = { 119 $self->{widgetset}{$arg{id}} = {
74 w => {}, 120 w => {},
98 1 144 1
99 }; 145 };
100 } 146 }
101 147
102 if (my $widget = eval { 148 if (my $widget = eval {
149 local $SIG{__DIE__};
103 "CFPlus::UI::$arg->{class}"->new ( 150 "CFPlus::UI::$arg->{class}"->new (
104 %$args, 151 %$args,
105 s_ws => $arg->{ws}, 152 s_ws => $arg->{ws},
106 s_id => $arg->{id}, 153 s_id => $arg->{id},
107 ) 154 )
128 175
129 my $w = $self->{widget}{$arg->{id}} 176 my $w = $self->{widget}{$arg->{id}}
130 or return; 177 or return;
131 my $m = $arg->{name}; 178 my $m = $arg->{name};
132 179
133 my @a = map {
134 "HASH" eq ref && 1 == (scalar keys %$_) && exists $_->{__widget_ref__}
135 ? $self->{widget}{$_->{__widget_ref__}}
136 : $_
137 } @{ $arg->{args} || [] }; 180 my $a = $arg->{args} || [];
138 181
139 if (exists $arg->{rid}) { 182 if (exists $arg->{rid}) {
140 $self->send_exti_msg (w_r => rid => $arg->{rid}, res => [$w->$m (@a)]); 183 $self->send_exti_msg (w_r => rid => $arg->{rid}, res => [$w->$m (@$a)]);
141 } else { 184 } else {
142 $w->$m (@a); 185 $w->$m (@$a);
143 } 186 }
144 }); 187 });
145 188
146 $self->connect_ext (w_s => sub { 189 $self->connect_ext (w_s => sub {
147 my ($arg) = @_; 190 my ($arg) = @_;
1129 1172
1130 (delete $self->{npc_dialog})->destroy 1173 (delete $self->{npc_dialog})->destroy
1131 if $self->{npc_dialog}; 1174 if $self->{npc_dialog};
1132 1175
1133 $self->SUPER::destroy; 1176 $self->SUPER::destroy;
1177
1178 %$self = ();
1134} 1179}
1135 1180
1136package CFPlus::NPCDialog; 1181package CFPlus::NPCDialog;
1137 1182
1138our @ISA = 'CFPlus::UI::Toplevel'; 1183our @ISA = 'CFPlus::UI::Toplevel';

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines