… | |
… | |
84 | our $CONSOLE; |
84 | our $CONSOLE; |
85 | our $METASERVER; |
85 | our $METASERVER; |
86 | our $LOGIN_BUTTON; |
86 | our $LOGIN_BUTTON; |
87 | our $QUIT_DIALOG; |
87 | our $QUIT_DIALOG; |
88 | our $HOST_ENTRY; |
88 | our $HOST_ENTRY; |
|
|
89 | our $SERVER_INFO; |
89 | |
90 | |
90 | our $SETUP_DIALOG; |
91 | our $SETUP_DIALOG; |
91 | our $SETUP_NOTEBOOK; |
92 | our $SETUP_NOTEBOOK; |
92 | our $SETUP_SERVER; |
93 | our $SETUP_SERVER; |
93 | our $SETUP_KEYBOARD; |
94 | our $SETUP_KEYBOARD; |
… | |
… | |
237 | |
238 | |
238 | # center: swap stats |
239 | # center: swap stats |
239 | my ($sw1, $sw2) = map +(new CFClient::UI::Combobox |
240 | my ($sw1, $sw2) = map +(new CFClient::UI::Combobox |
240 | value => $_, |
241 | value => $_, |
241 | options => [ |
242 | options => [ |
242 | [Str => 1, "Strength ($conn->{stat}{+CS_STAT_STR})"], |
243 | [1 => "Str", "Strength ($conn->{stat}{+CS_STAT_STR})"], |
243 | [Dex => 2, "Dexterity ($conn->{stat}{+CS_STAT_DEX})"], |
244 | [2 => "Dex", "Dexterity ($conn->{stat}{+CS_STAT_DEX})"], |
244 | [Con => 3, "Constitution ($conn->{stat}{+CS_STAT_CON})"], |
245 | [3 => "Con", "Constitution ($conn->{stat}{+CS_STAT_CON})"], |
245 | [Int => 4, "Intelligence ($conn->{stat}{+CS_STAT_INT})"], |
246 | [4 => "Int", "Intelligence ($conn->{stat}{+CS_STAT_INT})"], |
246 | [Wis => 5, "Wisdom ($conn->{stat}{+CS_STAT_WIS})"], |
247 | [5 => "Wis", "Wisdom ($conn->{stat}{+CS_STAT_WIS})"], |
247 | [Pow => 6, "Power ($conn->{stat}{+CS_STAT_POW})"], |
248 | [6 => "Pow", "Power ($conn->{stat}{+CS_STAT_POW})"], |
248 | [Cha => 7, "Charisma ($conn->{stat}{+CS_STAT_CHA})"], |
249 | [7 => "Cha", "Charisma ($conn->{stat}{+CS_STAT_CHA})"], |
249 | ], |
250 | ], |
250 | ), 1 .. 2; |
251 | ), 1 .. 2; |
251 | |
252 | |
252 | $table->add (2, 0, new CFClient::UI::Button |
253 | $table->add (2, 0, new CFClient::UI::Button |
253 | text => "Swap Stats", |
254 | text => "Swap Stats", |
… | |
… | |
362 | sub stop_game { |
363 | sub stop_game { |
363 | $LOGIN_BUTTON->set_text ("Login"); |
364 | $LOGIN_BUTTON->set_text ("Login"); |
364 | $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); |
365 | $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); |
365 | $SETUP_DIALOG->show; |
366 | $SETUP_DIALOG->show; |
366 | $INV_WINDOW->hide; |
367 | $INV_WINDOW->hide; |
|
|
368 | $SETUP_SPELLS->clear_spells; |
367 | |
369 | |
368 | return unless $CONN; |
370 | return unless $CONN; |
369 | |
371 | |
370 | status "connection closed"; |
372 | status "connection closed"; |
371 | |
373 | |
… | |
… | |
625 | &set_gauge_window_fontsize; |
627 | &set_gauge_window_fontsize; |
626 | |
628 | |
627 | $win |
629 | $win |
628 | } |
630 | } |
629 | |
631 | |
|
|
632 | sub debug_setup { |
|
|
633 | my $table = new CFClient::UI::Table; |
|
|
634 | |
|
|
635 | $table->add (0, 0, new CFClient::UI::Label text => "Widget Borders"); |
|
|
636 | $table->add (1, 0, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1 }); |
|
|
637 | $table->add (0, 1, new CFClient::UI::Label text => "Tooltip Widget Info"); |
|
|
638 | $table->add (1, 1, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2 }); |
|
|
639 | $table->add (0, 2, new CFClient::UI::Label text => "Show FPS"); |
|
|
640 | $table->add (1, 2, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4 }); |
|
|
641 | $table->add (0, 3, new CFClient::UI::Label text => "Suppress Tooltips"); |
|
|
642 | $table->add (1, 3, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8 }); |
|
|
643 | |
|
|
644 | my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05); |
|
|
645 | |
|
|
646 | for my $x (0..2) { |
|
|
647 | for my $y (0 .. 2) { |
|
|
648 | $table->add ($x + 3, $y, |
|
|
649 | new CFClient::UI::Entry |
|
|
650 | text => $default_smooth[$x * 3 + $y], |
|
|
651 | on_changed => sub { $MAP->{smooth_matrix}[$x * 3 + $y] = $_[1] if $MAP; 0 }, |
|
|
652 | ); |
|
|
653 | } |
|
|
654 | } |
|
|
655 | |
|
|
656 | |
|
|
657 | $table |
|
|
658 | } |
630 | |
659 | |
631 | sub stats_window { |
660 | sub stats_window { |
632 | my $tgw = new CFClient::UI::FancyFrame |
661 | my $tgw = new CFClient::UI::FancyFrame |
633 | y => $HEIGHT * (2/8), |
662 | y => $HEIGHT * (2/8), |
634 | x => "max", |
663 | x => "max", |
… | |
… | |
787 | $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED}); |
816 | $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED}); |
788 | $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP}); |
817 | $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP}); |
789 | |
818 | |
790 | $STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{+CS_STAT_WEIGHT_LIM} / 1000); |
819 | $STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{+CS_STAT_WEIGHT_LIM} / 1000); |
791 | |
820 | |
792 | # TODO: replace by CS_STAT_RES_xxx constants |
|
|
793 | my %tbl = ( |
821 | my %tbl = ( |
794 | phys => 100, |
822 | phys => CS_STAT_RES_PHYS, |
795 | magic => 101, |
823 | magic => CS_STAT_RES_MAG, |
796 | fire => 102, |
824 | fire => CS_STAT_RES_FIRE, |
797 | elec => 103, |
825 | elec => CS_STAT_RES_ELEC, |
798 | cold => 104, |
826 | cold => CS_STAT_RES_COLD, |
799 | conf => 105, |
827 | conf => CS_STAT_RES_CONF, |
800 | acid => 106, |
828 | acid => CS_STAT_RES_ACID, |
801 | drain => 107, |
829 | drain => CS_STAT_RES_DRAIN, |
802 | ghit => 108, |
830 | ghit => CS_STAT_RES_GHOSTHIT, |
803 | pois => 109, |
831 | pois => CS_STAT_RES_POISON, |
804 | slow => 110, |
832 | slow => CS_STAT_RES_SLOW, |
805 | para => 111, |
833 | para => CS_STAT_RES_PARA, |
806 | tund => 112, |
834 | tund => CS_STAT_TURN_UNDEAD, |
807 | fear => 113, |
835 | fear => CS_STAT_RES_FEAR, |
808 | depl => 113, |
836 | depl => CS_STAT_RES_DEPLETE, |
809 | deat => 115, |
837 | deat => CS_STAT_RES_DEATH, |
810 | holyw => 116, |
838 | holyw => CS_STAT_RES_HOLYWORD, |
811 | blind => 117, |
839 | blind => CS_STAT_RES_BLIND, |
812 | ); |
840 | ); |
813 | |
841 | |
814 | $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) |
842 | $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) |
815 | for keys %tbl; |
843 | for keys %tbl; |
816 | } |
844 | } |
… | |
… | |
1049 | my ($self, $value) = @_; |
1077 | my ($self, $value) = @_; |
1050 | $CFG->{say_command} = $value; |
1078 | $CFG->{say_command} = $value; |
1051 | } |
1079 | } |
1052 | ); |
1080 | ); |
1053 | |
1081 | |
|
|
1082 | $vbox->add (new CFClient::UI::Label |
|
|
1083 | text => "Server Info", |
|
|
1084 | fontsize => 1.2, |
|
|
1085 | padding_y => 8, |
|
|
1086 | fg => [1, 1, 0, 1], |
|
|
1087 | ); |
|
|
1088 | |
|
|
1089 | $vbox->add ($SERVER_INFO = new CFClient::UI::Label ellipsise => 0); |
|
|
1090 | |
1054 | $vbox |
1091 | $vbox |
1055 | } |
1092 | } |
1056 | |
1093 | |
1057 | sub message_window { |
1094 | sub message_window { |
1058 | my $window = new CFClient::UI::FancyFrame |
1095 | my $window = new CFClient::UI::FancyFrame |
… | |
… | |
1182 | ["Potions" => PICKUP_POTION], |
1219 | ["Potions" => PICKUP_POTION], |
1183 | ["Magic Devices" => PICKUP_MAGIC_DEVICE], |
1220 | ["Magic Devices" => PICKUP_MAGIC_DEVICE], |
1184 | ["Ignore cursed" => PICKUP_NOT_CURSED], |
1221 | ["Ignore cursed" => PICKUP_NOT_CURSED], |
1185 | ["Jewelery" => PICKUP_JEWELS], |
1222 | ["Jewelery" => PICKUP_JEWELS], |
1186 | ], |
1223 | ], |
|
|
1224 | ["Weight/Value ratio", 2, 17] |
1187 | ) |
1225 | ) |
1188 | { |
1226 | { |
1189 | my ($title, $x, $y, @bits) = @$_; |
1227 | my ($title, $x, $y, @bits) = @$_; |
1190 | $table->add ($x, $y, new CFClient::UI::Label text => $title, align => 1, fg => [1, 1, 0]); |
1228 | $table->add ($x, $y, new CFClient::UI::Label text => $title, align => 1, fg => [1, 1, 0]); |
1191 | |
1229 | |
… | |
… | |
1208 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1246 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1209 | if defined $::CONN; |
1247 | if defined $::CONN; |
1210 | }); |
1248 | }); |
1211 | } |
1249 | } |
1212 | } |
1250 | } |
|
|
1251 | |
|
|
1252 | $table->add (2, 18, new CFClient::UI::ValSlider |
|
|
1253 | range => [0, 0, 16, 1, 1], |
|
|
1254 | to_value => sub { ">= " . 5 * $_[0] }, |
|
|
1255 | on_changed => sub { |
|
|
1256 | my ($slider, $value) = @_; |
|
|
1257 | |
|
|
1258 | $::CFG->{pickup} &= ~0x7; |
|
|
1259 | $::CFG->{pickup} |= int $value |
|
|
1260 | if $value; |
|
|
1261 | 1; |
|
|
1262 | }); |
|
|
1263 | $table->add (3, 18, new CFClient::UI::Button |
|
|
1264 | text => "set", |
|
|
1265 | on_activate => sub { |
|
|
1266 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
|
|
1267 | if defined $::CONN; |
|
|
1268 | 1; |
|
|
1269 | }); |
1213 | |
1270 | |
1214 | $table |
1271 | $table |
1215 | } |
1272 | } |
1216 | |
1273 | |
1217 | sub inventory_window { |
1274 | sub inventory_window { |
… | |
… | |
1295 | } |
1352 | } |
1296 | } |
1353 | } |
1297 | }; |
1354 | }; |
1298 | |
1355 | |
1299 | my $vb = new CFClient::UI::VBox; |
1356 | my $vb = new CFClient::UI::VBox; |
|
|
1357 | $vb->add (my $hb = new CFClient::UI::HBox); |
|
|
1358 | $hb->add (new CFClient::UI::Label text => "only shift-up stops fire"); |
|
|
1359 | $hb->add (new CFClient::UI::CheckBox |
|
|
1360 | expand => 1, |
|
|
1361 | state => $CFG->{shift_fire_stop}, |
|
|
1362 | tooltip => "If this checkbox is enabled you will stop fire only if you stop pressing shift", |
|
|
1363 | on_changed => sub { |
|
|
1364 | my ($cbox, $value) = @_; |
|
|
1365 | $CFG->{shift_fire_stop} = $value; |
|
|
1366 | }); |
|
|
1367 | |
1300 | $vb->add ($binding_list); |
1368 | $vb->add ($binding_list); |
1301 | $vb->add (my $hb = new CFClient::UI::HBox); |
1369 | $vb->add (my $hb = new CFClient::UI::HBox); |
1302 | |
1370 | |
1303 | $hb->add (new CFClient::UI::Button |
1371 | $hb->add (new CFClient::UI::Button |
1304 | text => "record new", |
1372 | text => "record new", |
… | |
… | |
1335 | $refresh->(); |
1403 | $refresh->(); |
1336 | |
1404 | |
1337 | $vb |
1405 | $vb |
1338 | } |
1406 | } |
1339 | |
1407 | |
1340 | sub make_help_window { |
1408 | sub help_window { |
1341 | my $win = new CFClient::UI::FancyFrame |
1409 | my $win = new CFClient::UI::FancyFrame |
1342 | x => 'center', |
1410 | x => 'center', |
1343 | y => 'center', |
1411 | y => 'center', |
1344 | z => 2, |
1412 | z => 2, |
1345 | name => 'doc_browser', |
1413 | name => 'doc_browser', |
… | |
… | |
1348 | title => "Documentation"; |
1416 | title => "Documentation"; |
1349 | |
1417 | |
1350 | $win->add (my $vbox = new CFClient::UI::VBox); |
1418 | $win->add (my $vbox = new CFClient::UI::VBox); |
1351 | |
1419 | |
1352 | $vbox->add (my $buttons = new CFClient::UI::HBox); |
1420 | $vbox->add (my $buttons = new CFClient::UI::HBox); |
1353 | $vbox->add (my $viewer = new CFClient::UI::TextView expand => 1, fontsize => 0.8); |
1421 | $vbox->add (my $viewer = new CFClient::UI::TextScroller |
|
|
1422 | expand => 1, fontsize => 0.8, padding_x => 4); |
1354 | |
1423 | |
1355 | for ( |
1424 | $buttons->add (new CFClient::UI::Label text => "Choose a document to display: "); |
|
|
1425 | $buttons->add (my $combo = new CFClient::UI::Combobox |
|
|
1426 | value => undef, |
|
|
1427 | options => [ |
1356 | [intro => "Introduction"], |
1428 | [intro => "Introduction"], |
1357 | [manual => "Manual"], |
1429 | [manual => "Manual"], |
|
|
1430 | [skill_help => "Skills"], |
1358 | [command_help => "Commands"], |
1431 | [command_help => "Commands"], |
1359 | [skill_help => "Skills"], |
1432 | [dmcommand_help => "DM Commands"], |
1360 | ) { |
1433 | [COPYING => "License Terms"], |
1361 | my ($pod, $label) = @$_; |
1434 | ], |
|
|
1435 | on_changed => sub { |
|
|
1436 | my ($self, $pod) = @_; |
1362 | |
1437 | |
1363 | $buttons->add (new CFClient::UI::Button |
|
|
1364 | text => $label, |
|
|
1365 | on_activate => sub { |
|
|
1366 | my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", |
1438 | my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", |
1367 | doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; |
1439 | doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; |
1368 | |
1440 | |
1369 | $viewer->clear; |
1441 | $viewer->clear; |
1370 | |
1442 | |
1371 | $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) |
1443 | $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) |
1372 | for @$pom; |
1444 | for @$pom; |
1373 | |
1445 | |
1374 | $viewer->set_offset (0); |
1446 | $viewer->set_offset (0); |
1375 | }, |
1447 | }, |
|
|
1448 | on_visibility_change => sub { |
|
|
1449 | my ($self, $visible) = @_; |
|
|
1450 | return unless $visible; |
|
|
1451 | return if $self->{value}; |
|
|
1452 | $self->set_value ("intro"); |
|
|
1453 | }, |
1376 | ); |
1454 | ); |
1377 | } |
|
|
1378 | |
|
|
1379 | $viewer->add_paragraph ([1, 1, 0, 1], "<big>Use one of the buttons above to display a document.</big>"); |
|
|
1380 | |
1455 | |
1381 | $win |
1456 | $win |
1382 | } |
1457 | } |
1383 | |
1458 | |
1384 | sub sdl_init { |
1459 | sub sdl_init { |
… | |
… | |
1440 | name => "mapmap", |
1515 | name => "mapmap", |
1441 | x => 0, |
1516 | x => 0, |
1442 | y => $FONTSIZE + 8, |
1517 | y => $FONTSIZE + 8, |
1443 | border_bg => [1, 1, 1, 192/255], |
1518 | border_bg => [1, 1, 1, 192/255], |
1444 | bg => [1, 1, 1, 0], |
1519 | bg => [1, 1, 1, 0], |
|
|
1520 | no_close_button => 1, |
1445 | child => ($MAPMAP = new CFClient::MapWidget::MapMap |
1521 | child => ($MAPMAP = new CFClient::MapWidget::MapMap |
1446 | tooltip => "<b>Map</b>. On servers that support this feature, this will display an overview of the surrounding areas.", |
1522 | tooltip => "<b>Map</b>. On servers that support this feature, this will display an overview of the surrounding areas.", |
1447 | ), |
1523 | ), |
1448 | )->show; |
1524 | )->show; |
1449 | |
1525 | |
… | |
… | |
1461 | } |
1537 | } |
1462 | }); |
1538 | }); |
1463 | $MAPWIDGET->show; |
1539 | $MAPWIDGET->show; |
1464 | $MAPWIDGET->focus_in; |
1540 | $MAPWIDGET->focus_in; |
1465 | |
1541 | |
1466 | $LOGVIEW = new CFClient::UI::TextView |
1542 | $LOGVIEW = new CFClient::UI::TextScroller |
1467 | expand => 1, |
1543 | expand => 1, |
1468 | font => $FONT_FIXED, |
1544 | font => $FONT_FIXED, |
1469 | fontsize => $::CFG->{log_fontsize}, |
1545 | fontsize => $::CFG->{log_fontsize}, |
1470 | indent => -4, |
1546 | indent => -4, |
1471 | can_hover => 1, |
1547 | can_hover => 1, |
… | |
… | |
1501 | . "want to record press <b>Insert</b> and you will be asked to press a key-combo. " |
1577 | . "want to record press <b>Insert</b> and you will be asked to press a key-combo. " |
1502 | . "After pressing the combo the binding will be saved automatically and the " |
1578 | . "After pressing the combo the binding will be saved automatically and the " |
1503 | . "binding editor closes"); |
1579 | . "binding editor closes"); |
1504 | $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup, |
1580 | $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup, |
1505 | "Displays all spells you have and lets you edit keyboard shortcuts for them."); |
1581 | "Displays all spells you have and lets you edit keyboard shortcuts for them."); |
|
|
1582 | $SETUP_NOTEBOOK->add (Debug => debug_setup, |
|
|
1583 | "Some debuggign options. Do not ask."); |
1506 | |
1584 | |
1507 | $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
1585 | $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
1508 | |
1586 | |
1509 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
1587 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
1510 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
1588 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
… | |
… | |
1528 | CFClient::write_cfg "$Crossfire::VARDIR/cfplusrc"; |
1606 | CFClient::write_cfg "$Crossfire::VARDIR/cfplusrc"; |
1529 | status "Configuration Saved"; |
1607 | status "Configuration Saved"; |
1530 | }, |
1608 | }, |
1531 | ); |
1609 | ); |
1532 | |
1610 | |
1533 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => make_help_window, |
1611 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => help_window, |
1534 | tooltip => "View Documentation"); |
1612 | tooltip => "View Documentation"); |
1535 | |
1613 | |
1536 | $BUTTONBAR->add (new CFClient::UI::Button |
1614 | $BUTTONBAR->add (new CFClient::UI::Button |
1537 | text => "Quit", |
1615 | text => "Quit", |
1538 | tooltip => "Terminates the program", |
1616 | tooltip => "Terminates the program", |
… | |
… | |
1856 | video_init; |
1934 | video_init; |
1857 | audio_init; |
1935 | audio_init; |
1858 | } |
1936 | } |
1859 | |
1937 | |
1860 | Event::loop; |
1938 | Event::loop; |
|
|
1939 | #CFClient::SDL_Quit; |
|
|
1940 | #CFClient::_exit 0; |
1861 | |
1941 | |
1862 | END { CFClient::SDL_Quit } |
1942 | END { CFClient::SDL_Quit } |
1863 | |
1943 | |
1864 | =head1 NAME |
1944 | =head1 NAME |
1865 | |
1945 | |