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.74 by root, Sun Jun 18 17:13:12 2006 UTC vs.
Revision 1.96 by root, Mon Jul 17 01:41:54 2006 UTC

36 36
37use CFClient; 37use CFClient;
38use CFClient::OpenGL (); 38use CFClient::OpenGL ();
39use CFClient::Protocol; 39use CFClient::Protocol;
40use CFClient::UI; 40use CFClient::UI;
41use CFClient::BindingEditor;
41use CFClient::MapWidget; 42use CFClient::MapWidget;
42 43
43$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 44$SIG{QUIT} = sub { Carp::cluck "QUIT" };
45$SIG{PIPE} = 'IGNORE';
44 46
45$Event::DIED = sub { 47$Event::DIED = sub {
46 # TODO: display dialog box or so 48 # TODO: display dialog box or so
47 Carp::confess $_[1];#d#TODO: remove when stable 49 Carp::confess $_[1];#d#TODO: remove when stable
48 CFClient::error $_[1]; 50 CFClient::error $_[1];
84our $CONSOLE; 86our $CONSOLE;
85our $METASERVER; 87our $METASERVER;
86our $LOGIN_BUTTON; 88our $LOGIN_BUTTON;
87our $QUIT_DIALOG; 89our $QUIT_DIALOG;
88our $HOST_ENTRY; 90our $HOST_ENTRY;
91our $FULLSCREEN_ENABLE;
92our $PICKUP_ENABLE;
89our $SERVER_INFO; 93our $SERVER_INFO;
90 94
91our $SETUP_DIALOG; 95our $SETUP_DIALOG;
92our $SETUP_NOTEBOOK; 96our $SETUP_NOTEBOOK;
93our $SETUP_SERVER; 97our $SETUP_SERVER;
94our $SETUP_KEYBOARD; 98our $SETUP_KEYBOARD;
95our $SETUP_SPELLS;
96 99
100our $PL_NOTEBOOK;
97our $STATS_WINDOW; 101our $PL_WINDOW;
102
103our $INVENTORY_PAGE;
104our $STATS_PAGE;
105our $SKILL_PAGE;
106our $SPELL_PAGE;
107
108our $HELP_WINDOW;
98our $MESSAGE_WINDOW; 109our $MESSAGE_WINDOW;
99our $FLOORBOX; 110our $FLOORBOX;
100our $GAUGES; 111our $GAUGES;
101our $STATWIDS; 112our $STATWIDS;
102 113
109 120
110our $ALT_ENTER_MESSAGE; 121our $ALT_ENTER_MESSAGE;
111our $STATUSBOX; 122our $STATUSBOX;
112our $DEBUG_STATUS; 123our $DEBUG_STATUS;
113 124
114our $INV_WINDOW;
115our $INV; 125our $INV;
116our $INVR; 126our $INVR;
117our $INV_RIGHT_HB; 127our $INV_RIGHT_HB;
118 128
119our $BIND_EDITOR; 129our $BIND_EDITOR;
130our $BIND_UPD_CB;
120 131
121our $PICKUP_CFG; 132our $PICKUP_CFG;
122 133
123sub status { 134sub status {
124 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); 135 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
219 $conn->send ("reply $stat"); 230 $conn->send ("reply $stat");
220 destroy_query_dialog $conn; 231 destroy_query_dialog $conn;
221 return; 232 return;
222 } 233 }
223 234
224 $STATS_WINDOW->show; 235 $STATS_PAGE->show;
225 $MESSAGE_WINDOW->hide; 236 $MESSAGE_WINDOW->hide;
226 237
227 unshift @dialog, new CFClient::UI::Label 238 unshift @dialog, new CFClient::UI::Label
228 max_w => $::WIDTH * 0.4, 239 max_w => $::WIDTH * 0.4,
229 ellipsise => 0, 240 ellipsise => 0,
269 # right: accept 280 # right: accept
270 $table->add (4, 0, new CFClient::UI::Button 281 $table->add (4, 0, new CFClient::UI::Button
271 text => "Accept", 282 text => "Accept",
272 on_activate => sub { 283 on_activate => sub {
273 $conn->send ("reply n"); 284 $conn->send ("reply n");
274 $STATS_WINDOW->hide; 285 $STATS_PAGE->hide;
275 destroy_query_dialog $conn; 286 destroy_query_dialog $conn;
276 0 287 0
277 }, 288 },
278 ); 289 );
279 290
324 $LOGIN_BUTTON->set_text ("Logout"); 335 $LOGIN_BUTTON->set_text ("Logout");
325 $SETUP_DIALOG->hide; 336 $SETUP_DIALOG->hide;
326 337
327 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 338 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
328 339
329 my ($host, $port) = split /:/, $CFG->{host}; 340 my ($host, $port) = split /:/, $CFG->{profile}{default}{host};
330 341
331 $MAP = new CFClient::Map $mapsize, $mapsize; 342 $MAP = new CFClient::Map $mapsize, $mapsize;
332 343
333 $CONN = eval { 344 $CONN = eval {
334 new CFClient::Protocol 345 new CFClient::Protocol
335 host => $host, 346 host => $host,
336 port => $port || 13327, 347 port => $port || 13327,
337 user => $CFG->{user}, 348 user => $CFG->{profile}{default}{user},
338 pass => $CFG->{password}, 349 pass => $CFG->{profile}{default}{password},
339 mapw => $mapsize, 350 mapw => $mapsize,
340 maph => $mapsize, 351 maph => $mapsize,
341 352
342 map_widget => $MAPWIDGET, 353 map_widget => $MAPWIDGET,
343 logview => $LOGVIEW, 354 logview => $LOGVIEW,
371 382
372sub stop_game { 383sub stop_game {
373 $LOGIN_BUTTON->set_text ("Login"); 384 $LOGIN_BUTTON->set_text ("Login");
374 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); 385 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER);
375 $SETUP_DIALOG->show; 386 $SETUP_DIALOG->show;
376 $INV_WINDOW->hide; 387 $PL_WINDOW->hide;
377 $SETUP_SPELLS->clear_spells; 388 $SPELL_PAGE->clear_spells;
378 389
379 return unless $CONN; 390 return unless $CONN;
380 391
381 status "connection closed"; 392 status "connection closed";
382 393
383 destroy_query_dialog $CONN; 394 destroy_query_dialog $CONN;
384 $CONN->destroy; 395 $CONN->destroy;
385 $CONN = 0; # false, does not autovivify 396 $CONN = 0; # false, does not autovivify
397
398 undef $MAP;
386} 399}
387 400
388sub graphics_setup { 401sub graphics_setup {
389 my $vbox = new CFClient::UI::VBox; 402 my $vbox = new CFClient::UI::VBox;
390 403
405 $mode_slider->emit (changed => $mode_slider->{range}[0]); 418 $mode_slider->emit (changed => $mode_slider->{range}[0]);
406 419
407 my $row = 1; 420 my $row = 1;
408 421
409 $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");
410 $table->add (1, $row++, new CFClient::UI::CheckBox 423 $table->add (1, $row++, $FULLSCREEN_ENABLE = new CFClient::UI::CheckBox
411 state => $CFG->{fullscreen}, 424 state => $CFG->{fullscreen},
412 tooltip => "Bring the client into fullscreen mode.", 425 tooltip => "Bring the client into fullscreen mode.",
413 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } 426 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 }
414 ); 427 );
415 428
465 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], 478 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1],
466 tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", 479 tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.",
467 on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, 480 on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 },
468 ); 481 );
469 482
470 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize");
471
472 $table->add (1, $row++, new CFClient::UI::Slider
473 range => [$CFG->{stat_fontsize}, 0.5, 2, 0, 0.1],
474 tooltip => "The font size used by the <b>statistics window</b> only. Changes are instant.",
475 on_changed => sub {
476 $CFG->{stat_fontsize} = $_[1];
477 &set_stats_window_fontsize;
478 0
479 }
480 );
481
482 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); 483 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize");
483 $table->add (1, $row++, new CFClient::UI::Slider 484 $table->add (1, $row++, new CFClient::UI::Slider
484 range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], 485 range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1],
485 tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.", 486 tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.",
486 on_changed => sub { 487 on_changed => sub {
555 ); 556 );
556 557
557 $vbox 558 $vbox
558} 559}
559 560
560sub set_stats_window_fontsize {
561 for (values %{$STATWIDS}) {
562 $_->set_fontsize ($::CFG->{stat_fontsize});
563 }
564}
565
566sub set_gauge_window_fontsize { 561sub set_gauge_window_fontsize {
567 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) { 562 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) {
568 $_->set_fontsize ($::CFG->{gauge_fontsize}); 563 $_->set_fontsize ($::CFG->{gauge_fontsize});
569 } 564 }
570} 565}
649 644
650 $table 645 $table
651} 646}
652 647
653sub stats_window { 648sub stats_window {
654 my $tgw = new CFClient::UI::FancyFrame 649 my $vb = new CFClient::UI::VBox;
655 y => $HEIGHT * (2/8),
656 x => "max",
657 title => "Stats",
658 name => "stats_window",
659 has_close_button => 1;
660 650
661 $tgw->add (new CFClient::UI::Window child => my $vb = new CFClient::UI::VBox);
662 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, 651 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1,
663 can_hover => 1, can_events => 1, 652 can_hover => 1, can_events => 1,
664 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); 653 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server.");
665 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1, 654 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1,
666 can_hover => 1, can_events => 1, 655 can_hover => 1, can_events => 1,
690 [0, 6, st_cha => "Cha", 30, "<b>Charisma</b>, how well you are received by NPCs. Affects buying and selling prices in shops."], 679 [0, 6, st_cha => "Cha", 30, "<b>Charisma</b>, how well you are received by NPCs. Affects buying and selling prices in shops."],
691 680
692 [2, 0, st_wc => "Wc", -120, "<b>Weapon Class</b>, effectiveness of melee/missile attacks. Lower is more potent. Current weapon, level and Str are some things which effect the value of Wc. The value of Wc may range between 25 and -72."], 681 [2, 0, st_wc => "Wc", -120, "<b>Weapon Class</b>, effectiveness of melee/missile attacks. Lower is more potent. Current weapon, level and Str are some things which effect the value of Wc. The value of Wc may range between 25 and -72."],
693 [2, 1, st_ac => "Ac", -120, "<b>Armour Class</b>, how protected you are from being hit by any attack. Lower values are better. Ac is based on your race and is modified by the Dex and current armour worn. For characters that cannot wear armour, Ac improves as their level increases."], 682 [2, 1, st_ac => "Ac", -120, "<b>Armour Class</b>, how protected you are from being hit by any attack. Lower values are better. Ac is based on your race and is modified by the Dex and current armour worn. For characters that cannot wear armour, Ac improves as their level increases."],
694 [2, 2, st_dam => "Dam", 120, "<b>Damage</b>, how much damage your melee/missile attack inflicts. Higher values indicate a greater amount of damage will be inflicted with each attack."], 683 [2, 2, st_dam => "Dam", 120, "<b>Damage</b>, how much damage your melee/missile attack inflicts. Higher values indicate a greater amount of damage will be inflicted with each attack."],
695 [2, 3, st_arm => "Arm", 120, "<b>Armour</b>, how much damage (from physical attacks) will be subtracted from successful hits made upon you. This value ranges between 0 to 99%. Current armour worn primarily determines Arm value."], 684 [2, 3, st_arm => "Arm", 120, "<b>Armour</b>, how much damage (from physical attacks) will be subtracted from successful hits made upon you. This value ranges between 0 to 99%. Current armour worn primarily determines Arm value. This is the same as the physical resistance."],
696 [2, 4, st_spd => "Spd", 10.54, "<b>Speed</b>, how fast you can move. The value of speed may range between nearly 0 (\"very slow\") to higher than 5 (\"lightning fast\"). Base speed is determined from the Dex and modified downward proportionally by the amount of weight carried which exceeds the Max Carry limit. The armour worn also sets the upper limit on speed."], 685 [2, 4, st_spd => "Spd", 10.54, "<b>Speed</b>, how fast you can move. The value of speed may range between nearly 0 (\"very slow\") to higher than 5 (\"lightning fast\"). Base speed is determined from the Dex and modified downward proportionally by the amount of weight carried which exceeds the Max Carry limit. The armour worn also sets the upper limit on speed."],
697 [2, 5, st_wspd => "WSp", 10.54, "<b>Weapon Speed</b>, how many attacks you may make per unit of time (0.120s). Higher values indicate faster attack speed. Current weapon and Dex effect the value of weapon speed."], 686 [2, 5, st_wspd => "WSp", 10.54, "<b>Weapon Speed</b>, how many attacks you may make per unit of time (0.120s). Higher values indicate faster attack speed. Current weapon and Dex effect the value of weapon speed."],
698 ) { 687 ) {
699 my ($col, $row, $id, $label, $template, $tooltip) = @$_; 688 my ($col, $row, $id, $label, $template, $tooltip) = @$_;
700 689
702 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);
703 $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
704 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);
705 } 694 }
706 695
707 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); 696 $vb->add (my $tbl2 = new CFClient::UI::Table expand => 1);
708 697
709 my $row = 0; 698 my $row = 0;
710 my $col = 0; 699 my $col = 0;
711 700
712 my %resist_names = ( 701 my %resist_names = (
702 slow => ["Slow",
713 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",
714 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",
715 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",
716 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",
717 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",
718 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",
719 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",
720 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",
721 pois => "<b>Poison</b> (resistance to getting poisoned)", 719 "<b>Poison</b> (resistance to getting poisoned)"],
720 para => ["Paralysation",
722 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",
723 deat => "<b>Death</b> (resistance against death spells)", 723 "<b>Death</b> (resistance against death spells)"],
724 phys => "<b>Physical</b> (this is the resistance against physical attacks, like when a monster hit you in melee combat)", 724 phys => ["Physical",
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",
725 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",
726 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",
727 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",
728 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",
729 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",
730 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)"],
731 ); 738 );
732 for (qw/slow holyw conf fire depl magic 739 for (qw/slow holyw conf fire depl magic
733 drain acid pois para deat phys 740 drain acid pois para deat phys
734 blind fear tund elec cold ghit/) 741 blind fear tund elec cold ghit/)
735 { 742 {
740 template => "-100%", 747 template => "-100%",
741 align => +1, 748 align => +1,
742 valign => 0, 749 valign => 0,
743 can_events => 1, 750 can_events => 1,
744 can_hover => 1, 751 can_hover => 1,
745 tooltip => $resist_names{$_}, 752 tooltip => $resist_names{$_}->[1],
746 ); 753 );
747 $tbl2->add ($col + 1, $row, new CFClient::UI::Image 754 $tbl2->add ($col + 1, $row, new CFClient::UI::Image
748 font => $FONT_FIXED, 755 font => $FONT_FIXED,
749 can_hover => 1, 756 can_hover => 1,
750 can_events => 1, 757 can_events => 1,
751 image => "ui/resist/resist_$_.png", 758 path => "ui/resist/resist_$_.png",
752 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],
753 ); 767 );
754 768
755 $row++; 769 $row++;
756 if ($row % 6 == 0) { 770 if ($row % 6 == 0) {
757 $col += 2; 771 $col += 3;
758 $row = 0; 772 $row = 0;
759 } 773 }
760 } 774 }
761 775
762 &set_stats_window_fontsize;
763 update_stats_window ({}); 776 #update_stats_window ({});
764 777
765 $tgw 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]
766} 783}
767 784
768sub formsep($) { 785sub formsep($) {
769 scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 786 scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1
770} 787}
771 788
772sub update_stats_window {
773 my ($stats) = @_;
774
775 # I love text protocols...
776
777 my $hp = $stats->{+CS_STAT_HP} * 1;
778 my $hp_m = $stats->{+CS_STAT_MAXHP} * 1;
779 my $sp = $stats->{+CS_STAT_SP} * 1;
780 my $sp_m = $stats->{+CS_STAT_MAXSP} * 1;
781 my $fo = $stats->{+CS_STAT_FOOD} * 1;
782 my $fo_m = 999;
783 my $gr = $stats->{+CS_STAT_GRACE} * 1;
784 my $gr_m = $stats->{+CS_STAT_MAXGRACE} * 1;
785
786 $GAUGES->{hp} ->set_value ($hp, $hp_m);
787 $GAUGES->{mana} ->set_value ($sp, $sp_m);
788 $GAUGES->{food} ->set_value ($fo, $fo_m);
789 $GAUGES->{grace} ->set_value ($gr, $gr_m);
790 $GAUGES->{exp} ->set_text ("Exp: " . (formsep $stats->{+CS_STAT_EXP64})
791 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")");
792 my $rng = $stats->{+CS_STAT_RANGE};
793 $rng =~ s/^Range: //; # thank you so much dear server
794 $GAUGES->{range} ->set_text ("Rng: " . $rng);
795 my $title = $stats->{+CS_STAT_TITLE};
796 $title =~ s/^Player: //;
797 $STATWIDS->{title} ->set_text ("Title: " . $title);
798
799 $STATWIDS->{st_str} ->set_text (sprintf "%d" , $stats->{+CS_STAT_STR});
800 $STATWIDS->{st_dex} ->set_text (sprintf "%d" , $stats->{+CS_STAT_DEX});
801 $STATWIDS->{st_con} ->set_text (sprintf "%d" , $stats->{+CS_STAT_CON});
802 $STATWIDS->{st_int} ->set_text (sprintf "%d" , $stats->{+CS_STAT_INT});
803 $STATWIDS->{st_wis} ->set_text (sprintf "%d" , $stats->{+CS_STAT_WIS});
804 $STATWIDS->{st_pow} ->set_text (sprintf "%d" , $stats->{+CS_STAT_POW});
805 $STATWIDS->{st_cha} ->set_text (sprintf "%d" , $stats->{+CS_STAT_CHA});
806 $STATWIDS->{st_wc} ->set_text (sprintf "%d" , $stats->{+CS_STAT_WC});
807 $STATWIDS->{st_ac} ->set_text (sprintf "%d" , $stats->{+CS_STAT_AC});
808 $STATWIDS->{st_dam} ->set_text (sprintf "%d" , $stats->{+CS_STAT_DAM});
809 $STATWIDS->{st_arm} ->set_text (sprintf "%d" , $stats->{+CS_STAT_ARMOUR});
810 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED});
811 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP});
812
813 $STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{+CS_STAT_WEIGHT_LIM} / 1000);
814
815 my %tbl = (
816 phys => CS_STAT_RES_PHYS,
817 magic => CS_STAT_RES_MAG,
818 fire => CS_STAT_RES_FIRE,
819 elec => CS_STAT_RES_ELEC,
820 cold => CS_STAT_RES_COLD,
821 conf => CS_STAT_RES_CONF,
822 acid => CS_STAT_RES_ACID,
823 drain => CS_STAT_RES_DRAIN,
824 ghit => CS_STAT_RES_GHOSTHIT,
825 pois => CS_STAT_RES_POISON,
826 slow => CS_STAT_RES_SLOW,
827 para => CS_STAT_RES_PARA,
828 tund => CS_STAT_TURN_UNDEAD,
829 fear => CS_STAT_RES_FEAR,
830 depl => CS_STAT_RES_DEPLETE,
831 deat => CS_STAT_RES_DEATH,
832 holyw => CS_STAT_RES_HOLYWORD,
833 blind => CS_STAT_RES_BLIND,
834 );
835
836 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}})
837 for keys %tbl;
838}
839
840my $METASERVER_ATIME; 789my $METASERVER_ATIME;
841 790
842sub update_metaserver { 791sub update_metaserver {
792 my ($metaserver_dialog) = @_;
793
794 $METASERVER = $metaserver_dialog
795 if defined $metaserver_dialog;
796
843 return if $METASERVER_ATIME > time; 797 return if $METASERVER_ATIME > time;
844 $METASERVER_ATIME = time + 60; 798 $METASERVER_ATIME = time + 60;
845 799
846 my $table = $METASERVER->{table}; 800 my $table = $METASERVER->{table};
847 $table->clear; 801 $table->clear;
912 $table->add (scalar @$m, $y, new CFClient::UI::VBox children => [ 866 $table->add (scalar @$m, $y, new CFClient::UI::VBox children => [
913 (new CFClient::UI::Button 867 (new CFClient::UI::Button
914 text => "Use", 868 text => "Use",
915 tooltip => "Put this server into the <b>Host:Port</b> field", 869 tooltip => "Put this server into the <b>Host:Port</b> field",
916 on_activate => sub { 870 on_activate => sub {
917 $HOST_ENTRY->set_text ($CFG->{host} = $host); 871 $HOST_ENTRY->set_text ($CFG->{profile}{default}{host} = $host);
918 $METASERVER->hide; 872 $METASERVER->hide;
919 0 873 0
920 }, 874 },
921 ), 875 ),
922 (new CFClient::UI::Empty expand => 1), 876 (new CFClient::UI::Empty expand => 1),
935 } 889 }
936 }); 890 });
937} 891}
938 892
939sub metaserver_dialog { 893sub metaserver_dialog {
894 my $vbox = new CFClient::UI::VBox;
895 my $table = new CFClient::UI::Table;
896 $vbox->add (new CFClient::UI::ScrolledWindow expand => 1, child => $table);
897
940 my $dialog = new CFClient::UI::FancyFrame 898 my $dialog = new CFClient::UI::FancyFrame
941 title => "Server List", 899 title => "Server List",
942 name => 'metaserver_dialog', 900 name => 'metaserver_dialog',
943 x => 'center', 901 x => 'center',
944 y => 'center', 902 y => 'center',
945 z => 3, 903 z => 3,
946 force_h => $::HEIGHT * 0.4, 904 force_h => $::HEIGHT * 0.4,
947 child => (my $vbox = new CFClient::UI::VBox), 905 child => $vbox,
906 has_close_button => 1,
907 table => $table,
948 on_visibility_change => sub { 908 on_visibility_change => sub {
949 update_metaserver if $_[1]; 909 update_metaserver ($_[0]) if $_[1];
950 0 910 0
951 }, 911 },
952 ; 912 ;
953 913
954 $dialog->{table} = new CFClient::UI::Table;
955
956 $vbox->add (new CFClient::UI::ScrolledWindow expand => 1, child => $dialog->{table});
957
958 $dialog 914 $dialog
959} 915}
960 916
961sub server_setup { 917sub server_setup {
962 my $vbox = new CFClient::UI::VBox; 918 my $vbox = new CFClient::UI::VBox;
968 $table->add (1, 2, my $vbox = new CFClient::UI::VBox); 924 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
969 925
970 $vbox->add ( 926 $vbox->add (
971 $HOST_ENTRY = new CFClient::UI::Entry 927 $HOST_ENTRY = new CFClient::UI::Entry
972 expand => 1, 928 expand => 1,
973 text => $CFG->{host}, 929 text => $CFG->{profile}{default}{host},
974 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to", 930 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to",
975 on_changed => sub { 931 on_changed => sub {
976 my ($self, $value) = @_; 932 my ($self, $value) = @_;
977 $CFG->{host} = $value; 933 $CFG->{profile}{default}{host} = $value;
978 0 934 0
979 } 935 }
980 ); 936 );
981
982 $METASERVER = metaserver_dialog;
983 937
984 $vbox->add (new CFClient::UI::Button 938 $vbox->add (new CFClient::UI::Button
985 expand => 1, 939 expand => 1,
986 text => "Server List", 940 text => "Server List",
987 other => $METASERVER, 941 other => $METASERVER,
991 ); 945 );
992 } 946 }
993 947
994 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); 948 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
995 $table->add (1, 4, new CFClient::UI::Entry 949 $table->add (1, 4, new CFClient::UI::Entry
996 text => $CFG->{user}, 950 text => $CFG->{profile}{default}{user},
997 tooltip => "The name of your character on the server", 951 tooltip => "The name of your character on the server",
998 on_changed => sub { my ($self, $value) = @_; $CFG->{user} = $value; 0 } 952 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value }
999 ); 953 );
1000 954
1001 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password"); 955 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password");
1002 $table->add (1, 5, new CFClient::UI::Entry 956 $table->add (1, 5, new CFClient::UI::Entry
1003 text => $CFG->{password}, 957 text => $CFG->{profile}{default}{password},
1004 hidden => 1, 958 hidden => 1,
1005 tooltip => "The password for your character", 959 tooltip => "The password for your character",
1006 on_changed => sub { my ($self, $value) = @_; $CFG->{password} = $value; 0 } 960 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value }
1007 ); 961 );
1008 962
1009 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); 963 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
1010 $table->add (1, 7, new CFClient::UI::Slider 964 $table->add (1, 7, new CFClient::UI::Slider
1011 force_w => 100, 965 force_w => 100,
1083sub message_window { 1037sub message_window {
1084 my $window = new CFClient::UI::FancyFrame 1038 my $window = new CFClient::UI::FancyFrame
1085 name => "message_window", 1039 name => "message_window",
1086 title => "Messages", 1040 title => "Messages",
1087 border_bg => [1, 1, 1, 1], 1041 border_bg => [1, 1, 1, 1],
1088 bg => [0, 0, 0, 0.75],
1089 x => "max", 1042 x => "max",
1090 y => 0, 1043 y => 0,
1091 force_w => $::WIDTH * 0.4, 1044 force_w => $::WIDTH * 0.4,
1092 force_h => $::HEIGHT * 0.5, 1045 force_h => $::HEIGHT * 0.5,
1093 child => (my $vbox = new CFClient::UI::VBox), 1046 child => (my $vbox = new CFClient::UI::VBox),
1179sub autopickup_setup { 1132sub autopickup_setup {
1180 my $table = new CFClient::UI::Table; 1133 my $table = new CFClient::UI::Table;
1181 1134
1182 for ( 1135 for (
1183 ["General", 0, 0, 1136 ["General", 0, 0,
1184 ["Enable autopickup" => PICKUP_NEWMODE], 1137 ["Enable autopickup" => PICKUP_NEWMODE, \$PICKUP_ENABLE],
1185 ["Inhibit autopickup" => PICKUP_INHIBIT], 1138 ["Inhibit autopickup" => PICKUP_INHIBIT],
1186 ["Stop before pickup" => PICKUP_STOP], 1139 ["Stop before pickup" => PICKUP_STOP],
1187 ["Debug autopickup" => PICKUP_DEBUG], 1140 ["Debug autopickup" => PICKUP_DEBUG],
1188 ], 1141 ],
1189 ["Weapons", 0, 6, 1142 ["Weapons", 0, 6,
1226 for (@bits) { 1179 for (@bits) {
1227 ++$y; 1180 ++$y;
1228 1181
1229 my $mask = $_->[1]; 1182 my $mask = $_->[1];
1230 $table->add ($x , $y, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1); 1183 $table->add ($x , $y, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1);
1231 $table->add ($x+1, $y, new CFClient::UI::CheckBox 1184 $table->add ($x+1, $y, my $checkbox = new CFClient::UI::CheckBox
1232 state => $CFG->{pickup} & $mask, 1185 state => $::CFG->{pickup} & $mask,
1233 on_changed => sub { 1186 on_changed => sub {
1234 my ($box, $value) = @_; 1187 my ($box, $value) = @_;
1235 1188
1236 if ($value) { 1189 if ($value) {
1237 $::CFG->{pickup} |= $mask; 1190 $::CFG->{pickup} |= $mask;
1242 $::CONN->send_command ("pickup $::CFG->{pickup}") 1195 $::CONN->send_command ("pickup $::CFG->{pickup}")
1243 if defined $::CONN; 1196 if defined $::CONN;
1244 1197
1245 0 1198 0
1246 }); 1199 });
1200
1201 ${$_->[2]} = $checkbox if $_->[2];
1247 } 1202 }
1248 } 1203 }
1249 1204
1250 $table->add (2, 18, new CFClient::UI::ValSlider 1205 $table->add (2, 18, new CFClient::UI::ValSlider
1251 range => [0, 0, 16, 1, 1], 1206 range => [$::CFG->{pickup} & 0xF, 0, 16, 1, 1],
1207 template => ">= 99",
1252 to_value => sub { ">= " . 5 * $_[0] }, 1208 to_value => sub { ">= " . 5 * $_[0] },
1253 on_changed => sub { 1209 on_changed => sub {
1254 my ($slider, $value) = @_; 1210 my ($slider, $value) = @_;
1255 1211
1256 $::CFG->{pickup} &= ~0x7; 1212 $::CFG->{pickup} &= ~0xF;
1257 $::CFG->{pickup} |= int $value 1213 $::CFG->{pickup} |= int $value
1258 if $value; 1214 if $value;
1259 1; 1215 1;
1260 }); 1216 });
1217
1261 $table->add (3, 18, new CFClient::UI::Button 1218 $table->add (3, 18, new CFClient::UI::Button
1262 text => "set", 1219 text => "set",
1263 on_activate => sub { 1220 on_activate => sub {
1264 $::CONN->send_command ("pickup $::CFG->{pickup}") 1221 $::CONN->send_command ("pickup $::CFG->{pickup}")
1265 if defined $::CONN; 1222 if defined $::CONN;
1267 }); 1224 });
1268 1225
1269 $table 1226 $table
1270} 1227}
1271 1228
1272sub inventory_window { 1229sub inventory_widget {
1230 my $hb = new CFClient::UI::HBox homogeneous => 1;
1231
1232 $hb->add (my $vb1 = new CFClient::UI::VBox);
1233 $vb1->add (new CFClient::UI::Label align => 0, text => "Player");
1234 $vb1->add ($INV = new CFClient::UI::Inventory);
1235
1236 $hb->add (my $vb2 = new CFClient::UI::VBox);
1237
1238 $vb2->add ($INV_RIGHT_HB = new CFClient::UI::HBox);
1239
1240 $vb2->add ($INVR = new CFClient::UI::Inventory);
1241
1242 # XXX: Call after $INVR = ... because set_opencont sets the items
1243 CFClient::Protocol::set_opencont ($::CONN, 0, "Floor");
1244
1245 $hb
1246}
1247
1248sub toggle_player_page {
1249 my ($widget) = @_;
1250
1251 if ($PL_WINDOW->{visible} && $PL_NOTEBOOK->get_current_page == $widget) {
1252 $PL_WINDOW->hide;
1253 } else {
1254 $PL_NOTEBOOK->set_current_page ($widget);
1255 $PL_WINDOW->show;
1256 }
1257}
1258
1259sub player_window {
1273 my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame 1260 my $plwin = $PL_WINDOW = new CFClient::UI::FancyFrame
1274 x => "center", 1261 x => "center",
1275 y => "center", 1262 y => "center",
1276 force_w => $WIDTH * 9/10, 1263 force_w => $WIDTH * 9/10,
1277 force_h => $HEIGHT * 9/10, 1264 force_h => $HEIGHT * 9/10,
1278 title => "Inventory", 1265 title => "Player",
1266 name => "playerbook",
1279 has_close_button => 1, 1267 has_close_button => 1
1280 ; 1268 ;
1281 1269
1282 $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1); 1270 my $ntb =
1271 $PL_NOTEBOOK =
1272 new CFClient::UI::Notebook
1273 expand => 1,
1274 debug => 1,
1275 filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1),
1276 ;
1283 1277
1284 $hb->add (my $vb1 = new CFClient::UI::VBox); 1278 $ntb->add (
1285 $vb1->add (new CFClient::UI::Label align => 0, text => "Player"); 1279 "Statistics (F2)" => $STATS_PAGE = stats_window,
1286 $vb1->add ($INV = new CFClient::UI::Inventory expand => 1); 1280 "Shows statistics, where all your Stats and Resistances are shown."
1281 );
1282 $ntb->add (
1283 "Skills (F3)" => $SKILL_PAGE = skill_window,
1284 "Shows all your Skills."
1285 );
1286 $ntb->add (
1287 "Spellbook (F4)" => $SPELL_PAGE = new CFClient::UI::SpellList,
1288 "Displays all spells you have and lets you edit keyboard shortcuts for them."
1289 );
1290 $ntb->add (
1291 "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget,
1292 "Toggles the inventory window, where you can manage your loot (or treasures :). "
1293 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory."
1294 );
1287 1295
1288 $hb->add (my $vb2 = new CFClient::UI::VBox); 1296 $ntb->set_current_page ($INVENTORY_PAGE);
1289 1297
1290 $vb2->add ($INV_RIGHT_HB = new CFClient::UI::HBox); 1298 $plwin->add ($ntb);
1291 1299 $plwin
1292 $vb2->add ($INVR = new CFClient::UI::Inventory expand => 1);
1293
1294 # XXX: Call after $INVR = ... because set_opencont sets the items
1295 CFClient::Protocol::set_opencont ($::CONN, 0, "Floor");
1296
1297 $invwin
1298} 1300}
1299 1301
1300sub spell_setup { 1302sub update_bindings {
1301 new CFClient::UI::SpellList 1303 $BIND_UPD_CB->() if $BIND_UPD_CB;
1302} 1304}
1303 1305
1304sub keyboard_setup { 1306sub keyboard_setup {
1305 my $binding_list = new CFClient::UI::VBox; 1307 my $binding_list = new CFClient::UI::VBox;
1306 1308
1307 my $refresh; 1309 my $refresh;
1308 $refresh = sub { 1310 $refresh = $BIND_UPD_CB = sub {
1309 $binding_list->clear (); 1311 $binding_list->clear ();
1310 1312
1311 for my $mod (keys %{$::CFG->{bindings}}) { 1313 for my $mod (keys %{$::CFG->{profile}{default}{bindings}}) {
1312 for my $sym (keys %{$::CFG->{bindings}->{$mod}}) { 1314 for my $sym (keys %{$::CFG->{profile}{default}{bindings}{$mod}}) {
1313 my $cmds = $::CFG->{bindings}->{$mod}->{$sym}; 1315 my $cmds = $::CFG->{profile}{default}{bindings}{$mod}{$sym};
1314 next unless ref $cmds eq 'ARRAY' and @$cmds > 0; 1316 next unless ref $cmds eq 'ARRAY' and @$cmds > 0;
1315 1317
1316 my $lbl = join "; ", @$cmds; 1318 my $lbl = join "; ", @$cmds;
1317 my $nam = CFClient::Binder::keycombo_to_name ($mod, $sym); 1319 my $nam = CFClient::BindingEditor::keycombo_to_name ($mod, $sym);
1318 $binding_list->add (my $hb = new CFClient::UI::HBox); 1320 $binding_list->add (my $hb = new CFClient::UI::HBox);
1319 $hb->add (new CFClient::UI::Button 1321 $hb->add (new CFClient::UI::Button
1320 text => "delete", 1322 text => "delete",
1321 tooltip => "Deletes the binding", 1323 tooltip => "Deletes the binding",
1322 on_activate => sub { 1324 on_activate => sub {
1323 $binding_list->remove ($hb); 1325 $binding_list->remove ($hb);
1324 delete $::CFG->{bindings}->{$mod}->{$sym}; 1326 delete $::CFG->{profile}{default}{bindings}{$mod}{$sym};
1325 0 1327 0
1326 }); 1328 });
1327 1329
1328 $hb->add (new CFClient::UI::Button 1330 $hb->add (new CFClient::UI::Button
1329 text => "edit", 1331 text => "edit",
1330 tooltip => "Edits the binding", 1332 tooltip => "Edits the binding",
1331 on_activate => sub { 1333 on_activate => sub {
1332 $::BIND_EDITOR->set_binding ( 1334 $::BIND_EDITOR->set_binding (
1333 $mod, $sym, $::CFG->{bindings}->{$mod}->{$sym}, 1335 $mod, $sym, $::CFG->{profile}{default}{bindings}{$mod}{$sym},
1334 sub { 1336 sub {
1335 my ($nmod, $nsym, $ncmds) = @_; 1337 my ($nmod, $nsym, $ncmds) = @_;
1336 delete $::CFG->{bindings}->{$mod}->{$sym}; 1338 $::BIND_EDITOR->cfg_unbind ($mod, $sym);
1337 $::CFG->{bindings}->{$nmod}->{$nsym} = $ncmds; 1339 $::BIND_EDITOR->cfg_bind ($nmod, $nsym, $ncmds);
1338 $refresh->(); 1340 $refresh->();
1339 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); 1341 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD);
1340 $SETUP_DIALOG->show; 1342 $SETUP_DIALOG->show;
1341 }, 1343 },
1342 sub { 1344 sub {
1376 tooltip => "This button opens the binding editor with an empty binding.", 1378 tooltip => "This button opens the binding editor with an empty binding.",
1377 on_activate => sub { 1379 on_activate => sub {
1378 $::BIND_EDITOR->set_binding (undef, undef, [], 1380 $::BIND_EDITOR->set_binding (undef, undef, [],
1379 sub { 1381 sub {
1380 my ($mod, $sym, $cmds) = @_; 1382 my ($mod, $sym, $cmds) = @_;
1381 $::CFG->{bindings}->{$mod}->{$sym} = $cmds; 1383 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds);
1382 $refresh->(); 1384 $refresh->();
1383 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); 1385 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD);
1384 $SETUP_DIALOG->show; 1386 $SETUP_DIALOG->show;
1385 }, 1387 },
1386 sub { 1388 sub {
1407 $refresh->(); 1409 $refresh->();
1408 1410
1409 $vb 1411 $vb
1410} 1412}
1411 1413
1414# just weirdness, pls. ignore
1415sub load_html_page {
1416 my ($viewer, $base) = @_;
1417
1418 $viewer->clear;
1419
1420 require LWP::Simple;
1421 require HTML::Parser;
1422 require URI;
1423
1424 my $page = LWP::Simple::get ($base)
1425 or return;
1426
1427 my @s = { };
1428 my %passthrough = map ($_ => undef), qw(b i u s tt big small sub sup);
1429
1430 my $parser = HTML::Parser->new (
1431 text_h => [sub {
1432 my ($text) = @_;
1433 $text =~ s/\s+/ /g;
1434 $s[-1]{text} .= CFClient::UI::Label::escape $text;
1435 }, "dtext"],
1436 start_h => [sub {
1437 my ($tag, $attr) = @_;
1438 if ($passthrough{$tag}) {
1439 $s[-1]{text} .= "<$tag>";
1440 } elsif ($tag eq "h1") {
1441 push @s, { text => "<span foreground='#ffff00' size='x-large'>" };
1442 } elsif ($tag eq "h2") {
1443 push @s, { text => "<span foreground='#ccccff' size='large'>" };
1444 } elsif ($tag eq "h3") {
1445 push @s, { text => "<span size='large'>" };
1446 } elsif ($tag eq "a") {
1447 push @s, { text => "", url => $attr->{href} };
1448 } elsif ($tag eq "p") {
1449 push @s, { };
1450 } elsif ($tag eq "img") {
1451 eval {
1452 push @{$s[-1]{obj}}, new CFClient::UI::Image
1453 tex => (new_from_image CFClient::Texture LWP::Simple::get (URI->new ($attr->{src}, $base)->abs ($base)));
1454 $s[-1]{text} .= "\x{fffc}";
1455 };
1456 }
1457 }, "tagname, attr"],
1458 end_h => [sub {
1459 my ($tag) = @_;
1460 if ($passthrough{$tag}) {
1461 $s[-1]{text} .= "</$tag>";
1462 } elsif ($tag =~ /^h\d$/) {
1463 $s[-1]{text} .= "</span>";
1464 push @s, { };
1465 } elsif ($tag eq "a") {
1466 my $S = pop @s;
1467 $s[-1]{text} .= "\x{fffc}";
1468 push @{$s[-1]{obj}}, new CFClient::UI::Label
1469 fg => [0.8, 0.8, 1],
1470 markup => "<u>$S->{text}</u>",
1471 fontsize => 0.8,
1472 can_events => 1,
1473 can_focus => 1,
1474 on_button_up => sub {
1475 load_html_page ($viewer, URI->new ($S->{url}, $base)->abs ($base));
1476 },
1477 ;
1478 }
1479 }, "tagname"],
1480 );
1481
1482 $parser->parse ($page);
1483 $parser->eof;
1484
1485 $viewer->add_paragraph ([1, 1, 1, 1], [$_->{text}, @{ $_->{obj} || [] }], $_->{indent})
1486 for @s;
1487
1488 $viewer->set_offset (0);
1489}
1490
1412sub help_window { 1491sub help_window {
1413 my $win = new CFClient::UI::FancyFrame 1492 my $win = new CFClient::UI::FancyFrame
1414 x => 'center', 1493 x => 'center',
1415 y => 'center', 1494 y => 'center',
1416 z => 2, 1495 z => 2,
1417 name => 'doc_browser', 1496 name => 'doc_browser',
1418 force_w => int $WIDTH * 7/8, 1497 force_w => int $WIDTH * 7/8,
1419 force_h => int $HEIGHT * 7/8, 1498 force_h => int $HEIGHT * 7/8,
1420 title => "Documentation"; 1499 title => "Help Browser",
1500 has_close_button => 1;
1421 1501
1422 $win->add (my $vbox = new CFClient::UI::VBox); 1502 $win->add (my $vbox = new CFClient::UI::VBox);
1423 1503
1424 $vbox->add (my $buttons = new CFClient::UI::HBox); 1504 $vbox->add (my $buttons = new CFClient::UI::HBox);
1425 $vbox->add (my $viewer = new CFClient::UI::TextScroller 1505 $vbox->add (my $viewer = new CFClient::UI::TextScroller
1428 $buttons->add (new CFClient::UI::Label text => "Choose a document to display: "); 1508 $buttons->add (new CFClient::UI::Label text => "Choose a document to display: ");
1429 $buttons->add (my $combo = new CFClient::UI::Combobox 1509 $buttons->add (my $combo = new CFClient::UI::Combobox
1430 value => undef, 1510 value => undef,
1431 options => [ 1511 options => [
1432 [intro => "Introduction"], 1512 [intro => "Introduction"],
1433 [manual => "Manual"], 1513 [manual => "Main Manual"],
1434 [skill_help => "Skills"], 1514 [skill_help => "Skill Reference"],
1435 [command_help => "Commands"], 1515 [command_help => "Command Reference"],
1436 [dmcommand_help => "DM Commands"], 1516 [dmcommand_help => "DM Commands"],
1437 [COPYING => "License Terms"], 1517 [COPYING => "License Terms"],
1518 [test => "test (do not select)"], #d#TODO
1438 ], 1519 ],
1439 on_changed => sub { 1520 on_changed => sub {
1440 my ($self, $pod) = @_; 1521 my ($self, $pod) = @_;
1441 1522
1523 if ($pod eq "test") {#d#TODO
1524 eval {
1525 load_html_page $viewer, "http://crossfire.real-time.com/guides/walkthrough/newbie-tower.html";
1526 };
1527 warn "$@" if $@;
1528 return;
1529 }
1530
1442 my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", 1531 my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod",
1443 doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; 1532 doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] };
1444 1533
1445 $viewer->clear; 1534 $viewer->clear;
1535
1536# $viewer->add_paragraph ([1, 1, 1, 1], ["<big>Test</big>\n\n \x{fffc} \x{fffc}\n",
1537# (new CFClient::UI::Image path => "x.png", can_hover => 1, can_events => 1),
1538# (new CFClient::UI::Label text => "üüüü", can_hover => 1, can_events => 1, tooltip => "??"),
1539# ]);#d#
1446 1540
1447 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) 1541 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0])
1448 for @$pom; 1542 for @$pom;
1449 1543
1450 $viewer->set_offset (0); 1544 $viewer->set_offset (0);
1545
1451 0 1546 0
1452 }, 1547 },
1453 on_visibility_change => sub { 1548 on_visibility_change => sub {
1454 my ($self, $visible) = @_; 1549 my ($self, $visible) = @_;
1455 return unless $visible; 1550 return unless $visible;
1502 z => 100, 1597 z => 100,
1503 force_x => "max", 1598 force_x => "max",
1504 force_y => 0; 1599 force_y => 0;
1505 $DEBUG_STATUS->show; 1600 $DEBUG_STATUS->show;
1506 1601
1507 $BIND_EDITOR = new CFClient::UI::BindEditor (x => "max", y => 0); 1602 $BIND_EDITOR = new CFClient::BindingEditor (x => "max", y => 0);
1508 1603
1509 $STATUSBOX = new CFClient::UI::Statusbox; 1604 $STATUSBOX = new CFClient::UI::Statusbox;
1510 $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", timeout => 864000, pri => -100, color => [1, 1, 1, 0.8]); 1605 $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", timeout => 864000, pri => -100, color => [1, 1, 1, 0.8]);
1511 1606
1512 (new CFClient::UI::Frame 1607 (new CFClient::UI::Frame
1563 force_w => $::WIDTH * 0.6, 1658 force_w => $::WIDTH * 0.6,
1564 force_h => $::HEIGHT * 0.6, 1659 force_h => $::HEIGHT * 0.6,
1565 has_close_button => 1, 1660 has_close_button => 1,
1566 ; 1661 ;
1567 1662
1663 $METASERVER = metaserver_dialog;
1664
1568 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFClient::UI::Notebook expand => 1, debug => 1, 1665 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFClient::UI::Notebook expand => 1, debug => 1,
1569 filter => new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1); 1666 filter => new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1);
1570 1667
1571 $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, 1668 $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup,
1572 "Configure the server to play on, your username, password and other server-related options."); 1669 "Configure the server to play on, your username, password and other server-related options.");
1575 $SETUP_NOTEBOOK->add (Graphics => graphics_setup, 1672 $SETUP_NOTEBOOK->add (Graphics => graphics_setup,
1576 "Configure the video mode, performance, fonts and other graphical aspects of the game."); 1673 "Configure the video mode, performance, fonts and other graphical aspects of the game.");
1577 $SETUP_NOTEBOOK->add (Audio => audio_setup, 1674 $SETUP_NOTEBOOK->add (Audio => audio_setup,
1578 "Configure the use of audio, sound effects and background music."); 1675 "Configure the use of audio, sound effects and background music.");
1579 $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup, 1676 $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup,
1580 "Lets you define, edit and delete bindings." 1677 "Lets you define, edit and delete key bindings."
1581 . "There is a shortcut for making bindings: <b>Left Control + Insert</b> opens the binding editor " 1678 . "There is a shortcut for making bindings: <b>Control-Insert</b> opens the binding editor "
1582 . "with nothing set and the recording started. After doing the actions you " 1679 . "with nothing set and the recording started. After doing the actions you "
1583 . "want to record press <b>Insert</b> and you will be asked to press a key-combo. " 1680 . "want to record press <b>Insert</b> and you will be asked to press a key-combo. "
1584 . "After pressing the combo the binding will be saved automatically and the " 1681 . "After pressing the combo the binding will be saved automatically and the "
1585 . "binding editor closes"); 1682 . "binding editor closes");
1586 $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup,
1587 "Displays all spells you have and lets you edit keyboard shortcuts for them.");
1588 $SETUP_NOTEBOOK->add (Debug => debug_setup, 1683 $SETUP_NOTEBOOK->add (Debug => debug_setup,
1589 "Some debuggign options. Do not ask."); 1684 "Some debuggin' options. Do not ask.");
1590 1685
1591 $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top 1686 $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top
1592 1687
1593 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, 1688 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG,
1594 tooltip => "Toggles a dialog where you can configure all aspects of this client."); 1689 tooltip => "Toggles a dialog where you can configure all aspects of this client.");
1596 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW = message_window, 1691 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW = message_window,
1597 tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); 1692 tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server.");
1598 1693
1599 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 1694 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
1600 1695
1601 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => $STATS_WINDOW = stats_window,
1602 tooltip => "Toggles the statistics window, where all your Stats and Resistances are being displayed at all times.");
1603 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => inventory_window, 1696 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Playerbook", other => player_window,
1604 tooltip => "Toggles the inventory window, where you can manage your loot (or treasures :). " 1697 tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats.");
1605 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory.");
1606 1698
1607 $BUTTONBAR->add (new CFClient::UI::Button 1699 $BUTTONBAR->add (new CFClient::UI::Button
1608 text => "Save Config", 1700 text => "Save Config",
1609 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", 1701 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.",
1610 on_activate => sub { 1702 on_activate => sub {
1613 status "Configuration Saved"; 1705 status "Configuration Saved";
1614 0 1706 0
1615 }, 1707 },
1616 ); 1708 );
1617 1709
1618 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => help_window, 1710 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window,
1619 tooltip => "View Documentation"); 1711 tooltip => "View Documentation");
1620 1712
1621 $BUTTONBAR->add (new CFClient::UI::Button 1713 $BUTTONBAR->add (new CFClient::UI::Button
1622 text => "Quit", 1714 text => "Quit",
1623 tooltip => "Terminates the program", 1715 tooltip => "Terminates the program",
1829# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# 1921# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
1830 }, 1922 },
1831 CFClient::SDL_KEYDOWN => sub { 1923 CFClient::SDL_KEYDOWN => sub {
1832 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { 1924 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) {
1833 # alt-enter 1925 # alt-enter
1926 $FULLSCREEN_ENABLE->toggle;
1834 video_shutdown; 1927 video_shutdown;
1835 $CFG->{fullscreen} = !$CFG->{fullscreen};
1836 video_init; 1928 video_init;
1837 } else { 1929 } else {
1838 CFClient::UI::feed_sdl_key_down_event ($_[0]); 1930 CFClient::UI::feed_sdl_key_down_event ($_[0]);
1839 } 1931 }
1840 }, 1932 },
1856$SIG{INT} = $SIG{TERM} = sub { exit }; 1948$SIG{INT} = $SIG{TERM} = sub { exit };
1857 1949
1858{ 1950{
1859 local $SIG{__DIE__} = sub { 1951 local $SIG{__DIE__} = sub {
1860 return unless defined $^S && !$^S; 1952 return unless defined $^S && !$^S;
1861 Carp::confess $_[1];#d#TODO: remove when stable 1953 Carp::confess $_[0];#d#TODO: remove when stable
1862 CFClient::fatal $_[0]; 1954 CFClient::fatal $_[0];
1863 }; 1955 };
1864 1956
1865 CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc"; 1957 CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc";
1866 CFClient::UI::set_layout ($::CFG->{layout}); 1958 CFClient::UI::set_layout ($::CFG->{layout});
1867 1959
1868 my %DEF_CFG = ( 1960 my %DEF_CFG = (
1869 sdl_mode => 0, 1961 sdl_mode => 0,
1870 width => 640, 1962 width => 640,
1871 height => 480, 1963 height => 480,
1872 fullscreen => 0, 1964 fullscreen => 0,
1873 fast => 0, 1965 fast => 0,
1874 map_scale => 1, 1966 map_scale => 1,
1875 fow_enable => 1, 1967 fow_enable => 1,
1876 fow_intensity => 0.45, 1968 fow_intensity => 0.45,
1877 fow_smooth => 0, 1969 fow_smooth => 0,
1878 gui_fontsize => 1, 1970 gui_fontsize => 1,
1879 log_fontsize => 0.7, 1971 log_fontsize => 0.7,
1880 gauge_fontsize=> 1, 1972 gauge_fontsize => 1,
1881 gauge_size => 0.35, 1973 gauge_size => 0.35,
1882 stat_fontsize => 0.7, 1974 stat_fontsize => 0.7,
1883 mapsize => 100, 1975 mapsize => 100,
1884 host => "crossfire.schmorp.de",
1885 say_command => 'say', 1976 say_command => 'say',
1886 audio_enable => 1, 1977 audio_enable => 1,
1887 bgm_enable => 1, 1978 bgm_enable => 1,
1888 bgm_volume => 0.25, 1979 bgm_volume => 0.25,
1889 face_prefetch => 0, 1980 face_prefetch => 0,
1890 output_sync => 1, 1981 output_sync => 1,
1891 output_count => 1, 1982 output_count => 1,
1892 pickup => 0, 1983 pickup => 0,
1984 default => "profile", # default profile
1985 );
1893 ); 1986
1894
1895 while (my ($k, $v) = each %DEF_CFG) { 1987 while (my ($k, $v) = each %DEF_CFG) {
1896 $CFG->{$k} = $v unless exists $CFG->{$k}; 1988 $CFG->{$k} = $v unless exists $CFG->{$k};
1897 } 1989 }
1990
1991 $CFG->{profile}{default}{host} ||= "crossfire.schmorp.de";
1898 1992
1899 sdl_init; 1993 sdl_init;
1900 1994
1901 @SDL_MODES = reverse 1995 @SDL_MODES = reverse
1902 grep $_->[0] >= 640 && $_->[1] >= 480, 1996 grep $_->[0] >= 640 && $_->[1] >= 480,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines