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.11 by root, Fri May 26 18:56:14 2006 UTC vs.
Revision 1.17 by elmex, Sat May 27 20:26:22 2006 UTC

29use Time::HiRes 'time'; 29use Time::HiRes 'time';
30use Pod::POM; 30use Pod::POM;
31use Event; 31use Event;
32 32
33use Crossfire; 33use Crossfire;
34use Crossfire::Protocol::Base; 34use Crossfire::Protocol::Constants;
35 35
36use Compress::LZF; 36use Compress::LZF;
37 37
38use CFClient; 38use CFClient;
39use CFClient::OpenGL (); 39use CFClient::OpenGL ();
97 97
98our $ALT_ENTER_MESSAGE; 98our $ALT_ENTER_MESSAGE;
99our $STATUSBOX; 99our $STATUSBOX;
100our $DEBUG_STATUS; 100our $DEBUG_STATUS;
101 101
102our $INVWIN;
103our $INV; 102our $INV;
104our $INVR; 103our $INVR;
105our $INVR_LBL; 104our $INVR_LBL;
106 105
107sub status { 106sub status {
178 unless $BUTTONBAR->{children}[1]->{state}; 177 unless $BUTTONBAR->{children}[1]->{state};
179} 178}
180 179
181sub client_setup { 180sub client_setup {
182 my $dialog = new CFClient::UI::FancyFrame 181 my $dialog = new CFClient::UI::FancyFrame
182 name => "client_setup",
183 title => "Client Setup", 183 title => "Client Setup",
184 child => (my $vbox = new CFClient::UI::VBox); 184 child => (my $vbox = new CFClient::UI::VBox);
185 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 185 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
186 186
187 $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode"); 187 $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode");
255 state => $CFG->{fow_smooth}, 255 state => $CFG->{fow_smooth},
256 tooltip => "Smooth the Fog-of-War a bit to make it more realistic. Changes are instant.", 256 tooltip => "Smooth the Fog-of-War a bit to make it more realistic. Changes are instant.",
257 connect_changed => sub { 257 connect_changed => sub {
258 my ($self, $value) = @_; 258 my ($self, $value) = @_;
259 $CFG->{fow_smooth} = $value; 259 $CFG->{fow_smooth} = $value;
260 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; 260 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::OpenGL::GL_VERSION < 1.2;
261 } 261 }
262 ); 262 );
263 263
264 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); 264 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize");
265 $table->add (1, $row++, new CFClient::UI::Slider 265 $table->add (1, $row++, new CFClient::UI::Slider
432 432
433 $win 433 $win
434} 434}
435 435
436sub make_stats_window { 436sub make_stats_window {
437 my $tgw = new CFClient::UI::FancyFrame title => "Stats"; 437 my $tgw = new CFClient::UI::FancyFrame title => "Stats", name => "stats_window";
438 438
439 $tgw->add (new CFClient::UI::Window child => my $vb = new CFClient::UI::VBox); 439 $tgw->add (new CFClient::UI::Window child => my $vb = new CFClient::UI::VBox);
440 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, 440 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1,
441 can_hover => 1, can_events => 1, 441 can_hover => 1, can_events => 1,
442 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); 442 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server.");
445 tooltip => "The map you are currently on (if supported by the server)."); 445 tooltip => "The map you are currently on (if supported by the server).");
446 446
447 $vb->add (my $hb0 = new CFClient::UI::HBox); 447 $vb->add (my $hb0 = new CFClient::UI::HBox);
448 $hb0->add ($STATWIDS->{weight} = new CFClient::UI::Label valign => 0, align => -1, text => "Weight:", expand => 1, 448 $hb0->add ($STATWIDS->{weight} = new CFClient::UI::Label valign => 0, align => -1, text => "Weight:", expand => 1,
449 can_hover => 1, can_events => 1, 449 can_hover => 1, can_events => 1,
450 tooltip => "This is the amount the Player weights."); 450 tooltip => "The weight of the player including all inventory items.");
451 $hb0->add ($STATWIDS->{m_weight} = new CFClient::UI::Label valign => 0, align => -1, text => "Max weight:", expand => 1, 451 $hb0->add ($STATWIDS->{m_weight} = new CFClient::UI::Label valign => 0, align => -1, text => "Max weight:", expand => 1,
452 can_hover => 1, can_events => 1, 452 can_hover => 1, can_events => 1,
453 tooltip => "The weight limit, you can't carry more than this."); 453 tooltip => "The weight limit: you cannot carry more than this.");
454 454
455 455
456 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 456 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
457 $hb->add (my $tbl = new CFClient::UI::Table expand => 1); 457 $hb->add (my $tbl = new CFClient::UI::Table expand => 1);
458 458
548} 548}
549 549
550sub update_stats_window { 550sub update_stats_window {
551 my ($stats) = @_; 551 my ($stats) = @_;
552 552
553 # i love text protocols!!! 553 # I love text protocols...
554 my $hp = $stats->{Crossfire::Protocol::Base::CS_STAT_HP} * 1; 554
555 my $hp = $stats->{+CS_STAT_HP} * 1;
555 my $hp_m = $stats->{Crossfire::Protocol::Base::CS_STAT_MAXHP} * 1; 556 my $hp_m = $stats->{+CS_STAT_MAXHP} * 1;
556 my $sp = $stats->{Crossfire::Protocol::Base::CS_STAT_SP} * 1; 557 my $sp = $stats->{+CS_STAT_SP} * 1;
557 my $sp_m = $stats->{Crossfire::Protocol::Base::CS_STAT_MAXSP} * 1; 558 my $sp_m = $stats->{+CS_STAT_MAXSP} * 1;
558 my $fo = $stats->{Crossfire::Protocol::Base::CS_STAT_FOOD} * 1; 559 my $fo = $stats->{+CS_STAT_FOOD} * 1;
559 my $fo_m = 999; 560 my $fo_m = 999;
560 my $gr = $stats->{Crossfire::Protocol::Base::CS_STAT_GRACE} * 1; 561 my $gr = $stats->{+CS_STAT_GRACE} * 1;
561 my $gr_m = $stats->{Crossfire::Protocol::Base::CS_STAT_MAXGRACE} * 1; 562 my $gr_m = $stats->{+CS_STAT_MAXGRACE} * 1;
562 563
563 $GAUGES->{hp} ->set_value ($hp, $hp_m); 564 $GAUGES->{hp} ->set_value ($hp, $hp_m);
564 $GAUGES->{mana} ->set_value ($sp, $sp_m); 565 $GAUGES->{mana} ->set_value ($sp, $sp_m);
565 $GAUGES->{food} ->set_value ($fo, $fo_m); 566 $GAUGES->{food} ->set_value ($fo, $fo_m);
566 $GAUGES->{grace} ->set_value ($gr, $gr_m); 567 $GAUGES->{grace} ->set_value ($gr, $gr_m);
567 $GAUGES->{exp} ->set_text ("Exp: " . (formsep $stats->{Crossfire::Protocol::Base::CS_STAT_EXP64}) 568 $GAUGES->{exp} ->set_text ("Exp: " . (formsep $stats->{+CS_STAT_EXP64})
568 . " (lvl " . ($stats->{Crossfire::Protocol::Base::CS_STAT_LEVEL} * 1) . ")"); 569 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")");
569 my $rng = $stats->{Crossfire::Protocol::Base::CS_STAT_RANGE}; 570 my $rng = $stats->{+CS_STAT_RANGE};
570 $rng =~ s/^Range: //; # thank you so much dear server 571 $rng =~ s/^Range: //; # thank you so much dear server
571 $GAUGES->{range} ->set_text ("Rng: " . $rng); 572 $GAUGES->{range} ->set_text ("Rng: " . $rng);
572 my $title = $stats->{Crossfire::Protocol::Base::CS_STAT_TITLE}; 573 my $title = $stats->{+CS_STAT_TITLE};
573 $title =~ s/^Player: //; 574 $title =~ s/^Player: //;
574 $STATWIDS->{title} ->set_text ("Title: " . $title); 575 $STATWIDS->{title} ->set_text ("Title: " . $title);
575 576
576 $STATWIDS->{st_str} ->set_text (sprintf "%d", $stats->{5}); 577 $STATWIDS->{st_str} ->set_text (sprintf "%d" , $stats->{+CS_STAT_STR});
577 $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8}); 578 $STATWIDS->{st_dex} ->set_text (sprintf "%d" , $stats->{+CS_STAT_DEX});
578 $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9}); 579 $STATWIDS->{st_con} ->set_text (sprintf "%d" , $stats->{+CS_STAT_CON});
579 $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6}); 580 $STATWIDS->{st_int} ->set_text (sprintf "%d" , $stats->{+CS_STAT_INT});
580 $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7}); 581 $STATWIDS->{st_wis} ->set_text (sprintf "%d" , $stats->{+CS_STAT_WIS});
581 $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22}); 582 $STATWIDS->{st_pow} ->set_text (sprintf "%d" , $stats->{+CS_STAT_POW});
582 $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10}); 583 $STATWIDS->{st_cha} ->set_text (sprintf "%d" , $stats->{+CS_STAT_CHA});
583 $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13}); 584 $STATWIDS->{st_wc} ->set_text (sprintf "%d" , $stats->{+CS_STAT_WC});
584 $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14}); 585 $STATWIDS->{st_ac} ->set_text (sprintf "%d" , $stats->{+CS_STAT_AC});
585 $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15}); 586 $STATWIDS->{st_dam} ->set_text (sprintf "%d" , $stats->{+CS_STAT_DAM});
586 $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16}); 587 $STATWIDS->{st_arm} ->set_text (sprintf "%d" , $stats->{+CS_STAT_ARMOUR});
587 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::Base::CS_STAT_SPEED}); 588 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED});
588 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::Base::CS_STAT_WEAP_SP}); 589 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP});
589 590
590 $STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{Crossfire::Protocol::Base::CS_STAT_WEIGHT_LIM} / 1000); 591 $STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{+CS_STAT_WEIGHT_LIM} / 1000);
591 592
593 # TODO: replace by CS_STAT_RES_xxx constants
592 my %tbl = ( 594 my %tbl = (
593 phys => 100, 595 phys => 100,
594 magic => 101, 596 magic => 101,
595 fire => 102, 597 fire => 102,
596 elec => 103, 598 elec => 103,
605 tund => 112, 607 tund => 112,
606 fear => 113, 608 fear => 113,
607 depl => 113, 609 depl => 113,
608 deat => 115, 610 deat => 115,
609 holyw => 116, 611 holyw => 116,
610 blind => 117 612 blind => 117,
611 ); 613 );
612 614
613 for (keys %tbl) {
614 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}); 615 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}})
615 } 616 for keys %tbl;
616
617} 617}
618 618
619sub metaserver_dialog { 619sub metaserver_dialog {
620 my $dialog = new CFClient::UI::FancyFrame 620 my $dialog = new CFClient::UI::FancyFrame
621 title => "Server List", 621 title => "Server List",
705 }); 705 });
706} 706}
707 707
708sub server_setup { 708sub server_setup {
709 my $dialog = new CFClient::UI::FancyFrame 709 my $dialog = new CFClient::UI::FancyFrame
710 name => "server_setup",
710 title => "Server Setup", 711 title => "Server Setup",
711 child => (my $vbox = new CFClient::UI::VBox); 712 child => (my $vbox = new CFClient::UI::VBox);
712 713
713 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 714 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
714 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); 715 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port");
816 $dialog 817 $dialog
817} 818}
818 819
819sub message_window { 820sub message_window {
820 my $window = new CFClient::UI::FancyFrame 821 my $window = new CFClient::UI::FancyFrame
822 name => "message_window",
821 title => "Messages", 823 title => "Messages",
822 border_bg => [1, 1, 1, 1], 824 border_bg => [1, 1, 1, 1],
823 bg => [0, 0, 0, 0.75], 825 bg => [0, 0, 0, 0.75],
824 user_w => int $::WIDTH / 3, 826 user_w => int $::WIDTH / 3,
825 user_h => int $::HEIGHT / 5, 827 user_h => int $::HEIGHT / 5,
900 } 902 }
901} 903}
902 904
903sub make_inventory_window { 905sub make_inventory_window {
904 my $invwin = new CFClient::UI::FancyFrame 906 my $invwin = new CFClient::UI::FancyFrame
905 user_w => $WIDTH * (7/8), user_h => $HEIGHT * (7/8), title => "Inventory"; 907 user_w => $WIDTH * (7/8), user_h => $HEIGHT * (7/8), title => "Inventory", name => "inventory_window";
906 908
907 $invwin->add (my $hb = new CFClient::UI::HBox expand => 1); 909 $invwin->add (my $hb = new CFClient::UI::HBox expand => 1);
908 910
909 $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1); 911 $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1);
910 $vb1->add (my $lbl = new CFClient::UI::Label xalign => 0.5); 912 $vb1->add (my $lbl = new CFClient::UI::Label align => 0);
911 $lbl->set_text ("Player"); 913 $lbl->set_text ("Player");
912 $vb1->add ($INV = new CFClient::UI::Inventory expand => 1); 914 $vb1->add ($INV = new CFClient::UI::Inventory expand => 1);
913 915
914 $hb->add (my $vb2 = new CFClient::UI::VBox expand => 1); 916 $hb->add (my $vb2 = new CFClient::UI::VBox expand => 1);
917
918 $vb2->add (my $hb2 = new CFClient::UI::HBox);
915 $vb2->add ($INVR_LBL = new CFClient::UI::Label xalign => 0.5); 919 $hb2->add ($INVR_LBL = new CFClient::UI::Label align => 0, expand => 1);
920 $hb2->add (new CFClient::UI::Button
921 text => "Close",
922 tooltip => "Close the currently open container (if one is open)",
923 connect_activate => sub {
924 $CONN->send ("apply $CONN->{open_container}")
925 if $CONN->{open_container} != 0;
926 },
927 );
928
916 $INVR_LBL->set_text ("Floor"); 929 $INVR_LBL->set_text ("Floor");
917 $vb2->add ($INVR = new CFClient::UI::Inventory expand => 1); 930 $vb2->add ($INVR = new CFClient::UI::Inventory expand => 1);
918 931
919 $invwin 932 $invwin
920} 933}
1055 1068
1056 $BUTTONBAR->add (new CFClient::UI::Button 1069 $BUTTONBAR->add (new CFClient::UI::Button
1057 text => "Save Config", 1070 text => "Save Config",
1058 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", 1071 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.",
1059 connect_activate => sub { 1072 connect_activate => sub {
1073 $::CFG->{layout} = CFClient::UI::get_layout;
1060 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 1074 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
1061 status "Configuration Saved"; 1075 status "Configuration Saved";
1062 }, 1076 },
1063 ); 1077 );
1064 1078
1308 1322
1309{ 1323{
1310 local $SIG{__DIE__} = sub { CFClient::fatal $_[0] }; 1324 local $SIG{__DIE__} = sub { CFClient::fatal $_[0] };
1311 1325
1312 CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; 1326 CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
1327 CFClient::UI::set_layout ($::CFG->{layout});
1313 1328
1314 my %DEF_CFG = ( 1329 my %DEF_CFG = (
1315 sdl_mode => 0, 1330 sdl_mode => 0,
1316 width => 640, 1331 width => 640,
1317 height => 480, 1332 height => 480,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines