… | |
… | |
6 | use Crossfire::Protocol::Constants; |
6 | use Crossfire::Protocol::Constants; |
7 | |
7 | |
8 | use CFPlus; |
8 | use CFPlus; |
9 | use CFPlus::UI; |
9 | use CFPlus::UI; |
10 | use CFPlus::Pod; |
10 | use CFPlus::Pod; |
|
|
11 | |
|
|
12 | use Crossfire::Protocol::Base 0.95; |
11 | |
13 | |
12 | use base 'Crossfire::Protocol::Base'; |
14 | use base 'Crossfire::Protocol::Base'; |
13 | |
15 | |
14 | sub new { |
16 | sub new { |
15 | my $class = shift; |
17 | my $class = shift; |
… | |
… | |
319 | } |
321 | } |
320 | |
322 | |
321 | sub user_send { |
323 | sub user_send { |
322 | my ($self, $command) = @_; |
324 | my ($self, $command) = @_; |
323 | |
325 | |
324 | if ($self->{record}) { |
|
|
325 | push @{$self->{record}}, $command; |
326 | push @{$self->{record}}, $command |
326 | } |
327 | if $self->{record}; |
327 | |
328 | |
328 | $self->logprint ("send: ", $command); |
329 | $self->logprint ("send: ", $command); |
329 | $self->send_command ($command); |
330 | $self->send_command ($command); |
330 | ::status ($command); |
331 | ::status ($command); |
331 | } |
332 | } |
… | |
… | |
623 | [0.74, 0.65, 0.41], |
624 | [0.74, 0.65, 0.41], |
624 | ); |
625 | ); |
625 | |
626 | |
626 | $self->logprint ("info: ", $text); |
627 | $self->logprint ("info: ", $text); |
627 | |
628 | |
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 |
629 | # try to create single paragraphs of multiple lines sent by the server |
631 | $text =~ s/(?<=\S)\n(?=\w)/ /g; |
630 | $text =~ s/(?<=\S)\n(?=\w)/ /g; |
632 | |
631 | |
633 | $text = CFPlus::asxml $text; |
632 | $text = CFPlus::asxml $text; |
634 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
633 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
635 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
634 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
636 | |
635 | |
637 | $self->{logview}->add_paragraph ({ fg => $color[$color], markup => $_ }) |
636 | ::message ({ fg => $color[$color], markup => $_ }) |
638 | for map "<span foreground='#ffffff'>$time</span> $_", split /\n/, $text; |
637 | for split /\n/, $text; |
639 | $self->{logview}->scroll_to_bottom; |
|
|
640 | |
638 | |
641 | $self->{statusbox}->add ($text, |
639 | $self->{statusbox}->add ($text, |
642 | group => $text, |
640 | group => $text, |
643 | fg => $color[$color], |
641 | fg => $color[$color], |
644 | timeout => $color >= 2 ? 180 : 10, |
642 | timeout => $color >= 2 ? 180 : 10, |
… | |
… | |
668 | |
666 | |
669 | sub spell_delete { |
667 | sub spell_delete { |
670 | my ($self, $spell) = @_; |
668 | my ($self, $spell) = @_; |
671 | |
669 | |
672 | $::SPELL_PAGE->remove_spell ($spell); |
670 | $::SPELL_PAGE->remove_spell ($spell); |
|
|
671 | } |
|
|
672 | |
|
|
673 | sub setup { |
|
|
674 | my ($self, $setup) = @_; |
|
|
675 | |
|
|
676 | $::MAP->resize ($self->{mapw}, $self->{maph}); |
673 | } |
677 | } |
674 | |
678 | |
675 | sub addme_success { |
679 | sub addme_success { |
676 | my ($self) = @_; |
680 | my ($self) = @_; |
677 | |
681 | |
… | |
… | |
883 | $::SERVER_INFO->set_markup ( |
887 | $::SERVER_INFO->set_markup ( |
884 | "server <tt>$self->{host}:$self->{port}</tt>\n" |
888 | "server <tt>$self->{host}:$self->{port}</tt>\n" |
885 | . "protocol version <tt>$self->{version}</tt>\n" |
889 | . "protocol version <tt>$self->{version}</tt>\n" |
886 | . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" |
890 | . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" |
887 | . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" |
891 | . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" |
|
|
892 | . "editing support $yesno[!!$self->{editor_support}]\n" |
888 | . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" |
893 | . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" |
889 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]" |
894 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]" |
890 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
895 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
891 | . "map size $self->{mapw}×$self->{maph}\n" |
896 | . "map size $self->{mapw}×$self->{maph}\n" |
892 | ); |
897 | ); |
… | |
… | |
896 | my ($self) = @_; |
901 | my ($self) = @_; |
897 | |
902 | |
898 | $self->send_ext_req (cfplus_support => version => 1, sub { |
903 | $self->send_ext_req (cfplus_support => version => 1, sub { |
899 | $self->{cfplus_ext} = $_[0]{version}; |
904 | $self->{cfplus_ext} = $_[0]{version}; |
900 | $self->update_server_info; |
905 | $self->update_server_info; |
|
|
906 | |
|
|
907 | if ($self->{cfplus_ext} >= 2) { |
|
|
908 | $self->send_ext_req ("editor_support", sub { |
|
|
909 | $self->{editor_support} = $_[0]; |
|
|
910 | $self->update_server_info; |
|
|
911 | |
|
|
912 | 0 |
|
|
913 | }); |
|
|
914 | } |
901 | |
915 | |
902 | 0 |
916 | 0 |
903 | }); |
917 | }); |
904 | |
918 | |
905 | $self->update_server_info; |
919 | $self->update_server_info; |
… | |
… | |
1091 | |
1105 | |
1092 | $self->SUPER::destroy; |
1106 | $self->SUPER::destroy; |
1093 | } |
1107 | } |
1094 | |
1108 | |
1095 | 1 |
1109 | 1 |
|
|
1110 | |