--- deliantra/Deliantra-Client/DC/Protocol.pm 2006/05/27 08:45:23 1.4 +++ deliantra/Deliantra-Client/DC/Protocol.pm 2006/05/29 19:30:28 1.9 @@ -27,13 +27,14 @@ my @args = split /\|/, $2; @args = (".*") unless @args; - my $text = CFClient::pod_to_pango $head2->content; + $_ = $_ eq ".*" ? "" : " $_" + for @args; - for my $arg (@args) { - $arg = $arg eq ".*" ? "" : " $arg"; + my $text = CFClient::pod_to_pango $head2->content; - $self->{map_widget}->add_command ("$cmd$arg", $text); - } + $self->{map_widget}->add_command ("$cmd$_", $text) + for sort { (length $a) <=> (length $b) } + @args; } $self->{noface} = new_from_file CFClient::Texture @@ -56,7 +57,7 @@ if (my $exp = $stats->{+CS_STAT_EXP64}) { my $diff = $exp - $self->{prev_exp}; - $::STATUSBOX->add ("$diff experience gained", group => "experience $diff", fg => [0.5, 1, 0.5, 0.8], timeout => 5) + $self->{statusbox}->add ("$diff experience gained", group => "experience $diff", fg => [0.5, 1, 0.5, 0.8], timeout => 5) if exists $self->{prev_exp} && $diff; $self->{prev_exp} = $exp; } @@ -67,10 +68,25 @@ sub user_send { my ($self, $command) = @_; + if ($self->{record}) { + push @{$self->{record}}, $command; + } + $self->send_command ($command); ::status $command; } +sub start_record { + my ($self) = @_; + + $self->{record} = []; +} + +sub stop_record { + my ($self) = @_; + return delete $self->{record}; +} + sub map_scroll { my ($self, $dx, $dy) = @_; @@ -326,7 +342,12 @@ my $dialog = new CFClient::UI::FancyFrame title => "Query", - child => my $vbox = new CFClient::UI::VBox; + child => my $vbox = new CFClient::UI::VBox, + on_visibility_change => sub { + my ($self, $visible) = @_; + $self->center if $visible; + }, + ; $vbox->add (new CFClient::UI::Label max_w => $::WIDTH * 0.4, @@ -337,7 +358,7 @@ $vbox->add (my $hbox = new CFClient::UI::HBox); $hbox->add (new CFClient::UI::Button text => "No", - connect_activate => sub { + on_activate => sub { $self->send ("reply n"); $dialog->destroy; $self->{map_widget}->focus_in; @@ -345,7 +366,7 @@ ); $hbox->add (new CFClient::UI::Button text => "Yes", - connect_activate => sub { + on_activate => sub { $self->send ("reply y"); $dialog->destroy; }, @@ -356,7 +377,7 @@ } elsif ($flags & CS_QUERY_SINGLECHAR) { $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; $vbox->add (my $entry = new CFClient::UI::Entry - connect_changed => sub { + on_changed => sub { $self->send ("reply $_[1]"); $dialog->destroy; }, @@ -369,7 +390,7 @@ $vbox->add (my $entry = new CFClient::UI::Entry $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), - connect_activate => sub { + on_activate => sub { $self->send ("reply $_[1]"); $dialog->destroy; }, @@ -378,7 +399,7 @@ $entry->focus_in; } - $dialog->show_centered; + $dialog->show; } sub drawinfo { @@ -409,7 +430,7 @@ $self->{logview}->add_paragraph ($color[$color], join "\n", map "$time $_", split /\n/, $text); - $::STATUSBOX->add ($text, + $self->{statusbox}->add ($text, group => $text, fg => $color[$color], timeout => 10, @@ -491,14 +512,14 @@ $self->send ("requestinfo image_sums $face $face"); - $::STATUSBOX->add (CFClient::UI::Label::escape "prefetching $todo", + $self->{statusbox}->add (CFClient::UI::Label::escape "prefetching $todo", group => "prefetch", timeout => 2, fg => [1, 1, 0, 0.5]); } elsif (!exists $self->{num_faces}) { $self->send ("requestinfo image_info"); $self->{num_faces} = 0; - $::STATUSBOX->add (CFClient::UI::Label::escape "starting to prefetch", + $self->{statusbox}->add (CFClient::UI::Label::escape "starting to prefetch", group => "prefetch", timeout => 2, fg => [1, 1, 0, 0.5]); } }