… | |
… | |
85 | our $CONSOLE; |
85 | our $CONSOLE; |
86 | our $METASERVER; |
86 | our $METASERVER; |
87 | our $LOGIN_BUTTON; |
87 | our $LOGIN_BUTTON; |
88 | our $QUIT_DIALOG; |
88 | our $QUIT_DIALOG; |
89 | our $HOST_ENTRY; |
89 | our $HOST_ENTRY; |
|
|
90 | our $PICKUP_ENABLE; |
90 | our $SERVER_INFO; |
91 | our $SERVER_INFO; |
91 | |
92 | |
92 | our $SETUP_DIALOG; |
93 | our $SETUP_DIALOG; |
93 | our $SETUP_NOTEBOOK; |
94 | our $SETUP_NOTEBOOK; |
94 | our $SETUP_SERVER; |
95 | our $SETUP_SERVER; |
95 | our $SETUP_KEYBOARD; |
96 | our $SETUP_KEYBOARD; |
96 | our $SETUP_SPELLS; |
|
|
97 | |
97 | |
|
|
98 | our $PL_NOTEBOOK; |
98 | our $STATS_WINDOW; |
99 | our $PL_WINDOW; |
|
|
100 | |
|
|
101 | our $INVENTORY_PAGE; |
|
|
102 | our $STATS_PAGE; |
|
|
103 | our $SPELL_PAGE; |
|
|
104 | |
|
|
105 | our $HELP_WINDOW; |
99 | our $MESSAGE_WINDOW; |
106 | our $MESSAGE_WINDOW; |
100 | our $FLOORBOX; |
107 | our $FLOORBOX; |
101 | our $GAUGES; |
108 | our $GAUGES; |
102 | our $STATWIDS; |
109 | our $STATWIDS; |
103 | |
110 | |
… | |
… | |
113 | our $DEBUG_STATUS; |
120 | our $DEBUG_STATUS; |
114 | |
121 | |
115 | our $INV; |
122 | our $INV; |
116 | our $INVR; |
123 | our $INVR; |
117 | our $INV_RIGHT_HB; |
124 | our $INV_RIGHT_HB; |
118 | |
|
|
119 | our $PL_NOTEBOOK; |
|
|
120 | our $PL_WINDOW; |
|
|
121 | |
125 | |
122 | our $BIND_EDITOR; |
126 | our $BIND_EDITOR; |
123 | our $BIND_UPD_CB; |
127 | our $BIND_UPD_CB; |
124 | |
128 | |
125 | our $PICKUP_CFG; |
129 | our $PICKUP_CFG; |
… | |
… | |
223 | $conn->send ("reply $stat"); |
227 | $conn->send ("reply $stat"); |
224 | destroy_query_dialog $conn; |
228 | destroy_query_dialog $conn; |
225 | return; |
229 | return; |
226 | } |
230 | } |
227 | |
231 | |
228 | $STATS_WINDOW->show; |
232 | $STATS_PAGE->show; |
229 | $MESSAGE_WINDOW->hide; |
233 | $MESSAGE_WINDOW->hide; |
230 | |
234 | |
231 | unshift @dialog, new CFClient::UI::Label |
235 | unshift @dialog, new CFClient::UI::Label |
232 | max_w => $::WIDTH * 0.4, |
236 | max_w => $::WIDTH * 0.4, |
233 | ellipsise => 0, |
237 | ellipsise => 0, |
… | |
… | |
273 | # right: accept |
277 | # right: accept |
274 | $table->add (4, 0, new CFClient::UI::Button |
278 | $table->add (4, 0, new CFClient::UI::Button |
275 | text => "Accept", |
279 | text => "Accept", |
276 | on_activate => sub { |
280 | on_activate => sub { |
277 | $conn->send ("reply n"); |
281 | $conn->send ("reply n"); |
278 | $STATS_WINDOW->hide; |
282 | $STATS_PAGE->hide; |
279 | destroy_query_dialog $conn; |
283 | destroy_query_dialog $conn; |
280 | 0 |
284 | 0 |
281 | }, |
285 | }, |
282 | ); |
286 | ); |
283 | |
287 | |
… | |
… | |
376 | sub stop_game { |
380 | sub stop_game { |
377 | $LOGIN_BUTTON->set_text ("Login"); |
381 | $LOGIN_BUTTON->set_text ("Login"); |
378 | $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); |
382 | $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); |
379 | $SETUP_DIALOG->show; |
383 | $SETUP_DIALOG->show; |
380 | $PL_WINDOW->hide; |
384 | $PL_WINDOW->hide; |
381 | $SETUP_SPELLS->clear_spells; |
385 | $SPELL_PAGE->clear_spells; |
382 | |
386 | |
383 | return unless $CONN; |
387 | return unless $CONN; |
384 | |
388 | |
385 | status "connection closed"; |
389 | status "connection closed"; |
386 | |
390 | |
… | |
… | |
471 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
475 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
472 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", |
476 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", |
473 | on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
477 | on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
474 | ); |
478 | ); |
475 | |
479 | |
476 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize"); |
|
|
477 | |
|
|
478 | $table->add (1, $row++, new CFClient::UI::Slider |
|
|
479 | range => [$CFG->{stat_fontsize}, 0.5, 2, 0, 0.1], |
|
|
480 | tooltip => "The font size used by the <b>statistics window</b> only. Changes are instant.", |
|
|
481 | on_changed => sub { |
|
|
482 | $CFG->{stat_fontsize} = $_[1]; |
|
|
483 | &set_stats_window_fontsize; |
|
|
484 | 0 |
|
|
485 | } |
|
|
486 | ); |
|
|
487 | |
|
|
488 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
480 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
489 | $table->add (1, $row++, new CFClient::UI::Slider |
481 | $table->add (1, $row++, new CFClient::UI::Slider |
490 | range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], |
482 | range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], |
491 | tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.", |
483 | tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.", |
492 | on_changed => sub { |
484 | on_changed => sub { |
… | |
… | |
561 | ); |
553 | ); |
562 | |
554 | |
563 | $vbox |
555 | $vbox |
564 | } |
556 | } |
565 | |
557 | |
566 | sub set_stats_window_fontsize { |
|
|
567 | for (values %{$STATWIDS}) { |
|
|
568 | $_->set_fontsize ($::CFG->{stat_fontsize}); |
|
|
569 | } |
|
|
570 | } |
|
|
571 | |
|
|
572 | sub set_gauge_window_fontsize { |
558 | sub set_gauge_window_fontsize { |
573 | for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) { |
559 | for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) { |
574 | $_->set_fontsize ($::CFG->{gauge_fontsize}); |
560 | $_->set_fontsize ($::CFG->{gauge_fontsize}); |
575 | } |
561 | } |
576 | } |
562 | } |
… | |
… | |
655 | |
641 | |
656 | $table |
642 | $table |
657 | } |
643 | } |
658 | |
644 | |
659 | sub stats_window { |
645 | sub stats_window { |
660 | my $tgw = |
|
|
661 | new CFClient::UI::Window |
|
|
662 | child => my $vb = new CFClient::UI::VBox; |
646 | my $vb = new CFClient::UI::VBox; |
663 | |
647 | |
664 | $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, |
648 | $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, |
665 | can_hover => 1, can_events => 1, |
649 | can_hover => 1, can_events => 1, |
666 | tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); |
650 | tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); |
667 | $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1, |
651 | $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1, |
… | |
… | |
759 | $col += 2; |
743 | $col += 2; |
760 | $row = 0; |
744 | $row = 0; |
761 | } |
745 | } |
762 | } |
746 | } |
763 | |
747 | |
764 | &set_stats_window_fontsize; |
748 | $vb->add (my $tbl3 = new CFClient::UI::Table expand => 1); |
|
|
749 | $STATWIDS->{"_skill_tbl"} = $tbl3; |
|
|
750 | |
765 | update_stats_window ({}); |
751 | update_stats_window ({}); |
766 | |
752 | |
767 | $tgw |
753 | $vb |
768 | } |
754 | } |
769 | |
755 | |
770 | sub formsep($) { |
756 | sub formsep($) { |
771 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
757 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
772 | } |
758 | } |
… | |
… | |
832 | depl => CS_STAT_RES_DEPLETE, |
818 | depl => CS_STAT_RES_DEPLETE, |
833 | deat => CS_STAT_RES_DEATH, |
819 | deat => CS_STAT_RES_DEATH, |
834 | holyw => CS_STAT_RES_HOLYWORD, |
820 | holyw => CS_STAT_RES_HOLYWORD, |
835 | blind => CS_STAT_RES_BLIND, |
821 | blind => CS_STAT_RES_BLIND, |
836 | ); |
822 | ); |
|
|
823 | |
|
|
824 | if ($::CONN && !$STATWIDS->{_skill_tbl_init}) { |
|
|
825 | my $sktbl = $STATWIDS->{_skill_tbl}; |
|
|
826 | $sktbl->clear; |
|
|
827 | |
|
|
828 | $sktbl->add (0, 0, new CFClient::UI::Label text => "Exp.", align => 1); |
|
|
829 | $sktbl->add (1, 0, new CFClient::UI::Label text => "Level", align => 1); |
|
|
830 | $sktbl->add (2, 0, new CFClient::UI::Label text => "Skillname"); |
|
|
831 | |
|
|
832 | my @skills; |
|
|
833 | |
|
|
834 | for (my $i = CS_STAT_SKILLINFO; $i < CS_STAT_SKILLINFO+CS_NUM_SKILLS; $i++) { |
|
|
835 | push @skills, [$i, $::CONN->{skill_info}{$i}]; |
|
|
836 | } |
|
|
837 | |
|
|
838 | my $y = 1; |
|
|
839 | for (sort { $a->[1] cmp $b->[1] } @skills) { |
|
|
840 | my ($idx, $name) = @$_; |
|
|
841 | |
|
|
842 | unless (defined $STATWIDS->{"sk_xp_$idx"} || !$::CONN->{skill_info}{$idx}) { |
|
|
843 | $sktbl->add (0, $y, $STATWIDS->{"sk_xp_$idx"} = new CFClient::UI::Label text => "0", align => 1); |
|
|
844 | $sktbl->add (1, $y, $STATWIDS->{"sk_lvl_$idx"} = new CFClient::UI::Label text => "0", align => 1); |
|
|
845 | $sktbl->add (2, $y++, new CFClient::UI::Label text => $name); |
|
|
846 | } |
|
|
847 | } |
|
|
848 | |
|
|
849 | $STATWIDS->{_skill_tbl_init} = 1; |
|
|
850 | } |
|
|
851 | |
|
|
852 | for (my $i = CS_STAT_SKILLINFO; $i < CS_STAT_SKILLINFO+CS_NUM_SKILLS; $i++) { |
|
|
853 | if (exists $stats->{$i}) { |
|
|
854 | $STATWIDS->{"sk_xp_$i"}->set_text (formsep $stats->{$i}->[1]) |
|
|
855 | if $STATWIDS->{"sk_xp_$i"}; |
|
|
856 | $STATWIDS->{"sk_lvl_$i"}->set_text (sprintf "%d", $stats->{$i}->[0]) |
|
|
857 | if $STATWIDS->{"sk_lvl_$i"}; |
|
|
858 | } |
|
|
859 | } |
837 | |
860 | |
838 | $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) |
861 | $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) |
839 | for keys %tbl; |
862 | for keys %tbl; |
840 | } |
863 | } |
841 | |
864 | |
… | |
… | |
1186 | sub autopickup_setup { |
1209 | sub autopickup_setup { |
1187 | my $table = new CFClient::UI::Table; |
1210 | my $table = new CFClient::UI::Table; |
1188 | |
1211 | |
1189 | for ( |
1212 | for ( |
1190 | ["General", 0, 0, |
1213 | ["General", 0, 0, |
1191 | ["Enable autopickup" => PICKUP_NEWMODE], |
1214 | ["Enable autopickup" => PICKUP_NEWMODE, \$PICKUP_ENABLE], |
1192 | ["Inhibit autopickup" => PICKUP_INHIBIT], |
1215 | ["Inhibit autopickup" => PICKUP_INHIBIT], |
1193 | ["Stop before pickup" => PICKUP_STOP], |
1216 | ["Stop before pickup" => PICKUP_STOP], |
1194 | ["Debug autopickup" => PICKUP_DEBUG], |
1217 | ["Debug autopickup" => PICKUP_DEBUG], |
1195 | ], |
1218 | ], |
1196 | ["Weapons", 0, 6, |
1219 | ["Weapons", 0, 6, |
… | |
… | |
1233 | for (@bits) { |
1256 | for (@bits) { |
1234 | ++$y; |
1257 | ++$y; |
1235 | |
1258 | |
1236 | my $mask = $_->[1]; |
1259 | my $mask = $_->[1]; |
1237 | $table->add ($x , $y, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1); |
1260 | $table->add ($x , $y, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1); |
1238 | $table->add ($x+1, $y, new CFClient::UI::CheckBox |
1261 | $table->add ($x+1, $y, my $checkbox = new CFClient::UI::CheckBox |
1239 | state => $::CFG->{pickup} & $mask, |
1262 | state => $::CFG->{pickup} & $mask, |
1240 | on_changed => sub { |
1263 | on_changed => sub { |
1241 | my ($box, $value) = @_; |
1264 | my ($box, $value) = @_; |
1242 | |
1265 | |
1243 | if ($value) { |
1266 | if ($value) { |
… | |
… | |
1249 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1272 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1250 | if defined $::CONN; |
1273 | if defined $::CONN; |
1251 | |
1274 | |
1252 | 0 |
1275 | 0 |
1253 | }); |
1276 | }); |
|
|
1277 | |
|
|
1278 | ${$_->[2]} = $checkbox if $_->[2]; |
1254 | } |
1279 | } |
1255 | } |
1280 | } |
1256 | |
1281 | |
1257 | $table->add (2, 18, new CFClient::UI::ValSlider |
1282 | $table->add (2, 18, new CFClient::UI::ValSlider |
1258 | range => [$::CFG->{pickup} & 0xF, 0, 16, 1, 1], |
1283 | range => [$::CFG->{pickup} & 0xF, 0, 16, 1, 1], |
… | |
… | |
1295 | CFClient::Protocol::set_opencont ($::CONN, 0, "Floor"); |
1320 | CFClient::Protocol::set_opencont ($::CONN, 0, "Floor"); |
1296 | |
1321 | |
1297 | $hb |
1322 | $hb |
1298 | } |
1323 | } |
1299 | |
1324 | |
|
|
1325 | sub toggle_player_page { |
|
|
1326 | my ($widget) = @_; |
|
|
1327 | |
|
|
1328 | if ($PL_WINDOW->{visible} && $PL_NOTEBOOK->get_current_page == $widget) { |
|
|
1329 | $PL_WINDOW->hide; |
|
|
1330 | } else { |
|
|
1331 | $PL_NOTEBOOK->set_current_page ($widget); |
|
|
1332 | $PL_WINDOW->show; |
|
|
1333 | } |
|
|
1334 | } |
|
|
1335 | |
1300 | sub player_window { |
1336 | sub player_window { |
1301 | my $plwin = $PL_WINDOW = new CFClient::UI::FancyFrame |
1337 | my $plwin = $PL_WINDOW = new CFClient::UI::FancyFrame |
1302 | x => "center", |
1338 | x => "center", |
1303 | y => "center", |
1339 | y => "center", |
1304 | force_w => $WIDTH * 9/10, |
1340 | force_w => $WIDTH * 9/10, |
1305 | force_h => $HEIGHT * 9/10, |
1341 | force_h => $HEIGHT * 9/10, |
1306 | title => "Player", |
1342 | title => "Player", |
|
|
1343 | name => "playerbook", |
1307 | has_close_button => 1 |
1344 | has_close_button => 1 |
1308 | ; |
1345 | ; |
1309 | |
1346 | |
1310 | my $ntb = |
1347 | my $ntb = |
1311 | $PL_NOTEBOOK = |
1348 | $PL_NOTEBOOK = |
1312 | new CFClient::UI::Notebook |
1349 | new CFClient::UI::Notebook |
1313 | expand => 1, |
1350 | expand => 1, |
1314 | debug => 1, |
1351 | debug => 1, |
1315 | filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1), |
1352 | filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1), |
1316 | ; |
1353 | ; |
|
|
1354 | |
1317 | $ntb->add ( |
1355 | $ntb->add ( |
|
|
1356 | "Stats & Skills" => $STATS_PAGE = stats_window, |
|
|
1357 | "Shows statistics and skill window, where all your Stats, Resistances and Skills are shown." |
|
|
1358 | ); |
|
|
1359 | $ntb->add ( |
|
|
1360 | Spellbook => $SPELL_PAGE = new CFClient::UI::SpellList, |
|
|
1361 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
|
|
1362 | ); |
|
|
1363 | $ntb->add ( |
1318 | Inventory => inventory_widget, |
1364 | Inventory => $INVENTORY_PAGE = inventory_widget, |
1319 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1365 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1320 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1366 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1321 | ); |
1367 | ); |
1322 | |
1368 | |
1323 | $ntb->add ( |
1369 | $ntb->set_current_page ($INVENTORY_PAGE); |
1324 | Stats => $STATS_WINDOW = stats_window, |
|
|
1325 | "Toggles the statistics window, where all your Stats and Resistances are being displayed at all times." |
|
|
1326 | ); |
|
|
1327 | $ntb->add ( |
|
|
1328 | Spells => $SETUP_SPELLS = new CFClient::UI::SpellList, |
|
|
1329 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
|
|
1330 | ); |
|
|
1331 | |
1370 | |
1332 | $plwin->add ($ntb); |
1371 | $plwin->add ($ntb); |
1333 | $plwin |
1372 | $plwin |
1334 | } |
1373 | } |
1335 | |
1374 | |
… | |
… | |
1451 | y => 'center', |
1490 | y => 'center', |
1452 | z => 2, |
1491 | z => 2, |
1453 | name => 'doc_browser', |
1492 | name => 'doc_browser', |
1454 | force_w => int $WIDTH * 7/8, |
1493 | force_w => int $WIDTH * 7/8, |
1455 | force_h => int $HEIGHT * 7/8, |
1494 | force_h => int $HEIGHT * 7/8, |
1456 | title => "Documentation"; |
1495 | title => "Help Browser", |
|
|
1496 | has_close_button => 1; |
1457 | |
1497 | |
1458 | $win->add (my $vbox = new CFClient::UI::VBox); |
1498 | $win->add (my $vbox = new CFClient::UI::VBox); |
1459 | |
1499 | |
1460 | $vbox->add (my $buttons = new CFClient::UI::HBox); |
1500 | $vbox->add (my $buttons = new CFClient::UI::HBox); |
1461 | $vbox->add (my $viewer = new CFClient::UI::TextScroller |
1501 | $vbox->add (my $viewer = new CFClient::UI::TextScroller |
… | |
… | |
1638 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW = message_window, |
1678 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW = message_window, |
1639 | tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
1679 | tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
1640 | |
1680 | |
1641 | make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D |
1681 | make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D |
1642 | |
1682 | |
1643 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Player", other => player_window, |
1683 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Playerbook", other => player_window, |
1644 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
1684 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
1645 | |
1685 | |
1646 | $BUTTONBAR->add (new CFClient::UI::Button |
1686 | $BUTTONBAR->add (new CFClient::UI::Button |
1647 | text => "Save Config", |
1687 | text => "Save Config", |
1648 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
1688 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
… | |
… | |
1652 | status "Configuration Saved"; |
1692 | status "Configuration Saved"; |
1653 | 0 |
1693 | 0 |
1654 | }, |
1694 | }, |
1655 | ); |
1695 | ); |
1656 | |
1696 | |
1657 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => help_window, |
1697 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, |
1658 | tooltip => "View Documentation"); |
1698 | tooltip => "View Documentation"); |
1659 | |
1699 | |
1660 | $BUTTONBAR->add (new CFClient::UI::Button |
1700 | $BUTTONBAR->add (new CFClient::UI::Button |
1661 | text => "Quit", |
1701 | text => "Quit", |
1662 | tooltip => "Terminates the program", |
1702 | tooltip => "Terminates the program", |