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.1 by root, Fri May 26 18:56:14 2006 UTC vs.
Revision 1.8 by root, Sun May 28 19:25:55 2006 UTC

1package CFClient::Protocol; 1package CFClient::Protocol;
2 2
3use utf8; 3use utf8;
4use strict; 4use strict;
5
6use Crossfire::Protocol::Constants;
5 7
6use CFClient::UI; 8use CFClient::UI;
7 9
8use base 'Crossfire::Protocol::Base'; 10use base 'Crossfire::Protocol::Base';
9 11
23 25
24 my $cmd = $1; 26 my $cmd = $1;
25 my @args = split /\|/, $2; 27 my @args = split /\|/, $2;
26 @args = (".*") unless @args; 28 @args = (".*") unless @args;
27 29
30 $_ = $_ eq ".*" ? "" : " $_"
31 for @args;
32
28 my $text = CFClient::pod_to_pango $head2->content; 33 my $text = CFClient::pod_to_pango $head2->content;
29 34
30 for my $arg (@args) {
31 $arg = $arg eq ".*" ? "" : " $arg";
32
33 $self->{map_widget}->add_command ("$cmd$arg", $text); 35 $self->{map_widget}->add_command ("$cmd$_", $text)
34 } 36 for sort { (length $a) <=> (length $b) }
37 @args;
35 } 38 }
36 39
37 $self->{noface} = new_from_file CFClient::Texture 40 $self->{noface} = new_from_file CFClient::Texture
38 CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1; 41 CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1;
39 42
50} 53}
51 54
52sub stats_update { 55sub stats_update {
53 my ($self, $stats) = @_; 56 my ($self, $stats) = @_;
54 57
55 if (my $exp = $stats->{Crossfire::Protocol::Base::CS_STAT_EXP64}) { 58 if (my $exp = $stats->{+CS_STAT_EXP64}) {
56 my $diff = $exp - $self->{prev_exp}; 59 my $diff = $exp - $self->{prev_exp};
57 $self->{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)
58 if exists $self->{prev_exp} && $diff; 61 if exists $self->{prev_exp} && $diff;
59 $self->{prev_exp} = $exp; 62 $self->{prev_exp} = $exp;
60 } 63 }
64 67
65sub user_send { 68sub user_send {
66 my ($self, $command) = @_; 69 my ($self, $command) = @_;
67 70
68 $self->send_command ($command); 71 $self->send_command ($command);
69 status $command; 72 ::status $command;
70} 73}
71 74
72sub map_scroll { 75sub map_scroll {
73 my ($self, $dx, $dy) = @_; 76 my ($self, $dx, $dy) = @_;
74 77
322 $prompt = $LAST_QUERY unless length $prompt; 325 $prompt = $LAST_QUERY unless length $prompt;
323 $LAST_QUERY = $prompt; 326 $LAST_QUERY = $prompt;
324 327
325 my $dialog = new CFClient::UI::FancyFrame 328 my $dialog = new CFClient::UI::FancyFrame
326 title => "Query", 329 title => "Query",
327 child => my $vbox = new CFClient::UI::VBox; 330 child => my $vbox = new CFClient::UI::VBox,
331 on_visibility_change => sub {
332 my ($self, $visible) = @_;
333 $self->center if $visible;
334 },
335 ;
328 336
329 $vbox->add (new CFClient::UI::Label 337 $vbox->add (new CFClient::UI::Label
330 max_w => $::WIDTH * 0.4, 338 max_w => $::WIDTH * 0.4,
331 ellipsise => 0, 339 ellipsise => 0,
332 text => $prompt); 340 text => $prompt);
333 341
334 if ($flags & Crossfire::Protocol::Base::CS_QUERY_YESNO) { 342 if ($flags & CS_QUERY_YESNO) {
335 $vbox->add (my $hbox = new CFClient::UI::HBox); 343 $vbox->add (my $hbox = new CFClient::UI::HBox);
336 $hbox->add (new CFClient::UI::Button 344 $hbox->add (new CFClient::UI::Button
337 text => "No", 345 text => "No",
338 connect_activate => sub { 346 on_activate => sub {
339 $self->send ("reply n"); 347 $self->send ("reply n");
340 $dialog->destroy; 348 $dialog->destroy;
341 $self->{map_widget}->focus_in; 349 $self->{map_widget}->focus_in;
342 } 350 }
343 ); 351 );
344 $hbox->add (new CFClient::UI::Button 352 $hbox->add (new CFClient::UI::Button
345 text => "Yes", 353 text => "Yes",
346 connect_activate => sub { 354 on_activate => sub {
347 $self->send ("reply y"); 355 $self->send ("reply y");
348 $dialog->destroy; 356 $dialog->destroy;
349 }, 357 },
350 ); 358 );
351 359
352 $dialog->focus_in; 360 $dialog->focus_in;
353 361
354 } elsif ($flags & Crossfire::Protocol::Base::CS_QUERY_SINGLECHAR) { 362 } elsif ($flags & CS_QUERY_SINGLECHAR) {
355 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; 363 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)";
356 $vbox->add (my $entry = new CFClient::UI::Entry 364 $vbox->add (my $entry = new CFClient::UI::Entry
357 connect_changed => sub { 365 on_changed => sub {
358 $self->send ("reply $_[1]"); 366 $self->send ("reply $_[1]");
359 $dialog->destroy; 367 $dialog->destroy;
360 }, 368 },
361 ); 369 );
362 370
364 372
365 } else { 373 } else {
366 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; 374 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)";
367 375
368 $vbox->add (my $entry = new CFClient::UI::Entry 376 $vbox->add (my $entry = new CFClient::UI::Entry
369 $flags & Crossfire::Protocol::Base::CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), 377 $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (),
370 connect_activate => sub { 378 on_activate => sub {
371 $self->send ("reply $_[1]"); 379 $self->send ("reply $_[1]");
372 $dialog->destroy; 380 $dialog->destroy;
373 }, 381 },
374 ); 382 );
375 383
376 $entry->focus_in; 384 $entry->focus_in;
377 } 385 }
378 386
379 $dialog->show_centered; 387 $dialog->show;
380} 388}
381 389
382sub drawinfo { 390sub drawinfo {
383 my ($self, $color, $text) = @_; 391 my ($self, $color, $text) = @_;
384 392
602 return; 610 return;
603 } 611 }
604 612
605 CFClient::Item::update_widgets $item; 613 CFClient::Item::update_widgets $item;
606 614
607 if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & Crossfire::Protocol::Base::F_OPEN)) { 615 if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) {
608 set_opencont ($::CONN, 0, "Floor"); 616 set_opencont ($::CONN, 0, "Floor");
609 617
610 } elsif ($item->{flags} & Crossfire::Protocol::Base::F_OPEN) { 618 } elsif ($item->{flags} & F_OPEN) {
611 set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item); 619 set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item);
612 } else { 620 } else {
613 if ($item->{container} == 0) { 621 if ($item->{container} == 0) {
614 update_floorbox; 622 update_floorbox;
615 update_container (0); 623 update_container (0);
617 $::INV->set_items ($self->{container}{$item->{container}}) 625 $::INV->set_items ($self->{container}{$item->{container}})
618 } 626 }
619 } 627 }
620} 628}
621 629
630sub player_update {
631 my ($self, $player) = @_;
632 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000);
633}
634
6221; 6351;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines