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.182 by root, Sun Apr 30 11:17:08 2006 UTC vs.
Revision 1.183 by elmex, Sun Apr 30 13:10:46 2006 UTC

2634 $self->_draw; 2634 $self->_draw;
2635} 2635}
2636 2636
2637############################################################################# 2637#############################################################################
2638 2638
2639package CFClient::UI::InventoryItem;
2640
2641our @ISA = CFClient::UI::HBox::;
2642
2643sub new {
2644 my $class = shift;
2645
2646 my %args = @_;
2647
2648 my $item = $args{item};
2649
2650 my $desc = $item->{nrof} < 2
2651 ? $item->{name}
2652 : "$item->{nrof} $item->{name_pl}";
2653
2654
2655 my $self = $class->SUPER::new (
2656 can_hover => 1,
2657 can_events => 1,
2658 tooltip => (CFClient::UI::Label->escape ($desc)
2659 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"),
2660 connect_button_down => sub {
2661 my ($self, $ev, $x, $y) = @_;
2662
2663 # todo: maybe put examine on 1? but should just be a tooltip :(
2664 if ($ev->{button} == 1) {
2665 $::CONN->send ("move $::CONN->{player}{tag} $item->{tag} 0");
2666 } elsif ($ev->{button} == 2) {
2667 $::CONN->send ("apply $item->{tag}");
2668 } elsif ($ev->{button} == 3) {
2669 CFClient::UI::Menu->new (
2670 items => [
2671 ["examine", sub { $::CONN->send ("examine $item->{tag}") }],
2672 [
2673 $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock",
2674 sub { $::CONN->send ("lock $item->{tag}") },
2675 ],
2676 ["mark", sub { $::CONN->send ("mark $item->{tag}") }],
2677 ["apply", sub { $::CONN->send ("apply $item->{tag}") }],
2678 ["drop", sub { $::CONN->send ("move 0 $item->{tag} 0") }],
2679 ],
2680 )->popup ($ev);
2681 }
2682
2683 1
2684 },
2685 %args
2686 );
2687 $self->add(new CFClient::UI::Face
2688 can_events => 0,
2689 face => $item->{face},
2690 anim => $item->{anim},
2691 animspeed => $item->{animspeed});
2692 $self->add(new CFClient::UI::Label
2693 can_events => 0,
2694 text => $desc);
2695
2696 $self
2697}
2698
2699#############################################################################
2700
2639package CFClient::UI::Inventory; 2701package CFClient::UI::Inventory;
2640 2702
2641our @ISA = CFClient::UI::ScrolledWindow::; 2703our @ISA = CFClient::UI::ScrolledWindow::;
2642 2704
2643sub new { 2705sub new {
2664 for my $item (@items) { 2726 for my $item (@items) {
2665 my $desc = $item->{nrof} < 2 2727 my $desc = $item->{nrof} < 2
2666 ? $item->{name} 2728 ? $item->{name}
2667 : "$item->{nrof} $item->{name_pl}"; 2729 : "$item->{nrof} $item->{name_pl}";
2668 2730
2669 my $hb = new CFClient::UI::HBox; 2731 $self->{scrolled}->add (new CFClient::UI::InventoryItem item => $item);
2670
2671 $hb->add (my $f = new CFClient::UI::Face
2672 can_events => 0,
2673 face => $item->{face},
2674 anim => $item->{anim},
2675 animspeed => $item->{animspeed},
2676 expand => 1,
2677 );
2678 $hb->add (new CFClient::UI::Label text => $desc, expand => 1);
2679 $self->{scrolled}->add ($hb);
2680 } 2732 }
2681 2733
2682# $range->{range} = [$self->{pos}, 0, $self->{max_pos}, $page]; 2734# $range->{range} = [$self->{pos}, 0, $self->{max_pos}, $page];
2683} 2735}
2684 2736
2685sub size_request { 2737sub size_request {
2686 my ($self) = @_; 2738 my ($self) = @_;
2687 (100, 200) 2739 ($self->{req_w}, $self->{req_h});
2688} 2740}
2689 2741
2690############################################################################# 2742#############################################################################
2691 2743
2692package CFClient::UI; 2744package CFClient::UI;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines