ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/cfplus
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/cfplus (file contents):
Revision 1.102 by root, Mon Jul 24 04:24:43 2006 UTC vs.
Revision 1.103 by root, Mon Jul 24 08:23:28 2006 UTC

43use CFClient::MapWidget; 43use CFClient::MapWidget;
44 44
45$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 45$SIG{QUIT} = sub { Carp::cluck "QUIT" };
46$SIG{PIPE} = 'IGNORE'; 46$SIG{PIPE} = 'IGNORE';
47 47
48$Event::Eval = 0;
48$Event::DIED = sub { 49$Event::DIED = sub {
49 # TODO: display dialog box or so 50 # TODO: display dialog box or so
50 Carp::confess $_[1];#d#TODO: remove when stable 51 Carp::cluck $_[1];#d#TODO: remove when stable
51 CFClient::error $_[1]; 52 CFClient::error $_[1];
52}; 53};
53 54
54#$SIG{__WARN__} = sub { Carp::cluck $_[0] };#d# 55$SIG{__DIE__} = sub {
56 return if CFClient::in_destruct;
57 Carp::cluck $_[0];
58 CFClient::error $_[0];
59 return;#d#
60 #return unless defined $^S && !$^S;
61 $Event::DIED->(undef, $_[0]);
62};
55 63
56our $VERSION = '0.1'; 64our $VERSION = '0.1';
57 65
58my $MAX_FPS = 60; 66my $MAX_FPS = 60;
59my $MIN_FPS = 5; # unused as of yet 67my $MIN_FPS = 5; # unused as of yet
1479 $refresh->(); 1487 $refresh->();
1480 1488
1481 $vb 1489 $vb
1482} 1490}
1483 1491
1484# just weirdness, pls. ignore
1485sub load_html_page {
1486 my ($viewer, $base) = @_;
1487
1488 $viewer->clear;
1489
1490 require LWP::Simple;
1491 require HTML::Parser;
1492 require URI;
1493
1494 my $page = LWP::Simple::get ($base)
1495 or return;
1496
1497 my @s = { };
1498 my %passthrough = map ($_ => undef), qw(b i u s tt big small sub sup);
1499
1500 my $parser = HTML::Parser->new (
1501 text_h => [sub {
1502 my ($text) = @_;
1503 $text =~ s/\s+/ /g;
1504 $s[-1]{text} .= CFClient::asxml $text;
1505 }, "dtext"],
1506 start_h => [sub {
1507 my ($tag, $attr) = @_;
1508 if ($passthrough{$tag}) {
1509 $s[-1]{text} .= "<$tag>";
1510 } elsif ($tag eq "h1") {
1511 push @s, { text => "<span foreground='#ffff00' size='x-large'>" };
1512 } elsif ($tag eq "h2") {
1513 push @s, { text => "<span foreground='#ccccff' size='large'>" };
1514 } elsif ($tag eq "h3") {
1515 push @s, { text => "<span size='large'>" };
1516 } elsif ($tag eq "a") {
1517 push @s, { text => "", url => $attr->{href} };
1518 } elsif ($tag eq "p") {
1519 push @s, { };
1520 } elsif ($tag eq "img") {
1521 eval {
1522 push @{$s[-1]{obj}}, new CFClient::UI::Image
1523 tex => (new_from_image CFClient::Texture LWP::Simple::get (URI->new ($attr->{src}, $base)->abs ($base)));
1524 $s[-1]{text} .= "\x{fffc}";
1525 };
1526 }
1527 }, "tagname, attr"],
1528 end_h => [sub {
1529 my ($tag) = @_;
1530 if ($passthrough{$tag}) {
1531 $s[-1]{text} .= "</$tag>";
1532 } elsif ($tag =~ /^h\d$/) {
1533 $s[-1]{text} .= "</span>";
1534 push @s, { };
1535 } elsif ($tag eq "a") {
1536 my $S = pop @s;
1537 $s[-1]{text} .= "\x{fffc}";
1538 push @{$s[-1]{obj}}, new CFClient::UI::Label
1539 fg => [0.8, 0.8, 1],
1540 markup => "<u>$S->{text}</u>",
1541 fontsize => 0.8,
1542 can_events => 1,
1543 can_focus => 1,
1544 on_button_up => sub {
1545 load_html_page ($viewer, URI->new ($S->{url}, $base)->abs ($base));
1546 },
1547 ;
1548 }
1549 }, "tagname"],
1550 );
1551
1552 $parser->parse ($page);
1553 $parser->eof;
1554
1555 $viewer->add_paragraph ([1, 1, 1, 1], [$_->{text}, @{ $_->{obj} || [] }], $_->{indent})
1556 for @s;
1557
1558 $viewer->set_offset (0);
1559}
1560
1561sub help_window { 1492sub help_window {
1562 my $win = new CFClient::UI::FancyFrame 1493 my $win = new CFClient::UI::FancyFrame
1563 x => 'center', 1494 x => 'center',
1564 y => 'center', 1495 y => 'center',
1565 z => 2, 1496 z => 2,
1583 [manual => "Main Manual"], 1514 [manual => "Main Manual"],
1584 [skill_help => "Skill Reference"], 1515 [skill_help => "Skill Reference"],
1585 [command_help => "Command Reference"], 1516 [command_help => "Command Reference"],
1586 [dmcommand_help => "DM Commands"], 1517 [dmcommand_help => "DM Commands"],
1587 [COPYING => "License Terms"], 1518 [COPYING => "License Terms"],
1588 [test => "test (do not select)"], #d#TODO
1589 ], 1519 ],
1590 on_changed => sub { 1520 on_changed => sub {
1591 my ($self, $pod) = @_; 1521 my ($self, $pod) = @_;
1592 1522
1593 if ($pod eq "test") {#d#TODO
1594 eval {
1595 load_html_page $viewer, "http://crossfire.real-time.com/guides/walkthrough/newbie-tower.html";
1596 };
1597 warn "$@" if $@;
1598 return;
1599 }
1600
1601 my $pom = CFClient::Pod::load CFClient::find_rcfile "pod/$pod.pod",
1602 doc_viewer => 1, sub { CFClient::Pod::as_paragraphs $_[0] };
1603
1604 #use Data::Dumper; warn Dumper $pom;#d#
1605
1606 $viewer->clear; 1523 $viewer->clear;
1607 1524 $viewer->add_paragraph (@{ CFClient::Pod::pod_paragraphs $pod });
1608# $viewer->add_paragraph ([1, 1, 1, 1], ["<big>Test</big>\n\n \x{fffc} \x{fffc}\n",
1609# (new CFClient::UI::Image path => "x.png", can_hover => 1, can_events => 1),
1610# (new CFClient::UI::Label text => "üüüü", can_hover => 1, can_events => 1, tooltip => "??"),
1611# ]);#d#
1612
1613 $viewer->add_paragraph ([1, 1, 1, 1], [$_->{text}, @{ $_->{obj} || [] }], $_->{indent})
1614 for @$pom;
1615
1616 $viewer->set_offset (0); 1525 $viewer->set_offset (0);
1617 1526
1618 0 1527 0
1619 }, 1528 },
1620 on_visibility_change => sub { 1529 on_visibility_change => sub {
1964############################################################################# 1873#############################################################################
1965 1874
1966$SIG{INT} = $SIG{TERM} = sub { exit }; 1875$SIG{INT} = $SIG{TERM} = sub { exit };
1967 1876
1968{ 1877{
1969 local $SIG{__DIE__} = sub {
1970 return unless defined $^S && !$^S;
1971 Carp::confess $_[0];#d#TODO: remove when stable
1972 CFClient::fatal $_[0];
1973 };
1974
1975 CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc"; 1878 CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc";
1976 CFClient::UI::set_layout ($::CFG->{layout}); 1879 CFClient::UI::set_layout ($::CFG->{layout});
1977 1880
1978 my %DEF_CFG = ( 1881 my %DEF_CFG = (
1979 sdl_mode => 0, 1882 sdl_mode => 0,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines