… | |
… | |
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" |
… | |
… | |
280 | if ($ev->{button} == 1) { |
288 | if ($ev->{button} == 1) { |
281 | $::CONN->user_send ("ready_skill $name"); |
289 | $::CONN->user_send ("ready_skill $name"); |
282 | } elsif ($ev->{button} == 2) { |
290 | } elsif ($ev->{button} == 2) { |
283 | $::CONN->user_send ("use_skill $name"); |
291 | $::CONN->user_send ("use_skill $name"); |
284 | } elsif ($ev->{button} == 3) { |
292 | } elsif ($ev->{button} == 3) { |
|
|
293 | my $shortname = CFPlus::shorten $name, 14; |
285 | (new CFPlus::UI::Menu |
294 | (new CFPlus::UI::Menu |
286 | items => [ |
295 | items => [ |
287 | ["bind <i>ready_skill $name</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["ready_skill $name"]) }], |
296 | ["bind <i>ready_skill $shortname</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["ready_skill $name"]) }], |
288 | ["bind <i>use_skill $name</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["use_skill $name"]) }], |
297 | ["bind <i>use_skill $shortname</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["use_skill $name"]) }], |
289 | ], |
298 | ], |
290 | )->popup ($ev); |
299 | )->popup ($ev); |
291 | } else { |
300 | } else { |
292 | return 0; |
301 | return 0; |
293 | } |
302 | } |
… | |
… | |
313 | } |
322 | } |
314 | |
323 | |
315 | sub user_send { |
324 | sub user_send { |
316 | my ($self, $command) = @_; |
325 | my ($self, $command) = @_; |
317 | |
326 | |
318 | if ($self->{record}) { |
|
|
319 | push @{$self->{record}}, $command; |
327 | push @{$self->{record}}, $command |
320 | } |
328 | if $self->{record}; |
321 | |
329 | |
322 | $self->logprint ("send: ", $command); |
330 | $self->logprint ("send: ", $command); |
323 | $self->send_command ($command); |
331 | $self->send_command ($command); |
324 | ::status ($command); |
332 | ::status ($command); |
325 | } |
333 | } |
… | |
… | |
617 | [0.74, 0.65, 0.41], |
625 | [0.74, 0.65, 0.41], |
618 | ); |
626 | ); |
619 | |
627 | |
620 | $self->logprint ("info: ", $text); |
628 | $self->logprint ("info: ", $text); |
621 | |
629 | |
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 |
630 | # try to create single paragraphs of multiple lines sent by the server |
625 | $text =~ s/(?<=\S)\n(?=\w)/ /g; |
631 | $text =~ s/(?<=\S)\n(?=\w)/ /g; |
626 | |
632 | |
627 | $text = CFPlus::asxml $text; |
633 | $text = CFPlus::asxml $text; |
628 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
634 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
629 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
635 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
630 | |
636 | |
631 | $self->{logview}->add_paragraph ({ fg => $color[$color], markup => $_ }) |
637 | ::message ({ fg => $color[$color], markup => $_ }) |
632 | for map "<span foreground='#ffffff'>$time</span> $_", split /\n/, $text; |
638 | for split /\n/, $text; |
633 | $self->{logview}->scroll_to_bottom; |
|
|
634 | |
639 | |
635 | $self->{statusbox}->add ($text, |
640 | $self->{statusbox}->add ($text, |
636 | group => $text, |
641 | group => $text, |
637 | fg => $color[$color], |
642 | fg => $color[$color], |
638 | timeout => $color >= 2 ? 180 : 10, |
643 | timeout => $color >= 2 ? 180 : 10, |
… | |
… | |
652 | # try to create single paragraphs out of the multiple lines sent by the server |
657 | # try to create single paragraphs out of the multiple lines sent by the server |
653 | $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g; |
658 | $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g; |
654 | $spell->{message} =~ s/\n+$//; |
659 | $spell->{message} =~ s/\n+$//; |
655 | $spell->{message} ||= "Server did not provide a description for this spell."; |
660 | $spell->{message} ||= "Server did not provide a description for this spell."; |
656 | |
661 | |
657 | $::SPELL_PAGE->add_spell ($spell); |
662 | $::SPELL_LIST->add_spell ($spell); |
658 | |
663 | |
659 | $self->{map_widget}->add_command ("invoke $spell->{name}", CFPlus::asxml $spell->{message}); |
664 | $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}); |
665 | $self->{map_widget}->add_command ("cast $spell->{name}", CFPlus::asxml $spell->{message}); |
661 | } |
666 | } |
662 | |
667 | |
663 | sub spell_delete { |
668 | sub spell_delete { |
664 | my ($self, $spell) = @_; |
669 | my ($self, $spell) = @_; |
665 | |
670 | |
666 | $::SPELL_PAGE->remove_spell ($spell); |
671 | $::SPELL_LIST->remove_spell ($spell); |
|
|
672 | } |
|
|
673 | |
|
|
674 | sub setup { |
|
|
675 | my ($self, $setup) = @_; |
|
|
676 | |
|
|
677 | $::MAP->resize ($self->{mapw}, $self->{maph}); |
667 | } |
678 | } |
668 | |
679 | |
669 | sub addme_success { |
680 | sub addme_success { |
670 | my ($self) = @_; |
681 | my ($self) = @_; |
671 | |
682 | |
… | |
… | |
877 | $::SERVER_INFO->set_markup ( |
888 | $::SERVER_INFO->set_markup ( |
878 | "server <tt>$self->{host}:$self->{port}</tt>\n" |
889 | "server <tt>$self->{host}:$self->{port}</tt>\n" |
879 | . "protocol version <tt>$self->{version}</tt>\n" |
890 | . "protocol version <tt>$self->{version}</tt>\n" |
880 | . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" |
891 | . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" |
881 | . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" |
892 | . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" |
|
|
893 | . "editing support $yesno[!!$self->{editor_support}]\n" |
882 | . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" |
894 | . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" |
883 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]" |
895 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]" |
884 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
896 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
885 | . "map size $self->{mapw}×$self->{maph}\n" |
897 | . "map size $self->{mapw}×$self->{maph}\n" |
886 | ); |
898 | ); |
|
|
899 | |
|
|
900 | ::setup_build_button ($self->{editor_support}->{builder_ui}); |
887 | } |
901 | } |
888 | |
902 | |
889 | sub logged_in { |
903 | sub logged_in { |
890 | my ($self) = @_; |
904 | my ($self) = @_; |
891 | |
905 | |
892 | $self->send_ext_req (cfplus_support => version => 1, sub { |
906 | $self->send_ext_req (cfplus_support => version => 1, sub { |
893 | $self->{cfplus_ext} = $_[0]{version}; |
907 | $self->{cfplus_ext} = $_[0]{version}; |
894 | $self->update_server_info; |
908 | $self->update_server_info; |
895 | |
909 | |
|
|
910 | if ($self->{cfplus_ext} >= 2) { |
|
|
911 | $self->send_ext_req ("editor_support", sub { |
|
|
912 | $self->{editor_support} = $_[0]; |
|
|
913 | $self->update_server_info; |
|
|
914 | |
|
|
915 | 0 |
|
|
916 | }); |
|
|
917 | } |
|
|
918 | |
896 | 0 |
919 | 0 |
897 | }); |
920 | }); |
898 | |
921 | |
899 | $self->update_server_info; |
922 | $self->update_server_info; |
900 | |
923 | |
901 | $self->send_command ("output-sync $::CFG->{output_sync}"); |
924 | $self->send_command ("output-sync $::CFG->{output_sync}"); |
902 | $self->send_command ("output-count $::CFG->{output_count}"); |
925 | $self->send_command ("output-count $::CFG->{output_count}"); |
903 | $self->send_command ("pickup $::CFG->{pickup}"); |
926 | $self->send_command ("pickup $::CFG->{pickup}"); |
|
|
927 | } |
|
|
928 | |
|
|
929 | sub buildat { |
|
|
930 | my ($self, $builditem, $x, $y) = @_; |
|
|
931 | |
|
|
932 | if ($self->{cfplus_ext}) { |
|
|
933 | $self->send_ext_msg (builder_build => dx => $x, dy => $y, (ref ($builditem) eq 'HASH') ? %$builditem : (item => $builditem)); |
|
|
934 | } |
904 | } |
935 | } |
905 | |
936 | |
906 | sub lookat { |
937 | sub lookat { |
907 | my ($self, $x, $y) = @_; |
938 | my ($self, $x, $y) = @_; |
908 | |
939 | |
… | |
… | |
1085 | |
1116 | |
1086 | $self->SUPER::destroy; |
1117 | $self->SUPER::destroy; |
1087 | } |
1118 | } |
1088 | |
1119 | |
1089 | 1 |
1120 | 1 |
|
|
1121 | |