… | |
… | |
237 | |
237 | |
238 | # center: swap stats |
238 | # center: swap stats |
239 | my ($sw1, $sw2) = map +(new CFClient::UI::Combobox |
239 | my ($sw1, $sw2) = map +(new CFClient::UI::Combobox |
240 | value => $_, |
240 | value => $_, |
241 | options => [ |
241 | options => [ |
242 | [Str => 1, "Strength ($conn->{stat}{+CS_STAT_STR})"], |
242 | [1 => "Str", "Strength ($conn->{stat}{+CS_STAT_STR})"], |
243 | [Dex => 2, "Dexterity ($conn->{stat}{+CS_STAT_DEX})"], |
243 | [2 => "Dex", "Dexterity ($conn->{stat}{+CS_STAT_DEX})"], |
244 | [Con => 3, "Constitution ($conn->{stat}{+CS_STAT_CON})"], |
244 | [3 => "Con", "Constitution ($conn->{stat}{+CS_STAT_CON})"], |
245 | [Int => 4, "Intelligence ($conn->{stat}{+CS_STAT_INT})"], |
245 | [4 => "Int", "Intelligence ($conn->{stat}{+CS_STAT_INT})"], |
246 | [Wis => 5, "Wisdom ($conn->{stat}{+CS_STAT_WIS})"], |
246 | [5 => "Wis", "Wisdom ($conn->{stat}{+CS_STAT_WIS})"], |
247 | [Pow => 6, "Power ($conn->{stat}{+CS_STAT_POW})"], |
247 | [6 => "Pow", "Power ($conn->{stat}{+CS_STAT_POW})"], |
248 | [Cha => 7, "Charisma ($conn->{stat}{+CS_STAT_CHA})"], |
248 | [7 => "Cha", "Charisma ($conn->{stat}{+CS_STAT_CHA})"], |
249 | ], |
249 | ], |
250 | ), 1 .. 2; |
250 | ), 1 .. 2; |
251 | |
251 | |
252 | $table->add (2, 0, new CFClient::UI::Button |
252 | $table->add (2, 0, new CFClient::UI::Button |
253 | text => "Swap Stats", |
253 | text => "Swap Stats", |
… | |
… | |
625 | &set_gauge_window_fontsize; |
625 | &set_gauge_window_fontsize; |
626 | |
626 | |
627 | $win |
627 | $win |
628 | } |
628 | } |
629 | |
629 | |
|
|
630 | sub debug_setup { |
|
|
631 | my $table = new CFClient::UI::Table; |
|
|
632 | |
|
|
633 | $table->add (0, 0, new CFClient::UI::Label text => "Widget Borders"); |
|
|
634 | $table->add (1, 0, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1 }); |
|
|
635 | $table->add (0, 1, new CFClient::UI::Label text => "Tooltip Widget Info"); |
|
|
636 | $table->add (1, 1, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2 }); |
|
|
637 | $table->add (0, 2, new CFClient::UI::Label text => "Show FPS"); |
|
|
638 | $table->add (1, 2, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4 }); |
|
|
639 | $table->add (0, 3, new CFClient::UI::Label text => "Suppress Tooltips"); |
|
|
640 | $table->add (1, 3, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8 }); |
|
|
641 | |
|
|
642 | my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05); |
|
|
643 | |
|
|
644 | for my $x (0..2) { |
|
|
645 | for my $y (0 .. 2) { |
|
|
646 | $table->add ($x + 3, $y, |
|
|
647 | new CFClient::UI::Entry |
|
|
648 | text => $default_smooth[$x * 3 + $y], |
|
|
649 | on_changed => sub { $MAP->{smooth_matrix}[$x * 3 + $y] = $_[1] if $MAP; 0 }, |
|
|
650 | ); |
|
|
651 | } |
|
|
652 | } |
|
|
653 | |
|
|
654 | |
|
|
655 | $table |
|
|
656 | } |
630 | |
657 | |
631 | sub stats_window { |
658 | sub stats_window { |
632 | my $tgw = new CFClient::UI::FancyFrame |
659 | my $tgw = new CFClient::UI::FancyFrame |
633 | y => $HEIGHT * (2/8), |
660 | y => $HEIGHT * (2/8), |
634 | x => "max", |
661 | x => "max", |
… | |
… | |
846 | |
873 | |
847 | utf8::decode $buf if utf8::valid $buf; |
874 | utf8::decode $buf if utf8::valid $buf; |
848 | |
875 | |
849 | $table->clear; |
876 | $table->clear; |
850 | |
877 | |
|
|
878 | my @tip = ( |
|
|
879 | "The current number of users logged in on the server.", |
|
|
880 | "The hostname of the server.", |
|
|
881 | "The time this server has been running without being restarted.", |
|
|
882 | "The server software version - a '+' indicates a Crossfire+ server.", |
|
|
883 | "Short information about this server provided by its admins.", |
|
|
884 | ); |
851 | my @col = qw(Use #Users Host Uptime Version Description); |
885 | my @col = qw(#Users Host Uptime Version Description); |
852 | $table->add ($_, 0, new CFClient::UI::Label align => 0, fg => [1, 1, 0], text => $col[$_]) |
886 | $table->add ($_, 0, new CFClient::UI::Label |
|
|
887 | can_hover => 1, can_events => 1, |
|
|
888 | align => 0, fg => [1, 1, 0], |
|
|
889 | text => $col[$_], tooltip => $tip[$_]) |
853 | for 0 .. $#col; |
890 | for 0 .. $#col; |
854 | |
891 | |
855 | my @align = qw(1 0 1 1 -1); |
892 | my @align = qw(1 0 1 1 -1); |
856 | |
893 | |
857 | my $y = 0; |
894 | my $y = 0; |
858 | for my $m (sort { $b->[3] <=> $a->[3] } map [split /\|/], split /\015?\012/, $buf) { |
895 | for my $m (sort { $b->[3] <=> $a->[3] } map [split /\|/], split /\015?\012/, $buf) { |
… | |
… | |
875 | |
912 | |
876 | $m = [$users, $host, $uptime, $version, $desc]; |
913 | $m = [$users, $host, $uptime, $version, $desc]; |
877 | |
914 | |
878 | $y++; |
915 | $y++; |
879 | |
916 | |
880 | $table->add (0, $y, new CFClient::UI::VBox children => [ |
917 | $table->add (scalar @$m, $y, new CFClient::UI::VBox children => [ |
881 | (new CFClient::UI::Button text => "Use", on_activate => sub { |
918 | (new CFClient::UI::Button |
|
|
919 | text => "Use", |
|
|
920 | tooltip => "Put this server into the <b>Host:Port</b> field", |
|
|
921 | on_activate => sub { |
882 | $HOST_ENTRY->set_text ($CFG->{host} = $host); |
922 | $HOST_ENTRY->set_text ($CFG->{host} = $host); |
883 | $METASERVER->toggle_visibility; |
923 | $METASERVER->hide; |
|
|
924 | }, |
884 | }), |
925 | ), |
885 | (new CFClient::UI::Empty expand => 1), |
926 | (new CFClient::UI::Empty expand => 1), |
886 | ]); |
927 | ]); |
887 | |
928 | |
888 | $table->add ($_ + 1, $y, new CFClient::UI::Label |
929 | $table->add ($_, $y, new CFClient::UI::Label |
889 | ellipsise => 0, align => $align[$_], text => $m->[$_], fontsize => 0.8) |
930 | ellipsise => 0, |
|
|
931 | align => $align[$_], |
|
|
932 | text => $m->[$_], |
|
|
933 | tooltip => $tip[$_], |
|
|
934 | can_hover => 1, |
|
|
935 | can_events => 1, |
|
|
936 | fontsize => 0.8) |
890 | for 0 .. $#$m; |
937 | for 0 .. $#$m; |
891 | } |
938 | } |
892 | } |
939 | } |
893 | }); |
940 | }); |
894 | } |
941 | } |
895 | |
942 | |
896 | sub metaserver_dialog { |
943 | sub metaserver_dialog { |
897 | my $dialog = new CFClient::UI::FancyFrame |
944 | my $dialog = new CFClient::UI::FancyFrame |
898 | title => "Server List", |
945 | title => "Server List", |
899 | name => 'metaserver_dialog', |
946 | name => 'metaserver_dialog', |
900 | x => 'center', |
947 | x => 'center', |
901 | y => 'center', |
948 | y => 'center', |
902 | z => 3, |
949 | z => 3, |
|
|
950 | force_h => $::HEIGHT * 0.4, |
903 | child => (my $vbox = new CFClient::UI::VBox), |
951 | child => (my $vbox = new CFClient::UI::VBox), |
904 | on_visibility_change => sub { |
952 | on_visibility_change => sub { |
905 | update_metaserver if $_[1]; |
953 | update_metaserver if $_[1]; |
906 | }, |
954 | }, |
907 | ; |
955 | ; |
908 | |
956 | |
909 | $vbox->add ($dialog->{table} = new CFClient::UI::Table); |
957 | $dialog->{table} = new CFClient::UI::Table; |
|
|
958 | |
|
|
959 | $vbox->add (new CFClient::UI::ScrolledWindow expand => 1, child => $dialog->{table}); |
910 | |
960 | |
911 | $dialog |
961 | $dialog |
912 | } |
962 | } |
913 | |
963 | |
914 | sub server_setup { |
964 | sub server_setup { |
… | |
… | |
937 | expand => 1, |
987 | expand => 1, |
938 | text => "Server List", |
988 | text => "Server List", |
939 | other => $METASERVER, |
989 | other => $METASERVER, |
940 | tooltip => "Show a list of available crossfire servers", |
990 | tooltip => "Show a list of available crossfire servers", |
941 | on_activate => sub { $METASERVER->toggle_visibility }, |
991 | on_activate => sub { $METASERVER->toggle_visibility }, |
|
|
992 | on_visibility_change => sub { $METASERVER->hide unless $_[1] }, |
942 | ); |
993 | ); |
943 | } |
994 | } |
944 | |
995 | |
945 | $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); |
996 | $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); |
946 | $table->add (1, 4, new CFClient::UI::Entry |
997 | $table->add (1, 4, new CFClient::UI::Entry |
… | |
… | |
1172 | $table->add ($x , $y, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1); |
1223 | $table->add ($x , $y, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1); |
1173 | $table->add ($x+1, $y, new CFClient::UI::CheckBox |
1224 | $table->add ($x+1, $y, new CFClient::UI::CheckBox |
1174 | state => $CFG->{pickup} & $mask, |
1225 | state => $CFG->{pickup} & $mask, |
1175 | on_changed => sub { |
1226 | on_changed => sub { |
1176 | my ($box, $value) = @_; |
1227 | my ($box, $value) = @_; |
|
|
1228 | |
1177 | if ($value) { |
1229 | if ($value) { |
1178 | $::CFG->{pickup} |= $mask; |
1230 | $::CFG->{pickup} |= $mask; |
1179 | } else { |
1231 | } else { |
1180 | $::CFG->{pickup} = $::CFG->{pickup} & ~$mask; |
1232 | $::CFG->{pickup} &= ~$mask; |
1181 | } |
1233 | } |
|
|
1234 | |
1182 | $::CONN->send (sprintf "command pickup %u", $::CFG->{pickup}) |
1235 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1183 | if defined $::CONN; |
1236 | if defined $::CONN; |
1184 | }); |
1237 | }); |
1185 | } |
1238 | } |
1186 | } |
1239 | } |
1187 | |
1240 | |
… | |
… | |
1309 | $refresh->(); |
1362 | $refresh->(); |
1310 | |
1363 | |
1311 | $vb |
1364 | $vb |
1312 | } |
1365 | } |
1313 | |
1366 | |
1314 | sub make_help_window { |
1367 | sub help_window { |
1315 | my $win = new CFClient::UI::FancyFrame |
1368 | my $win = new CFClient::UI::FancyFrame |
1316 | x => 'center', |
1369 | x => 'center', |
1317 | y => 'center', |
1370 | y => 'center', |
1318 | z => 2, |
1371 | z => 2, |
1319 | name => 'doc_browser', |
1372 | name => 'doc_browser', |
… | |
… | |
1322 | title => "Documentation"; |
1375 | title => "Documentation"; |
1323 | |
1376 | |
1324 | $win->add (my $vbox = new CFClient::UI::VBox); |
1377 | $win->add (my $vbox = new CFClient::UI::VBox); |
1325 | |
1378 | |
1326 | $vbox->add (my $buttons = new CFClient::UI::HBox); |
1379 | $vbox->add (my $buttons = new CFClient::UI::HBox); |
1327 | $vbox->add (my $viewer = new CFClient::UI::TextView expand => 1, fontsize => 0.8); |
1380 | $vbox->add (my $viewer = new CFClient::UI::TextScroller |
|
|
1381 | expand => 1, fontsize => 0.8, padding_x => 4); |
1328 | |
1382 | |
1329 | for ( |
1383 | $buttons->add (new CFClient::UI::Label text => "Choose a document to display: "); |
|
|
1384 | $buttons->add (my $combo = new CFClient::UI::Combobox |
|
|
1385 | value => undef, |
|
|
1386 | options => [ |
1330 | [intro => "Introduction"], |
1387 | [intro => "Introduction"], |
1331 | [manual => "Manual"], |
1388 | [manual => "Manual"], |
|
|
1389 | [skill_help => "Skills"], |
1332 | [command_help => "Commands"], |
1390 | [command_help => "Commands"], |
1333 | [skill_help => "Skills"], |
1391 | [dmcommand_help => "DM Commands"], |
1334 | ) { |
1392 | [COPYING => "License Terms"], |
1335 | my ($pod, $label) = @$_; |
1393 | ], |
|
|
1394 | on_changed => sub { |
|
|
1395 | my ($self, $pod) = @_; |
1336 | |
1396 | |
1337 | $buttons->add (new CFClient::UI::Button |
|
|
1338 | text => $label, |
|
|
1339 | on_activate => sub { |
|
|
1340 | my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", |
1397 | my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", |
1341 | doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; |
1398 | doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; |
1342 | |
1399 | |
1343 | $viewer->clear; |
1400 | $viewer->clear; |
1344 | |
1401 | |
1345 | $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) |
1402 | $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) |
1346 | for @$pom; |
1403 | for @$pom; |
1347 | |
1404 | |
1348 | $viewer->set_offset (0); |
1405 | $viewer->set_offset (0); |
1349 | }, |
1406 | }, |
|
|
1407 | on_visibility_change => sub { |
|
|
1408 | my ($self, $visible) = @_; |
|
|
1409 | return unless $visible; |
|
|
1410 | return if $self->{value}; |
|
|
1411 | $self->set_value ("intro"); |
|
|
1412 | }, |
1350 | ); |
1413 | ); |
1351 | } |
|
|
1352 | |
|
|
1353 | $viewer->add_paragraph ([1, 1, 0, 1], "<big>Use one of the buttons above to display a document.</big>"); |
|
|
1354 | |
1414 | |
1355 | $win |
1415 | $win |
1356 | } |
1416 | } |
1357 | |
1417 | |
1358 | sub sdl_init { |
1418 | sub sdl_init { |
… | |
… | |
1435 | } |
1495 | } |
1436 | }); |
1496 | }); |
1437 | $MAPWIDGET->show; |
1497 | $MAPWIDGET->show; |
1438 | $MAPWIDGET->focus_in; |
1498 | $MAPWIDGET->focus_in; |
1439 | |
1499 | |
1440 | $LOGVIEW = new CFClient::UI::TextView |
1500 | $LOGVIEW = new CFClient::UI::TextScroller |
1441 | expand => 1, |
1501 | expand => 1, |
1442 | font => $FONT_FIXED, |
1502 | font => $FONT_FIXED, |
1443 | fontsize => $::CFG->{log_fontsize}, |
1503 | fontsize => $::CFG->{log_fontsize}, |
1444 | indent => -4, |
1504 | indent => -4, |
1445 | can_hover => 1, |
1505 | can_hover => 1, |
… | |
… | |
1475 | . "want to record press <b>Insert</b> and you will be asked to press a key-combo. " |
1535 | . "want to record press <b>Insert</b> and you will be asked to press a key-combo. " |
1476 | . "After pressing the combo the binding will be saved automatically and the " |
1536 | . "After pressing the combo the binding will be saved automatically and the " |
1477 | . "binding editor closes"); |
1537 | . "binding editor closes"); |
1478 | $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup, |
1538 | $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup, |
1479 | "Displays all spells you have and lets you edit keyboard shortcuts for them."); |
1539 | "Displays all spells you have and lets you edit keyboard shortcuts for them."); |
|
|
1540 | $SETUP_NOTEBOOK->add (Debug => debug_setup, |
|
|
1541 | "Some debuggign options. Do not ask."); |
1480 | |
1542 | |
1481 | $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
1543 | $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
1482 | |
1544 | |
1483 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
1545 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
1484 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
1546 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
… | |
… | |
1502 | CFClient::write_cfg "$Crossfire::VARDIR/cfplusrc"; |
1564 | CFClient::write_cfg "$Crossfire::VARDIR/cfplusrc"; |
1503 | status "Configuration Saved"; |
1565 | status "Configuration Saved"; |
1504 | }, |
1566 | }, |
1505 | ); |
1567 | ); |
1506 | |
1568 | |
1507 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => make_help_window, |
1569 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => help_window, |
1508 | tooltip => "View Documentation"); |
1570 | tooltip => "View Documentation"); |
1509 | |
1571 | |
1510 | $BUTTONBAR->add (new CFClient::UI::Button |
1572 | $BUTTONBAR->add (new CFClient::UI::Button |
1511 | text => "Quit", |
1573 | text => "Quit", |
1512 | tooltip => "Terminates the program", |
1574 | tooltip => "Terminates the program", |
… | |
… | |
1773 | bgm_enable => 1, |
1835 | bgm_enable => 1, |
1774 | bgm_volume => 0.25, |
1836 | bgm_volume => 0.25, |
1775 | face_prefetch => 0, |
1837 | face_prefetch => 0, |
1776 | output_sync => 1, |
1838 | output_sync => 1, |
1777 | output_count => 1, |
1839 | output_count => 1, |
|
|
1840 | pickup => 0, |
1778 | ); |
1841 | ); |
1779 | |
1842 | |
1780 | while (my ($k, $v) = each %DEF_CFG) { |
1843 | while (my ($k, $v) = each %DEF_CFG) { |
1781 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
1844 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
1782 | } |
1845 | } |