… | |
… | |
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; |
… | |
… | |
41 | $self->{map_widget}->add_command (@$_) |
43 | $self->{map_widget}->add_command (@$_) |
42 | for @cmd_help; |
44 | for @cmd_help; |
43 | |
45 | |
44 | $self->{noface} = new_from_file CFPlus::Texture |
46 | $self->{noface} = new_from_file CFPlus::Texture |
45 | CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1; |
47 | CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1; |
|
|
48 | |
|
|
49 | { |
|
|
50 | $self->{dialogue} = my $tex = new_from_file CFPlus::Texture |
|
|
51 | CFPlus::find_rcfile "dialogue.png", minify => 1, mipmap => 1; |
|
|
52 | $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
|
|
53 | } |
46 | |
54 | |
47 | $self->{open_container} = 0; |
55 | $self->{open_container} = 0; |
48 | |
56 | |
49 | # "global" |
57 | # "global" |
50 | $self->{tilecache} = CFPlus::db_table "tilecache" |
58 | $self->{tilecache} = CFPlus::db_table "tilecache" |
… | |
… | |
313 | } |
321 | } |
314 | |
322 | |
315 | sub user_send { |
323 | sub user_send { |
316 | my ($self, $command) = @_; |
324 | my ($self, $command) = @_; |
317 | |
325 | |
318 | if ($self->{record}) { |
|
|
319 | push @{$self->{record}}, $command; |
326 | push @{$self->{record}}, $command |
320 | } |
327 | if $self->{record}; |
321 | |
328 | |
322 | $self->logprint ("send: ", $command); |
329 | $self->logprint ("send: ", $command); |
323 | $self->send_command ($command); |
330 | $self->send_command ($command); |
324 | ::status ($command); |
331 | ::status ($command); |
325 | } |
332 | } |
… | |
… | |
617 | [0.74, 0.65, 0.41], |
624 | [0.74, 0.65, 0.41], |
618 | ); |
625 | ); |
619 | |
626 | |
620 | $self->logprint ("info: ", $text); |
627 | $self->logprint ("info: ", $text); |
621 | |
628 | |
622 | my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0]; |
|
|
623 | |
|
|
624 | # 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 |
625 | $text =~ s/(?<=\S)\n(?=\w)/ /g; |
630 | $text =~ s/(?<=\S)\n(?=\w)/ /g; |
626 | |
631 | |
627 | $text = CFPlus::asxml $text; |
632 | $text = CFPlus::asxml $text; |
628 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
633 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
629 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
634 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
630 | |
635 | |
631 | $self->{logview}->add_paragraph ({ fg => $color[$color], markup => $_ }) |
636 | ::message ({ fg => $color[$color], markup => $_ }) |
632 | for map "<span foreground='#ffffff'>$time</span> $_", split /\n/, $text; |
637 | for split /\n/, $text; |
633 | $self->{logview}->scroll_to_bottom; |
|
|
634 | |
638 | |
635 | $self->{statusbox}->add ($text, |
639 | $self->{statusbox}->add ($text, |
636 | group => $text, |
640 | group => $text, |
637 | fg => $color[$color], |
641 | fg => $color[$color], |
638 | timeout => $color >= 2 ? 180 : 10, |
642 | timeout => $color >= 2 ? 180 : 10, |
… | |
… | |
652 | # 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 |
653 | $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g; |
657 | $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g; |
654 | $spell->{message} =~ s/\n+$//; |
658 | $spell->{message} =~ s/\n+$//; |
655 | $spell->{message} ||= "Server did not provide a description for this spell."; |
659 | $spell->{message} ||= "Server did not provide a description for this spell."; |
656 | |
660 | |
657 | $::SPELL_PAGE->add_spell ($spell); |
661 | $::SPELL_LIST->add_spell ($spell); |
658 | |
662 | |
659 | $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}); |
660 | $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}); |
661 | } |
665 | } |
662 | |
666 | |
663 | sub spell_delete { |
667 | sub spell_delete { |
664 | my ($self, $spell) = @_; |
668 | my ($self, $spell) = @_; |
665 | |
669 | |
666 | $::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}); |
667 | } |
677 | } |
668 | |
678 | |
669 | sub addme_success { |
679 | sub addme_success { |
670 | my ($self) = @_; |
680 | my ($self) = @_; |
671 | |
681 | |
… | |
… | |
877 | $::SERVER_INFO->set_markup ( |
887 | $::SERVER_INFO->set_markup ( |
878 | "server <tt>$self->{host}:$self->{port}</tt>\n" |
888 | "server <tt>$self->{host}:$self->{port}</tt>\n" |
879 | . "protocol version <tt>$self->{version}</tt>\n" |
889 | . "protocol version <tt>$self->{version}</tt>\n" |
880 | . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" |
890 | . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" |
881 | . "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" |
|
|
893 | . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" |
882 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]" |
894 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]" |
883 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
895 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
884 | . "map size $self->{mapw}×$self->{maph}\n" |
896 | . "map size $self->{mapw}×$self->{maph}\n" |
885 | ); |
897 | ); |
886 | } |
898 | } |
… | |
… | |
889 | my ($self) = @_; |
901 | my ($self) = @_; |
890 | |
902 | |
891 | $self->send_ext_req (cfplus_support => version => 1, sub { |
903 | $self->send_ext_req (cfplus_support => version => 1, sub { |
892 | $self->{cfplus_ext} = $_[0]{version}; |
904 | $self->{cfplus_ext} = $_[0]{version}; |
893 | $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 | } |
894 | |
915 | |
895 | 0 |
916 | 0 |
896 | }); |
917 | }); |
897 | |
918 | |
898 | $self->update_server_info; |
919 | $self->update_server_info; |
… | |
… | |
1084 | |
1105 | |
1085 | $self->SUPER::destroy; |
1106 | $self->SUPER::destroy; |
1086 | } |
1107 | } |
1087 | |
1108 | |
1088 | 1 |
1109 | 1 |
|
|
1110 | |