… | |
… | |
40 | use CFClient::UI; |
40 | use CFClient::UI; |
41 | use CFClient::BindingEditor; |
41 | use CFClient::BindingEditor; |
42 | use CFClient::MapWidget; |
42 | use CFClient::MapWidget; |
43 | |
43 | |
44 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
44 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
|
|
45 | $SIG{PIPE} = 'IGNORE'; |
45 | |
46 | |
46 | $Event::DIED = sub { |
47 | $Event::DIED = sub { |
47 | # TODO: display dialog box or so |
48 | # TODO: display dialog box or so |
48 | Carp::confess $_[1];#d#TODO: remove when stable |
49 | Carp::confess $_[1];#d#TODO: remove when stable |
49 | CFClient::error $_[1]; |
50 | CFClient::error $_[1]; |
… | |
… | |
475 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
476 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
476 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", |
477 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", |
477 | on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
478 | on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
478 | ); |
479 | ); |
479 | |
480 | |
480 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize"); |
|
|
481 | |
|
|
482 | $table->add (1, $row++, new CFClient::UI::Slider |
|
|
483 | range => [$CFG->{stat_fontsize}, 0.5, 2, 0, 0.1], |
|
|
484 | tooltip => "The font size used by the <b>statistics window</b> only. Changes are instant.", |
|
|
485 | on_changed => sub { |
|
|
486 | $CFG->{stat_fontsize} = $_[1]; |
|
|
487 | &set_stats_window_fontsize; |
|
|
488 | 0 |
|
|
489 | } |
|
|
490 | ); |
|
|
491 | |
|
|
492 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
481 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
493 | $table->add (1, $row++, new CFClient::UI::Slider |
482 | $table->add (1, $row++, new CFClient::UI::Slider |
494 | range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], |
483 | range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], |
495 | tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.", |
484 | tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.", |
496 | on_changed => sub { |
485 | on_changed => sub { |
… | |
… | |
565 | ); |
554 | ); |
566 | |
555 | |
567 | $vbox |
556 | $vbox |
568 | } |
557 | } |
569 | |
558 | |
570 | sub set_stats_window_fontsize { |
|
|
571 | for (values %{$STATWIDS}) { |
|
|
572 | $_->set_fontsize ($::CFG->{stat_fontsize}); |
|
|
573 | } |
|
|
574 | } |
|
|
575 | |
|
|
576 | sub set_gauge_window_fontsize { |
559 | sub set_gauge_window_fontsize { |
577 | for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) { |
560 | for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) { |
578 | $_->set_fontsize ($::CFG->{gauge_fontsize}); |
561 | $_->set_fontsize ($::CFG->{gauge_fontsize}); |
579 | } |
562 | } |
580 | } |
563 | } |
… | |
… | |
659 | |
642 | |
660 | $table |
643 | $table |
661 | } |
644 | } |
662 | |
645 | |
663 | sub stats_window { |
646 | sub stats_window { |
664 | my $tgw = |
|
|
665 | new CFClient::UI::Window |
|
|
666 | child => my $vb = new CFClient::UI::VBox; |
647 | my $vb = new CFClient::UI::VBox; |
667 | |
648 | |
668 | $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, |
649 | $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, |
669 | can_hover => 1, can_events => 1, |
650 | 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."); |
651 | 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 CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1, |
652 | $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1, |
… | |
… | |
763 | $col += 2; |
744 | $col += 2; |
764 | $row = 0; |
745 | $row = 0; |
765 | } |
746 | } |
766 | } |
747 | } |
767 | |
748 | |
768 | &set_stats_window_fontsize; |
749 | $vb->add (my $tbl3 = new CFClient::UI::Table expand => 1); |
|
|
750 | $STATWIDS->{"_skill_tbl"} = $tbl3; |
|
|
751 | |
769 | update_stats_window ({}); |
752 | update_stats_window ({}); |
770 | |
753 | |
771 | $tgw |
754 | $vb |
772 | } |
755 | } |
773 | |
756 | |
774 | sub formsep($) { |
757 | sub formsep($) { |
775 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
758 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
776 | } |
759 | } |
… | |
… | |
836 | depl => CS_STAT_RES_DEPLETE, |
819 | depl => CS_STAT_RES_DEPLETE, |
837 | deat => CS_STAT_RES_DEATH, |
820 | deat => CS_STAT_RES_DEATH, |
838 | holyw => CS_STAT_RES_HOLYWORD, |
821 | holyw => CS_STAT_RES_HOLYWORD, |
839 | blind => CS_STAT_RES_BLIND, |
822 | blind => CS_STAT_RES_BLIND, |
840 | ); |
823 | ); |
|
|
824 | |
|
|
825 | if ($::CONN && !$STATWIDS->{_skill_tbl_init}) { |
|
|
826 | my $sktbl = $STATWIDS->{_skill_tbl}; |
|
|
827 | $sktbl->clear; |
|
|
828 | |
|
|
829 | $sktbl->add (0, 0, new CFClient::UI::Label text => "Exp.", align => 1); |
|
|
830 | $sktbl->add (1, 0, new CFClient::UI::Label text => "Level", align => 1); |
|
|
831 | $sktbl->add (2, 0, new CFClient::UI::Label text => "Skillname"); |
|
|
832 | |
|
|
833 | my @skills; |
|
|
834 | |
|
|
835 | for (my $i = CS_STAT_SKILLINFO; $i < CS_STAT_SKILLINFO+CS_NUM_SKILLS; $i++) { |
|
|
836 | push @skills, [$i, $::CONN->{skill_info}{$i}]; |
|
|
837 | } |
|
|
838 | |
|
|
839 | my $y = 1; |
|
|
840 | for (sort { $a->[1] cmp $b->[1] } @skills) { |
|
|
841 | my ($idx, $name) = @$_; |
|
|
842 | |
|
|
843 | unless (defined $STATWIDS->{"sk_xp_$idx"} || !$::CONN->{skill_info}{$idx}) { |
|
|
844 | $sktbl->add (0, $y, $STATWIDS->{"sk_xp_$idx"} = new CFClient::UI::Label text => "0", align => 1); |
|
|
845 | $sktbl->add (1, $y, $STATWIDS->{"sk_lvl_$idx"} = new CFClient::UI::Label text => "0", align => 1); |
|
|
846 | $sktbl->add (2, $y++, new CFClient::UI::Label text => $name); |
|
|
847 | } |
|
|
848 | } |
|
|
849 | |
|
|
850 | $STATWIDS->{_skill_tbl_init} = 1; |
|
|
851 | } |
|
|
852 | |
|
|
853 | for (my $i = CS_STAT_SKILLINFO; $i < CS_STAT_SKILLINFO+CS_NUM_SKILLS; $i++) { |
|
|
854 | if (exists $stats->{$i}) { |
|
|
855 | $STATWIDS->{"sk_xp_$i"}->set_text (formsep $stats->{$i}->[1]) |
|
|
856 | if $STATWIDS->{"sk_xp_$i"}; |
|
|
857 | $STATWIDS->{"sk_lvl_$i"}->set_text (sprintf "%d", $stats->{$i}->[0]) |
|
|
858 | if $STATWIDS->{"sk_lvl_$i"}; |
|
|
859 | } |
|
|
860 | } |
841 | |
861 | |
842 | $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) |
862 | $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) |
843 | for keys %tbl; |
863 | for keys %tbl; |
844 | } |
864 | } |
845 | |
865 | |
… | |
… | |
1319 | x => "center", |
1339 | x => "center", |
1320 | y => "center", |
1340 | y => "center", |
1321 | force_w => $WIDTH * 9/10, |
1341 | force_w => $WIDTH * 9/10, |
1322 | force_h => $HEIGHT * 9/10, |
1342 | force_h => $HEIGHT * 9/10, |
1323 | title => "Player", |
1343 | title => "Player", |
|
|
1344 | name => "playerbook", |
1324 | has_close_button => 1 |
1345 | has_close_button => 1 |
1325 | ; |
1346 | ; |
1326 | |
1347 | |
1327 | my $ntb = |
1348 | my $ntb = |
1328 | $PL_NOTEBOOK = |
1349 | $PL_NOTEBOOK = |
… | |
… | |
1344 | Inventory => $INVENTORY_PAGE = inventory_widget, |
1365 | Inventory => $INVENTORY_PAGE = inventory_widget, |
1345 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1366 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1346 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1367 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1347 | ); |
1368 | ); |
1348 | |
1369 | |
|
|
1370 | $ntb->set_current_page ($INVENTORY_PAGE); |
1349 | |
1371 | |
1350 | $plwin->add ($ntb); |
1372 | $plwin->add ($ntb); |
1351 | $plwin |
1373 | $plwin |
1352 | } |
1374 | } |
1353 | |
1375 | |