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.107 by root, Sun Aug 13 03:20:56 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");
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 (
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 => "#stat_$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_string_query {
1139 my $cb = $_[1];
1140 my $dialog = new CFPlus::UI::FancyFrame
1141 x => "center",
1142 y => "center",
1143 z => 50,
1144 force_w => $WIDTH * 4/5,
1145 title => $_[0];
1146
1147 $dialog->add (
1148 my $e = new CFPlus::UI::Entry
1149 on_activate => sub { $cb->(@_); $dialog->hide; 0 },
1150 on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 },
1151 );
1152
1153 $e->grab_focus;
1154 $dialog->show;
1155}
1156
1157sub open_quit_dialog {
1158 unless ($QUIT_DIALOG) {
1159 $QUIT_DIALOG = new CFPlus::UI::FancyFrame
1160 x => "center",
1161 y => "center",
1162 z => 50,
1163 title => "Really Quit?",
1164 on_key_down => sub {
1165 my ($dialog, $ev) = @_;
1166 $ev->{sym} == 27 and $dialog->hide;
1167 }
1168 ;
1169
1170 $QUIT_DIALOG->add (my $vb = new CFPlus::UI::VBox expand => 1);
1171
1172 $vb->add (new CFPlus::UI::Label
1173 text => "You should find a savebed and apply it first!",
1174 max_w => $WIDTH * 0.25,
1175 ellipsize => 0,
1176 );
1177 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1);
1178 $hb->add (new CFPlus::UI::Button
1179 text => "Ok",
1180 expand => 1,
1181 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1182 );
1183 $hb->add (new CFPlus::UI::Button
1184 text => "Quit anyway",
1185 expand => 1,
1186 on_activate => sub { exit },
1187 );
1188 }
1189
1190 $QUIT_DIALOG->show;
1191 $QUIT_DIALOG->grab_focus;
1192} 1133}
1193 1134
1194sub autopickup_setup { 1135sub autopickup_setup {
1195 my $table = new CFPlus::UI::Table; 1136 my $table = new CFPlus::UI::Table;
1196 1137
1353 $PL_WINDOW->show; 1294 $PL_WINDOW->show;
1354 } 1295 }
1355} 1296}
1356 1297
1357sub player_window { 1298sub player_window {
1358 my $plwin = $PL_WINDOW = new CFPlus::UI::FancyFrame 1299 my $plwin = $PL_WINDOW = new CFPlus::UI::Toplevel
1359 x => "center", 1300 x => "center",
1360 y => "center", 1301 y => "center",
1361 force_w => $WIDTH * 9/10, 1302 force_w => $WIDTH * 9/10,
1362 force_h => $HEIGHT * 9/10, 1303 force_h => $HEIGHT * 9/10,
1363 title => "Player", 1304 title => "Player",
1452 } 1393 }
1453 } 1394 }
1454 }; 1395 };
1455 1396
1456 my $vb = new CFPlus::UI::VBox; 1397 my $vb = new CFPlus::UI::VBox;
1398 $vb->add (new CFPlus::UI::FancyFrame
1399 label => "Options",
1457 $vb->add (my $hb = new CFPlus::UI::HBox); 1400 child => (my $hb = new CFPlus::UI::HBox),
1401 );
1458 $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");
1459 $hb->add (new CFPlus::UI::CheckBox 1403 $hb->add (new CFPlus::UI::CheckBox
1460 expand => 1, 1404 expand => 1,
1461 state => $CFG->{shift_fire_stop}, 1405 state => $CFG->{shift_fire_stop},
1462 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",
1464 my ($cbox, $value) = @_; 1408 my ($cbox, $value) = @_;
1465 $CFG->{shift_fire_stop} = $value; 1409 $CFG->{shift_fire_stop} = $value;
1466 0 1410 0
1467 }); 1411 });
1468 1412
1469 $vb->add ($binding_list); 1413 $vb->add (new CFPlus::UI::FancyFrame
1414 label => "Bindings",
1415 child => $binding_list);
1470 $vb->add (my $hb = new CFPlus::UI::HBox); 1416 $vb->add (my $hb = new CFPlus::UI::HBox);
1471 1417
1472 $hb->add (new CFPlus::UI::Button 1418 $hb->add (new CFPlus::UI::Button
1473 text => "record new", 1419 text => "record new",
1474 expand => 1, 1420 expand => 1,
1507 1453
1508 $vb 1454 $vb
1509} 1455}
1510 1456
1511sub help_window { 1457sub help_window {
1512 my $win = new CFPlus::UI::FancyFrame 1458 my $win = new CFPlus::UI::Toplevel
1513 x => 'center', 1459 x => 'center',
1514 y => 'center', 1460 y => 'center',
1515 z => 2, 1461 z => 4,
1516 name => 'doc_browser', 1462 name => 'doc_browser',
1517 force_w => int $WIDTH * 7/8, 1463 force_w => int $WIDTH * 7/8,
1518 force_h => int $HEIGHT * 7/8, 1464 force_h => int $HEIGHT * 7/8,
1519 title => "Help Browser", 1465 title => "Help Browser",
1520 has_close_button => 1; 1466 has_close_button => 1;
1521 1467
1522 $win->add (my $vbox = new CFPlus::UI::VBox); 1468 $win->add (my $vbox = new CFPlus::UI::VBox);
1523 1469
1470 $vbox->add (new CFPlus::UI::FancyFrame
1471 label => "Navigation",
1524 $vbox->add (my $buttons = new CFPlus::UI::HBox); 1472 child => (my $buttons = new CFPlus::UI::HBox),
1473 );
1525 $vbox->add (my $viewer = new CFPlus::UI::TextScroller 1474 $vbox->add (my $viewer = new CFPlus::UI::TextScroller
1526 expand => 1, fontsize => 0.8, padding_x => 4); 1475 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
1527 1476
1528 $buttons->add (new CFPlus::UI::Label text => "Choose a document to display: "); 1477 my @history;
1529 $buttons->add (my $combo = new CFPlus::UI::Selector 1478 my @future;
1530 value => undef, 1479 my $curnode;
1531 options => [ 1480
1532 [intro => "Introduction"], 1481 my $load_node; $load_node = sub {
1533 [manual => "Main Manual"], 1482 my ($node, $para) = @_;
1534 [skill_help => "Skill Reference"], 1483
1535 [command_help => "Command Reference"], 1484 $buttons->clear;
1536 [dmcommand_help => "DM Commands"], 1485
1537 [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 );
1538 ], 1506 }
1539 on_changed => sub {
1540 my ($self, $pod) = @_;
1541 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
1542 $viewer->clear; 1540 $viewer->clear;
1543 $viewer->add_paragraph (CFPlus::Pod::section pod => $pod); 1541 $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $curnode);
1544 $viewer->set_offset (0); 1542 $viewer->scroll_to ($para);
1543 };
1545 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;
1546 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;
1547 }, 1663 },
1548 on_visibility_change => sub {
1549 my ($self, $visible) = @_;
1550 return unless $visible;
1551 return if $self->{value};
1552 $self->set_value ("intro");
1553 0
1554 },
1555 ); 1664 );
1556 1665
1557 $win 1666 $dialog->show;
1558} 1667}
1559 1668
1560sub sdl_init { 1669sub sdl_init {
1561 CFPlus::SDL_Init 1670 CFPlus::SDL_Init
1562 and die "SDL::Init failed!\n"; 1671 and die "SDL::Init failed!\n";
1609 force_x => 0, 1718 force_x => 0,
1610 force_y => "max", 1719 force_y => "max",
1611 child => $STATUSBOX, 1720 child => $STATUSBOX,
1612 )->show; 1721 )->show;
1613 1722
1614 CFPlus::UI::FancyFrame->new ( 1723 CFPlus::UI::Toplevel->new (
1615 title => "Map", 1724 title => "Map",
1616 name => "mapmap", 1725 name => "mapmap",
1617 x => 0, 1726 x => 0,
1618 y => $FONTSIZE + 8, 1727 y => $FONTSIZE + 8,
1619 border_bg => [1, 1, 1, 192/255], 1728 border_bg => [1, 1, 1, 192/255],
1647 can_hover => 1, 1756 can_hover => 1,
1648 can_events => 1, 1757 can_events => 1,
1649 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.",
1650 ; 1759 ;
1651 1760
1652 $SETUP_DIALOG = new CFPlus::UI::FancyFrame 1761 $SETUP_DIALOG = new CFPlus::UI::Toplevel
1653 title => "Setup", 1762 title => "Setup",
1654 name => "setup_dialog", 1763 name => "setup_dialog",
1655 x => 'center', 1764 x => 'center',
1656 y => 'center', 1765 y => 'center',
1657 z => 2, 1766 z => 2,
1921 output_sync => 1, 2030 output_sync => 1,
1922 output_count => 1, 2031 output_count => 1,
1923 pickup => 0, 2032 pickup => 0,
1924 inv_sort => "mtime", 2033 inv_sort => "mtime",
1925 default => "profile", # default profile 2034 default => "profile", # default profile
2035 show_tips => 1,
1926 ); 2036 );
1927 2037
1928 while (my ($k, $v) = each %DEF_CFG) { 2038 while (my ($k, $v) = each %DEF_CFG) {
1929 $CFG->{$k} = $v unless exists $CFG->{$k}; 2039 $CFG->{$k} = $v unless exists $CFG->{$k};
1930 } 2040 }
1978 2088
1979 video_init; 2089 video_init;
1980 audio_init; 2090 audio_init;
1981} 2091}
1982 2092
2093show_tip_of_the_day if $CFG->{show_tips};
2094
1983Event::loop; 2095Event::loop;
1984#CFPlus::SDL_Quit; 2096#CFPlus::SDL_Quit;
1985#CFPlus::_exit 0; 2097#CFPlus::_exit 0;
1986 2098
1987END { CFPlus::SDL_Quit } 2099END { CFPlus::SDL_Quit }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines