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.5 by elmex, Sat May 27 10:32:35 2006 UTC vs.
Revision 1.11 by root, Tue May 30 07:26:02 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
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
531} 550}
532 551
533sub set_opencont { 552sub set_opencont {
534 my ($conn, $tag, $name) = @_; 553 my ($conn, $tag, $name) = @_;
535 $conn->{open_container} = $tag; 554 $conn->{open_container} = $tag;
536 $::INVR_LBL->set_text ($name); 555
556 $::INV_RIGHT_HB->clear ();
557 $::INV_RIGHT_HB->add (new CFClient::UI::Label align => 0, expand => 1, text => $name);
558
559 if ($tag != 0) { # Floor isn't closable, is it?
560 $::INV_RIGHT_HB->add (new CFClient::UI::Button
561 text => "Close container",
562 tooltip => "Close the currently open container (if one is open)",
563 on_activate => sub {
564 $::CONN->send ("apply $tag") # $::CONN->{open_container}")
565 if $tag != 0;
566 #if $CONN->{open_container} != 0;
567 },
568 );
569 }
570
537 $::INVR->set_items ($conn->{container}{$tag}); 571 $::INVR->set_items ($conn->{container}{$tag});
538} 572}
539 573
540sub update_container { 574sub update_container {
541 my ($tag) = @_; 575 my ($tag) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines