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.226 by root, Thu Nov 15 03:07:46 2012 UTC vs.
Revision 1.227 by root, Tue Nov 20 14:32:12 2012 UTC

37 $self->update_fx_want; 37 $self->update_fx_want;
38 38
39 my $exp_guard = $self->addme_guard; 39 my $exp_guard = $self->addme_guard;
40 my $skl_guard = $self->addme_guard; 40 my $skl_guard = $self->addme_guard;
41 my $spl_guard = $self->addme_guard; 41 my $spl_guard = $self->addme_guard;
42 my $cmd_guard = $self->addme_guard;
43 $self->send_exti_req (resource => qw(exp_table skill_info spell_paths command_list), sub { 42 $self->send_exti_req (resource => qw(exp_table skill_info spell_paths), sub {
44 my ($exp, $skl, $spl, $cmd) = @_; 43 my ($exp, $skl, $spl) = @_;
45 44
46 $self->register_face_handler ($exp, sub { 45 $self->register_face_handler ($exp, sub {
47 my ($face) = @_; 46 my ($face) = @_;
48 47
49 undef $exp_guard; 48 undef $exp_guard;
65 undef $spl_guard; 64 undef $spl_guard;
66 my $info = $self->{json_coder}->decode (delete $face->{data}); 65 my $info = $self->{json_coder}->decode (delete $face->{data});
67 $self->{spell_paths} = { map { (1 << $_) => $info->[$_][0] } 0 .. $#$info }; 66 $self->{spell_paths} = { map { (1 << $_) => $info->[$_][0] } 0 .. $#$info };
68 }); 67 });
69 68
70 $self->register_face_handler ($cmd, sub {
71 my ($face) = @_;
72
73 undef $cmd_guard;
74 my $info = $self->{json_coder}->decode (delete $face->{data});
75 $self->{command_list} = [ sort map @{ $_->[1] }, grep $_->[0] != 2, @$info ];
76
77 });
78
79 () 69 ()
80 }); 70 });
81 71
82 $self->{map_widget}->clr_commands; 72 $::COMPLETER->reset;
83
84 my @cmd_help = map {
85 $_->[DC::Pod::N_KW][0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x
86 or die "unparseable command help: $_->[DC::Pod::N_KW][0]";
87
88 my $cmd = $1;
89 my @args = split /\|/, $2;
90 @args = (".*") unless @args;
91
92 my (undef, @par) = DC::Pod::section_of $_;
93 my $text = DC::Pod::as_label @par;
94
95 $_ = $_ eq ".*" ? "" : " $_"
96 for @args;
97
98 map ["$cmd$_", $text],
99 sort { (length $a) <=> (length $b) }
100 @args
101 } sort { $a->[DC::Pod::N_PAR] <=> $b->[DC::Pod::N_PAR] }
102 DC::Pod::find command => "*";
103 73
104 $self->{json_coder} 74 $self->{json_coder}
105 ->convert_blessed 75 ->convert_blessed
106 ->filter_json_single_key_object ("\fw" => sub { 76 ->filter_json_single_key_object ("\fw" => sub {
107 $self->{widget}{$_[0]} 77 $self->{widget}{$_[0]}
124 $::INV->clear; 94 $::INV->clear;
125 $::INVR->clear; 95 $::INVR->clear;
126 $::INVR_HB->clear; 96 $::INVR_HB->clear;
127 $::FLOORBOX->clear; 97 $::FLOORBOX->clear;
128 }); 98 });
129
130 $self->{map_widget}->add_command (@$_)
131 for @cmd_help;
132 99
133 { 100 {
134 $self->{dialogue} = my $tex = $TEX_DIALOGUE; 101 $self->{dialogue} = my $tex = $TEX_DIALOGUE;
135 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 102 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}});
136 } 103 }
194} 161}
195 162
196sub ext_ambient_music { 163sub ext_ambient_music {
197 my ($self, $songs) = @_; 164 my ($self, $songs) = @_;
198 &::audio_music_set_ambient ($songs); 165 &::audio_music_set_ambient ($songs);
166}
167
168sub ext_command_list {
169 my ($self, @faces) = @_;
170
171 my $handler = $self->{command_facehandler} = {};
172 my $commands = $::COMPLETER->{command_list} = {};
173
174 for my $idx (@faces) {
175 $handler->{$idx} = $self->register_face_handler ($idx, sub {
176 my ($face) = @_;
177
178 $commands->{$idx} =
179 $face->{cache} ||= $self->{json_coder}->decode ($face->{data});
180 });
181 }
199} 182}
200 183
201############################################################################# 184#############################################################################
202 185
203sub widget_associate { 186sub widget_associate {
1178 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g; 1161 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g;
1179 $spell->{message} =~ s/\n+$//; 1162 $spell->{message} =~ s/\n+$//;
1180 $spell->{message} ||= "Server did not provide a description for this spell."; 1163 $spell->{message} ||= "Server did not provide a description for this spell.";
1181 1164
1182 $::SPELL_LIST->add_spell ($spell); 1165 $::SPELL_LIST->add_spell ($spell);
1183 1166 delete $::COMPLETER->{command_list}{spells};
1184 $self->{map_widget}->add_command ("invoke $spell->{name}", DC::asxml $spell->{message});
1185 $self->{map_widget}->add_command ("cast $spell->{name}", DC::asxml $spell->{message});
1186} 1167}
1187 1168
1188sub spell_delete { 1169sub spell_delete {
1189 my ($self, $spell) = @_; 1170 my ($self, $spell) = @_;
1190 1171
1191 $::SPELL_LIST->remove_spell ($spell); 1172 $::SPELL_LIST->remove_spell ($spell);
1173 delete $::COMPLETER->{command_list}{spells};
1192} 1174}
1193 1175
1194sub setup { 1176sub setup {
1195 my ($self, $setup) = @_; 1177 my ($self, $setup) = @_;
1196 1178
1219} 1201}
1220 1202
1221sub eof { 1203sub eof {
1222 my ($self) = @_; 1204 my ($self) = @_;
1223 1205
1224 $self->{map_widget}->clr_commands; 1206 $::COMPLETER->reset;
1225 1207
1226 ::stop_game (); 1208 ::stop_game ();
1227} 1209}
1228 1210
1229sub update_floorbox { 1211sub update_floorbox {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines