… | |
… | |
91 | our %AUDIO_CHUNKS; # audio files |
91 | our %AUDIO_CHUNKS; # audio files |
92 | |
92 | |
93 | our $ALT_ENTER_MESSAGE; |
93 | our $ALT_ENTER_MESSAGE; |
94 | our $STATUS_LINE; |
94 | our $STATUS_LINE; |
95 | our $DEBUG_STATUS; |
95 | our $DEBUG_STATUS; |
|
|
96 | |
|
|
97 | our $INVWIN; |
|
|
98 | our $INV; |
96 | |
99 | |
97 | sub status { |
100 | sub 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 | |
|
|
786 | sub 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 | |
783 | sub sdl_init { |
795 | sub 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 | |
… | |
… | |
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 | $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 |
852 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); |
864 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); |
|
|
865 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window); |
853 | |
866 | |
854 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
867 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
855 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
868 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
856 | status "Configuration Saved"; |
869 | status "Configuration Saved"; |
857 | }); |
870 | }); |
… | |
… | |
1370 | |
1383 | |
1371 | sub conn::container_add { |
1384 | sub conn::container_add { |
1372 | my ($self, $id, $items) = @_; |
1385 | my ($self, $id, $items) = @_; |
1373 | |
1386 | |
1374 | update_floorbox if $id == 0; |
1387 | update_floorbox if $id == 0; |
|
|
1388 | if ($self->{player}{tag} == $id) { |
|
|
1389 | $INV->set_items ($self->{container}{$self->{player}{tag}}); |
|
|
1390 | } |
1375 | # $self-<{player}{tag} => player inv |
1391 | # $self-<{player}{tag} => player inv |
1376 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
1392 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
1377 | } |
1393 | } |
1378 | |
1394 | |
1379 | sub conn::container_clear { |
1395 | sub conn::container_clear { |
1380 | my ($self, $id) = @_; |
1396 | my ($self, $id) = @_; |
1381 | |
1397 | |
1382 | update_floorbox if $id == 0; |
1398 | update_floorbox if $id == 0; |
|
|
1399 | if ($self->{player}{tag} == $id) { |
|
|
1400 | $INV->set_items ($self->{container}{$id}); |
|
|
1401 | } |
|
|
1402 | |
1383 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
1403 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
1384 | } |
1404 | } |
1385 | |
1405 | |
1386 | sub conn::item_delete { |
1406 | sub conn::item_delete { |
1387 | my ($self, @items) = @_; |
1407 | my ($self, @items) = @_; |
1388 | |
1408 | |
1389 | for (@items) { |
1409 | for (@items) { |
1390 | update_floorbox if $_->{container} == 0; |
1410 | update_floorbox if $_->{container} == 0; |
|
|
1411 | if ($self->{player}{tag} == $_->{container}) { |
|
|
1412 | $INV->set_items ($self->{container}{$_->{container}}); |
|
|
1413 | } |
1391 | } |
1414 | } |
1392 | } |
1415 | } |
1393 | |
1416 | |
1394 | sub conn::item_update { |
1417 | sub conn::item_update { |
1395 | my ($self, $item) = @_; |
1418 | my ($self, $item) = @_; |
1396 | |
1419 | |
1397 | update_floorbox if $item->{container} == 0; |
1420 | update_floorbox if $item->{container} == 0; |
|
|
1421 | if ($self->{player}{tag} == $item->{container}) { |
|
|
1422 | $INV->set_items ($self->{container}{$item->{container}}); |
|
|
1423 | } |
1398 | } |
1424 | } |
1399 | |
1425 | |
1400 | %SDL_CB = ( |
1426 | %SDL_CB = ( |
1401 | CFClient::SDL_QUIT => sub { |
1427 | CFClient::SDL_QUIT => sub { |
1402 | Event::unloop -1; |
1428 | Event::unloop -1; |