… | |
… | |
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, |
… | |
… | |
708 | font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, align => +1, template => $template, tooltip => $tooltip); |
689 | font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, align => +1, template => $template, tooltip => $tooltip); |
709 | $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFClient::UI::Label |
690 | $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFClient::UI::Label |
710 | font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0, align => -1, text => $label, tooltip => $tooltip); |
691 | font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0, align => -1, text => $label, tooltip => $tooltip); |
711 | } |
692 | } |
712 | |
693 | |
713 | $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); |
694 | $vb->add (my $tbl2 = new CFClient::UI::Table expand => 1); |
714 | |
695 | |
715 | my $row = 0; |
696 | my $row = 0; |
716 | my $col = 0; |
697 | my $col = 0; |
717 | |
698 | |
718 | my %resist_names = ( |
699 | my %resist_names = ( |
|
|
700 | slow => ["Slow", |
719 | slow => "<b>Slow</b> (slows you down when you are hit by the spell. Monsters will have an opportunity to come near you faster and hit you more often.)", |
701 | "<b>Slow</b> (slows you down when you are hit by the spell. Monsters will have an opportunity to come near you faster and hit you more often.)"], |
|
|
702 | holyw => ["Holy Word", |
720 | holyw => "<b>Holy Word</b> (resistance you against getting the fear when someone whose god doesn't like you spells the holy word on you.)", |
703 | "<b>Holy Word</b> (resistance you against getting the fear when someone whose god doesn't like you spells the holy word on you.)"], |
|
|
704 | conf => ["Confusion", |
721 | conf => "<b>Confusion</b> (If you are hit by confusion you will move into random directions, and likely into monsters.)", |
705 | "<b>Confusion</b> (If you are hit by confusion you will move into random directions, and likely into monsters.)"], |
|
|
706 | fire => ["Fire", |
722 | fire => "<b>Fire</b> (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)", |
707 | "<b>Fire</b> (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)"], |
|
|
708 | depl => ["Depletion", |
723 | depl => "<b>Depletion</b> (some monsters and other effects can cause stats depletion)", |
709 | "<b>Depletion</b> (some monsters and other effects can cause stats depletion)"], |
|
|
710 | magic => ["Magic", |
724 | magic => "<b>Magic</b> (resistance to magic spells like magic missile or similar)", |
711 | "<b>Magic</b> (resistance to magic spells like magic missile or similar)"], |
|
|
712 | drain => ["Draining", |
725 | drain => "<b>Draining</b> (some monsters (e.g. vampires) and other effects can steal experience)", |
713 | "<b>Draining</b> (some monsters (e.g. vampires) and other effects can steal experience)"], |
|
|
714 | acid => ["Acid", |
726 | acid => "<b>Acid</b> (resistance to acid, acid hurts pretty much and also corrodes your weapons)", |
715 | "<b>Acid</b> (resistance to acid, acid hurts pretty much and also corrodes your weapons)"], |
|
|
716 | pois => ["Poison", |
727 | pois => "<b>Poison</b> (resistance to getting poisoned)", |
717 | "<b>Poison</b> (resistance to getting poisoned)"], |
|
|
718 | para => ["Paralysation", |
728 | para => "<b>Paralysation</b> (this resistance affects the chance you get paralysed)", |
719 | "<b>Paralysation</b> (this resistance affects the chance you get paralysed)"], |
|
|
720 | deat => ["Death", |
729 | deat => "<b>Death</b> (resistance against death spells)", |
721 | "<b>Death</b> (resistance against death spells)"], |
|
|
722 | phys => ["Physical", |
730 | phys => "<b>Physical</b> (this is the resistance against physical attacks, like when a monster hit you in melee combat. The value displayed here is also displayed in the 'Arm' field on the left.)", |
723 | "<b>Physical</b> (this is the resistance against physical attacks, like when a monster hit you in melee combat. The value displayed here is also displayed in the 'Arm' field on the left.)"], |
|
|
724 | blind => ["Blind", |
731 | blind => "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)", |
725 | "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)"], |
|
|
726 | fear => ["Fear", |
732 | fear => "<b>Fear</b> (this attack will drive you away from monsters who cast this and hit you successfully, being resistant to this helps a lot when fighting those monsters)", |
727 | "<b>Fear</b> (this attack will drive you away from monsters who cast this and hit you successfully, being resistant to this helps a lot when fighting those monsters)"], |
|
|
728 | tund => ["Turn undead", |
733 | tund => "<b>Turn undead</b> (affects your resistancy to various forms of 'turn undead' spells. Only relevant when you are, in fact, undead...", |
729 | "<b>Turn undead</b> (affects your resistancy to various forms of 'turn undead' spells. Only relevant when you are, in fact, undead..."], |
|
|
730 | elec => ["Electricity", |
734 | elec => "<b>Electricity</b> (resistance against electricity, spells like large lightning, small lightning, ...)", |
731 | "<b>Electricity</b> (resistance against electricity, spells like large lightning, small lightning, ...)"], |
|
|
732 | cold => ["Cold", |
735 | cold => "<b>Cold</b> (this is your resistance against cold spells like icestorm, snowstorm, ...)", |
733 | "<b>Cold</b> (this is your resistance against cold spells like icestorm, snowstorm, ...)"], |
|
|
734 | ghit => ["Ghost hit", |
736 | ghit => "<b>Ghost hit</b> (special attack used by ghosts and ghost-like beings)", |
735 | "<b>Ghost hit</b> (special attack used by ghosts and ghost-like beings)"], |
737 | ); |
736 | ); |
738 | for (qw/slow holyw conf fire depl magic |
737 | for (qw/slow holyw conf fire depl magic |
739 | drain acid pois para deat phys |
738 | drain acid pois para deat phys |
740 | blind fear tund elec cold ghit/) |
739 | blind fear tund elec cold ghit/) |
741 | { |
740 | { |
… | |
… | |
746 | template => "-100%", |
745 | template => "-100%", |
747 | align => +1, |
746 | align => +1, |
748 | valign => 0, |
747 | valign => 0, |
749 | can_events => 1, |
748 | can_events => 1, |
750 | can_hover => 1, |
749 | can_hover => 1, |
751 | tooltip => $resist_names{$_}, |
750 | tooltip => $resist_names{$_}->[1], |
752 | ); |
751 | ); |
753 | $tbl2->add ($col + 1, $row, new CFClient::UI::Image |
752 | $tbl2->add ($col + 1, $row, new CFClient::UI::Image |
754 | font => $FONT_FIXED, |
753 | font => $FONT_FIXED, |
755 | can_hover => 1, |
754 | can_hover => 1, |
756 | can_events => 1, |
755 | can_events => 1, |
757 | path => "ui/resist/resist_$_.png", |
756 | path => "ui/resist/resist_$_.png", |
758 | tooltip => $resist_names{$_}, |
757 | tooltip => $resist_names{$_}->[1], |
|
|
758 | ); |
|
|
759 | $tbl2->add ($col + 2, $row, new CFClient::UI::Label |
|
|
760 | text => $resist_names{$_}->[0], |
|
|
761 | font => $FONT_FIXED, |
|
|
762 | can_hover => 1, |
|
|
763 | can_events => 1, |
|
|
764 | tooltip => $resist_names{$_}->[1], |
759 | ); |
765 | ); |
760 | |
766 | |
761 | $row++; |
767 | $row++; |
762 | if ($row % 6 == 0) { |
768 | if ($row % 6 == 0) { |
763 | $col += 2; |
769 | $col += 3; |
764 | $row = 0; |
770 | $row = 0; |
765 | } |
771 | } |
766 | } |
772 | } |
767 | |
773 | |
768 | &set_stats_window_fontsize; |
|
|
769 | update_stats_window ({}); |
774 | update_stats_window ({}); |
770 | |
775 | |
771 | $tgw |
776 | $vb |
|
|
777 | } |
|
|
778 | |
|
|
779 | sub skill_window { |
|
|
780 | my ($self) = @_; |
|
|
781 | $STATWIDS->{"_skill_tbl"} = new CFClient::UI::Table expand => 1; |
772 | } |
782 | } |
773 | |
783 | |
774 | sub formsep($) { |
784 | sub formsep($) { |
775 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
785 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
776 | } |
786 | } |
… | |
… | |
836 | depl => CS_STAT_RES_DEPLETE, |
846 | depl => CS_STAT_RES_DEPLETE, |
837 | deat => CS_STAT_RES_DEATH, |
847 | deat => CS_STAT_RES_DEATH, |
838 | holyw => CS_STAT_RES_HOLYWORD, |
848 | holyw => CS_STAT_RES_HOLYWORD, |
839 | blind => CS_STAT_RES_BLIND, |
849 | blind => CS_STAT_RES_BLIND, |
840 | ); |
850 | ); |
|
|
851 | |
|
|
852 | if ($::CONN && !$STATWIDS->{_skill_tbl_init}) { |
|
|
853 | my $sktbl = $STATWIDS->{_skill_tbl}; |
|
|
854 | $sktbl->clear; |
|
|
855 | |
|
|
856 | $sktbl->add (0, 0, new CFClient::UI::Label text => "Exp.", align => 1); |
|
|
857 | $sktbl->add (1, 0, new CFClient::UI::Label text => "Level", align => 1); |
|
|
858 | $sktbl->add (2, 0, new CFClient::UI::Label text => "Skillname"); |
|
|
859 | |
|
|
860 | my @skills; |
|
|
861 | |
|
|
862 | for (my $i = CS_STAT_SKILLINFO; $i < CS_STAT_SKILLINFO+CS_NUM_SKILLS; $i++) { |
|
|
863 | push @skills, [$i, $::CONN->{skill_info}{$i}]; |
|
|
864 | } |
|
|
865 | |
|
|
866 | my $y = 1; |
|
|
867 | for (sort { $a->[1] cmp $b->[1] } @skills) { |
|
|
868 | my ($idx, $name) = @$_; |
|
|
869 | |
|
|
870 | unless (defined $STATWIDS->{"sk_xp_$idx"} || !$::CONN->{skill_info}{$idx}) { |
|
|
871 | $sktbl->add (0, $y, $STATWIDS->{"sk_xp_$idx"} = new CFClient::UI::Label text => "0", align => 1); |
|
|
872 | $sktbl->add (1, $y, $STATWIDS->{"sk_lvl_$idx"} = new CFClient::UI::Label text => "0", align => 1); |
|
|
873 | $sktbl->add (2, $y++, new CFClient::UI::Label text => $name); |
|
|
874 | } |
|
|
875 | } |
|
|
876 | |
|
|
877 | $STATWIDS->{_skill_tbl_init} = 1; |
|
|
878 | } |
|
|
879 | |
|
|
880 | for (my $i = CS_STAT_SKILLINFO; $i < CS_STAT_SKILLINFO+CS_NUM_SKILLS; $i++) { |
|
|
881 | if (exists $stats->{$i}) { |
|
|
882 | $STATWIDS->{"sk_xp_$i"}->set_text (formsep $stats->{$i}->[1]) |
|
|
883 | if $STATWIDS->{"sk_xp_$i"}; |
|
|
884 | $STATWIDS->{"sk_lvl_$i"}->set_text (sprintf "%d", $stats->{$i}->[0]) |
|
|
885 | if $STATWIDS->{"sk_lvl_$i"}; |
|
|
886 | } |
|
|
887 | } |
841 | |
888 | |
842 | $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) |
889 | $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) |
843 | for keys %tbl; |
890 | for keys %tbl; |
844 | } |
891 | } |
845 | |
892 | |
… | |
… | |
1094 | sub message_window { |
1141 | sub message_window { |
1095 | my $window = new CFClient::UI::FancyFrame |
1142 | my $window = new CFClient::UI::FancyFrame |
1096 | name => "message_window", |
1143 | name => "message_window", |
1097 | title => "Messages", |
1144 | title => "Messages", |
1098 | border_bg => [1, 1, 1, 1], |
1145 | border_bg => [1, 1, 1, 1], |
1099 | bg => [0, 0, 0, 0.75], |
|
|
1100 | x => "max", |
1146 | x => "max", |
1101 | y => 0, |
1147 | y => 0, |
1102 | force_w => $::WIDTH * 0.4, |
1148 | force_w => $::WIDTH * 0.4, |
1103 | force_h => $::HEIGHT * 0.5, |
1149 | force_h => $::HEIGHT * 0.5, |
1104 | child => (my $vbox = new CFClient::UI::VBox), |
1150 | child => (my $vbox = new CFClient::UI::VBox), |
… | |
… | |
1319 | x => "center", |
1365 | x => "center", |
1320 | y => "center", |
1366 | y => "center", |
1321 | force_w => $WIDTH * 9/10, |
1367 | force_w => $WIDTH * 9/10, |
1322 | force_h => $HEIGHT * 9/10, |
1368 | force_h => $HEIGHT * 9/10, |
1323 | title => "Player", |
1369 | title => "Player", |
|
|
1370 | name => "playerbook", |
1324 | has_close_button => 1 |
1371 | has_close_button => 1 |
1325 | ; |
1372 | ; |
1326 | |
1373 | |
1327 | my $ntb = |
1374 | my $ntb = |
1328 | $PL_NOTEBOOK = |
1375 | $PL_NOTEBOOK = |
… | |
… | |
1331 | debug => 1, |
1378 | debug => 1, |
1332 | filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1), |
1379 | filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1), |
1333 | ; |
1380 | ; |
1334 | |
1381 | |
1335 | $ntb->add ( |
1382 | $ntb->add ( |
1336 | "Stats & Skills" => $STATS_PAGE = stats_window, |
1383 | "Stats" => $STATS_PAGE = stats_window, |
1337 | "Shows statistics and skill window, where all your Stats, Resistances and Skills are shown." |
1384 | "Shows statistics, where all your Stats and Resistances are shown." |
1338 | ); |
1385 | ); |
1339 | $ntb->add ( |
1386 | $ntb->add ( |
|
|
1387 | "Skills" => $STATS_PAGE = skill_window, |
|
|
1388 | "Shows all your Skills." |
|
|
1389 | ); |
|
|
1390 | $ntb->add ( |
1340 | Spells => $SPELL_PAGE = new CFClient::UI::SpellList, |
1391 | Spellbook => $SPELL_PAGE = new CFClient::UI::SpellList, |
1341 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
1392 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
1342 | ); |
1393 | ); |
1343 | $ntb->add ( |
1394 | $ntb->add ( |
1344 | Inventory => $INVENTORY_PAGE = inventory_widget, |
1395 | Inventory => $INVENTORY_PAGE = inventory_widget, |
1345 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1396 | "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." |
1397 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1347 | ); |
1398 | ); |
1348 | |
1399 | |
|
|
1400 | $ntb->set_current_page ($INVENTORY_PAGE); |
1349 | |
1401 | |
1350 | $plwin->add ($ntb); |
1402 | $plwin->add ($ntb); |
1351 | $plwin |
1403 | $plwin |
1352 | } |
1404 | } |
1353 | |
1405 | |
… | |
… | |
1469 | y => 'center', |
1521 | y => 'center', |
1470 | z => 2, |
1522 | z => 2, |
1471 | name => 'doc_browser', |
1523 | name => 'doc_browser', |
1472 | force_w => int $WIDTH * 7/8, |
1524 | force_w => int $WIDTH * 7/8, |
1473 | force_h => int $HEIGHT * 7/8, |
1525 | force_h => int $HEIGHT * 7/8, |
1474 | title => "Documentation"; |
1526 | title => "Help Browser", |
|
|
1527 | has_close_button => 1; |
1475 | |
1528 | |
1476 | $win->add (my $vbox = new CFClient::UI::VBox); |
1529 | $win->add (my $vbox = new CFClient::UI::VBox); |
1477 | |
1530 | |
1478 | $vbox->add (my $buttons = new CFClient::UI::HBox); |
1531 | $vbox->add (my $buttons = new CFClient::UI::HBox); |
1479 | $vbox->add (my $viewer = new CFClient::UI::TextScroller |
1532 | $vbox->add (my $viewer = new CFClient::UI::TextScroller |
… | |
… | |
1656 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW = message_window, |
1709 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW = message_window, |
1657 | tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
1710 | tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
1658 | |
1711 | |
1659 | 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 |
1712 | 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 |
1660 | |
1713 | |
1661 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Player", other => player_window, |
1714 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Playerbook", other => player_window, |
1662 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
1715 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
1663 | |
1716 | |
1664 | $BUTTONBAR->add (new CFClient::UI::Button |
1717 | $BUTTONBAR->add (new CFClient::UI::Button |
1665 | text => "Save Config", |
1718 | text => "Save Config", |
1666 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
1719 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |