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.3 by root, Sat Dec 9 21:50:00 2006 UTC vs.
Revision 1.8 by root, Tue Dec 25 07:39:18 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines