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.102 by root, Wed Apr 18 18:16:16 2007 UTC vs.
Revision 1.105 by root, Tue Apr 24 01:13:15 2007 UTC

20 my ($class, %arg) = @_; 20 my ($class, %arg) = @_;
21 21
22 my $self = $class->SUPER::new (%arg, 22 my $self = $class->SUPER::new (%arg,
23 setup_req => { 23 setup_req => {
24 extmap => 1, 24 extmap => 1,
25 excmd => 1,
25 %{$arg{setup_req} || {}}, 26 %{$arg{setup_req} || {}},
26 }, 27 },
27 ); 28 );
28 29
29 $self->{map_widget}->clr_commands; 30 $self->{map_widget}->clr_commands;
633 $LAST_QUERY = $prompt; 634 $LAST_QUERY = $prompt;
634 635
635 $self->{query}-> ($self, $flags, $prompt); 636 $self->{query}-> ($self, $flags, $prompt);
636} 637}
637 638
638sub drawinfo { 639our %NAME_TO_COLOR = (
639 my ($self, $color, $text) = @_; 640 black => 0,
641 white => 1,
642 darkblue => 2,
643 red => 3,
644 orange => 4,
645 lightblue => 5,
646 darkorange => 6,
647 green => 7,
648 darkgreen => 8,
649 grey => 9,
650 brown => 10,
651 yellow => 11,
652 tan => 12,
653);
640 654
641 my @color = ( 655our @CF_COLOR = (
642 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], 656 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00],
643 [1.00, 1.00, 1.00], 657 [1.00, 1.00, 1.00],
644 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55] 658 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55]
645 [1.00, 0.00, 0.00], 659 [1.00, 0.00, 0.00],
646 [1.00, 0.54, 0.00], 660 [1.00, 0.54, 0.00],
647 [0.11, 0.56, 1.00], 661 [0.11, 0.56, 1.00],
648 [0.93, 0.46, 0.00], 662 [0.93, 0.46, 0.00],
649 [0.18, 0.54, 0.34], 663 [0.18, 0.54, 0.34],
650 [0.56, 0.73, 0.56], 664 [0.56, 0.73, 0.56],
651 [0.80, 0.80, 0.80], 665 [0.80, 0.80, 0.80],
652 [0.75, 0.61, 0.20], 666 [0.75, 0.61, 0.20],
653 [0.99, 0.77, 0.26], 667 [0.99, 0.77, 0.26],
654 [0.74, 0.65, 0.41], 668 [0.74, 0.65, 0.41],
655 ); 669);
656 670
657 my $fg = $color[$color % @color]; 671sub msg {
672 my ($self, $color, $type, $text, @extra) = @_;
658 673
674 if (my $cb = $self->{cb_msg}{$type}) {
675 $_->($self, $color, $type, $text, @extra) for values %$cb;
676 } elsif ($type =~ /^(?:chargen-race-title|chargen-race-description)$/) {
677 $type =~ s/-/_/g;
678 $self->{$type} = $text;
679 } else {
659 $self->logprint ("info: ", $text); 680 $self->logprint ("msg: ", $text);
681 return if $color < 0; # negative color == ignore if not understood
660 682
683 my $fg = $CF_COLOR[$color % @CF_COLOR];
684
661 ## try to create single paragraphs of multiple lines sent by the server 685 ## try to create single paragraphs of multiple lines sent by the server
662 # no longer neecssary with TRT servers 686 # no longer neecssary with TRT servers
663 #$text =~ s/(?<=\S)\n(?=\w)/ /g; 687 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
664 688
665 $text = CFPlus::asxml $text;
666 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
667 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
668
669 ::message ({ fg => $fg, markup => $_ }) 689 ::message ({ fg => $fg, markup => $_ })
670 for split /\n/, $text; 690 for split /\n/, $text;
671 691
672 $self->{statusbox}->add ($text, 692 $self->{statusbox}->add ($text,
673 group => $text, 693 group => $text,
674 fg => $fg, 694 fg => $fg,
675 timeout => $color >= 2 ? 180 : 10, 695 timeout => $color >= 2 ? 180 : 10,
676 tooltip_font => $::FONT_FIXED, 696 tooltip_font => $::FONT_FIXED,
677 ); 697 );
678} 698 }
679
680sub drawextinfo {
681 my ($self, $color, $type, $subtype, $message) = @_;
682
683 $self->drawinfo ($color, $message);
684} 699}
685 700
686sub spell_add { 701sub spell_add {
687 my ($self, $spell) = @_; 702 my ($self, $spell) = @_;
688 703
921 $::SERVER_INFO->set_markup ( 936 $::SERVER_INFO->set_markup (
922 "server <tt>$self->{host}:$self->{port}</tt>\n" 937 "server <tt>$self->{host}:$self->{port}</tt>\n"
923 . "protocol version <tt>$self->{version}</tt>\n" 938 . "protocol version <tt>$self->{version}</tt>\n"
924 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" 939 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"
925 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" 940 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n"
941 . "examine command support $yesno[$self->{setup}{excmd} > 0]\n"
926 . "editing support $yesno[!!$self->{editor_support}]\n" 942 . "editing support $yesno[!!$self->{editor_support}]\n"
927 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" 943 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n"
944 . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n"
928 . "cfplus support $yesno[$self->{cfplus_ext} > 0]" 945 . "cfplus support $yesno[$self->{cfplus_ext} > 0]"
929 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 946 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
930 . "map size $self->{mapw}×$self->{maph}\n" 947 . "map size $self->{mapw}×$self->{maph}\n"
931 ); 948 );
932 949

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines