--- deliantra/Deliantra-Client/bin/cfplus 2006/08/14 03:41:29 1.115
+++ deliantra/Deliantra-Client/bin/cfplus 2006/09/29 00:56:06 1.119
@@ -49,19 +49,11 @@
$Event::DIED = sub {
# TODO: display dialog box or so
Carp::cluck $_[1];#d#TODO: remove when stable
- CFPlus::error $_[1];
-};
-
-$SIG{__DIE__} = sub {
- return if CFPlus::in_destruct;
- Carp::cluck $_[0];
- CFPlus::error $_[0];
return;#d#
- #return unless defined $^S && !$^S;
- $Event::DIED->(undef, $_[0]);
+ CFPlus::fatal ($_[1]);
};
-our $VERSION = '0.1';
+our $VERSION = '0.9';
my $MAX_FPS = 60;
my $MIN_FPS = 5; # unused as of yet
@@ -369,6 +361,8 @@
mapw => $mapsize,
maph => $mapsize,
+ client => "cfplus $VERSION $] $^O",
+
map_widget => $MAPWIDGET,
logview => $LOGVIEW,
statusbox => $STATUSBOX,
@@ -1045,7 +1039,7 @@
$table->add (0, 12, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command");
$table->add (1, 12, my $saycmd = new CFPlus::UI::Entry
- text => $CFG->{say_command},
+ text => $CFG->{say_command},
tooltip => "This is the command that will be used if you write a line in the message window entry or press \" in the map window. "
. "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
. "But you could also set it to tell playername to only chat with that user.",
@@ -1056,6 +1050,17 @@
}
);
+ $table->add (0, 13, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day");
+ $table->add (1, 13, my $saycmd = new CFPlus::UI::CheckBox
+ state => $CFG->{show_tips},
+ tooltip => "Show the Tip of the day window at startup?",
+ on_changed => sub {
+ my ($self, $value) = @_;
+ $CFG->{shop_tips} = $value;
+ 0
+ }
+ );
+
$vbox->add (new CFPlus::UI::FancyFrame
label => "Server Info",
child => ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0),
@@ -1127,62 +1132,6 @@
$window
}
-sub open_string_query {
- my $cb = $_[1];
- my $dialog = new CFPlus::UI::Toplevel
- x => "center",
- y => "center",
- z => 50,
- force_w => $WIDTH * 4/5,
- title => $_[0];
-
- $dialog->add (
- my $e = new CFPlus::UI::Entry
- on_activate => sub { $cb->(@_); $dialog->hide; 0 },
- on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 },
- );
-
- $e->grab_focus;
- $dialog->show;
-}
-
-sub open_quit_dialog {
- unless ($QUIT_DIALOG) {
- $QUIT_DIALOG = new CFPlus::UI::Toplevel
- x => "center",
- y => "center",
- z => 50,
- title => "Really Quit?",
- on_key_down => sub {
- my ($dialog, $ev) = @_;
- $ev->{sym} == 27 and $dialog->hide;
- }
- ;
-
- $QUIT_DIALOG->add (my $vb = new CFPlus::UI::VBox expand => 1);
-
- $vb->add (new CFPlus::UI::Label
- text => "You should find a savebed and apply it first!",
- max_w => $WIDTH * 0.25,
- ellipsize => 0,
- );
- $vb->add (my $hb = new CFPlus::UI::HBox expand => 1);
- $hb->add (new CFPlus::UI::Button
- text => "Ok",
- expand => 1,
- on_activate => sub { $QUIT_DIALOG->hide; 0 },
- );
- $hb->add (new CFPlus::UI::Button
- text => "Quit anyway",
- expand => 1,
- on_activate => sub { exit },
- );
- }
-
- $QUIT_DIALOG->show;
- $QUIT_DIALOG->grab_focus;
-}
-
sub autopickup_setup {
my $table = new CFPlus::UI::Table;
@@ -1509,7 +1458,7 @@
my $win = new CFPlus::UI::Toplevel
x => 'center',
y => 'center',
- z => 2,
+ z => 4,
name => 'doc_browser',
force_w => int $WIDTH * 7/8,
force_h => int $HEIGHT * 7/8,
@@ -1534,10 +1483,21 @@
$buttons->clear;
+ $buttons->add (new CFPlus::UI::Button
+ text => "⇤",
+ tooltip => "back to the starting page",
+ on_activate => sub {
+ unshift @future, [$curnode, $viewer->current_paragraph] if $curnode;
+ unshift @future, @history;
+ @history = ();
+ $load_node->(@{shift @future});
+ },
+ );
+
if (@history) {
$buttons->add (new CFPlus::UI::Button
text => "⋘",
- tooltip => "back to " . (CFPlus::asxml CFPlus::Pod::full_path $history[-1]) . "",
+ tooltip => "back to " . (CFPlus::asxml CFPlus::Pod::full_path $history[-1][0]) . "",
on_activate => sub {
unshift @future, [$curnode, $viewer->current_paragraph] if $curnode;
$load_node->(@{pop @history});
@@ -1548,7 +1508,7 @@
if (@future) {
$buttons->add (new CFPlus::UI::Button
text => "⋙",
- tooltip => "forward to " . (CFPlus::asxml CFPlus::Pod::full_path $future[0]) . "",
+ tooltip => "forward to " . (CFPlus::asxml CFPlus::Pod::full_path $future[0][0]) . "",
on_activate => sub {
push @history, [$curnode, $viewer->current_paragraph];
$load_node->(@{shift @future});
@@ -1589,13 +1549,123 @@
push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = ();
- $load_node->(CFPlus::Pod::find @path);
+ $load_node->((CFPlus::Pod::find @path)[0]);
$win->show;
};
$win
}
+sub open_string_query {
+ my ($title, $cb, $txt, $tooltip) = @_;
+ my $dialog = new CFPlus::UI::Toplevel
+ x => "center",
+ y => "center",
+ z => 50,
+ force_w => $WIDTH * 4/5,
+ title => $title;
+
+ $dialog->add (
+ my $e = new CFPlus::UI::Entry
+ on_activate => sub { $cb->(@_); $dialog->hide; 0 },
+ on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 },
+ tooltip => $tooltip
+ );
+
+ $e->grab_focus;
+ $e->set_text ($txt) if $txt;
+ $dialog->show;
+}
+
+sub open_quit_dialog {
+ unless ($QUIT_DIALOG) {
+ $QUIT_DIALOG = new CFPlus::UI::Toplevel
+ x => "center",
+ y => "center",
+ z => 50,
+ title => "Really Quit?",
+ on_key_down => sub {
+ my ($dialog, $ev) = @_;
+ $ev->{sym} == 27 and $dialog->hide;
+ }
+ ;
+
+ $QUIT_DIALOG->add (my $vb = new CFPlus::UI::VBox expand => 1);
+
+ $vb->add (new CFPlus::UI::Label
+ text => "You should find a savebed and apply it first!",
+ max_w => $WIDTH * 0.25,
+ ellipsize => 0,
+ );
+ $vb->add (my $hb = new CFPlus::UI::HBox expand => 1);
+ $hb->add (new CFPlus::UI::Button
+ text => "Ok",
+ expand => 1,
+ on_activate => sub { $QUIT_DIALOG->hide; 0 },
+ );
+ $hb->add (new CFPlus::UI::Button
+ text => "Quit anyway",
+ expand => 1,
+ on_activate => sub { exit },
+ );
+ }
+
+ $QUIT_DIALOG->show;
+ $QUIT_DIALOG->grab_focus;
+}
+
+sub show_tip_of_the_day {
+ # find all tips
+ my @tod = CFPlus::Pod::find tip_of_the_day => "*";
+
+ my $todindex = $CFPlus::DB_STATE->get ("tip_of_the_day");
+ $todindex = 0 if $todindex >= @tod;
+ $CFPlus::DB_STATE->put (tip_of_the_day => $todindex + 1);
+
+ # create dialog
+ my $dialog;
+
+ my $close = sub {
+ $dialog->destroy;
+ };
+
+ $dialog = new CFPlus::UI::Toplevel
+ x => "center",
+ y => "center",
+ z => 3,
+ name => 'tip_of_the_day',
+ force_w => int $WIDTH * 4/9,
+ force_h => int $WIDTH * 2/9,
+ title => "Tip of the day #" . (1 + $todindex),
+ child => my $vbox = new CFPlus::UI::VBox,
+ has_close_button => 1,
+ on_delete => $close,
+ ;
+
+ $vbox->add (my $viewer = new CFPlus::UI::TextScroller
+ expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
+ $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $tod[$todindex]);
+
+ $vbox->add (my $table = new CFPlus::UI::Table);
+
+ $table->add (0, 0, new CFPlus::UI::Button
+ text => "Close",
+ tooltip => "Close the tip of the day window. To never see it again, disable the tip of the day in the Server Setup.",
+ on_activate => $close,
+ );
+
+ $table->add (2, 0, new CFPlus::UI::Button
+ text => "Next",
+ tooltip => "Show the next Tip of the day.",
+ on_activate => sub {
+ $close->();
+ &show_tip_of_the_day;
+ },
+ );
+
+ $dialog->show;
+}
+
sub sdl_init {
CFPlus::SDL_Init
and die "SDL::Init failed!\n";
@@ -1962,6 +2032,7 @@
pickup => 0,
inv_sort => "mtime",
default => "profile", # default profile
+ show_tips => 1,
);
while (my ($k, $v) = each %DEF_CFG) {
@@ -2019,6 +2090,8 @@
audio_init;
}
+show_tip_of_the_day if $CFG->{show_tips};
+
Event::loop;
#CFPlus::SDL_Quit;
#CFPlus::_exit 0;