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.100 by root, Tue Apr 10 11:12:53 2007 UTC vs.
Revision 1.106 by root, Sun Apr 29 20:03:08 2007 UTC

15use Crossfire::Protocol::Base 0.95; 15use Crossfire::Protocol::Base 0.95;
16 16
17use base 'Crossfire::Protocol::Base'; 17use base 'Crossfire::Protocol::Base';
18 18
19sub new { 19sub new {
20 my $class = shift; 20 my ($class, %arg) = @_;
21 21
22 my $self = $class->SUPER::new (@_, 22 my $self = $class->SUPER::new (%arg,
23 setup_req => { 23 setup_req => {
24 extmap => 1, 24 extmap => 1,
25 smoothing => 1, 25 excmd => 1,
26 %{$arg{setup_req} || {}},
26 }, 27 },
27 ); 28 );
28 29
29 $self->{map_widget}->clr_commands; 30 $self->{map_widget}->clr_commands;
30 31
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
684 # no longer neecssary with TRT servers
662 $text =~ s/(?<=\S)\n(?=\w)/ /g; 685 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
663 686
664 $text = CFPlus::asxml $text;
665 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
666 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
667
668 ::message ({ fg => $fg, markup => $_ }) 687 ::message ({ fg => $fg, markup => $_ })
669 for split /\n/, $text; 688 for split /\n/, $text;
670 689
671 $self->{statusbox}->add ($text, 690 $self->{statusbox}->add ($text,
672 group => $text, 691 group => $text,
673 fg => $fg, 692 fg => $fg,
674 timeout => $color >= 2 ? 180 : 10, 693 timeout => $color >= 2 ? 180 : 10,
675 tooltip_font => $::FONT_FIXED, 694 tooltip_font => $::FONT_FIXED,
676 ); 695 );
677} 696 }
678
679sub drawextinfo {
680 my ($self, $color, $type, $subtype, $message) = @_;
681
682 $self->drawinfo ($color, $message);
683} 697}
684 698
685sub spell_add { 699sub spell_add {
686 my ($self, $spell) = @_; 700 my ($self, $spell) = @_;
687 701
920 $::SERVER_INFO->set_markup ( 934 $::SERVER_INFO->set_markup (
921 "server <tt>$self->{host}:$self->{port}</tt>\n" 935 "server <tt>$self->{host}:$self->{port}</tt>\n"
922 . "protocol version <tt>$self->{version}</tt>\n" 936 . "protocol version <tt>$self->{version}</tt>\n"
923 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" 937 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"
924 . "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"
925 . "editing support $yesno[!!$self->{editor_support}]\n" 940 . "editing support $yesno[!!$self->{editor_support}]\n"
926 . "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"
927 . "cfplus support $yesno[$self->{cfplus_ext} > 0]" 943 . "cfplus support $yesno[$self->{cfplus_ext} > 0]"
928 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 944 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
929 . "map size $self->{mapw}×$self->{maph}\n" 945 . "map size $self->{mapw}×$self->{maph}\n"
930 ); 946 );
931 947

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines