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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines