… | |
… | |
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]; |
… | |
… | |
85 | our $CONSOLE; |
86 | our $CONSOLE; |
86 | our $METASERVER; |
87 | our $METASERVER; |
87 | our $LOGIN_BUTTON; |
88 | our $LOGIN_BUTTON; |
88 | our $QUIT_DIALOG; |
89 | our $QUIT_DIALOG; |
89 | our $HOST_ENTRY; |
90 | our $HOST_ENTRY; |
|
|
91 | our $FULLSCREEN_ENABLE; |
90 | our $PICKUP_ENABLE; |
92 | our $PICKUP_ENABLE; |
91 | our $SERVER_INFO; |
93 | our $SERVER_INFO; |
92 | |
94 | |
93 | our $SETUP_DIALOG; |
95 | our $SETUP_DIALOG; |
94 | our $SETUP_NOTEBOOK; |
96 | our $SETUP_NOTEBOOK; |
… | |
… | |
415 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
417 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
416 | |
418 | |
417 | my $row = 1; |
419 | my $row = 1; |
418 | |
420 | |
419 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen"); |
421 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen"); |
420 | $table->add (1, $row++, new CFClient::UI::CheckBox |
422 | $table->add (1, $row++, $FULLSCREEN_ENABLE = new CFClient::UI::CheckBox |
421 | state => $CFG->{fullscreen}, |
423 | state => $CFG->{fullscreen}, |
422 | tooltip => "Bring the client into fullscreen mode.", |
424 | tooltip => "Bring the client into fullscreen mode.", |
423 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
425 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
424 | ); |
426 | ); |
425 | |
427 | |
… | |
… | |
688 | font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, align => +1, template => $template, tooltip => $tooltip); |
690 | font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, align => +1, template => $template, tooltip => $tooltip); |
689 | $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFClient::UI::Label |
691 | $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFClient::UI::Label |
690 | font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0, align => -1, text => $label, tooltip => $tooltip); |
692 | font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0, align => -1, text => $label, tooltip => $tooltip); |
691 | } |
693 | } |
692 | |
694 | |
693 | $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); |
695 | $vb->add (my $tbl2 = new CFClient::UI::Table expand => 1); |
694 | |
696 | |
695 | my $row = 0; |
697 | my $row = 0; |
696 | my $col = 0; |
698 | my $col = 0; |
697 | |
699 | |
698 | my %resist_names = ( |
700 | my %resist_names = ( |
|
|
701 | slow => ["Slow", |
699 | 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.)", |
702 | "<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.)"], |
|
|
703 | holyw => ["Holy Word", |
700 | 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.)", |
704 | "<b>Holy Word</b> (resistance you against getting the fear when someone whose god doesn't like you spells the holy word on you.)"], |
|
|
705 | conf => ["Confusion", |
701 | conf => "<b>Confusion</b> (If you are hit by confusion you will move into random directions, and likely into monsters.)", |
706 | "<b>Confusion</b> (If you are hit by confusion you will move into random directions, and likely into monsters.)"], |
|
|
707 | fire => ["Fire", |
702 | fire => "<b>Fire</b> (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)", |
708 | "<b>Fire</b> (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)"], |
|
|
709 | depl => ["Depletion", |
703 | depl => "<b>Depletion</b> (some monsters and other effects can cause stats depletion)", |
710 | "<b>Depletion</b> (some monsters and other effects can cause stats depletion)"], |
|
|
711 | magic => ["Magic", |
704 | magic => "<b>Magic</b> (resistance to magic spells like magic missile or similar)", |
712 | "<b>Magic</b> (resistance to magic spells like magic missile or similar)"], |
|
|
713 | drain => ["Draining", |
705 | drain => "<b>Draining</b> (some monsters (e.g. vampires) and other effects can steal experience)", |
714 | "<b>Draining</b> (some monsters (e.g. vampires) and other effects can steal experience)"], |
|
|
715 | acid => ["Acid", |
706 | acid => "<b>Acid</b> (resistance to acid, acid hurts pretty much and also corrodes your weapons)", |
716 | "<b>Acid</b> (resistance to acid, acid hurts pretty much and also corrodes your weapons)"], |
|
|
717 | pois => ["Poison", |
707 | pois => "<b>Poison</b> (resistance to getting poisoned)", |
718 | "<b>Poison</b> (resistance to getting poisoned)"], |
|
|
719 | para => ["Paralysation", |
708 | para => "<b>Paralysation</b> (this resistance affects the chance you get paralysed)", |
720 | "<b>Paralysation</b> (this resistance affects the chance you get paralysed)"], |
|
|
721 | deat => ["Death", |
709 | deat => "<b>Death</b> (resistance against death spells)", |
722 | "<b>Death</b> (resistance against death spells)"], |
|
|
723 | phys => ["Physical", |
710 | 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.)", |
724 | "<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.)"], |
|
|
725 | blind => ["Blind", |
711 | blind => "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)", |
726 | "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)"], |
|
|
727 | fear => ["Fear", |
712 | 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)", |
728 | "<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)"], |
|
|
729 | tund => ["Turn undead", |
713 | tund => "<b>Turn undead</b> (affects your resistancy to various forms of 'turn undead' spells. Only relevant when you are, in fact, undead...", |
730 | "<b>Turn undead</b> (affects your resistancy to various forms of 'turn undead' spells. Only relevant when you are, in fact, undead..."], |
|
|
731 | elec => ["Electricity", |
714 | elec => "<b>Electricity</b> (resistance against electricity, spells like large lightning, small lightning, ...)", |
732 | "<b>Electricity</b> (resistance against electricity, spells like large lightning, small lightning, ...)"], |
|
|
733 | cold => ["Cold", |
715 | cold => "<b>Cold</b> (this is your resistance against cold spells like icestorm, snowstorm, ...)", |
734 | "<b>Cold</b> (this is your resistance against cold spells like icestorm, snowstorm, ...)"], |
|
|
735 | ghit => ["Ghost hit", |
716 | ghit => "<b>Ghost hit</b> (special attack used by ghosts and ghost-like beings)", |
736 | "<b>Ghost hit</b> (special attack used by ghosts and ghost-like beings)"], |
717 | ); |
737 | ); |
718 | for (qw/slow holyw conf fire depl magic |
738 | for (qw/slow holyw conf fire depl magic |
719 | drain acid pois para deat phys |
739 | drain acid pois para deat phys |
720 | blind fear tund elec cold ghit/) |
740 | blind fear tund elec cold ghit/) |
721 | { |
741 | { |
… | |
… | |
726 | template => "-100%", |
746 | template => "-100%", |
727 | align => +1, |
747 | align => +1, |
728 | valign => 0, |
748 | valign => 0, |
729 | can_events => 1, |
749 | can_events => 1, |
730 | can_hover => 1, |
750 | can_hover => 1, |
731 | tooltip => $resist_names{$_}, |
751 | tooltip => $resist_names{$_}->[1], |
732 | ); |
752 | ); |
733 | $tbl2->add ($col + 1, $row, new CFClient::UI::Image |
753 | $tbl2->add ($col + 1, $row, new CFClient::UI::Image |
734 | font => $FONT_FIXED, |
754 | font => $FONT_FIXED, |
735 | can_hover => 1, |
755 | can_hover => 1, |
736 | can_events => 1, |
756 | can_events => 1, |
737 | path => "ui/resist/resist_$_.png", |
757 | path => "ui/resist/resist_$_.png", |
738 | tooltip => $resist_names{$_}, |
758 | tooltip => $resist_names{$_}->[1], |
|
|
759 | ); |
|
|
760 | $tbl2->add ($col + 2, $row, new CFClient::UI::Label |
|
|
761 | text => $resist_names{$_}->[0], |
|
|
762 | font => $FONT_FIXED, |
|
|
763 | can_hover => 1, |
|
|
764 | can_events => 1, |
|
|
765 | tooltip => $resist_names{$_}->[1], |
739 | ); |
766 | ); |
740 | |
767 | |
741 | $row++; |
768 | $row++; |
742 | if ($row % 6 == 0) { |
769 | if ($row % 6 == 0) { |
743 | $col += 2; |
770 | $col += 3; |
744 | $row = 0; |
771 | $row = 0; |
745 | } |
772 | } |
746 | } |
773 | } |
747 | |
774 | |
748 | $vb->add (my $tbl3 = new CFClient::UI::Table expand => 1); |
|
|
749 | $STATWIDS->{"_skill_tbl"} = $tbl3; |
|
|
750 | |
|
|
751 | update_stats_window ({}); |
775 | update_stats_window ({}); |
752 | |
776 | |
753 | $vb |
777 | $vb |
|
|
778 | } |
|
|
779 | |
|
|
780 | sub skill_window { |
|
|
781 | my ($self) = @_; |
|
|
782 | $STATWIDS->{"_skill_tbl"} = new CFClient::UI::Table expand => 1; |
754 | } |
783 | } |
755 | |
784 | |
756 | sub formsep($) { |
785 | sub formsep($) { |
757 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
786 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
758 | } |
787 | } |
… | |
… | |
1113 | sub message_window { |
1142 | sub message_window { |
1114 | my $window = new CFClient::UI::FancyFrame |
1143 | my $window = new CFClient::UI::FancyFrame |
1115 | name => "message_window", |
1144 | name => "message_window", |
1116 | title => "Messages", |
1145 | title => "Messages", |
1117 | border_bg => [1, 1, 1, 1], |
1146 | border_bg => [1, 1, 1, 1], |
1118 | bg => [0, 0, 0, 0.75], |
|
|
1119 | x => "max", |
1147 | x => "max", |
1120 | y => 0, |
1148 | y => 0, |
1121 | force_w => $::WIDTH * 0.4, |
1149 | force_w => $::WIDTH * 0.4, |
1122 | force_h => $::HEIGHT * 0.5, |
1150 | force_h => $::HEIGHT * 0.5, |
1123 | child => (my $vbox = new CFClient::UI::VBox), |
1151 | child => (my $vbox = new CFClient::UI::VBox), |
… | |
… | |
1338 | x => "center", |
1366 | x => "center", |
1339 | y => "center", |
1367 | y => "center", |
1340 | force_w => $WIDTH * 9/10, |
1368 | force_w => $WIDTH * 9/10, |
1341 | force_h => $HEIGHT * 9/10, |
1369 | force_h => $HEIGHT * 9/10, |
1342 | title => "Player", |
1370 | title => "Player", |
|
|
1371 | name => "playerbook", |
1343 | has_close_button => 1 |
1372 | has_close_button => 1 |
1344 | ; |
1373 | ; |
1345 | |
1374 | |
1346 | my $ntb = |
1375 | my $ntb = |
1347 | $PL_NOTEBOOK = |
1376 | $PL_NOTEBOOK = |
… | |
… | |
1350 | debug => 1, |
1379 | debug => 1, |
1351 | filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1), |
1380 | filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1), |
1352 | ; |
1381 | ; |
1353 | |
1382 | |
1354 | $ntb->add ( |
1383 | $ntb->add ( |
1355 | "Stats & Skills" => $STATS_PAGE = stats_window, |
1384 | "Stats" => $STATS_PAGE = stats_window, |
1356 | "Shows statistics and skill window, where all your Stats, Resistances and Skills are shown." |
1385 | "Shows statistics, where all your Stats and Resistances are shown." |
|
|
1386 | ); |
|
|
1387 | $ntb->add ( |
|
|
1388 | "Skills" => $STATS_PAGE = skill_window, |
|
|
1389 | "Shows all your Skills." |
1357 | ); |
1390 | ); |
1358 | $ntb->add ( |
1391 | $ntb->add ( |
1359 | Spellbook => $SPELL_PAGE = new CFClient::UI::SpellList, |
1392 | Spellbook => $SPELL_PAGE = new CFClient::UI::SpellList, |
1360 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
1393 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
1361 | ); |
1394 | ); |
… | |
… | |
1907 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
1940 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
1908 | }, |
1941 | }, |
1909 | CFClient::SDL_KEYDOWN => sub { |
1942 | CFClient::SDL_KEYDOWN => sub { |
1910 | if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { |
1943 | if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { |
1911 | # alt-enter |
1944 | # alt-enter |
|
|
1945 | $FULLSCREEN_ENABLE->toggle; |
1912 | video_shutdown; |
1946 | video_shutdown; |
1913 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
|
|
1914 | video_init; |
1947 | video_init; |
1915 | } else { |
1948 | } else { |
1916 | CFClient::UI::feed_sdl_key_down_event ($_[0]); |
1949 | CFClient::UI::feed_sdl_key_down_event ($_[0]); |
1917 | } |
1950 | } |
1918 | }, |
1951 | }, |