--- deliantra/Deliantra-Client/DC/Item.pm 2006/12/09 21:50:00 1.3
+++ deliantra/Deliantra-Client/DC/Item.pm 2007/12/29 13:44:29 1.12
@@ -1,9 +1,10 @@
-package CFPlus::Item;
+package DC::Item;
use strict;
use utf8;
+use Encode;
-use Crossfire::Protocol::Constants;
+use Deliantra::Protocol::Constants;
my $last_enter_count = 1;
@@ -44,14 +45,14 @@
sub do_n_dialog {
my ($cb) = @_;
- my $w = new CFPlus::UI::Toplevel
+ my $w = new DC::UI::Toplevel
on_delete => sub { $_[0]->destroy; 1 },
has_close_button => 1,
;
- $w->add (my $vb = new CFPlus::UI::VBox x => "center", y => "center");
- $vb->add (new CFPlus::UI::Label text => "Enter item count:");
- $vb->add (my $entry = new CFPlus::UI::Entry
+ $w->add (my $vb = new DC::UI::VBox x => "center", y => "center");
+ $vb->add (new DC::UI::Label text => "Enter item count:");
+ $vb->add (my $entry = new DC::UI::Entry
text => $last_enter_count,
on_activate => sub {
my ($entry) = @_;
@@ -72,7 +73,7 @@
my ($self) = @_;
# necessary to avoid cyclic references
- CFPlus::weaken $self;
+ DC::weaken $self;
my $button_cb = sub {
my (undef, $ev, $x, $y) = @_;
@@ -83,10 +84,10 @@
$targ = $::CONN->{open_container};
}
- if (($ev->{mod} & CFPlus::KMOD_SHIFT) && $ev->{button} == 1) {
+ if (($ev->{mod} & DC::KMOD_SHIFT) && $ev->{button} == 1) {
$::CONN->send ("move $targ $self->{tag} 0")
if $targ || !($self->{flags} & F_LOCKED);
- } elsif (($ev->{mod} & CFPlus::KMOD_SHIFT) && $ev->{button} == 2) {
+ } elsif (($ev->{mod} & DC::KMOD_SHIFT) && $ev->{button} == 2) {
$self->{flags} & F_LOCKED
? $::CONN->send ("lock " . pack "CN", 0, $self->{tag})
: $::CONN->send ("lock " . pack "CN", 1, $self->{tag})
@@ -100,7 +101,7 @@
$move_prefix = "take";
}
- my $shortname = CFPlus::shorten $self->{name}, 14;
+ my $shortname = DC::shorten $self->{name}, 14;
my @menu_items = (
["examine", sub { $::CONN->send ("examine $self->{tag}") }],
@@ -116,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");
});
}
],
@@ -125,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");
}
@@ -146,28 +147,31 @@
]
)
),
- ["bind apply $shortname to a key" => sub { CFPlus::Macro::quick_macro ["apply $self->{name}"] }],
+ ["bind apply $shortname to a key" => sub { DC::Macro::quick_macro ["apply $self->{name}"] }],
);
- CFPlus::UI::Menu->new (items => \@menu_items)->popup ($ev);
+ DC::UI::Menu->new (items => \@menu_items)->popup ($ev);
}
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;
- $self->{face_widget} ||= new CFPlus::UI::Face
+ my $desc = DC::Item::desc_string $self;
+
+ $self->{face_widget} ||= new DC::UI::Face
can_events => 1,
can_hover => 1,
anim => $self->{anim},
@@ -178,34 +182,49 @@
$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
+ $self->{desc_widget} ||= new DC::UI::Label
can_events => 1,
can_hover => 1,
ellipsise => 2,
- align => -1,
- on_button_down => $button_cb,
+ align => 0,
+
+ 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");
- $self->{weight_widget} ||= new CFPlus::UI::Label
+ my $long_desc = $self->{long_desc} || $desc;
+ $self->{desc_widget}->set_tooltip ("$long_desc\n\n$tooltip_std");
+
+ $self->{weight_widget} ||= new DC::UI::Label
can_events => 1,
can_hover => 1,
ellipsise => 0,
- align => 0,
on_button_down => $button_cb,
;
$self->{weight_widget}{bg} = $bg;
- $self->{weight_widget}->set_text (CFPlus::Item::weight_string $self);
+ $self->{weight_widget}->set_text (DC::Item::weight_string $self);
$self->{weight_widget}->set_tooltip (
"Weight.\n"
. ($self->{weight} >= 0 ? "One item weighs $self->{weight}g. " : "You have no idea how much this weighs. ")
@@ -213,3 +232,4 @@
. "\n\n$tooltip_std"
);
}
+