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.424 by root, Mon Aug 6 05:31:12 2007 UTC vs.
Revision 1.429 by root, Tue Aug 21 00:59:34 2007 UTC

2044 : ($self->{w} - $size->[0]) * 0.5); 2044 : ($self->{w} - $size->[0]) * 0.5);
2045 2045
2046 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y} 2046 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y}
2047 : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y} 2047 : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y}
2048 : ($self->{h} - $size->[1]) * 0.5); 2048 : ($self->{h} - $size->[1]) * 0.5);
2049
2050 $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style});
2049 }; 2051 };
2050 2052
2051# unless ($self->{list}) { 2053# unless ($self->{list}) {
2052# $self->{list} = CFPlus::OpenGL::glGenList; 2054# $self->{list} = CFPlus::OpenGL::glGenList;
2053# CFPlus::OpenGL::glNewList $self->{list}; 2055# CFPlus::OpenGL::glNewList $self->{list};
2055# CFPlus::OpenGL::glEndList; 2057# CFPlus::OpenGL::glEndList;
2056# } 2058# }
2057# 2059#
2058# CFPlus::OpenGL::glCallList $self->{list}; 2060# CFPlus::OpenGL::glCallList $self->{list};
2059 2061
2060 $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); 2062 $self->{layout}->draw;
2061} 2063}
2062 2064
2063#sub destroy { 2065#sub destroy {
2064# my ($self) = @_; 2066# my ($self) = @_;
2065# 2067#
2651 can_events => 1, 2653 can_events => 1,
2652 @_ 2654 @_
2653 ); 2655 );
2654} 2656}
2655 2657
2658sub invoke_button_down {
2659 my ($self, $ev, $x, $y) = @_;
2660
2661 1
2662}
2663
2656sub invoke_button_up { 2664sub invoke_button_up {
2657 my ($self, $ev, $x, $y) = @_; 2665 my ($self, $ev, $x, $y) = @_;
2658 2666
2659 $self->emit ("activate") 2667 $self->emit ("activate")
2660 if $x >= 0 && $x < $self->{w} 2668 if $x >= 0 && $x < $self->{w}
3304 3312
3305 if ($y0 < $y + $h && $y < $y1) { 3313 if ($y0 < $y + $h && $y < $y1) {
3306 my $layout = $self->get_layout ($para); 3314 my $layout = $self->get_layout ($para);
3307 3315
3308 $layout->render ($para->{indent}, $y - $y0); 3316 $layout->render ($para->{indent}, $y - $y0);
3317 $layout->draw;
3309 3318
3310 if (my @w = @{ $para->{widget} }) { 3319 if (my @w = @{ $para->{widget} }) {
3311 my @s = $layout->get_shapes; 3320 my @s = $layout->get_shapes;
3312 3321
3313 for (@w) { 3322 for (@w) {
3546 $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed}; 3555 $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed};
3547 $widget->{anim_start} = $self->{animspeed} * int Event::time / $self->{animspeed}; 3556 $widget->{anim_start} = $self->{animspeed} * int Event::time / $self->{animspeed};
3548 $self->{timer} = Event->timer ( 3557 $self->{timer} = Event->timer (
3549 parked => 1, 3558 parked => 1,
3550 cb => sub { 3559 cb => sub {
3551 return unless $::CONN && $widget; 3560 return unless $::CONN;
3552 3561
3562 my $w = $widget
3563 or return;
3564
3553 ++$widget->{frame}; 3565 ++$w->{frame};
3554 $widget->update_face; 3566 $w->update_face;
3567
3568 # somehow, $widget can go away
3555 $widget->update; 3569 $w->update;
3556
3557 $widget->update_timer; 3570 $w->update_timer;
3558 }, 3571 },
3559 ); 3572 );
3560 3573
3561 $self->update_face; 3574 $self->update_face;
3562 $self->update_timer; 3575 $self->update_timer;
3583} 3596}
3584 3597
3585sub update_face { 3598sub update_face {
3586 my ($self) = @_; 3599 my ($self) = @_;
3587 3600
3588 return unless $::CONN; 3601 if ($::CONN) {
3589
3590 if (my $anim = $::CONN->{anim}[$self->{anim}]) { 3602 if (my $anim = $::CONN->{anim}[$self->{anim}]) {
3591 if ($anim && @$anim) { 3603 if ($anim && @$anim) {
3592 delete $self->{wait_face};
3593 $self->{face} = $anim->[ $self->{frame} % @$anim ]; 3604 $self->{face} = $anim->[ $self->{frame} % @$anim ];
3605 delete $self->{face_change_cb};
3606
3594 if (my $tex = $self->{tex} = $::CONN->{texture}[ $::CONN->{faceid}[$self->{face}] ]) { 3607 if (my $tex = $self->{tex} = $::CONN->{texture}[ $::CONN->{face}[$self->{face}]{id} ]) {
3595 unless ($tex->{name} || $tex->{loading}) { 3608 unless ($tex->{name} || $tex->{loading}) {
3596 $tex->upload (sub { $self->reconfigure }); 3609 $tex->upload (sub { $self->reconfigure });
3610 }
3597 } 3611 }
3598 } 3612 }
3599 } 3613 }
3600 } 3614 }
3601} 3615}
3602 3616
3603sub size_request { 3617sub size_request {
3604 my ($self) = @_; 3618 my ($self) = @_;
3605 3619
3606 if ($::CONN) { 3620 if ($::CONN) {
3607 if (my $faceid = $::CONN->{faceid}[$self->{face}]) { 3621 if (my $faceid = $::CONN->{face}[$self->{face}]{id}) {
3608 if (my $tex = $self->{tex} = $::CONN->{texture}[$faceid]) { 3622 if (my $tex = $self->{tex} = $::CONN->{texture}[$faceid]) {
3609 if ($tex->{name}) { 3623 if ($tex->{name}) {
3610 return ($self->{size_w} || $tex->{w}, $self->{size_h} || $tex->{h}); 3624 return ($self->{size_w} || $tex->{w}, $self->{size_h} || $tex->{h});
3611 } elsif (!$tex->{loading}) { 3625 } elsif (!$tex->{loading}) {
3612 $tex->upload (sub { $self->reconfigure }); 3626 $tex->upload (sub { $self->reconfigure });
3613 } 3627 }
3614 } else {
3615 $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub {
3616 $self->reconfigure;
3617 });
3618 } 3628 }
3629
3630 $self->{face_change_cb} ||= $::CONN->on_face_change ($self->{face}, sub { $self->reconfigure });
3619 } 3631 }
3620 } 3632 }
3621 3633
3622 ($self->{size_w} || 8, $self->{size_h} || 8) 3634 ($self->{size_w} || 8, $self->{size_h} || 8)
3623} 3635}
4206} 4218}
4207 4219
4208sub update { 4220sub update {
4209 my ($self) = @_; 4221 my ($self) = @_;
4210 4222
4211 $::WANT_REFRESH++; 4223 $::WANT_REFRESH->start;
4212} 4224}
4213 4225
4214sub add { 4226sub add {
4215 my ($self, @children) = @_; 4227 my ($self, @children) = @_;
4216 4228

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines