… | |
… | |
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, |
… | |
… | |
658 | # try to create single paragraphs out of the multiple lines sent by the server |
656 | # try to create single paragraphs out of the multiple lines sent by the server |
659 | $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g; |
657 | $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g; |
660 | $spell->{message} =~ s/\n+$//; |
658 | $spell->{message} =~ s/\n+$//; |
661 | $spell->{message} ||= "Server did not provide a description for this spell."; |
659 | $spell->{message} ||= "Server did not provide a description for this spell."; |
662 | |
660 | |
663 | $::SPELL_PAGE->add_spell ($spell); |
661 | $::SPELL_LIST->add_spell ($spell); |
664 | |
662 | |
665 | $self->{map_widget}->add_command ("invoke $spell->{name}", CFPlus::asxml $spell->{message}); |
663 | $self->{map_widget}->add_command ("invoke $spell->{name}", CFPlus::asxml $spell->{message}); |
666 | $self->{map_widget}->add_command ("cast $spell->{name}", CFPlus::asxml $spell->{message}); |
664 | $self->{map_widget}->add_command ("cast $spell->{name}", CFPlus::asxml $spell->{message}); |
667 | } |
665 | } |
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_LIST->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 | ); |
|
|
898 | |
|
|
899 | ::setup_build_button ($self->{editor_support}->{builder_ui}); |
893 | } |
900 | } |
894 | |
901 | |
895 | sub logged_in { |
902 | sub logged_in { |
896 | my ($self) = @_; |
903 | my ($self) = @_; |
897 | |
904 | |
898 | $self->send_ext_req (cfplus_support => version => 1, sub { |
905 | $self->send_ext_req (cfplus_support => version => 1, sub { |
899 | $self->{cfplus_ext} = $_[0]{version}; |
906 | $self->{cfplus_ext} = $_[0]{version}; |
900 | $self->update_server_info; |
907 | $self->update_server_info; |
901 | |
908 | |
|
|
909 | if ($self->{cfplus_ext} >= 2) { |
|
|
910 | $self->send_ext_req ("editor_support", sub { |
|
|
911 | $self->{editor_support} = $_[0]; |
|
|
912 | $self->update_server_info; |
|
|
913 | |
|
|
914 | 0 |
|
|
915 | }); |
|
|
916 | } |
|
|
917 | |
902 | 0 |
918 | 0 |
903 | }); |
919 | }); |
904 | |
920 | |
905 | $self->update_server_info; |
921 | $self->update_server_info; |
906 | |
922 | |
907 | $self->send_command ("output-sync $::CFG->{output_sync}"); |
923 | $self->send_command ("output-sync $::CFG->{output_sync}"); |
908 | $self->send_command ("output-count $::CFG->{output_count}"); |
924 | $self->send_command ("output-count $::CFG->{output_count}"); |
909 | $self->send_command ("pickup $::CFG->{pickup}"); |
925 | $self->send_command ("pickup $::CFG->{pickup}"); |
|
|
926 | } |
|
|
927 | |
|
|
928 | sub buildat { |
|
|
929 | my ($self, $builditem, $x, $y) = @_; |
|
|
930 | |
|
|
931 | if ($self->{cfplus_ext}) { |
|
|
932 | $self->send_ext_msg (builder_build => dx => $x, dy => $y, (ref ($builditem) eq 'HASH') ? %$builditem : (item => $builditem)); |
|
|
933 | } |
910 | } |
934 | } |
911 | |
935 | |
912 | sub lookat { |
936 | sub lookat { |
913 | my ($self, $x, $y) = @_; |
937 | my ($self, $x, $y) = @_; |
914 | |
938 | |