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.377 by root, Mon Jul 16 20:20:30 2007 UTC vs.
Revision 1.381 by root, Thu Jul 19 13:45:18 2007 UTC

986} 986}
987 987
988sub set_offset { 988sub set_offset {
989 my ($self, $x, $y) = @_; 989 my ($self, $x, $y) = @_;
990 990
991 $self->{view_x} = max 0, min $self->child->{w} - $self->{w}, int $x; 991 my $x = max 0, min $self->child->{w} - $self->{w}, int $x;
992 $self->{view_y} = max 0, min $self->child->{h} - $self->{h}, int $y; 992 my $y = max 0, min $self->child->{h} - $self->{h}, int $y;
993 993
994 $self->emit (changed => $self->{view_x}, $self->{view_y}); 994 if ($x != $self->{view_x} or $y != $self->{view_y}) {
995 $self->{view_x} = $x;
996 $self->{view_y} = $y;
997
998 $self->emit (changed => $x, $y);
995 $self->update; 999 $self->update;
1000 }
996} 1001}
997 1002
998# hmm, this does not work for topleft of $self... but we should not ask for that 1003# hmm, this does not work for topleft of $self... but we should not ask for that
999sub coord2local { 1004sub coord2local {
1000 my ($self, $x, $y) = @_; 1005 my ($self, $x, $y) = @_;
2376 2381
2377use CFPlus::OpenGL; 2382use CFPlus::OpenGL;
2378 2383
2379my @tex = 2384my @tex =
2380 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 2385 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 }
2381 qw(b1_button_active.png); 2386 qw(b1_button_inactive.png b1_button_active.png);
2382 2387
2383sub new { 2388sub new {
2384 my $class = shift; 2389 my $class = shift;
2385 2390
2386 $class->SUPER::new ( 2391 $class->SUPER::new (
2387 padding_x => 4, 2392 padding_x => 4,
2388 padding_y => 4, 2393 padding_y => 4,
2389 fg => [1, 1, 1], 2394 fg => [1.0, 1.0, 1.0],
2390 active_fg => [0, 0, 1], 2395 active_fg => [0.8, 0.8, 0.8],
2391 can_hover => 1, 2396 can_hover => 1,
2392 align => 0, 2397 align => 0,
2393 valign => 0, 2398 valign => 0,
2394 can_events => 1, 2399 can_events => 1,
2395 @_ 2400 @_
2413 2418
2414 glEnable GL_TEXTURE_2D; 2419 glEnable GL_TEXTURE_2D;
2415 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 2420 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2416 glColor 0, 0, 0, 1; 2421 glColor 0, 0, 0, 1;
2417 2422
2423 my $tex = $tex[$GRAB == $self];
2418 $tex[0]->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); 2424 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h});
2419 2425
2420 glDisable GL_TEXTURE_2D; 2426 glDisable GL_TEXTURE_2D;
2421 2427
2422 $self->SUPER::_draw; 2428 $self->SUPER::_draw;
2423} 2429}
3488 ); 3494 );
3489 3495
3490 if ($self->{anim} && $self->{animspeed}) { 3496 if ($self->{anim} && $self->{animspeed}) {
3491 CFPlus::weaken (my $widget = $self); 3497 CFPlus::weaken (my $widget = $self);
3492 3498
3499 $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed};
3500 $widget->{anim_start} = $self->{animspeed} * Event::time / $self->{animspeed};
3493 $self->{timer} = Event->timer ( 3501 $self->{timer} = Event->timer (
3494 at => $self->{animspeed} * int $::NOW / $self->{animspeed},
3495 hard => 1, 3502 parked => 1,
3496 interval => $self->{animspeed},
3497 cb => sub { 3503 cb => sub {
3498 return unless $::CONN; 3504 return unless $::CONN && $widget;
3499 3505
3500 ++$widget->{frame}; 3506 ++$widget->{frame};
3501 $self->update_face; 3507 $widget->update_face;
3502 $self->update; 3508 $widget->update;
3509
3510 $widget->update_timer;
3503 }, 3511 },
3504 ); 3512 );
3505 3513
3506 $self->update_face; 3514 $self->update_face;
3515 $self->update_timer;
3507 } 3516 }
3508 3517
3509 $self 3518 $self
3519}
3520
3521sub update_timer {
3522 my ($self) = @_;
3523
3524 return unless $self->{timer};
3525
3526 if ($self->{visible}) {
3527 $self->{timer}->at (
3528 $self->{anim_start}
3529 + $self->{animspeed}
3530 * int 1.5 + (Event::time - $self->{anim_start}) / $self->{animspeed}
3531 );
3532 $self->{timer}->start;
3533 } else {
3534 $self->{timer}->stop;
3535 }
3510} 3536}
3511 3537
3512sub update_face { 3538sub update_face {
3513 my ($self) = @_; 3539 my ($self) = @_;
3514 3540
3546 return unless $self->{visible}; 3572 return unless $self->{visible};
3547 3573
3548 $self->SUPER::update; 3574 $self->SUPER::update;
3549} 3575}
3550 3576
3577sub invoke_visibility_change {
3578 my ($self) = @_;
3579
3580 $self->update_timer;
3581
3582 0
3583}
3584
3551sub _draw { 3585sub _draw {
3552 my ($self) = @_; 3586 my ($self) = @_;
3553 3587
3554 return unless $::CONN; 3588 return unless $::CONN;
3555 3589
3570} 3604}
3571 3605
3572sub destroy { 3606sub destroy {
3573 my ($self) = @_; 3607 my ($self) = @_;
3574 3608
3575 $self->{timer}->cancel 3609 (delete $self->{timer})->cancel
3576 if $self->{timer}; 3610 if $self->{timer};
3577 3611
3578 $self->SUPER::destroy; 3612 $self->SUPER::destroy;
3579} 3613}
3580 3614
4224 while ($self->{post_alloc_hook}) { 4258 while ($self->{post_alloc_hook}) {
4225 $_->() 4259 $_->()
4226 for values %{delete $self->{post_alloc_hook}}; 4260 for values %{delete $self->{post_alloc_hook}};
4227 } 4261 }
4228 4262
4229
4230 glViewport 0, 0, $::WIDTH, $::HEIGHT; 4263 glViewport 0, 0, $::WIDTH, $::HEIGHT;
4231 glClearColor +($::CFG->{fow_intensity}) x 3, 1; 4264 glClearColor +($::CFG->{fow_intensity}) x 3, 1;
4232 glClear GL_COLOR_BUFFER_BIT; 4265 glClear GL_COLOR_BUFFER_BIT;
4233 4266
4234 glMatrixMode GL_PROJECTION; 4267 glMatrixMode GL_PROJECTION;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines