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.206 by root, Tue May 9 22:27:55 2006 UTC vs.
Revision 1.212 by root, Fri May 12 15:45:42 2006 UTC

37use CFClient; 37use CFClient;
38use CFClient::UI; 38use CFClient::UI;
39use CFClient::MapWidget; 39use CFClient::MapWidget;
40 40
41$Event::DIED = sub { 41$Event::DIED = sub {
42 # TODO: display dialog box or so
42 CFClient::error $_[1]; 43 CFClient::error $_[1];
43}; 44};
44 45
45#$SIG{__WARN__} = sub { Carp::cluck $_[0] };#d# 46#$SIG{__WARN__} = sub { Carp::cluck $_[0] };#d#
46 47
93our $SDL_MIXER; 94our $SDL_MIXER;
94our @SOUNDS; # event => file mapping 95our @SOUNDS; # event => file mapping
95our %AUDIO_CHUNKS; # audio files 96our %AUDIO_CHUNKS; # audio files
96 97
97our $ALT_ENTER_MESSAGE; 98our $ALT_ENTER_MESSAGE;
98our $STATUS_LINE; 99our $STATUSBOX;
99our $DEBUG_STATUS; 100our $DEBUG_STATUS;
100 101
101our $INVWIN; 102our $INVWIN;
102our $INV; 103our $INV;
103 104
104sub status { 105sub status {
105 $STATUS_LINE->set_text ($_[0]); 106 $STATUSBOX->add ($_[0], pri => -10, group => "status", timeout => 20, color => [1, 1, 0, 1]);
106 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h}); 107 $CFClient::UI::ROOT->on_post_alloc (status_line_positioner => sub {
108 my $widget = $STATUSBOX->{parent};
109 $widget->move (0, $HEIGHT - $widget->{h});#d# to in toplevel
110 });
107} 111}
108 112
109sub debug { 113sub debug {
110 $DEBUG_STATUS->set_text ($_[0]); 114 $DEBUG_STATUS->set_text ($_[0]);
111 my ($w, $h) = $DEBUG_STATUS->size_request; 115 my ($w, $h) = $DEBUG_STATUS->size_request;
378 y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh 382 y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh
379 ); 383 );
380 $win->add (my $hbox = new CFClient::UI::HBox 384 $win->add (my $hbox = new CFClient::UI::HBox
381 children => [ 385 children => [
382 (new CFClient::UI::HBox expand => 1), 386 (new CFClient::UI::HBox expand => 1),
383 ($FLOORBOX = new CFClient::UI::VBox), 387 (new CFClient::UI::VBox children => [
388 (new CFClient::UI::Empty expand => 1),
389 (new CFClient::UI::Frame bg => [0, 0, 0, 0.4], child => ($FLOORBOX = new CFClient::UI::VBox)),
390 ]),
384 (my $vbox = new CFClient::UI::VBox), 391 (my $vbox = new CFClient::UI::VBox),
385 ], 392 ],
386 ); 393 );
387 394
388 $vbox->add (new CFClient::UI::HBox 395 $vbox->add (new CFClient::UI::HBox
852 # create the widgets 859 # create the widgets
853 860
854 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100, text => "hulla", x => 100;#d# 861 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100, text => "hulla", x => 100;#d#
855 $DEBUG_STATUS->show; 862 $DEBUG_STATUS->show;
856 863
857 $STATUS_LINE = new CFClient::UI::Label 864 $STATUSBOX = new CFClient::UI::Statusbox;
858 padding => 0, 865 $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", pri => -100, size => 0.8, color => [1, 1, 1, 0.8]);
859 y => $HEIGHT - $FONTSIZE * 1.8;
860 $STATUS_LINE->show;
861 866
862 $ALT_ENTER_MESSAGE = new CFClient::UI::Label 867 (new CFClient::UI::Frame
863 padding => 0, 868 bg => [0, 0, 0, 0.4],
864 fontsize => 0.8, 869 child => $STATUSBOX,
865 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 870 )->show;
866 $ALT_ENTER_MESSAGE->show;
867 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h});
868 871
869 CFClient::UI::FancyFrame->new ( 872 CFClient::UI::FancyFrame->new (
870 border_bg => [1, 1, 1, 192/255], 873 border_bg => [1, 1, 1, 192/255],
871 bg => [1, 1, 1, 0], 874 bg => [1, 1, 1, 0],
872 child => ($MAPMAP = new CFClient::MapWidget::MapMap), 875 child => ($MAPMAP = new CFClient::MapWidget::MapMap),
905 }); 908 });
906 909
907 $BUTTONBAR->show; 910 $BUTTONBAR->show;
908 911
909 # delay till geometry is constant 912 # delay till geometry is constant
910 $CFClient::UI::ROOT->on_refresh (startup => sub { 913 $CFClient::UI::ROOT->on_post_alloc (startup => sub {
911 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 914 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
912 }); 915 });
913 force_refresh (); 916 force_refresh ();
914 } 917 }
915} 918}
1326 [0.55, 0.41, 0.13], 1329 [0.55, 0.41, 0.13],
1327 [0.99, 0.77, 0.26], 1330 [0.99, 0.77, 0.26],
1328 [0.74, 0.65, 0.41], 1331 [0.74, 0.65, 0.41],
1329 ); 1332 );
1330 1333
1334 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0];
1335
1336 $text =~ s/&/&amp;/g; $text =~ s/</&lt;/g;
1337 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
1338 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
1339
1331 $LOGVIEW->add_paragraph ($color[$color], $text); 1340 $LOGVIEW->add_paragraph ($color[$color],
1341 join "\n", map "$time $_", split /\n/, $text);
1342
1343 $STATUSBOX->add ($text,
1344 group => $text,
1345 color => $color[$color],
1346 timeout => 60,
1347 tooltip_font => $::FONT_FIXED,
1348 );
1349}
1350
1351sub conn::drawextinfo {
1352 my ($self, $color, $type, $subtype, $message) = @_;
1353
1354 $self->drawinfo ($color, $message);
1332} 1355}
1333 1356
1334sub conn::spell_add { 1357sub conn::spell_add {
1335 my ($self, $spell) = @_; 1358 my ($self, $spell) = @_;
1336 1359
1367 return unless $CONN; 1390 return unless $CONN;
1368 1391
1369 $FLOORBOX->clear; 1392 $FLOORBOX->clear;
1370 $FLOORBOX->add (new CFClient::UI::Empty expand => 1); 1393 $FLOORBOX->add (new CFClient::UI::Empty expand => 1);
1371 1394
1372 # we basically have to use the same sorting as everybody else 1395 my $count = 4;
1373 $FLOORBOX->add ( 1396 for (@{ $CONN->{container}{0} }) {
1397 if (--$count) {
1374 map +(new CFClient::UI::InventoryItem item => $_), 1398 $FLOORBOX->add (new CFClient::UI::InventoryItem item => $_);
1375 @{ $CONN->{container}{0} } 1399 } else {
1400 $FLOORBOX->add (new CFClient::UI::Label text => "More...");
1401 last;
1402 }
1376 ); 1403 }
1377 }); 1404 });
1378 1405
1379 $WANT_REFRESH++; 1406 $WANT_REFRESH++;
1380} 1407}
1381 1408

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines