ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Item.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Item.pm (file contents):
Revision 1.2 by root, Sat Dec 9 21:26:46 2006 UTC vs.
Revision 1.7 by elmex, Tue Aug 14 12:02:14 2007 UTC

1package CFPlus::Item; 1package CFPlus::Item;
2 2
3use strict; 3use strict;
4use utf8;
5use Encode;
6
4use Crossfire::Protocol::Constants; 7use Crossfire::Protocol::Constants;
5 8
6my $last_enter_count = 1; 9my $last_enter_count = 1;
7 10
8sub desc_string { 11sub desc_string {
112 ["inscribe", # first try of an easier use of flint&steel 115 ["inscribe", # first try of an easier use of flint&steel
113 sub { 116 sub {
114 &::open_string_query ("Text to inscribe", sub { 117 &::open_string_query ("Text to inscribe", sub {
115 my ($entry, $txt) = @_; 118 my ($entry, $txt) = @_;
116 $::CONN->send ("mark ". pack "N", $self->{tag}); 119 $::CONN->send ("mark ". pack "N", $self->{tag});
117 $::CONN->send ("command use_skill inscription $txt"); 120 $::CONN->send_utf8 ("command use_skill inscription $txt");
118 }); 121 });
119 } 122 }
120 ], 123 ],
121 ["rename", # first try of an easier use of flint&steel 124 ["rename", # first try of an easier use of flint&steel
122 sub { 125 sub {
123 &::open_string_query ("Rename item to:", sub { 126 &::open_string_query ("Rename item to:", sub {
124 my ($entry, $txt) = @_; 127 my ($entry, $txt) = @_;
125 $::CONN->send ("mark ". pack "N", $self->{tag}); 128 $::CONN->send ("mark ". pack "N", $self->{tag});
126 $::CONN->send ("command rename to <$txt>"); 129 $::CONN->send_utf8 ("command rename to <$txt>");
127 }, $self->{name}, 130 }, $self->{name},
128 "If you input no name or erase the current custom name, the custom name will be unset"); 131 "If you input no name or erase the current custom name, the custom name will be unset");
129 } 132 }
130 ], 133 ],
131 ["apply", sub { $::CONN->send ("apply $self->{tag}") }], 134 ["apply", sub { $::CONN->send ("apply $self->{tag}") }],
151 } 154 }
152 155
153 1 156 1
154 }; 157 };
155 158
156 my $tooltip_std = "<small>" 159 my $tooltip_std =
160 "<small>"
157 . "Left click - examine item\n" 161 . "Left click - examine item\n"
158 . "Shift-Left click - " . ($self->{container} ? "move or drop" : "take") . " item\n" 162 . "Shift-Left click - " . ($self->{container} ? "move or drop" : "take") . " item\n"
159 . "Middle click - apply\n" 163 . "Middle click - apply\n"
160 . "Shift-Middle click - lock/unlock\n" 164 . "Shift-Middle click - lock/unlock\n"
161 . "Right click - further options" 165 . "Right click - further options"
162 . "</small>\n"; 166 . "</small>\n";
163 167
164 my $bg = $self->{flags} & F_CURSED ? [1 , 0 , 0, 0.5] 168 my $bg = $self->{flags} & F_CURSED ? [1 , 0 , 0, 0.5]
165 : $self->{flags} & F_MAGIC ? [0.2, 0.2, 1, 0.5] 169 : $self->{flags} & F_MAGIC ? [0.2, 0.2, 1, 0.5]
166 : undef; 170 : undef;
167 171
186 $self->{desc_widget} ||= new CFPlus::UI::Label 190 $self->{desc_widget} ||= new CFPlus::UI::Label
187 can_events => 1, 191 can_events => 1,
188 can_hover => 1, 192 can_hover => 1,
189 ellipsise => 2, 193 ellipsise => 2,
190 align => -1, 194 align => -1,
195
191 on_button_down => $button_cb, 196 on_button_down => $button_cb,
197 on_tooltip_show => sub {
198 my ($widget) = @_;
199
200 $::CONN && $::CONN->ex ($self->{tag}, sub {
201 my ($long_desc) = @_;
202
203 $long_desc =~ s/\s+$//;
204
205 $self->{long_desc} = $long_desc;
206 $widget->set_tooltip ("<b>$long_desc</b>\n\n$tooltip_std");
207 });
208 },
192 ; 209 ;
210
193 my $desc = CFPlus::Item::desc_string $self; 211 my $desc = CFPlus::Item::desc_string $self;
194 $self->{desc_widget}{bg} = $bg; 212 $self->{desc_widget}{bg} = $bg;
195 $self->{desc_widget}->set_text ($desc); 213 $self->{desc_widget}->set_text ($desc);
214
215 my $long_desc = $self->{long_desc} || $desc;
196 $self->{desc_widget}->set_tooltip ("<b>$desc</b>.\n$tooltip_std"); 216 $self->{desc_widget}->set_tooltip ("<b>$long_desc</b>\n\n$tooltip_std");
197 217
198 $self->{weight_widget} ||= new CFPlus::UI::Label 218 $self->{weight_widget} ||= new CFPlus::UI::Label
199 can_events => 1, 219 can_events => 1,
200 can_hover => 1, 220 can_hover => 1,
201 ellipsise => 0, 221 ellipsise => 0,
209 . ($self->{weight} >= 0 ? "One item weighs $self->{weight}g. " : "You have no idea how much this weighs. ") 229 . ($self->{weight} >= 0 ? "One item weighs $self->{weight}g. " : "You have no idea how much this weighs. ")
210 . ($self->{nrof} ? "You have $self->{nrof} of it. " : "Item cannot stack with others of it's kind. ") 230 . ($self->{nrof} ? "You have $self->{nrof} of it. " : "Item cannot stack with others of it's kind. ")
211 . "\n\n$tooltip_std" 231 . "\n\n$tooltip_std"
212 ); 232 );
213} 233}
234

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines