… | |
… | |
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 | |
|
|
64 | our $VERSION = '0.1'; |
56 | our $VERSION = '0.9'; |
65 | |
57 | |
66 | my $MAX_FPS = 60; |
58 | my $MAX_FPS = 60; |
67 | my $MIN_FPS = 5; # unused as of yet |
59 | my $MIN_FPS = 5; # unused as of yet |
68 | |
60 | |
69 | our $META_SERVER = "crossfire.real-time.com:13326"; |
61 | our $META_SERVER = "crossfire.real-time.com:13326"; |
… | |
… | |
71 | our $LAST_REFRESH; |
63 | our $LAST_REFRESH; |
72 | our $NOW; |
64 | our $NOW; |
73 | |
65 | |
74 | our $CFG; |
66 | our $CFG; |
75 | our $CONN; |
67 | our $CONN; |
|
|
68 | our $PROFILE; # current profile |
76 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
69 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
77 | |
70 | |
78 | our $WANT_REFRESH; |
71 | our $WANT_REFRESH; |
79 | our $CAN_REFRESH; |
72 | our $CAN_REFRESH; |
80 | |
73 | |
… | |
… | |
155 | |
148 | |
156 | # server query dialog |
149 | # server query dialog |
157 | sub server_query { |
150 | sub 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 | ; |
… | |
… | |
352 | status "logging in..."; |
345 | status "logging in..."; |
353 | |
346 | |
354 | $LOGIN_BUTTON->set_text ("Logout"); |
347 | $LOGIN_BUTTON->set_text ("Logout"); |
355 | $SETUP_DIALOG->hide; |
348 | $SETUP_DIALOG->hide; |
356 | |
349 | |
|
|
350 | $PROFILE = $CFG->{profile}{default}; |
|
|
351 | |
357 | 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; |
358 | |
353 | |
359 | my ($host, $port) = split /:/, $CFG->{profile}{default}{host}; |
354 | my ($host, $port) = split /:/, $PROFILE->{host}; |
360 | |
355 | |
361 | $MAP = new CFPlus::Map $mapsize, $mapsize; |
356 | $MAP = new CFPlus::Map $mapsize, $mapsize; |
362 | |
357 | |
363 | $CONN = eval { |
358 | $CONN = eval { |
364 | new CFPlus::Protocol |
359 | new CFPlus::Protocol |
365 | host => $host, |
360 | host => $host, |
366 | port => $port || 13327, |
361 | port => $port || 13327, |
367 | user => $CFG->{profile}{default}{user}, |
362 | user => $PROFILE->{user}, |
368 | pass => $CFG->{profile}{default}{password}, |
363 | pass => $PROFILE->{password}, |
369 | mapw => $mapsize, |
364 | mapw => $mapsize, |
370 | maph => $mapsize, |
365 | maph => $mapsize, |
|
|
366 | |
|
|
367 | client => "cfplus $VERSION $] $^O", |
371 | |
368 | |
372 | map_widget => $MAPWIDGET, |
369 | map_widget => $MAPWIDGET, |
373 | logview => $LOGVIEW, |
370 | logview => $LOGVIEW, |
374 | statusbox => $STATUSBOX, |
371 | statusbox => $STATUSBOX, |
375 | map => $MAP, |
372 | map => $MAP, |
… | |
… | |
413 | destroy_query_dialog $CONN; |
410 | destroy_query_dialog $CONN; |
414 | $CONN->destroy; |
411 | $CONN->destroy; |
415 | $CONN = 0; # false, does not autovivify |
412 | $CONN = 0; # false, does not autovivify |
416 | |
413 | |
417 | undef $MAP; |
414 | undef $MAP; |
|
|
415 | undef $PROFILE; |
418 | } |
416 | } |
419 | |
417 | |
420 | sub graphics_setup { |
418 | sub graphics_setup { |
421 | my $vbox = new CFPlus::UI::VBox; |
419 | my $vbox = new CFPlus::UI::VBox; |
422 | |
420 | |
… | |
… | |
663 | expand => 1, |
661 | expand => 1, |
664 | scroll_y => 1 |
662 | scroll_y => 1 |
665 | ); |
663 | ); |
666 | $r->add (my $vb = new CFPlus::UI::VBox); |
664 | $r->add (my $vb = new CFPlus::UI::VBox); |
667 | |
665 | |
|
|
666 | $vb->add (new CFPlus::UI::FancyFrame |
|
|
667 | label => "Player", |
|
|
668 | child => (my $pi = new CFPlus::UI::VBox), |
|
|
669 | ); |
|
|
670 | |
668 | $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, |
669 | can_hover => 1, can_events => 1, |
672 | can_hover => 1, can_events => 1, |
670 | 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."); |
671 | $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, |
672 | can_hover => 1, can_events => 1, |
675 | can_hover => 1, can_events => 1, |
673 | 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)."); |
674 | |
677 | |
675 | $vb->add (my $hb0 = new CFPlus::UI::HBox); |
678 | $pi->add (my $hb0 = new CFPlus::UI::HBox); |
676 | $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, |
677 | can_hover => 1, can_events => 1, |
680 | can_hover => 1, can_events => 1, |
678 | tooltip => "The weight of the player including all inventory items."); |
681 | tooltip => "The weight of the player including all inventory items."); |
679 | $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, |
680 | can_hover => 1, can_events => 1, |
683 | can_hover => 1, can_events => 1, |
681 | tooltip => "The weight limit: you cannot carry more than this."); |
684 | tooltip => "The weight limit: you cannot carry more than this."); |
682 | |
685 | |
|
|
686 | $vb->add (new CFPlus::UI::FancyFrame |
|
|
687 | label => "Primary/Secondary Statistics", |
683 | $vb->add (my $hb = new CFPlus::UI::HBox expand => 1); |
688 | child => (my $hb = new CFPlus::UI::HBox expand => 1), |
|
|
689 | ); |
684 | $hb->add (my $tbl = new CFPlus::UI::Table expand => 1); |
690 | $hb->add (my $tbl = new CFPlus::UI::Table expand => 1); |
685 | |
691 | |
686 | my $color2 = [1, 1, 0]; |
692 | my $color2 = [1, 1, 0]; |
687 | |
693 | |
688 | for ( |
694 | for ( |
… | |
… | |
709 | $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 |
710 | 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, |
711 | align => -1, text => $label, tooltip => "#stat_$label"); |
717 | align => -1, text => $label, tooltip => "#stat_$label"); |
712 | } |
718 | } |
713 | |
719 | |
|
|
720 | $vb->add (new CFPlus::UI::FancyFrame |
|
|
721 | label => "Resistancies", |
714 | $vb->add (my $tbl2 = new CFPlus::UI::Table expand => 1); |
722 | child => (my $tbl2 = new CFPlus::UI::Table expand => 1), |
|
|
723 | ); |
715 | |
724 | |
716 | my $row = 0; |
725 | my $row = 0; |
717 | my $col = 0; |
726 | my $col = 0; |
718 | |
727 | |
719 | my %resist_names = ( |
728 | my %resist_names = ( |
… | |
… | |
913 | sub metaserver_dialog { |
922 | sub metaserver_dialog { |
914 | my $vbox = new CFPlus::UI::VBox; |
923 | my $vbox = new CFPlus::UI::VBox; |
915 | my $table = new CFPlus::UI::Table; |
924 | my $table = new CFPlus::UI::Table; |
916 | $vbox->add (new CFPlus::UI::ScrolledWindow expand => 1, child => $table); |
925 | $vbox->add (new CFPlus::UI::ScrolledWindow expand => 1, child => $table); |
917 | |
926 | |
918 | my $dialog = new CFPlus::UI::FancyFrame |
927 | my $dialog = new CFPlus::UI::Toplevel |
919 | title => "Server List", |
928 | title => "Server List", |
920 | name => 'metaserver_dialog', |
929 | name => 'metaserver_dialog', |
921 | x => 'center', |
930 | x => 'center', |
922 | y => 'center', |
931 | y => 'center', |
923 | z => 3, |
932 | z => 3, |
… | |
… | |
935 | } |
944 | } |
936 | |
945 | |
937 | sub server_setup { |
946 | sub server_setup { |
938 | my $vbox = new CFPlus::UI::VBox; |
947 | my $vbox = new CFPlus::UI::VBox; |
939 | |
948 | |
|
|
949 | $vbox->add (new CFPlus::UI::FancyFrame |
|
|
950 | label => "Connection Settings", |
940 | $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 | ); |
941 | $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"); |
942 | |
954 | |
943 | { |
955 | { |
944 | $table->add (1, 2, my $vbox = new CFPlus::UI::VBox); |
956 | $table->add (1, 2, my $vbox = new CFPlus::UI::VBox); |
945 | |
957 | |
… | |
… | |
1029 | }, |
1041 | }, |
1030 | ); |
1042 | ); |
1031 | |
1043 | |
1032 | $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"); |
1033 | $table->add (1, 12, my $saycmd = new CFPlus::UI::Entry |
1045 | $table->add (1, 12, my $saycmd = new CFPlus::UI::Entry |
1034 | text => $CFG->{say_command}, |
1046 | text => $CFG->{say_command}, |
1035 | 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. " |
1036 | . "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. " |
1037 | . "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.", |
1038 | on_changed => sub { |
1050 | on_changed => sub { |
1039 | my ($self, $value) = @_; |
1051 | my ($self, $value) = @_; |
1040 | $CFG->{say_command} = $value; |
1052 | $CFG->{say_command} = $value; |
1041 | 0 |
1053 | 0 |
1042 | } |
1054 | } |
1043 | ); |
1055 | ); |
1044 | |
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 | |
1045 | $vbox->add (new CFPlus::UI::Label |
1068 | $vbox->add (new CFPlus::UI::FancyFrame |
1046 | text => "Server Info", |
1069 | label => "Server Info", |
1047 | fontsize => 1.2, |
|
|
1048 | padding_y => 8, |
|
|
1049 | fg => [1, 1, 0, 1], |
|
|
1050 | ); |
|
|
1051 | |
|
|
1052 | $vbox->add ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0); |
1070 | child => ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0), |
|
|
1071 | ); |
1053 | |
1072 | |
1054 | $vbox |
1073 | $vbox |
1055 | } |
1074 | } |
1056 | |
1075 | |
1057 | sub message_window { |
1076 | sub message_window { |
1058 | my $window = new CFPlus::UI::FancyFrame |
1077 | my $window = new CFPlus::UI::Toplevel |
1059 | name => "message_window", |
1078 | name => "message_window", |
1060 | title => "Messages", |
1079 | title => "Messages", |
1061 | border_bg => [1, 1, 1, 1], |
1080 | border_bg => [1, 1, 1, 1], |
1062 | x => "max", |
1081 | x => "max", |
1063 | y => 0, |
1082 | y => 0, |
… | |
… | |
1113 | window => $window, |
1132 | window => $window, |
1114 | input => $input, |
1133 | input => $input, |
1115 | }; |
1134 | }; |
1116 | |
1135 | |
1117 | $window |
1136 | $window |
1118 | } |
|
|
1119 | |
|
|
1120 | sub open_string_query { |
|
|
1121 | my $cb = $_[1]; |
|
|
1122 | my $dialog = new CFPlus::UI::FancyFrame |
|
|
1123 | x => "center", |
|
|
1124 | y => "center", |
|
|
1125 | z => 50, |
|
|
1126 | force_w => $WIDTH * 4/5, |
|
|
1127 | title => $_[0]; |
|
|
1128 | |
|
|
1129 | $dialog->add ( |
|
|
1130 | my $e = new CFPlus::UI::Entry |
|
|
1131 | on_activate => sub { $cb->(@_); $dialog->hide; 0 }, |
|
|
1132 | on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 }, |
|
|
1133 | ); |
|
|
1134 | |
|
|
1135 | $e->grab_focus; |
|
|
1136 | $dialog->show; |
|
|
1137 | } |
|
|
1138 | |
|
|
1139 | sub open_quit_dialog { |
|
|
1140 | unless ($QUIT_DIALOG) { |
|
|
1141 | $QUIT_DIALOG = new CFPlus::UI::FancyFrame |
|
|
1142 | x => "center", |
|
|
1143 | y => "center", |
|
|
1144 | z => 50, |
|
|
1145 | title => "Really Quit?", |
|
|
1146 | on_key_down => sub { |
|
|
1147 | my ($dialog, $ev) = @_; |
|
|
1148 | $ev->{sym} == 27 and $dialog->hide; |
|
|
1149 | } |
|
|
1150 | ; |
|
|
1151 | |
|
|
1152 | $QUIT_DIALOG->add (my $vb = new CFPlus::UI::VBox expand => 1); |
|
|
1153 | |
|
|
1154 | $vb->add (new CFPlus::UI::Label |
|
|
1155 | text => "You should find a savebed and apply it first!", |
|
|
1156 | max_w => $WIDTH * 0.25, |
|
|
1157 | ellipsize => 0, |
|
|
1158 | ); |
|
|
1159 | $vb->add (my $hb = new CFPlus::UI::HBox expand => 1); |
|
|
1160 | $hb->add (new CFPlus::UI::Button |
|
|
1161 | text => "Ok", |
|
|
1162 | expand => 1, |
|
|
1163 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
|
|
1164 | ); |
|
|
1165 | $hb->add (new CFPlus::UI::Button |
|
|
1166 | text => "Quit anyway", |
|
|
1167 | expand => 1, |
|
|
1168 | on_activate => sub { exit }, |
|
|
1169 | ); |
|
|
1170 | } |
|
|
1171 | |
|
|
1172 | $QUIT_DIALOG->show; |
|
|
1173 | $QUIT_DIALOG->grab_focus; |
|
|
1174 | } |
1137 | } |
1175 | |
1138 | |
1176 | sub autopickup_setup { |
1139 | sub autopickup_setup { |
1177 | my $table = new CFPlus::UI::Table; |
1140 | my $table = new CFPlus::UI::Table; |
1178 | |
1141 | |
… | |
… | |
1335 | $PL_WINDOW->show; |
1298 | $PL_WINDOW->show; |
1336 | } |
1299 | } |
1337 | } |
1300 | } |
1338 | |
1301 | |
1339 | sub player_window { |
1302 | sub player_window { |
1340 | my $plwin = $PL_WINDOW = new CFPlus::UI::FancyFrame |
1303 | my $plwin = $PL_WINDOW = new CFPlus::UI::Toplevel |
1341 | x => "center", |
1304 | x => "center", |
1342 | y => "center", |
1305 | y => "center", |
1343 | force_w => $WIDTH * 9/10, |
1306 | force_w => $WIDTH * 9/10, |
1344 | force_h => $HEIGHT * 9/10, |
1307 | force_h => $HEIGHT * 9/10, |
1345 | title => "Player", |
1308 | title => "Player", |
… | |
… | |
1387 | |
1350 | |
1388 | my $refresh; |
1351 | my $refresh; |
1389 | $refresh = $BIND_UPD_CB = sub { |
1352 | $refresh = $BIND_UPD_CB = sub { |
1390 | $binding_list->clear (); |
1353 | $binding_list->clear (); |
1391 | |
1354 | |
|
|
1355 | return unless $PROFILE; |
|
|
1356 | |
1392 | for my $mod (keys %{$::CFG->{profile}{default}{bindings}}) { |
1357 | for my $mod (keys %{$PROFILE->{bindings}}) { |
1393 | for my $sym (keys %{$::CFG->{profile}{default}{bindings}{$mod}}) { |
1358 | for my $sym (keys %{$PROFILE->{bindings}{$mod}}) { |
1394 | my $cmds = $::CFG->{profile}{default}{bindings}{$mod}{$sym}; |
1359 | my $cmds = $PROFILE->{bindings}{$mod}{$sym}; |
1395 | next unless ref $cmds eq 'ARRAY' and @$cmds > 0; |
1360 | next unless ref $cmds eq 'ARRAY' and @$cmds > 0; |
1396 | |
1361 | |
1397 | my $lbl = join "; ", @$cmds; |
1362 | my $lbl = join "; ", @$cmds; |
1398 | my $nam = CFPlus::BindingEditor::keycombo_to_name ($mod, $sym); |
1363 | my $nam = CFPlus::BindingEditor::keycombo_to_name ($mod, $sym); |
1399 | $binding_list->add (my $hb = new CFPlus::UI::HBox); |
1364 | $binding_list->add (my $hb = new CFPlus::UI::HBox); |
1400 | $hb->add (new CFPlus::UI::Button |
1365 | $hb->add (new CFPlus::UI::Button |
1401 | text => "delete", |
1366 | text => "delete", |
1402 | tooltip => "Deletes the binding", |
1367 | tooltip => "Deletes the binding", |
1403 | on_activate => sub { |
1368 | on_activate => sub { |
1404 | $binding_list->remove ($hb); |
1369 | $binding_list->remove ($hb); |
1405 | delete $::CFG->{profile}{default}{bindings}{$mod}{$sym}; |
1370 | delete $PROFILE->{bindings}{$mod}{$sym}; |
1406 | 0 |
1371 | 0 |
1407 | }); |
1372 | }); |
1408 | |
1373 | |
1409 | $hb->add (new CFPlus::UI::Button |
1374 | $hb->add (new CFPlus::UI::Button |
1410 | text => "edit", |
1375 | text => "edit", |
1411 | tooltip => "Edits the binding", |
1376 | tooltip => "Edits the binding", |
1412 | on_activate => sub { |
1377 | on_activate => sub { |
1413 | $::BIND_EDITOR->set_binding ( |
1378 | $::BIND_EDITOR->set_binding ( |
1414 | $mod, $sym, $::CFG->{profile}{default}{bindings}{$mod}{$sym}, |
1379 | $mod, $sym, $PROFILE->{bindings}{$mod}{$sym}, |
1415 | sub { |
1380 | sub { |
1416 | my ($nmod, $nsym, $ncmds) = @_; |
1381 | my ($nmod, $nsym, $ncmds) = @_; |
1417 | $::BIND_EDITOR->cfg_unbind ($mod, $sym); |
1382 | $::BIND_EDITOR->cfg_unbind ($mod, $sym); |
1418 | $::BIND_EDITOR->cfg_bind ($nmod, $nsym, $ncmds); |
1383 | $::BIND_EDITOR->cfg_bind ($nmod, $nsym, $ncmds); |
1419 | $refresh->(); |
1384 | $refresh->(); |
… | |
… | |
1434 | } |
1399 | } |
1435 | } |
1400 | } |
1436 | }; |
1401 | }; |
1437 | |
1402 | |
1438 | my $vb = new CFPlus::UI::VBox; |
1403 | my $vb = new CFPlus::UI::VBox; |
|
|
1404 | $vb->add (new CFPlus::UI::FancyFrame |
|
|
1405 | label => "Options", |
1439 | $vb->add (my $hb = new CFPlus::UI::HBox); |
1406 | child => (my $hb = new CFPlus::UI::HBox), |
|
|
1407 | ); |
1440 | $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"); |
1441 | $hb->add (new CFPlus::UI::CheckBox |
1409 | $hb->add (new CFPlus::UI::CheckBox |
1442 | expand => 1, |
1410 | expand => 1, |
1443 | state => $CFG->{shift_fire_stop}, |
1411 | state => $CFG->{shift_fire_stop}, |
1444 | 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", |
… | |
… | |
1446 | my ($cbox, $value) = @_; |
1414 | my ($cbox, $value) = @_; |
1447 | $CFG->{shift_fire_stop} = $value; |
1415 | $CFG->{shift_fire_stop} = $value; |
1448 | 0 |
1416 | 0 |
1449 | }); |
1417 | }); |
1450 | |
1418 | |
1451 | $vb->add ($binding_list); |
1419 | $vb->add (new CFPlus::UI::FancyFrame |
|
|
1420 | label => "Bindings", |
|
|
1421 | child => $binding_list); |
1452 | $vb->add (my $hb = new CFPlus::UI::HBox); |
1422 | $vb->add (my $hb = new CFPlus::UI::HBox); |
1453 | |
1423 | |
1454 | $hb->add (new CFPlus::UI::Button |
1424 | $hb->add (new CFPlus::UI::Button |
1455 | text => "record new", |
1425 | text => "record new", |
1456 | expand => 1, |
1426 | expand => 1, |
… | |
… | |
1489 | |
1459 | |
1490 | $vb |
1460 | $vb |
1491 | } |
1461 | } |
1492 | |
1462 | |
1493 | sub help_window { |
1463 | sub help_window { |
1494 | my $win = new CFPlus::UI::FancyFrame |
1464 | my $win = new CFPlus::UI::Toplevel |
1495 | x => 'center', |
1465 | x => 'center', |
1496 | y => 'center', |
1466 | y => 'center', |
1497 | z => 2, |
1467 | z => 4, |
1498 | name => 'doc_browser', |
1468 | name => 'doc_browser', |
1499 | force_w => int $WIDTH * 7/8, |
1469 | force_w => int $WIDTH * 7/8, |
1500 | force_h => int $HEIGHT * 7/8, |
1470 | force_h => int $HEIGHT * 7/8, |
1501 | title => "Help Browser", |
1471 | title => "Help Browser", |
1502 | has_close_button => 1; |
1472 | has_close_button => 1; |
1503 | |
1473 | |
1504 | $win->add (my $vbox = new CFPlus::UI::VBox); |
1474 | $win->add (my $vbox = new CFPlus::UI::VBox); |
1505 | |
1475 | |
|
|
1476 | $vbox->add (new CFPlus::UI::FancyFrame |
|
|
1477 | label => "Navigation", |
1506 | $vbox->add (my $buttons = new CFPlus::UI::HBox); |
1478 | child => (my $buttons = new CFPlus::UI::HBox), |
|
|
1479 | ); |
1507 | $vbox->add (my $viewer = new CFPlus::UI::TextScroller |
1480 | $vbox->add (my $viewer = new CFPlus::UI::TextScroller |
1508 | expand => 1, fontsize => 0.8, padding_x => 4); |
1481 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4); |
1509 | |
1482 | |
1510 | my @history; |
1483 | my @history; |
1511 | my @future; |
1484 | my @future; |
1512 | my $curnode; |
1485 | my $curnode; |
1513 | |
1486 | |
1514 | my $load_node; $load_node = sub { |
1487 | my $load_node; $load_node = sub { |
1515 | my ($node) = @_; |
1488 | my ($node, $para) = @_; |
1516 | |
1489 | |
1517 | $buttons->clear; |
1490 | $buttons->clear; |
|
|
1491 | |
|
|
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 | ); |
1518 | |
1502 | |
1519 | if (@history) { |
1503 | if (@history) { |
1520 | $buttons->add (new CFPlus::UI::Button |
1504 | $buttons->add (new CFPlus::UI::Button |
1521 | text => "<", |
1505 | text => "⋘", |
1522 | tooltip => "back to " . CFPlus::Pod::full_path_of $history[-1], |
1506 | tooltip => "back to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $history[-1][0]) . "</i>", |
1523 | on_activate => sub { |
1507 | on_activate => sub { |
1524 | unshift @future, $curnode if $curnode; |
1508 | unshift @future, [$curnode, $viewer->current_paragraph] if $curnode; |
1525 | $load_node->(pop @history); |
1509 | $load_node->(@{pop @history}); |
|
|
1510 | }, |
1526 | }); |
1511 | ); |
1527 | } |
1512 | } |
1528 | |
1513 | |
1529 | if (@future) { |
1514 | if (@future) { |
1530 | $buttons->add (new CFPlus::UI::Button |
1515 | $buttons->add (new CFPlus::UI::Button |
1531 | text => ">", |
1516 | text => "⋙", |
1532 | tooltip => "forward to " . CFPlus::Pod::full_path_of $future[0], |
1517 | tooltip => "forward to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $future[0][0]) . "</i>", |
1533 | on_activate => sub { |
1518 | on_activate => sub { |
1534 | push @history, $curnode; |
1519 | push @history, [$curnode, $viewer->current_paragraph]; |
1535 | $load_node->(shift @future); |
1520 | $load_node->(@{shift @future}); |
|
|
1521 | }, |
1536 | }); |
1522 | ); |
1537 | } |
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); |
1538 | |
1543 | |
1539 | $curnode = $node; |
1544 | $curnode = $node; |
1540 | |
1545 | |
1541 | $viewer->clear; |
1546 | $viewer->clear; |
1542 | $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $curnode); |
1547 | $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $curnode); |
1543 | $viewer->set_offset (0); |
1548 | $viewer->scroll_to ($para); |
1544 | }; |
1549 | }; |
1545 | |
1550 | |
1546 | $load_node->(CFPlus::Pod::find pod => "mainpage"); |
1551 | $load_node->(CFPlus::Pod::find pod => "mainpage"); |
1547 | |
1552 | |
1548 | $CFPlus::Pod::on_link = sub { |
1553 | $CFPlus::Pod::goto_document = sub { |
1549 | my (@path) = @_; |
1554 | my (@path) = @_; |
1550 | |
1555 | |
1551 | push @history, $curnode if $curnode; |
1556 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
1552 | @future = (); |
|
|
1553 | |
1557 | |
1554 | $load_node->(CFPlus::Pod::find @path); |
1558 | $load_node->((CFPlus::Pod::find @path)[0]); |
1555 | $win->show; |
1559 | $win->show; |
1556 | }; |
1560 | }; |
1557 | |
1561 | |
1558 | $win |
1562 | $win |
|
|
1563 | } |
|
|
1564 | |
|
|
1565 | sub 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 | |
|
|
1586 | sub 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; |
|
|
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 | |
|
|
1623 | sub 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; |
|
|
1669 | }, |
|
|
1670 | ); |
|
|
1671 | |
|
|
1672 | $dialog->show; |
1559 | } |
1673 | } |
1560 | |
1674 | |
1561 | sub sdl_init { |
1675 | sub sdl_init { |
1562 | CFPlus::SDL_Init |
1676 | CFPlus::SDL_Init |
1563 | and die "SDL::Init failed!\n"; |
1677 | and die "SDL::Init failed!\n"; |
… | |
… | |
1610 | force_x => 0, |
1724 | force_x => 0, |
1611 | force_y => "max", |
1725 | force_y => "max", |
1612 | child => $STATUSBOX, |
1726 | child => $STATUSBOX, |
1613 | )->show; |
1727 | )->show; |
1614 | |
1728 | |
1615 | CFPlus::UI::FancyFrame->new ( |
1729 | CFPlus::UI::Toplevel->new ( |
1616 | title => "Map", |
1730 | title => "Map", |
1617 | name => "mapmap", |
1731 | name => "mapmap", |
1618 | x => 0, |
1732 | x => 0, |
1619 | y => $FONTSIZE + 8, |
1733 | y => $FONTSIZE + 8, |
1620 | border_bg => [1, 1, 1, 192/255], |
1734 | border_bg => [1, 1, 1, 192/255], |
… | |
… | |
1648 | can_hover => 1, |
1762 | can_hover => 1, |
1649 | can_events => 1, |
1763 | can_events => 1, |
1650 | 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.", |
1651 | ; |
1765 | ; |
1652 | |
1766 | |
1653 | $SETUP_DIALOG = new CFPlus::UI::FancyFrame |
1767 | $SETUP_DIALOG = new CFPlus::UI::Toplevel |
1654 | title => "Setup", |
1768 | title => "Setup", |
1655 | name => "setup_dialog", |
1769 | name => "setup_dialog", |
1656 | x => 'center', |
1770 | x => 'center', |
1657 | y => 'center', |
1771 | y => 'center', |
1658 | z => 2, |
1772 | z => 2, |
… | |
… | |
1922 | output_sync => 1, |
2036 | output_sync => 1, |
1923 | output_count => 1, |
2037 | output_count => 1, |
1924 | pickup => 0, |
2038 | pickup => 0, |
1925 | inv_sort => "mtime", |
2039 | inv_sort => "mtime", |
1926 | default => "profile", # default profile |
2040 | default => "profile", # default profile |
|
|
2041 | show_tips => 1, |
1927 | ); |
2042 | ); |
1928 | |
2043 | |
1929 | while (my ($k, $v) = each %DEF_CFG) { |
2044 | while (my ($k, $v) = each %DEF_CFG) { |
1930 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2045 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
1931 | } |
2046 | } |
… | |
… | |
1979 | |
2094 | |
1980 | video_init; |
2095 | video_init; |
1981 | audio_init; |
2096 | audio_init; |
1982 | } |
2097 | } |
1983 | |
2098 | |
|
|
2099 | show_tip_of_the_day if $CFG->{show_tips}; |
|
|
2100 | |
|
|
2101 | use Data::Dumper; warn Dumper [CFPlus::win32_proxy_info()];#d# |
|
|
2102 | |
1984 | Event::loop; |
2103 | Event::loop; |
1985 | #CFPlus::SDL_Quit; |
2104 | #CFPlus::SDL_Quit; |
1986 | #CFPlus::_exit 0; |
2105 | #CFPlus::_exit 0; |
1987 | |
2106 | |
1988 | END { CFPlus::SDL_Quit } |
2107 | END { CFPlus::SDL_Quit } |