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

2381 2381
2382use CFPlus::OpenGL; 2382use CFPlus::OpenGL;
2383 2383
2384my @tex = 2384my @tex =
2385 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 2385 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 }
2386 qw(b1_button_active.png); 2386 qw(b1_button_inactive.png b1_button_active.png);
2387 2387
2388sub new { 2388sub new {
2389 my $class = shift; 2389 my $class = shift;
2390 2390
2391 $class->SUPER::new ( 2391 $class->SUPER::new (
2392 padding_x => 4, 2392 padding_x => 4,
2393 padding_y => 4, 2393 padding_y => 4,
2394 fg => [1, 1, 1], 2394 fg => [1.0, 1.0, 1.0],
2395 active_fg => [0, 0, 1], 2395 active_fg => [0.8, 0.8, 0.8],
2396 can_hover => 1, 2396 can_hover => 1,
2397 align => 0, 2397 align => 0,
2398 valign => 0, 2398 valign => 0,
2399 can_events => 1, 2399 can_events => 1,
2400 @_ 2400 @_
2418 2418
2419 glEnable GL_TEXTURE_2D; 2419 glEnable GL_TEXTURE_2D;
2420 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 2420 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2421 glColor 0, 0, 0, 1; 2421 glColor 0, 0, 0, 1;
2422 2422
2423 my $tex = $tex[$GRAB == $self];
2423 $tex[0]->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); 2424 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h});
2424 2425
2425 glDisable GL_TEXTURE_2D; 2426 glDisable GL_TEXTURE_2D;
2426 2427
2427 $self->SUPER::_draw; 2428 $self->SUPER::_draw;
2428} 2429}
3493 ); 3494 );
3494 3495
3495 if ($self->{anim} && $self->{animspeed}) { 3496 if ($self->{anim} && $self->{animspeed}) {
3496 CFPlus::weaken (my $widget = $self); 3497 CFPlus::weaken (my $widget = $self);
3497 3498
3499 $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed};
3500 $widget->{anim_start} = $self->{animspeed} * Event::time / $self->{animspeed};
3498 $self->{timer} = Event->timer ( 3501 $self->{timer} = Event->timer (
3499 at => $self->{animspeed} * int $::NOW / $self->{animspeed},
3500 hard => 1, 3502 parked => 1,
3501 interval => $self->{animspeed},
3502 cb => sub { 3503 cb => sub {
3503 return unless $::CONN; 3504 return unless $::CONN && $widget;
3504 3505
3505 ++$widget->{frame}; 3506 ++$widget->{frame};
3506 $self->update_face; 3507 $widget->update_face;
3507 $self->update; 3508 $widget->update;
3509
3510 $widget->update_timer;
3508 }, 3511 },
3509 ); 3512 );
3510 3513
3511 $self->update_face; 3514 $self->update_face;
3515 $self->update_timer;
3512 } 3516 }
3513 3517
3514 $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 }
3515} 3536}
3516 3537
3517sub update_face { 3538sub update_face {
3518 my ($self) = @_; 3539 my ($self) = @_;
3519 3540
3551 return unless $self->{visible}; 3572 return unless $self->{visible};
3552 3573
3553 $self->SUPER::update; 3574 $self->SUPER::update;
3554} 3575}
3555 3576
3577sub invoke_visibility_change {
3578 my ($self) = @_;
3579
3580 $self->update_timer;
3581
3582 0
3583}
3584
3556sub _draw { 3585sub _draw {
3557 my ($self) = @_; 3586 my ($self) = @_;
3558 3587
3559 return unless $::CONN; 3588 return unless $::CONN;
3560 3589
3575} 3604}
3576 3605
3577sub destroy { 3606sub destroy {
3578 my ($self) = @_; 3607 my ($self) = @_;
3579 3608
3580 $self->{timer}->cancel 3609 (delete $self->{timer})->cancel
3581 if $self->{timer}; 3610 if $self->{timer};
3582 3611
3583 $self->SUPER::destroy; 3612 $self->SUPER::destroy;
3584} 3613}
3585 3614
4229 while ($self->{post_alloc_hook}) { 4258 while ($self->{post_alloc_hook}) {
4230 $_->() 4259 $_->()
4231 for values %{delete $self->{post_alloc_hook}}; 4260 for values %{delete $self->{post_alloc_hook}};
4232 } 4261 }
4233 4262
4234
4235 glViewport 0, 0, $::WIDTH, $::HEIGHT; 4263 glViewport 0, 0, $::WIDTH, $::HEIGHT;
4236 glClearColor +($::CFG->{fow_intensity}) x 3, 1; 4264 glClearColor +($::CFG->{fow_intensity}) x 3, 1;
4237 glClear GL_COLOR_BUFFER_BIT; 4265 glClear GL_COLOR_BUFFER_BIT;
4238 4266
4239 glMatrixMode GL_PROJECTION; 4267 glMatrixMode GL_PROJECTION;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines