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.86 by root, Sun Oct 8 21:22:30 2006 UTC vs.
Revision 1.92 by root, Sat Dec 9 21:26:46 2006 UTC

6use Crossfire::Protocol::Constants; 6use Crossfire::Protocol::Constants;
7 7
8use CFPlus; 8use CFPlus;
9use CFPlus::UI; 9use CFPlus::UI;
10use CFPlus::Pod; 10use CFPlus::Pod;
11use CFPlus::Macro;
12use CFPlus::Item;
13
14use Crossfire::Protocol::Base 0.95;
11 15
12use base 'Crossfire::Protocol::Base'; 16use base 'Crossfire::Protocol::Base';
13 17
14sub new { 18sub new {
15 my $class = shift; 19 my $class = shift;
286 if ($ev->{button} == 1) { 290 if ($ev->{button} == 1) {
287 $::CONN->user_send ("ready_skill $name"); 291 $::CONN->user_send ("ready_skill $name");
288 } elsif ($ev->{button} == 2) { 292 } elsif ($ev->{button} == 2) {
289 $::CONN->user_send ("use_skill $name"); 293 $::CONN->user_send ("use_skill $name");
290 } elsif ($ev->{button} == 3) { 294 } elsif ($ev->{button} == 3) {
295 my $shortname = CFPlus::shorten $name, 14;
291 (new CFPlus::UI::Menu 296 (new CFPlus::UI::Menu
292 items => [ 297 items => [
293 ["bind <i>ready_skill $name</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["ready_skill $name"]) }], 298 ["bind <i>ready_skill $shortname</i> to a key" => sub { CFPlus::Macro::quick_macro ["ready_skill $name"] }],
294 ["bind <i>use_skill $name</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["use_skill $name"]) }], 299 ["bind <i>use_skill $shortname</i> to a key" => sub { CFPlus::Macro::quick_macro ["use_skill $name"] }],
295 ], 300 ],
296 )->popup ($ev); 301 )->popup ($ev);
297 } else { 302 } else {
298 return 0; 303 return 0;
299 } 304 }
316 $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1])); 321 $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1]));
317 $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1); 322 $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1);
318 } 323 }
319} 324}
320 325
326sub macro_send {
327 my ($self, $macro) = @_;
328
329 for my $cmd (@{ $macro->{action} }) {
330 $self->send_command ($cmd);
331 }
332}
333
321sub user_send { 334sub user_send {
322 my ($self, $command) = @_; 335 my ($self, $command) = @_;
323 336
337 $self->{record}->($command)
324 if ($self->{record}) { 338 if $self->{record};
325 push @{$self->{record}}, $command;
326 }
327 339
328 $self->logprint ("send: ", $command); 340 $self->logprint ("send: ", $command);
329 $self->send_command ($command); 341 $self->send_command ($command);
330 ::status ($command); 342 ::status ($command);
331} 343}
332 344
333sub start_record { 345sub record {
334 my ($self) = @_; 346 my ($self, $cb) = @_;
335 347
336 $self->{record} = []; 348 $self->{record} = $cb;
337}
338
339sub stop_record {
340 my ($self) = @_;
341 return delete $self->{record};
342} 349}
343 350
344sub map_scroll { 351sub map_scroll {
345 my ($self, $dx, $dy) = @_; 352 my ($self, $dx, $dy) = @_;
346 353
655 # try to create single paragraphs out of the multiple lines sent by the server 662 # try to create single paragraphs out of the multiple lines sent by the server
656 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g; 663 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g;
657 $spell->{message} =~ s/\n+$//; 664 $spell->{message} =~ s/\n+$//;
658 $spell->{message} ||= "Server did not provide a description for this spell."; 665 $spell->{message} ||= "Server did not provide a description for this spell.";
659 666
660 $::SPELL_PAGE->add_spell ($spell); 667 $::SPELL_LIST->add_spell ($spell);
661 668
662 $self->{map_widget}->add_command ("invoke $spell->{name}", CFPlus::asxml $spell->{message}); 669 $self->{map_widget}->add_command ("invoke $spell->{name}", CFPlus::asxml $spell->{message});
663 $self->{map_widget}->add_command ("cast $spell->{name}", CFPlus::asxml $spell->{message}); 670 $self->{map_widget}->add_command ("cast $spell->{name}", CFPlus::asxml $spell->{message});
664} 671}
665 672
666sub spell_delete { 673sub spell_delete {
667 my ($self, $spell) = @_; 674 my ($self, $spell) = @_;
668 675
669 $::SPELL_PAGE->remove_spell ($spell); 676 $::SPELL_LIST->remove_spell ($spell);
677}
678
679sub setup {
680 my ($self, $setup) = @_;
681
682 $::MAP->resize ($self->{mapw}, $self->{maph});
670} 683}
671 684
672sub addme_success { 685sub addme_success {
673 my ($self) = @_; 686 my ($self) = @_;
674 687
886 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" 899 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n"
887 . "cfplus support $yesno[$self->{cfplus_ext} > 0]" 900 . "cfplus support $yesno[$self->{cfplus_ext} > 0]"
888 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 901 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
889 . "map size $self->{mapw}×$self->{maph}\n" 902 . "map size $self->{mapw}×$self->{maph}\n"
890 ); 903 );
904
905 ::setup_build_button ($self->{editor_support}->{builder_ui});
891} 906}
892 907
893sub logged_in { 908sub logged_in {
894 my ($self) = @_; 909 my ($self) = @_;
895 910
912 $self->update_server_info; 927 $self->update_server_info;
913 928
914 $self->send_command ("output-sync $::CFG->{output_sync}"); 929 $self->send_command ("output-sync $::CFG->{output_sync}");
915 $self->send_command ("output-count $::CFG->{output_count}"); 930 $self->send_command ("output-count $::CFG->{output_count}");
916 $self->send_command ("pickup $::CFG->{pickup}"); 931 $self->send_command ("pickup $::CFG->{pickup}");
932}
933
934sub buildat {
935 my ($self, $builditem, $x, $y) = @_;
936
937 if ($self->{cfplus_ext}) {
938 $self->send_ext_msg (builder_build => dx => $x, dy => $y, (ref ($builditem) eq 'HASH') ? %$builditem : (item => $builditem));
939 }
917} 940}
918 941
919sub lookat { 942sub lookat {
920 my ($self, $x, $y) = @_; 943 my ($self, $x, $y) = @_;
921 944
964 kw => { hi => 0, yes => 0, no => 0 }, 987 kw => { hi => 0, yes => 0, no => 0 },
965 has_close_button => 1, 988 has_close_button => 1,
966 @_, 989 @_,
967 ); 990 );
968 991
969 Scalar::Util::weaken (my $this = $self); 992 CFPlus::weaken (my $this = $self);
970 993
971 $self->connect (delete => sub { $this->destroy; 1 }); 994 $self->connect (delete => sub { $this->destroy; 1 });
972 995
973 # better use a pane... 996 # better use a pane...
974 $self->add (my $hbox = new CFPlus::UI::HBox); 997 $self->add (my $hbox = new CFPlus::UI::HBox);
1018}; 1041};
1019 1042
1020sub update_options { 1043sub update_options {
1021 my ($self) = @_; 1044 my ($self) = @_;
1022 1045
1023 Scalar::Util::weaken $self; 1046 CFPlus::weaken $self;
1024 1047
1025 $self->{options}->clear; 1048 $self->{options}->clear;
1026 $self->{options}->add ($self->{bye_button}); 1049 $self->{options}->add ($self->{bye_button});
1027 1050
1028 for my $kw (sort keys %{ $self->{kw} }) { 1051 for my $kw (sort keys %{ $self->{kw} }) {
1037} 1060}
1038 1061
1039sub feed { 1062sub feed {
1040 my ($self, $msg) = @_; 1063 my ($self, $msg) = @_;
1041 1064
1042 Scalar::Util::weaken $self; 1065 CFPlus::weaken $self;
1043 1066
1044 if ($msg->{msgtype} eq "reply") { 1067 if ($msg->{msgtype} eq "reply") {
1045 $self->{kw}{$_} = 1 for @{$msg->{add_topics} || []}; 1068 $self->{kw}{$_} = 1 for @{$msg->{add_topics} || []};
1046 $self->{kw}{$_} = 0 for @{$msg->{del_topics} || []}; 1069 $self->{kw}{$_} = 0 for @{$msg->{del_topics} || []};
1047 1070

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines