… | |
… | |
27 | ); |
27 | ); |
28 | |
28 | |
29 | $self->{map_widget}->clr_commands; |
29 | $self->{map_widget}->clr_commands; |
30 | |
30 | |
31 | my @cmd_help = map { |
31 | my @cmd_help = map { |
32 | $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x |
32 | $_->[DC::Pod::N_KW][0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x |
33 | or die "unparseable command help: $_->{kw}[0]"; |
33 | or die "unparseable command help: $_->[DC::Pod::N_KW][0]"; |
34 | |
34 | |
35 | my $cmd = $1; |
35 | my $cmd = $1; |
36 | my @args = split /\|/, $2; |
36 | my @args = split /\|/, $2; |
37 | @args = (".*") unless @args; |
37 | @args = (".*") unless @args; |
38 | |
38 | |
… | |
… | |
43 | for @args; |
43 | for @args; |
44 | |
44 | |
45 | map ["$cmd$_", $text], |
45 | map ["$cmd$_", $text], |
46 | sort { (length $a) <=> (length $b) } |
46 | sort { (length $a) <=> (length $b) } |
47 | @args |
47 | @args |
48 | } sort { $a->{par} <=> $b->{par} } |
48 | } sort { $a->[DC::Pod::N_PAR] <=> $b->[DC::Pod::N_PAR] } |
49 | DC::Pod::find command => "*"; |
49 | DC::Pod::find command => "*"; |
50 | |
50 | |
51 | $self->{json_coder} |
51 | $self->{json_coder} |
52 | ->convert_blessed |
52 | ->convert_blessed |
53 | ->filter_json_single_key_object ("\fw" => sub { |
53 | ->filter_json_single_key_object ("\fw" => sub { |
… | |
… | |
64 | $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub { |
64 | $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub { |
65 | for my $ws (values %{delete $self->{widgetset} || {}}) { |
65 | for my $ws (values %{delete $self->{widgetset} || {}}) { |
66 | $_->destroy |
66 | $_->destroy |
67 | for values %{delete $ws->{w} || {}}; |
67 | for values %{delete $ws->{w} || {}}; |
68 | } |
68 | } |
|
|
69 | |
|
|
70 | delete $self->{items}; |
|
|
71 | $::INV->clear; |
|
|
72 | $::INVR_HB->clear; |
|
|
73 | $::FLOORBOX->clear; |
69 | }); |
74 | }); |
70 | |
75 | |
71 | $self->{map_widget}->add_command (@$_) |
76 | $self->{map_widget}->add_command (@$_) |
72 | for @cmd_help; |
77 | for @cmd_help; |
73 | |
78 | |
… | |
… | |
225 | @w |
230 | @w |
226 | }; |
231 | }; |
227 | |
232 | |
228 | # either array reference, or face # |
233 | # either array reference, or face # |
229 | if ($type eq "inline") { |
234 | if ($type eq "inline") { |
|
|
235 | $done_cb->(); |
230 | $parse_list->($template); |
236 | $parse_list->($template); |
231 | $done_cb->(); |
|
|
232 | } elsif ($type eq "face") { |
237 | } elsif ($type eq "face") { |
233 | #... |
238 | my $handler; $handler = $self->register_face_handler ($template, sub { |
|
|
239 | my ($face) = @_; |
|
|
240 | |
|
|
241 | undef $handler; |
234 | $done_cb->(0); |
242 | $done_cb->(); |
|
|
243 | $parse_list->($self->{json_coder}->decode ($face->{data})); |
|
|
244 | }); |
235 | } else { |
245 | } else { |
236 | $done_cb->(0); |
246 | $done_cb->(0); |
237 | } |
247 | } |
238 | } |
248 | } |
239 | |
249 | |
… | |
… | |
270 | spell_list => $::SPELL_LIST, |
280 | spell_list => $::SPELL_LIST, |
271 | |
281 | |
272 | floorbox => $::FLOORBOX, |
282 | floorbox => $::FLOORBOX, |
273 | help_window => $::HELP_WINDOW, |
283 | help_window => $::HELP_WINDOW, |
274 | message_window => $::MESSAGE_WINDOW, |
284 | message_window => $::MESSAGE_WINDOW, |
|
|
285 | message_dist => $::MESSAGE_DIST, |
275 | statusbox => $::SDTATUSBOX, |
286 | statusbox => $::SDTATUSBOX, |
276 | |
287 | |
277 | inv => $::INV, |
288 | inv => $::INV, |
278 | invr => $::INVR, |
289 | invr => $::INVR, |
279 | invr_hb => $::INVR_HB, |
290 | invr_hb => $::INVR_HB, |
… | |
… | |
328 | |
339 | |
329 | # message window |
340 | # message window |
330 | sub ext_channel_info { |
341 | sub ext_channel_info { |
331 | my ($self, $info) = @_; |
342 | my ($self, $info) = @_; |
332 | $self->{channels}->{$info->{id}} = $info; |
343 | $self->{channels}->{$info->{id}} = $info; |
333 | $::MESSAGE_WINDOW->add_channel ($info); |
344 | $::MESSAGE_DIST->add_channel ($info); |
334 | } |
345 | } |
335 | |
346 | |
336 | ############################################################################# |
347 | ############################################################################# |
337 | |
348 | |
338 | sub logprint { |
349 | sub logprint { |
… | |
… | |
520 | $sktbl->clear; |
531 | $sktbl->clear; |
521 | |
532 | |
522 | my $sw = $self->{skillwid}{""} ||= [ |
533 | my $sw = $self->{skillwid}{""} ||= [ |
523 | 0, 0, (new DC::UI::Label text => "Experience", align => 1), |
534 | 0, 0, (new DC::UI::Label text => "Experience", align => 1), |
524 | 1, 0, (new DC::UI::Label text => "Lvl.", align => 1), |
535 | 1, 0, (new DC::UI::Label text => "Lvl.", align => 1), |
525 | 2, 0, (new DC::UI::Label text => "Progress", align => 0), |
536 | 2, 0, (new DC::UI::Label text => "Progress"), |
526 | 3, 0, (new DC::UI::Label text => "Skill", expand => 1), |
537 | 3, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), |
527 | 4, 0, (new DC::UI::Label text => "Experience", align => 1), |
538 | 4, 0, (new DC::UI::Label text => "Experience", align => 1), |
528 | 5, 0, (new DC::UI::Label text => "Lvl.", align => 1), |
539 | 5, 0, (new DC::UI::Label text => "Lvl.", align => 1), |
529 | 6, 0, (new DC::UI::Label text => "Progress", align => 0), |
540 | 6, 0, (new DC::UI::Label text => "Progress"), |
530 | 7, 0, (new DC::UI::Label text => "Skill", expand => 1), |
541 | 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), |
531 | ]; |
542 | ]; |
532 | |
543 | |
533 | my @add = @$sw; |
544 | my @add = @$sw; |
534 | |
545 | |
535 | my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; |
546 | my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; |
… | |
… | |
574 | |
585 | |
575 | # progress |
586 | # progress |
576 | (new DC::UI::ExperienceProgress), |
587 | (new DC::UI::ExperienceProgress), |
577 | |
588 | |
578 | # label |
589 | # label |
579 | (new DC::UI::Label text => $name, on_button_down => $spell_cb, |
590 | (new DC::UI::Label text => $name, on_button_down => $spell_cb, align => 0, |
580 | can_events => 1, can_hover => 1, tooltip => (DC::Pod::section_label skill_description => $name) . $TOOLTIP_ALL), |
591 | can_events => 1, can_hover => 1, tooltip => (DC::Pod::section_label skill_description => $name) . $TOOLTIP_ALL), |
581 | ]; |
592 | ]; |
582 | |
593 | |
583 | push @add, |
594 | push @add, |
584 | $x * 4 + 0, $y, $sw->[0], |
595 | $x * 4 + 0, $y, $sw->[0], |
… | |
… | |
1019 | s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&/g; |
1030 | s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&/g; |
1020 | |
1031 | |
1021 | # handle some elements |
1032 | # handle some elements |
1022 | s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs; |
1033 | s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs; |
1023 | s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs; |
1034 | s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs; |
|
|
1035 | |
|
|
1036 | s/\s+$//; |
1024 | |
1037 | |
1025 | $_ |
1038 | $_ |
1026 | } |
1039 | } |
1027 | |
1040 | |
1028 | our %NAME_TO_COLOR = ( |
1041 | our %NAME_TO_COLOR = ( |
… | |
… | |
1134 | |
1147 | |
1135 | my %skill_help; |
1148 | my %skill_help; |
1136 | |
1149 | |
1137 | for my $node (DC::Pod::find skill_description => "*") { |
1150 | for my $node (DC::Pod::find skill_description => "*") { |
1138 | my (undef, @par) = DC::Pod::section_of $node; |
1151 | my (undef, @par) = DC::Pod::section_of $node; |
1139 | $skill_help{$node->{kw}[0]} = DC::Pod::as_label @par; |
1152 | $skill_help{$node->[DC::Pod::N_KW][0]} = DC::Pod::as_label @par; |
1140 | }; |
1153 | }; |
1141 | |
1154 | |
1142 | for my $skill (values %{$self->{skill_info}}) { |
1155 | for my $skill (values %{$self->{skill_info}}) { |
1143 | $self->{map_widget}->add_command ("ready_skill $skill", |
1156 | $self->{map_widget}->add_command ("ready_skill $skill", |
1144 | (DC::asxml "Ready the skill '$skill'\n\n") |
1157 | (DC::asxml "Ready the skill '$skill'\n\n") |
… | |
… | |
1164 | $::FLOORBOX->clear; |
1177 | $::FLOORBOX->clear; |
1165 | |
1178 | |
1166 | my @add; |
1179 | my @add; |
1167 | |
1180 | |
1168 | my $row; |
1181 | my $row; |
1169 | for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { |
1182 | for (sort { $b->{count} <=> $a->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { |
|
|
1183 | next if $_->{tag} & 0x80000000; |
1170 | if ($row < 6) { |
1184 | if ($row < 6) { |
1171 | local $_->{face_widget}; # hack to force recreation of widget |
1185 | local $_->{face_widget}; # hack to force recreation of widget |
1172 | local $_->{desc_widget}; # hack to force recreation of widget |
1186 | local $_->{desc_widget}; # hack to force recreation of widget |
1173 | DC::Item::update_widgets $_; |
1187 | DC::Item::update_widgets $_; |
1174 | |
1188 | |
… | |
… | |
1201 | sub set_opencont { |
1215 | sub set_opencont { |
1202 | my ($conn, $tag, $name) = @_; |
1216 | my ($conn, $tag, $name) = @_; |
1203 | $conn->{open_container} = $tag; |
1217 | $conn->{open_container} = $tag; |
1204 | update_floorbox; |
1218 | update_floorbox; |
1205 | |
1219 | |
1206 | $::INVR_HB->clear (); |
1220 | $::INVR_HB->clear; |
1207 | $::INVR_HB->add (new DC::UI::Label align => 0, expand => 1, text => $name); |
1221 | $::INVR_HB->add (new DC::UI::Label expand => 1, text => $name); |
1208 | |
1222 | |
1209 | if ($tag != 0) { # Floor isn't closable, is it? |
1223 | if ($tag != 0) { # Floor isn't closable, is it? |
1210 | $::INVR_HB->add (new DC::UI::Button |
1224 | $::INVR_HB->add (new DC::UI::Button |
1211 | text => "Close container", |
1225 | text => "Close container", |
1212 | tooltip => "Close the currently open container (if one is open)", |
1226 | tooltip => "Close the currently open container (if one is open)", |
… | |
… | |
1267 | } |
1281 | } |
1268 | |
1282 | |
1269 | sub item_update { |
1283 | sub item_update { |
1270 | my ($self, $item) = @_; |
1284 | my ($self, $item) = @_; |
1271 | |
1285 | |
1272 | #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n"; |
1286 | #print "item_update: $item->{tag} in $item->{container} pt($self->{player}{tag}) oc($::CONN->{open_container}) f($item->{flags})\n"; |
1273 | |
1287 | |
1274 | DC::Item::update_widgets $item; |
1288 | DC::Item::update_widgets $item; |
1275 | |
1289 | |
1276 | if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { |
1290 | if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { |
1277 | set_opencont ($::CONN, 0, "Floor"); |
1291 | set_opencont ($::CONN, 0, "Floor"); |
1278 | |
1292 | |
1279 | } elsif ($item->{flags} & F_OPEN) { |
1293 | } elsif ($item->{flags} & F_OPEN) { |
1280 | set_opencont ($::CONN, $item->{tag}, DC::Item::desc_string $item); |
1294 | set_opencont ($::CONN, $item->{tag}, DC::Item::desc_string $item); |
… | |
… | |
1296 | |
1310 | |
1297 | my $weight = .001 * $self->{player}{weight}; |
1311 | my $weight = .001 * $self->{player}{weight}; |
1298 | my $limit = .001 * $self->{stat}{+CS_STAT_WEIGHT_LIM}; |
1312 | my $limit = .001 * $self->{stat}{+CS_STAT_WEIGHT_LIM}; |
1299 | |
1313 | |
1300 | $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $weight); |
1314 | $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $weight); |
1301 | $::STATWIDS->{m_weight}->set_text (sprintf "%.1fkg", $limit); |
1315 | $::STATWIDS->{m_weight}->set_text (sprintf "Max Weight: %.1fkg", $limit); |
1302 | $::STATWIDS->{i_weight}->set_text (sprintf "%.1f/%.1fkg", $weight, $limit); |
1316 | $::STATWIDS->{i_weight}->set_text (sprintf "%.1f/%.1fkg", $weight, $limit); |
1303 | } |
1317 | } |
1304 | |
1318 | |
1305 | sub update_server_info { |
1319 | sub update_server_info { |
1306 | my ($self) = @_; |
1320 | my ($self) = @_; |
… | |
… | |
1314 | . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" |
1328 | . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" |
1315 | . "examine command support $yesno[$self->{setup}{excmd} > 0]\n" |
1329 | . "examine command support $yesno[$self->{setup}{excmd} > 0]\n" |
1316 | . "editing support $yesno[!!$self->{editor_support}]\n" |
1330 | . "editing support $yesno[!!$self->{editor_support}]\n" |
1317 | . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" |
1331 | . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" |
1318 | . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n" |
1332 | . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n" |
1319 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]" |
1333 | . "client support $yesno[$self->{cfplus_ext} > 0]" |
1320 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
1334 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
1321 | . "map size $self->{mapw}×$self->{maph}\n" |
1335 | . "map size $self->{mapw}×$self->{maph}\n" |
1322 | ); |
1336 | ); |
1323 | |
1337 | |
1324 | } |
1338 | } |