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.6 by root, Sat May 27 19:49:07 2006 UTC vs.
Revision 1.13 by root, Wed May 31 07:40:33 2006 UTC

66} 66}
67 67
68sub user_send { 68sub user_send {
69 my ($self, $command) = @_; 69 my ($self, $command) = @_;
70 70
71 if ($self->{record}) {
72 push @{$self->{record}}, $command;
73 }
74
71 $self->send_command ($command); 75 $self->send_command ($command);
72 ::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};
73} 88}
74 89
75sub map_scroll { 90sub map_scroll {
76 my ($self, $dx, $dy) = @_; 91 my ($self, $dx, $dy) = @_;
77 92
324 339
325 $prompt = $LAST_QUERY unless length $prompt; 340 $prompt = $LAST_QUERY unless length $prompt;
326 $LAST_QUERY = $prompt; 341 $LAST_QUERY = $prompt;
327 342
328 my $dialog = new CFClient::UI::FancyFrame 343 my $dialog = new CFClient::UI::FancyFrame
344 x => "center",
345 y => "center",
329 title => "Query", 346 title => "Query",
330 child => my $vbox = new CFClient::UI::VBox; 347 child => my $vbox = new CFClient::UI::VBox,
348 ;
331 349
332 $vbox->add (new CFClient::UI::Label 350 $vbox->add (new CFClient::UI::Label
333 max_w => $::WIDTH * 0.4, 351 max_w => $::WIDTH * 0.4,
334 ellipsise => 0, 352 ellipsise => 0,
335 text => $prompt); 353 text => $prompt);
336 354
337 if ($flags & CS_QUERY_YESNO) { 355 if ($flags & CS_QUERY_YESNO) {
338 $vbox->add (my $hbox = new CFClient::UI::HBox); 356 $vbox->add (my $hbox = new CFClient::UI::HBox);
339 $hbox->add (new CFClient::UI::Button 357 $hbox->add (new CFClient::UI::Button
340 text => "No", 358 text => "No",
341 connect_activate => sub { 359 on_activate => sub {
342 $self->send ("reply n"); 360 $self->send ("reply n");
343 $dialog->destroy; 361 $dialog->destroy;
344 $self->{map_widget}->focus_in; 362 $self->{map_widget}->focus_in;
345 } 363 }
346 ); 364 );
347 $hbox->add (new CFClient::UI::Button 365 $hbox->add (new CFClient::UI::Button
348 text => "Yes", 366 text => "Yes",
349 connect_activate => sub { 367 on_activate => sub {
350 $self->send ("reply y"); 368 $self->send ("reply y");
351 $dialog->destroy; 369 $dialog->destroy;
352 }, 370 },
353 ); 371 );
354 372
355 $dialog->focus_in; 373 $dialog->focus_in;
356 374
357 } elsif ($flags & CS_QUERY_SINGLECHAR) { 375 } elsif ($flags & CS_QUERY_SINGLECHAR) {
358 $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)";
359 $vbox->add (my $entry = new CFClient::UI::Entry 377 $vbox->add (my $entry = new CFClient::UI::Entry
360 connect_changed => sub { 378 on_changed => sub {
361 $self->send ("reply $_[1]"); 379 $self->send ("reply $_[1]");
362 $dialog->destroy; 380 $dialog->destroy;
363 }, 381 },
364 ); 382 );
365 383
368 } else { 386 } else {
369 $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)";
370 388
371 $vbox->add (my $entry = new CFClient::UI::Entry 389 $vbox->add (my $entry = new CFClient::UI::Entry
372 $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), 390 $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (),
373 connect_activate => sub { 391 on_activate => sub {
374 $self->send ("reply $_[1]"); 392 $self->send ("reply $_[1]");
375 $dialog->destroy; 393 $dialog->destroy;
376 }, 394 },
377 ); 395 );
378 396
379 $entry->focus_in; 397 $entry->focus_in;
380 } 398 }
381 399
382 $dialog->show_centered; 400 $dialog->show;
383} 401}
384 402
385sub drawinfo { 403sub drawinfo {
386 my ($self, $color, $text) = @_; 404 my ($self, $color, $text) = @_;
387 405
438} 456}
439 457
440sub addme_success { 458sub addme_success {
441 my ($self) = @_; 459 my ($self) = @_;
442 460
443 $self->send ("command output-sync $::CFG->{output_sync}");
444 $self->send ("command output-count $::CFG->{output_count}");
445
446 my $parser = new Pod::POM; 461 my $parser = new Pod::POM;
447 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");
448 463
449 my %skill_tooltip; 464 my %skill_tooltip;
450 465
532} 547}
533 548
534sub set_opencont { 549sub set_opencont {
535 my ($conn, $tag, $name) = @_; 550 my ($conn, $tag, $name) = @_;
536 $conn->{open_container} = $tag; 551 $conn->{open_container} = $tag;
537 $::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
538 $::INVR->set_items ($conn->{container}{$tag}); 568 $::INVR->set_items ($conn->{container}{$tag});
539} 569}
540 570
541sub update_container { 571sub update_container {
542 my ($tag) = @_; 572 my ($tag) = @_;
571 if ($tag == 0) { 601 if ($tag == 0) {
572 update_floorbox; 602 update_floorbox;
573 update_container (0); 603 update_container (0);
574 } elsif ($tag == $self->{player}{tag}) { 604 } elsif ($tag == $self->{player}{tag}) {
575 $::INV->set_items ($self->{container}{$tag}) 605 $::INV->set_items ($self->{container}{$tag})
606 } else {
607 update_container ($tag);
576 } 608 }
577 609
578# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; 610# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
579} 611}
580 612
588 update_floorbox; 620 update_floorbox;
589 update_container ($_->{tag}); 621 update_container ($_->{tag});
590 } elsif ($_->{container} == $self->{player}{tag}) { 622 } elsif ($_->{container} == $self->{player}{tag}) {
591 $::INV->set_items ($self->{container}{$self->{player}{tag}}) 623 $::INV->set_items ($self->{container}{$self->{player}{tag}})
592 } else { 624 } else {
593 update_container ($_->{tag}); 625 update_container ($_->{container});
594 } 626 }
595 } 627 }
596} 628}
597 629
598sub item_update { 630sub item_update {
623} 655}
624 656
625sub player_update { 657sub player_update {
626 my ($self, $player) = @_; 658 my ($self, $player) = @_;
627 $::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}");
628} 664}
629 665
6301; 6661;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines