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.85 by root, Sun Oct 1 11:53:59 2006 UTC vs.
Revision 1.90 by root, Wed Dec 6 00:15:12 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;
11
12use Crossfire::Protocol::Base 0.95;
11 13
12use base 'Crossfire::Protocol::Base'; 14use base 'Crossfire::Protocol::Base';
13 15
14sub new { 16sub new {
15 my $class = shift; 17 my $class = shift;
286 if ($ev->{button} == 1) { 288 if ($ev->{button} == 1) {
287 $::CONN->user_send ("ready_skill $name"); 289 $::CONN->user_send ("ready_skill $name");
288 } elsif ($ev->{button} == 2) { 290 } elsif ($ev->{button} == 2) {
289 $::CONN->user_send ("use_skill $name"); 291 $::CONN->user_send ("use_skill $name");
290 } elsif ($ev->{button} == 3) { 292 } elsif ($ev->{button} == 3) {
293 my $shortname = CFPlus::shorten $name, 14;
291 (new CFPlus::UI::Menu 294 (new CFPlus::UI::Menu
292 items => [ 295 items => [
293 ["bind <i>ready_skill $name</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["ready_skill $name"]) }], 296 ["bind <i>ready_skill $shortname</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["ready_skill $name"]) }],
294 ["bind <i>use_skill $name</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["use_skill $name"]) }], 297 ["bind <i>use_skill $shortname</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["use_skill $name"]) }],
295 ], 298 ],
296 )->popup ($ev); 299 )->popup ($ev);
297 } else { 300 } else {
298 return 0; 301 return 0;
299 } 302 }
319} 322}
320 323
321sub user_send { 324sub user_send {
322 my ($self, $command) = @_; 325 my ($self, $command) = @_;
323 326
324 if ($self->{record}) {
325 push @{$self->{record}}, $command; 327 push @{$self->{record}}, $command
326 } 328 if $self->{record};
327 329
328 $self->logprint ("send: ", $command); 330 $self->logprint ("send: ", $command);
329 $self->send_command ($command); 331 $self->send_command ($command);
330 ::status ($command); 332 ::status ($command);
331} 333}
623 [0.74, 0.65, 0.41], 625 [0.74, 0.65, 0.41],
624 ); 626 );
625 627
626 $self->logprint ("info: ", $text); 628 $self->logprint ("info: ", $text);
627 629
628 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0];
629
630 # try to create single paragraphs of multiple lines sent by the server 630 # try to create single paragraphs of multiple lines sent by the server
631 $text =~ s/(?<=\S)\n(?=\w)/ /g; 631 $text =~ s/(?<=\S)\n(?=\w)/ /g;
632 632
633 $text = CFPlus::asxml $text; 633 $text = CFPlus::asxml $text;
634 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; 634 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
635 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 635 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
636 636
637 $self->{logview}->add_paragraph ({ fg => $color[$color], markup => $_ }) 637 ::message ({ fg => $color[$color], markup => $_ })
638 for map "<span foreground='#ffffff'>$time</span> $_", split /\n/, $text; 638 for split /\n/, $text;
639 $self->{logview}->scroll_to_bottom;
640 639
641 $self->{statusbox}->add ($text, 640 $self->{statusbox}->add ($text,
642 group => $text, 641 group => $text,
643 fg => $color[$color], 642 fg => $color[$color],
644 timeout => $color >= 2 ? 180 : 10, 643 timeout => $color >= 2 ? 180 : 10,
658 # try to create single paragraphs out of the multiple lines sent by the server 657 # try to create single paragraphs out of the multiple lines sent by the server
659 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g; 658 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g;
660 $spell->{message} =~ s/\n+$//; 659 $spell->{message} =~ s/\n+$//;
661 $spell->{message} ||= "Server did not provide a description for this spell."; 660 $spell->{message} ||= "Server did not provide a description for this spell.";
662 661
663 $::SPELL_PAGE->add_spell ($spell); 662 $::SPELL_LIST->add_spell ($spell);
664 663
665 $self->{map_widget}->add_command ("invoke $spell->{name}", CFPlus::asxml $spell->{message}); 664 $self->{map_widget}->add_command ("invoke $spell->{name}", CFPlus::asxml $spell->{message});
666 $self->{map_widget}->add_command ("cast $spell->{name}", CFPlus::asxml $spell->{message}); 665 $self->{map_widget}->add_command ("cast $spell->{name}", CFPlus::asxml $spell->{message});
667} 666}
668 667
669sub spell_delete { 668sub spell_delete {
670 my ($self, $spell) = @_; 669 my ($self, $spell) = @_;
671 670
672 $::SPELL_PAGE->remove_spell ($spell); 671 $::SPELL_LIST->remove_spell ($spell);
672}
673
674sub setup {
675 my ($self, $setup) = @_;
676
677 $::MAP->resize ($self->{mapw}, $self->{maph});
673} 678}
674 679
675sub addme_success { 680sub addme_success {
676 my ($self) = @_; 681 my ($self) = @_;
677 682
883 $::SERVER_INFO->set_markup ( 888 $::SERVER_INFO->set_markup (
884 "server <tt>$self->{host}:$self->{port}</tt>\n" 889 "server <tt>$self->{host}:$self->{port}</tt>\n"
885 . "protocol version <tt>$self->{version}</tt>\n" 890 . "protocol version <tt>$self->{version}</tt>\n"
886 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" 891 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"
887 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" 892 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n"
888 . "editor support $yesno[!!length $self->{cvs_root}]\n" 893 . "editing support $yesno[!!$self->{editor_support}]\n"
889 . "test server " . (length $self->{test_server} ? $self->{test_server} : $yesno[0]) . "\n"
890 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" 894 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n"
891 . "cfplus support $yesno[$self->{cfplus_ext} > 0]" 895 . "cfplus support $yesno[$self->{cfplus_ext} > 0]"
892 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 896 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
893 . "map size $self->{mapw}×$self->{maph}\n" 897 . "map size $self->{mapw}×$self->{maph}\n"
894 ); 898 );
899
900 ::setup_build_button ($self->{editor_support}->{builder_ui});
895} 901}
896 902
897sub logged_in { 903sub logged_in {
898 my ($self) = @_; 904 my ($self) = @_;
899 905
901 $self->{cfplus_ext} = $_[0]{version}; 907 $self->{cfplus_ext} = $_[0]{version};
902 $self->update_server_info; 908 $self->update_server_info;
903 909
904 if ($self->{cfplus_ext} >= 2) { 910 if ($self->{cfplus_ext} >= 2) {
905 $self->send_ext_req ("editor_support", sub { 911 $self->send_ext_req ("editor_support", sub {
906 $self->{cvs_root} = $_[0]{cvs_root}; 912 $self->{editor_support} = $_[0];
907 $self->{upload} = $_[0]{upload};
908 $self->{test_server} = $_[0]{server};
909 $self->update_server_info; 913 $self->update_server_info;
910 914
911 0 915 0
912 }); 916 });
913 } 917 }
918 $self->update_server_info; 922 $self->update_server_info;
919 923
920 $self->send_command ("output-sync $::CFG->{output_sync}"); 924 $self->send_command ("output-sync $::CFG->{output_sync}");
921 $self->send_command ("output-count $::CFG->{output_count}"); 925 $self->send_command ("output-count $::CFG->{output_count}");
922 $self->send_command ("pickup $::CFG->{pickup}"); 926 $self->send_command ("pickup $::CFG->{pickup}");
927}
928
929sub buildat {
930 my ($self, $builditem, $x, $y) = @_;
931
932 if ($self->{cfplus_ext}) {
933 $self->send_ext_msg (builder_build => dx => $x, dy => $y, (ref ($builditem) eq 'HASH') ? %$builditem : (item => $builditem));
934 }
923} 935}
924 936
925sub lookat { 937sub lookat {
926 my ($self, $x, $y) = @_; 938 my ($self, $x, $y) = @_;
927 939

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines