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.90 by root, Wed Dec 6 00:15:12 2006 UTC vs.
Revision 1.94 by root, Fri Mar 16 02:33:49 2007 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;
11 13
12use Crossfire::Protocol::Base 0.95; 14use Crossfire::Protocol::Base 0.95;
13 15
14use base 'Crossfire::Protocol::Base'; 16use base 'Crossfire::Protocol::Base';
15 17
291 $::CONN->user_send ("use_skill $name"); 293 $::CONN->user_send ("use_skill $name");
292 } elsif ($ev->{button} == 3) { 294 } elsif ($ev->{button} == 3) {
293 my $shortname = CFPlus::shorten $name, 14; 295 my $shortname = CFPlus::shorten $name, 14;
294 (new CFPlus::UI::Menu 296 (new CFPlus::UI::Menu
295 items => [ 297 items => [
296 ["bind <i>ready_skill $shortname</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"] }],
297 ["bind <i>use_skill $shortname</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"] }],
298 ], 300 ],
299 )->popup ($ev); 301 )->popup ($ev);
300 } else { 302 } else {
301 return 0; 303 return 0;
302 } 304 }
319 $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1])); 321 $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1]));
320 $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1); 322 $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1);
321 } 323 }
322} 324}
323 325
326sub macro_send {
327 my ($self, $macro) = @_;
328
329 for my $cmd (@{ $macro->{action} }) {
330 $self->send_command ($cmd);
331 }
332}
333
324sub user_send { 334sub user_send {
325 my ($self, $command) = @_; 335 my ($self, $command) = @_;
326 336
327 push @{$self->{record}}, $command 337 $self->{record}->($command)
328 if $self->{record}; 338 if $self->{record};
329 339
330 $self->logprint ("send: ", $command); 340 $self->logprint ("send: ", $command);
331 $self->send_command ($command); 341 $self->send_command ($command);
332 ::status ($command); 342 ::status ($command);
333} 343}
334 344
335sub start_record { 345sub record {
336 my ($self) = @_; 346 my ($self, $cb) = @_;
337 347
338 $self->{record} = []; 348 $self->{record} = $cb;
339}
340
341sub stop_record {
342 my ($self) = @_;
343 return delete $self->{record};
344} 349}
345 350
346sub map_scroll { 351sub map_scroll {
347 my ($self, $dx, $dy) = @_; 352 my ($self, $dx, $dy) = @_;
348 353
623 [0.75, 0.61, 0.20], 628 [0.75, 0.61, 0.20],
624 [0.99, 0.77, 0.26], 629 [0.99, 0.77, 0.26],
625 [0.74, 0.65, 0.41], 630 [0.74, 0.65, 0.41],
626 ); 631 );
627 632
633 my $fg = $color[$color % @color];
634
628 $self->logprint ("info: ", $text); 635 $self->logprint ("info: ", $text);
629 636
630 # try to create single paragraphs of multiple lines sent by the server 637 # try to create single paragraphs of multiple lines sent by the server
631 $text =~ s/(?<=\S)\n(?=\w)/ /g; 638 $text =~ s/(?<=\S)\n(?=\w)/ /g;
632 639
633 $text = CFPlus::asxml $text; 640 $text = CFPlus::asxml $text;
634 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; 641 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
635 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 642 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
636 643
637 ::message ({ fg => $color[$color], markup => $_ }) 644 ::message ({ fg => $fg, markup => $_ })
638 for split /\n/, $text; 645 for split /\n/, $text;
639 646
640 $self->{statusbox}->add ($text, 647 $self->{statusbox}->add ($text,
641 group => $text, 648 group => $text,
642 fg => $color[$color], 649 fg => $fg,
643 timeout => $color >= 2 ? 180 : 10, 650 timeout => $color >= 2 ? 180 : 10,
644 tooltip_font => $::FONT_FIXED, 651 tooltip_font => $::FONT_FIXED,
645 ); 652 );
646} 653}
647 654
921 928
922 $self->update_server_info; 929 $self->update_server_info;
923 930
924 $self->send_command ("output-sync $::CFG->{output_sync}"); 931 $self->send_command ("output-sync $::CFG->{output_sync}");
925 $self->send_command ("output-count $::CFG->{output_count}"); 932 $self->send_command ("output-count $::CFG->{output_count}");
933 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0;
926 $self->send_command ("pickup $::CFG->{pickup}"); 934 $self->send_command ("pickup $::CFG->{pickup}");
927} 935}
928 936
929sub buildat { 937sub buildat {
930 my ($self, $builditem, $x, $y) = @_; 938 my ($self, $builditem, $x, $y) = @_;
982 kw => { hi => 0, yes => 0, no => 0 }, 990 kw => { hi => 0, yes => 0, no => 0 },
983 has_close_button => 1, 991 has_close_button => 1,
984 @_, 992 @_,
985 ); 993 );
986 994
987 Scalar::Util::weaken (my $this = $self); 995 CFPlus::weaken (my $this = $self);
988 996
989 $self->connect (delete => sub { $this->destroy; 1 }); 997 $self->connect (delete => sub { $this->destroy; 1 });
990 998
991 # better use a pane... 999 # better use a pane...
992 $self->add (my $hbox = new CFPlus::UI::HBox); 1000 $self->add (my $hbox = new CFPlus::UI::HBox);
1036}; 1044};
1037 1045
1038sub update_options { 1046sub update_options {
1039 my ($self) = @_; 1047 my ($self) = @_;
1040 1048
1041 Scalar::Util::weaken $self; 1049 CFPlus::weaken $self;
1042 1050
1043 $self->{options}->clear; 1051 $self->{options}->clear;
1044 $self->{options}->add ($self->{bye_button}); 1052 $self->{options}->add ($self->{bye_button});
1045 1053
1046 for my $kw (sort keys %{ $self->{kw} }) { 1054 for my $kw (sort keys %{ $self->{kw} }) {
1055} 1063}
1056 1064
1057sub feed { 1065sub feed {
1058 my ($self, $msg) = @_; 1066 my ($self, $msg) = @_;
1059 1067
1060 Scalar::Util::weaken $self; 1068 CFPlus::weaken $self;
1061 1069
1062 if ($msg->{msgtype} eq "reply") { 1070 if ($msg->{msgtype} eq "reply") {
1063 $self->{kw}{$_} = 1 for @{$msg->{add_topics} || []}; 1071 $self->{kw}{$_} = 1 for @{$msg->{add_topics} || []};
1064 $self->{kw}{$_} = 0 for @{$msg->{del_topics} || []}; 1072 $self->{kw}{$_} = 0 for @{$msg->{del_topics} || []};
1065 1073

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines