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.118 by root, Tue Aug 22 06:37:30 2006 UTC vs.
Revision 1.119 by root, Fri Sep 29 00:56:06 2006 UTC

47 47
48$Event::Eval = 0; 48$Event::Eval = 0;
49$Event::DIED = sub { 49$Event::DIED = sub {
50 # TODO: display dialog box or so 50 # TODO: display dialog box or so
51 Carp::cluck $_[1];#d#TODO: remove when stable 51 Carp::cluck $_[1];#d#TODO: remove when stable
52 CFPlus::error $_[1];
53};
54
55$SIG{__DIE__} = sub {
56 return if CFPlus::in_destruct;
57 Carp::cluck $_[0];
58 CFPlus::error $_[0];
59 return;#d# 52 return;#d#
60 #return unless defined $^S && !$^S; 53 CFPlus::fatal ($_[1]);
61 $Event::DIED->(undef, $_[0]);
62}; 54};
63 55
64our $VERSION = '0.9'; 56our $VERSION = '0.9';
65 57
66my $MAX_FPS = 60; 58my $MAX_FPS = 60;
1045 }, 1037 },
1046 ); 1038 );
1047 1039
1048 $table->add (0, 12, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command"); 1040 $table->add (0, 12, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command");
1049 $table->add (1, 12, my $saycmd = new CFPlus::UI::Entry 1041 $table->add (1, 12, my $saycmd = new CFPlus::UI::Entry
1050 text => $CFG->{say_command}, 1042 text => $CFG->{say_command},
1051 tooltip => "This is the command that will be used if you write a line in the message window entry or press <b>\"</b> in the map window. " 1043 tooltip => "This is the command that will be used if you write a line in the message window entry or press <b>\"</b> in the map window. "
1052 . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " 1044 . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
1053 . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.", 1045 . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.",
1054 on_changed => sub { 1046 on_changed => sub {
1055 my ($self, $value) = @_; 1047 my ($self, $value) = @_;
1056 $CFG->{say_command} = $value; 1048 $CFG->{say_command} = $value;
1049 0
1050 }
1051 );
1052
1053 $table->add (0, 13, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day");
1054 $table->add (1, 13, my $saycmd = new CFPlus::UI::CheckBox
1055 state => $CFG->{show_tips},
1056 tooltip => "Show the <b>Tip of the day</b> window at startup?",
1057 on_changed => sub {
1058 my ($self, $value) = @_;
1059 $CFG->{shop_tips} = $value;
1057 0 1060 0
1058 } 1061 }
1059 ); 1062 );
1060 1063
1061 $vbox->add (new CFPlus::UI::FancyFrame 1064 $vbox->add (new CFPlus::UI::FancyFrame
1125 window => $window, 1128 window => $window,
1126 input => $input, 1129 input => $input,
1127 }; 1130 };
1128 1131
1129 $window 1132 $window
1130}
1131
1132sub open_string_query {
1133 my ($title, $cb, $txt, $tooltip) = @_;
1134 my $dialog = new CFPlus::UI::Toplevel
1135 x => "center",
1136 y => "center",
1137 z => 50,
1138 force_w => $WIDTH * 4/5,
1139 title => $title;
1140
1141 $dialog->add (
1142 my $e = new CFPlus::UI::Entry
1143 on_activate => sub { $cb->(@_); $dialog->hide; 0 },
1144 on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 },
1145 tooltip => $tooltip
1146 );
1147
1148 $e->grab_focus;
1149 $e->set_text ($txt) if $txt;
1150 $dialog->show;
1151}
1152
1153sub open_quit_dialog {
1154 unless ($QUIT_DIALOG) {
1155 $QUIT_DIALOG = new CFPlus::UI::Toplevel
1156 x => "center",
1157 y => "center",
1158 z => 50,
1159 title => "Really Quit?",
1160 on_key_down => sub {
1161 my ($dialog, $ev) = @_;
1162 $ev->{sym} == 27 and $dialog->hide;
1163 }
1164 ;
1165
1166 $QUIT_DIALOG->add (my $vb = new CFPlus::UI::VBox expand => 1);
1167
1168 $vb->add (new CFPlus::UI::Label
1169 text => "You should find a savebed and apply it first!",
1170 max_w => $WIDTH * 0.25,
1171 ellipsize => 0,
1172 );
1173 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1);
1174 $hb->add (new CFPlus::UI::Button
1175 text => "Ok",
1176 expand => 1,
1177 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1178 );
1179 $hb->add (new CFPlus::UI::Button
1180 text => "Quit anyway",
1181 expand => 1,
1182 on_activate => sub { exit },
1183 );
1184 }
1185
1186 $QUIT_DIALOG->show;
1187 $QUIT_DIALOG->grab_focus;
1188} 1133}
1189 1134
1190sub autopickup_setup { 1135sub autopickup_setup {
1191 my $table = new CFPlus::UI::Table; 1136 my $table = new CFPlus::UI::Table;
1192 1137
1511 1456
1512sub help_window { 1457sub help_window {
1513 my $win = new CFPlus::UI::Toplevel 1458 my $win = new CFPlus::UI::Toplevel
1514 x => 'center', 1459 x => 'center',
1515 y => 'center', 1460 y => 'center',
1516 z => 2, 1461 z => 4,
1517 name => 'doc_browser', 1462 name => 'doc_browser',
1518 force_w => int $WIDTH * 7/8, 1463 force_w => int $WIDTH * 7/8,
1519 force_h => int $HEIGHT * 7/8, 1464 force_h => int $HEIGHT * 7/8,
1520 title => "Help Browser", 1465 title => "Help Browser",
1521 has_close_button => 1; 1466 has_close_button => 1;
1607 $load_node->((CFPlus::Pod::find @path)[0]); 1552 $load_node->((CFPlus::Pod::find @path)[0]);
1608 $win->show; 1553 $win->show;
1609 }; 1554 };
1610 1555
1611 $win 1556 $win
1557}
1558
1559sub open_string_query {
1560 my ($title, $cb, $txt, $tooltip) = @_;
1561 my $dialog = new CFPlus::UI::Toplevel
1562 x => "center",
1563 y => "center",
1564 z => 50,
1565 force_w => $WIDTH * 4/5,
1566 title => $title;
1567
1568 $dialog->add (
1569 my $e = new CFPlus::UI::Entry
1570 on_activate => sub { $cb->(@_); $dialog->hide; 0 },
1571 on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 },
1572 tooltip => $tooltip
1573 );
1574
1575 $e->grab_focus;
1576 $e->set_text ($txt) if $txt;
1577 $dialog->show;
1578}
1579
1580sub open_quit_dialog {
1581 unless ($QUIT_DIALOG) {
1582 $QUIT_DIALOG = new CFPlus::UI::Toplevel
1583 x => "center",
1584 y => "center",
1585 z => 50,
1586 title => "Really Quit?",
1587 on_key_down => sub {
1588 my ($dialog, $ev) = @_;
1589 $ev->{sym} == 27 and $dialog->hide;
1590 }
1591 ;
1592
1593 $QUIT_DIALOG->add (my $vb = new CFPlus::UI::VBox expand => 1);
1594
1595 $vb->add (new CFPlus::UI::Label
1596 text => "You should find a savebed and apply it first!",
1597 max_w => $WIDTH * 0.25,
1598 ellipsize => 0,
1599 );
1600 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1);
1601 $hb->add (new CFPlus::UI::Button
1602 text => "Ok",
1603 expand => 1,
1604 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1605 );
1606 $hb->add (new CFPlus::UI::Button
1607 text => "Quit anyway",
1608 expand => 1,
1609 on_activate => sub { exit },
1610 );
1611 }
1612
1613 $QUIT_DIALOG->show;
1614 $QUIT_DIALOG->grab_focus;
1615}
1616
1617sub show_tip_of_the_day {
1618 # find all tips
1619 my @tod = CFPlus::Pod::find tip_of_the_day => "*";
1620
1621 my $todindex = $CFPlus::DB_STATE->get ("tip_of_the_day");
1622 $todindex = 0 if $todindex >= @tod;
1623 $CFPlus::DB_STATE->put (tip_of_the_day => $todindex + 1);
1624
1625 # create dialog
1626 my $dialog;
1627
1628 my $close = sub {
1629 $dialog->destroy;
1630 };
1631
1632 $dialog = new CFPlus::UI::Toplevel
1633 x => "center",
1634 y => "center",
1635 z => 3,
1636 name => 'tip_of_the_day',
1637 force_w => int $WIDTH * 4/9,
1638 force_h => int $WIDTH * 2/9,
1639 title => "Tip of the day #" . (1 + $todindex),
1640 child => my $vbox = new CFPlus::UI::VBox,
1641 has_close_button => 1,
1642 on_delete => $close,
1643 ;
1644
1645 $vbox->add (my $viewer = new CFPlus::UI::TextScroller
1646 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
1647 $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $tod[$todindex]);
1648
1649 $vbox->add (my $table = new CFPlus::UI::Table);
1650
1651 $table->add (0, 0, new CFPlus::UI::Button
1652 text => "Close",
1653 tooltip => "Close the tip of the day window. To never see it again, disable the tip of the day in the <b>Server Setup</b>.",
1654 on_activate => $close,
1655 );
1656
1657 $table->add (2, 0, new CFPlus::UI::Button
1658 text => "Next",
1659 tooltip => "Show the next <b>Tip of the day</b>.",
1660 on_activate => sub {
1661 $close->();
1662 &show_tip_of_the_day;
1663 },
1664 );
1665
1666 $dialog->show;
1612} 1667}
1613 1668
1614sub sdl_init { 1669sub sdl_init {
1615 CFPlus::SDL_Init 1670 CFPlus::SDL_Init
1616 and die "SDL::Init failed!\n"; 1671 and die "SDL::Init failed!\n";
1975 output_sync => 1, 2030 output_sync => 1,
1976 output_count => 1, 2031 output_count => 1,
1977 pickup => 0, 2032 pickup => 0,
1978 inv_sort => "mtime", 2033 inv_sort => "mtime",
1979 default => "profile", # default profile 2034 default => "profile", # default profile
2035 show_tips => 1,
1980 ); 2036 );
1981 2037
1982 while (my ($k, $v) = each %DEF_CFG) { 2038 while (my ($k, $v) = each %DEF_CFG) {
1983 $CFG->{$k} = $v unless exists $CFG->{$k}; 2039 $CFG->{$k} = $v unless exists $CFG->{$k};
1984 } 2040 }
2032 2088
2033 video_init; 2089 video_init;
2034 audio_init; 2090 audio_init;
2035} 2091}
2036 2092
2093show_tip_of_the_day if $CFG->{show_tips};
2094
2037Event::loop; 2095Event::loop;
2038#CFPlus::SDL_Quit; 2096#CFPlus::SDL_Quit;
2039#CFPlus::_exit 0; 2097#CFPlus::_exit 0;
2040 2098
2041END { CFPlus::SDL_Quit } 2099END { CFPlus::SDL_Quit }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines