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.104 by root, Sun Jul 30 13:14:15 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]; 52 return;#d#
53 CFPlus::fatal ($_[1]);
53}; 54};
54 55
55$SIG{__DIE__} = sub {
56 return if CFPlus::in_destruct;
57 Carp::cluck $_[0];
58 CFPlus::error $_[0];
59 return;#d#
60 #return unless defined $^S && !$^S;
61 $Event::DIED->(undef, $_[0]);
62};
63
64our $VERSION = '0.1'; 56our $VERSION = '0.9';
65 57
66my $MAX_FPS = 60; 58my $MAX_FPS = 60;
67my $MIN_FPS = 5; # unused as of yet 59my $MIN_FPS = 5; # unused as of yet
68 60
69our $META_SERVER = "crossfire.real-time.com:13326"; 61our $META_SERVER = "crossfire.real-time.com:13326";
155 147
156# server query dialog 148# server query dialog
157sub server_query { 149sub server_query {
158 my ($conn, $flags, $prompt) = @_; 150 my ($conn, $flags, $prompt) = @_;
159 151
160 $conn->{query_dialog} = my $dialog = new CFPlus::UI::FancyFrame 152 $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel
161 x => "center", 153 x => "center",
162 y => "center", 154 y => "center",
163 title => "Server Query", 155 title => "Server Query",
164 child => my $vbox = new CFPlus::UI::VBox, 156 child => my $vbox = new CFPlus::UI::VBox,
165 ; 157 ;
190 ); 182 );
191 183
192 $dialog->grab_focus; 184 $dialog->grab_focus;
193 185
194 } elsif ($flags & CS_QUERY_SINGLECHAR) { 186 } elsif ($flags & CS_QUERY_SINGLECHAR) {
195 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; 187 $dialog->{tooltip} = "#charcreation_focus";
196 188
197 if ($prompt =~ /Now choose a character|Press any key for the next race/i) { 189 if ($prompt =~ /Now choose a character|Press any key for the next race/i) {
198 $MESSAGE_WINDOW->show; 190 $MESSAGE_WINDOW->show;
199 191
200 unshift @dialog, new CFPlus::UI::Label 192 unshift @dialog, new CFPlus::UI::Label
222 ); 214 );
223 215
224 unshift @dialog, new CFPlus::UI::Label 216 unshift @dialog, new CFPlus::UI::Label
225 max_w => $::WIDTH * 0.4, 217 max_w => $::WIDTH * 0.4,
226 ellipsise => 0, 218 ellipsise => 0,
227 markup => 219 markup => (CFPlus::Pod::section_label ui => "chargen_race"),
228 "<big><b>Character Creation: Race</b></big>\n\n"
229 . "Look at the <b>Messages</b> window to see a description of this race "
230 . "and the center of the screen to see how this race looks like "
231 . "(<small>below this dialog window: you may need to move the dialog away and "
232 . "click into the display area to make it visible</small>).\n\n"
233 . "You can look at another race, or accept this race (you will cycle back to "
234 . "this race eventually, so you can take your time making this important choice."
235 ; 220 ;
236 221
237 } elsif ($prompt =~ /roll new stats/) { 222 } elsif ($prompt =~ /roll new stats/) {
238 if (my $stat = delete $conn->{stat_change_with}) { 223 if (my $stat = delete $conn->{stat_change_with}) {
239 $conn->send ("reply $stat"); 224 $conn->send ("reply $stat");
313 markup => "$conn->{stat}{$id} <span foreground='yellow'>$name</span>", 298 markup => "$conn->{stat}{$id} <span foreground='yellow'>$name</span>",
314 align => 0, 299 align => 0,
315 expand => 1, 300 expand => 1,
316 can_events => 1, 301 can_events => 1,
317 can_hover => 1, 302 can_hover => 1,
318 tooltip => $CFPlus::STAT_TOOLTIP{$name}, 303 tooltip => "#stat_$name",
319 ); 304 );
320 } 305 }
321 306
322 unshift @dialog, new CFPlus::UI::Label 307 unshift @dialog, new CFPlus::UI::Label
323 max_w => $::WIDTH * 0.4, 308 max_w => $::WIDTH * 0.4,
324 ellipsise => 0, 309 ellipsise => 0,
325 markup => 310 markup => (CFPlus::Pod::section_label ui => "chargen_stats"),
326 "<big><b>Character Creation: Stats</b></big>\n\n"
327 . "<b>Stats</b> are a very important aspect of your character. You can use the tooltips to learn what each Stat governs.\n\n"
328 . "The stats generated by the server are always sorted from Str (highest) to Cha (lowest). "
329 . "They will be modified later by both the race and the class you choose.\n\n"
330 . "You can create another set of stats, swap two stat values with each other or accept the stats as shown below and continue.\n"
331 ; 311 ;
332 } 312 }
333 313
334 push @dialog, my $entry = new CFPlus::UI::Entry 314 push @dialog, my $entry = new CFPlus::UI::Entry
335 on_changed => sub { 315 on_changed => sub {
379 user => $CFG->{profile}{default}{user}, 359 user => $CFG->{profile}{default}{user},
380 pass => $CFG->{profile}{default}{password}, 360 pass => $CFG->{profile}{default}{password},
381 mapw => $mapsize, 361 mapw => $mapsize,
382 maph => $mapsize, 362 maph => $mapsize,
383 363
364 client => "cfplus $VERSION $] $^O",
365
384 map_widget => $MAPWIDGET, 366 map_widget => $MAPWIDGET,
385 logview => $LOGVIEW, 367 logview => $LOGVIEW,
386 statusbox => $STATUSBOX, 368 statusbox => $STATUSBOX,
387 map => $MAP, 369 map => $MAP,
388 mapmap => $MAPMAP, 370 mapmap => $MAPMAP,
622 (new CFPlus::UI::Empty expand => 1), 604 (new CFPlus::UI::Empty expand => 1),
623 (my $hb = new CFPlus::UI::HBox), 605 (my $hb = new CFPlus::UI::HBox),
624 ], 606 ],
625 ); 607 );
626 608
627 $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', 609 $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health");
628 tooltip => "<b>Health points</b>. Measures of how much damage you can take before dying. Hit points are determined from your level and are influenced by the value of your Con. Hp value may range between 1 to beyond 500 and higher values indicate a greater ability to withstand punishment.");
629 $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', 610 $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana");
630 tooltip => "<b>Spell points</b>. Measures of how much \"fuel\" you have for casting spells and incantations. Mana is calculated from your level and your Pow. Mana values can range between 1 to beyond 500 (glowing crystals can increase the current spell points beyond your normal maximum). Higher values indicate greater amounts of mana.");
631 $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', 611 $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace");
632 tooltip => "<b>Grace points</b> - how favored you are by your god. In game terms, how much divine magic you can cast. Your level, Wis and Pow effect what the value of grace is. Prayong on an altar of your god can increase this value beyond your normal maximum. Grace can take on large positive and negative values. Positive values indicate favor by the gods.");
633 $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', 612 $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food");
634 tooltip => "<b>Food</b>. Ranges between 0 (starving) and 999 (satiated). At a value of 0 the character begins to die. Some magic can speed up or slow down the character digestion. Healing wounds will speed up digestion too.");
635 613
636 $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, 614 $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp");
637 tooltip => "<b>Experience points and overall level</b> - experience is increased as a reward for appropriate action (such as killing monsters) and may decrease as a result of a magical attack or dying. Level is directly derived from the experience value. As the level of the character increases, the character becomes able to succeed at more difficult tasks. A character's level starts at a value of 0 and may range up beyond 100.");
638 $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, 615 $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged");
639 tooltip => "<b>Ranged attack</b> - how you attack when you press shift-cursor (spell, skill, weapon etc.)");
640 616
641 $GAUGES = { 617 $GAUGES = {
642 exp => $exp, win => $win, range => $rng, 618 exp => $exp, win => $win, range => $rng,
643 food => $fg, mana => $mg, hp => $hg, grace => $gg 619 food => $fg, mana => $mg, hp => $hg, grace => $gg
644 }; 620 };
681 expand => 1, 657 expand => 1,
682 scroll_y => 1 658 scroll_y => 1
683 ); 659 );
684 $r->add (my $vb = new CFPlus::UI::VBox); 660 $r->add (my $vb = new CFPlus::UI::VBox);
685 661
662 $vb->add (new CFPlus::UI::FancyFrame
663 label => "Player",
664 child => (my $pi = new CFPlus::UI::VBox),
665 );
666
686 $vb->add ($STATWIDS->{title} = new CFPlus::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, 667 $pi->add ($STATWIDS->{title} = new CFPlus::UI::Label valign => 0, align => -1, text => "Title:", expand => 1,
687 can_hover => 1, can_events => 1, 668 can_hover => 1, can_events => 1,
688 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); 669 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server.");
689 $vb->add ($STATWIDS->{map} = new CFPlus::UI::Label valign => 0, align => -1, text => "Map:", expand => 1, 670 $pi->add ($STATWIDS->{map} = new CFPlus::UI::Label valign => 0, align => -1, text => "Map:", expand => 1,
690 can_hover => 1, can_events => 1, 671 can_hover => 1, can_events => 1,
691 tooltip => "The map you are currently on (if supported by the server)."); 672 tooltip => "The map you are currently on (if supported by the server).");
692 673
693 $vb->add (my $hb0 = new CFPlus::UI::HBox); 674 $pi->add (my $hb0 = new CFPlus::UI::HBox);
694 $hb0->add ($STATWIDS->{weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Weight:", expand => 1, 675 $hb0->add ($STATWIDS->{weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Weight:", expand => 1,
695 can_hover => 1, can_events => 1, 676 can_hover => 1, can_events => 1,
696 tooltip => "The weight of the player including all inventory items."); 677 tooltip => "The weight of the player including all inventory items.");
697 $hb0->add ($STATWIDS->{m_weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Max weight:", expand => 1, 678 $hb0->add ($STATWIDS->{m_weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Max weight:", expand => 1,
698 can_hover => 1, can_events => 1, 679 can_hover => 1, can_events => 1,
699 tooltip => "The weight limit: you cannot carry more than this."); 680 tooltip => "The weight limit: you cannot carry more than this.");
700 681
682 $vb->add (new CFPlus::UI::FancyFrame
683 label => "Primary/Secondary Statistics",
701 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1); 684 child => (my $hb = new CFPlus::UI::HBox expand => 1),
685 );
702 $hb->add (my $tbl = new CFPlus::UI::Table expand => 1); 686 $hb->add (my $tbl = new CFPlus::UI::Table expand => 1);
703 687
704 my $color2 = [1, 1, 0]; 688 my $color2 = [1, 1, 0];
705 689
706 for ( 690 for (
721 ) { 705 ) {
722 my ($col, $row, $id, $label, $template) = @$_; 706 my ($col, $row, $id, $label, $template) = @$_;
723 707
724 $tbl->add ($col , $row, $STATWIDS->{$id} = new CFPlus::UI::Label 708 $tbl->add ($col , $row, $STATWIDS->{$id} = new CFPlus::UI::Label
725 font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, 709 font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0,
726 align => +1, template => $template, tooltip => $CFPlus::STAT_TOOLTIP{$label}); 710 align => +1, template => $template, tooltip => "#stat_$label");
727 $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFPlus::UI::Label 711 $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFPlus::UI::Label
728 font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0, 712 font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0,
729 align => -1, text => $label, tooltip => $CFPlus::STAT_TOOLTIP{$label}); 713 align => -1, text => $label, tooltip => "#stat_$label");
730 } 714 }
731 715
716 $vb->add (new CFPlus::UI::FancyFrame
717 label => "Resistancies",
732 $vb->add (my $tbl2 = new CFPlus::UI::Table expand => 1); 718 child => (my $tbl2 = new CFPlus::UI::Table expand => 1),
719 );
733 720
734 my $row = 0; 721 my $row = 0;
735 my $col = 0; 722 my $col = 0;
736 723
737 my %resist_names = ( 724 my %resist_names = (
931sub metaserver_dialog { 918sub metaserver_dialog {
932 my $vbox = new CFPlus::UI::VBox; 919 my $vbox = new CFPlus::UI::VBox;
933 my $table = new CFPlus::UI::Table; 920 my $table = new CFPlus::UI::Table;
934 $vbox->add (new CFPlus::UI::ScrolledWindow expand => 1, child => $table); 921 $vbox->add (new CFPlus::UI::ScrolledWindow expand => 1, child => $table);
935 922
936 my $dialog = new CFPlus::UI::FancyFrame 923 my $dialog = new CFPlus::UI::Toplevel
937 title => "Server List", 924 title => "Server List",
938 name => 'metaserver_dialog', 925 name => 'metaserver_dialog',
939 x => 'center', 926 x => 'center',
940 y => 'center', 927 y => 'center',
941 z => 3, 928 z => 3,
953} 940}
954 941
955sub server_setup { 942sub server_setup {
956 my $vbox = new CFPlus::UI::VBox; 943 my $vbox = new CFPlus::UI::VBox;
957 944
945 $vbox->add (new CFPlus::UI::FancyFrame
946 label => "Connection Settings",
958 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]); 947 child => (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]),
948 );
959 $table->add (0, 2, new CFPlus::UI::Label valign => 0, align => 1, text => "Host:Port"); 949 $table->add (0, 2, new CFPlus::UI::Label valign => 0, align => 1, text => "Host:Port");
960 950
961 { 951 {
962 $table->add (1, 2, my $vbox = new CFPlus::UI::VBox); 952 $table->add (1, 2, my $vbox = new CFPlus::UI::VBox);
963 953
1047 }, 1037 },
1048 ); 1038 );
1049 1039
1050 $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");
1051 $table->add (1, 12, my $saycmd = new CFPlus::UI::Entry 1041 $table->add (1, 12, my $saycmd = new CFPlus::UI::Entry
1052 text => $CFG->{say_command}, 1042 text => $CFG->{say_command},
1053 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. "
1054 . "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. "
1055 . "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.",
1056 on_changed => sub { 1046 on_changed => sub {
1057 my ($self, $value) = @_; 1047 my ($self, $value) = @_;
1058 $CFG->{say_command} = $value; 1048 $CFG->{say_command} = $value;
1059 0 1049 0
1060 } 1050 }
1061 ); 1051 );
1062 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;
1060 0
1061 }
1062 );
1063
1063 $vbox->add (new CFPlus::UI::Label 1064 $vbox->add (new CFPlus::UI::FancyFrame
1064 text => "Server Info", 1065 label => "Server Info",
1065 fontsize => 1.2,
1066 padding_y => 8,
1067 fg => [1, 1, 0, 1],
1068 );
1069
1070 $vbox->add ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0); 1066 child => ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0),
1067 );
1071 1068
1072 $vbox 1069 $vbox
1073} 1070}
1074 1071
1075sub message_window { 1072sub message_window {
1076 my $window = new CFPlus::UI::FancyFrame 1073 my $window = new CFPlus::UI::Toplevel
1077 name => "message_window", 1074 name => "message_window",
1078 title => "Messages", 1075 title => "Messages",
1079 border_bg => [1, 1, 1, 1], 1076 border_bg => [1, 1, 1, 1],
1080 x => "max", 1077 x => "max",
1081 y => 0, 1078 y => 0,
1131 window => $window, 1128 window => $window,
1132 input => $input, 1129 input => $input,
1133 }; 1130 };
1134 1131
1135 $window 1132 $window
1136}
1137
1138sub open_quit_dialog {
1139 unless ($QUIT_DIALOG) {
1140 $QUIT_DIALOG = new CFPlus::UI::FancyFrame
1141 x => "center",
1142 y => "center",
1143 z => 50,
1144 title => "Really Quit?",
1145 on_key_down => sub {
1146 my ($dialog, $ev) = @_;
1147 $ev->{sym} == 27 and $dialog->hide;
1148 }
1149 ;
1150
1151 $QUIT_DIALOG->add (my $vb = new CFPlus::UI::VBox expand => 1);
1152
1153 $vb->add (new CFPlus::UI::Label
1154 text => "You should find a savebed and apply it first!",
1155 max_w => $WIDTH * 0.25,
1156 ellipsize => 0,
1157 );
1158 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1);
1159 $hb->add (new CFPlus::UI::Button
1160 text => "Ok",
1161 expand => 1,
1162 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1163 );
1164 $hb->add (new CFPlus::UI::Button
1165 text => "Quit anyway",
1166 expand => 1,
1167 on_activate => sub { exit },
1168 );
1169 }
1170
1171 $QUIT_DIALOG->show;
1172 $QUIT_DIALOG->grab_focus;
1173} 1133}
1174 1134
1175sub autopickup_setup { 1135sub autopickup_setup {
1176 my $table = new CFPlus::UI::Table; 1136 my $table = new CFPlus::UI::Table;
1177 1137
1334 $PL_WINDOW->show; 1294 $PL_WINDOW->show;
1335 } 1295 }
1336} 1296}
1337 1297
1338sub player_window { 1298sub player_window {
1339 my $plwin = $PL_WINDOW = new CFPlus::UI::FancyFrame 1299 my $plwin = $PL_WINDOW = new CFPlus::UI::Toplevel
1340 x => "center", 1300 x => "center",
1341 y => "center", 1301 y => "center",
1342 force_w => $WIDTH * 9/10, 1302 force_w => $WIDTH * 9/10,
1343 force_h => $HEIGHT * 9/10, 1303 force_h => $HEIGHT * 9/10,
1344 title => "Player", 1304 title => "Player",
1433 } 1393 }
1434 } 1394 }
1435 }; 1395 };
1436 1396
1437 my $vb = new CFPlus::UI::VBox; 1397 my $vb = new CFPlus::UI::VBox;
1398 $vb->add (new CFPlus::UI::FancyFrame
1399 label => "Options",
1438 $vb->add (my $hb = new CFPlus::UI::HBox); 1400 child => (my $hb = new CFPlus::UI::HBox),
1401 );
1439 $hb->add (new CFPlus::UI::Label text => "only shift-up stops fire"); 1402 $hb->add (new CFPlus::UI::Label text => "only shift-up stops fire");
1440 $hb->add (new CFPlus::UI::CheckBox 1403 $hb->add (new CFPlus::UI::CheckBox
1441 expand => 1, 1404 expand => 1,
1442 state => $CFG->{shift_fire_stop}, 1405 state => $CFG->{shift_fire_stop},
1443 tooltip => "If this checkbox is enabled you will stop fire only if you stop pressing shift", 1406 tooltip => "If this checkbox is enabled you will stop fire only if you stop pressing shift",
1445 my ($cbox, $value) = @_; 1408 my ($cbox, $value) = @_;
1446 $CFG->{shift_fire_stop} = $value; 1409 $CFG->{shift_fire_stop} = $value;
1447 0 1410 0
1448 }); 1411 });
1449 1412
1450 $vb->add ($binding_list); 1413 $vb->add (new CFPlus::UI::FancyFrame
1414 label => "Bindings",
1415 child => $binding_list);
1451 $vb->add (my $hb = new CFPlus::UI::HBox); 1416 $vb->add (my $hb = new CFPlus::UI::HBox);
1452 1417
1453 $hb->add (new CFPlus::UI::Button 1418 $hb->add (new CFPlus::UI::Button
1454 text => "record new", 1419 text => "record new",
1455 expand => 1, 1420 expand => 1,
1488 1453
1489 $vb 1454 $vb
1490} 1455}
1491 1456
1492sub help_window { 1457sub help_window {
1493 my $win = new CFPlus::UI::FancyFrame 1458 my $win = new CFPlus::UI::Toplevel
1494 x => 'center', 1459 x => 'center',
1495 y => 'center', 1460 y => 'center',
1496 z => 2, 1461 z => 4,
1497 name => 'doc_browser', 1462 name => 'doc_browser',
1498 force_w => int $WIDTH * 7/8, 1463 force_w => int $WIDTH * 7/8,
1499 force_h => int $HEIGHT * 7/8, 1464 force_h => int $HEIGHT * 7/8,
1500 title => "Help Browser", 1465 title => "Help Browser",
1501 has_close_button => 1; 1466 has_close_button => 1;
1502 1467
1503 $win->add (my $vbox = new CFPlus::UI::VBox); 1468 $win->add (my $vbox = new CFPlus::UI::VBox);
1504 1469
1470 $vbox->add (new CFPlus::UI::FancyFrame
1471 label => "Navigation",
1505 $vbox->add (my $buttons = new CFPlus::UI::HBox); 1472 child => (my $buttons = new CFPlus::UI::HBox),
1473 );
1506 $vbox->add (my $viewer = new CFPlus::UI::TextScroller 1474 $vbox->add (my $viewer = new CFPlus::UI::TextScroller
1507 expand => 1, fontsize => 0.8, padding_x => 4); 1475 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
1508 1476
1509 $buttons->add (new CFPlus::UI::Label text => "Choose a document to display: "); 1477 my @history;
1510 $buttons->add (my $combo = new CFPlus::UI::Selector 1478 my @future;
1511 value => undef, 1479 my $curnode;
1512 options => [ 1480
1513 [intro => "Introduction"], 1481 my $load_node; $load_node = sub {
1514 [manual => "Main Manual"], 1482 my ($node, $para) = @_;
1515 [skill_help => "Skill Reference"], 1483
1516 [command_help => "Command Reference"], 1484 $buttons->clear;
1517 [dmcommand_help => "DM Commands"], 1485
1518 [COPYING => "License Terms"], 1486 $buttons->add (new CFPlus::UI::Button
1487 text => "⇤",
1488 tooltip => "back to the starting page",
1489 on_activate => sub {
1490 unshift @future, [$curnode, $viewer->current_paragraph] if $curnode;
1491 unshift @future, @history;
1492 @history = ();
1493 $load_node->(@{shift @future});
1494 },
1495 );
1496
1497 if (@history) {
1498 $buttons->add (new CFPlus::UI::Button
1499 text => "⋘",
1500 tooltip => "back to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $history[-1][0]) . "</i>",
1501 on_activate => sub {
1502 unshift @future, [$curnode, $viewer->current_paragraph] if $curnode;
1503 $load_node->(@{pop @history});
1504 },
1505 );
1519 ], 1506 }
1520 on_changed => sub {
1521 my ($self, $pod) = @_;
1522 1507
1508 if (@future) {
1509 $buttons->add (new CFPlus::UI::Button
1510 text => "⋙",
1511 tooltip => "forward to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $future[0][0]) . "</i>",
1512 on_activate => sub {
1513 push @history, [$curnode, $viewer->current_paragraph];
1514 $load_node->(@{shift @future});
1515 },
1516 );
1517 }
1518
1519 $buttons->add (new CFPlus::UI::Label text => " ");
1520
1521 my @path = CFPlus::Pod::full_path_of $node;
1522 pop @path; # drop current node
1523
1524 for my $node (@path) {
1525 $buttons->add (new CFPlus::UI::Button
1526 text => $node->{kw}[0],
1527 tooltip => "go to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $node) . "</i>",
1528 on_activate => sub {
1529 push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = ();
1530 $load_node->($node);
1531 },
1532 );
1533 $buttons->add (new CFPlus::UI::Label text => "/");
1534 }
1535
1536 $buttons->add (new CFPlus::UI::Label text => $node->{kw}[0], padding_x => 4, padding_y => 4);
1537
1538 $curnode = $node;
1539
1523 $viewer->clear; 1540 $viewer->clear;
1524 $viewer->add_paragraph (@{ CFPlus::Pod::pod_paragraphs $pod }); 1541 $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $curnode);
1525 $viewer->set_offset (0); 1542 $viewer->scroll_to ($para);
1543 };
1526 1544
1545 $load_node->(CFPlus::Pod::find pod => "mainpage");
1546
1547 $CFPlus::Pod::goto_document = sub {
1548 my (@path) = @_;
1549
1550 push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = ();
1551
1552 $load_node->((CFPlus::Pod::find @path)[0]);
1553 $win->show;
1554 };
1555
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;
1527 0 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;
1528 }, 1663 },
1529 on_visibility_change => sub {
1530 my ($self, $visible) = @_;
1531 return unless $visible;
1532 return if $self->{value};
1533 $self->set_value ("intro");
1534 0
1535 },
1536 ); 1664 );
1537 1665
1538 $win 1666 $dialog->show;
1539} 1667}
1540 1668
1541sub sdl_init { 1669sub sdl_init {
1542 CFPlus::SDL_Init 1670 CFPlus::SDL_Init
1543 and die "SDL::Init failed!\n"; 1671 and die "SDL::Init failed!\n";
1590 force_x => 0, 1718 force_x => 0,
1591 force_y => "max", 1719 force_y => "max",
1592 child => $STATUSBOX, 1720 child => $STATUSBOX,
1593 )->show; 1721 )->show;
1594 1722
1595 CFPlus::UI::FancyFrame->new ( 1723 CFPlus::UI::Toplevel->new (
1596 title => "Map", 1724 title => "Map",
1597 name => "mapmap", 1725 name => "mapmap",
1598 x => 0, 1726 x => 0,
1599 y => $FONTSIZE + 8, 1727 y => $FONTSIZE + 8,
1600 border_bg => [1, 1, 1, 192/255], 1728 border_bg => [1, 1, 1, 192/255],
1628 can_hover => 1, 1756 can_hover => 1,
1629 can_events => 1, 1757 can_events => 1,
1630 tooltip => "<b>Server Log</b>. This text viewer contains all the messages sent by the server.", 1758 tooltip => "<b>Server Log</b>. This text viewer contains all the messages sent by the server.",
1631 ; 1759 ;
1632 1760
1633 $SETUP_DIALOG = new CFPlus::UI::FancyFrame 1761 $SETUP_DIALOG = new CFPlus::UI::Toplevel
1634 title => "Setup", 1762 title => "Setup",
1635 name => "setup_dialog", 1763 name => "setup_dialog",
1636 x => 'center', 1764 x => 'center',
1637 y => 'center', 1765 y => 'center',
1638 z => 2, 1766 z => 2,
1902 output_sync => 1, 2030 output_sync => 1,
1903 output_count => 1, 2031 output_count => 1,
1904 pickup => 0, 2032 pickup => 0,
1905 inv_sort => "mtime", 2033 inv_sort => "mtime",
1906 default => "profile", # default profile 2034 default => "profile", # default profile
2035 show_tips => 1,
1907 ); 2036 );
1908 2037
1909 while (my ($k, $v) = each %DEF_CFG) { 2038 while (my ($k, $v) = each %DEF_CFG) {
1910 $CFG->{$k} = $v unless exists $CFG->{$k}; 2039 $CFG->{$k} = $v unless exists $CFG->{$k};
1911 } 2040 }
1959 2088
1960 video_init; 2089 video_init;
1961 audio_init; 2090 audio_init;
1962} 2091}
1963 2092
2093show_tip_of_the_day if $CFG->{show_tips};
2094
1964Event::loop; 2095Event::loop;
1965#CFPlus::SDL_Quit; 2096#CFPlus::SDL_Quit;
1966#CFPlus::_exit 0; 2097#CFPlus::_exit 0;
1967 2098
1968END { CFPlus::SDL_Quit } 2099END { CFPlus::SDL_Quit }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines