… | |
… | |
644 | |
644 | |
645 | $table |
645 | $table |
646 | } |
646 | } |
647 | |
647 | |
648 | sub stats_window { |
648 | sub stats_window { |
|
|
649 | my $r = |
|
|
650 | new CFClient::UI::ScrolledWindow ( |
|
|
651 | expand => 1, |
|
|
652 | scroll_y => 1 |
|
|
653 | ); |
649 | my $vb = new CFClient::UI::VBox; |
654 | $r->add (my $vb = new CFClient::UI::VBox); |
650 | |
655 | |
651 | $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, |
656 | $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, |
652 | can_hover => 1, can_events => 1, |
657 | can_hover => 1, can_events => 1, |
653 | tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); |
658 | tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); |
654 | $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1, |
659 | $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1, |
… | |
… | |
773 | } |
778 | } |
774 | } |
779 | } |
775 | |
780 | |
776 | #update_stats_window ({}); |
781 | #update_stats_window ({}); |
777 | |
782 | |
778 | $vb |
783 | $r |
779 | } |
784 | } |
780 | |
785 | |
781 | sub skill_window { |
786 | sub skill_window { |
|
|
787 | my $sw = new CFClient::UI::ScrolledWindow (expand => 1); |
782 | $STATWIDS->{skill_tbl} = new CFClient::UI::Table expand => 1, col_expand => [0, 0, 1, 0, 0, 1] |
788 | $sw->add ($STATWIDS->{skill_tbl} = new CFClient::UI::Table expand => 1, col_expand => [0, 0, 1, 0, 0, 1]); |
|
|
789 | $sw |
783 | } |
790 | } |
784 | |
791 | |
785 | sub formsep($) { |
792 | sub formsep($) { |
786 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
793 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
787 | } |
794 | } |
… | |
… | |
1229 | sub inventory_widget { |
1236 | sub inventory_widget { |
1230 | my $hb = new CFClient::UI::HBox homogeneous => 1; |
1237 | my $hb = new CFClient::UI::HBox homogeneous => 1; |
1231 | |
1238 | |
1232 | $hb->add (my $vb1 = new CFClient::UI::VBox); |
1239 | $hb->add (my $vb1 = new CFClient::UI::VBox); |
1233 | $vb1->add (new CFClient::UI::Label align => 0, text => "Player"); |
1240 | $vb1->add (new CFClient::UI::Label align => 0, text => "Player"); |
|
|
1241 | $vb1->add (my $sw1 = new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1234 | $vb1->add ($INV = new CFClient::UI::Inventory); |
1242 | $sw1->add ($INV = new CFClient::UI::Inventory); |
1235 | |
1243 | |
1236 | $hb->add (my $vb2 = new CFClient::UI::VBox); |
1244 | $hb->add (my $vb2 = new CFClient::UI::VBox); |
1237 | |
1245 | |
1238 | $vb2->add ($INV_RIGHT_HB = new CFClient::UI::HBox); |
1246 | $vb2->add ($INV_RIGHT_HB = new CFClient::UI::HBox); |
1239 | |
1247 | |
|
|
1248 | $vb2->add (my $sw2 = new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1240 | $vb2->add ($INVR = new CFClient::UI::Inventory); |
1249 | $sw2->add ($INVR = new CFClient::UI::Inventory); |
1241 | |
1250 | |
1242 | # XXX: Call after $INVR = ... because set_opencont sets the items |
1251 | # XXX: Call after $INVR = ... because set_opencont sets the items |
1243 | CFClient::Protocol::set_opencont ($::CONN, 0, "Floor"); |
1252 | CFClient::Protocol::set_opencont ($::CONN, 0, "Floor"); |
1244 | |
1253 | |
1245 | $hb |
1254 | $hb |
… | |
… | |
1267 | has_close_button => 1 |
1276 | has_close_button => 1 |
1268 | ; |
1277 | ; |
1269 | |
1278 | |
1270 | my $ntb = |
1279 | my $ntb = |
1271 | $PL_NOTEBOOK = |
1280 | $PL_NOTEBOOK = |
1272 | new CFClient::UI::Notebook |
1281 | new CFClient::UI::Notebook expand => 1, debug => 1; |
1273 | expand => 1, |
|
|
1274 | debug => 1, |
|
|
1275 | filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1), |
|
|
1276 | ; |
|
|
1277 | |
1282 | |
1278 | $ntb->add ( |
1283 | $ntb->add ( |
1279 | "Statistics (F2)" => $STATS_PAGE = stats_window, |
1284 | "Statistics (F2)" => $STATS_PAGE = stats_window, |
1280 | "Shows statistics, where all your Stats and Resistances are shown." |
1285 | "Shows statistics, where all your Stats and Resistances are shown." |
1281 | ); |
1286 | ); |
1282 | $ntb->add ( |
1287 | $ntb->add ( |
1283 | "Skills (F3)" => $SKILL_PAGE = skill_window, |
1288 | "Skills (F3)" => $SKILL_PAGE = skill_window, |
1284 | "Shows all your Skills." |
1289 | "Shows all your Skills." |
1285 | ); |
1290 | ); |
|
|
1291 | |
|
|
1292 | my $spellsw = new CFClient::UI::ScrolledWindow (expand => 1, scroll_y => 1); |
|
|
1293 | $spellsw->add ($SPELL_PAGE = new CFClient::UI::SpellList); |
1286 | $ntb->add ( |
1294 | $ntb->add ( |
1287 | "Spellbook (F4)" => $SPELL_PAGE = new CFClient::UI::SpellList, |
1295 | "Spellbook (F4)" => $spellsw, |
1288 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
1296 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
1289 | ); |
1297 | ); |
1290 | $ntb->add ( |
1298 | $ntb->add ( |
1291 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1299 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1292 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1300 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
… | |
… | |
1409 | $refresh->(); |
1417 | $refresh->(); |
1410 | |
1418 | |
1411 | $vb |
1419 | $vb |
1412 | } |
1420 | } |
1413 | |
1421 | |
|
|
1422 | # just weirdness, pls. ignore |
|
|
1423 | sub load_html_page { |
|
|
1424 | my ($viewer, $base) = @_; |
|
|
1425 | |
|
|
1426 | $viewer->clear; |
|
|
1427 | |
|
|
1428 | require LWP::Simple; |
|
|
1429 | require HTML::Parser; |
|
|
1430 | require URI; |
|
|
1431 | |
|
|
1432 | my $page = LWP::Simple::get ($base) |
|
|
1433 | or return; |
|
|
1434 | |
|
|
1435 | my @s = { }; |
|
|
1436 | my %passthrough = map ($_ => undef), qw(b i u s tt big small sub sup); |
|
|
1437 | |
|
|
1438 | my $parser = HTML::Parser->new ( |
|
|
1439 | text_h => [sub { |
|
|
1440 | my ($text) = @_; |
|
|
1441 | $text =~ s/\s+/ /g; |
|
|
1442 | $s[-1]{text} .= CFClient::UI::Label::escape $text; |
|
|
1443 | }, "dtext"], |
|
|
1444 | start_h => [sub { |
|
|
1445 | my ($tag, $attr) = @_; |
|
|
1446 | if ($passthrough{$tag}) { |
|
|
1447 | $s[-1]{text} .= "<$tag>"; |
|
|
1448 | } elsif ($tag eq "h1") { |
|
|
1449 | push @s, { text => "<span foreground='#ffff00' size='x-large'>" }; |
|
|
1450 | } elsif ($tag eq "h2") { |
|
|
1451 | push @s, { text => "<span foreground='#ccccff' size='large'>" }; |
|
|
1452 | } elsif ($tag eq "h3") { |
|
|
1453 | push @s, { text => "<span size='large'>" }; |
|
|
1454 | } elsif ($tag eq "a") { |
|
|
1455 | push @s, { text => "", url => $attr->{href} }; |
|
|
1456 | } elsif ($tag eq "p") { |
|
|
1457 | push @s, { }; |
|
|
1458 | } elsif ($tag eq "img") { |
|
|
1459 | eval { |
|
|
1460 | push @{$s[-1]{obj}}, new CFClient::UI::Image |
|
|
1461 | tex => (new_from_image CFClient::Texture LWP::Simple::get (URI->new ($attr->{src}, $base)->abs ($base))); |
|
|
1462 | $s[-1]{text} .= "\x{fffc}"; |
|
|
1463 | }; |
|
|
1464 | } |
|
|
1465 | }, "tagname, attr"], |
|
|
1466 | end_h => [sub { |
|
|
1467 | my ($tag) = @_; |
|
|
1468 | if ($passthrough{$tag}) { |
|
|
1469 | $s[-1]{text} .= "</$tag>"; |
|
|
1470 | } elsif ($tag =~ /^h\d$/) { |
|
|
1471 | $s[-1]{text} .= "</span>"; |
|
|
1472 | push @s, { }; |
|
|
1473 | } elsif ($tag eq "a") { |
|
|
1474 | my $S = pop @s; |
|
|
1475 | $s[-1]{text} .= "\x{fffc}"; |
|
|
1476 | push @{$s[-1]{obj}}, new CFClient::UI::Label |
|
|
1477 | fg => [0.8, 0.8, 1], |
|
|
1478 | markup => "<u>$S->{text}</u>", |
|
|
1479 | fontsize => 0.8, |
|
|
1480 | can_events => 1, |
|
|
1481 | can_focus => 1, |
|
|
1482 | on_button_up => sub { |
|
|
1483 | load_html_page ($viewer, URI->new ($S->{url}, $base)->abs ($base)); |
|
|
1484 | }, |
|
|
1485 | ; |
|
|
1486 | } |
|
|
1487 | }, "tagname"], |
|
|
1488 | ); |
|
|
1489 | |
|
|
1490 | $parser->parse ($page); |
|
|
1491 | $parser->eof; |
|
|
1492 | |
|
|
1493 | $viewer->add_paragraph ([1, 1, 1, 1], [$_->{text}, @{ $_->{obj} || [] }], $_->{indent}) |
|
|
1494 | for @s; |
|
|
1495 | |
|
|
1496 | $viewer->set_offset (0); |
|
|
1497 | } |
|
|
1498 | |
1414 | sub help_window { |
1499 | sub help_window { |
1415 | my $win = new CFClient::UI::FancyFrame |
1500 | my $win = new CFClient::UI::FancyFrame |
1416 | x => 'center', |
1501 | x => 'center', |
1417 | y => 'center', |
1502 | y => 'center', |
1418 | z => 2, |
1503 | z => 2, |
… | |
… | |
1436 | [manual => "Main Manual"], |
1521 | [manual => "Main Manual"], |
1437 | [skill_help => "Skill Reference"], |
1522 | [skill_help => "Skill Reference"], |
1438 | [command_help => "Command Reference"], |
1523 | [command_help => "Command Reference"], |
1439 | [dmcommand_help => "DM Commands"], |
1524 | [dmcommand_help => "DM Commands"], |
1440 | [COPYING => "License Terms"], |
1525 | [COPYING => "License Terms"], |
|
|
1526 | [test => "test (do not select)"], #d#TODO |
1441 | ], |
1527 | ], |
1442 | on_changed => sub { |
1528 | on_changed => sub { |
1443 | my ($self, $pod) = @_; |
1529 | my ($self, $pod) = @_; |
|
|
1530 | |
|
|
1531 | if ($pod eq "test") {#d#TODO |
|
|
1532 | eval { |
|
|
1533 | load_html_page $viewer, "http://crossfire.real-time.com/guides/walkthrough/newbie-tower.html"; |
|
|
1534 | }; |
|
|
1535 | warn "$@" if $@; |
|
|
1536 | return; |
|
|
1537 | } |
1444 | |
1538 | |
1445 | my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", |
1539 | my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", |
1446 | doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; |
1540 | doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; |
1447 | |
1541 | |
1448 | $viewer->clear; |
1542 | $viewer->clear; |