… | |
… | |
12 | use base 'Crossfire::Protocol::Base'; |
12 | use base 'Crossfire::Protocol::Base'; |
13 | |
13 | |
14 | sub new { |
14 | sub new { |
15 | my $class = shift; |
15 | my $class = shift; |
16 | |
16 | |
17 | my $self = $class->SUPER::new (@_); |
17 | my $self = $class->SUPER::new (@_, setup_req => { extmap => 1 }); |
18 | |
18 | |
19 | $self->{map_widget}->clr_commands; |
19 | $self->{map_widget}->clr_commands; |
20 | |
20 | |
21 | my @cmd_help = map { |
21 | my @cmd_help = map { |
22 | $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x |
22 | $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x |
… | |
… | |
34 | |
34 | |
35 | map ["$cmd$_", $text], |
35 | map ["$cmd$_", $text], |
36 | sort { (length $a) <=> (length $b) } |
36 | sort { (length $a) <=> (length $b) } |
37 | @args |
37 | @args |
38 | } sort { $a->{par} <=> $b->{par} } |
38 | } sort { $a->{par} <=> $b->{par} } |
39 | CFPlus::Pod::find command_help => "*"; |
39 | CFPlus::Pod::find command => "*"; |
40 | |
40 | |
41 | $self->{map_widget}->add_command (@$_) |
41 | $self->{map_widget}->add_command (@$_) |
42 | for @cmd_help; |
42 | for @cmd_help; |
43 | |
43 | |
44 | $self->{noface} = new_from_file CFPlus::Texture |
44 | $self->{noface} = new_from_file CFPlus::Texture |
45 | CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1; |
45 | CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1; |
46 | |
46 | |
|
|
47 | { |
|
|
48 | $self->{dialogue} = my $tex = new_from_file CFPlus::Texture |
|
|
49 | CFPlus::find_rcfile "dialogue.png", minify => 1, mipmap => 1; |
|
|
50 | $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
|
|
51 | } |
|
|
52 | |
47 | $self->{open_container} = 0; |
53 | $self->{open_container} = 0; |
48 | |
54 | |
49 | # "global" |
55 | # "global" |
50 | $self->{tilecache} = CFPlus::db_table "tilecache"; |
56 | $self->{tilecache} = CFPlus::db_table "tilecache" |
|
|
57 | or die "tilecache: unable to open database table"; |
51 | $self->{facemap} = CFPlus::db_table "facemap"; |
58 | $self->{facemap} = CFPlus::db_table "facemap" |
|
|
59 | or die "facemap: unable to open database table"; |
52 | |
60 | |
53 | # per server |
61 | # per server |
54 | $self->{mapcache} = CFPlus::db_table "mapcache_$self->{host}_$self->{port}"; |
62 | $self->{mapcache} = CFPlus::db_table "mapcache_$self->{host}_$self->{port}" |
|
|
63 | or die "mapcache_$self->{host}_$self->{port}: unable to open database table"; |
55 | |
64 | |
56 | $self |
65 | $self |
57 | } |
66 | } |
58 | |
67 | |
59 | sub logprint { |
68 | sub logprint { |
… | |
… | |
339 | } |
348 | } |
340 | |
349 | |
341 | sub feed_map1a { |
350 | sub feed_map1a { |
342 | my ($self, $data) = @_; |
351 | my ($self, $data) = @_; |
343 | |
352 | |
344 | $self->{map}->map1a_update ($data); |
353 | $self->{map}->map1a_update ($data, $self->{setup}{extmap}); |
345 | $self->{map_widget}->update; |
354 | $self->{map_widget}->update; |
346 | } |
355 | } |
347 | |
356 | |
348 | sub magicmap { |
357 | sub magicmap { |
349 | my ($self, $w, $h, $x, $y, $data) = @_; |
358 | my ($self, $w, $h, $x, $y, $data) = @_; |
… | |
… | |
614 | [0.74, 0.65, 0.41], |
623 | [0.74, 0.65, 0.41], |
615 | ); |
624 | ); |
616 | |
625 | |
617 | $self->logprint ("info: ", $text); |
626 | $self->logprint ("info: ", $text); |
618 | |
627 | |
619 | my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0]; |
|
|
620 | |
|
|
621 | # try to create single paragraphs of multiple lines sent by the server |
628 | # try to create single paragraphs of multiple lines sent by the server |
622 | $text =~ s/(?<=\S)\n(?=\w)/ /g; |
629 | $text =~ s/(?<=\S)\n(?=\w)/ /g; |
623 | |
630 | |
624 | $text = CFPlus::asxml $text; |
631 | $text = CFPlus::asxml $text; |
625 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
632 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
626 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
633 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
627 | |
634 | |
628 | $self->{logview}->add_paragraph ({ fg => $color[$color], markup => $_ }) |
635 | ::message ({ fg => $color[$color], markup => $_ }) |
629 | for map "<span foreground='#ffffff'>$time</span> $_", split /\n/, $text; |
636 | for split /\n/, $text; |
630 | $self->{logview}->scroll_to_bottom; |
|
|
631 | |
637 | |
632 | $self->{statusbox}->add ($text, |
638 | $self->{statusbox}->add ($text, |
633 | group => $text, |
639 | group => $text, |
634 | fg => $color[$color], |
640 | fg => $color[$color], |
635 | timeout => $color >= 2 ? 180 : 10, |
641 | timeout => $color >= 2 ? 180 : 10, |
… | |
… | |
874 | $::SERVER_INFO->set_markup ( |
880 | $::SERVER_INFO->set_markup ( |
875 | "server <tt>$self->{host}:$self->{port}</tt>\n" |
881 | "server <tt>$self->{host}:$self->{port}</tt>\n" |
876 | . "protocol version <tt>$self->{version}</tt>\n" |
882 | . "protocol version <tt>$self->{version}</tt>\n" |
877 | . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" |
883 | . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" |
878 | . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" |
884 | . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" |
|
|
885 | . "editing support $yesno[!!$self->{editor_support}]\n" |
|
|
886 | . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" |
879 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]" |
887 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]" |
880 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
888 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
881 | . "map size $self->{mapw}×$self->{maph}\n" |
889 | . "map size $self->{mapw}×$self->{maph}\n" |
882 | ); |
890 | ); |
883 | } |
891 | } |
… | |
… | |
886 | my ($self) = @_; |
894 | my ($self) = @_; |
887 | |
895 | |
888 | $self->send_ext_req (cfplus_support => version => 1, sub { |
896 | $self->send_ext_req (cfplus_support => version => 1, sub { |
889 | $self->{cfplus_ext} = $_[0]{version}; |
897 | $self->{cfplus_ext} = $_[0]{version}; |
890 | $self->update_server_info; |
898 | $self->update_server_info; |
|
|
899 | |
|
|
900 | if ($self->{cfplus_ext} >= 2) { |
|
|
901 | $self->send_ext_req ("editor_support", sub { |
|
|
902 | $self->{editor_support} = $_[0]; |
|
|
903 | $self->update_server_info; |
|
|
904 | |
|
|
905 | 0 |
|
|
906 | }); |
|
|
907 | } |
891 | |
908 | |
892 | 0 |
909 | 0 |
893 | }); |
910 | }); |
894 | |
911 | |
895 | $self->update_server_info; |
912 | $self->update_server_info; |
… | |
… | |
922 | } |
939 | } |
923 | |
940 | |
924 | sub destroy { |
941 | sub destroy { |
925 | my ($self) = @_; |
942 | my ($self) = @_; |
926 | |
943 | |
927 | $self->{npc_dialog}->destroy |
944 | (delete $self->{npc_dialog})->destroy |
928 | if $self->{npc_dialog}; |
945 | if $self->{npc_dialog}; |
929 | |
946 | |
930 | $self->SUPER::destroy; |
947 | $self->SUPER::destroy; |
931 | } |
948 | } |
932 | |
949 | |
933 | package CFPlus::NPCDialog; |
950 | package CFPlus::NPCDialog; |
934 | |
951 | |
935 | our @ISA = 'CFPlus::UI::FancyFrame'; |
952 | our @ISA = 'CFPlus::UI::Toplevel'; |
936 | |
953 | |
937 | sub new { |
954 | sub new { |
938 | my $class = shift; |
955 | my $class = shift; |
939 | |
956 | |
940 | my $self = $class->SUPER::new ( |
957 | my $self = $class->SUPER::new ( |
… | |
… | |
1044 | padding_y => 0, |
1061 | padding_y => 0, |
1045 | on_button_up => sub { |
1062 | on_button_up => sub { |
1046 | $self->send ($kw); |
1063 | $self->send ($kw); |
1047 | }; |
1064 | }; |
1048 | |
1065 | |
1049 | chr 0xfffc |
1066 | "\x{fffc}" |
1050 | }giex; |
1067 | }giex; |
1051 | |
1068 | |
1052 | $self->{textview}->add_paragraph ({ markup => $text, widget => \@link }); |
1069 | $self->{textview}->add_paragraph ({ markup => $text, widget => \@link }); |
1053 | $self->{textview}->scroll_to_bottom; |
1070 | $self->{textview}->scroll_to_bottom; |
1054 | $self->update_options; |
1071 | $self->update_options; |
… | |
… | |
1081 | |
1098 | |
1082 | $self->SUPER::destroy; |
1099 | $self->SUPER::destroy; |
1083 | } |
1100 | } |
1084 | |
1101 | |
1085 | 1 |
1102 | 1 |
|
|
1103 | |