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.94 by root, Sun Jul 16 20:04:08 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 $SPELL_PAGE;
106
107our $HELP_WINDOW;
98our $MESSAGE_WINDOW; 108our $MESSAGE_WINDOW;
99our $FLOORBOX; 109our $FLOORBOX;
100our $GAUGES; 110our $GAUGES;
101our $STATWIDS; 111our $STATWIDS;
102 112
109 119
110our $ALT_ENTER_MESSAGE; 120our $ALT_ENTER_MESSAGE;
111our $STATUSBOX; 121our $STATUSBOX;
112our $DEBUG_STATUS; 122our $DEBUG_STATUS;
113 123
114our $INV_WINDOW;
115our $INV; 124our $INV;
116our $INVR; 125our $INVR;
117our $INV_RIGHT_HB; 126our $INV_RIGHT_HB;
118 127
119our $BIND_EDITOR; 128our $BIND_EDITOR;
129our $BIND_UPD_CB;
120 130
121our $PICKUP_CFG; 131our $PICKUP_CFG;
122 132
123sub status { 133sub status {
124 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); 134 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
219 $conn->send ("reply $stat"); 229 $conn->send ("reply $stat");
220 destroy_query_dialog $conn; 230 destroy_query_dialog $conn;
221 return; 231 return;
222 } 232 }
223 233
224 $STATS_WINDOW->show; 234 $STATS_PAGE->show;
225 $MESSAGE_WINDOW->hide; 235 $MESSAGE_WINDOW->hide;
226 236
227 unshift @dialog, new CFClient::UI::Label 237 unshift @dialog, new CFClient::UI::Label
228 max_w => $::WIDTH * 0.4, 238 max_w => $::WIDTH * 0.4,
229 ellipsise => 0, 239 ellipsise => 0,
269 # right: accept 279 # right: accept
270 $table->add (4, 0, new CFClient::UI::Button 280 $table->add (4, 0, new CFClient::UI::Button
271 text => "Accept", 281 text => "Accept",
272 on_activate => sub { 282 on_activate => sub {
273 $conn->send ("reply n"); 283 $conn->send ("reply n");
274 $STATS_WINDOW->hide; 284 $STATS_PAGE->hide;
275 destroy_query_dialog $conn; 285 destroy_query_dialog $conn;
276 0 286 0
277 }, 287 },
278 ); 288 );
279 289
324 $LOGIN_BUTTON->set_text ("Logout"); 334 $LOGIN_BUTTON->set_text ("Logout");
325 $SETUP_DIALOG->hide; 335 $SETUP_DIALOG->hide;
326 336
327 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 337 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
328 338
329 my ($host, $port) = split /:/, $CFG->{host}; 339 my ($host, $port) = split /:/, $CFG->{profile}{default}{host};
330 340
331 $MAP = new CFClient::Map $mapsize, $mapsize; 341 $MAP = new CFClient::Map $mapsize, $mapsize;
332 342
333 $CONN = eval { 343 $CONN = eval {
334 new CFClient::Protocol 344 new CFClient::Protocol
335 host => $host, 345 host => $host,
336 port => $port || 13327, 346 port => $port || 13327,
337 user => $CFG->{user}, 347 user => $CFG->{profile}{default}{user},
338 pass => $CFG->{password}, 348 pass => $CFG->{profile}{default}{password},
339 mapw => $mapsize, 349 mapw => $mapsize,
340 maph => $mapsize, 350 maph => $mapsize,
341 351
342 map_widget => $MAPWIDGET, 352 map_widget => $MAPWIDGET,
343 logview => $LOGVIEW, 353 logview => $LOGVIEW,
371 381
372sub stop_game { 382sub stop_game {
373 $LOGIN_BUTTON->set_text ("Login"); 383 $LOGIN_BUTTON->set_text ("Login");
374 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); 384 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER);
375 $SETUP_DIALOG->show; 385 $SETUP_DIALOG->show;
376 $INV_WINDOW->hide; 386 $PL_WINDOW->hide;
377 $SETUP_SPELLS->clear_spells; 387 $SPELL_PAGE->clear_spells;
378 388
379 return unless $CONN; 389 return unless $CONN;
380 390
381 status "connection closed"; 391 status "connection closed";
382 392
383 destroy_query_dialog $CONN; 393 destroy_query_dialog $CONN;
384 $CONN->destroy; 394 $CONN->destroy;
385 $CONN = 0; # false, does not autovivify 395 $CONN = 0; # false, does not autovivify
396
397 undef $MAP;
386} 398}
387 399
388sub graphics_setup { 400sub graphics_setup {
389 my $vbox = new CFClient::UI::VBox; 401 my $vbox = new CFClient::UI::VBox;
390 402
405 $mode_slider->emit (changed => $mode_slider->{range}[0]); 417 $mode_slider->emit (changed => $mode_slider->{range}[0]);
406 418
407 my $row = 1; 419 my $row = 1;
408 420
409 $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");
410 $table->add (1, $row++, new CFClient::UI::CheckBox 422 $table->add (1, $row++, $FULLSCREEN_ENABLE = new CFClient::UI::CheckBox
411 state => $CFG->{fullscreen}, 423 state => $CFG->{fullscreen},
412 tooltip => "Bring the client into fullscreen mode.", 424 tooltip => "Bring the client into fullscreen mode.",
413 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } 425 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 }
414 ); 426 );
415 427
465 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], 477 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.", 478 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 }, 479 on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 },
468 ); 480 );
469 481
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"); 482 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize");
483 $table->add (1, $row++, new CFClient::UI::Slider 483 $table->add (1, $row++, new CFClient::UI::Slider
484 range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], 484 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.", 485 tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.",
486 on_changed => sub { 486 on_changed => sub {
555 ); 555 );
556 556
557 $vbox 557 $vbox
558} 558}
559 559
560sub set_stats_window_fontsize {
561 for (values %{$STATWIDS}) {
562 $_->set_fontsize ($::CFG->{stat_fontsize});
563 }
564}
565
566sub set_gauge_window_fontsize { 560sub set_gauge_window_fontsize {
567 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) { 561 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) {
568 $_->set_fontsize ($::CFG->{gauge_fontsize}); 562 $_->set_fontsize ($::CFG->{gauge_fontsize});
569 } 563 }
570} 564}
649 643
650 $table 644 $table
651} 645}
652 646
653sub stats_window { 647sub stats_window {
654 my $tgw = new CFClient::UI::FancyFrame 648 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 649
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, 650 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1,
663 can_hover => 1, can_events => 1, 651 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."); 652 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, 653 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1,
666 can_hover => 1, can_events => 1, 654 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."], 678 [0, 6, st_cha => "Cha", 30, "<b>Charisma</b>, how well you are received by NPCs. Affects buying and selling prices in shops."],
691 679
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."], 680 [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."], 681 [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."], 682 [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."], 683 [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."], 684 [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."], 685 [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 ) { 686 ) {
699 my ($col, $row, $id, $label, $template, $tooltip) = @$_; 687 my ($col, $row, $id, $label, $template, $tooltip) = @$_;
700 688
702 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);
703 $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
704 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);
705 } 693 }
706 694
707 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); 695 $vb->add (my $tbl2 = new CFClient::UI::Table expand => 1);
708 696
709 my $row = 0; 697 my $row = 0;
710 my $col = 0; 698 my $col = 0;
711 699
712 my %resist_names = ( 700 my %resist_names = (
701 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.)", 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",
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.)", 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",
715 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",
716 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",
717 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",
718 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",
719 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",
720 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",
721 pois => "<b>Poison</b> (resistance to getting poisoned)", 718 "<b>Poison</b> (resistance to getting poisoned)"],
719 para => ["Paralysation",
722 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",
723 deat => "<b>Death</b> (resistance against death spells)", 722 "<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)", 723 phys => ["Physical",
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",
725 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",
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)", 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",
727 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",
728 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",
729 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",
730 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)"],
731 ); 737 );
732 for (qw/slow holyw conf fire depl magic 738 for (qw/slow holyw conf fire depl magic
733 drain acid pois para deat phys 739 drain acid pois para deat phys
734 blind fear tund elec cold ghit/) 740 blind fear tund elec cold ghit/)
735 { 741 {
740 template => "-100%", 746 template => "-100%",
741 align => +1, 747 align => +1,
742 valign => 0, 748 valign => 0,
743 can_events => 1, 749 can_events => 1,
744 can_hover => 1, 750 can_hover => 1,
745 tooltip => $resist_names{$_}, 751 tooltip => $resist_names{$_}->[1],
746 ); 752 );
747 $tbl2->add ($col + 1, $row, new CFClient::UI::Image 753 $tbl2->add ($col + 1, $row, new CFClient::UI::Image
748 font => $FONT_FIXED, 754 font => $FONT_FIXED,
749 can_hover => 1, 755 can_hover => 1,
750 can_events => 1, 756 can_events => 1,
751 image => "ui/resist/resist_$_.png", 757 path => "ui/resist/resist_$_.png",
752 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],
753 ); 766 );
754 767
755 $row++; 768 $row++;
756 if ($row % 6 == 0) { 769 if ($row % 6 == 0) {
757 $col += 2; 770 $col += 3;
758 $row = 0; 771 $row = 0;
759 } 772 }
760 } 773 }
761 774
762 &set_stats_window_fontsize;
763 update_stats_window ({}); 775 update_stats_window ({});
764 776
765 $tgw 777 $vb
778}
779
780sub skill_window {
781 my ($self) = @_;
782 $STATWIDS->{"_skill_tbl"} = new CFClient::UI::Table expand => 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}
804 $STATWIDS->{st_pow} ->set_text (sprintf "%d" , $stats->{+CS_STAT_POW}); 821 $STATWIDS->{st_pow} ->set_text (sprintf "%d" , $stats->{+CS_STAT_POW});
805 $STATWIDS->{st_cha} ->set_text (sprintf "%d" , $stats->{+CS_STAT_CHA}); 822 $STATWIDS->{st_cha} ->set_text (sprintf "%d" , $stats->{+CS_STAT_CHA});
806 $STATWIDS->{st_wc} ->set_text (sprintf "%d" , $stats->{+CS_STAT_WC}); 823 $STATWIDS->{st_wc} ->set_text (sprintf "%d" , $stats->{+CS_STAT_WC});
807 $STATWIDS->{st_ac} ->set_text (sprintf "%d" , $stats->{+CS_STAT_AC}); 824 $STATWIDS->{st_ac} ->set_text (sprintf "%d" , $stats->{+CS_STAT_AC});
808 $STATWIDS->{st_dam} ->set_text (sprintf "%d" , $stats->{+CS_STAT_DAM}); 825 $STATWIDS->{st_dam} ->set_text (sprintf "%d" , $stats->{+CS_STAT_DAM});
809 $STATWIDS->{st_arm} ->set_text (sprintf "%d" , $stats->{+CS_STAT_ARMOUR}); 826 $STATWIDS->{st_arm} ->set_text (sprintf "%d" , $stats->{+CS_STAT_RES_PHYS});
810 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED}); 827 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED});
811 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP}); 828 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP});
812 829
813 $STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{+CS_STAT_WEIGHT_LIM} / 1000); 830 $STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{+CS_STAT_WEIGHT_LIM} / 1000);
814 831
831 deat => CS_STAT_RES_DEATH, 848 deat => CS_STAT_RES_DEATH,
832 holyw => CS_STAT_RES_HOLYWORD, 849 holyw => CS_STAT_RES_HOLYWORD,
833 blind => CS_STAT_RES_BLIND, 850 blind => CS_STAT_RES_BLIND,
834 ); 851 );
835 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 }
889
836 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) 890 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}})
837 for keys %tbl; 891 for keys %tbl;
838} 892}
839 893
840my $METASERVER_ATIME; 894my $METASERVER_ATIME;
841 895
842sub update_metaserver { 896sub update_metaserver {
897 my ($metaserver_dialog) = @_;
898
899 $METASERVER = $metaserver_dialog
900 if defined $metaserver_dialog;
901
843 return if $METASERVER_ATIME > time; 902 return if $METASERVER_ATIME > time;
844 $METASERVER_ATIME = time + 60; 903 $METASERVER_ATIME = time + 60;
845 904
846 my $table = $METASERVER->{table}; 905 my $table = $METASERVER->{table};
847 $table->clear; 906 $table->clear;
912 $table->add (scalar @$m, $y, new CFClient::UI::VBox children => [ 971 $table->add (scalar @$m, $y, new CFClient::UI::VBox children => [
913 (new CFClient::UI::Button 972 (new CFClient::UI::Button
914 text => "Use", 973 text => "Use",
915 tooltip => "Put this server into the <b>Host:Port</b> field", 974 tooltip => "Put this server into the <b>Host:Port</b> field",
916 on_activate => sub { 975 on_activate => sub {
917 $HOST_ENTRY->set_text ($CFG->{host} = $host); 976 $HOST_ENTRY->set_text ($CFG->{profile}{default}{host} = $host);
918 $METASERVER->hide; 977 $METASERVER->hide;
919 0 978 0
920 }, 979 },
921 ), 980 ),
922 (new CFClient::UI::Empty expand => 1), 981 (new CFClient::UI::Empty expand => 1),
935 } 994 }
936 }); 995 });
937} 996}
938 997
939sub metaserver_dialog { 998sub metaserver_dialog {
999 my $vbox = new CFClient::UI::VBox;
1000 my $table = new CFClient::UI::Table;
1001 $vbox->add (new CFClient::UI::ScrolledWindow expand => 1, child => $table);
1002
940 my $dialog = new CFClient::UI::FancyFrame 1003 my $dialog = new CFClient::UI::FancyFrame
941 title => "Server List", 1004 title => "Server List",
942 name => 'metaserver_dialog', 1005 name => 'metaserver_dialog',
943 x => 'center', 1006 x => 'center',
944 y => 'center', 1007 y => 'center',
945 z => 3, 1008 z => 3,
946 force_h => $::HEIGHT * 0.4, 1009 force_h => $::HEIGHT * 0.4,
947 child => (my $vbox = new CFClient::UI::VBox), 1010 child => $vbox,
1011 has_close_button => 1,
1012 table => $table,
948 on_visibility_change => sub { 1013 on_visibility_change => sub {
949 update_metaserver if $_[1]; 1014 update_metaserver ($_[0]) if $_[1];
950 0 1015 0
951 }, 1016 },
952 ; 1017 ;
953 1018
954 $dialog->{table} = new CFClient::UI::Table;
955
956 $vbox->add (new CFClient::UI::ScrolledWindow expand => 1, child => $dialog->{table});
957
958 $dialog 1019 $dialog
959} 1020}
960 1021
961sub server_setup { 1022sub server_setup {
962 my $vbox = new CFClient::UI::VBox; 1023 my $vbox = new CFClient::UI::VBox;
968 $table->add (1, 2, my $vbox = new CFClient::UI::VBox); 1029 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
969 1030
970 $vbox->add ( 1031 $vbox->add (
971 $HOST_ENTRY = new CFClient::UI::Entry 1032 $HOST_ENTRY = new CFClient::UI::Entry
972 expand => 1, 1033 expand => 1,
973 text => $CFG->{host}, 1034 text => $CFG->{profile}{default}{host},
974 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to", 1035 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to",
975 on_changed => sub { 1036 on_changed => sub {
976 my ($self, $value) = @_; 1037 my ($self, $value) = @_;
977 $CFG->{host} = $value; 1038 $CFG->{profile}{default}{host} = $value;
978 0 1039 0
979 } 1040 }
980 ); 1041 );
981
982 $METASERVER = metaserver_dialog;
983 1042
984 $vbox->add (new CFClient::UI::Button 1043 $vbox->add (new CFClient::UI::Button
985 expand => 1, 1044 expand => 1,
986 text => "Server List", 1045 text => "Server List",
987 other => $METASERVER, 1046 other => $METASERVER,
991 ); 1050 );
992 } 1051 }
993 1052
994 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); 1053 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
995 $table->add (1, 4, new CFClient::UI::Entry 1054 $table->add (1, 4, new CFClient::UI::Entry
996 text => $CFG->{user}, 1055 text => $CFG->{profile}{default}{user},
997 tooltip => "The name of your character on the server", 1056 tooltip => "The name of your character on the server",
998 on_changed => sub { my ($self, $value) = @_; $CFG->{user} = $value; 0 } 1057 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value }
999 ); 1058 );
1000 1059
1001 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password"); 1060 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password");
1002 $table->add (1, 5, new CFClient::UI::Entry 1061 $table->add (1, 5, new CFClient::UI::Entry
1003 text => $CFG->{password}, 1062 text => $CFG->{profile}{default}{password},
1004 hidden => 1, 1063 hidden => 1,
1005 tooltip => "The password for your character", 1064 tooltip => "The password for your character",
1006 on_changed => sub { my ($self, $value) = @_; $CFG->{password} = $value; 0 } 1065 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value }
1007 ); 1066 );
1008 1067
1009 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); 1068 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
1010 $table->add (1, 7, new CFClient::UI::Slider 1069 $table->add (1, 7, new CFClient::UI::Slider
1011 force_w => 100, 1070 force_w => 100,
1083sub message_window { 1142sub message_window {
1084 my $window = new CFClient::UI::FancyFrame 1143 my $window = new CFClient::UI::FancyFrame
1085 name => "message_window", 1144 name => "message_window",
1086 title => "Messages", 1145 title => "Messages",
1087 border_bg => [1, 1, 1, 1], 1146 border_bg => [1, 1, 1, 1],
1088 bg => [0, 0, 0, 0.75],
1089 x => "max", 1147 x => "max",
1090 y => 0, 1148 y => 0,
1091 force_w => $::WIDTH * 0.4, 1149 force_w => $::WIDTH * 0.4,
1092 force_h => $::HEIGHT * 0.5, 1150 force_h => $::HEIGHT * 0.5,
1093 child => (my $vbox = new CFClient::UI::VBox), 1151 child => (my $vbox = new CFClient::UI::VBox),
1179sub autopickup_setup { 1237sub autopickup_setup {
1180 my $table = new CFClient::UI::Table; 1238 my $table = new CFClient::UI::Table;
1181 1239
1182 for ( 1240 for (
1183 ["General", 0, 0, 1241 ["General", 0, 0,
1184 ["Enable autopickup" => PICKUP_NEWMODE], 1242 ["Enable autopickup" => PICKUP_NEWMODE, \$PICKUP_ENABLE],
1185 ["Inhibit autopickup" => PICKUP_INHIBIT], 1243 ["Inhibit autopickup" => PICKUP_INHIBIT],
1186 ["Stop before pickup" => PICKUP_STOP], 1244 ["Stop before pickup" => PICKUP_STOP],
1187 ["Debug autopickup" => PICKUP_DEBUG], 1245 ["Debug autopickup" => PICKUP_DEBUG],
1188 ], 1246 ],
1189 ["Weapons", 0, 6, 1247 ["Weapons", 0, 6,
1226 for (@bits) { 1284 for (@bits) {
1227 ++$y; 1285 ++$y;
1228 1286
1229 my $mask = $_->[1]; 1287 my $mask = $_->[1];
1230 $table->add ($x , $y, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1); 1288 $table->add ($x , $y, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1);
1231 $table->add ($x+1, $y, new CFClient::UI::CheckBox 1289 $table->add ($x+1, $y, my $checkbox = new CFClient::UI::CheckBox
1232 state => $CFG->{pickup} & $mask, 1290 state => $::CFG->{pickup} & $mask,
1233 on_changed => sub { 1291 on_changed => sub {
1234 my ($box, $value) = @_; 1292 my ($box, $value) = @_;
1235 1293
1236 if ($value) { 1294 if ($value) {
1237 $::CFG->{pickup} |= $mask; 1295 $::CFG->{pickup} |= $mask;
1242 $::CONN->send_command ("pickup $::CFG->{pickup}") 1300 $::CONN->send_command ("pickup $::CFG->{pickup}")
1243 if defined $::CONN; 1301 if defined $::CONN;
1244 1302
1245 0 1303 0
1246 }); 1304 });
1305
1306 ${$_->[2]} = $checkbox if $_->[2];
1247 } 1307 }
1248 } 1308 }
1249 1309
1250 $table->add (2, 18, new CFClient::UI::ValSlider 1310 $table->add (2, 18, new CFClient::UI::ValSlider
1251 range => [0, 0, 16, 1, 1], 1311 range => [$::CFG->{pickup} & 0xF, 0, 16, 1, 1],
1312 template => ">= 99",
1252 to_value => sub { ">= " . 5 * $_[0] }, 1313 to_value => sub { ">= " . 5 * $_[0] },
1253 on_changed => sub { 1314 on_changed => sub {
1254 my ($slider, $value) = @_; 1315 my ($slider, $value) = @_;
1255 1316
1256 $::CFG->{pickup} &= ~0x7; 1317 $::CFG->{pickup} &= ~0xF;
1257 $::CFG->{pickup} |= int $value 1318 $::CFG->{pickup} |= int $value
1258 if $value; 1319 if $value;
1259 1; 1320 1;
1260 }); 1321 });
1322
1261 $table->add (3, 18, new CFClient::UI::Button 1323 $table->add (3, 18, new CFClient::UI::Button
1262 text => "set", 1324 text => "set",
1263 on_activate => sub { 1325 on_activate => sub {
1264 $::CONN->send_command ("pickup $::CFG->{pickup}") 1326 $::CONN->send_command ("pickup $::CFG->{pickup}")
1265 if defined $::CONN; 1327 if defined $::CONN;
1267 }); 1329 });
1268 1330
1269 $table 1331 $table
1270} 1332}
1271 1333
1272sub inventory_window { 1334sub inventory_widget {
1335 my $hb = new CFClient::UI::HBox homogeneous => 1;
1336
1337 $hb->add (my $vb1 = new CFClient::UI::VBox);
1338 $vb1->add (new CFClient::UI::Label align => 0, text => "Player");
1339 $vb1->add ($INV = new CFClient::UI::Inventory);
1340
1341 $hb->add (my $vb2 = new CFClient::UI::VBox);
1342
1343 $vb2->add ($INV_RIGHT_HB = new CFClient::UI::HBox);
1344
1345 $vb2->add ($INVR = new CFClient::UI::Inventory);
1346
1347 # XXX: Call after $INVR = ... because set_opencont sets the items
1348 CFClient::Protocol::set_opencont ($::CONN, 0, "Floor");
1349
1350 $hb
1351}
1352
1353sub toggle_player_page {
1354 my ($widget) = @_;
1355
1356 if ($PL_WINDOW->{visible} && $PL_NOTEBOOK->get_current_page == $widget) {
1357 $PL_WINDOW->hide;
1358 } else {
1359 $PL_NOTEBOOK->set_current_page ($widget);
1360 $PL_WINDOW->show;
1361 }
1362}
1363
1364sub player_window {
1273 my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame 1365 my $plwin = $PL_WINDOW = new CFClient::UI::FancyFrame
1274 x => "center", 1366 x => "center",
1275 y => "center", 1367 y => "center",
1276 force_w => $WIDTH * 9/10, 1368 force_w => $WIDTH * 9/10,
1277 force_h => $HEIGHT * 9/10, 1369 force_h => $HEIGHT * 9/10,
1278 title => "Inventory", 1370 title => "Player",
1371 name => "playerbook",
1279 has_close_button => 1, 1372 has_close_button => 1
1280 ; 1373 ;
1281 1374
1282 $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1); 1375 my $ntb =
1376 $PL_NOTEBOOK =
1377 new CFClient::UI::Notebook
1378 expand => 1,
1379 debug => 1,
1380 filter => (new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1),
1381 ;
1283 1382
1284 $hb->add (my $vb1 = new CFClient::UI::VBox); 1383 $ntb->add (
1285 $vb1->add (new CFClient::UI::Label align => 0, text => "Player"); 1384 "Stats" => $STATS_PAGE = stats_window,
1286 $vb1->add ($INV = new CFClient::UI::Inventory expand => 1); 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."
1390 );
1391 $ntb->add (
1392 Spellbook => $SPELL_PAGE = new CFClient::UI::SpellList,
1393 "Displays all spells you have and lets you edit keyboard shortcuts for them."
1394 );
1395 $ntb->add (
1396 Inventory => $INVENTORY_PAGE = inventory_widget,
1397 "Toggles the inventory window, where you can manage your loot (or treasures :). "
1398 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory."
1399 );
1287 1400
1288 $hb->add (my $vb2 = new CFClient::UI::VBox); 1401 $ntb->set_current_page ($INVENTORY_PAGE);
1289 1402
1290 $vb2->add ($INV_RIGHT_HB = new CFClient::UI::HBox); 1403 $plwin->add ($ntb);
1291 1404 $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} 1405}
1299 1406
1300sub spell_setup { 1407sub update_bindings {
1301 new CFClient::UI::SpellList 1408 $BIND_UPD_CB->() if $BIND_UPD_CB;
1302} 1409}
1303 1410
1304sub keyboard_setup { 1411sub keyboard_setup {
1305 my $binding_list = new CFClient::UI::VBox; 1412 my $binding_list = new CFClient::UI::VBox;
1306 1413
1307 my $refresh; 1414 my $refresh;
1308 $refresh = sub { 1415 $refresh = $BIND_UPD_CB = sub {
1309 $binding_list->clear (); 1416 $binding_list->clear ();
1310 1417
1311 for my $mod (keys %{$::CFG->{bindings}}) { 1418 for my $mod (keys %{$::CFG->{profile}{default}{bindings}}) {
1312 for my $sym (keys %{$::CFG->{bindings}->{$mod}}) { 1419 for my $sym (keys %{$::CFG->{profile}{default}{bindings}{$mod}}) {
1313 my $cmds = $::CFG->{bindings}->{$mod}->{$sym}; 1420 my $cmds = $::CFG->{profile}{default}{bindings}{$mod}{$sym};
1314 next unless ref $cmds eq 'ARRAY' and @$cmds > 0; 1421 next unless ref $cmds eq 'ARRAY' and @$cmds > 0;
1315 1422
1316 my $lbl = join "; ", @$cmds; 1423 my $lbl = join "; ", @$cmds;
1317 my $nam = CFClient::Binder::keycombo_to_name ($mod, $sym); 1424 my $nam = CFClient::BindingEditor::keycombo_to_name ($mod, $sym);
1318 $binding_list->add (my $hb = new CFClient::UI::HBox); 1425 $binding_list->add (my $hb = new CFClient::UI::HBox);
1319 $hb->add (new CFClient::UI::Button 1426 $hb->add (new CFClient::UI::Button
1320 text => "delete", 1427 text => "delete",
1321 tooltip => "Deletes the binding", 1428 tooltip => "Deletes the binding",
1322 on_activate => sub { 1429 on_activate => sub {
1323 $binding_list->remove ($hb); 1430 $binding_list->remove ($hb);
1324 delete $::CFG->{bindings}->{$mod}->{$sym}; 1431 delete $::CFG->{profile}{default}{bindings}{$mod}{$sym};
1325 0 1432 0
1326 }); 1433 });
1327 1434
1328 $hb->add (new CFClient::UI::Button 1435 $hb->add (new CFClient::UI::Button
1329 text => "edit", 1436 text => "edit",
1330 tooltip => "Edits the binding", 1437 tooltip => "Edits the binding",
1331 on_activate => sub { 1438 on_activate => sub {
1332 $::BIND_EDITOR->set_binding ( 1439 $::BIND_EDITOR->set_binding (
1333 $mod, $sym, $::CFG->{bindings}->{$mod}->{$sym}, 1440 $mod, $sym, $::CFG->{profile}{default}{bindings}{$mod}{$sym},
1334 sub { 1441 sub {
1335 my ($nmod, $nsym, $ncmds) = @_; 1442 my ($nmod, $nsym, $ncmds) = @_;
1336 delete $::CFG->{bindings}->{$mod}->{$sym}; 1443 $::BIND_EDITOR->cfg_unbind ($mod, $sym);
1337 $::CFG->{bindings}->{$nmod}->{$nsym} = $ncmds; 1444 $::BIND_EDITOR->cfg_bind ($nmod, $nsym, $ncmds);
1338 $refresh->(); 1445 $refresh->();
1339 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); 1446 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD);
1340 $SETUP_DIALOG->show; 1447 $SETUP_DIALOG->show;
1341 }, 1448 },
1342 sub { 1449 sub {
1376 tooltip => "This button opens the binding editor with an empty binding.", 1483 tooltip => "This button opens the binding editor with an empty binding.",
1377 on_activate => sub { 1484 on_activate => sub {
1378 $::BIND_EDITOR->set_binding (undef, undef, [], 1485 $::BIND_EDITOR->set_binding (undef, undef, [],
1379 sub { 1486 sub {
1380 my ($mod, $sym, $cmds) = @_; 1487 my ($mod, $sym, $cmds) = @_;
1381 $::CFG->{bindings}->{$mod}->{$sym} = $cmds; 1488 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds);
1382 $refresh->(); 1489 $refresh->();
1383 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); 1490 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD);
1384 $SETUP_DIALOG->show; 1491 $SETUP_DIALOG->show;
1385 }, 1492 },
1386 sub { 1493 sub {
1415 y => 'center', 1522 y => 'center',
1416 z => 2, 1523 z => 2,
1417 name => 'doc_browser', 1524 name => 'doc_browser',
1418 force_w => int $WIDTH * 7/8, 1525 force_w => int $WIDTH * 7/8,
1419 force_h => int $HEIGHT * 7/8, 1526 force_h => int $HEIGHT * 7/8,
1420 title => "Documentation"; 1527 title => "Help Browser",
1528 has_close_button => 1;
1421 1529
1422 $win->add (my $vbox = new CFClient::UI::VBox); 1530 $win->add (my $vbox = new CFClient::UI::VBox);
1423 1531
1424 $vbox->add (my $buttons = new CFClient::UI::HBox); 1532 $vbox->add (my $buttons = new CFClient::UI::HBox);
1425 $vbox->add (my $viewer = new CFClient::UI::TextScroller 1533 $vbox->add (my $viewer = new CFClient::UI::TextScroller
1428 $buttons->add (new CFClient::UI::Label text => "Choose a document to display: "); 1536 $buttons->add (new CFClient::UI::Label text => "Choose a document to display: ");
1429 $buttons->add (my $combo = new CFClient::UI::Combobox 1537 $buttons->add (my $combo = new CFClient::UI::Combobox
1430 value => undef, 1538 value => undef,
1431 options => [ 1539 options => [
1432 [intro => "Introduction"], 1540 [intro => "Introduction"],
1433 [manual => "Manual"], 1541 [manual => "Main Manual"],
1434 [skill_help => "Skills"], 1542 [skill_help => "Skill Reference"],
1435 [command_help => "Commands"], 1543 [command_help => "Command Reference"],
1436 [dmcommand_help => "DM Commands"], 1544 [dmcommand_help => "DM Commands"],
1437 [COPYING => "License Terms"], 1545 [COPYING => "License Terms"],
1438 ], 1546 ],
1439 on_changed => sub { 1547 on_changed => sub {
1440 my ($self, $pod) = @_; 1548 my ($self, $pod) = @_;
1441 1549
1442 my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", 1550 my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod",
1443 doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; 1551 doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] };
1444 1552
1445 $viewer->clear; 1553 $viewer->clear;
1554
1555# $viewer->add_paragraph ([1, 1, 1, 1], ["<big>Test</big>\n\n \x{fffc} \x{fffc}\n",
1556# (new CFClient::UI::Image path => "x.png", can_hover => 1, can_events => 1),
1557# (new CFClient::UI::Label text => "üüüü", can_hover => 1, can_events => 1, tooltip => "??"),
1558# ]);#d#
1446 1559
1447 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) 1560 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0])
1448 for @$pom; 1561 for @$pom;
1449 1562
1450 $viewer->set_offset (0); 1563 $viewer->set_offset (0);
1564
1451 0 1565 0
1452 }, 1566 },
1453 on_visibility_change => sub { 1567 on_visibility_change => sub {
1454 my ($self, $visible) = @_; 1568 my ($self, $visible) = @_;
1455 return unless $visible; 1569 return unless $visible;
1502 z => 100, 1616 z => 100,
1503 force_x => "max", 1617 force_x => "max",
1504 force_y => 0; 1618 force_y => 0;
1505 $DEBUG_STATUS->show; 1619 $DEBUG_STATUS->show;
1506 1620
1507 $BIND_EDITOR = new CFClient::UI::BindEditor (x => "max", y => 0); 1621 $BIND_EDITOR = new CFClient::BindingEditor (x => "max", y => 0);
1508 1622
1509 $STATUSBOX = new CFClient::UI::Statusbox; 1623 $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]); 1624 $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", timeout => 864000, pri => -100, color => [1, 1, 1, 0.8]);
1511 1625
1512 (new CFClient::UI::Frame 1626 (new CFClient::UI::Frame
1563 force_w => $::WIDTH * 0.6, 1677 force_w => $::WIDTH * 0.6,
1564 force_h => $::HEIGHT * 0.6, 1678 force_h => $::HEIGHT * 0.6,
1565 has_close_button => 1, 1679 has_close_button => 1,
1566 ; 1680 ;
1567 1681
1682 $METASERVER = metaserver_dialog;
1683
1568 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFClient::UI::Notebook expand => 1, debug => 1, 1684 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFClient::UI::Notebook expand => 1, debug => 1,
1569 filter => new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1); 1685 filter => new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1);
1570 1686
1571 $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, 1687 $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup,
1572 "Configure the server to play on, your username, password and other server-related options."); 1688 "Configure the server to play on, your username, password and other server-related options.");
1575 $SETUP_NOTEBOOK->add (Graphics => graphics_setup, 1691 $SETUP_NOTEBOOK->add (Graphics => graphics_setup,
1576 "Configure the video mode, performance, fonts and other graphical aspects of the game."); 1692 "Configure the video mode, performance, fonts and other graphical aspects of the game.");
1577 $SETUP_NOTEBOOK->add (Audio => audio_setup, 1693 $SETUP_NOTEBOOK->add (Audio => audio_setup,
1578 "Configure the use of audio, sound effects and background music."); 1694 "Configure the use of audio, sound effects and background music.");
1579 $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup, 1695 $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup,
1580 "Lets you define, edit and delete bindings." 1696 "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 " 1697 . "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 " 1698 . "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. " 1699 . "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 " 1700 . "After pressing the combo the binding will be saved automatically and the "
1585 . "binding editor closes"); 1701 . "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, 1702 $SETUP_NOTEBOOK->add (Debug => debug_setup,
1589 "Some debuggign options. Do not ask."); 1703 "Some debuggin' options. Do not ask.");
1590 1704
1591 $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top 1705 $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top
1592 1706
1593 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, 1707 $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."); 1708 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, 1710 $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."); 1711 tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server.");
1598 1712
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 1713 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 1714
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, 1715 $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 :). " 1716 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 1717
1607 $BUTTONBAR->add (new CFClient::UI::Button 1718 $BUTTONBAR->add (new CFClient::UI::Button
1608 text => "Save Config", 1719 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.", 1720 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 { 1721 on_activate => sub {
1613 status "Configuration Saved"; 1724 status "Configuration Saved";
1614 0 1725 0
1615 }, 1726 },
1616 ); 1727 );
1617 1728
1618 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => help_window, 1729 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window,
1619 tooltip => "View Documentation"); 1730 tooltip => "View Documentation");
1620 1731
1621 $BUTTONBAR->add (new CFClient::UI::Button 1732 $BUTTONBAR->add (new CFClient::UI::Button
1622 text => "Quit", 1733 text => "Quit",
1623 tooltip => "Terminates the program", 1734 tooltip => "Terminates the program",
1829# 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#
1830 }, 1941 },
1831 CFClient::SDL_KEYDOWN => sub { 1942 CFClient::SDL_KEYDOWN => sub {
1832 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { 1943 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) {
1833 # alt-enter 1944 # alt-enter
1945 $FULLSCREEN_ENABLE->toggle;
1834 video_shutdown; 1946 video_shutdown;
1835 $CFG->{fullscreen} = !$CFG->{fullscreen};
1836 video_init; 1947 video_init;
1837 } else { 1948 } else {
1838 CFClient::UI::feed_sdl_key_down_event ($_[0]); 1949 CFClient::UI::feed_sdl_key_down_event ($_[0]);
1839 } 1950 }
1840 }, 1951 },
1864 1975
1865 CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc"; 1976 CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc";
1866 CFClient::UI::set_layout ($::CFG->{layout}); 1977 CFClient::UI::set_layout ($::CFG->{layout});
1867 1978
1868 my %DEF_CFG = ( 1979 my %DEF_CFG = (
1869 sdl_mode => 0, 1980 sdl_mode => 0,
1870 width => 640, 1981 width => 640,
1871 height => 480, 1982 height => 480,
1872 fullscreen => 0, 1983 fullscreen => 0,
1873 fast => 0, 1984 fast => 0,
1874 map_scale => 1, 1985 map_scale => 1,
1875 fow_enable => 1, 1986 fow_enable => 1,
1876 fow_intensity => 0.45, 1987 fow_intensity => 0.45,
1877 fow_smooth => 0, 1988 fow_smooth => 0,
1878 gui_fontsize => 1, 1989 gui_fontsize => 1,
1879 log_fontsize => 0.7, 1990 log_fontsize => 0.7,
1880 gauge_fontsize=> 1, 1991 gauge_fontsize => 1,
1881 gauge_size => 0.35, 1992 gauge_size => 0.35,
1882 stat_fontsize => 0.7, 1993 stat_fontsize => 0.7,
1883 mapsize => 100, 1994 mapsize => 100,
1884 host => "crossfire.schmorp.de",
1885 say_command => 'say', 1995 say_command => 'say',
1886 audio_enable => 1, 1996 audio_enable => 1,
1887 bgm_enable => 1, 1997 bgm_enable => 1,
1888 bgm_volume => 0.25, 1998 bgm_volume => 0.25,
1889 face_prefetch => 0, 1999 face_prefetch => 0,
1890 output_sync => 1, 2000 output_sync => 1,
1891 output_count => 1, 2001 output_count => 1,
1892 pickup => 0, 2002 pickup => 0,
2003 default => "profile", # default profile
2004 );
1893 ); 2005
1894
1895 while (my ($k, $v) = each %DEF_CFG) { 2006 while (my ($k, $v) = each %DEF_CFG) {
1896 $CFG->{$k} = $v unless exists $CFG->{$k}; 2007 $CFG->{$k} = $v unless exists $CFG->{$k};
1897 } 2008 }
2009
2010 $CFG->{profile}{default}{host} ||= "crossfire.schmorp.de";
1898 2011
1899 sdl_init; 2012 sdl_init;
1900 2013
1901 @SDL_MODES = reverse 2014 @SDL_MODES = reverse
1902 grep $_->[0] >= 640 && $_->[1] >= 480, 2015 grep $_->[0] >= 640 && $_->[1] >= 480,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines