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.172 by root, Mon Apr 24 03:43:52 2006 UTC vs.
Revision 1.176 by root, Mon Apr 24 10:19:40 2006 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2 2
3use strict; 3use strict;
4use utf8; 4use utf8;
5
6BEGIN {
7 if (%PAR::LibCache) {
8 @INC = grep ref, @INC; # weed out all paths except pars loader refs
9
10 while (my ($filename, $zip) = each %PAR::LibCache) {
11 for ($zip->memberNames) {
12 next unless /^\/root\/(.*)/;
13 $zip->extractMember ($_, "$ENV{PAR_TEMP}/$1")
14 unless -e "$ENV{PAR_TEMP}/$1";
15 }
16 }
17
18 unshift @INC, $ENV{PAR_TEMP};
19
20 if ($^O eq "MSWin32") {
21 $ENV{GTK_RC_FILES} = "$ENV{PAR_TEMP}/share/themes/MS-Windows/gtk-2.0/gtkrc";
22 }
23 }
24}
25
26# need to do it again because that pile of garbage called PAR nukes it before main
27unshift @INC, $ENV{PAR_TEMP};
5 28
6use Time::HiRes 'time'; 29use Time::HiRes 'time';
7use Event; 30use Event;
8 31
9use Crossfire; 32use Crossfire;
12use Compress::LZF; 35use Compress::LZF;
13 36
14use CFClient; 37use CFClient;
15use CFClient::UI; 38use CFClient::UI;
16use CFClient::MapWidget; 39use CFClient::MapWidget;
40
41$SIG{__DIE__} = sub { CFClient::fatal "$_[0]"; exit 1 };
17 42
18our $VERSION = '0.1'; 43our $VERSION = '0.1';
19 44
20my $MAX_FPS = 60; 45my $MAX_FPS = 60;
21my $MIN_FPS = 5; # unused as of yet 46my $MIN_FPS = 5; # unused as of yet
47our $BUTTONBAR; 72our $BUTTONBAR;
48our $LOGVIEW; 73our $LOGVIEW;
49our $CONSOLE; 74our $CONSOLE;
50our $METASERVER; 75our $METASERVER;
51 76
77our $FLOORBOX;
52our $GAUGES; 78our $GAUGES;
53our $STATWIDS; 79our $STATWIDS;
54 80
55our $SDL_ACTIVE; 81our $SDL_ACTIVE;
56our %SDL_CB; 82our %SDL_CB;
308# my $gw = int ($WIDTH * $CFG->{gauge_w_size}); 334# my $gw = int ($WIDTH * $CFG->{gauge_w_size});
309 335
310 my $win = new CFClient::UI::Frame ( 336 my $win = new CFClient::UI::Frame (
311 y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh 337 y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh
312 ); 338 );
313 $win->add (my $vb = new CFClient::UI::VBox); 339 $win->add (my $hbox = new CFClient::UI::HBox
314 340 children => [
315 $vb->add (my $hb1 = new CFClient::UI::HBox expand => 1); 341 (new CFClient::UI::HBox expand => 1),
342 ($FLOORBOX = new CFClient::UI::VBox),
343 (my $vbox = new CFClient::UI::VBox),
344 ],
345 );
316 346
347 $vbox->add (new CFClient::UI::HBox
348 expand => 1,
349 children => [
317 $hb1->add (new CFClient::UI::Empty expand => 1); 350 (new CFClient::UI::Empty expand => 1),
318 $hb1->add (my $hb = new CFClient::UI::HBox); 351 (my $hb = new CFClient::UI::HBox),
352 ],
353 );
354
319 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp', 355 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp',
320 tooltip => "Health points - depletes when you get wounded, refills when you heal or idle"); 356 tooltip => "Health points - depletes when you get wounded, refills when you heal or idle");
321 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana', 357 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana',
322 tooltip => "Spell points - deplete when you cast wizard spells, refills when you idle"); 358 tooltip => "Spell points - deplete when you cast wizard spells, refills when you idle");
323 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace', 359 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace',
324 tooltip => "Grace points - deplete when you cast priest spells, refills when you pray"); 360 tooltip => "Grace points - deplete when you cast priest spells, refills when you pray");
325 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food', 361 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food',
326 tooltip => "Food - depletes with time, faster when you heal or build mana, refills when you eat healthy food"); 362 tooltip => "Food - depletes with time, faster when you heal or build mana, refills when you eat healthy food");
327 363
328 $vb->add (my $hb2 = new CFClient::UI::HBox);
329
330 $hb2->add (new CFClient::UI::Empty expand => 1);
331 $hb2->add (my $vb2 = new CFClient::UI::VBox);
332 $vb2->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, 364 $vbox->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1,
333 tooltip => "Experience points and level - increases when you kill monsters or successfully use skills"); 365 tooltip => "Experience points and level - increases when you kill monsters or successfully use skills");
334 $vb2->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, 366 $vbox->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1,
335 tooltip => "Ranged attack - how you attack when you press shift-cursor (spell, skill, weapon etc.)"); 367 tooltip => "Ranged attack - how you attack when you press shift-cursor (spell, skill, weapon etc.)");
336 368
337 $GAUGES = { 369 $GAUGES = {
338 exp => $exp, win => $win, range => $rng, 370 exp => $exp, win => $win, range => $rng,
339 food => $fg, mana => $mg, hp => $hg, grace => $gg 371 food => $fg, mana => $mg, hp => $hg, grace => $gg
352 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1); 384 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1);
353 385
354 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 386 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
355 387
356 $hb->add (my $tbl = new CFClient::UI::Table expand => 1); 388 $hb->add (my $tbl = new CFClient::UI::Table expand => 1);
389
390 my $black = [0, 0, 0];
357 391
358 $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 392 $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
359 $tbl->add (0, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 393 $tbl->add (0, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
360 $tbl->add (0, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 394 $tbl->add (0, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
361 $tbl->add (0, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 395 $tbl->add (0, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
362 $tbl->add (0, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 396 $tbl->add (0, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
363 $tbl->add (0, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 397 $tbl->add (0, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
364 $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 398 $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
365 399
366 $tbl->add (1, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Str"); 400 $tbl->add (1, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Str");
367 $tbl->add (1, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Dex"); 401 $tbl->add (1, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Dex");
368 $tbl->add (1, 2, $STATWIDS->{st_con_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Con"); 402 $tbl->add (1, 2, $STATWIDS->{st_con_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Con");
369 $tbl->add (1, 3, $STATWIDS->{st_int_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Int"); 403 $tbl->add (1, 3, $STATWIDS->{st_int_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Int");
370 $tbl->add (1, 4, $STATWIDS->{st_wis_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Wis"); 404 $tbl->add (1, 4, $STATWIDS->{st_wis_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Wis");
371 $tbl->add (1, 5, $STATWIDS->{st_pow_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Pow"); 405 $tbl->add (1, 5, $STATWIDS->{st_pow_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Pow");
372 $tbl->add (1, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Cha"); 406 $tbl->add (1, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Cha");
373 407
374 $tbl->add (2, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, template => "-120"); 408 $tbl->add (2, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, template => "-120");
375 $tbl->add (2, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => +1, template => "-120"); 409 $tbl->add (2, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => +1, template => "-120");
376 $tbl->add (2, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => +1, template => "120"); 410 $tbl->add (2, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => +1, template => "120");
377 $tbl->add (2, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => +1, template => "120"); 411 $tbl->add (2, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => +1, template => "120");
378 $tbl->add (2, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => +1, template => "10.54"); 412 $tbl->add (2, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => +1, template => "10.54");
379 $tbl->add (2, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, template => "9"); 413 $tbl->add (2, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, template => "9");
380 414
381 $tbl->add (3, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Wc"); 415 $tbl->add (3, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Wc");
382 $tbl->add (3, 1, $STATWIDS->{st_ac_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Ac"); 416 $tbl->add (3, 1, $STATWIDS->{st_ac_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Ac");
383 $tbl->add (3, 2, $STATWIDS->{st_dam_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Dam"); 417 $tbl->add (3, 2, $STATWIDS->{st_dam_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Dam");
384 $tbl->add (3, 3, $STATWIDS->{st_arm_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Arm"); 418 $tbl->add (3, 3, $STATWIDS->{st_arm_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Arm");
385 $tbl->add (3, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Sp"); 419 $tbl->add (3, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Sp");
386 $tbl->add (3, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "WSp"); 420 $tbl->add (3, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "WSp");
387 421
388 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); 422 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1);
389 423
390 my $row = 0; 424 my $row = 0;
391 my $col = 0; 425 my $col = 0;
648 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); 682 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd");
649 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry 683 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry
650 text => $CFG->{say_command}, 684 text => $CFG->{say_command},
651 tooltip => "This is the command that will be used if you write a line in the message window entry. " 685 tooltip => "This is the command that will be used if you write a line in the message window entry. "
652 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " 686 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
653 ."But you could also set it to 'tell <playername>' to only chat with that user.", 687 ."But you could also set it to 'tell &lt;playername&gt;' to only chat with that user.",
654 connect_changed => sub { 688 connect_changed => sub {
655 my ($self, $value) = @_; 689 my ($self, $value) = @_;
656 $CFG->{say_command} = $value; 690 $CFG->{say_command} = $value;
657 } 691 }
658 ); 692 );
1093 } 1127 }
1094 1128
1095gotid: 1129gotid:
1096 $face->{id} = $id; 1130 $face->{id} = $id;
1097 $MAP->set_face ($facenum => $id); 1131 $MAP->set_face ($facenum => $id);
1132 $self->{faceid}[$facenum] = $id;#d#
1098 $TILECACHE->get ($id) 1133 $TILECACHE->get ($id)
1099} 1134}
1100 1135
1101sub conn::face_update { 1136sub conn::face_update {
1102 my ($self, $facenum, $face) = @_; 1137 my ($self, $facenum, $face) = @_;
1110 my ($self, $id, $data) = @_; 1145 my ($self, $id, $data) = @_;
1111 1146
1112 $self->{texture}[$id] ||= do { 1147 $self->{texture}[$id] ||= do {
1113 my $tex = 1148 my $tex =
1114 new_from_image CFClient::Texture 1149 new_from_image CFClient::Texture
1115 $data, minify => 1; 1150 $data, minify => 1, mipmap => 1;
1116 1151
1117 $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 1152 $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});
1118 $MAPWIDGET->update; 1153 $MAPWIDGET->update;
1119 1154
1120 $tex 1155 $tex
1243 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); 1278 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'");
1244 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'"); 1279 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'");
1245 } 1280 }
1246} 1281}
1247 1282
1283sub update_floorbox {
1284 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub {
1285 $FLOORBOX->clear;
1286 $FLOORBOX->add (new CFClient::UI::Empty expand => 1);
1287
1288 my @items = values %{ $CONN->{container}{0} };
1289
1290 # we basically have to use the same sorting as everybody else
1291 @items = sort { $a->{type} <=> $b->{type} } @items;
1292
1293 for my $item (reverse @items) {
1294 my $desc = $item->{nrof} < 2
1295 ? $item->{name}
1296 : "$item->{nrof} $item->{name_pl}";
1297 # todo: animation widget, face widget, weight(?) etc.
1298 $FLOORBOX->add (my $hbox = new CFClient::UI::HBox
1299 tooltip => (CFClient::UI::Label->escape ($desc)
1300 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"),
1301 can_hover => 1,
1302 can_events => 1,
1303 connect_button_down => sub {
1304 my ($self, $ev, $x, $y) = @_;
1305
1306 # todo: maybe put examine on 1? but should just be a tooltip :(
1307 if ($ev->{button} == 1) {
1308 $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0");
1309 } elsif ($ev->{button} == 2) {
1310 $CONN->send ("apply $item->{tag}");
1311 } elsif ($ev->{button} == 3) {
1312 # examine, lock, mark, maybe other things
1313 warn "MENU not implemented yet\n";
1314 }
1315
1316 1
1317 },
1318 );
1319
1320 $hbox->add (new CFClient::UI::Face
1321 can_events => 0,
1322 face => $item->{face},
1323 anim => $item->{anim},
1324 animspeed => $item->{animspeed},
1325 );
1326
1327 $hbox->add (new CFClient::UI::Label
1328 can_events => 0,
1329 text => $desc,
1330 );
1331 }
1332 });
1333 refresh;
1334}
1335
1248sub conn::container_add { 1336sub conn::container_add {
1249 my ($self, $id, $items) = @_; 1337 my ($self, $id, $items) = @_;
1250 1338
1251 # 0 floor 1339 update_floorbox if $id == 0;
1252 # $self-<{player}{tag} => player inv 1340 # $self-<{player}{tag} => player inv
1253 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; 1341 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
1254} 1342}
1255 1343
1256sub conn::container_clear { 1344sub conn::container_clear {
1257 my ($self, $id) = @_; 1345 my ($self, $id) = @_;
1346
1347 update_floorbox if $id == 0;
1258# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; 1348# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1349}
1350
1351sub conn::item_delete {
1352 my ($self, @items) = @_;
1353
1354 for (@items) {
1355 update_floorbox if $_->{container} == 0;
1356 }
1357}
1358
1359sub conn::item_update {
1360 my ($self, $item) = @_;
1361
1362 update_floorbox if $item->{container} == 0;
1259} 1363}
1260 1364
1261%SDL_CB = ( 1365%SDL_CB = (
1262 CFClient::SDL_QUIT => sub { 1366 CFClient::SDL_QUIT => sub {
1263 Event::unloop -1; 1367 Event::unloop -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines