ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/cfplus
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/cfplus (file contents):
Revision 1.89 by elmex, Sun Jul 9 21:11:48 2006 UTC vs.
Revision 1.95 by root, Sun Jul 16 23:30:08 2006 UTC

40use CFClient::UI; 40use CFClient::UI;
41use CFClient::BindingEditor; 41use CFClient::BindingEditor;
42use CFClient::MapWidget; 42use 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];
85our $CONSOLE; 86our $CONSOLE;
86our $METASERVER; 87our $METASERVER;
87our $LOGIN_BUTTON; 88our $LOGIN_BUTTON;
88our $QUIT_DIALOG; 89our $QUIT_DIALOG;
89our $HOST_ENTRY; 90our $HOST_ENTRY;
91our $FULLSCREEN_ENABLE;
90our $PICKUP_ENABLE; 92our $PICKUP_ENABLE;
91our $SERVER_INFO; 93our $SERVER_INFO;
92 94
93our $SETUP_DIALOG; 95our $SETUP_DIALOG;
94our $SETUP_NOTEBOOK; 96our $SETUP_NOTEBOOK;
98our $PL_NOTEBOOK; 100our $PL_NOTEBOOK;
99our $PL_WINDOW; 101our $PL_WINDOW;
100 102
101our $INVENTORY_PAGE; 103our $INVENTORY_PAGE;
102our $STATS_PAGE; 104our $STATS_PAGE;
105our $SKILL_PAGE;
103our $SPELL_PAGE; 106our $SPELL_PAGE;
104 107
105our $HELP_WINDOW; 108our $HELP_WINDOW;
106our $MESSAGE_WINDOW; 109our $MESSAGE_WINDOW;
107our $FLOORBOX; 110our $FLOORBOX;
415 $mode_slider->emit (changed => $mode_slider->{range}[0]); 418 $mode_slider->emit (changed => $mode_slider->{range}[0]);
416 419
417 my $row = 1; 420 my $row = 1;
418 421
419 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen"); 422 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen");
420 $table->add (1, $row++, new CFClient::UI::CheckBox 423 $table->add (1, $row++, $FULLSCREEN_ENABLE = new CFClient::UI::CheckBox
421 state => $CFG->{fullscreen}, 424 state => $CFG->{fullscreen},
422 tooltip => "Bring the client into fullscreen mode.", 425 tooltip => "Bring the client into fullscreen mode.",
423 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } 426 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 }
424 ); 427 );
425 428
688 font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, align => +1, template => $template, tooltip => $tooltip); 691 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 692 $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); 693 font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0, align => -1, text => $label, tooltip => $tooltip);
691 } 694 }
692 695
693 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); 696 $vb->add (my $tbl2 = new CFClient::UI::Table expand => 1);
694 697
695 my $row = 0; 698 my $row = 0;
696 my $col = 0; 699 my $col = 0;
697 700
698 my %resist_names = ( 701 my %resist_names = (
702 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.)", 703 "<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.)"],
704 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.)", 705 "<b>Holy Word</b> (resistance you against getting the fear when someone whose god doesn't like you spells the holy word on you.)"],
706 conf => ["Confusion",
701 conf => "<b>Confusion</b> (If you are hit by confusion you will move into random directions, and likely into monsters.)", 707 "<b>Confusion</b> (If you are hit by confusion you will move into random directions, and likely into monsters.)"],
708 fire => ["Fire",
702 fire => "<b>Fire</b> (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)", 709 "<b>Fire</b> (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)"],
710 depl => ["Depletion",
703 depl => "<b>Depletion</b> (some monsters and other effects can cause stats depletion)", 711 "<b>Depletion</b> (some monsters and other effects can cause stats depletion)"],
712 magic => ["Magic",
704 magic => "<b>Magic</b> (resistance to magic spells like magic missile or similar)", 713 "<b>Magic</b> (resistance to magic spells like magic missile or similar)"],
714 drain => ["Draining",
705 drain => "<b>Draining</b> (some monsters (e.g. vampires) and other effects can steal experience)", 715 "<b>Draining</b> (some monsters (e.g. vampires) and other effects can steal experience)"],
716 acid => ["Acid",
706 acid => "<b>Acid</b> (resistance to acid, acid hurts pretty much and also corrodes your weapons)", 717 "<b>Acid</b> (resistance to acid, acid hurts pretty much and also corrodes your weapons)"],
718 pois => ["Poison",
707 pois => "<b>Poison</b> (resistance to getting poisoned)", 719 "<b>Poison</b> (resistance to getting poisoned)"],
720 para => ["Paralysation",
708 para => "<b>Paralysation</b> (this resistance affects the chance you get paralysed)", 721 "<b>Paralysation</b> (this resistance affects the chance you get paralysed)"],
722 deat => ["Death",
709 deat => "<b>Death</b> (resistance against death spells)", 723 "<b>Death</b> (resistance against death spells)"],
724 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.)", 725 "<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.)"],
726 blind => ["Blind",
711 blind => "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)", 727 "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)"],
728 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)", 729 "<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)"],
730 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...", 731 "<b>Turn undead</b> (affects your resistancy to various forms of 'turn undead' spells. Only relevant when you are, in fact, undead..."],
732 elec => ["Electricity",
714 elec => "<b>Electricity</b> (resistance against electricity, spells like large lightning, small lightning, ...)", 733 "<b>Electricity</b> (resistance against electricity, spells like large lightning, small lightning, ...)"],
734 cold => ["Cold",
715 cold => "<b>Cold</b> (this is your resistance against cold spells like icestorm, snowstorm, ...)", 735 "<b>Cold</b> (this is your resistance against cold spells like icestorm, snowstorm, ...)"],
736 ghit => ["Ghost hit",
716 ghit => "<b>Ghost hit</b> (special attack used by ghosts and ghost-like beings)", 737 "<b>Ghost hit</b> (special attack used by ghosts and ghost-like beings)"],
717 ); 738 );
718 for (qw/slow holyw conf fire depl magic 739 for (qw/slow holyw conf fire depl magic
719 drain acid pois para deat phys 740 drain acid pois para deat phys
720 blind fear tund elec cold ghit/) 741 blind fear tund elec cold ghit/)
721 { 742 {
726 template => "-100%", 747 template => "-100%",
727 align => +1, 748 align => +1,
728 valign => 0, 749 valign => 0,
729 can_events => 1, 750 can_events => 1,
730 can_hover => 1, 751 can_hover => 1,
731 tooltip => $resist_names{$_}, 752 tooltip => $resist_names{$_}->[1],
732 ); 753 );
733 $tbl2->add ($col + 1, $row, new CFClient::UI::Image 754 $tbl2->add ($col + 1, $row, new CFClient::UI::Image
734 font => $FONT_FIXED, 755 font => $FONT_FIXED,
735 can_hover => 1, 756 can_hover => 1,
736 can_events => 1, 757 can_events => 1,
737 path => "ui/resist/resist_$_.png", 758 path => "ui/resist/resist_$_.png",
738 tooltip => $resist_names{$_}, 759 tooltip => $resist_names{$_}->[1],
760 );
761 $tbl2->add ($col + 2, $row, new CFClient::UI::Label
762 text => $resist_names{$_}->[0],
763 font => $FONT_FIXED,
764 can_hover => 1,
765 can_events => 1,
766 tooltip => $resist_names{$_}->[1],
739 ); 767 );
740 768
741 $row++; 769 $row++;
742 if ($row % 6 == 0) { 770 if ($row % 6 == 0) {
743 $col += 2; 771 $col += 3;
744 $row = 0; 772 $row = 0;
745 } 773 }
746 } 774 }
747 775
748 $vb->add (my $tbl3 = new CFClient::UI::Table expand => 1);
749 $STATWIDS->{"_skill_tbl"} = $tbl3;
750
751 update_stats_window ({}); 776 #update_stats_window ({});
752 777
753 $vb 778 $vb
779}
780
781sub skill_window {
782 $STATWIDS->{skill_tbl} = new CFClient::UI::Table expand => 1, col_expand => [0, 0, 1, 0, 0, 1]
754} 783}
755 784
756sub formsep($) { 785sub formsep($) {
757 scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 786 scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1
758}
759
760sub update_stats_window {
761 my ($stats) = @_;
762
763 # I love text protocols...
764
765 my $hp = $stats->{+CS_STAT_HP} * 1;
766 my $hp_m = $stats->{+CS_STAT_MAXHP} * 1;
767 my $sp = $stats->{+CS_STAT_SP} * 1;
768 my $sp_m = $stats->{+CS_STAT_MAXSP} * 1;
769 my $fo = $stats->{+CS_STAT_FOOD} * 1;
770 my $fo_m = 999;
771 my $gr = $stats->{+CS_STAT_GRACE} * 1;
772 my $gr_m = $stats->{+CS_STAT_MAXGRACE} * 1;
773
774 $GAUGES->{hp} ->set_value ($hp, $hp_m);
775 $GAUGES->{mana} ->set_value ($sp, $sp_m);
776 $GAUGES->{food} ->set_value ($fo, $fo_m);
777 $GAUGES->{grace} ->set_value ($gr, $gr_m);
778 $GAUGES->{exp} ->set_text ("Exp: " . (formsep $stats->{+CS_STAT_EXP64})
779 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")");
780 my $rng = $stats->{+CS_STAT_RANGE};
781 $rng =~ s/^Range: //; # thank you so much dear server
782 $GAUGES->{range} ->set_text ("Rng: " . $rng);
783 my $title = $stats->{+CS_STAT_TITLE};
784 $title =~ s/^Player: //;
785 $STATWIDS->{title} ->set_text ("Title: " . $title);
786
787 $STATWIDS->{st_str} ->set_text (sprintf "%d" , $stats->{+CS_STAT_STR});
788 $STATWIDS->{st_dex} ->set_text (sprintf "%d" , $stats->{+CS_STAT_DEX});
789 $STATWIDS->{st_con} ->set_text (sprintf "%d" , $stats->{+CS_STAT_CON});
790 $STATWIDS->{st_int} ->set_text (sprintf "%d" , $stats->{+CS_STAT_INT});
791 $STATWIDS->{st_wis} ->set_text (sprintf "%d" , $stats->{+CS_STAT_WIS});
792 $STATWIDS->{st_pow} ->set_text (sprintf "%d" , $stats->{+CS_STAT_POW});
793 $STATWIDS->{st_cha} ->set_text (sprintf "%d" , $stats->{+CS_STAT_CHA});
794 $STATWIDS->{st_wc} ->set_text (sprintf "%d" , $stats->{+CS_STAT_WC});
795 $STATWIDS->{st_ac} ->set_text (sprintf "%d" , $stats->{+CS_STAT_AC});
796 $STATWIDS->{st_dam} ->set_text (sprintf "%d" , $stats->{+CS_STAT_DAM});
797 $STATWIDS->{st_arm} ->set_text (sprintf "%d" , $stats->{+CS_STAT_RES_PHYS});
798 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED});
799 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP});
800
801 $STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{+CS_STAT_WEIGHT_LIM} / 1000);
802
803 my %tbl = (
804 phys => CS_STAT_RES_PHYS,
805 magic => CS_STAT_RES_MAG,
806 fire => CS_STAT_RES_FIRE,
807 elec => CS_STAT_RES_ELEC,
808 cold => CS_STAT_RES_COLD,
809 conf => CS_STAT_RES_CONF,
810 acid => CS_STAT_RES_ACID,
811 drain => CS_STAT_RES_DRAIN,
812 ghit => CS_STAT_RES_GHOSTHIT,
813 pois => CS_STAT_RES_POISON,
814 slow => CS_STAT_RES_SLOW,
815 para => CS_STAT_RES_PARA,
816 tund => CS_STAT_TURN_UNDEAD,
817 fear => CS_STAT_RES_FEAR,
818 depl => CS_STAT_RES_DEPLETE,
819 deat => CS_STAT_RES_DEATH,
820 holyw => CS_STAT_RES_HOLYWORD,
821 blind => CS_STAT_RES_BLIND,
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 }
860
861 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}})
862 for keys %tbl;
863} 787}
864 788
865my $METASERVER_ATIME; 789my $METASERVER_ATIME;
866 790
867sub update_metaserver { 791sub update_metaserver {
1113sub message_window { 1037sub message_window {
1114 my $window = new CFClient::UI::FancyFrame 1038 my $window = new CFClient::UI::FancyFrame
1115 name => "message_window", 1039 name => "message_window",
1116 title => "Messages", 1040 title => "Messages",
1117 border_bg => [1, 1, 1, 1], 1041 border_bg => [1, 1, 1, 1],
1118 bg => [0, 0, 0, 0.75],
1119 x => "max", 1042 x => "max",
1120 y => 0, 1043 y => 0,
1121 force_w => $::WIDTH * 0.4, 1044 force_w => $::WIDTH * 0.4,
1122 force_h => $::HEIGHT * 0.5, 1045 force_h => $::HEIGHT * 0.5,
1123 child => (my $vbox = new CFClient::UI::VBox), 1046 child => (my $vbox = new CFClient::UI::VBox),
1338 x => "center", 1261 x => "center",
1339 y => "center", 1262 y => "center",
1340 force_w => $WIDTH * 9/10, 1263 force_w => $WIDTH * 9/10,
1341 force_h => $HEIGHT * 9/10, 1264 force_h => $HEIGHT * 9/10,
1342 title => "Player", 1265 title => "Player",
1266 name => "playerbook",
1343 has_close_button => 1 1267 has_close_button => 1
1344 ; 1268 ;
1345 1269
1346 my $ntb = 1270 my $ntb =
1347 $PL_NOTEBOOK = 1271 $PL_NOTEBOOK =
1350 debug => 1, 1274 debug => 1,
1351 filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1), 1275 filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1),
1352 ; 1276 ;
1353 1277
1354 $ntb->add ( 1278 $ntb->add (
1355 "Stats &amp; Skills" => $STATS_PAGE = stats_window, 1279 "Statistics (F2)" => $STATS_PAGE = stats_window,
1356 "Shows statistics and skill window, where all your Stats, Resistances and Skills are shown." 1280 "Shows statistics, where all your Stats and Resistances are shown."
1357 ); 1281 );
1358 $ntb->add ( 1282 $ntb->add (
1283 "Skills (F3)" => $SKILL_PAGE = skill_window,
1284 "Shows all your Skills."
1285 );
1286 $ntb->add (
1359 Spellbook => $SPELL_PAGE = new CFClient::UI::SpellList, 1287 "Spellbook (F4)" => $SPELL_PAGE = new CFClient::UI::SpellList,
1360 "Displays all spells you have and lets you edit keyboard shortcuts for them." 1288 "Displays all spells you have and lets you edit keyboard shortcuts for them."
1361 ); 1289 );
1362 $ntb->add ( 1290 $ntb->add (
1363 Inventory => $INVENTORY_PAGE = inventory_widget, 1291 "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget,
1364 "Toggles the inventory window, where you can manage your loot (or treasures :). " 1292 "Toggles the inventory window, where you can manage your loot (or treasures :). "
1365 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." 1293 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory."
1366 ); 1294 );
1367 1295
1368 $ntb->set_current_page ($INVENTORY_PAGE); 1296 $ntb->set_current_page ($INVENTORY_PAGE);
1907# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# 1835# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
1908 }, 1836 },
1909 CFClient::SDL_KEYDOWN => sub { 1837 CFClient::SDL_KEYDOWN => sub {
1910 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { 1838 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) {
1911 # alt-enter 1839 # alt-enter
1840 $FULLSCREEN_ENABLE->toggle;
1912 video_shutdown; 1841 video_shutdown;
1913 $CFG->{fullscreen} = !$CFG->{fullscreen};
1914 video_init; 1842 video_init;
1915 } else { 1843 } else {
1916 CFClient::UI::feed_sdl_key_down_event ($_[0]); 1844 CFClient::UI::feed_sdl_key_down_event ($_[0]);
1917 } 1845 }
1918 }, 1846 },
1934$SIG{INT} = $SIG{TERM} = sub { exit }; 1862$SIG{INT} = $SIG{TERM} = sub { exit };
1935 1863
1936{ 1864{
1937 local $SIG{__DIE__} = sub { 1865 local $SIG{__DIE__} = sub {
1938 return unless defined $^S && !$^S; 1866 return unless defined $^S && !$^S;
1939 Carp::confess $_[1];#d#TODO: remove when stable 1867 Carp::confess $_[0];#d#TODO: remove when stable
1940 CFClient::fatal $_[0]; 1868 CFClient::fatal $_[0];
1941 }; 1869 };
1942 1870
1943 CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc"; 1871 CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc";
1944 CFClient::UI::set_layout ($::CFG->{layout}); 1872 CFClient::UI::set_layout ($::CFG->{layout});

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines