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.64 by root, Sun Jul 23 08:58:44 2006 UTC vs.
Revision 1.65 by root, Sun Jul 23 16:11:12 2006 UTC

5 5
6use Crossfire::Protocol::Constants; 6use Crossfire::Protocol::Constants;
7 7
8use CFClient; 8use CFClient;
9use CFClient::UI; 9use CFClient::UI;
10use CFClient::Pod;
10 11
11use base 'Crossfire::Protocol::Base'; 12use base 'Crossfire::Protocol::Base';
12 13
13sub new { 14sub new {
14 my $class = shift; 15 my $class = shift;
15 16
16 my $self = $class->SUPER::new (@_); 17 my $self = $class->SUPER::new (@_);
17 18
18 $self->{map_widget}->clr_commands; 19 $self->{map_widget}->clr_commands;
19 20
20 my $cmd_help = CFClient::load_pod CFClient::find_rcfile "pod/command_help.pod", command_help => 1, sub { 21 my $cmd_help = CFClient::Pod::load CFClient::find_rcfile "pod/command_help.pod", command_help => 1, sub {
21 my ($pom) = @_; 22 my ($pom) = @_;
22 23
23 my @cmd_help; 24 my @cmd_help;
24 25
25 for my $head2 ($pom->head1->[-2]->head2) { 26 for my $head2 ($pom->head1->[-2]->head2) {
31 @args = (".*") unless @args; 32 @args = (".*") unless @args;
32 33
33 $_ = $_ eq ".*" ? "" : " $_" 34 $_ = $_ eq ".*" ? "" : " $_"
34 for @args; 35 for @args;
35 36
36 my $text = CFClient::pod_to_pango $head2->content; 37 my $text = CFClient::Pod::as_xml $head2->content;
37 38
38 push @cmd_help, ["$cmd$_", $text] 39 push @cmd_help, ["$cmd$_", $text]
39 for sort { (length $a) <=> (length $b) } 40 for sort { (length $a) <=> (length $b) }
40 @args; 41 @args;
41 } 42 }
260 $sktbl->add (2, 0, new CFClient::UI::Label text => "Skill", expand => 1); 261 $sktbl->add (2, 0, new CFClient::UI::Label text => "Skill", expand => 1);
261 $sktbl->add (3, 0, new CFClient::UI::Label text => "Experience", align => 1); 262 $sktbl->add (3, 0, new CFClient::UI::Label text => "Experience", align => 1);
262 $sktbl->add (4, 0, new CFClient::UI::Label text => "Lvl.", align => 1); 263 $sktbl->add (4, 0, new CFClient::UI::Label text => "Lvl.", align => 1);
263 $sktbl->add (5, 0, new CFClient::UI::Label text => "Skill", expand => 1); 264 $sktbl->add (5, 0, new CFClient::UI::Label text => "Skill", expand => 1);
264 265
265 my ($x, $y) = (1, 0); 266 my ($x, $y) = (0, 1);
266 for ( 267 for (
267 sort { $stats->{$b->[0]}[1] <=> $stats->{$a->[0]}[1] or $a->[1] cmp $b->[1] } 268 sort { $stats->{$b->[0]}[1] <=> $stats->{$a->[0]}[1] or $a->[1] cmp $b->[1] }
268 map [$_, $self->{skill_info}{$_}], 269 map [$_, $self->{skill_info}{$_}],
269 grep exists $stats->{$_}, 270 grep exists $stats->{$_},
270 @skills 271 @skills
597 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0]; 598 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0];
598 599
599 # try to create single paragraphs of multiple lines sent by the server 600 # try to create single paragraphs of multiple lines sent by the server
600 $text =~ s/(?<=\S)\n(?=\w)/ /g; 601 $text =~ s/(?<=\S)\n(?=\w)/ /g;
601 602
602 $text = CFClient::UI::Label::escape $text; 603 $text = CFClient::asxml $text;
603 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; 604 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
604 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 605 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
605 606
606 $self->{logview}->add_paragraph ($color[$color], $_) 607 $self->{logview}->add_paragraph ($color[$color], $_)
607 for map "<span foreground='#ffffff'>$time</span> $_", split /\n/, $text; 608 for map "<span foreground='#ffffff'>$time</span> $_", split /\n/, $text;
629 $spell->{message} =~ s/\n+$//; 630 $spell->{message} =~ s/\n+$//;
630 $spell->{message} ||= "Server did not provide a description for this spell."; 631 $spell->{message} ||= "Server did not provide a description for this spell.";
631 632
632 $::SPELL_PAGE->add_spell ($spell); 633 $::SPELL_PAGE->add_spell ($spell);
633 634
634 $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message}); 635 $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::asxml $spell->{message});
635 $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message}); 636 $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::asxml $spell->{message});
636} 637}
637 638
638sub spell_delete { 639sub spell_delete {
639 my ($self, $spell) = @_; 640 my ($self, $spell) = @_;
640 641
642} 643}
643 644
644sub addme_success { 645sub addme_success {
645 my ($self) = @_; 646 my ($self) = @_;
646 647
647 my $skill_help = CFClient::load_pod CFClient::find_rcfile "pod/skill_help.pod", skill_help => 1, sub { 648 my $skill_help = CFClient::Pod::load CFClient::find_rcfile "pod/skill_help.pod", skill_help => 1, sub {
648 my ($pom) = @_; 649 my ($pom) = @_;
649 650
650 my %skill_help; 651 my %skill_help;
651 652
652 for my $head2 ($pom->head1->[3]->head2) { 653 for my $head2 ($pom->head1->[3]->head2) {
653 $skill_help{$head2->title} = CFClient::pod_to_pango $head2->content; 654 $skill_help{$head2->title} = CFClient::Pod::as_xml $head2->content;
654 } 655 }
655 656
656 \%skill_help 657 \%skill_help
657 }; 658 };
658 659
659 for my $skill (values %{$self->{skill_info}}) { 660 for my $skill (values %{$self->{skill_info}}) {
660 $self->{map_widget}->add_command ("ready_skill $skill", 661 $self->{map_widget}->add_command ("ready_skill $skill",
661 (CFClient::UI::Label::escape "Ready the skill '$skill'\n\n") 662 (CFClient::asxml "Ready the skill '$skill'\n\n")
662 . $skill_help->{$skill}); 663 . $skill_help->{$skill});
663 $self->{map_widget}->add_command ("use_skill $skill", 664 $self->{map_widget}->add_command ("use_skill $skill",
664 (CFClient::UI::Label::escape "Immediately use the skill '$skill'\n\n") 665 (CFClient::asxml "Immediately use the skill '$skill'\n\n")
665 . $skill_help->{$skill}); 666 . $skill_help->{$skill});
666 } 667 }
667} 668}
668 669
669sub eof { 670sub eof {
694 695
695 my ($face) = splice @{ $self->{face_prefetch} }, + rand @{ $self->{face_prefetch} }, 1, (); 696 my ($face) = splice @{ $self->{face_prefetch} }, + rand @{ $self->{face_prefetch} }, 1, ();
696 697
697 $self->send ("requestinfo image_sums $face $face"); 698 $self->send ("requestinfo image_sums $face $face");
698 699
699 $self->{statusbox}->add (CFClient::UI::Label::escape "prefetching $todo", 700 $self->{statusbox}->add (CFClient::asxml "prefetching $todo",
700 group => "prefetch", timeout => 3, fg => [1, 1, 0, 0.5]); 701 group => "prefetch", timeout => 3, fg => [1, 1, 0, 0.5]);
701 } elsif (!exists $self->{num_faces}) { 702 } elsif (!exists $self->{num_faces}) {
702 $self->send ("requestinfo image_info"); 703 $self->send ("requestinfo image_info");
703 704
704 $self->{num_faces} = 0; 705 $self->{num_faces} = 0;
705 706
706 $self->{statusbox}->add (CFClient::UI::Label::escape "starting to prefetch", 707 $self->{statusbox}->add (CFClient::asxml "starting to prefetch",
707 group => "prefetch", timeout => 3, fg => [1, 1, 0, 0.5]); 708 group => "prefetch", timeout => 3, fg => [1, 1, 0, 0.5]);
708 } 709 }
709} 710}
710 711
711sub update_floorbox { 712sub update_floorbox {
1012 1013
1013 utf8::decode $_ for ($msg, @kw); 1014 utf8::decode $_ for ($msg, @kw);
1014 1015
1015 $self->{kw}{$_} = 1 for @kw; 1016 $self->{kw}{$_} = 1 for @kw;
1016 1017
1017 $msg = "\n" . CFClient::UI::Label::escape $msg; 1018 $msg = "\n" . CFClient::UI::asxml $msg;
1018 my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} }; 1019 my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} };
1019 my @link; 1020 my @link;
1020 $msg =~ s{ 1021 $msg =~ s{
1021 ($match) 1022 ($match)
1022 }{ 1023 }{
1046} 1047}
1047 1048
1048sub send { 1049sub send {
1049 my ($self, $msg) = @_; 1050 my ($self, $msg) = @_;
1050 1051
1051 $self->{textview}->add_paragraph ([1, 1, 0, 1], "\n" . CFClient::UI::Label::escape $msg); 1052 $self->{textview}->add_paragraph ([1, 1, 0, 1], "\n" . CFClient::asxml $msg);
1052 $self->{textview}->scroll_to_bottom; 1053 $self->{textview}->scroll_to_bottom;
1053 1054
1054 utf8::encode $msg; 1055 utf8::encode $msg;
1055 $self->{conn}->send ("ext npc_dialog_tell $self->{token} $msg"); 1056 $self->{conn}->send ("ext npc_dialog_tell $self->{token} $msg");
1056} 1057}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines