ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Protocol.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Protocol.pm (file contents):
Revision 1.4 by elmex, Sat May 27 08:45:23 2006 UTC vs.
Revision 1.13 by root, Wed May 31 07:40:33 2006 UTC

25 25
26 my $cmd = $1; 26 my $cmd = $1;
27 my @args = split /\|/, $2; 27 my @args = split /\|/, $2;
28 @args = (".*") unless @args; 28 @args = (".*") unless @args;
29 29
30 $_ = $_ eq ".*" ? "" : " $_"
31 for @args;
32
30 my $text = CFClient::pod_to_pango $head2->content; 33 my $text = CFClient::pod_to_pango $head2->content;
31 34
32 for my $arg (@args) {
33 $arg = $arg eq ".*" ? "" : " $arg";
34
35 $self->{map_widget}->add_command ("$cmd$arg", $text); 35 $self->{map_widget}->add_command ("$cmd$_", $text)
36 } 36 for sort { (length $a) <=> (length $b) }
37 @args;
37 } 38 }
38 39
39 $self->{noface} = new_from_file CFClient::Texture 40 $self->{noface} = new_from_file CFClient::Texture
40 CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1; 41 CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1;
41 42
54sub stats_update { 55sub stats_update {
55 my ($self, $stats) = @_; 56 my ($self, $stats) = @_;
56 57
57 if (my $exp = $stats->{+CS_STAT_EXP64}) { 58 if (my $exp = $stats->{+CS_STAT_EXP64}) {
58 my $diff = $exp - $self->{prev_exp}; 59 my $diff = $exp - $self->{prev_exp};
59 $::STATUSBOX->add ("$diff experience gained", group => "experience $diff", fg => [0.5, 1, 0.5, 0.8], timeout => 5) 60 $self->{statusbox}->add ("$diff experience gained", group => "experience $diff", fg => [0.5, 1, 0.5, 0.8], timeout => 5)
60 if exists $self->{prev_exp} && $diff; 61 if exists $self->{prev_exp} && $diff;
61 $self->{prev_exp} = $exp; 62 $self->{prev_exp} = $exp;
62 } 63 }
63 64
64 ::update_stats_window ($stats); 65 ::update_stats_window ($stats);
65} 66}
66 67
67sub user_send { 68sub user_send {
68 my ($self, $command) = @_; 69 my ($self, $command) = @_;
69 70
71 if ($self->{record}) {
72 push @{$self->{record}}, $command;
73 }
74
70 $self->send_command ($command); 75 $self->send_command ($command);
71 ::status $command; 76 ::status $command;
77}
78
79sub start_record {
80 my ($self) = @_;
81
82 $self->{record} = [];
83}
84
85sub stop_record {
86 my ($self) = @_;
87 return delete $self->{record};
72} 88}
73 89
74sub map_scroll { 90sub map_scroll {
75 my ($self, $dx, $dy) = @_; 91 my ($self, $dx, $dy) = @_;
76 92
323 339
324 $prompt = $LAST_QUERY unless length $prompt; 340 $prompt = $LAST_QUERY unless length $prompt;
325 $LAST_QUERY = $prompt; 341 $LAST_QUERY = $prompt;
326 342
327 my $dialog = new CFClient::UI::FancyFrame 343 my $dialog = new CFClient::UI::FancyFrame
344 x => "center",
345 y => "center",
328 title => "Query", 346 title => "Query",
329 child => my $vbox = new CFClient::UI::VBox; 347 child => my $vbox = new CFClient::UI::VBox,
348 ;
330 349
331 $vbox->add (new CFClient::UI::Label 350 $vbox->add (new CFClient::UI::Label
332 max_w => $::WIDTH * 0.4, 351 max_w => $::WIDTH * 0.4,
333 ellipsise => 0, 352 ellipsise => 0,
334 text => $prompt); 353 text => $prompt);
335 354
336 if ($flags & CS_QUERY_YESNO) { 355 if ($flags & CS_QUERY_YESNO) {
337 $vbox->add (my $hbox = new CFClient::UI::HBox); 356 $vbox->add (my $hbox = new CFClient::UI::HBox);
338 $hbox->add (new CFClient::UI::Button 357 $hbox->add (new CFClient::UI::Button
339 text => "No", 358 text => "No",
340 connect_activate => sub { 359 on_activate => sub {
341 $self->send ("reply n"); 360 $self->send ("reply n");
342 $dialog->destroy; 361 $dialog->destroy;
343 $self->{map_widget}->focus_in; 362 $self->{map_widget}->focus_in;
344 } 363 }
345 ); 364 );
346 $hbox->add (new CFClient::UI::Button 365 $hbox->add (new CFClient::UI::Button
347 text => "Yes", 366 text => "Yes",
348 connect_activate => sub { 367 on_activate => sub {
349 $self->send ("reply y"); 368 $self->send ("reply y");
350 $dialog->destroy; 369 $dialog->destroy;
351 }, 370 },
352 ); 371 );
353 372
354 $dialog->focus_in; 373 $dialog->focus_in;
355 374
356 } elsif ($flags & CS_QUERY_SINGLECHAR) { 375 } elsif ($flags & CS_QUERY_SINGLECHAR) {
357 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; 376 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)";
358 $vbox->add (my $entry = new CFClient::UI::Entry 377 $vbox->add (my $entry = new CFClient::UI::Entry
359 connect_changed => sub { 378 on_changed => sub {
360 $self->send ("reply $_[1]"); 379 $self->send ("reply $_[1]");
361 $dialog->destroy; 380 $dialog->destroy;
362 }, 381 },
363 ); 382 );
364 383
367 } else { 386 } else {
368 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; 387 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)";
369 388
370 $vbox->add (my $entry = new CFClient::UI::Entry 389 $vbox->add (my $entry = new CFClient::UI::Entry
371 $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), 390 $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (),
372 connect_activate => sub { 391 on_activate => sub {
373 $self->send ("reply $_[1]"); 392 $self->send ("reply $_[1]");
374 $dialog->destroy; 393 $dialog->destroy;
375 }, 394 },
376 ); 395 );
377 396
378 $entry->focus_in; 397 $entry->focus_in;
379 } 398 }
380 399
381 $dialog->show_centered; 400 $dialog->show;
382} 401}
383 402
384sub drawinfo { 403sub drawinfo {
385 my ($self, $color, $text) = @_; 404 my ($self, $color, $text) = @_;
386 405
407 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 426 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
408 427
409 $self->{logview}->add_paragraph ($color[$color], 428 $self->{logview}->add_paragraph ($color[$color],
410 join "\n", map "$time $_", split /\n/, $text); 429 join "\n", map "$time $_", split /\n/, $text);
411 430
412 $::STATUSBOX->add ($text, 431 $self->{statusbox}->add ($text,
413 group => $text, 432 group => $text,
414 fg => $color[$color], 433 fg => $color[$color],
415 timeout => 10, 434 timeout => 10,
416 tooltip_font => $::FONT_FIXED, 435 tooltip_font => $::FONT_FIXED,
417 ); 436 );
436 my ($self, $spell) = @_; 455 my ($self, $spell) = @_;
437} 456}
438 457
439sub addme_success { 458sub addme_success {
440 my ($self) = @_; 459 my ($self) = @_;
441
442 $self->send ("command output-sync $::CFG->{output_sync}");
443 $self->send ("command output-count $::CFG->{output_count}");
444 460
445 my $parser = new Pod::POM; 461 my $parser = new Pod::POM;
446 my $pod = $parser->parse_file (CFClient::find_rcfile "pod/skill_help.pod"); 462 my $pod = $parser->parse_file (CFClient::find_rcfile "pod/skill_help.pod");
447 463
448 my %skill_tooltip; 464 my %skill_tooltip;
489 505
490 my ($face) = splice @{ $self->{face_prefetch} }, + rand @{ $self->{face_prefetch} }, 1, (); 506 my ($face) = splice @{ $self->{face_prefetch} }, + rand @{ $self->{face_prefetch} }, 1, ();
491 507
492 $self->send ("requestinfo image_sums $face $face"); 508 $self->send ("requestinfo image_sums $face $face");
493 509
494 $::STATUSBOX->add (CFClient::UI::Label::escape "prefetching $todo", 510 $self->{statusbox}->add (CFClient::UI::Label::escape "prefetching $todo",
495 group => "prefetch", timeout => 2, fg => [1, 1, 0, 0.5]); 511 group => "prefetch", timeout => 2, fg => [1, 1, 0, 0.5]);
496 } elsif (!exists $self->{num_faces}) { 512 } elsif (!exists $self->{num_faces}) {
497 $self->send ("requestinfo image_info"); 513 $self->send ("requestinfo image_info");
498 514
499 $self->{num_faces} = 0; 515 $self->{num_faces} = 0;
500 516
501 $::STATUSBOX->add (CFClient::UI::Label::escape "starting to prefetch", 517 $self->{statusbox}->add (CFClient::UI::Label::escape "starting to prefetch",
502 group => "prefetch", timeout => 2, fg => [1, 1, 0, 0.5]); 518 group => "prefetch", timeout => 2, fg => [1, 1, 0, 0.5]);
503 } 519 }
504} 520}
505 521
506sub update_floorbox { 522sub update_floorbox {
531} 547}
532 548
533sub set_opencont { 549sub set_opencont {
534 my ($conn, $tag, $name) = @_; 550 my ($conn, $tag, $name) = @_;
535 $conn->{open_container} = $tag; 551 $conn->{open_container} = $tag;
536 $::INVR_LBL->set_text ($name); 552
553 $::INV_RIGHT_HB->clear ();
554 $::INV_RIGHT_HB->add (new CFClient::UI::Label align => 0, expand => 1, text => $name);
555
556 if ($tag != 0) { # Floor isn't closable, is it?
557 $::INV_RIGHT_HB->add (new CFClient::UI::Button
558 text => "Close container",
559 tooltip => "Close the currently open container (if one is open)",
560 on_activate => sub {
561 $::CONN->send ("apply $tag") # $::CONN->{open_container}")
562 if $tag != 0;
563 #if $CONN->{open_container} != 0;
564 },
565 );
566 }
567
537 $::INVR->set_items ($conn->{container}{$tag}); 568 $::INVR->set_items ($conn->{container}{$tag});
538} 569}
539 570
540sub update_container { 571sub update_container {
541 my ($tag) = @_; 572 my ($tag) = @_;
570 if ($tag == 0) { 601 if ($tag == 0) {
571 update_floorbox; 602 update_floorbox;
572 update_container (0); 603 update_container (0);
573 } elsif ($tag == $self->{player}{tag}) { 604 } elsif ($tag == $self->{player}{tag}) {
574 $::INV->set_items ($self->{container}{$tag}) 605 $::INV->set_items ($self->{container}{$tag})
606 } else {
607 update_container ($tag);
575 } 608 }
576 609
577# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; 610# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
578} 611}
579 612
587 update_floorbox; 620 update_floorbox;
588 update_container ($_->{tag}); 621 update_container ($_->{tag});
589 } elsif ($_->{container} == $self->{player}{tag}) { 622 } elsif ($_->{container} == $self->{player}{tag}) {
590 $::INV->set_items ($self->{container}{$self->{player}{tag}}) 623 $::INV->set_items ($self->{container}{$self->{player}{tag}})
591 } else { 624 } else {
592 update_container ($_->{tag}); 625 update_container ($_->{container});
593 } 626 }
594 } 627 }
595} 628}
596 629
597sub item_update { 630sub item_update {
622} 655}
623 656
624sub player_update { 657sub player_update {
625 my ($self, $player) = @_; 658 my ($self, $player) = @_;
626 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); 659 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000);
660
661 # do it here because it is ignored earlier, and there is no "login" event
662 $self->send_command ("output-sync $::CFG->{output_sync}");
663 $self->send_command ("output-count $::CFG->{output_count}");
627} 664}
628 665
6291; 6661;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines