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.185 by root, Mon May 8 17:23:08 2006 UTC

737 737
738 $self->{view_x} = int $x; 738 $self->{view_x} = int $x;
739 $self->{view_y} = int $y; 739 $self->{view_y} = int $y;
740 740
741 $self->update; 741 $self->update;
742}
743
744# hmm, this does not work for topleft of $self... but we should not aks for that
745sub _topleft {
746 my ($self, $x, $y) = @_;
747
748 $self->SUPER::_topleft ($x - $self->{view_x}, $y - $self->{view_y})
749}
750
751sub find_widget {
752 my ($self, $x, $y) = @_;
753
754 if ( $x >= $self->{x} && $x < $self->{x} + $self->{w}
755 && $y >= $self->{y} && $y < $self->{y} + $self->{h}
756 ) {
757 $self->child->find_widget ($x + $self->{view_x}, $y + $self->{view_y})
758 } else {
759 $self->CFClient::UI::Base::find_widget ($x, $y)
760 }
742} 761}
743 762
744sub _render { 763sub _render {
745 my ($self) = @_; 764 my ($self) = @_;
746 765
2464} 2483}
2465 2484
2466sub _draw { 2485sub _draw {
2467 my ($self) = @_; 2486 my ($self) = @_;
2468 2487
2488 return unless $::CONN;#d# manage and cache textures differently
2469 my $tex = $::CONN->{texture}[$::CONN->{faceid}[$self->{face}]]; 2489 my $tex = $::CONN->{texture}[$::CONN->{faceid}[$self->{face}]];
2470 2490
2471 # TODO animation 2491 # TODO animation
2472 if ($tex) { 2492 if ($tex) {
2473 glEnable GL_BLEND; 2493 glEnable GL_BLEND;
2634 $self->_draw; 2654 $self->_draw;
2635} 2655}
2636 2656
2637############################################################################# 2657#############################################################################
2638 2658
2659package CFClient::UI::InventoryItem;
2660
2661our @ISA = CFClient::UI::HBox::;
2662
2663sub new {
2664 my $class = shift;
2665
2666 my %args = @_;
2667
2668 my $item = $args{item};
2669
2670 my $desc = $item->{nrof} < 2
2671 ? $item->{name}
2672 : "$item->{nrof} $item->{name_pl}";
2673
2674
2675 my $self = $class->SUPER::new (
2676 can_hover => 1,
2677 can_events => 1,
2678 tooltip => (CFClient::UI::Label->escape ($desc)
2679 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"),
2680 connect_button_down => sub {
2681 my ($self, $ev, $x, $y) = @_;
2682
2683 # todo: maybe put examine on 1? but should just be a tooltip :(
2684 if ($ev->{button} == 1) {
2685 $::CONN->send ("move $::CONN->{player}{tag} $item->{tag} 0");
2686 } elsif ($ev->{button} == 2) {
2687 $::CONN->send ("apply $item->{tag}");
2688 } elsif ($ev->{button} == 3) {
2689 CFClient::UI::Menu->new (
2690 items => [
2691 ["examine", sub { $::CONN->send ("examine $item->{tag}") }],
2692 [
2693 $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock",
2694 sub { $::CONN->send ("lock $item->{tag}") },
2695 ],
2696 ["mark", sub { $::CONN->send ("mark $item->{tag}") }],
2697 ["apply", sub { $::CONN->send ("apply $item->{tag}") }],
2698 ["drop", sub { $::CONN->send ("move 0 $item->{tag} 0") }],
2699 ],
2700 )->popup ($ev);
2701 }
2702
2703 1
2704 },
2705 %args
2706 );
2707 $self->add(new CFClient::UI::Face
2708 can_events => 0,
2709 face => $item->{face},
2710 anim => $item->{anim},
2711 animspeed => $item->{animspeed});
2712 $self->add(new CFClient::UI::Label
2713 can_events => 0,
2714 text => $desc);
2715
2716 $self
2717}
2718
2719#############################################################################
2720
2639package CFClient::UI::Inventory; 2721package CFClient::UI::Inventory;
2640 2722
2641our @ISA = CFClient::UI::ScrolledWindow::; 2723our @ISA = CFClient::UI::ScrolledWindow::;
2642 2724
2643sub new { 2725sub new {
2664 for my $item (@items) { 2746 for my $item (@items) {
2665 my $desc = $item->{nrof} < 2 2747 my $desc = $item->{nrof} < 2
2666 ? $item->{name} 2748 ? $item->{name}
2667 : "$item->{nrof} $item->{name_pl}"; 2749 : "$item->{nrof} $item->{name_pl}";
2668 2750
2669 my $hb = new CFClient::UI::HBox; 2751 $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 } 2752 }
2681 2753
2682# $range->{range} = [$self->{pos}, 0, $self->{max_pos}, $page]; 2754# $range->{range} = [$self->{pos}, 0, $self->{max_pos}, $page];
2683} 2755}
2684 2756
2685sub size_request { 2757sub size_request {
2686 my ($self) = @_; 2758 my ($self) = @_;
2687 (100, 200) 2759 ($self->{req_w}, $self->{req_h});
2688} 2760}
2689 2761
2690############################################################################# 2762#############################################################################
2691 2763
2692package CFClient::UI; 2764package CFClient::UI;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines