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

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.211 by elmex, Wed May 17 10:33:03 2006 UTC vs.
Revision 1.212 by elmex, Wed May 17 14:55:14 2006 UTC

2518 2518
2519package CFClient::UI::InventoryItem; 2519package CFClient::UI::InventoryItem;
2520 2520
2521our @ISA = CFClient::UI::HBox::; 2521our @ISA = CFClient::UI::HBox::;
2522 2522
2523sub new { 2523sub _item_to_desc {
2524 my $class = shift; 2524 my ($item) = @_;
2525 2525
2526 my %args = @_; 2526 my $desc =
2527
2528 my $item = delete $args{item};
2529
2530 my $desc = $item->{nrof} < 2 2527 $item->{nrof} < 2
2531 ? $item->{name} 2528 ? $item->{name}
2532 : "$item->{nrof} $item->{name_pl}"; 2529 : "$item->{nrof} $item->{name_pl}";
2533 2530
2534 $item->{flags} & Crossfire::Protocol::F_OPEN 2531 $item->{flags} & Crossfire::Protocol::F_OPEN
2535 and $desc .= " (open)"; 2532 and $desc .= " (open)";
2536 $item->{flags} & Crossfire::Protocol::F_APPLIED 2533 $item->{flags} & Crossfire::Protocol::F_APPLIED
2537 and $desc .= " (applied)"; 2534 and $desc .= " (applied)";
2544 $item->{flags} & Crossfire::Protocol::F_DAMNED 2541 $item->{flags} & Crossfire::Protocol::F_DAMNED
2545 and $desc .= " (damned)"; 2542 and $desc .= " (damned)";
2546 $item->{flags} & Crossfire::Protocol::F_LOCKED 2543 $item->{flags} & Crossfire::Protocol::F_LOCKED
2547 and $desc .= " *"; 2544 and $desc .= " *";
2548 2545
2546 $desc
2547}
2548
2549sub new {
2550 my $class = shift;
2551
2552 my %args = @_;
2553
2554 my $item = delete $args{item};
2555
2556 my $desc = _item_to_desc ($item);
2557
2549 my $self = $class->SUPER::new ( 2558 my $self = $class->SUPER::new (
2550 can_hover => 1, 2559 can_hover => 1,
2551 can_events => 1, 2560 can_events => 1,
2552 tooltip => ((CFClient::UI::Label::escape $desc) 2561 tooltip => ((CFClient::UI::Label::escape $desc)
2553 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"), 2562 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"),
2583 1 2592 1
2584 }, 2593 },
2585 %args 2594 %args
2586 ); 2595 );
2587 2596
2597
2588 $self->add (new CFClient::UI::Face 2598 $self->add (new CFClient::UI::Face
2589 can_events => 0, 2599 can_events => 0,
2590 face => $item->{face}, 2600 face => $item->{face},
2591 anim => $item->{anim}, 2601 anim => $item->{anim},
2592 animspeed => $item->{animspeed}, 2602 animspeed => $item->{animspeed},
2593 ); 2603 );
2594 2604
2595 $self->add (new CFClient::UI::Label 2605 $self->add ($self->{name_lbl} = new CFClient::UI::Label can_events => 0);
2596 can_events => 0, 2606
2597 text => $desc, 2607 $self->{item} = $item;
2598 ); 2608
2609 $self->update_item;
2599 2610
2600 $self 2611 $self
2612}
2613
2614sub update_item {
2615 my ($self) = @_;
2616
2617 my $desc = _item_to_desc ($self->{item});
2618
2619 $self->{name_lbl}->set_text ($desc);
2601} 2620}
2602 2621
2603############################################################################# 2622#############################################################################
2604 2623
2605package CFClient::UI::Inventory; 2624package CFClient::UI::Inventory;
2629 } @$items; 2648 } @$items;
2630 2649
2631 $self->{real_items} = \@items; 2650 $self->{real_items} = \@items;
2632 2651
2633 for my $item (@items) { 2652 for my $item (@items) {
2634 my $desc = $item->{nrof} < 2
2635 ? $item->{name}
2636 : "$item->{nrof} $item->{name_pl}";
2637
2638 $item = $item->{widget} ||= new CFClient::UI::InventoryItem item => $item; 2653 $item = $item->{widget} ||= new CFClient::UI::InventoryItem item => $item;
2654 $item->update_item ();
2639 } 2655 }
2640 2656
2641 $self->{scrolled}->add (@items); 2657 $self->{scrolled}->add (@items);
2642 2658
2643# $range->{range} = [$self->{pos}, 0, $self->{max_pos}, $page]; 2659# $range->{range} = [$self->{pos}, 0, $self->{max_pos}, $page];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines