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.9 by elmex, Mon May 29 19:30:28 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
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
329 title => "Query", 344 title => "Query",
330 child => my $vbox = new CFClient::UI::VBox; 345 child => my $vbox = new CFClient::UI::VBox,
346 on_visibility_change => sub {
347 my ($self, $visible) = @_;
348 $self->center if $visible;
349 },
350 ;
331 351
332 $vbox->add (new CFClient::UI::Label 352 $vbox->add (new CFClient::UI::Label
333 max_w => $::WIDTH * 0.4, 353 max_w => $::WIDTH * 0.4,
334 ellipsise => 0, 354 ellipsise => 0,
335 text => $prompt); 355 text => $prompt);
336 356
337 if ($flags & CS_QUERY_YESNO) { 357 if ($flags & CS_QUERY_YESNO) {
338 $vbox->add (my $hbox = new CFClient::UI::HBox); 358 $vbox->add (my $hbox = new CFClient::UI::HBox);
339 $hbox->add (new CFClient::UI::Button 359 $hbox->add (new CFClient::UI::Button
340 text => "No", 360 text => "No",
341 connect_activate => sub { 361 on_activate => sub {
342 $self->send ("reply n"); 362 $self->send ("reply n");
343 $dialog->destroy; 363 $dialog->destroy;
344 $self->{map_widget}->focus_in; 364 $self->{map_widget}->focus_in;
345 } 365 }
346 ); 366 );
347 $hbox->add (new CFClient::UI::Button 367 $hbox->add (new CFClient::UI::Button
348 text => "Yes", 368 text => "Yes",
349 connect_activate => sub { 369 on_activate => sub {
350 $self->send ("reply y"); 370 $self->send ("reply y");
351 $dialog->destroy; 371 $dialog->destroy;
352 }, 372 },
353 ); 373 );
354 374
355 $dialog->focus_in; 375 $dialog->focus_in;
356 376
357 } elsif ($flags & CS_QUERY_SINGLECHAR) { 377 } elsif ($flags & CS_QUERY_SINGLECHAR) {
358 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; 378 $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 379 $vbox->add (my $entry = new CFClient::UI::Entry
360 connect_changed => sub { 380 on_changed => sub {
361 $self->send ("reply $_[1]"); 381 $self->send ("reply $_[1]");
362 $dialog->destroy; 382 $dialog->destroy;
363 }, 383 },
364 ); 384 );
365 385
368 } else { 388 } else {
369 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; 389 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)";
370 390
371 $vbox->add (my $entry = new CFClient::UI::Entry 391 $vbox->add (my $entry = new CFClient::UI::Entry
372 $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), 392 $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (),
373 connect_activate => sub { 393 on_activate => sub {
374 $self->send ("reply $_[1]"); 394 $self->send ("reply $_[1]");
375 $dialog->destroy; 395 $dialog->destroy;
376 }, 396 },
377 ); 397 );
378 398
379 $entry->focus_in; 399 $entry->focus_in;
380 } 400 }
381 401
382 $dialog->show_centered; 402 $dialog->show;
383} 403}
384 404
385sub drawinfo { 405sub drawinfo {
386 my ($self, $color, $text) = @_; 406 my ($self, $color, $text) = @_;
387 407

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines