… | |
… | |
19 | |
19 | |
20 | my $self = $class->SUPER::new (%arg, |
20 | my $self = $class->SUPER::new (%arg, |
21 | setup_req => { |
21 | setup_req => { |
22 | extmap => 1, |
22 | extmap => 1, |
23 | excmd => 1, |
23 | excmd => 1, |
24 | widget => 1, |
24 | widget => 2, |
25 | %{$arg{setup_req} || {}}, |
25 | %{$arg{setup_req} || {}}, |
26 | }, |
26 | }, |
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 { |
… | |
… | |
102 | } |
102 | } |
103 | |
103 | |
104 | sub ext_capabilities { |
104 | sub ext_capabilities { |
105 | my ($self, %cap) = @_; |
105 | my ($self, %cap) = @_; |
106 | |
106 | |
107 | #$self->send ("setup sound 0"); # we use a different protocol |
|
|
108 | $self->update_fx_want; |
107 | $self->update_fx_want; |
109 | |
108 | |
110 | $self->send_exti_req (resource => "exp_table", sub { |
109 | $self->send_exti_req (resource => "exp_table", sub { |
111 | my ($exp_table) = @_; |
110 | my ($exp_table) = @_; |
112 | |
111 | |
… | |
… | |
191 | $ws, $id => scalar eval { |
190 | $ws, $id => scalar eval { |
192 | local $SIG{__DIE__}; |
191 | local $SIG{__DIE__}; |
193 | "DC::UI::$class"->new (%$args) |
192 | "DC::UI::$class"->new (%$args) |
194 | } |
193 | } |
195 | ); |
194 | ); |
|
|
195 | } |
|
|
196 | |
|
|
197 | # widgetset create template |
|
|
198 | sub ext_ws_ct { |
|
|
199 | my ($self, $ws, $type, $template, $done_cb, $cfg) = @_; |
|
|
200 | |
|
|
201 | $done_cb ||= sub { }; |
|
|
202 | |
|
|
203 | my $parse_list; $parse_list = sub { |
|
|
204 | my ($list) = @_; |
|
|
205 | my @w; |
|
|
206 | |
|
|
207 | while (@$list) { |
|
|
208 | my ($class, $args) = splice @$list, 0, 2; |
|
|
209 | my $name = delete $args->{s_id}; |
|
|
210 | my $cl = delete $args->{s_cl}; |
|
|
211 | my $cfg = delete $cfg->{$name}; |
|
|
212 | my $id = delete $cfg->{id}; |
|
|
213 | my $w = eval { "DC::UI::$class"->new (%$args, %{ $cfg || {} }) } |
|
|
214 | or next; |
|
|
215 | |
|
|
216 | $self->widget_associate ($ws, $id, $w) |
|
|
217 | if $id; |
|
|
218 | |
|
|
219 | $w->add ($parse_list->($cl)) |
|
|
220 | if $cl; |
|
|
221 | |
|
|
222 | push @w, $w; |
|
|
223 | } |
|
|
224 | |
|
|
225 | @w |
|
|
226 | }; |
|
|
227 | |
|
|
228 | # either array reference, or face # |
|
|
229 | if ($type eq "inline") { |
|
|
230 | $done_cb->(); |
|
|
231 | $parse_list->($template); |
|
|
232 | } elsif ($type eq "face") { |
|
|
233 | my $handler; $handler = $self->register_face_handler ($template, sub { |
|
|
234 | my ($face) = @_; |
|
|
235 | |
|
|
236 | undef $handler; |
|
|
237 | $done_cb->(); |
|
|
238 | $parse_list->($self->{json_coder}->decode ($face->{data})); |
|
|
239 | }); |
|
|
240 | } else { |
|
|
241 | $done_cb->(0); |
|
|
242 | } |
196 | } |
243 | } |
197 | |
244 | |
198 | # widgetset associate |
245 | # widgetset associate |
199 | sub ext_ws_a { |
246 | sub ext_ws_a { |
200 | my ($self, %ass) = @_; |
247 | my ($self, %ass) = @_; |
… | |
… | |
228 | spell_list => $::SPELL_LIST, |
275 | spell_list => $::SPELL_LIST, |
229 | |
276 | |
230 | floorbox => $::FLOORBOX, |
277 | floorbox => $::FLOORBOX, |
231 | help_window => $::HELP_WINDOW, |
278 | help_window => $::HELP_WINDOW, |
232 | message_window => $::MESSAGE_WINDOW, |
279 | message_window => $::MESSAGE_WINDOW, |
|
|
280 | message_dist => $::MESSAGE_DIST, |
233 | statusbox => $::SDTATUSBOX, |
281 | statusbox => $::SDTATUSBOX, |
234 | |
282 | |
235 | inv => $::INV, |
283 | inv => $::INV, |
236 | invr => $::INVR, |
284 | invr => $::INVR, |
237 | invr_hb => $::INVR_HB, |
285 | invr_hb => $::INVR_HB, |
… | |
… | |
286 | |
334 | |
287 | # message window |
335 | # message window |
288 | sub ext_channel_info { |
336 | sub ext_channel_info { |
289 | my ($self, $info) = @_; |
337 | my ($self, $info) = @_; |
290 | $self->{channels}->{$info->{id}} = $info; |
338 | $self->{channels}->{$info->{id}} = $info; |
291 | $::MESSAGE_WINDOW->add_channel ($info); |
339 | $::MESSAGE_DIST->add_channel ($info); |
292 | } |
340 | } |
293 | |
341 | |
294 | ############################################################################# |
342 | ############################################################################# |
295 | |
343 | |
296 | sub logprint { |
344 | sub logprint { |
… | |
… | |
478 | $sktbl->clear; |
526 | $sktbl->clear; |
479 | |
527 | |
480 | my $sw = $self->{skillwid}{""} ||= [ |
528 | my $sw = $self->{skillwid}{""} ||= [ |
481 | 0, 0, (new DC::UI::Label text => "Experience", align => 1), |
529 | 0, 0, (new DC::UI::Label text => "Experience", align => 1), |
482 | 1, 0, (new DC::UI::Label text => "Lvl.", align => 1), |
530 | 1, 0, (new DC::UI::Label text => "Lvl.", align => 1), |
483 | 2, 0, (new DC::UI::Label text => "Progress", align => 0), |
531 | 2, 0, (new DC::UI::Label text => "Progress"), |
484 | 3, 0, (new DC::UI::Label text => "Skill", expand => 1), |
532 | 3, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), |
485 | 4, 0, (new DC::UI::Label text => "Experience", align => 1), |
533 | 4, 0, (new DC::UI::Label text => "Experience", align => 1), |
486 | 5, 0, (new DC::UI::Label text => "Lvl.", align => 1), |
534 | 5, 0, (new DC::UI::Label text => "Lvl.", align => 1), |
487 | 6, 0, (new DC::UI::Label text => "Progress", align => 0), |
535 | 6, 0, (new DC::UI::Label text => "Progress"), |
488 | 7, 0, (new DC::UI::Label text => "Skill", expand => 1), |
536 | 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), |
489 | ]; |
537 | ]; |
490 | |
538 | |
491 | my @add = @$sw; |
539 | my @add = @$sw; |
492 | |
540 | |
493 | my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; |
541 | my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; |
… | |
… | |
532 | |
580 | |
533 | # progress |
581 | # progress |
534 | (new DC::UI::ExperienceProgress), |
582 | (new DC::UI::ExperienceProgress), |
535 | |
583 | |
536 | # label |
584 | # label |
537 | (new DC::UI::Label text => $name, on_button_down => $spell_cb, |
585 | (new DC::UI::Label text => $name, on_button_down => $spell_cb, align => 0, |
538 | can_events => 1, can_hover => 1, tooltip => (DC::Pod::section_label skill_description => $name) . $TOOLTIP_ALL), |
586 | can_events => 1, can_hover => 1, tooltip => (DC::Pod::section_label skill_description => $name) . $TOOLTIP_ALL), |
539 | ]; |
587 | ]; |
540 | |
588 | |
541 | push @add, |
589 | push @add, |
542 | $x * 4 + 0, $y, $sw->[0], |
590 | $x * 4 + 0, $y, $sw->[0], |
… | |
… | |
977 | s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&/g; |
1025 | s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&/g; |
978 | |
1026 | |
979 | # handle some elements |
1027 | # handle some elements |
980 | s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs; |
1028 | s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs; |
981 | s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs; |
1029 | s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs; |
|
|
1030 | |
|
|
1031 | s/\s+$//; |
982 | |
1032 | |
983 | $_ |
1033 | $_ |
984 | } |
1034 | } |
985 | |
1035 | |
986 | our %NAME_TO_COLOR = ( |
1036 | our %NAME_TO_COLOR = ( |
… | |
… | |
1092 | |
1142 | |
1093 | my %skill_help; |
1143 | my %skill_help; |
1094 | |
1144 | |
1095 | for my $node (DC::Pod::find skill_description => "*") { |
1145 | for my $node (DC::Pod::find skill_description => "*") { |
1096 | my (undef, @par) = DC::Pod::section_of $node; |
1146 | my (undef, @par) = DC::Pod::section_of $node; |
1097 | $skill_help{$node->{kw}[0]} = DC::Pod::as_label @par; |
1147 | $skill_help{$node->[DC::Pod::N_KW][0]} = DC::Pod::as_label @par; |
1098 | }; |
1148 | }; |
1099 | |
1149 | |
1100 | for my $skill (values %{$self->{skill_info}}) { |
1150 | for my $skill (values %{$self->{skill_info}}) { |
1101 | $self->{map_widget}->add_command ("ready_skill $skill", |
1151 | $self->{map_widget}->add_command ("ready_skill $skill", |
1102 | (DC::asxml "Ready the skill '$skill'\n\n") |
1152 | (DC::asxml "Ready the skill '$skill'\n\n") |
… | |
… | |
1122 | $::FLOORBOX->clear; |
1172 | $::FLOORBOX->clear; |
1123 | |
1173 | |
1124 | my @add; |
1174 | my @add; |
1125 | |
1175 | |
1126 | my $row; |
1176 | my $row; |
1127 | for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { |
1177 | for (sort { $b->{count} <=> $a->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { |
|
|
1178 | next if $_->{tag} & 0x80000000; |
1128 | if ($row < 6) { |
1179 | if ($row < 6) { |
1129 | local $_->{face_widget}; # hack to force recreation of widget |
1180 | local $_->{face_widget}; # hack to force recreation of widget |
1130 | local $_->{desc_widget}; # hack to force recreation of widget |
1181 | local $_->{desc_widget}; # hack to force recreation of widget |
1131 | DC::Item::update_widgets $_; |
1182 | DC::Item::update_widgets $_; |
1132 | |
1183 | |
… | |
… | |
1160 | my ($conn, $tag, $name) = @_; |
1211 | my ($conn, $tag, $name) = @_; |
1161 | $conn->{open_container} = $tag; |
1212 | $conn->{open_container} = $tag; |
1162 | update_floorbox; |
1213 | update_floorbox; |
1163 | |
1214 | |
1164 | $::INVR_HB->clear (); |
1215 | $::INVR_HB->clear (); |
1165 | $::INVR_HB->add (new DC::UI::Label align => 0, expand => 1, text => $name); |
1216 | $::INVR_HB->add (new DC::UI::Label expand => 1, text => $name); |
1166 | |
1217 | |
1167 | if ($tag != 0) { # Floor isn't closable, is it? |
1218 | if ($tag != 0) { # Floor isn't closable, is it? |
1168 | $::INVR_HB->add (new DC::UI::Button |
1219 | $::INVR_HB->add (new DC::UI::Button |
1169 | text => "Close container", |
1220 | text => "Close container", |
1170 | tooltip => "Close the currently open container (if one is open)", |
1221 | tooltip => "Close the currently open container (if one is open)", |
… | |
… | |
1225 | } |
1276 | } |
1226 | |
1277 | |
1227 | sub item_update { |
1278 | sub item_update { |
1228 | my ($self, $item) = @_; |
1279 | my ($self, $item) = @_; |
1229 | |
1280 | |
1230 | #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n"; |
1281 | #print "item_update: $item->{tag} in $item->{container} pt($self->{player}{tag}) oc($::CONN->{open_container}) f($item->{flags})\n"; |
1231 | |
1282 | |
1232 | DC::Item::update_widgets $item; |
1283 | DC::Item::update_widgets $item; |
1233 | |
1284 | |
1234 | if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { |
1285 | if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { |
1235 | set_opencont ($::CONN, 0, "Floor"); |
1286 | set_opencont ($::CONN, 0, "Floor"); |
1236 | |
1287 | |
1237 | } elsif ($item->{flags} & F_OPEN) { |
1288 | } elsif ($item->{flags} & F_OPEN) { |
1238 | set_opencont ($::CONN, $item->{tag}, DC::Item::desc_string $item); |
1289 | set_opencont ($::CONN, $item->{tag}, DC::Item::desc_string $item); |
… | |
… | |
1254 | |
1305 | |
1255 | my $weight = .001 * $self->{player}{weight}; |
1306 | my $weight = .001 * $self->{player}{weight}; |
1256 | my $limit = .001 * $self->{stat}{+CS_STAT_WEIGHT_LIM}; |
1307 | my $limit = .001 * $self->{stat}{+CS_STAT_WEIGHT_LIM}; |
1257 | |
1308 | |
1258 | $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $weight); |
1309 | $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $weight); |
1259 | $::STATWIDS->{m_weight}->set_text (sprintf "%.1fkg", $limit); |
1310 | $::STATWIDS->{m_weight}->set_text (sprintf "Max Weight: %.1fkg", $limit); |
1260 | $::STATWIDS->{i_weight}->set_text (sprintf "%.1f/%.1fkg", $weight, $limit); |
1311 | $::STATWIDS->{i_weight}->set_text (sprintf "%.1f/%.1fkg", $weight, $limit); |
1261 | } |
1312 | } |
1262 | |
1313 | |
1263 | sub update_server_info { |
1314 | sub update_server_info { |
1264 | my ($self) = @_; |
1315 | my ($self) = @_; |
… | |
… | |
1272 | . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" |
1323 | . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" |
1273 | . "examine command support $yesno[$self->{setup}{excmd} > 0]\n" |
1324 | . "examine command support $yesno[$self->{setup}{excmd} > 0]\n" |
1274 | . "editing support $yesno[!!$self->{editor_support}]\n" |
1325 | . "editing support $yesno[!!$self->{editor_support}]\n" |
1275 | . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" |
1326 | . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" |
1276 | . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n" |
1327 | . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n" |
1277 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]" |
1328 | . "client support $yesno[$self->{cfplus_ext} > 0]" |
1278 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
1329 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
1279 | . "map size $self->{mapw}×$self->{maph}\n" |
1330 | . "map size $self->{mapw}×$self->{maph}\n" |
1280 | ); |
1331 | ); |
1281 | |
1332 | |
1282 | } |
1333 | } |