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

Comparing deliantra/Deliantra-Client/DC.pm (file contents):
Revision 1.61 by root, Wed May 24 21:49:58 2006 UTC vs.
Revision 1.62 by root, Thu May 25 16:24:43 2006 UTC

18 $VERSION = '0.1'; 18 $VERSION = '0.1';
19 19
20 use XSLoader; 20 use XSLoader;
21 XSLoader::load "CFClient", $VERSION; 21 XSLoader::load "CFClient", $VERSION;
22} 22}
23
24use utf8;
23 25
24use Carp (); 26use Carp ();
25use AnyEvent (); 27use AnyEvent ();
26use BerkeleyDB; 28use BerkeleyDB;
27 29
213 my ($db, $key, $data) = @_; 215 my ($db, $key, $data) = @_;
214 216
215 $DB_SYNC{$db} = AnyEvent->timer (after => 5, cb => sub { $db->db_sync }); 217 $DB_SYNC{$db} = AnyEvent->timer (after => 5, cb => sub { $db->db_sync });
216 218
217 $db->db_put ($key => $data) 219 $db->db_put ($key => $data)
220}
221
222package CFClient::Item;
223
224sub desc_string {
225 my ($self) = @_;
226
227 my $desc =
228 $self->{nrof} < 2
229 ? $self->{name}
230 : "$self->{nrof} × $self->{name_pl}";
231
232 $self->{flags} & Crossfire::Protocol::F_OPEN
233 and $desc .= " (open)";
234 $self->{flags} & Crossfire::Protocol::F_APPLIED
235 and $desc .= " (applied)";
236 $self->{flags} & Crossfire::Protocol::F_UNPAID
237 and $desc .= " (unpaid)";
238 $self->{flags} & Crossfire::Protocol::F_MAGIC
239 and $desc .= " (magic)";
240 $self->{flags} & Crossfire::Protocol::F_CURSED
241 and $desc .= " (cursed)";
242 $self->{flags} & Crossfire::Protocol::F_DAMNED
243 and $desc .= " (damned)";
244 $self->{flags} & Crossfire::Protocol::F_LOCKED
245 and $desc .= " *";
246
247 $desc
248}
249
250sub weight_string {
251 my ($self) = @_;
252
253 my $weight = ($self->{nrof} || 1) * $self->{weight};
254
255 $weight < 0 ? "?" : $weight * 0.001
256}
257
258sub update_widgets {
259 my ($self) = @_;
260
261 my $tooltip_std = "<small>"
262 . "Left click - examine item\n"
263 . "Shift-Left click - " . ($self->{container} ? "move or drop" : "take") . " item\n"
264 . "Middle click - apply\n"
265 . "Right click - further options"
266 . "</small>\n";
267
268 $self->{face_widget} ||= new CFClient::UI::Face can_events => 1, can_hover => 1;
269 $self->{face_widget}{face} = $self->{face};
270 $self->{face_widget}{anim} = $self->{anim};
271 $self->{face_widget}{animspeed} = $self->{animespeed};
272 $self->{face_widget}->set_tooltip (
273 "<b>Face/Animation.</b>\n"
274 . "Item uses face #$self->{face}. "
275 . ($self->{animspeed} ? "Item uses animation #$self->{anim} at " . (1 / $self->{animspeed}) . "fps. " : "Item is not animated. ")
276 . "\n\n$tooltip_std"
277 );
278
279 $self->{desc_widget} ||= new CFClient::UI::Label ellipsise => 2, can_events => 1, can_hover => 1;
280 $self->{desc_widget}->set_text (CFClient::Item::desc_string $self);
281
282 $self->{weight_widget} ||= new CFClient::UI::Label ellipsise => 0, can_events => 1, can_hover => 1, align => 0.5;
283 $self->{weight_widget}->set_text (CFClient::Item::weight_string $self);
284
285 $self->{weight_widget}->set_tooltip (
286 "<b>Weight</b>.\n"
287 . ($self->{weight} >= 0 ? "One item weighs $self->{weight}g. " : "You have no idea how much this weighs. ")
288 . ($self->{nrof} ? "You have $self->{nrof} of it. " : "Item cannot stack with others of it's kind. ")
289 . "\n\n$tooltip_std"
290 );
218} 291}
219 292
220package CFClient::Texture; 293package CFClient::Texture;
221 294
222use strict; 295use strict;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines