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.87 by root, Sun Jul 2 21:41:34 2006 UTC vs.
Revision 1.94 by root, Sun Jul 16 20:04: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;
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
475 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], 477 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.", 478 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 }, 479 on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 },
478 ); 480 );
479 481
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"); 482 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize");
493 $table->add (1, $row++, new CFClient::UI::Slider 483 $table->add (1, $row++, new CFClient::UI::Slider
494 range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], 484 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.", 485 tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.",
496 on_changed => sub { 486 on_changed => sub {
565 ); 555 );
566 556
567 $vbox 557 $vbox
568} 558}
569 559
570sub set_stats_window_fontsize {
571 for (values %{$STATWIDS}) {
572 $_->set_fontsize ($::CFG->{stat_fontsize});
573 }
574}
575
576sub set_gauge_window_fontsize { 560sub set_gauge_window_fontsize {
577 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) { 561 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) {
578 $_->set_fontsize ($::CFG->{gauge_fontsize}); 562 $_->set_fontsize ($::CFG->{gauge_fontsize});
579 } 563 }
580} 564}
659 643
660 $table 644 $table
661} 645}
662 646
663sub stats_window { 647sub stats_window {
664 my $tgw =
665 new CFClient::UI::Window
666 child => my $vb = new CFClient::UI::VBox; 648 my $vb = new CFClient::UI::VBox;
667 649
668 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, 650 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1,
669 can_hover => 1, can_events => 1, 651 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."); 652 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, 653 $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); 690 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 691 $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); 692 font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0, align => -1, text => $label, tooltip => $tooltip);
711 } 693 }
712 694
713 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); 695 $vb->add (my $tbl2 = new CFClient::UI::Table expand => 1);
714 696
715 my $row = 0; 697 my $row = 0;
716 my $col = 0; 698 my $col = 0;
717 699
718 my %resist_names = ( 700 my %resist_names = (
701 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.)", 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",
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.)", 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",
721 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",
722 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",
723 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",
724 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",
725 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",
726 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",
727 pois => "<b>Poison</b> (resistance to getting poisoned)", 718 "<b>Poison</b> (resistance to getting poisoned)"],
719 para => ["Paralysation",
728 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",
729 deat => "<b>Death</b> (resistance against death spells)", 722 "<b>Death</b> (resistance against death spells)"],
723 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.)", 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",
731 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",
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)", 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",
733 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",
734 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",
735 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",
736 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)"],
737 ); 737 );
738 for (qw/slow holyw conf fire depl magic 738 for (qw/slow holyw conf fire depl magic
739 drain acid pois para deat phys 739 drain acid pois para deat phys
740 blind fear tund elec cold ghit/) 740 blind fear tund elec cold ghit/)
741 { 741 {
746 template => "-100%", 746 template => "-100%",
747 align => +1, 747 align => +1,
748 valign => 0, 748 valign => 0,
749 can_events => 1, 749 can_events => 1,
750 can_hover => 1, 750 can_hover => 1,
751 tooltip => $resist_names{$_}, 751 tooltip => $resist_names{$_}->[1],
752 ); 752 );
753 $tbl2->add ($col + 1, $row, new CFClient::UI::Image 753 $tbl2->add ($col + 1, $row, new CFClient::UI::Image
754 font => $FONT_FIXED, 754 font => $FONT_FIXED,
755 can_hover => 1, 755 can_hover => 1,
756 can_events => 1, 756 can_events => 1,
757 path => "ui/resist/resist_$_.png", 757 path => "ui/resist/resist_$_.png",
758 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],
759 ); 766 );
760 767
761 $row++; 768 $row++;
762 if ($row % 6 == 0) { 769 if ($row % 6 == 0) {
763 $col += 2; 770 $col += 3;
764 $row = 0; 771 $row = 0;
765 } 772 }
766 } 773 }
767 774
768 &set_stats_window_fontsize;
769 update_stats_window ({}); 775 update_stats_window ({});
770 776
771 $tgw 777 $vb
778}
779
780sub skill_window {
781 my ($self) = @_;
782 $STATWIDS->{"_skill_tbl"} = new CFClient::UI::Table expand => 1;
772} 783}
773 784
774sub formsep($) { 785sub formsep($) {
775 scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 786 scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1
776} 787}
836 depl => CS_STAT_RES_DEPLETE, 847 depl => CS_STAT_RES_DEPLETE,
837 deat => CS_STAT_RES_DEATH, 848 deat => CS_STAT_RES_DEATH,
838 holyw => CS_STAT_RES_HOLYWORD, 849 holyw => CS_STAT_RES_HOLYWORD,
839 blind => CS_STAT_RES_BLIND, 850 blind => CS_STAT_RES_BLIND,
840 ); 851 );
852
853 if ($::CONN && !$STATWIDS->{_skill_tbl_init}) {
854 my $sktbl = $STATWIDS->{_skill_tbl};
855 $sktbl->clear;
856
857 $sktbl->add (0, 0, new CFClient::UI::Label text => "Exp.", align => 1);
858 $sktbl->add (1, 0, new CFClient::UI::Label text => "Level", align => 1);
859 $sktbl->add (2, 0, new CFClient::UI::Label text => "Skillname");
860
861 my @skills;
862
863 for (my $i = CS_STAT_SKILLINFO; $i < CS_STAT_SKILLINFO+CS_NUM_SKILLS; $i++) {
864 push @skills, [$i, $::CONN->{skill_info}{$i}];
865 }
866
867 my $y = 1;
868 for (sort { $a->[1] cmp $b->[1] } @skills) {
869 my ($idx, $name) = @$_;
870
871 unless (defined $STATWIDS->{"sk_xp_$idx"} || !$::CONN->{skill_info}{$idx}) {
872 $sktbl->add (0, $y, $STATWIDS->{"sk_xp_$idx"} = new CFClient::UI::Label text => "0", align => 1);
873 $sktbl->add (1, $y, $STATWIDS->{"sk_lvl_$idx"} = new CFClient::UI::Label text => "0", align => 1);
874 $sktbl->add (2, $y++, new CFClient::UI::Label text => $name);
875 }
876 }
877
878 $STATWIDS->{_skill_tbl_init} = 1;
879 }
880
881 for (my $i = CS_STAT_SKILLINFO; $i < CS_STAT_SKILLINFO+CS_NUM_SKILLS; $i++) {
882 if (exists $stats->{$i}) {
883 $STATWIDS->{"sk_xp_$i"}->set_text (formsep $stats->{$i}->[1])
884 if $STATWIDS->{"sk_xp_$i"};
885 $STATWIDS->{"sk_lvl_$i"}->set_text (sprintf "%d", $stats->{$i}->[0])
886 if $STATWIDS->{"sk_lvl_$i"};
887 }
888 }
841 889
842 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) 890 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}})
843 for keys %tbl; 891 for keys %tbl;
844} 892}
845 893
1094sub message_window { 1142sub message_window {
1095 my $window = new CFClient::UI::FancyFrame 1143 my $window = new CFClient::UI::FancyFrame
1096 name => "message_window", 1144 name => "message_window",
1097 title => "Messages", 1145 title => "Messages",
1098 border_bg => [1, 1, 1, 1], 1146 border_bg => [1, 1, 1, 1],
1099 bg => [0, 0, 0, 0.75],
1100 x => "max", 1147 x => "max",
1101 y => 0, 1148 y => 0,
1102 force_w => $::WIDTH * 0.4, 1149 force_w => $::WIDTH * 0.4,
1103 force_h => $::HEIGHT * 0.5, 1150 force_h => $::HEIGHT * 0.5,
1104 child => (my $vbox = new CFClient::UI::VBox), 1151 child => (my $vbox = new CFClient::UI::VBox),
1319 x => "center", 1366 x => "center",
1320 y => "center", 1367 y => "center",
1321 force_w => $WIDTH * 9/10, 1368 force_w => $WIDTH * 9/10,
1322 force_h => $HEIGHT * 9/10, 1369 force_h => $HEIGHT * 9/10,
1323 title => "Player", 1370 title => "Player",
1371 name => "playerbook",
1324 has_close_button => 1 1372 has_close_button => 1
1325 ; 1373 ;
1326 1374
1327 my $ntb = 1375 my $ntb =
1328 $PL_NOTEBOOK = 1376 $PL_NOTEBOOK =
1331 debug => 1, 1379 debug => 1,
1332 filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1), 1380 filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1),
1333 ; 1381 ;
1334 1382
1335 $ntb->add ( 1383 $ntb->add (
1336 "Stats &amp; Skills" => $STATS_PAGE = stats_window, 1384 "Stats" => $STATS_PAGE = stats_window,
1337 "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."
1338 ); 1390 );
1339 $ntb->add ( 1391 $ntb->add (
1340 Spellbook => $SPELL_PAGE = new CFClient::UI::SpellList, 1392 Spellbook => $SPELL_PAGE = new CFClient::UI::SpellList,
1341 "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."
1342 ); 1394 );
1344 Inventory => $INVENTORY_PAGE = inventory_widget, 1396 Inventory => $INVENTORY_PAGE = inventory_widget,
1345 "Toggles the inventory window, where you can manage your loot (or treasures :). " 1397 "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." 1398 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory."
1347 ); 1399 );
1348 1400
1401 $ntb->set_current_page ($INVENTORY_PAGE);
1349 1402
1350 $plwin->add ($ntb); 1403 $plwin->add ($ntb);
1351 $plwin 1404 $plwin
1352} 1405}
1353 1406
1887# 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#
1888 }, 1941 },
1889 CFClient::SDL_KEYDOWN => sub { 1942 CFClient::SDL_KEYDOWN => sub {
1890 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { 1943 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) {
1891 # alt-enter 1944 # alt-enter
1945 $FULLSCREEN_ENABLE->toggle;
1892 video_shutdown; 1946 video_shutdown;
1893 $CFG->{fullscreen} = !$CFG->{fullscreen};
1894 video_init; 1947 video_init;
1895 } else { 1948 } else {
1896 CFClient::UI::feed_sdl_key_down_event ($_[0]); 1949 CFClient::UI::feed_sdl_key_down_event ($_[0]);
1897 } 1950 }
1898 }, 1951 },

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines