ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/pclient
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/pclient (file contents):
Revision 1.190 by elmex, Thu Apr 27 08:55:35 2006 UTC vs.
Revision 1.193 by root, Sat Apr 29 16:17:10 2006 UTC

91our %AUDIO_CHUNKS; # audio files 91our %AUDIO_CHUNKS; # audio files
92 92
93our $ALT_ENTER_MESSAGE; 93our $ALT_ENTER_MESSAGE;
94our $STATUS_LINE; 94our $STATUS_LINE;
95our $DEBUG_STATUS; 95our $DEBUG_STATUS;
96
97our $INVWIN;
98our $INV;
96 99
97sub status { 100sub status {
98 $STATUS_LINE->set_text ($_[0]); 101 $STATUS_LINE->set_text ($_[0]);
99 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h}); 102 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h});
100} 103}
778 }; 781 };
779 782
780 $window 783 $window
781} 784}
782 785
786sub make_inventory_window {
787 my $invwin = new CFClient::UI::FancyFrame user_w => 300, user_h => 300, title => "Inventory";
788 $invwin->add (my $hb = new CFClient::UI::HBox);
789 $hb->add ($INV = new CFClient::UI::Inventory expand => 1);
790 $hb->add (my $rng = new CFClient::UI::Slider vertical => 1);
791 $INV->set_range ($rng);
792 $invwin
793}
794
783sub sdl_init { 795sub sdl_init {
784 CFClient::SDL_Init 796 CFClient::SDL_Init
785 and die "SDL::Init failed!\n"; 797 and die "SDL::Init failed!\n";
786} 798}
787 799
846 858
847 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); 859 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup);
848 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); 860 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup);
849 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); 861 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window);
850 862
851 $CFClient::UI::ROOT->add (make_gauge_window); # 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 863 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
864
852 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); 865 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window);
866 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window);
853 867
854 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { 868 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub {
855 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 869 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
856 status "Configuration Saved"; 870 status "Configuration Saved";
857 }); 871 });
1309sub update_floorbox { 1323sub update_floorbox {
1310 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { 1324 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub {
1311 $FLOORBOX->clear; 1325 $FLOORBOX->clear;
1312 $FLOORBOX->add (new CFClient::UI::Empty expand => 1); 1326 $FLOORBOX->add (new CFClient::UI::Empty expand => 1);
1313 1327
1314 my @items = values %{ $CONN->{container}{0} };
1315
1316 # we basically have to use the same sorting as everybody else 1328 # we basically have to use the same sorting as everybody else
1317 @items = sort { $a->{type} <=> $b->{type} } @items; 1329 for my $item (@{ $CONN->{container}{0} }) {
1318
1319 for my $item (reverse @items) {
1320 my $desc = $item->{nrof} < 2 1330 my $desc = $item->{nrof} < 2
1321 ? $item->{name} 1331 ? $item->{name}
1322 : "$item->{nrof} $item->{name_pl}"; 1332 : "$item->{nrof} $item->{name_pl}";
1323 # todo: animation widget, face widget, weight(?) etc. 1333 # todo: animation widget, face widget, weight(?) etc.
1324 $FLOORBOX->add (my $hbox = new CFClient::UI::HBox 1334 $FLOORBOX->add (my $hbox = new CFClient::UI::HBox
1370 1380
1371sub conn::container_add { 1381sub conn::container_add {
1372 my ($self, $id, $items) = @_; 1382 my ($self, $id, $items) = @_;
1373 1383
1374 update_floorbox if $id == 0; 1384 update_floorbox if $id == 0;
1385 if ($self->{player}{tag} == $id) {
1386 $INV->set_items ($self->{container}{$self->{player}{tag}});
1387 }
1375 # $self-<{player}{tag} => player inv 1388 # $self-<{player}{tag} => player inv
1376 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; 1389 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
1377} 1390}
1378 1391
1379sub conn::container_clear { 1392sub conn::container_clear {
1380 my ($self, $id) = @_; 1393 my ($self, $id) = @_;
1381 1394
1382 update_floorbox if $id == 0; 1395 update_floorbox if $id == 0;
1396 if ($self->{player}{tag} == $id) {
1397 $INV->set_items ($self->{container}{$id});
1398 }
1399
1383# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; 1400# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1384} 1401}
1385 1402
1386sub conn::item_delete { 1403sub conn::item_delete {
1387 my ($self, @items) = @_; 1404 my ($self, @items) = @_;
1388 1405
1389 for (@items) { 1406 for (@items) {
1390 update_floorbox if $_->{container} == 0; 1407 update_floorbox if $_->{container} == 0;
1408 if ($self->{player}{tag} == $_->{container}) {
1409 $INV->set_items ($self->{container}{$_->{container}});
1410 }
1391 } 1411 }
1392} 1412}
1393 1413
1394sub conn::item_update { 1414sub conn::item_update {
1395 my ($self, $item) = @_; 1415 my ($self, $item) = @_;
1396 1416
1397 update_floorbox if $item->{container} == 0; 1417 update_floorbox if $item->{container} == 0;
1418 if ($self->{player}{tag} == $item->{container}) {
1419 $INV->set_items ($self->{container}{$item->{container}});
1420 }
1398} 1421}
1399 1422
1400%SDL_CB = ( 1423%SDL_CB = (
1401 CFClient::SDL_QUIT => sub { 1424 CFClient::SDL_QUIT => sub {
1402 Event::unloop -1; 1425 Event::unloop -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines