--- deliantra/Deliantra-Client/DC/Protocol.pm 2006/12/04 15:17:14 1.89
+++ deliantra/Deliantra-Client/DC/Protocol.pm 2006/12/22 03:43:05 1.93
@@ -8,6 +8,8 @@
use CFPlus;
use CFPlus::UI;
use CFPlus::Pod;
+use CFPlus::Macro;
+use CFPlus::Item;
use Crossfire::Protocol::Base 0.95;
@@ -290,10 +292,11 @@
} elsif ($ev->{button} == 2) {
$::CONN->user_send ("use_skill $name");
} elsif ($ev->{button} == 3) {
+ my $shortname = CFPlus::shorten $name, 14;
(new CFPlus::UI::Menu
items => [
- ["bind ready_skill $name to a key" => sub { $::BIND_EDITOR->do_quick_binding (["ready_skill $name"]) }],
- ["bind use_skill $name 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 {
@@ -320,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);
@@ -331,15 +342,10 @@
::status ($command);
}
-sub start_record {
- my ($self) = @_;
+sub record {
+ my ($self, $cb) = @_;
- $self->{record} = [];
-}
-
-sub stop_record {
- my ($self) = @_;
- return delete $self->{record};
+ $self->{record} = $cb;
}
sub map_scroll {
@@ -624,6 +630,8 @@
[0.74, 0.65, 0.41],
);
+ my $fg = $color[$color % @color];
+
$self->logprint ("info: ", $text);
# try to create single paragraphs of multiple lines sent by the server
@@ -633,12 +641,12 @@
$text =~ s/\[b\](.*?)\[\/b\]/\1<\/b>/g;
$text =~ s/\[color=(.*?)\](.*?)\[\/color\]/\2<\/span>/g;
- ::message ({ fg => $color[$color], markup => $_ })
+ ::message ({ fg => $fg, markup => $_ })
for split /\n/, $text;
$self->{statusbox}->add ($text,
group => $text,
- fg => $color[$color],
+ fg => $fg,
timeout => $color >= 2 ? 180 : 10,
tooltip_font => $::FONT_FIXED,
);
@@ -983,7 +991,7 @@
@_,
);
- Scalar::Util::weaken (my $this = $self);
+ CFPlus::weaken (my $this = $self);
$self->connect (delete => sub { $this->destroy; 1 });
@@ -1037,7 +1045,7 @@
sub update_options {
my ($self) = @_;
- Scalar::Util::weaken $self;
+ CFPlus::weaken $self;
$self->{options}->clear;
$self->{options}->add ($self->{bye_button});
@@ -1056,7 +1064,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} || []};