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.205 by root, Tue May 9 16:22:44 2006 UTC vs.
Revision 1.210 by root, Fri May 12 01:47:04 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
59our $NOW; 60our $NOW;
60 61
61our $CFG; 62our $CFG;
62our $CONN; 63our $CONN;
63our $FAST; # fast, low-quality mode, possibly useful for software-rendering 64our $FAST; # fast, low-quality mode, possibly useful for software-rendering
65
66our $WANT_REFRESH;
67our $CAN_REFRESH;
64 68
65our @SDL_MODES; 69our @SDL_MODES;
66our $WIDTH; 70our $WIDTH;
67our $HEIGHT; 71our $HEIGHT;
68our $FULLSCREEN; 72our $FULLSCREEN;
97 101
98our $INVWIN; 102our $INVWIN;
99our $INV; 103our $INV;
100 104
101sub status { 105sub status {
102 $STATUS_LINE->set_text ($_[0]); 106 $STATUS_LINE->add ($_[0], pri => -10, group => "status", timeout => 20, color => [1, 1, 0, 1]);
103 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h}); 107 $CFClient::UI::ROOT->on_refresh ($STATUS_LINE => sub {
108 $STATUS_LINE->move (0, $HEIGHT - $STATUS_LINE->{h});#d# to in toplevel
109 });
104} 110}
105 111
106sub debug { 112sub debug {
107 $DEBUG_STATUS->set_text ($_[0]); 113 $DEBUG_STATUS->set_text ($_[0]);
108 $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0, $DEBUG_STATUS->{w}, $DEBUG_STATUS->{h}); 114 my ($w, $h) = $DEBUG_STATUS->size_request;
115 $DEBUG_STATUS->move ($WIDTH - $w, 0);
109} 116}
110 117
111sub start_game { 118sub start_game {
112 status "logging in..."; 119 status "logging in...";
113 120
845 $CFClient::UI::ROOT->reconfigure; 852 $CFClient::UI::ROOT->reconfigure;
846 853
847 } else { 854 } else {
848 # create the widgets 855 # create the widgets
849 856
850 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; 857 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100, text => "hulla", x => 100;#d#
851 $DEBUG_STATUS->show; 858 $DEBUG_STATUS->show;
852 859
853 $STATUS_LINE = new CFClient::UI::Label 860 $STATUS_LINE = new CFClient::UI::Statusbox;
854 padding => 0, 861 $STATUS_LINE->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", pri => -100, size => 0.8, color => [1, 1, 1, 0.8]);
855 y => $HEIGHT - $FONTSIZE * 1.8;
856 $STATUS_LINE->show; 862 $STATUS_LINE->show;
857
858 $ALT_ENTER_MESSAGE = new CFClient::UI::Label
859 padding => 0,
860 fontsize => 0.8,
861 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
862 $ALT_ENTER_MESSAGE->show;
863 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h});
864 863
865 CFClient::UI::FancyFrame->new ( 864 CFClient::UI::FancyFrame->new (
866 border_bg => [1, 1, 1, 192/255], 865 border_bg => [1, 1, 1, 192/255],
867 bg => [1, 1, 1, 0], 866 bg => [1, 1, 1, 0],
868 child => ($MAPMAP = new CFClient::MapWidget::MapMap), 867 child => ($MAPMAP = new CFClient::MapWidget::MapMap),
900 status "Configuration Saved"; 899 status "Configuration Saved";
901 }); 900 });
902 901
903 $BUTTONBAR->show; 902 $BUTTONBAR->show;
904 903
904 # delay till geometry is constant
905 $CFClient::UI::ROOT->on_refresh (startup => sub {
905 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 906 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
907 });
908 force_refresh ();
906 } 909 }
907} 910}
908 911
909sub video_shutdown { 912sub video_shutdown {
910 undef $SDL_ACTIVE; 913 undef $SDL_ACTIVE;
966} 969}
967 970
968my %animate_object; 971my %animate_object;
969my $animate_timer; 972my $animate_timer;
970 973
971my $want_refresh;
972my $can_refresh;
973
974my $fps = 9; 974my $fps = 9;
975 975
976sub force_refresh { 976sub force_refresh {
977 $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05; 977 $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05;
978 debug sprintf "%3.2f", $fps; 978 debug sprintf "%3.2f", $fps;
979 979
980 $want_refresh = 0;
981 $can_refresh = 0;
982
983 $CFClient::UI::ROOT->draw; 980 $CFClient::UI::ROOT->draw;
984
985 CFClient::SDL_GL_SwapBuffers; 981 CFClient::SDL_GL_SwapBuffers;
986 982
983 $WANT_REFRESH = 0;
984 $CAN_REFRESH = 0;
987 $LAST_REFRESH = $NOW; 985 $LAST_REFRESH = $NOW;
988} 986}
989 987
990my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { 988my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub {
991 $NOW = time; 989 $NOW = time;
993 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) 991 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_)
994 for CFClient::SDL_PollEvent; 992 for CFClient::SDL_PollEvent;
995 993
996 if (%animate_object) { 994 if (%animate_object) {
997 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; 995 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object;
998 $want_refresh++; 996 $WANT_REFRESH++;
999 } 997 }
1000 998
1001 if ($want_refresh) { 999 if ($WANT_REFRESH) {
1002 force_refresh; 1000 force_refresh;
1003 } else { 1001 } else {
1004 $can_refresh = 1; 1002 $CAN_REFRESH = 1;
1005 } 1003 }
1006}); 1004});
1007
1008sub refresh {
1009 $want_refresh++;
1010}
1011 1005
1012sub animation_start { 1006sub animation_start {
1013 my ($widget) = @_; 1007 my ($widget) = @_;
1014 $animate_object{$widget} = $widget; 1008 $animate_object{$widget} = $widget;
1015} 1009}
1327 [0.55, 0.41, 0.13], 1321 [0.55, 0.41, 0.13],
1328 [0.99, 0.77, 0.26], 1322 [0.99, 0.77, 0.26],
1329 [0.74, 0.65, 0.41], 1323 [0.74, 0.65, 0.41],
1330 ); 1324 );
1331 1325
1326 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0];
1327
1328 $text =~ s/&/&amp;/g; $text =~ s/</&lt;/g;
1329 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
1330 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
1331
1332 $LOGVIEW->add_paragraph ($color[$color], $text); 1332 $LOGVIEW->add_paragraph ($color[$color],
1333 join "\n", map "$time $_", split /\n/, $text);
1334 $STATUS_LINE->add ($text, color => $color[$color], timeout => 60);
1335}
1336
1337sub conn::drawextinfo {
1338 my ($self, $color, $type, $subtype, $message) = @_;
1339
1340 $self->drawinfo ($color, $message);
1333} 1341}
1334 1342
1335sub conn::spell_add { 1343sub conn::spell_add {
1336 my ($self, $spell) = @_; 1344 my ($self, $spell) = @_;
1337 1345
1368 return unless $CONN; 1376 return unless $CONN;
1369 1377
1370 $FLOORBOX->clear; 1378 $FLOORBOX->clear;
1371 $FLOORBOX->add (new CFClient::UI::Empty expand => 1); 1379 $FLOORBOX->add (new CFClient::UI::Empty expand => 1);
1372 1380
1373 # we basically have to use the same sorting as everybody else 1381 my $count = 4;
1374 $FLOORBOX->add ( 1382 for (@{ $CONN->{container}{0} }) {
1383 if (--$count) {
1375 map +(new CFClient::UI::InventoryItem item => $_), 1384 $FLOORBOX->add (new CFClient::UI::InventoryItem item => $_);
1376 @{ $CONN->{container}{0} } 1385 } else {
1386 $FLOORBOX->add (new CFClient::UI::Label text => "More...");
1387 last;
1388 }
1377 ); 1389 }
1378 }); 1390 });
1379 refresh; 1391
1392 $WANT_REFRESH++;
1380} 1393}
1381 1394
1382sub conn::container_add { 1395sub conn::container_add {
1383 my ($self, $tag, $items) = @_; 1396 my ($self, $tag, $items) = @_;
1384 1397
1426 CFClient::SDL_QUIT => sub { 1439 CFClient::SDL_QUIT => sub {
1427 Event::unloop -1; 1440 Event::unloop -1;
1428 }, 1441 },
1429 CFClient::SDL_VIDEORESIZE => sub { 1442 CFClient::SDL_VIDEORESIZE => sub {
1430 }, 1443 },
1431 CFClient::SDL_VIDEOEXPOSE => \&refresh, 1444 CFClient::SDL_VIDEOEXPOSE => sub {
1445 $WANT_REFRESH++;
1446 },
1432 CFClient::SDL_ACTIVEEVENT => sub { 1447 CFClient::SDL_ACTIVEEVENT => sub {
1433# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# 1448# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
1434 }, 1449 },
1435 CFClient::SDL_KEYDOWN => sub { 1450 CFClient::SDL_KEYDOWN => sub {
1436 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { 1451 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) {
1477 fow_enable => 1, 1492 fow_enable => 1,
1478 fow_intensity => 0.45, 1493 fow_intensity => 0.45,
1479 fow_smooth => 0, 1494 fow_smooth => 0,
1480 gui_fontsize => 1, 1495 gui_fontsize => 1,
1481 log_fontsize => 1, 1496 log_fontsize => 1,
1482 gauge_fontsize => 1, 1497 gauge_fontsize=> 1,
1483 gauge_size => 0.35, 1498 gauge_size => 0.35,
1484 stat_fontsize => 1, 1499 stat_fontsize => 1,
1485 mapsize => 100, 1500 mapsize => 100,
1486 host => "crossfire.schmorp.de", 1501 host => "crossfire.schmorp.de",
1487 say_command => 'say', 1502 say_command => 'say',
1488 audio_enable => 1, 1503 audio_enable => 1,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines