--- deliantra/Deliantra-Client/DC/Protocol.pm 2006/12/06 00:15:12 1.90
+++ deliantra/Deliantra-Client/DC/Protocol.pm 2006/12/09 21:26:46 1.92
@@ -8,6 +8,8 @@
use CFPlus;
use CFPlus::UI;
use CFPlus::Pod;
+use CFPlus::Macro;
+use CFPlus::Item;
use Crossfire::Protocol::Base 0.95;
@@ -293,8 +295,8 @@
my $shortname = CFPlus::shorten $name, 14;
(new CFPlus::UI::Menu
items => [
- ["bind ready_skill $shortname to a key" => sub { $::BIND_EDITOR->do_quick_binding (["ready_skill $name"]) }],
- ["bind use_skill $shortname to a key" => sub { $::BIND_EDITOR->do_quick_binding (["use_skill $name"]) }],
+ ["bind ready_skill $shortname to a key" => sub { CFPlus::Macro::quick_macro ["ready_skill $name"] }],
+ ["bind use_skill $shortname to a key" => sub { CFPlus::Macro::quick_macro ["use_skill $name"] }],
],
)->popup ($ev);
} else {
@@ -321,10 +323,18 @@
}
}
+sub macro_send {
+ my ($self, $macro) = @_;
+
+ for my $cmd (@{ $macro->{action} }) {
+ $self->send_command ($cmd);
+ }
+}
+
sub user_send {
my ($self, $command) = @_;
- push @{$self->{record}}, $command
+ $self->{record}->($command)
if $self->{record};
$self->logprint ("send: ", $command);
@@ -332,15 +342,10 @@
::status ($command);
}
-sub start_record {
- my ($self) = @_;
-
- $self->{record} = [];
-}
+sub record {
+ my ($self, $cb) = @_;
-sub stop_record {
- my ($self) = @_;
- return delete $self->{record};
+ $self->{record} = $cb;
}
sub map_scroll {
@@ -984,7 +989,7 @@
@_,
);
- Scalar::Util::weaken (my $this = $self);
+ CFPlus::weaken (my $this = $self);
$self->connect (delete => sub { $this->destroy; 1 });
@@ -1038,7 +1043,7 @@
sub update_options {
my ($self) = @_;
- Scalar::Util::weaken $self;
+ CFPlus::weaken $self;
$self->{options}->clear;
$self->{options}->add ($self->{bye_button});
@@ -1057,7 +1062,7 @@
sub feed {
my ($self, $msg) = @_;
- Scalar::Util::weaken $self;
+ CFPlus::weaken $self;
if ($msg->{msgtype} eq "reply") {
$self->{kw}{$_} = 1 for @{$msg->{add_topics} || []};