… | |
… | |
1505 | |
1505 | |
1506 | $vbox->add (my $buttons = new CFPlus::UI::HBox); |
1506 | $vbox->add (my $buttons = new CFPlus::UI::HBox); |
1507 | $vbox->add (my $viewer = new CFPlus::UI::TextScroller |
1507 | $vbox->add (my $viewer = new CFPlus::UI::TextScroller |
1508 | expand => 1, fontsize => 0.8, padding_x => 4); |
1508 | expand => 1, fontsize => 0.8, padding_x => 4); |
1509 | |
1509 | |
1510 | $buttons->add (new CFPlus::UI::Label text => "Choose a document to display: "); |
1510 | my @history; |
1511 | $buttons->add (my $combo = new CFPlus::UI::Selector |
1511 | my @future; |
1512 | value => undef, |
1512 | my $curnode; |
1513 | options => [ |
1513 | |
1514 | [intro => "Introduction"], |
1514 | my $load_node; $load_node = sub { |
1515 | [manual => "Main Manual"], |
1515 | my ($node) = @_; |
1516 | [skill_help => "Skill Reference"], |
1516 | |
1517 | [command_help => "Command Reference"], |
1517 | $buttons->clear; |
1518 | [dmcommand_help => "DM Commands"], |
1518 | |
1519 | [COPYING => "License Terms"], |
1519 | if (@history) { |
|
|
1520 | $buttons->add (new CFPlus::UI::Button |
|
|
1521 | text => "<", |
|
|
1522 | tooltip => "back to " . CFPlus::Pod::full_path_of $history[-1], |
|
|
1523 | on_activate => sub { |
|
|
1524 | unshift @future, $curnode if $curnode; |
|
|
1525 | $load_node->(pop @history); |
|
|
1526 | }); |
1520 | ], |
1527 | } |
1521 | on_changed => sub { |
|
|
1522 | my ($self, $pod) = @_; |
|
|
1523 | |
1528 | |
|
|
1529 | if (@future) { |
|
|
1530 | $buttons->add (new CFPlus::UI::Button |
|
|
1531 | text => ">", |
|
|
1532 | tooltip => "forward to " . CFPlus::Pod::full_path_of $future[0], |
|
|
1533 | on_activate => sub { |
|
|
1534 | push @history, $curnode; |
|
|
1535 | $load_node->(shift @future); |
|
|
1536 | }); |
|
|
1537 | } |
|
|
1538 | |
|
|
1539 | $curnode = $node; |
|
|
1540 | |
1524 | $viewer->clear; |
1541 | $viewer->clear; |
1525 | $viewer->add_paragraph (CFPlus::Pod::section_paragraphs pod => $pod); |
1542 | $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $curnode); |
1526 | $viewer->set_offset (0); |
1543 | $viewer->set_offset (0); |
1527 | |
|
|
1528 | 0 |
|
|
1529 | }, |
|
|
1530 | on_visibility_change => sub { |
|
|
1531 | my ($self, $visible) = @_; |
|
|
1532 | return unless $visible; |
|
|
1533 | return if $self->{value}; |
|
|
1534 | $self->set_value ("intro"); |
|
|
1535 | 0 |
|
|
1536 | }, |
|
|
1537 | ); |
1544 | }; |
|
|
1545 | |
|
|
1546 | $load_node->(CFPlus::Pod::find pod => "mainpage"); |
|
|
1547 | |
|
|
1548 | $CFPlus::Pod::on_link = sub { |
|
|
1549 | my (@path) = @_; |
|
|
1550 | |
|
|
1551 | push @history, $curnode if $curnode; |
|
|
1552 | @future = (); |
|
|
1553 | |
|
|
1554 | $load_node->(CFPlus::Pod::find @path); |
|
|
1555 | $win->show; |
|
|
1556 | }; |
1538 | |
1557 | |
1539 | $win |
1558 | $win |
1540 | } |
1559 | } |
1541 | |
1560 | |
1542 | sub sdl_init { |
1561 | sub sdl_init { |