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.216 by root, Fri May 19 16:43:57 2006 UTC vs.
Revision 1.217 by root, Fri May 19 23:18:42 2006 UTC

797 $self->{vp}->set_offset (0, $_[1] * ($self->{vp}{child_h} - $self->{vp}{h})); 797 $self->{vp}->set_offset (0, $_[1] * ($self->{vp}{child_h} - $self->{vp}{h}));
798 }, 798 },
799 ; 799 ;
800 800
801 $self = $class->SUPER::new ( 801 $self = $class->SUPER::new (
802 vp => (new CFClient::UI::ViewPort), 802 vp => (new CFClient::UI::ViewPort expand => 1),
803 slider => $slider, 803 slider => $slider,
804 @_, 804 @_,
805 ); 805 );
806 806
807 $self->{vp}->add ($self->{scrolled}); 807 $self->{vp}->add ($self->{scrolled});
2050 range => [0, 0, 100, 10], 2050 range => [0, 0, 100, 10],
2051 req_w => $::WIDTH / 80, 2051 req_w => $::WIDTH / 80,
2052 req_h => $::WIDTH / 80, 2052 req_h => $::WIDTH / 80,
2053 vertical => 0, 2053 vertical => 0,
2054 can_hover => 1, 2054 can_hover => 1,
2055 inner_pad => .05, 2055 inner_pad => 0.02,
2056 @_ 2056 @_
2057 ); 2057 );
2058 2058
2059 $self->set_value ($self->{range}[0]); 2059 $self->set_value ($self->{range}[0]);
2060 $self->update; 2060 $self->update;
2489use CFClient::OpenGL; 2489use CFClient::OpenGL;
2490 2490
2491sub new { 2491sub new {
2492 my $class = shift; 2492 my $class = shift;
2493 2493
2494 $class->SUPER::new ( 2494 my $self = $class->SUPER::new (
2495 aspect => 1, 2495 aspect => 1,
2496 @_, 2496 @_,
2497 ) 2497 );
2498
2499 if ($self->{anim} && $self->{animspeed}) {
2500 Scalar::Util::weaken (my $widget = $self);
2501
2502 $self->{timer} = Event->timer (
2503 at => $self->{animspeed} * int $::NOW / $self->{animspeed},
2504 hard => 1,
2505 interval => $self->{animspeed},
2506 cb => sub {
2507 ++$widget->{frame};
2508 $widget->update;
2509 },
2510 );
2511 }
2512
2513 $self
2498} 2514}
2499 2515
2500sub size_request { 2516sub size_request {
2501 (32, 8) 2517 (32, 8)
2502} 2518}
2503 2519
2504sub _draw { 2520sub _draw {
2505 my ($self) = @_; 2521 my ($self) = @_;
2506 2522
2507 return unless $::CONN;#d# manage and cache textures differently 2523 return unless $::CONN;#d# manage and cache textures differently
2524
2525 my $face;
2526
2527 if ($self->{frame}) {
2528 my $anim = $::CONN->{anim}[$self->{anim}];
2529
2530 $face = $anim->[ $self->{frame} % @$anim ]
2531 if $anim && @$anim;
2532 }
2533
2508 my $tex = $::CONN->{texture}[$::CONN->{faceid}[$self->{face}]]; 2534 my $tex = $::CONN->{texture}[$::CONN->{faceid}[$face || $self->{face}]];
2509 2535
2510 # TODO animation
2511 if ($tex) { 2536 if ($tex) {
2512 glEnable GL_TEXTURE_2D; 2537 glEnable GL_TEXTURE_2D;
2513 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 2538 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2514 glColor 1, 1, 1, 1; 2539 glColor 1, 1, 1, 1;
2515 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); 2540 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h});
2516 glDisable GL_TEXTURE_2D; 2541 glDisable GL_TEXTURE_2D;
2517 } 2542 }
2518} 2543}
2519 2544
2545sub DESTROY {
2546 my ($self) = @_;
2547
2548 $self->{timer}->cancel
2549 if $self->{timer};
2550
2551 $self->SUPER::DESTROY;
2552}
2553
2520############################################################################# 2554#############################################################################
2521 2555
2522package CFClient::UI::InventoryItem; 2556package CFClient::UI::InventoryItem;
2523 2557
2524our @ISA = CFClient::UI::HBox::; 2558our @ISA = CFClient::UI::HBox::;
2527 my ($item) = @_; 2561 my ($item) = @_;
2528 2562
2529 my $desc = 2563 my $desc =
2530 $item->{nrof} < 2 2564 $item->{nrof} < 2
2531 ? $item->{name} 2565 ? $item->{name}
2532 : "$item->{nrof} $item->{name_pl}"; 2566 : "$item->{nrof} × $item->{name_pl}";
2533 2567
2534 $item->{flags} & Crossfire::Protocol::F_OPEN 2568 $item->{flags} & Crossfire::Protocol::F_OPEN
2535 and $desc .= " (open)"; 2569 and $desc .= " (open)";
2536 $item->{flags} & Crossfire::Protocol::F_APPLIED 2570 $item->{flags} & Crossfire::Protocol::F_APPLIED
2537 and $desc .= " (applied)"; 2571 and $desc .= " (applied)";
2557 my $item = delete $args{item}; 2591 my $item = delete $args{item};
2558 2592
2559 my $desc = _item_to_desc ($item); 2593 my $desc = _item_to_desc ($item);
2560 2594
2561 my $self = $class->SUPER::new ( 2595 my $self = $class->SUPER::new (
2562 can_hover => 1, 2596 can_hover => 1,
2563 can_events => 1, 2597 can_events => 1,
2564 tooltip => ((CFClient::UI::Label::escape $desc) 2598 tooltip => ((CFClient::UI::Label::escape $desc)
2565 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"), 2599 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"),
2566 connect_button_down => sub { 2600 connect_button_down => sub {
2567 my ($self, $ev, $x, $y) = @_; 2601 my ($self, $ev, $x, $y) = @_;
2568 2602
2569 # todo: maybe put examine on 1? but should just be a tooltip :( 2603 # todo: maybe put examine on 1? but should just be a tooltip :(

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines