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.120 by root, Sun Oct 1 14:48:51 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";
71our $LAST_REFRESH; 63our $LAST_REFRESH;
72our $NOW; 64our $NOW;
73 65
74our $CFG; 66our $CFG;
75our $CONN; 67our $CONN;
68our $PROFILE; # current profile
76our $FAST; # fast, low-quality mode, possibly useful for software-rendering 69our $FAST; # fast, low-quality mode, possibly useful for software-rendering
77 70
78our $WANT_REFRESH; 71our $WANT_REFRESH;
79our $CAN_REFRESH; 72our $CAN_REFRESH;
80 73
155 148
156# server query dialog 149# server query dialog
157sub server_query { 150sub server_query {
158 my ($conn, $flags, $prompt) = @_; 151 my ($conn, $flags, $prompt) = @_;
159 152
160 $conn->{query_dialog} = my $dialog = new CFPlus::UI::FancyFrame 153 $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel
161 x => "center", 154 x => "center",
162 y => "center", 155 y => "center",
163 title => "Server Query", 156 title => "Server Query",
164 child => my $vbox = new CFPlus::UI::VBox, 157 child => my $vbox = new CFPlus::UI::VBox,
165 ; 158 ;
190 ); 183 );
191 184
192 $dialog->grab_focus; 185 $dialog->grab_focus;
193 186
194 } elsif ($flags & CS_QUERY_SINGLECHAR) { 187 } elsif ($flags & CS_QUERY_SINGLECHAR) {
195 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; 188 $dialog->{tooltip} = "#charcreation_focus";
196 189
197 if ($prompt =~ /Now choose a character|Press any key for the next race/i) { 190 if ($prompt =~ /Now choose a character|Press any key for the next race/i) {
198 $MESSAGE_WINDOW->show; 191 $MESSAGE_WINDOW->show;
199 192
200 unshift @dialog, new CFPlus::UI::Label 193 unshift @dialog, new CFPlus::UI::Label
222 ); 215 );
223 216
224 unshift @dialog, new CFPlus::UI::Label 217 unshift @dialog, new CFPlus::UI::Label
225 max_w => $::WIDTH * 0.4, 218 max_w => $::WIDTH * 0.4,
226 ellipsise => 0, 219 ellipsise => 0,
227 markup => 220 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 ; 221 ;
236 222
237 } elsif ($prompt =~ /roll new stats/) { 223 } elsif ($prompt =~ /roll new stats/) {
238 if (my $stat = delete $conn->{stat_change_with}) { 224 if (my $stat = delete $conn->{stat_change_with}) {
239 $conn->send ("reply $stat"); 225 $conn->send ("reply $stat");
313 markup => "$conn->{stat}{$id} <span foreground='yellow'>$name</span>", 299 markup => "$conn->{stat}{$id} <span foreground='yellow'>$name</span>",
314 align => 0, 300 align => 0,
315 expand => 1, 301 expand => 1,
316 can_events => 1, 302 can_events => 1,
317 can_hover => 1, 303 can_hover => 1,
318 tooltip => $CFPlus::STAT_TOOLTIP{$name}, 304 tooltip => "#stat_$name",
319 ); 305 );
320 } 306 }
321 307
322 unshift @dialog, new CFPlus::UI::Label 308 unshift @dialog, new CFPlus::UI::Label
323 max_w => $::WIDTH * 0.4, 309 max_w => $::WIDTH * 0.4,
324 ellipsise => 0, 310 ellipsise => 0,
325 markup => 311 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 ; 312 ;
332 } 313 }
333 314
334 push @dialog, my $entry = new CFPlus::UI::Entry 315 push @dialog, my $entry = new CFPlus::UI::Entry
335 on_changed => sub { 316 on_changed => sub {
364 status "logging in..."; 345 status "logging in...";
365 346
366 $LOGIN_BUTTON->set_text ("Logout"); 347 $LOGIN_BUTTON->set_text ("Logout");
367 $SETUP_DIALOG->hide; 348 $SETUP_DIALOG->hide;
368 349
350 $PROFILE = $CFG->{profile}{default};
351
369 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 352 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
370 353
371 my ($host, $port) = split /:/, $CFG->{profile}{default}{host}; 354 my ($host, $port) = split /:/, $PROFILE->{host};
372 355
373 $MAP = new CFPlus::Map $mapsize, $mapsize; 356 $MAP = new CFPlus::Map $mapsize, $mapsize;
374 357
375 $CONN = eval { 358 $CONN = eval {
376 new CFPlus::Protocol 359 new CFPlus::Protocol
377 host => $host, 360 host => $host,
378 port => $port || 13327, 361 port => $port || 13327,
379 user => $CFG->{profile}{default}{user}, 362 user => $PROFILE->{user},
380 pass => $CFG->{profile}{default}{password}, 363 pass => $PROFILE->{password},
381 mapw => $mapsize, 364 mapw => $mapsize,
382 maph => $mapsize, 365 maph => $mapsize,
366
367 client => "cfplus $VERSION $] $^O",
383 368
384 map_widget => $MAPWIDGET, 369 map_widget => $MAPWIDGET,
385 logview => $LOGVIEW, 370 logview => $LOGVIEW,
386 statusbox => $STATUSBOX, 371 statusbox => $STATUSBOX,
387 map => $MAP, 372 map => $MAP,
425 destroy_query_dialog $CONN; 410 destroy_query_dialog $CONN;
426 $CONN->destroy; 411 $CONN->destroy;
427 $CONN = 0; # false, does not autovivify 412 $CONN = 0; # false, does not autovivify
428 413
429 undef $MAP; 414 undef $MAP;
415 undef $PROFILE;
430} 416}
431 417
432sub graphics_setup { 418sub graphics_setup {
433 my $vbox = new CFPlus::UI::VBox; 419 my $vbox = new CFPlus::UI::VBox;
434 420
622 (new CFPlus::UI::Empty expand => 1), 608 (new CFPlus::UI::Empty expand => 1),
623 (my $hb = new CFPlus::UI::HBox), 609 (my $hb = new CFPlus::UI::HBox),
624 ], 610 ],
625 ); 611 );
626 612
627 $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', 613 $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', 614 $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', 615 $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', 616 $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 617
636 $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, 618 $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, 619 $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 620
641 $GAUGES = { 621 $GAUGES = {
642 exp => $exp, win => $win, range => $rng, 622 exp => $exp, win => $win, range => $rng,
643 food => $fg, mana => $mg, hp => $hg, grace => $gg 623 food => $fg, mana => $mg, hp => $hg, grace => $gg
644 }; 624 };
681 expand => 1, 661 expand => 1,
682 scroll_y => 1 662 scroll_y => 1
683 ); 663 );
684 $r->add (my $vb = new CFPlus::UI::VBox); 664 $r->add (my $vb = new CFPlus::UI::VBox);
685 665
666 $vb->add (new CFPlus::UI::FancyFrame
667 label => "Player",
668 child => (my $pi = new CFPlus::UI::VBox),
669 );
670
686 $vb->add ($STATWIDS->{title} = new CFPlus::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, 671 $pi->add ($STATWIDS->{title} = new CFPlus::UI::Label valign => 0, align => -1, text => "Title:", expand => 1,
687 can_hover => 1, can_events => 1, 672 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."); 673 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, 674 $pi->add ($STATWIDS->{map} = new CFPlus::UI::Label valign => 0, align => -1, text => "Map:", expand => 1,
690 can_hover => 1, can_events => 1, 675 can_hover => 1, can_events => 1,
691 tooltip => "The map you are currently on (if supported by the server)."); 676 tooltip => "The map you are currently on (if supported by the server).");
692 677
693 $vb->add (my $hb0 = new CFPlus::UI::HBox); 678 $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, 679 $hb0->add ($STATWIDS->{weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Weight:", expand => 1,
695 can_hover => 1, can_events => 1, 680 can_hover => 1, can_events => 1,
696 tooltip => "The weight of the player including all inventory items."); 681 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, 682 $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, 683 can_hover => 1, can_events => 1,
699 tooltip => "The weight limit: you cannot carry more than this."); 684 tooltip => "The weight limit: you cannot carry more than this.");
700 685
686 $vb->add (new CFPlus::UI::FancyFrame
687 label => "Primary/Secondary Statistics",
701 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1); 688 child => (my $hb = new CFPlus::UI::HBox expand => 1),
689 );
702 $hb->add (my $tbl = new CFPlus::UI::Table expand => 1); 690 $hb->add (my $tbl = new CFPlus::UI::Table expand => 1);
703 691
704 my $color2 = [1, 1, 0]; 692 my $color2 = [1, 1, 0];
705 693
706 for ( 694 for (
721 ) { 709 ) {
722 my ($col, $row, $id, $label, $template) = @$_; 710 my ($col, $row, $id, $label, $template) = @$_;
723 711
724 $tbl->add ($col , $row, $STATWIDS->{$id} = new CFPlus::UI::Label 712 $tbl->add ($col , $row, $STATWIDS->{$id} = new CFPlus::UI::Label
725 font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, 713 font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0,
726 align => +1, template => $template, tooltip => $CFPlus::STAT_TOOLTIP{$label}); 714 align => +1, template => $template, tooltip => "#stat_$label");
727 $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFPlus::UI::Label 715 $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, 716 font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0,
729 align => -1, text => $label, tooltip => $CFPlus::STAT_TOOLTIP{$label}); 717 align => -1, text => $label, tooltip => "#stat_$label");
730 } 718 }
731 719
720 $vb->add (new CFPlus::UI::FancyFrame
721 label => "Resistancies",
732 $vb->add (my $tbl2 = new CFPlus::UI::Table expand => 1); 722 child => (my $tbl2 = new CFPlus::UI::Table expand => 1),
723 );
733 724
734 my $row = 0; 725 my $row = 0;
735 my $col = 0; 726 my $col = 0;
736 727
737 my %resist_names = ( 728 my %resist_names = (
931sub metaserver_dialog { 922sub metaserver_dialog {
932 my $vbox = new CFPlus::UI::VBox; 923 my $vbox = new CFPlus::UI::VBox;
933 my $table = new CFPlus::UI::Table; 924 my $table = new CFPlus::UI::Table;
934 $vbox->add (new CFPlus::UI::ScrolledWindow expand => 1, child => $table); 925 $vbox->add (new CFPlus::UI::ScrolledWindow expand => 1, child => $table);
935 926
936 my $dialog = new CFPlus::UI::FancyFrame 927 my $dialog = new CFPlus::UI::Toplevel
937 title => "Server List", 928 title => "Server List",
938 name => 'metaserver_dialog', 929 name => 'metaserver_dialog',
939 x => 'center', 930 x => 'center',
940 y => 'center', 931 y => 'center',
941 z => 3, 932 z => 3,
953} 944}
954 945
955sub server_setup { 946sub server_setup {
956 my $vbox = new CFPlus::UI::VBox; 947 my $vbox = new CFPlus::UI::VBox;
957 948
949 $vbox->add (new CFPlus::UI::FancyFrame
950 label => "Connection Settings",
958 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]); 951 child => (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]),
952 );
959 $table->add (0, 2, new CFPlus::UI::Label valign => 0, align => 1, text => "Host:Port"); 953 $table->add (0, 2, new CFPlus::UI::Label valign => 0, align => 1, text => "Host:Port");
960 954
961 { 955 {
962 $table->add (1, 2, my $vbox = new CFPlus::UI::VBox); 956 $table->add (1, 2, my $vbox = new CFPlus::UI::VBox);
963 957
1047 }, 1041 },
1048 ); 1042 );
1049 1043
1050 $table->add (0, 12, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command"); 1044 $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 1045 $table->add (1, 12, my $saycmd = new CFPlus::UI::Entry
1052 text => $CFG->{say_command}, 1046 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. " 1047 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. " 1048 . "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.", 1049 . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.",
1056 on_changed => sub { 1050 on_changed => sub {
1057 my ($self, $value) = @_; 1051 my ($self, $value) = @_;
1058 $CFG->{say_command} = $value; 1052 $CFG->{say_command} = $value;
1059 0 1053 0
1060 } 1054 }
1061 ); 1055 );
1062 1056
1057 $table->add (0, 13, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day");
1058 $table->add (1, 13, my $saycmd = new CFPlus::UI::CheckBox
1059 state => $CFG->{show_tips},
1060 tooltip => "Show the <b>Tip of the day</b> window at startup?",
1061 on_changed => sub {
1062 my ($self, $value) = @_;
1063 $CFG->{shop_tips} = $value;
1064 0
1065 }
1066 );
1067
1063 $vbox->add (new CFPlus::UI::Label 1068 $vbox->add (new CFPlus::UI::FancyFrame
1064 text => "Server Info", 1069 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); 1070 child => ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0),
1071 );
1071 1072
1072 $vbox 1073 $vbox
1073} 1074}
1074 1075
1075sub message_window { 1076sub message_window {
1076 my $window = new CFPlus::UI::FancyFrame 1077 my $window = new CFPlus::UI::Toplevel
1077 name => "message_window", 1078 name => "message_window",
1078 title => "Messages", 1079 title => "Messages",
1079 border_bg => [1, 1, 1, 1], 1080 border_bg => [1, 1, 1, 1],
1080 x => "max", 1081 x => "max",
1081 y => 0, 1082 y => 0,
1131 window => $window, 1132 window => $window,
1132 input => $input, 1133 input => $input,
1133 }; 1134 };
1134 1135
1135 $window 1136 $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} 1137}
1174 1138
1175sub autopickup_setup { 1139sub autopickup_setup {
1176 my $table = new CFPlus::UI::Table; 1140 my $table = new CFPlus::UI::Table;
1177 1141
1334 $PL_WINDOW->show; 1298 $PL_WINDOW->show;
1335 } 1299 }
1336} 1300}
1337 1301
1338sub player_window { 1302sub player_window {
1339 my $plwin = $PL_WINDOW = new CFPlus::UI::FancyFrame 1303 my $plwin = $PL_WINDOW = new CFPlus::UI::Toplevel
1340 x => "center", 1304 x => "center",
1341 y => "center", 1305 y => "center",
1342 force_w => $WIDTH * 9/10, 1306 force_w => $WIDTH * 9/10,
1343 force_h => $HEIGHT * 9/10, 1307 force_h => $HEIGHT * 9/10,
1344 title => "Player", 1308 title => "Player",
1386 1350
1387 my $refresh; 1351 my $refresh;
1388 $refresh = $BIND_UPD_CB = sub { 1352 $refresh = $BIND_UPD_CB = sub {
1389 $binding_list->clear (); 1353 $binding_list->clear ();
1390 1354
1355 return unless $PROFILE;
1356
1391 for my $mod (keys %{$::CFG->{profile}{default}{bindings}}) { 1357 for my $mod (keys %{$PROFILE->{bindings}}) {
1392 for my $sym (keys %{$::CFG->{profile}{default}{bindings}{$mod}}) { 1358 for my $sym (keys %{$PROFILE->{bindings}{$mod}}) {
1393 my $cmds = $::CFG->{profile}{default}{bindings}{$mod}{$sym}; 1359 my $cmds = $PROFILE->{bindings}{$mod}{$sym};
1394 next unless ref $cmds eq 'ARRAY' and @$cmds > 0; 1360 next unless ref $cmds eq 'ARRAY' and @$cmds > 0;
1395 1361
1396 my $lbl = join "; ", @$cmds; 1362 my $lbl = join "; ", @$cmds;
1397 my $nam = CFPlus::BindingEditor::keycombo_to_name ($mod, $sym); 1363 my $nam = CFPlus::BindingEditor::keycombo_to_name ($mod, $sym);
1398 $binding_list->add (my $hb = new CFPlus::UI::HBox); 1364 $binding_list->add (my $hb = new CFPlus::UI::HBox);
1399 $hb->add (new CFPlus::UI::Button 1365 $hb->add (new CFPlus::UI::Button
1400 text => "delete", 1366 text => "delete",
1401 tooltip => "Deletes the binding", 1367 tooltip => "Deletes the binding",
1402 on_activate => sub { 1368 on_activate => sub {
1403 $binding_list->remove ($hb); 1369 $binding_list->remove ($hb);
1404 delete $::CFG->{profile}{default}{bindings}{$mod}{$sym}; 1370 delete $PROFILE->{bindings}{$mod}{$sym};
1405 0 1371 0
1406 }); 1372 });
1407 1373
1408 $hb->add (new CFPlus::UI::Button 1374 $hb->add (new CFPlus::UI::Button
1409 text => "edit", 1375 text => "edit",
1410 tooltip => "Edits the binding", 1376 tooltip => "Edits the binding",
1411 on_activate => sub { 1377 on_activate => sub {
1412 $::BIND_EDITOR->set_binding ( 1378 $::BIND_EDITOR->set_binding (
1413 $mod, $sym, $::CFG->{profile}{default}{bindings}{$mod}{$sym}, 1379 $mod, $sym, $PROFILE->{bindings}{$mod}{$sym},
1414 sub { 1380 sub {
1415 my ($nmod, $nsym, $ncmds) = @_; 1381 my ($nmod, $nsym, $ncmds) = @_;
1416 $::BIND_EDITOR->cfg_unbind ($mod, $sym); 1382 $::BIND_EDITOR->cfg_unbind ($mod, $sym);
1417 $::BIND_EDITOR->cfg_bind ($nmod, $nsym, $ncmds); 1383 $::BIND_EDITOR->cfg_bind ($nmod, $nsym, $ncmds);
1418 $refresh->(); 1384 $refresh->();
1433 } 1399 }
1434 } 1400 }
1435 }; 1401 };
1436 1402
1437 my $vb = new CFPlus::UI::VBox; 1403 my $vb = new CFPlus::UI::VBox;
1404 $vb->add (new CFPlus::UI::FancyFrame
1405 label => "Options",
1438 $vb->add (my $hb = new CFPlus::UI::HBox); 1406 child => (my $hb = new CFPlus::UI::HBox),
1407 );
1439 $hb->add (new CFPlus::UI::Label text => "only shift-up stops fire"); 1408 $hb->add (new CFPlus::UI::Label text => "only shift-up stops fire");
1440 $hb->add (new CFPlus::UI::CheckBox 1409 $hb->add (new CFPlus::UI::CheckBox
1441 expand => 1, 1410 expand => 1,
1442 state => $CFG->{shift_fire_stop}, 1411 state => $CFG->{shift_fire_stop},
1443 tooltip => "If this checkbox is enabled you will stop fire only if you stop pressing shift", 1412 tooltip => "If this checkbox is enabled you will stop fire only if you stop pressing shift",
1445 my ($cbox, $value) = @_; 1414 my ($cbox, $value) = @_;
1446 $CFG->{shift_fire_stop} = $value; 1415 $CFG->{shift_fire_stop} = $value;
1447 0 1416 0
1448 }); 1417 });
1449 1418
1450 $vb->add ($binding_list); 1419 $vb->add (new CFPlus::UI::FancyFrame
1420 label => "Bindings",
1421 child => $binding_list);
1451 $vb->add (my $hb = new CFPlus::UI::HBox); 1422 $vb->add (my $hb = new CFPlus::UI::HBox);
1452 1423
1453 $hb->add (new CFPlus::UI::Button 1424 $hb->add (new CFPlus::UI::Button
1454 text => "record new", 1425 text => "record new",
1455 expand => 1, 1426 expand => 1,
1488 1459
1489 $vb 1460 $vb
1490} 1461}
1491 1462
1492sub help_window { 1463sub help_window {
1493 my $win = new CFPlus::UI::FancyFrame 1464 my $win = new CFPlus::UI::Toplevel
1494 x => 'center', 1465 x => 'center',
1495 y => 'center', 1466 y => 'center',
1496 z => 2, 1467 z => 4,
1497 name => 'doc_browser', 1468 name => 'doc_browser',
1498 force_w => int $WIDTH * 7/8, 1469 force_w => int $WIDTH * 7/8,
1499 force_h => int $HEIGHT * 7/8, 1470 force_h => int $HEIGHT * 7/8,
1500 title => "Help Browser", 1471 title => "Help Browser",
1501 has_close_button => 1; 1472 has_close_button => 1;
1502 1473
1503 $win->add (my $vbox = new CFPlus::UI::VBox); 1474 $win->add (my $vbox = new CFPlus::UI::VBox);
1504 1475
1476 $vbox->add (new CFPlus::UI::FancyFrame
1477 label => "Navigation",
1505 $vbox->add (my $buttons = new CFPlus::UI::HBox); 1478 child => (my $buttons = new CFPlus::UI::HBox),
1479 );
1506 $vbox->add (my $viewer = new CFPlus::UI::TextScroller 1480 $vbox->add (my $viewer = new CFPlus::UI::TextScroller
1507 expand => 1, fontsize => 0.8, padding_x => 4); 1481 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
1508 1482
1509 $buttons->add (new CFPlus::UI::Label text => "Choose a document to display: "); 1483 my @history;
1510 $buttons->add (my $combo = new CFPlus::UI::Selector 1484 my @future;
1511 value => undef, 1485 my $curnode;
1512 options => [ 1486
1513 [intro => "Introduction"], 1487 my $load_node; $load_node = sub {
1514 [manual => "Main Manual"], 1488 my ($node, $para) = @_;
1515 [skill_help => "Skill Reference"], 1489
1516 [command_help => "Command Reference"], 1490 $buttons->clear;
1517 [dmcommand_help => "DM Commands"], 1491
1518 [COPYING => "License Terms"], 1492 $buttons->add (new CFPlus::UI::Button
1493 text => "⇤",
1494 tooltip => "back to the starting page",
1495 on_activate => sub {
1496 unshift @future, [$curnode, $viewer->current_paragraph] if $curnode;
1497 unshift @future, @history;
1498 @history = ();
1499 $load_node->(@{shift @future});
1500 },
1501 );
1502
1503 if (@history) {
1504 $buttons->add (new CFPlus::UI::Button
1505 text => "⋘",
1506 tooltip => "back to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $history[-1][0]) . "</i>",
1507 on_activate => sub {
1508 unshift @future, [$curnode, $viewer->current_paragraph] if $curnode;
1509 $load_node->(@{pop @history});
1510 },
1511 );
1519 ], 1512 }
1520 on_changed => sub {
1521 my ($self, $pod) = @_;
1522 1513
1514 if (@future) {
1515 $buttons->add (new CFPlus::UI::Button
1516 text => "⋙",
1517 tooltip => "forward to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $future[0][0]) . "</i>",
1518 on_activate => sub {
1519 push @history, [$curnode, $viewer->current_paragraph];
1520 $load_node->(@{shift @future});
1521 },
1522 );
1523 }
1524
1525 $buttons->add (new CFPlus::UI::Label text => " ");
1526
1527 my @path = CFPlus::Pod::full_path_of $node;
1528 pop @path; # drop current node
1529
1530 for my $node (@path) {
1531 $buttons->add (new CFPlus::UI::Button
1532 text => $node->{kw}[0],
1533 tooltip => "go to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $node) . "</i>",
1534 on_activate => sub {
1535 push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = ();
1536 $load_node->($node);
1537 },
1538 );
1539 $buttons->add (new CFPlus::UI::Label text => "/");
1540 }
1541
1542 $buttons->add (new CFPlus::UI::Label text => $node->{kw}[0], padding_x => 4, padding_y => 4);
1543
1544 $curnode = $node;
1545
1523 $viewer->clear; 1546 $viewer->clear;
1524 $viewer->add_paragraph (@{ CFPlus::Pod::pod_paragraphs $pod }); 1547 $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $curnode);
1525 $viewer->set_offset (0); 1548 $viewer->scroll_to ($para);
1549 };
1526 1550
1551 $load_node->(CFPlus::Pod::find pod => "mainpage");
1552
1553 $CFPlus::Pod::goto_document = sub {
1554 my (@path) = @_;
1555
1556 push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = ();
1557
1558 $load_node->((CFPlus::Pod::find @path)[0]);
1559 $win->show;
1560 };
1561
1562 $win
1563}
1564
1565sub open_string_query {
1566 my ($title, $cb, $txt, $tooltip) = @_;
1567 my $dialog = new CFPlus::UI::Toplevel
1568 x => "center",
1569 y => "center",
1570 z => 50,
1571 force_w => $WIDTH * 4/5,
1572 title => $title;
1573
1574 $dialog->add (
1575 my $e = new CFPlus::UI::Entry
1576 on_activate => sub { $cb->(@_); $dialog->hide; 0 },
1577 on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 },
1578 tooltip => $tooltip
1579 );
1580
1581 $e->grab_focus;
1582 $e->set_text ($txt) if $txt;
1583 $dialog->show;
1584}
1585
1586sub open_quit_dialog {
1587 unless ($QUIT_DIALOG) {
1588 $QUIT_DIALOG = new CFPlus::UI::Toplevel
1589 x => "center",
1590 y => "center",
1591 z => 50,
1592 title => "Really Quit?",
1593 on_key_down => sub {
1594 my ($dialog, $ev) = @_;
1595 $ev->{sym} == 27 and $dialog->hide;
1527 0 1596 }
1597 ;
1598
1599 $QUIT_DIALOG->add (my $vb = new CFPlus::UI::VBox expand => 1);
1600
1601 $vb->add (new CFPlus::UI::Label
1602 text => "You should find a savebed and apply it first!",
1603 max_w => $WIDTH * 0.25,
1604 ellipsize => 0,
1605 );
1606 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1);
1607 $hb->add (new CFPlus::UI::Button
1608 text => "Ok",
1609 expand => 1,
1610 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1611 );
1612 $hb->add (new CFPlus::UI::Button
1613 text => "Quit anyway",
1614 expand => 1,
1615 on_activate => sub { exit },
1616 );
1617 }
1618
1619 $QUIT_DIALOG->show;
1620 $QUIT_DIALOG->grab_focus;
1621}
1622
1623sub show_tip_of_the_day {
1624 # find all tips
1625 my @tod = CFPlus::Pod::find tip_of_the_day => "*";
1626
1627 my $todindex = $CFPlus::DB_STATE->get ("tip_of_the_day");
1628 $todindex = 0 if $todindex >= @tod;
1629 $CFPlus::DB_STATE->put (tip_of_the_day => $todindex + 1);
1630
1631 # create dialog
1632 my $dialog;
1633
1634 my $close = sub {
1635 $dialog->destroy;
1636 };
1637
1638 $dialog = new CFPlus::UI::Toplevel
1639 x => "center",
1640 y => "center",
1641 z => 3,
1642 name => 'tip_of_the_day',
1643 force_w => int $WIDTH * 4/9,
1644 force_h => int $WIDTH * 2/9,
1645 title => "Tip of the day #" . (1 + $todindex),
1646 child => my $vbox = new CFPlus::UI::VBox,
1647 has_close_button => 1,
1648 on_delete => $close,
1649 ;
1650
1651 $vbox->add (my $viewer = new CFPlus::UI::TextScroller
1652 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
1653 $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $tod[$todindex]);
1654
1655 $vbox->add (my $table = new CFPlus::UI::Table);
1656
1657 $table->add (0, 0, new CFPlus::UI::Button
1658 text => "Close",
1659 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>.",
1660 on_activate => $close,
1661 );
1662
1663 $table->add (2, 0, new CFPlus::UI::Button
1664 text => "Next",
1665 tooltip => "Show the next <b>Tip of the day</b>.",
1666 on_activate => sub {
1667 $close->();
1668 &show_tip_of_the_day;
1528 }, 1669 },
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 ); 1670 );
1537 1671
1538 $win 1672 $dialog->show;
1539} 1673}
1540 1674
1541sub sdl_init { 1675sub sdl_init {
1542 CFPlus::SDL_Init 1676 CFPlus::SDL_Init
1543 and die "SDL::Init failed!\n"; 1677 and die "SDL::Init failed!\n";
1590 force_x => 0, 1724 force_x => 0,
1591 force_y => "max", 1725 force_y => "max",
1592 child => $STATUSBOX, 1726 child => $STATUSBOX,
1593 )->show; 1727 )->show;
1594 1728
1595 CFPlus::UI::FancyFrame->new ( 1729 CFPlus::UI::Toplevel->new (
1596 title => "Map", 1730 title => "Map",
1597 name => "mapmap", 1731 name => "mapmap",
1598 x => 0, 1732 x => 0,
1599 y => $FONTSIZE + 8, 1733 y => $FONTSIZE + 8,
1600 border_bg => [1, 1, 1, 192/255], 1734 border_bg => [1, 1, 1, 192/255],
1628 can_hover => 1, 1762 can_hover => 1,
1629 can_events => 1, 1763 can_events => 1,
1630 tooltip => "<b>Server Log</b>. This text viewer contains all the messages sent by the server.", 1764 tooltip => "<b>Server Log</b>. This text viewer contains all the messages sent by the server.",
1631 ; 1765 ;
1632 1766
1633 $SETUP_DIALOG = new CFPlus::UI::FancyFrame 1767 $SETUP_DIALOG = new CFPlus::UI::Toplevel
1634 title => "Setup", 1768 title => "Setup",
1635 name => "setup_dialog", 1769 name => "setup_dialog",
1636 x => 'center', 1770 x => 'center',
1637 y => 'center', 1771 y => 'center',
1638 z => 2, 1772 z => 2,
1902 output_sync => 1, 2036 output_sync => 1,
1903 output_count => 1, 2037 output_count => 1,
1904 pickup => 0, 2038 pickup => 0,
1905 inv_sort => "mtime", 2039 inv_sort => "mtime",
1906 default => "profile", # default profile 2040 default => "profile", # default profile
2041 show_tips => 1,
1907 ); 2042 );
1908 2043
1909 while (my ($k, $v) = each %DEF_CFG) { 2044 while (my ($k, $v) = each %DEF_CFG) {
1910 $CFG->{$k} = $v unless exists $CFG->{$k}; 2045 $CFG->{$k} = $v unless exists $CFG->{$k};
1911 } 2046 }
1959 2094
1960 video_init; 2095 video_init;
1961 audio_init; 2096 audio_init;
1962} 2097}
1963 2098
2099show_tip_of_the_day if $CFG->{show_tips};
2100
2101use Data::Dumper; warn Dumper [CFPlus::win32_proxy_info()];#d#
2102
1964Event::loop; 2103Event::loop;
1965#CFPlus::SDL_Quit; 2104#CFPlus::SDL_Quit;
1966#CFPlus::_exit 0; 2105#CFPlus::_exit 0;
1967 2106
1968END { CFPlus::SDL_Quit } 2107END { CFPlus::SDL_Quit }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines