--- deliantra/Deliantra-Client/DC/Item.pm 2006/12/09 02:21:25 1.1
+++ deliantra/Deliantra-Client/DC/Item.pm 2007/12/26 18:09:30 1.9
@@ -1,7 +1,10 @@
package CFPlus::Item;
use strict;
-use Crossfire::Protocol::Constants;
+use utf8;
+use Encode;
+
+use Deliantra::Protocol::Constants;
my $last_enter_count = 1;
@@ -70,7 +73,7 @@
my ($self) = @_;
# necessary to avoid cyclic references
- Scalar::Util::weaken $self;
+ CFPlus::weaken $self;
my $button_cb = sub {
my (undef, $ev, $x, $y) = @_;
@@ -114,7 +117,7 @@
&::open_string_query ("Text to inscribe", sub {
my ($entry, $txt) = @_;
$::CONN->send ("mark ". pack "N", $self->{tag});
- $::CONN->send ("command use_skill inscription $txt");
+ $::CONN->send_utf8 ("command use_skill inscription $txt");
});
}
],
@@ -123,7 +126,7 @@
&::open_string_query ("Rename item to:", sub {
my ($entry, $txt) = @_;
$::CONN->send ("mark ". pack "N", $self->{tag});
- $::CONN->send ("command rename to <$txt>");
+ $::CONN->send_utf8 ("command rename to <$txt>");
}, $self->{name},
"If you input no name or erase the current custom name, the custom name will be unset");
}
@@ -153,18 +156,21 @@
1
};
- my $tooltip_std = ""
- . "Left click - examine item\n"
- . "Shift-Left click - " . ($self->{container} ? "move or drop" : "take") . " item\n"
- . "Middle click - apply\n"
- . "Shift-Middle click - lock/unlock\n"
- . "Right click - further options"
- . "\n";
+ my $tooltip_std =
+ ""
+ . "Left click - examine item\n"
+ . "Shift-Left click - " . ($self->{container} ? "move or drop" : "take") . " item\n"
+ . "Middle click - apply\n"
+ . "Shift-Middle click - lock/unlock\n"
+ . "Right click - further options"
+ . "\n";
my $bg = $self->{flags} & F_CURSED ? [1 , 0 , 0, 0.5]
: $self->{flags} & F_MAGIC ? [0.2, 0.2, 1, 0.5]
: undef;
+ my $desc = CFPlus::Item::desc_string $self;
+
$self->{face_widget} ||= new CFPlus::UI::Face
can_events => 1,
can_hover => 1,
@@ -176,24 +182,40 @@
$self->{face_widget}{face} = $self->{face};
$self->{face_widget}{anim} = $self->{anim};
$self->{face_widget}{animspeed} = $self->{animspeed};
- $self->{face_widget}->set_tooltip (
- "Face/Animation.\n"
- . "Item uses face #$self->{face}. "
- . ($self->{animspeed} ? "Item uses animation #$self->{anim} at " . (1 / $self->{animspeed}) . "fps. " : "Item is not animated. ")
- . "\n\n$tooltip_std"
- );
+# $self->{face_widget}->set_tooltip (
+# "Face/Animation.\n"
+# . "Item uses face #$self->{face}. "
+# . ($self->{animspeed} ? "Item uses animation #$self->{anim} at " . (1 / $self->{animspeed}) . "fps. " : "Item is not animated. ")
+# . "\n\n$tooltip_std"
+# );
+ $self->{face_widget}->set_tooltip ("$desc\n\n$tooltip_std");
$self->{desc_widget} ||= new CFPlus::UI::Label
can_events => 1,
can_hover => 1,
ellipsise => 2,
align => -1,
- on_button_down => $button_cb,
+
+ on_button_down => $button_cb,
+ on_tooltip_show => sub {
+ my ($widget) = @_;
+
+ $::CONN && $::CONN->ex ($self->{tag}, sub {
+ my ($long_desc) = @_;
+
+ $long_desc =~ s/\s+$//;
+
+ $self->{long_desc} = $long_desc;
+ $widget->set_tooltip ("$long_desc\n\n$tooltip_std");
+ });
+ },
;
- my $desc = CFPlus::Item::desc_string $self;
+
$self->{desc_widget}{bg} = $bg;
$self->{desc_widget}->set_text ($desc);
- $self->{desc_widget}->set_tooltip ("$desc.\n$tooltip_std");
+
+ my $long_desc = $self->{long_desc} || $desc;
+ $self->{desc_widget}->set_tooltip ("$long_desc\n\n$tooltip_std");
$self->{weight_widget} ||= new CFPlus::UI::Label
can_events => 1,
@@ -211,3 +233,4 @@
. "\n\n$tooltip_std"
);
}
+