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.106 by root, Sun Apr 29 20:03:08 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;
248 $::GAUGES->{mana} ->set_value ($sp, $sp_m); 249 $::GAUGES->{mana} ->set_value ($sp, $sp_m);
249 $::GAUGES->{food} ->set_value ($fo, $fo_m); 250 $::GAUGES->{food} ->set_value ($fo, $fo_m);
250 $::GAUGES->{grace} ->set_value ($gr, $gr_m); 251 $::GAUGES->{grace} ->set_value ($gr, $gr_m);
251 $::GAUGES->{exp} ->set_text ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64})) 252 $::GAUGES->{exp} ->set_text ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64}))
252 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")"); 253 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")");
253 my $rng = $stats->{+CS_STAT_RANGE}; 254 $::GAUGES->{range} ->set_text ($stats->{+CS_STAT_RANGE});
254 $rng =~ s/^Range: //; # thank you so much dear server
255 $::GAUGES->{range} ->set_text ("Rng: " . $rng);
256 my $title = $stats->{+CS_STAT_TITLE}; 255 my $title = $stats->{+CS_STAT_TITLE};
257 $title =~ s/^Player: //; 256 $title =~ s/^Player: //;
258 $::STATWIDS->{title} ->set_text ("Title: " . $title); 257 $::STATWIDS->{title} ->set_text ("Title: " . $title);
259 258
260 $::STATWIDS->{st_str} ->set_text (sprintf "%d" , $stats->{+CS_STAT_STR}); 259 $::STATWIDS->{st_str} ->set_text (sprintf "%d" , $stats->{+CS_STAT_STR});
633 $LAST_QUERY = $prompt; 632 $LAST_QUERY = $prompt;
634 633
635 $self->{query}-> ($self, $flags, $prompt); 634 $self->{query}-> ($self, $flags, $prompt);
636} 635}
637 636
638sub drawinfo { 637our %NAME_TO_COLOR = (
639 my ($self, $color, $text) = @_; 638 black => 0,
639 white => 1,
640 darkblue => 2,
641 red => 3,
642 orange => 4,
643 lightblue => 5,
644 darkorange => 6,
645 green => 7,
646 darkgreen => 8,
647 grey => 9,
648 brown => 10,
649 yellow => 11,
650 tan => 12,
651);
640 652
641 my @color = ( 653our @CF_COLOR = (
642 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], 654 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00],
643 [1.00, 1.00, 1.00], 655 [1.00, 1.00, 1.00],
644 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55] 656 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55]
645 [1.00, 0.00, 0.00], 657 [1.00, 0.00, 0.00],
646 [1.00, 0.54, 0.00], 658 [1.00, 0.54, 0.00],
647 [0.11, 0.56, 1.00], 659 [0.11, 0.56, 1.00],
648 [0.93, 0.46, 0.00], 660 [0.93, 0.46, 0.00],
649 [0.18, 0.54, 0.34], 661 [0.18, 0.54, 0.34],
650 [0.56, 0.73, 0.56], 662 [0.56, 0.73, 0.56],
651 [0.80, 0.80, 0.80], 663 [0.80, 0.80, 0.80],
652 [0.75, 0.61, 0.20], 664 [0.75, 0.61, 0.20],
653 [0.99, 0.77, 0.26], 665 [0.99, 0.77, 0.26],
654 [0.74, 0.65, 0.41], 666 [0.74, 0.65, 0.41],
655 ); 667);
656 668
657 my $fg = $color[$color % @color]; 669sub msg {
670 my ($self, $color, $type, $text, @extra) = @_;
658 671
672 if (my $cb = $self->{cb_msg}{$type}) {
673 $_->($self, $color, $type, $text, @extra) for values %$cb;
674 } elsif ($type =~ /^(?:chargen-race-title|chargen-race-description)$/) {
675 $type =~ s/-/_/g;
676 $self->{$type} = $text;
677 } else {
659 $self->logprint ("info: ", $text); 678 $self->logprint ("msg: ", $text);
679 return if $color < 0; # negative color == ignore if not understood
660 680
681 my $fg = $CF_COLOR[$color % @CF_COLOR];
682
661 ## try to create single paragraphs of multiple lines sent by the server 683 ## try to create single paragraphs of multiple lines sent by the server
662 # no longer neecssary with TRT servers 684 # no longer neecssary with TRT servers
663 #$text =~ s/(?<=\S)\n(?=\w)/ /g; 685 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
664 686
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 => $_ }) 687 ::message ({ fg => $fg, markup => $_ })
670 for split /\n/, $text; 688 for split /\n/, $text;
671 689
672 $self->{statusbox}->add ($text, 690 $self->{statusbox}->add ($text,
673 group => $text, 691 group => $text,
674 fg => $fg, 692 fg => $fg,
675 timeout => $color >= 2 ? 180 : 10, 693 timeout => $color >= 2 ? 180 : 10,
676 tooltip_font => $::FONT_FIXED, 694 tooltip_font => $::FONT_FIXED,
677 ); 695 );
678} 696 }
679
680sub drawextinfo {
681 my ($self, $color, $type, $subtype, $message) = @_;
682
683 $self->drawinfo ($color, $message);
684} 697}
685 698
686sub spell_add { 699sub spell_add {
687 my ($self, $spell) = @_; 700 my ($self, $spell) = @_;
688 701
921 $::SERVER_INFO->set_markup ( 934 $::SERVER_INFO->set_markup (
922 "server <tt>$self->{host}:$self->{port}</tt>\n" 935 "server <tt>$self->{host}:$self->{port}</tt>\n"
923 . "protocol version <tt>$self->{version}</tt>\n" 936 . "protocol version <tt>$self->{version}</tt>\n"
924 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" 937 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"
925 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" 938 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n"
939 . "examine command support $yesno[$self->{setup}{excmd} > 0]\n"
926 . "editing support $yesno[!!$self->{editor_support}]\n" 940 . "editing support $yesno[!!$self->{editor_support}]\n"
927 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" 941 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n"
942 . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n"
928 . "cfplus support $yesno[$self->{cfplus_ext} > 0]" 943 . "cfplus support $yesno[$self->{cfplus_ext} > 0]"
929 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 944 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
930 . "map size $self->{mapw}×$self->{maph}\n" 945 . "map size $self->{mapw}×$self->{maph}\n"
931 ); 946 );
932 947

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines