--- deliantra/Deliantra-Client/DC/Protocol.pm 2006/05/26 19:14:33 1.2 +++ deliantra/Deliantra-Client/DC/Protocol.pm 2006/06/01 18:56:05 1.15 @@ -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 @@ -54,7 +55,7 @@ sub stats_update { my ($self, $stats) = @_; - if (my $exp = $stats->{CS_STAT_EXP64}) { + if (my $exp = $stats->{+CS_STAT_EXP64}) { my $diff = $exp - $self->{prev_exp}; $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; @@ -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) = @_; @@ -254,7 +270,7 @@ # I love transactions for (1..100) { my $txn = $CFClient::DB_ENV->txn_begin; - my $status = $self->{facemap}->db_get (id => $id, BerkeleyDB::DB_RMW); + my $status = $self->{facemap}->db_get (id => $id); if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) { $id = ($id || 16) + 1; if ($self->{facemap}->put (id => $id) == 0 @@ -264,7 +280,7 @@ goto gotid; } } - $txn->abort; + $txn->txn_abort; } CFClient::fatal "maximum number of transaction retries reached - database problems?"; @@ -325,8 +341,11 @@ $LAST_QUERY = $prompt; my $dialog = new CFClient::UI::FancyFrame + x => "center", + y => "center", title => "Query", - child => my $vbox = new CFClient::UI::VBox; + child => my $vbox = new CFClient::UI::VBox, + ; $vbox->add (new CFClient::UI::Label max_w => $::WIDTH * 0.4, @@ -337,7 +356,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 +364,7 @@ ); $hbox->add (new CFClient::UI::Button text => "Yes", - connect_activate => sub { + on_activate => sub { $self->send ("reply y"); $dialog->destroy; }, @@ -356,7 +375,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 +388,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 +397,7 @@ $entry->focus_in; } - $dialog->show_centered; + $dialog->show; } sub drawinfo { @@ -428,20 +447,20 @@ # TODO # create a widget dynamically, using spell face (CF::Protocol downloads them) + $::SPELL_LIST->add_spell ($spell); + $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message}); $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message}); } sub spell_delete { my ($self, $spell) = @_; + $::SPELL_LIST->remove_spell ($spell); } sub addme_success { my ($self) = @_; - $self->send ("command output-sync $::CFG->{output_sync}"); - $self->send ("command output-count $::CFG->{output_count}"); - my $parser = new Pod::POM; my $pod = $parser->parse_file (CFClient::find_rcfile "pod/skill_help.pod"); @@ -533,7 +552,22 @@ sub set_opencont { my ($conn, $tag, $name) = @_; $conn->{open_container} = $tag; - $::INVR_LBL->set_text ($name); + + $::INV_RIGHT_HB->clear (); + $::INV_RIGHT_HB->add (new CFClient::UI::Label align => 0, expand => 1, text => $name); + + if ($tag != 0) { # Floor isn't closable, is it? + $::INV_RIGHT_HB->add (new CFClient::UI::Button + text => "Close container", + tooltip => "Close the currently open container (if one is open)", + on_activate => sub { + $::CONN->send ("apply $tag") # $::CONN->{open_container}") + if $tag != 0; + #if $CONN->{open_container} != 0; + }, + ); + } + $::INVR->set_items ($conn->{container}{$tag}); } @@ -572,6 +606,8 @@ update_container (0); } elsif ($tag == $self->{player}{tag}) { $::INV->set_items ($self->{container}{$tag}) + } else { + update_container ($tag); } # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; @@ -589,7 +625,7 @@ } elsif ($_->{container} == $self->{player}{tag}) { $::INV->set_items ($self->{container}{$self->{player}{tag}}) } else { - update_container ($_->{tag}); + update_container ($_->{container}); } } } @@ -621,4 +657,13 @@ } } +sub player_update { + my ($self, $player) = @_; + $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); + + # do it here because it is ignored earlier, and there is no "login" event + $self->send_command ("output-sync $::CFG->{output_sync}"); + $self->send_command ("output-count $::CFG->{output_count}"); +} + 1;