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.89 by elmex, Mon Dec 4 15:17:14 2006 UTC vs.
Revision 1.93 by root, Fri Dec 22 03:43:05 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;
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
288 if ($ev->{button} == 1) { 290 if ($ev->{button} == 1) {
289 $::CONN->user_send ("ready_skill $name"); 291 $::CONN->user_send ("ready_skill $name");
290 } elsif ($ev->{button} == 2) { 292 } elsif ($ev->{button} == 2) {
291 $::CONN->user_send ("use_skill $name"); 293 $::CONN->user_send ("use_skill $name");
292 } elsif ($ev->{button} == 3) { 294 } elsif ($ev->{button} == 3) {
295 my $shortname = CFPlus::shorten $name, 14;
293 (new CFPlus::UI::Menu 296 (new CFPlus::UI::Menu
294 items => [ 297 items => [
295 ["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"] }],
296 ["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"] }],
297 ], 300 ],
298 )->popup ($ev); 301 )->popup ($ev);
299 } else { 302 } else {
300 return 0; 303 return 0;
301 } 304 }
318 $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1])); 321 $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1]));
319 $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1); 322 $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1);
320 } 323 }
321} 324}
322 325
326sub macro_send {
327 my ($self, $macro) = @_;
328
329 for my $cmd (@{ $macro->{action} }) {
330 $self->send_command ($cmd);
331 }
332}
333
323sub user_send { 334sub user_send {
324 my ($self, $command) = @_; 335 my ($self, $command) = @_;
325 336
326 push @{$self->{record}}, $command 337 $self->{record}->($command)
327 if $self->{record}; 338 if $self->{record};
328 339
329 $self->logprint ("send: ", $command); 340 $self->logprint ("send: ", $command);
330 $self->send_command ($command); 341 $self->send_command ($command);
331 ::status ($command); 342 ::status ($command);
332} 343}
333 344
334sub start_record { 345sub record {
335 my ($self) = @_; 346 my ($self, $cb) = @_;
336 347
337 $self->{record} = []; 348 $self->{record} = $cb;
338}
339
340sub stop_record {
341 my ($self) = @_;
342 return delete $self->{record};
343} 349}
344 350
345sub map_scroll { 351sub map_scroll {
346 my ($self, $dx, $dy) = @_; 352 my ($self, $dx, $dy) = @_;
347 353
622 [0.75, 0.61, 0.20], 628 [0.75, 0.61, 0.20],
623 [0.99, 0.77, 0.26], 629 [0.99, 0.77, 0.26],
624 [0.74, 0.65, 0.41], 630 [0.74, 0.65, 0.41],
625 ); 631 );
626 632
633 my $fg = $color[$color % @color];
634
627 $self->logprint ("info: ", $text); 635 $self->logprint ("info: ", $text);
628 636
629 # 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
630 $text =~ s/(?<=\S)\n(?=\w)/ /g; 638 $text =~ s/(?<=\S)\n(?=\w)/ /g;
631 639
632 $text = CFPlus::asxml $text; 640 $text = CFPlus::asxml $text;
633 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; 641 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
634 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 642 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
635 643
636 ::message ({ fg => $color[$color], markup => $_ }) 644 ::message ({ fg => $fg, markup => $_ })
637 for split /\n/, $text; 645 for split /\n/, $text;
638 646
639 $self->{statusbox}->add ($text, 647 $self->{statusbox}->add ($text,
640 group => $text, 648 group => $text,
641 fg => $color[$color], 649 fg => $fg,
642 timeout => $color >= 2 ? 180 : 10, 650 timeout => $color >= 2 ? 180 : 10,
643 tooltip_font => $::FONT_FIXED, 651 tooltip_font => $::FONT_FIXED,
644 ); 652 );
645} 653}
646 654
981 kw => { hi => 0, yes => 0, no => 0 }, 989 kw => { hi => 0, yes => 0, no => 0 },
982 has_close_button => 1, 990 has_close_button => 1,
983 @_, 991 @_,
984 ); 992 );
985 993
986 Scalar::Util::weaken (my $this = $self); 994 CFPlus::weaken (my $this = $self);
987 995
988 $self->connect (delete => sub { $this->destroy; 1 }); 996 $self->connect (delete => sub { $this->destroy; 1 });
989 997
990 # better use a pane... 998 # better use a pane...
991 $self->add (my $hbox = new CFPlus::UI::HBox); 999 $self->add (my $hbox = new CFPlus::UI::HBox);
1035}; 1043};
1036 1044
1037sub update_options { 1045sub update_options {
1038 my ($self) = @_; 1046 my ($self) = @_;
1039 1047
1040 Scalar::Util::weaken $self; 1048 CFPlus::weaken $self;
1041 1049
1042 $self->{options}->clear; 1050 $self->{options}->clear;
1043 $self->{options}->add ($self->{bye_button}); 1051 $self->{options}->add ($self->{bye_button});
1044 1052
1045 for my $kw (sort keys %{ $self->{kw} }) { 1053 for my $kw (sort keys %{ $self->{kw} }) {
1054} 1062}
1055 1063
1056sub feed { 1064sub feed {
1057 my ($self, $msg) = @_; 1065 my ($self, $msg) = @_;
1058 1066
1059 Scalar::Util::weaken $self; 1067 CFPlus::weaken $self;
1060 1068
1061 if ($msg->{msgtype} eq "reply") { 1069 if ($msg->{msgtype} eq "reply") {
1062 $self->{kw}{$_} = 1 for @{$msg->{add_topics} || []}; 1070 $self->{kw}{$_} = 1 for @{$msg->{add_topics} || []};
1063 $self->{kw}{$_} = 0 for @{$msg->{del_topics} || []}; 1071 $self->{kw}{$_} = 0 for @{$msg->{del_topics} || []};
1064 1072

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines