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.176 by root, Mon Apr 24 10:19:40 2006 UTC vs.
Revision 1.191 by elmex, Fri Apr 28 05:17:24 2006 UTC

36 36
37use CFClient; 37use CFClient;
38use CFClient::UI; 38use CFClient::UI;
39use CFClient::MapWidget; 39use CFClient::MapWidget;
40 40
41$SIG{__DIE__} = sub { CFClient::fatal "$_[0]"; exit 1 }; 41$Event::DIED = sub {
42 CFClient::error $_[1];
43};
44
45#$SIG{__WARN__} = sub { Carp::cluck $_[0] };#d#
42 46
43our $VERSION = '0.1'; 47our $VERSION = '0.1';
44 48
45my $MAX_FPS = 60; 49my $MAX_FPS = 60;
46my $MIN_FPS = 5; # unused as of yet 50my $MIN_FPS = 5; # unused as of yet
66 70
67our $FONT_PROP; 71our $FONT_PROP;
68our $FONT_FIXED; 72our $FONT_FIXED;
69 73
70our $MAP; 74our $MAP;
75our $MAPMAP;
71our $MAPWIDGET; 76our $MAPWIDGET;
72our $BUTTONBAR; 77our $BUTTONBAR;
73our $LOGVIEW; 78our $LOGVIEW;
74our $CONSOLE; 79our $CONSOLE;
75our $METASERVER; 80our $METASERVER;
86our %AUDIO_CHUNKS; # audio files 91our %AUDIO_CHUNKS; # audio files
87 92
88our $ALT_ENTER_MESSAGE; 93our $ALT_ENTER_MESSAGE;
89our $STATUS_LINE; 94our $STATUS_LINE;
90our $DEBUG_STATUS; 95our $DEBUG_STATUS;
96
97our $INVWIN;
98our $INV;
91 99
92sub status { 100sub status {
93 $STATUS_LINE->set_text ($_[0]); 101 $STATUS_LINE->set_text ($_[0]);
94 $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});
95} 103}
309 audio_shutdown (); 317 audio_shutdown ();
310 audio_init (); 318 audio_init ();
311 } 319 }
312 ); 320 );
313 321
322 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Communication cmd");
323 $table->add (1, $row++, my $saycmd = new CFClient::UI::Entry
324 text => $CFG->{say_command},
325 tooltip => "This is the command that will be used if you write a line in the message window entry. "
326 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
327 ."But you could also set it to 'tell <playername>' to only chat with that user.",
328 connect_changed => sub {
329 my ($self, $value) = @_;
330 $CFG->{say_command} = $value;
331 }
332 );
333
314 $dialog 334 $dialog
315} 335}
316 336
317sub set_stats_window_fontsize { 337sub set_stats_window_fontsize {
318 for (values %{$STATWIDS}) { 338 for (values %{$STATWIDS}) {
351 (my $hb = new CFClient::UI::HBox), 371 (my $hb = new CFClient::UI::HBox),
352 ], 372 ],
353 ); 373 );
354 374
355 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp', 375 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp',
356 tooltip => "Health points - depletes when you get wounded, refills when you heal or idle"); 376 tooltip => "Health points. Measures of how much damage you can take before dying. Hit points are determined from your level and are influenced by the value of your Con. Hp value may range between 1 to beyond 500 and higher values indicate a greater ability to withstand punishment.");
357 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana', 377 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana',
358 tooltip => "Spell points - deplete when you cast wizard spells, refills when you idle"); 378 tooltip => "Spell points. Measures of how much \"fuel\" you have for casting spells and incantations. Mana is calculated from your level and your Pow. Mana values can range between 1 to beyond 500 (glowing crystals can increase the current spell points beyond your normal maximum). Higher values indicate greater amounts of mana.");
359 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace', 379 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace',
360 tooltip => "Grace points - deplete when you cast priest spells, refills when you pray"); 380 tooltip => "Grace points - how favored you are by your god. In game terms, how much divine magic you can cast. Your level, Wis and Pow effect what the value of grace is. Prayong on an altar of your god can increase this value beyond your normal maximum. Grace can take on large positive and negative values. Positive values indicate favor by the gods.");
361 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food', 381 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food',
362 tooltip => "Food - depletes with time, faster when you heal or build mana, refills when you eat healthy food"); 382 tooltip => "Food. Ranges between 0 (starving) and 999 (satiated). At a value of 0 the character begins to die. Some magic can speed up or slow down the character digestion. Healing wounds will speed up digestion too.");
363 383
364 $vbox->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, 384 $vbox->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1,
365 tooltip => "Experience points and level - increases when you kill monsters or successfully use skills"); 385 tooltip => "Experience points and overall level - experience is increased as a reward for appropriate action (such as killing monsters) and may decrease as a result of a magical attack or dying. Level is directly derived from the experience value. As the level of the character increases, the character becomes able to succeed at more difficult tasks. A character's level starts at a value of 0 and may range up beyond 100.");
366 $vbox->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, 386 $vbox->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1,
367 tooltip => "Ranged attack - how you attack when you press shift-cursor (spell, skill, weapon etc.)"); 387 tooltip => "Ranged attack - how you attack when you press shift-cursor (spell, skill, weapon etc.)");
368 388
369 $GAUGES = { 389 $GAUGES = {
370 exp => $exp, win => $win, range => $rng, 390 exp => $exp, win => $win, range => $rng,
375 395
376 $win 396 $win
377} 397}
378 398
379sub make_stats_window { 399sub make_stats_window {
380 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats"); 400 my $tgw = new CFClient::UI::FancyFrame x => $WIDTH * 2/5, y => 0, title => "Stats";
381 401
382 $tgw->add (my $vb = new CFClient::UI::VBox); 402 $tgw->add (new CFClient::UI::Window child => my $vb = new CFClient::UI::VBox);
383 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1); 403 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1);
384 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1); 404 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1);
385 405
386 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 406 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
387 407
388 $hb->add (my $tbl = new CFClient::UI::Table expand => 1); 408 $hb->add (my $tbl = new CFClient::UI::Table expand => 1);
389 409
390 my $black = [0, 0, 0]; 410 my $black = [0, 0, 0];
391 411
392 $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 412 for (
393 $tbl->add (0, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 413 [0, 0, st_str => "Str", 30, "Physical Strength, determines damage dealt with weapons, how much you can carry, and how often you can attack"],
394 $tbl->add (0, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 414 [0, 1, st_dex => "Dex", 30, "Dexterity, your physical agility. Determines chance of being hit and affects armor class and speed"],
395 $tbl->add (0, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 415 [0, 2, st_con => "Con", 30, "Constitution, physical health and toughness. Determines how many healthpoints you can have"],
396 $tbl->add (0, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 416 [0, 3, st_int => "Int", 30, "Intelligence, your ability to learn and use skills and incantations (both prayers and magic) and determines how much spell points you can have"],
397 $tbl->add (0, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 417 [0, 4, st_wis => "Wis", 30, "Wisdom, the ability to learn and use divine magic (prayers). Determines how many grace points you can have"],
398 $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 418 [0, 5, st_pow => "Pow", 30, "Power, your magical potential. Influences the strength of spell effects, and also how much your spell and grace points increase when leveling up"],
419 [0, 6, st_cha => "Cha", 30, "Charisma, how well you are received by NPCs. Affects buying and selling prices in shops."],
399 420
400 $tbl->add (1, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Str"); 421 [2, 0, st_wc => "Wc", -120, "Weapon Class, effectiveness of melee/missile attacks. Lower is more potent. Current weapon, level and Str are some things which effect the value of Wc. The value of Wc may range between 25 and -72."],
401 $tbl->add (1, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Dex"); 422 [2, 1, st_ac => "Ac", -120, "Armour Class, how protected you are from being hit by any attack. Lower values are better. Ac is based on your race and is modified by the Dex and current armour worn. For characters that cannot wear armour, Ac improves as their level increases."],
402 $tbl->add (1, 2, $STATWIDS->{st_con_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Con"); 423 [2, 2, st_dam => "Dam", 120, "Damage, how much damage your melee/missile attack inflicts. Higher values indicate a greater amount of damage will be inflicted with each attack."],
403 $tbl->add (1, 3, $STATWIDS->{st_int_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Int"); 424 [2, 3, st_arm => "Arm", 120, "Armour, how much damage (from physical attacks) will be subtracted from successful hits made upon you. This value ranges between 0 to 99%. Current armour worn primarily determines Arm value."],
404 $tbl->add (1, 4, $STATWIDS->{st_wis_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Wis"); 425 [2, 4, st_spd => "Spd", 10.54, "Speed, how fast you can move. The value of speed may range between nearly 0 (\"very slow\") to higher than 5 (\"lightning fast\"). Base speed is determined from the Dex and modified downward proportionally by the amount of weight carried which exceeds the Max Carry limit. The armour worn also sets the upper limit on speed."],
405 $tbl->add (1, 5, $STATWIDS->{st_pow_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Pow"); 426 [2, 5, st_wspd => "WSp", 10.54, "Weapon Speed, how many attacks you may make per unit of time (0.120s). Higher values indicate faster attack speed. Current weapon and Dex effect the value of weapon speed."],
406 $tbl->add (1, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Cha"); 427 ) {
428 my ($col, $row, $id, $label, $template, $tooltip) = @$_;
407 429
408 $tbl->add (2, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, template => "-120"); 430 $tbl->add ($col , $row, $STATWIDS->{$id} = new CFClient::UI::Label
409 $tbl->add (2, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => +1, template => "-120"); 431 font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, align => +1, template => $template, tooltip => $tooltip);
410 $tbl->add (2, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => +1, template => "120"); 432 $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFClient::UI::Label
411 $tbl->add (2, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => +1, template => "120"); 433 font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $black, valign => 0, align => -1, text => $label, tooltip => $tooltip);
412 $tbl->add (2, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => +1, template => "10.54"); 434 }
413 $tbl->add (2, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, template => "9");
414
415 $tbl->add (3, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Wc");
416 $tbl->add (3, 1, $STATWIDS->{st_ac_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Ac");
417 $tbl->add (3, 2, $STATWIDS->{st_dam_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Dam");
418 $tbl->add (3, 3, $STATWIDS->{st_arm_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Arm");
419 $tbl->add (3, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Sp");
420 $tbl->add (3, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "WSp");
421 435
422 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); 436 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1);
423 437
424 my $row = 0; 438 my $row = 0;
425 my $col = 0; 439 my $col = 0;
426 440
427 my %resist_names = ( 441 my %resist_names = (
428 slow => "Slow", 442 slow => "Slow (slows you down when you are hit by the spell. Monsters will have an opportunity to come near you faster and hit you more often.)",
429 holyw => "Holy Word", 443 holyw => "Holy Word (resistance you against getting the fear when someone whose god doesn't like you spells the holy word on you.)",
430 conf => "Confusion", 444 conf => "Confusion (If you are hit by confusion you will move into random directions, and likely into monsters.)",
431 fire => "Fire", 445 fire => "Fire (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)",
432 depl => "Depletion", 446 depl => "Depletion (some monsters and other effects can cause stats depletion)",
433 magic => "Magic", 447 magic => "Magic (resistance to magic spells like magic missile or similar)",
434 drain => "Draining", 448 drain => "Draining (some monsters (e.g. vampires) and other effects can steal experience)",
435 acid => "Acid", 449 acid => "Acid (resistance to acid, acid hurts pretty much and also corrodes your weapons)",
436 pois => "Poison", 450 pois => "Poison (resistance to getting poisoned)",
437 para => "Paralysation", 451 para => "Paralysation (this resistance affects the chance you get paralysed)",
438 deat => "Death", 452 deat => "Death (resistance against death spells)",
439 phys => "Physical", 453 phys => "Physical (this is the resistance against physical attacks, like when a monster hit you in melee combat)",
440 blind => "Blind", 454 blind => "Blind (blind resistance affects the chance of a successful blinding attack)",
441 fear => "Fear", 455 fear => "Fear (this attack will drive you away from monsters who cast this and hit you successfully, being resistant to this helps a lot when fighting those monsters)",
442 tund => "Turn undead", 456 tund => "Turn undead",
443 elec => "Electricity", 457 elec => "Electricity (resistance againt electricity, spells like large lightning, small lightning, ...)",
444 cold => "Cold", 458 cold => "Cold (this is your resistance against cold spells like icestorm, snowstorm, ...)",
445 ghit => "Ghost hit", 459 ghit => "Ghost hit (special attack used by ghosts and ghost-like beings)",
446 ); 460 );
447 for (qw/slow holyw conf fire depl magic 461 for (qw/slow holyw conf fire depl magic
448 drain acid pois para deat phys 462 drain acid pois para deat phys
449 blind fear tund elec cold ghit/) 463 blind fear tund elec cold ghit/)
450 { 464 {
451 $tbl2->add ($col, $row, 465 $tbl2->add ($col, $row,
452 $STATWIDS->{"res_$_"} = 466 $STATWIDS->{"res_$_"} =
453 new CFClient::UI::Label 467 new CFClient::UI::Label
468 font => $FONT_FIXED,
454 template => "-100%", 469 template => "-100%",
455 align => +1, 470 align => +1,
456 valign => 0, 471 valign => 0,
472 can_events => 1,
473 can_hover => 1,
457 tooltip => $resist_names{$_} 474 tooltip => $resist_names{$_},
458 ); 475 );
459 $tbl2->add ($col + 1, $row, new CFClient::UI::Image 476 $tbl2->add ($col + 1, $row, new CFClient::UI::Image
477 font => $FONT_FIXED,
460 can_hover => 1, 478 can_hover => 1,
461 can_events => 1, 479 can_events => 1,
462 image => "ui/resist/resist_$_.png", 480 image => "ui/resist/resist_$_.png",
463 tooltip => $resist_names{$_} 481 tooltip => $resist_names{$_},
464 ); 482 );
465 483
466 $row++; 484 $row++;
467 if ($row % 6 == 0) { 485 if ($row % 6 == 0) {
468 $col += 2; 486 $col += 2;
555 $vbox->add ($dialog->{table} = new CFClient::UI::Table); 573 $vbox->add ($dialog->{table} = new CFClient::UI::Table);
556 574
557 $dialog 575 $dialog
558} 576}
559 577
578my $METASERVER_ATIME;
579
560sub update_metaserver { 580sub update_metaserver {
561 my ($HOST) = @_; 581 my ($HOST) = @_;
562 582
563 status "fetching metaserver list..."; 583 return if $METASERVER_ATIME > time;
584 $METASERVER_ATIME = time + 60;
585
586 my $table = $METASERVER->{table};
587 $table->clear;
588 $table->add (0, 0, my $label = new CFClient::UI::Label max_w => $WIDTH * 0.8, text => "fetching server list...");
564 589
565 my $buf; 590 my $buf;
566 591
567 my $fh = new IO::Socket::INET PeerHost => $META_SERVER, Blocking => 0; 592 my $fh = new IO::Socket::INET PeerHost => $META_SERVER, Blocking => 0;
593
594 unless ($fh) {
595 $label->set_text ("unable to contact metaserver: $!");
596 return;
597 }
568 598
569 Event->io (fd => $fh, poll => 'r', cb => sub { 599 Event->io (fd => $fh, poll => 'r', cb => sub {
570 my $res = sysread $fh, $buf, 8192, length $buf; 600 my $res = sysread $fh, $buf, 8192, length $buf;
571 601
572 if (!defined $res) { 602 if (!defined $res) {
573 $_[0]->w->cancel; 603 $_[0]->w->cancel;
574 status "metaserver: $!"; 604 $label->set_text ("error while retrieving server list: $!");
575 } elsif ($res == 0) { 605 } elsif ($res == 0) {
576 $_[0]->w->cancel; 606 $_[0]->w->cancel;
577 status "server list retrieved"; 607 status "server list retrieved";
578 608
579 my $table = $METASERVER->{table}; 609 utf8::decode $buf if utf8::valid $buf;
580 610
581 $table->clear; 611 $table->clear;
582 612
583 my @col = qw(Use #Users Host Uptime Version Description); 613 my @col = qw(Use #Users Host Uptime Version Description);
584 $table->add ($_, 0, new CFClient::UI::Label align => 0, fg => [1, 1, 0], text => $col[$_]) 614 $table->add ($_, 0, new CFClient::UI::Label align => 0, fg => [1, 1, 0], text => $col[$_])
608 $m = [$users, $host, $uptime, $version, $desc]; 638 $m = [$users, $host, $uptime, $version, $desc];
609 639
610 $y++; 640 $y++;
611 641
612 $table->add (0, $y, new CFClient::UI::VBox children => [ 642 $table->add (0, $y, new CFClient::UI::VBox children => [
613 (new CFClient::UI::Button text => " ", connect_activate => sub { 643 (new CFClient::UI::Button text => "Use", connect_activate => sub {
614 $HOST->set_text ($CFG->{host} = $host); 644 $HOST->set_text ($CFG->{host} = $host);
615 }), 645 }),
616 (new CFClient::UI::Empty expand => 1), 646 (new CFClient::UI::Empty expand => 1),
617 ]); 647 ]);
618 648
677 my ($self, $value) = @_; 707 my ($self, $value) = @_;
678 $CFG->{password} = $value; 708 $CFG->{password} = $value;
679 } 709 }
680 ); 710 );
681 711
682 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd");
683 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry
684 text => $CFG->{say_command},
685 tooltip => "This is the command that will be used if you write a line in the message window entry. "
686 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
687 ."But you could also set it to 'tell <playername>' to only chat with that user.",
688 connect_changed => sub {
689 my ($self, $value) = @_;
690 $CFG->{say_command} = $value;
691 }
692 );
693
694 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); 712 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
695 $table->add (1, 7, new CFClient::UI::Slider 713 $table->add (1, 7, new CFClient::UI::Slider
696 req_w => 100, 714 req_w => 100,
697 range => [$CFG->{mapsize}, 10, 100 + 1, 1], 715 range => [$CFG->{mapsize}, 10, 100 + 1, 1],
698 tooltip => "This is the size of the portion of the map update the server sends you. " 716 tooltip => "This is the size of the portion of the map update the server sends you. "
712} 730}
713 731
714sub message_window { 732sub message_window {
715 my $window = new CFClient::UI::FancyFrame 733 my $window = new CFClient::UI::FancyFrame
716 title => "Messages", 734 title => "Messages",
717 border_bg => [1, 1, 1, 0.5], 735 border_bg => [1, 1, 1, 1],
718 bg => [0.3, 0.3, 0.3, 0.8], 736 bg => [0, 0, 0, 0.5],
719 user_w => int $::WIDTH / 3, 737 user_w => int $::WIDTH / 3,
720 user_h => int $::HEIGHT / 5, 738 user_h => int $::HEIGHT / 5,
721 child => (my $vbox = new CFClient::UI::VBox); 739 child => (my $vbox = new CFClient::UI::VBox);
722 740
723 $vbox->add ($LOGVIEW = new CFClient::UI::TextView 741 $vbox->add ($LOGVIEW = new CFClient::UI::TextView
763 }; 781 };
764 782
765 $window 783 $window
766} 784}
767 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
768sub sdl_init { 795sub sdl_init {
769 CFClient::SDL_Init 796 CFClient::SDL_Init
770 and die "SDL::Init failed!\n"; 797 and die "SDL::Init failed!\n";
771} 798}
772 799
803 fontsize => 0.8, 830 fontsize => 0.8,
804 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 831 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
805 $ALT_ENTER_MESSAGE->show; 832 $ALT_ENTER_MESSAGE->show;
806 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); 833 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h});
807 834
808 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::MapWidget); 835 CFClient::UI::FancyFrame->new (
809 $MAPWIDGET->focus_in; 836 border_bg => [1, 1, 1, 192/255],
837 bg => [1, 1, 1, 0],
838 child => ($MAPMAP = new CFClient::MapWidget::MapMap),
839 )->show;
840
841 $MAPWIDGET = new CFClient::MapWidget;
810 $MAPWIDGET->connect (activate_console => sub { 842 $MAPWIDGET->connect (activate_console => sub {
811 my ($mapwidget, $preset) = @_; 843 my ($mapwidget, $preset) = @_;
812 844
813 if ($CONSOLE) { 845 if ($CONSOLE) {
814 $CONSOLE->{input}->{auto_activated} = 1; 846 $CONSOLE->{input}->{auto_activated} = 1;
817 if ($preset && $CONSOLE->{input}->get_text eq '') { 849 if ($preset && $CONSOLE->{input}->get_text eq '') {
818 $CONSOLE->{input}->set_text ($preset); 850 $CONSOLE->{input}->set_text ($preset);
819 } 851 }
820 } 852 }
821 }); 853 });
854 $MAPWIDGET->show;
855 $MAPWIDGET->focus_in;
822 856
823 $CFClient::UI::ROOT->add ($BUTTONBAR = new CFClient::UI::HBox); 857 $BUTTONBAR = new CFClient::UI::HBox;
824 858
825 $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);
826 $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);
827 $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);
828 862
829 $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
830 $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);
831 866
832 $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 {
833 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 868 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
834 status "Configuration Saved"; 869 status "Configuration Saved";
835 }); 870 });
836 871
872 $BUTTONBAR->show;
873
837 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 874 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
838} 875}
839 876
840sub video_shutdown { 877sub video_shutdown {
841 $CFClient::UI::ROOT->{children} = []; 878 $CFClient::UI::ROOT->{children} = [];
879 undef $CFClient::UI::GRAB;
880 undef $CFClient::UI::HOVER;
842 undef $SDL_ACTIVE; 881 undef $SDL_ACTIVE;
843} 882}
844 883
845my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d# 884my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d#
846my $bgmusic;#TODO#hack#d# 885my $bgmusic;#TODO#hack#d#
1020# at worst. 1059# at worst.
1021sub conn::flood_fill { 1060sub conn::flood_fill {
1022 my ($self, $gx, $gy, $path, $hash, $flags) = @_; 1061 my ($self, $gx, $gy, $path, $hash, $flags) = @_;
1023 1062
1024 # the server does not allow map paths > 6 1063 # the server does not allow map paths > 6
1025 return if 6 <= length $path; 1064 return if 7 <= length $path;
1026 1065
1027 my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; 1066 my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}};
1028 1067
1029 for ( 1068 for (
1030 [1, 0, -1], 1069 [1, 0, -1],
1073 1112
1074 $self->flush_map; 1113 $self->flush_map;
1075 1114
1076 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 1115 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
1077 1116
1078 my $mapmapw = 250; 1117 my $mapmapw = $MAPMAP->{w};
1079 my $mapmaph = 250; 1118 my $mapmaph = $MAPMAP->{h};
1080 1119
1081 $self->{neigh_rect} = [ 1120 $self->{neigh_rect} = [
1082 $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, 1121 $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5,
1083 $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, 1122 $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h,
1084 ]; 1123 ];
1307 if ($ev->{button} == 1) { 1346 if ($ev->{button} == 1) {
1308 $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0"); 1347 $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0");
1309 } elsif ($ev->{button} == 2) { 1348 } elsif ($ev->{button} == 2) {
1310 $CONN->send ("apply $item->{tag}"); 1349 $CONN->send ("apply $item->{tag}");
1311 } elsif ($ev->{button} == 3) { 1350 } elsif ($ev->{button} == 3) {
1312 # examine, lock, mark, maybe other things 1351 CFClient::UI::Menu->new (
1313 warn "MENU not implemented yet\n"; 1352 items => [
1353 ["examine", sub { $CONN->send ("examine $item->{tag}") }],
1354 [
1355 $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock",
1356 sub { $CONN->send ("lock $item->{tag}") },
1357 ],
1358 ["mark", sub { $CONN->send ("mark $item->{tag}") }],
1359 ["apply", sub { $CONN->send ("apply $item->{tag}") }],
1360 ],
1361 )->popup ($ev);
1314 } 1362 }
1315 1363
1316 1 1364 1
1317 }, 1365 },
1318 ); 1366 );
1335 1383
1336sub conn::container_add { 1384sub conn::container_add {
1337 my ($self, $id, $items) = @_; 1385 my ($self, $id, $items) = @_;
1338 1386
1339 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 }
1340 # $self-<{player}{tag} => player inv 1391 # $self-<{player}{tag} => player inv
1341 #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}};
1342} 1393}
1343 1394
1344sub conn::container_clear { 1395sub conn::container_clear {
1345 my ($self, $id) = @_; 1396 my ($self, $id) = @_;
1346 1397
1347 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
1348# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; 1403# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1349} 1404}
1350 1405
1351sub conn::item_delete { 1406sub conn::item_delete {
1352 my ($self, @items) = @_; 1407 my ($self, @items) = @_;
1353 1408
1354 for (@items) { 1409 for (@items) {
1355 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 }
1356 } 1414 }
1357} 1415}
1358 1416
1359sub conn::item_update { 1417sub conn::item_update {
1360 my ($self, $item) = @_; 1418 my ($self, $item) = @_;
1361 1419
1362 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 }
1363} 1424}
1364 1425
1365%SDL_CB = ( 1426%SDL_CB = (
1366 CFClient::SDL_QUIT => sub { 1427 CFClient::SDL_QUIT => sub {
1367 Event::unloop -1; 1428 Event::unloop -1;
1460 1521
1461Event::loop; 1522Event::loop;
1462 1523
1463END { CFClient::SDL_Quit } 1524END { CFClient::SDL_Quit }
1464 1525
1526=head1 pclient - Crossfire+ and Crossfire game client
1465 1527
1528Pclient is a Crossfire+ and Crossfire game client.
1529
1530=head2 Features
1531
1532=over 4
1533
1534=item Fullscreen Map
1535
1536PClient can uses a fullscreen map, which greatly enhances how much of the
1537game world you can see.
1538
1539=item Persistent Map Cache (Crossfire+ only)
1540
1541PClient can persistently cache all map data it received from the
1542server. This not only allows it to display an overview map, but also
1543ensures that once-explored areas will be available the next time you want
1544to explore more.
1545
1546=item Hardware acceleration
1547
1548Unlike most Crossfire clients, PClient take advantage of OpenGL hardware
1549acceleration. Most modern graphics cards have difficulties with 2D
1550acceleration, while 3D graphics is accelerated well.
1551
1552=item No arbitrary limits
1553
1554Unlike other Crossfire clients, pclient does not suffer from arbitrary
1555limits (like a fixed amount of face numbers). There are still limits, but
1556they are not arbitrarily low :)
1557
1558=back
1559
1560=head1 USAGE
1561
1562=head2 The Map
1563
1564The map is always displayed in the background, behind all other windows and UI elements.
1565
1566#TODO# middle-click scrolls
1567#
1568# keys:
1569#
1570# a apply
1571# keypad moves, kp_5 applies ranged attack to self
1572
1573Starting to type enters the I<completion mode>. In that mode, you can type
1574abbreviations or commands and have them executed as soon as they match a
1575valid command. This is best explained by a few examples:
1576
1577Typing B<climb> will display a list of commands with I<climb> in their
1578name, such as I<ready_skill climbing> and I<use_skill climbing>.
1579
1580You can abbreviate commands by typing only the first character of every
1581word. For example, typing I<iwor> will likely select I<invoke word of
1582recall>, while I<ccfo> will select I<cast create food>. Likewise, I<rscli>
1583will likely select I<ready_skill climbing> and I<usl> will give you
1584I<use_skill levitation>.
1585
1586=head2 The map overview
1587
1588#TODO#
1589
1590=head2 The Status area in the lower right corner
1591
1592#TODO#
1593
1594=head2 The I<Statistics>/I>Stats> window
1595
1596#TODO#
1597
1598=head1 FAQ
1599
1600=over 4
1601
1602=item The client is very sluggish and slow, what can I do about this?
1603
1604Most likely, you don't have accelerated OpenGL support. Try to find a
1605newer driver, or a driver from your hardware vendor, that features OpenGL
1606support.
1607
1608If this is not an option, the following Setup options reduce the load and
1609will likely make the client playable with sofwtare rendering (it will
1610still be slow, though):
1611
1612=over 4
1613
1614=item B<Video Mode> should be set as low as possible (e.g. 640x480)
1615
1616=item Enable B<Fast & Ugly> mode
1617
1618=item Disable B<Fog of War>
1619
1620=item Increase B<Map Scale>
1621
1622=back
1623
1624=back
1625
1626=head1 AUTHOR
1627
1628Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org>
1629
1630
1631

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines