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.178 by root, Tue Apr 25 08:39:18 2006 UTC vs.
Revision 1.203 by root, Mon May 8 20:55:49 2006 UTC

70 70
71our $FONT_PROP; 71our $FONT_PROP;
72our $FONT_FIXED; 72our $FONT_FIXED;
73 73
74our $MAP; 74our $MAP;
75our $MAPMAP;
75our $MAPWIDGET; 76our $MAPWIDGET;
76our $BUTTONBAR; 77our $BUTTONBAR;
77our $LOGVIEW; 78our $LOGVIEW;
78our $CONSOLE; 79our $CONSOLE;
79our $METASERVER; 80our $METASERVER;
81our $LOGIN_BUTTON;
80 82
81our $FLOORBOX; 83our $FLOORBOX;
82our $GAUGES; 84our $GAUGES;
83our $STATWIDS; 85our $STATWIDS;
84 86
91 93
92our $ALT_ENTER_MESSAGE; 94our $ALT_ENTER_MESSAGE;
93our $STATUS_LINE; 95our $STATUS_LINE;
94our $DEBUG_STATUS; 96our $DEBUG_STATUS;
95 97
98our $INVWIN;
99our $INV;
100
96sub status { 101sub status {
97 $STATUS_LINE->set_text ($_[0]); 102 $STATUS_LINE->set_text ($_[0]);
98 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h}); 103 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h});
99} 104}
100 105
107 status "logging in..."; 112 status "logging in...";
108 113
109 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 114 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
110 115
111 $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}"; 116 $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}";
112
113 $MAP = new CFClient::Map $mapsize, $mapsize; 117 $MAP = new CFClient::Map $mapsize, $mapsize;
114 118
115 my ($host, $port) = split /:/, $CFG->{host}; 119 my ($host, $port) = split /:/, $CFG->{host};
116 120
117 $CONN = new conn 121 $CONN = eval {
122 new conn
118 host => $host, 123 host => $host,
119 port => $port || 13327, 124 port => $port || 13327,
120 user => $CFG->{user}, 125 user => $CFG->{user},
121 pass => $CFG->{password}, 126 pass => $CFG->{password},
122 mapw => $mapsize, 127 mapw => $mapsize,
123 maph => $mapsize, 128 maph => $mapsize,
129 ;
124 ; 130 };
125 131
132 if ($CONN) {
133 $LOGIN_BUTTON->set_text ("Logout");
134
126 status "login successful"; 135 status "login successful";
127 136
128 CFClient::lowdelay fileno $CONN->{fh}; 137 CFClient::lowdelay fileno $CONN->{fh};
138 } else {
139 status "unable to connect";
140 stop_game();
141 }
129} 142}
130 143
131sub stop_game { 144sub stop_game {
145 return unless $CONN;
146
147 status "connection closed";
148 $LOGIN_BUTTON->set_text ("Login");
149 $CONN->destroy;
150 $CONN = 0; # false, does not autovivify
151
152 undef $MAPCACHE;
132 undef $CONN; 153 undef $MAP;
133} 154}
134 155
135sub client_setup { 156sub client_setup {
136 my $dialog = new CFClient::UI::FancyFrame 157 my $dialog = new CFClient::UI::FancyFrame
137 title => "Client Setup", 158 title => "Client Setup",
313 audio_shutdown (); 334 audio_shutdown ();
314 audio_init (); 335 audio_init ();
315 } 336 }
316 ); 337 );
317 338
339 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Communication cmd");
340 $table->add (1, $row++, my $saycmd = new CFClient::UI::Entry
341 text => $CFG->{say_command},
342 tooltip => "This is the command that will be used if you write a line in the message window entry. "
343 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
344 ."But you could also set it to 'tell <playername>' to only chat with that user.",
345 connect_changed => sub {
346 my ($self, $value) = @_;
347 $CFG->{say_command} = $value;
348 }
349 );
350
318 $dialog 351 $dialog
319} 352}
320 353
321sub set_stats_window_fontsize { 354sub set_stats_window_fontsize {
322 for (values %{$STATWIDS}) { 355 for (values %{$STATWIDS}) {
355 (my $hb = new CFClient::UI::HBox), 388 (my $hb = new CFClient::UI::HBox),
356 ], 389 ],
357 ); 390 );
358 391
359 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp', 392 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp',
360 tooltip => "Health points - depletes when you get wounded, refills when you heal or idle"); 393 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.");
361 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana', 394 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana',
362 tooltip => "Spell points - deplete when you cast wizard spells, refills when you idle"); 395 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.");
363 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace', 396 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace',
364 tooltip => "Grace points - deplete when you cast priest spells, refills when you pray"); 397 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.");
365 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food', 398 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food',
366 tooltip => "Food - depletes with time, faster when you heal or build mana, refills when you eat healthy food"); 399 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.");
367 400
368 $vbox->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, 401 $vbox->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1,
369 tooltip => "Experience points and level - increases when you kill monsters or successfully use skills"); 402 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.");
370 $vbox->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, 403 $vbox->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1,
371 tooltip => "Ranged attack - how you attack when you press shift-cursor (spell, skill, weapon etc.)"); 404 tooltip => "Ranged attack - how you attack when you press shift-cursor (spell, skill, weapon etc.)");
372 405
373 $GAUGES = { 406 $GAUGES = {
374 exp => $exp, win => $win, range => $rng, 407 exp => $exp, win => $win, range => $rng,
379 412
380 $win 413 $win
381} 414}
382 415
383sub make_stats_window { 416sub make_stats_window {
384 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats"); 417 my $tgw = new CFClient::UI::FancyFrame x => $WIDTH * 2/5, y => 0, title => "Stats";
385 418
386 $tgw->add (my $vb = new CFClient::UI::VBox); 419 $tgw->add (new CFClient::UI::Window child => my $vb = new CFClient::UI::VBox);
387 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1); 420 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1);
388 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1); 421 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1);
389 422
390 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 423 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
391 424
392 $hb->add (my $tbl = new CFClient::UI::Table expand => 1); 425 $hb->add (my $tbl = new CFClient::UI::Table expand => 1);
393 426
394 my $black = [0, 0, 0]; 427 my $black = [0, 0, 0];
395 428
396 $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 429 for (
397 $tbl->add (0, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 430 [0, 0, st_str => "Str", 30, "Physical Strength, determines damage dealt with weapons, how much you can carry, and how often you can attack"],
398 $tbl->add (0, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 431 [0, 1, st_dex => "Dex", 30, "Dexterity, your physical agility. Determines chance of being hit and affects armor class and speed"],
399 $tbl->add (0, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 432 [0, 2, st_con => "Con", 30, "Constitution, physical health and toughness. Determines how many healthpoints you can have"],
400 $tbl->add (0, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 433 [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"],
401 $tbl->add (0, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 434 [0, 4, st_wis => "Wis", 30, "Wisdom, the ability to learn and use divine magic (prayers). Determines how many grace points you can have"],
402 $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); 435 [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"],
436 [0, 6, st_cha => "Cha", 30, "Charisma, how well you are received by NPCs. Affects buying and selling prices in shops."],
403 437
404 $tbl->add (1, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Str"); 438 [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."],
405 $tbl->add (1, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Dex"); 439 [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."],
406 $tbl->add (1, 2, $STATWIDS->{st_con_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Con"); 440 [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."],
407 $tbl->add (1, 3, $STATWIDS->{st_int_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Int"); 441 [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."],
408 $tbl->add (1, 4, $STATWIDS->{st_wis_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Wis"); 442 [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."],
409 $tbl->add (1, 5, $STATWIDS->{st_pow_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Pow"); 443 [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."],
410 $tbl->add (1, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Cha"); 444 ) {
445 my ($col, $row, $id, $label, $template, $tooltip) = @$_;
411 446
412 $tbl->add (2, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, template => "-120"); 447 $tbl->add ($col , $row, $STATWIDS->{$id} = new CFClient::UI::Label
413 $tbl->add (2, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => +1, template => "-120"); 448 font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, align => +1, template => $template, tooltip => $tooltip);
414 $tbl->add (2, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => +1, template => "120"); 449 $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFClient::UI::Label
415 $tbl->add (2, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => +1, template => "120"); 450 font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $black, valign => 0, align => -1, text => $label, tooltip => $tooltip);
416 $tbl->add (2, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => +1, template => "10.54"); 451 }
417 $tbl->add (2, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, template => "9");
418
419 $tbl->add (3, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Wc");
420 $tbl->add (3, 1, $STATWIDS->{st_ac_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Ac");
421 $tbl->add (3, 2, $STATWIDS->{st_dam_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Dam");
422 $tbl->add (3, 3, $STATWIDS->{st_arm_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Arm");
423 $tbl->add (3, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Sp");
424 $tbl->add (3, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "WSp");
425 452
426 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); 453 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1);
427 454
428 my $row = 0; 455 my $row = 0;
429 my $col = 0; 456 my $col = 0;
430 457
431 my %resist_names = ( 458 my %resist_names = (
432 slow => "Slow", 459 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.)",
433 holyw => "Holy Word", 460 holyw => "Holy Word (resistance you against getting the fear when someone whose god doesn't like you spells the holy word on you.)",
434 conf => "Confusion", 461 conf => "Confusion (If you are hit by confusion you will move into random directions, and likely into monsters.)",
435 fire => "Fire", 462 fire => "Fire (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)",
436 depl => "Depletion", 463 depl => "Depletion (some monsters and other effects can cause stats depletion)",
437 magic => "Magic", 464 magic => "Magic (resistance to magic spells like magic missile or similar)",
438 drain => "Draining", 465 drain => "Draining (some monsters (e.g. vampires) and other effects can steal experience)",
439 acid => "Acid", 466 acid => "Acid (resistance to acid, acid hurts pretty much and also corrodes your weapons)",
440 pois => "Poison", 467 pois => "Poison (resistance to getting poisoned)",
441 para => "Paralysation", 468 para => "Paralysation (this resistance affects the chance you get paralysed)",
442 deat => "Death", 469 deat => "Death (resistance against death spells)",
443 phys => "Physical", 470 phys => "Physical (this is the resistance against physical attacks, like when a monster hit you in melee combat)",
444 blind => "Blind", 471 blind => "Blind (blind resistance affects the chance of a successful blinding attack)",
445 fear => "Fear", 472 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)",
446 tund => "Turn undead", 473 tund => "Turn undead",
447 elec => "Electricity", 474 elec => "Electricity (resistance againt electricity, spells like large lightning, small lightning, ...)",
448 cold => "Cold", 475 cold => "Cold (this is your resistance against cold spells like icestorm, snowstorm, ...)",
449 ghit => "Ghost hit", 476 ghit => "Ghost hit (special attack used by ghosts and ghost-like beings)",
450 ); 477 );
451 for (qw/slow holyw conf fire depl magic 478 for (qw/slow holyw conf fire depl magic
452 drain acid pois para deat phys 479 drain acid pois para deat phys
453 blind fear tund elec cold ghit/) 480 blind fear tund elec cold ghit/)
454 { 481 {
455 $tbl2->add ($col, $row, 482 $tbl2->add ($col, $row,
456 $STATWIDS->{"res_$_"} = 483 $STATWIDS->{"res_$_"} =
457 new CFClient::UI::Label 484 new CFClient::UI::Label
485 font => $FONT_FIXED,
458 template => "-100%", 486 template => "-100%",
459 align => +1, 487 align => +1,
460 valign => 0, 488 valign => 0,
489 can_events => 1,
490 can_hover => 1,
461 tooltip => $resist_names{$_} 491 tooltip => $resist_names{$_},
462 ); 492 );
463 $tbl2->add ($col + 1, $row, new CFClient::UI::Image 493 $tbl2->add ($col + 1, $row, new CFClient::UI::Image
494 font => $FONT_FIXED,
464 can_hover => 1, 495 can_hover => 1,
465 can_events => 1, 496 can_events => 1,
466 image => "ui/resist/resist_$_.png", 497 image => "ui/resist/resist_$_.png",
467 tooltip => $resist_names{$_} 498 tooltip => $resist_names{$_},
468 ); 499 );
469 500
470 $row++; 501 $row++;
471 if ($row % 6 == 0) { 502 if ($row % 6 == 0) {
472 $col += 2; 503 $col += 2;
551 582
552} 583}
553 584
554sub metaserver_dialog { 585sub metaserver_dialog {
555 my $dialog = new CFClient::UI::FancyFrame 586 my $dialog = new CFClient::UI::FancyFrame
556 title => "Metaserver", 587 title => "Server List",
557 child => (my $vbox = new CFClient::UI::VBox); 588 child => (my $vbox = new CFClient::UI::VBox);
558 589
559 $vbox->add ($dialog->{table} = new CFClient::UI::Table); 590 $vbox->add ($dialog->{table} = new CFClient::UI::Table);
560 591
561 $dialog 592 $dialog
562} 593}
594
595my $METASERVER_ATIME;
563 596
564sub update_metaserver { 597sub update_metaserver {
565 my ($HOST) = @_; 598 my ($HOST) = @_;
566 599
600 return if $METASERVER_ATIME > time;
601 $METASERVER_ATIME = time + 60;
602
567 my $table = $METASERVER->{table}; 603 my $table = $METASERVER->{table};
568 $table->clear; 604 $table->clear;
569 $table->add (0, 0, my $label = new CFClient::UI::Label max_w => $WIDTH * 0.8, text => "fetching metaserver list..."); 605 $table->add (0, 0, my $label = new CFClient::UI::Label max_w => $WIDTH * 0.8, text => "fetching server list...");
570 606
571 my $buf; 607 my $buf;
572 608
573 my $fh = new IO::Socket::INET PeerHost => $META_SERVER, Blocking => 0; 609 my $fh = new IO::Socket::INET PeerHost => $META_SERVER, Blocking => 0;
574 610
658 694
659 $METASERVER = metaserver_dialog; 695 $METASERVER = metaserver_dialog;
660 696
661 $vbox->add (new CFClient::UI::Flopper 697 $vbox->add (new CFClient::UI::Flopper
662 expand => 1, 698 expand => 1,
663 text => "Metaserver", 699 text => "Server List",
664 other => $METASERVER, 700 other => $METASERVER,
665 tooltip => "Show a list of avaible crossfire servers", 701 tooltip => "Show a list of available crossfire servers",
666 connect_open => sub { 702 connect_open => sub {
667 update_metaserver $HOST; 703 update_metaserver $HOST;
668 } 704 }
669 ); 705 );
670 } 706 }
685 hidden => 1, 721 hidden => 1,
686 tooltip => "The password for your character", 722 tooltip => "The password for your character",
687 connect_changed => sub { 723 connect_changed => sub {
688 my ($self, $value) = @_; 724 my ($self, $value) = @_;
689 $CFG->{password} = $value; 725 $CFG->{password} = $value;
690 }
691 );
692
693 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd");
694 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry
695 text => $CFG->{say_command},
696 tooltip => "This is the command that will be used if you write a line in the message window entry. "
697 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
698 ."But you could also set it to 'tell <playername>' to only chat with that user.",
699 connect_changed => sub {
700 my ($self, $value) = @_;
701 $CFG->{say_command} = $value;
702 } 726 }
703 ); 727 );
704 728
705 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); 729 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
706 $table->add (1, 7, new CFClient::UI::Slider 730 $table->add (1, 7, new CFClient::UI::Slider
713 737
714 $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 738 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
715 }, 739 },
716 ); 740 );
717 741
718 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { 742 $table->add (1, 8, $LOGIN_BUTTON = new CFClient::UI::Button
743 expand => 1,
744 align => 0,
745 text => "Login",
746 connect_activate => sub {
747 $CONN ? stop_game
719 start_game; 748 : start_game;
749 },
720 }); 750 );
721 751
722 $dialog 752 $dialog
723} 753}
724 754
725sub message_window { 755sub message_window {
726 my $window = new CFClient::UI::FancyFrame 756 my $window = new CFClient::UI::FancyFrame
727 title => "Messages", 757 title => "Messages",
728 border_bg => [1, 1, 1, 0.5], 758 border_bg => [1, 1, 1, 1],
729 bg => [0.3, 0.3, 0.3, 0.8], 759 bg => [0, 0, 0, 0.5],
730 user_w => int $::WIDTH / 3, 760 user_w => int $::WIDTH / 3,
731 user_h => int $::HEIGHT / 5, 761 user_h => int $::HEIGHT / 5,
732 child => (my $vbox = new CFClient::UI::VBox); 762 child => (my $vbox = new CFClient::UI::VBox);
733 763
734 $vbox->add ($LOGVIEW = new CFClient::UI::TextView 764 $vbox->add ($LOGVIEW = new CFClient::UI::TextView
774 }; 804 };
775 805
776 $window 806 $window
777} 807}
778 808
809sub make_inventory_window {
810 my $invwin = new CFClient::UI::FancyFrame user_w => 300, user_h => 300, title => "Inventory";
811 $invwin->add ($INV = new CFClient::UI::Inventory expand => 1);
812 $invwin
813}
814
779sub sdl_init { 815sub sdl_init {
780 CFClient::SDL_Init 816 CFClient::SDL_Init
781 and die "SDL::Init failed!\n"; 817 and die "SDL::Init failed!\n";
782} 818}
783 819
784sub video_init { 820sub video_init {
785 sdl_init; 821 sdl_init;
786 822
823 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES;
824
787 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 825 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
788 $FULLSCREEN = $CFG->{fullscreen}; 826 $FULLSCREEN = $CFG->{fullscreen};
789 $FAST = $CFG->{fast}; 827 $FAST = $CFG->{fast};
790 828
791 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN 829 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN
792 or die "SDL_SetVideoMode failed!\n"; 830 or die "SDL_SetVideoMode failed!\n";
793 831
794 $SDL_ACTIVE = 1; 832 $SDL_ACTIVE = 1;
795
796 $LAST_REFRESH = time - 0.01; 833 $LAST_REFRESH = time - 0.01;
797 834
798 CFClient::gl_init; 835 CFClient::gl_init;
799 836
800 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; 837 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
801 838
839 $CFClient::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d#
840
802 ############################################################################# 841 #############################################################################
803 842
843 if ($DEBUG_STATUS) {
844 # reconfigure all widgets
845 $CFClient::UI::ROOT->reconfigure;
846
847 } else {
848 # create the widgets
849
804 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; 850 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100;
805 $DEBUG_STATUS->show; 851 $DEBUG_STATUS->show;
806 852
807 $STATUS_LINE = new CFClient::UI::Label 853 $STATUS_LINE = new CFClient::UI::Label
808 padding => 0, 854 padding => 0,
809 y => $HEIGHT - $FONTSIZE * 1.8; 855 y => $HEIGHT - $FONTSIZE * 1.8;
810 $STATUS_LINE->show; 856 $STATUS_LINE->show;
811 857
812 $ALT_ENTER_MESSAGE = new CFClient::UI::Label 858 $ALT_ENTER_MESSAGE = new CFClient::UI::Label
813 padding => 0, 859 padding => 0,
814 fontsize => 0.8, 860 fontsize => 0.8,
815 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 861 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
816 $ALT_ENTER_MESSAGE->show; 862 $ALT_ENTER_MESSAGE->show;
817 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); 863 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h});
818 864
819 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::MapWidget); 865 CFClient::UI::FancyFrame->new (
820 $MAPWIDGET->focus_in; 866 border_bg => [1, 1, 1, 192/255],
867 bg => [1, 1, 1, 0],
868 child => ($MAPMAP = new CFClient::MapWidget::MapMap),
869 )->show;
870
871 $MAPWIDGET = new CFClient::MapWidget;
821 $MAPWIDGET->connect (activate_console => sub { 872 $MAPWIDGET->connect (activate_console => sub {
822 my ($mapwidget, $preset) = @_; 873 my ($mapwidget, $preset) = @_;
823 874
824 if ($CONSOLE) { 875 if ($CONSOLE) {
825 $CONSOLE->{input}->{auto_activated} = 1; 876 $CONSOLE->{input}->{auto_activated} = 1;
826 $CONSOLE->{input}->focus_in; 877 $CONSOLE->{input}->focus_in;
827 878
828 if ($preset && $CONSOLE->{input}->get_text eq '') { 879 if ($preset && $CONSOLE->{input}->get_text eq '') {
829 $CONSOLE->{input}->set_text ($preset); 880 $CONSOLE->{input}->set_text ($preset);
881 }
830 } 882 }
831 } 883 });
832 }); 884 $MAPWIDGET->show;
885 $MAPWIDGET->focus_in;
833 886
834 $CFClient::UI::ROOT->add ($BUTTONBAR = new CFClient::UI::HBox); 887 $BUTTONBAR = new CFClient::UI::HBox;
835 888
836 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); 889 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup);
837 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); 890 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup);
838 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); 891 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window);
839 892
840 $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 893 make_gauge_window->show; # 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
894
841 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); 895 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window);
896 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window);
842 897
843 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { 898 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub {
844 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 899 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
845 status "Configuration Saved"; 900 status "Configuration Saved";
846 }); 901 });
847 902
903 $BUTTONBAR->show;
904
848 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 905 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
906 }
849} 907}
850 908
851sub video_shutdown { 909sub video_shutdown {
852 $CFClient::UI::ROOT->{children} = [];
853 undef $CFClient::UI::GRAB;
854 undef $CFClient::UI::HOVER;
855 undef $SDL_ACTIVE; 910 undef $SDL_ACTIVE;
856} 911}
857 912
858my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d# 913my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d#
859my $bgmusic;#TODO#hack#d# 914my $bgmusic;#TODO#hack#d#
915
916sub audio_channel_finished {
917 my ($channel) = @_;
918
919 warn "channel $channel finished\n";#d#
920}
860 921
861sub audio_music_finished { 922sub audio_music_finished {
862 return unless $CFG->{bgm_enable}; 923 return unless $CFG->{bgm_enable};
863 924
864 # TODO: hack, do play loop and mood music 925 # TODO: hack, do play loop and mood music
868 push @bgmusic, shift @bgmusic; 929 push @bgmusic, shift @bgmusic;
869} 930}
870 931
871sub audio_init { 932sub audio_init {
872 if ($CFG->{audio_enable}) { 933 if ($CFG->{audio_enable}) {
873 if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { 934 if (open my $fh, "<", CFClient::find_rcfile "sounds/config") {
874 $SDL_MIXER = !CFClient::Mix_OpenAudio; 935 $SDL_MIXER = !CFClient::Mix_OpenAudio;
875 CFClient::Mix_AllocateChannels 8; 936 CFClient::Mix_AllocateChannels 8;
876 CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; 937 CFClient::MixMusic::volume $CFG->{bgm_volume} * 128;
877 938
878 audio_music_finished; 939 audio_music_finished;
1033# at worst. 1094# at worst.
1034sub conn::flood_fill { 1095sub conn::flood_fill {
1035 my ($self, $gx, $gy, $path, $hash, $flags) = @_; 1096 my ($self, $gx, $gy, $path, $hash, $flags) = @_;
1036 1097
1037 # the server does not allow map paths > 6 1098 # the server does not allow map paths > 6
1038 return if 6 <= length $path; 1099 return if 7 <= length $path;
1039 1100
1040 my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; 1101 my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}};
1041 1102
1042 for ( 1103 for (
1043 [1, 0, -1], 1104 [1, 0, -1],
1086 1147
1087 $self->flush_map; 1148 $self->flush_map;
1088 1149
1089 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 1150 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
1090 1151
1091 my $mapmapw = 250; 1152 my $mapmapw = $MAPMAP->{w};
1092 my $mapmaph = 250; 1153 my $mapmaph = $MAPMAP->{h};
1093 1154
1094 $self->{neigh_rect} = [ 1155 $self->{neigh_rect} = [
1095 $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, 1156 $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5,
1096 $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, 1157 $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h,
1097 ]; 1158 ];
1289 1350
1290 for my $skill (values %{$self->{skill_info}}) { 1351 for my $skill (values %{$self->{skill_info}}) {
1291 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); 1352 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'");
1292 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'"); 1353 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'");
1293 } 1354 }
1355
1356 $MAPWIDGET->add_command ("pet\\_mode defend", "Tell pets to stay close to you and defend you");
1357 $MAPWIDGET->add_command ("pet\\_mode arena", "Same as petmode attack, but also attack other players");
1358 $MAPWIDGET->add_command ("pet\\_mode sad", "Search &amp; Destroy - tell pets to roam about and attack enemies");
1359 $MAPWIDGET->add_command ("kill\\_pets", "kill your pets");
1360}
1361
1362sub conn::eof {
1363 stop_game;
1294} 1364}
1295 1365
1296sub update_floorbox { 1366sub update_floorbox {
1297 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { 1367 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub {
1368 return unless $CONN;
1369
1298 $FLOORBOX->clear; 1370 $FLOORBOX->clear;
1299 $FLOORBOX->add (new CFClient::UI::Empty expand => 1); 1371 $FLOORBOX->add (new CFClient::UI::Empty expand => 1);
1300 1372
1301 my @items = values %{ $CONN->{container}{0} };
1302
1303 # we basically have to use the same sorting as everybody else 1373 # we basically have to use the same sorting as everybody else
1304 @items = sort { $a->{type} <=> $b->{type} } @items; 1374 for my $item (@{ $CONN->{container}{0} }) {
1305 1375 $FLOORBOX->add (new CFClient::UI::InventoryItem item => $item);
1306 for my $item (reverse @items) {
1307 my $desc = $item->{nrof} < 2
1308 ? $item->{name}
1309 : "$item->{nrof} $item->{name_pl}";
1310 # todo: animation widget, face widget, weight(?) etc.
1311 $FLOORBOX->add (my $hbox = new CFClient::UI::HBox
1312 tooltip => (CFClient::UI::Label->escape ($desc)
1313 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"),
1314 can_hover => 1,
1315 can_events => 1,
1316 connect_button_down => sub {
1317 my ($self, $ev, $x, $y) = @_;
1318
1319 # todo: maybe put examine on 1? but should just be a tooltip :(
1320 if ($ev->{button} == 1) {
1321 $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0");
1322 } elsif ($ev->{button} == 2) {
1323 $CONN->send ("apply $item->{tag}");
1324 } elsif ($ev->{button} == 3) {
1325 # examine, lock, mark, maybe other things
1326 warn "MENU not implemented yet\n";
1327 }
1328
1329 1
1330 },
1331 );
1332
1333 $hbox->add (new CFClient::UI::Face
1334 can_events => 0,
1335 face => $item->{face},
1336 anim => $item->{anim},
1337 animspeed => $item->{animspeed},
1338 );
1339
1340 $hbox->add (new CFClient::UI::Label
1341 can_events => 0,
1342 text => $desc,
1343 );
1344 } 1376 }
1345 }); 1377 });
1346 refresh; 1378 refresh;
1347} 1379}
1348 1380
1349sub conn::container_add { 1381sub conn::container_add {
1350 my ($self, $id, $items) = @_; 1382 my ($self, $tag, $items) = @_;
1351 1383
1352 update_floorbox if $id == 0; 1384 update_floorbox if $tag == 0;
1385
1386 $INV->set_items ($self->{container}{$self->{player}{tag}})
1387 if $tag == $self->{player}{tag};
1388
1353 # $self-<{player}{tag} => player inv 1389 # $self-<{player}{tag} => player inv
1354 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; 1390 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
1355} 1391}
1356 1392
1357sub conn::container_clear { 1393sub conn::container_clear {
1358 my ($self, $id) = @_; 1394 my ($self, $tag) = @_;
1359 1395
1360 update_floorbox if $id == 0; 1396 update_floorbox if $tag == 0;
1397
1398 $INV->set_items ($self->{container}{$tag})
1399 if $tag == $self->{player}{tag};
1400
1361# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; 1401# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1362} 1402}
1363 1403
1364sub conn::item_delete { 1404sub conn::item_delete {
1365 my ($self, @items) = @_; 1405 my ($self, @items) = @_;
1366 1406
1367 for (@items) { 1407 for (@items) {
1368 update_floorbox if $_->{container} == 0; 1408 update_floorbox if $_->{container} == 0;
1409
1410 $INV->set_items ($self->{container}{$_->{container}})
1411 if $_->{container} == $self->{player}{tag};
1369 } 1412 }
1370} 1413}
1371 1414
1372sub conn::item_update { 1415sub conn::item_update {
1373 my ($self, $item) = @_; 1416 my ($self, $item) = @_;
1374 1417
1375 update_floorbox if $item->{container} == 0; 1418 update_floorbox if $item->{container} == 0;
1419
1420 $INV->set_items ($self->{container}{$item->{container}})
1421 if $item->{container}; == $self->{player}{tag};
1376} 1422}
1377 1423
1378%SDL_CB = ( 1424%SDL_CB = (
1379 CFClient::SDL_QUIT => sub { 1425 CFClient::SDL_QUIT => sub {
1380 Event::unloop -1; 1426 Event::unloop -1;
1393 video_init; 1439 video_init;
1394 } else { 1440 } else {
1395 CFClient::UI::feed_sdl_key_down_event ($_[0]); 1441 CFClient::UI::feed_sdl_key_down_event ($_[0]);
1396 } 1442 }
1397 }, 1443 },
1398 CFClient::SDL_KEYUP => \&CFClient::UI::feed_sdl_key_up_event, 1444 CFClient::SDL_KEYUP => \&CFClient::UI::feed_sdl_key_up_event,
1399 CFClient::SDL_MOUSEMOTION => \&CFClient::UI::feed_sdl_motion_event, 1445 CFClient::SDL_MOUSEMOTION => \&CFClient::UI::feed_sdl_motion_event,
1400 CFClient::SDL_MOUSEBUTTONDOWN => \&CFClient::UI::feed_sdl_button_down_event, 1446 CFClient::SDL_MOUSEBUTTONDOWN => \&CFClient::UI::feed_sdl_button_down_event,
1401 CFClient::SDL_MOUSEBUTTONUP => \&CFClient::UI::feed_sdl_button_up_event, 1447 CFClient::SDL_MOUSEBUTTONUP => \&CFClient::UI::feed_sdl_button_up_event,
1402 CFClient::SDL_USEREVENT => \&audio_music_finished, 1448 CFClient::SDL_USEREVENT => sub {
1449 if ($_[0]{code} == 1) {
1450 audio_channel_finished $_[0]{data1};
1451 } elsif ($_[0]{code} == 0) {
1452 audio_music_finished;
1453 }
1454 },
1403); 1455);
1404 1456
1405############################################################################# 1457#############################################################################
1406 1458
1407$SIG{INT} = $SIG{TERM} = sub { exit }; 1459$SIG{INT} = $SIG{TERM} = sub { exit };
1460
1461CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
1408 1462
1409$TILECACHE = CFClient::db_table "tilecache"; 1463$TILECACHE = CFClient::db_table "tilecache";
1410$FACEMAP = CFClient::db_table "facemap"; 1464$FACEMAP = CFClient::db_table "facemap";
1411
1412CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
1413 1465
1414my %DEF_CFG = ( 1466my %DEF_CFG = (
1415 sdl_mode => 0, 1467 sdl_mode => 0,
1416 width => 640, 1468 width => 640,
1417 height => 480, 1469 height => 480,
1507limits (like a fixed amount of face numbers). There are still limits, but 1559limits (like a fixed amount of face numbers). There are still limits, but
1508they are not arbitrarily low :) 1560they are not arbitrarily low :)
1509 1561
1510=back 1562=back
1511 1563
1564=head1 USAGE
1565
1566=head2 The Map
1567
1568The map is always displayed in the background, behind all other windows and UI elements.
1569
1570#TODO# middle-click scrolls
1571#
1572# keys:
1573#
1574# a apply
1575# keypad moves, kp_5 applies ranged attack to self
1576
1577Starting to type enters the I<completion mode>. In that mode, you can type
1578abbreviations or commands and have them executed as soon as they match a
1579valid command. This is best explained by a few examples:
1580
1581Typing B<climb> will display a list of commands with I<climb> in their
1582name, such as I<ready_skill climbing> and I<use_skill climbing>.
1583
1584You can abbreviate commands by typing only the first character of every
1585word. For example, typing I<iwor> will likely select I<invoke word of
1586recall>, while I<ccfo> will select I<cast create food>. Likewise, I<rscli>
1587will likely select I<ready_skill climbing> and I<usl> will give you
1588I<use_skill levitation>.
1589
1590=head2 The map overview
1591
1592#TODO#
1593
1594=head2 The Status area in the lower right corner
1595
1596#TODO#
1597
1598=head2 The I<Statistics>/I>Stats> window
1599
1600#TODO#
1601
1512=head1 FAQ 1602=head1 FAQ
1513 1603
1514=over 4 1604=over 4
1515 1605
1516=item The client is very sluggish and slow, what can I do about this? 1606=item The client is very sluggish and slow, what can I do about this?

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines