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.369 by root, Sun Jul 15 20:25:26 2007 UTC vs.
Revision 1.387 by root, Fri Jul 20 18:19:45 2007 UTC

547 547
548 # parent 548 # parent
549 $self->{parent} && $self->{parent}->emit ($signal, @args) 549 $self->{parent} && $self->{parent}->emit ($signal, @args)
550} 550}
551 551
552sub find_widget { 552#sub find_widget {
553 my ($self, $x, $y) = @_; 553# in .xs
554
555 return () unless $self->{can_events};
556
557 return $self
558 if $x >= $self->{x} && $x < $self->{x} + $self->{w}
559 && $y >= $self->{y} && $y < $self->{y} + $self->{h};
560
561 ()
562}
563 554
564sub set_parent { 555sub set_parent {
565 my ($self, $parent) = @_; 556 my ($self, $parent) = @_;
566 557
567 CFPlus::weaken ($self->{parent} = $parent); 558 CFPlus::weaken ($self->{parent} = $parent);
944 935
945############################################################################# 936#############################################################################
946 937
947package CFPlus::UI::ViewPort; 938package CFPlus::UI::ViewPort;
948 939
940use List::Util qw(min max);
941
949our @ISA = CFPlus::UI::Window::; 942our @ISA = CFPlus::UI::Window::;
950 943
951sub new { 944sub new {
952 my $class = shift; 945 my $class = shift;
953 946
984} 977}
985 978
986sub set_offset { 979sub set_offset {
987 my ($self, $x, $y) = @_; 980 my ($self, $x, $y) = @_;
988 981
982 my $x = max 0, min $self->child->{w} - $self->{w}, int $x;
983 my $y = max 0, min $self->child->{h} - $self->{h}, int $y;
984
985 if ($x != $self->{view_x} or $y != $self->{view_y}) {
989 $self->{view_x} = int $x; 986 $self->{view_x} = $x;
990 $self->{view_y} = int $y; 987 $self->{view_y} = $y;
991 988
989 $self->emit (changed => $x, $y);
992 $self->update; 990 $self->update;
991 }
993} 992}
994 993
995# hmm, this does not work for topleft of $self... but we should not ask for that 994# hmm, this does not work for topleft of $self... but we should not ask for that
996sub coord2local { 995sub coord2local {
997 my ($self, $x, $y) = @_; 996 my ($self, $x, $y) = @_;
1012 my ($self, $x, $y) = @_; 1011 my ($self, $x, $y) = @_;
1013 1012
1014 if ( $x >= $self->{x} && $x < $self->{x} + $self->{w} 1013 if ( $x >= $self->{x} && $x < $self->{x} + $self->{w}
1015 && $y >= $self->{y} && $y < $self->{y} + $self->{h} 1014 && $y >= $self->{y} && $y < $self->{y} + $self->{h}
1016 ) { 1015 ) {
1017 $self->child->find_widget ($x + $self->{view_x}, $y + $self->{view_y}) 1016 $self->child->find_widget ($x + $self->{view_x}, $y + $self->{view_y})
1018 } else { 1017 } else {
1019 $self->CFPlus::UI::Base::find_widget ($x, $y) 1018 $self->CFPlus::UI::Base::find_widget ($x, $y)
1020 } 1019 }
1021} 1020}
1022 1021
1061 $self->{vp}->set_offset ($self->{hpos}, $self->{vpos}); 1060 $self->{vp}->set_offset ($self->{hpos}, $self->{vpos});
1062 }, 1061 },
1063 ; 1062 ;
1064 1063
1065 $self = $class->SUPER::new ( 1064 $self = $class->SUPER::new (
1066 vp => (new CFPlus::UI::ViewPort expand => 1), 1065 scroll_x => 0,
1066 scroll_y => 1,
1067 can_events => 1, 1067 can_events => 1,
1068 hslider => $hslider, 1068 hslider => $hslider,
1069 vslider => $vslider, 1069 vslider => $vslider,
1070 col_expand => [1, 0], 1070 col_expand => [1, 0],
1071 row_expand => [1, 0], 1071 row_expand => [1, 0],
1072 %arg, 1072 %arg,
1073 ); 1073 );
1074 1074
1075 $self->{vp} = new CFPlus::UI::ViewPort
1076 expand => 1,
1077 scroll_x => $self->{scroll_x},
1078 scroll_y => $self->{scroll_y},
1079 on_changed => sub {
1080 my ($vp, $x, $y) = @_;
1081
1082 $vp->{parent}{hslider}->set_value ($x);
1083 $vp->{parent}{vslider}->set_value ($y);
1084
1085 0
1086 },
1087 ;
1088
1075 $self->SUPER::add (0, 0, $self->{vp}); 1089 $self->SUPER::add_at (0, 0, $self->{vp});
1076 $self->SUPER::add (1, 0, $self->{vslider});
1077 $self->SUPER::add (0, 1, $self->{hslider});
1078 1090
1079 $self->add ($child) if $child; 1091 $self->add ($child) if $child;
1080 1092
1081 $self 1093 $self
1082} 1094}
1087 my ($self, $widget) = @_; 1099 my ($self, $widget) = @_;
1088 1100
1089 $self->{vp}->add ($self->{child} = $widget); 1101 $self->{vp}->add ($self->{child} = $widget);
1090} 1102}
1091 1103
1104sub update_slider {
1105 my ($self) = @_;
1106
1107 my $child = ($self->{vp} or return)->child;
1108
1109 my ($w1, $w2) = ($child->{w}, $self->{vp}{w});
1110 $self->{hslider}->set_range ([$self->{hslider}{range}[0], 0, $w1, $w2, 1]);
1111
1112 my $visible = $w1 > $w2;
1113 if ($visible != $self->{hslider}{visible}) {
1114 $visible ? $self->SUPER::add_at (0, 1, $self->{hslider})
1115 : $self->{hslider}->hide;
1116 }
1117
1118 my ($h1, $h2) = ($child->{h}, $self->{vp}{h});
1119 $self->{vslider}->set_range ([$self->{vslider}{range}[0], 0, $h1, $h2, 1]);
1120
1121 my $visible = $h1 > $h2;
1122 if ($visible != $self->{vslider}{visible}) {
1123 $visible ? $self->SUPER::add_at (1, 0, $self->{vslider})
1124 : $self->{vslider}->hide;
1125 }
1126}
1127
1128sub update {
1129 my ($self) = @_;
1130
1131 $self->update_slider;
1132 $self->SUPER::update;
1133}
1134
1092sub invoke_mouse_wheel { 1135sub invoke_mouse_wheel {
1093 my ($self, $ev) = @_; 1136 my ($self, $ev) = @_;
1094 1137
1095 return 0 unless $ev->{dy}; # only vertical movements 1138 return 0 unless $ev->{dy}; # only vertical movements for now
1096 1139
1097 $self->{vslider}->emit (mouse_wheel => $ev); 1140 $self->{vslider}->emit (mouse_wheel => $ev);
1098 1141
1099 1 1142 1
1100} 1143}
1101 1144
1102sub update_slider { 1145sub invoke_button_down {
1103 my ($self) = @_; 1146 my ($self, $ev, $x, $y) = @_;
1104 1147
1105 my ($w1, $w2) = ($self->{vp}->child->{w}, $self->{vp}{w}); 1148 if ($ev->{button} == 2) {
1106 $self->{hslider}->set_range ([$self->{hslider}{range}[0], 0, $w1, $w2, 1]); 1149 $self->grab_focus;
1107 #$self->{hslider}->set_visibility ($w1 != $w2);
1108 1150
1109 my ($h1, $h2) = ($self->{vp}->child->{h}, $self->{vp}{h}); 1151 my $ox = $self->{vp}{view_x} + $ev->{x};
1110 $self->{vslider}->set_range ([$self->{vslider}{range}[0], 0, $h1, $h2, 1]); 1152 my $oy = $self->{vp}{view_y} + $ev->{y};
1111 #$self->{vslider}->set_visibility ($h1 != $h2); 1153
1112} 1154 $self->{motion} = sub {
1155 my ($ev, $x, $y) = @_;
1113 1156
1114sub update { 1157 $self->{vp}->set_offset ($ox - $ev->{x}, $oy - $ev->{y});
1115 my ($self) = @_; 1158 $self->update;
1159 };
1116 1160
1117 $self->SUPER::update; 1161 return 1;
1162 }
1118 1163
1119 $self->update_slider; 1164 0
1165}
1166
1167sub invoke_button_up {
1168 my ($self, $ev, $x, $y) = @_;
1169
1170 if (delete $self->{motion}) {
1171 return 1;
1172 }
1173
1174 0
1175}
1176
1177sub invoke_mouse_motion {
1178 my ($self, $ev, $x, $y) = @_;
1179
1180 if ($self->{motion}) {
1181 $self->{motion}->($ev, $x, $y);
1182 return 1;
1183 }
1184
1185 0
1120} 1186}
1121 1187
1122sub invoke_size_allocate { 1188sub invoke_size_allocate {
1123 my ($self, $w, $h) = @_; 1189 my ($self, $w, $h) = @_;
1124 1190
1125 $self->update_slider; 1191 $self->update_slider;
1126
1127 $self->SUPER::invoke_size_allocate ($w, $h) 1192 $self->SUPER::invoke_size_allocate ($w, $h)
1128} 1193}
1129 1194
1130############################################################################# 1195#############################################################################
1131 1196
1281 1346
1282my @border = 1347my @border =
1283 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 1348 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 }
1284 qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); 1349 qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png);
1285 1350
1351my @icon =
1352 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 }
1353 qw(x1_move.png x1_resize.png);
1354
1286sub new { 1355sub new {
1287 my ($class, %arg) = @_; 1356 my ($class, %arg) = @_;
1288 1357
1289 my $self = $class->SUPER::new ( 1358 my $self = $class->SUPER::new (
1290 bg => [1, 1, 1, 1], 1359 bg => [1, 1, 1, 1],
1458 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 1527 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
1459 1528
1460 my $border = $self->border; 1529 my $border = $self->border;
1461 1530
1462 glColor @{ $self->{border_bg} }; 1531 glColor @{ $self->{border_bg} };
1463 $border[0]->draw_quad_alpha (0, 0, $w, $border); 1532 $border[0]->draw_quad_alpha ( 0, 0, $w, $border);
1464 $border[1]->draw_quad_alpha (0, $border, $border, $ch); 1533 $border[1]->draw_quad_alpha ( 0, $border, $border, $ch);
1465 $border[2]->draw_quad_alpha ($w - $border, $border, $border, $ch); 1534 $border[2]->draw_quad_alpha ($w - $border, $border, $border, $ch);
1466 $border[3]->draw_quad_alpha (0, $h - $border, $w, $border); 1535 $border[3]->draw_quad_alpha ( 0, $h - $border, $w, $border);
1536
1537 # move
1538 my $w2 = ($w - $border) * .5;
1539 my $h2 = ($h - $border) * .5;
1540 $icon[0]->draw_quad_alpha ( 0, $h2, $border, $border);
1541 $icon[0]->draw_quad_alpha ($w - $border, $h2, $border, $border);
1542 $icon[0]->draw_quad_alpha ($w2 , $h - $border, $border, $border);
1543
1544 # resize
1545 $icon[1]->draw_quad_alpha ( 0, 0, $border, $border);
1546 $icon[1]->draw_quad_alpha ($w - $border, 0, $border, $border)
1547 unless $self->{has_close_button};
1548 $icon[1]->draw_quad_alpha ( 0, $h - $border, $border, $border);
1549 $icon[1]->draw_quad_alpha ($w - $border, $h - $border, $border, $border);
1467 1550
1468 if (@{$self->{bg}} < 4 || $self->{bg}[3]) { 1551 if (@{$self->{bg}} < 4 || $self->{bg}[3]) {
1469 glColor @{ $self->{bg} }; 1552 glColor @{ $self->{bg} };
1470 1553
1471 # TODO: repeat texture not scale 1554 # TODO: repeat texture not scale
1502 1585
1503sub new { 1586sub new {
1504 my $class = shift; 1587 my $class = shift;
1505 1588
1506 $class->SUPER::new ( 1589 $class->SUPER::new (
1590 children => [],
1507 col_expand => [], 1591 col_expand => [],
1508 row_expand => [], 1592 row_expand => [],
1509 @_, 1593 @_,
1510 ) 1594 )
1511} 1595}
1512 1596
1513sub children { 1597sub children {
1514 grep $_, map @$_, grep $_, @{ $_[0]{children} } 1598 grep $_, map @$_, grep $_, @{ $_[0]{children} }
1515} 1599}
1516 1600
1601# TODO: store row/col info in child widget and use standard add/del
1517sub add { 1602sub add {
1518 my ($self) = shift; 1603 my $self = shift;
1604
1605 Carp::cluck "please use the add_at method instead of calling add, thank you.\n";#d#
1606 $self->add_at (@_);
1607}
1608
1609sub add_at {
1610 my $self = shift;
1519 1611
1520 while (@_) { 1612 while (@_) {
1521 my ($x, $y, $child) = splice @_, 0, 3, (); 1613 my ($col, $row, $child) = splice @_, 0, 3, ();
1614
1522 $child->set_parent ($self); 1615 $child->set_parent ($self);
1523 $self->{children}[$y][$x] = $child; 1616 $self->{children}[$row][$col] = $child;
1524 } 1617 }
1525 1618
1526 $self->{force_realloc} = 1; 1619 $self->{force_realloc} = 1;
1527 $self->{force_size_alloc} = 1; 1620 $self->{force_size_alloc} = 1;
1528 $self->realloc; 1621 $self->realloc;
1529} 1622}
1530 1623
1531sub remove { 1624sub remove {
1532 my ($self, $child) = @_; 1625 my ($self, $child) = @_;
1533 1626
1534 # TODO: not yet implemented 1627 for (@{ $self->{children} }) {
1628 for (@{ $_ || [] }) {
1629 $_ = undef if $_ == $child;
1630 }
1631 }
1535} 1632}
1536 1633
1537# TODO: move to container class maybe? send children a signal on removal? 1634# TODO: move to container class maybe? send children a signal on removal?
1538sub clear { 1635sub clear {
1539 my ($self) = @_; 1636 my ($self) = @_;
1652 my ($self) = @_; 1749 my ($self) = @_;
1653 1750
1654 for (grep $_, @{$self->{children}}) { 1751 for (grep $_, @{$self->{children}}) {
1655 $_->draw for grep $_, @$_; 1752 $_->draw for grep $_, @$_;
1656 } 1753 }
1754}
1755
1756#############################################################################
1757
1758package CFPlus::UI::Fixed;
1759
1760use List::Util qw(min max);
1761
1762our @ISA = CFPlus::UI::Container::;
1763
1764sub add {
1765 my ($self, $child, $posmode, $x, $y, $sizemode, $w, $h) = @_;
1766
1767 $child->{_fixed} = [$posmode, $x, $y, $sizemode, $w, $h];
1768 $self->SUPER::add ($child);
1769}
1770
1771sub _scale($$$) {
1772 my ($mode, $val, $max) = @_;
1773
1774 $mode eq "abs" ? $val
1775 : $mode eq "rel" ? $val * $max
1776 : 0
1777}
1778
1779sub size_request {
1780 my ($self) = @_;
1781
1782 my ($x1, $y1, $x2, $y2) = (0, 0, 0, 0);
1783
1784 # determine overall size by querying abs widgets
1785 for my $child ($self->visible_children) {
1786 my ($pos, $x, $y, $size, $w, $h) = @{ $child->{_fixed} };
1787
1788 if ($pos eq "abs") {
1789 $w = _scale $size, $w, $child->{req_w};
1790 $h = _scale $size, $h, $child->{req_h};
1791
1792 $x1 = min $x1, $x; $x2 = max $x2, $x + $w;
1793 $y1 = min $y1, $y; $y2 = max $y2, $y + $h;
1794 }
1795 }
1796
1797 my $W = $x2 - $x1;
1798 my $H = $y2 - $y1;
1799
1800 # now layout remaining widgets
1801 for my $child ($self->visible_children) {
1802 my ($pos, $x, $y, $size, $w, $h) = @{ $child->{_fixed} };
1803
1804 if ($pos ne "abs") {
1805 $x = _scale $pos, $x, $W;
1806 $y = _scale $pos, $x, $H;
1807 $w = _scale $size, $w, $child->{req_w};
1808 $h = _scale $size, $h, $child->{req_h};
1809
1810 $x1 = min $x1, $x; $x2 = max $x2, $x + $w;
1811 $y1 = min $y1, $y; $y2 = max $y2, $y + $h;
1812 }
1813 }
1814
1815 my $W = $x2 - $x1;
1816 my $H = $y2 - $y1;
1817
1818 ($W, $H)
1819}
1820
1821sub invoke_size_allocate {
1822 my ($self, $W, $H) = @_;
1823
1824 for my $child ($self->visible_children) {
1825 my ($pos, $x, $y, $size, $w, $h) = @{ $child->{_fixed} };
1826
1827 $x = _scale $pos, $x, $W;
1828 $y = _scale $pos, $x, $H;
1829 $w = _scale $size, $w, $child->{req_w};
1830 $h = _scale $size, $h, $child->{req_h};
1831
1832 $child->configure ($x, $y, $w, $h);
1833 }
1834
1835 1
1657} 1836}
1658 1837
1659############################################################################# 1838#############################################################################
1660 1839
1661package CFPlus::UI::Box; 1840package CFPlus::UI::Box;
2219 2398
2220use CFPlus::OpenGL; 2399use CFPlus::OpenGL;
2221 2400
2222my @tex = 2401my @tex =
2223 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 2402 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 }
2224 qw(b1_button_active.png); 2403 qw(b1_button_inactive.png b1_button_active.png);
2225 2404
2226sub new { 2405sub new {
2227 my $class = shift; 2406 my $class = shift;
2228 2407
2229 $class->SUPER::new ( 2408 $class->SUPER::new (
2230 padding_x => 4, 2409 padding_x => 4,
2231 padding_y => 4, 2410 padding_y => 4,
2232 fg => [1, 1, 1], 2411 fg => [1.0, 1.0, 1.0],
2233 active_fg => [0, 0, 1], 2412 active_fg => [0.8, 0.8, 0.8],
2234 can_hover => 1, 2413 can_hover => 1,
2235 align => 0, 2414 align => 0,
2236 valign => 0, 2415 valign => 0,
2237 can_events => 1, 2416 can_events => 1,
2238 @_ 2417 @_
2256 2435
2257 glEnable GL_TEXTURE_2D; 2436 glEnable GL_TEXTURE_2D;
2258 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 2437 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2259 glColor 0, 0, 0, 1; 2438 glColor 0, 0, 0, 1;
2260 2439
2440 my $tex = $tex[$GRAB == $self];
2261 $tex[0]->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); 2441 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h});
2262 2442
2263 glDisable GL_TEXTURE_2D; 2443 glDisable GL_TEXTURE_2D;
2264 2444
2265 $self->SUPER::_draw; 2445 $self->SUPER::_draw;
2266} 2446}
3321 3501
3322sub new { 3502sub new {
3323 my $class = shift; 3503 my $class = shift;
3324 3504
3325 my $self = $class->SUPER::new ( 3505 my $self = $class->SUPER::new (
3506 size_w => 32,
3507 size_h => 8,
3326 aspect => 1, 3508 aspect => 1,
3327 can_events => 0, 3509 can_events => 0,
3328 @_, 3510 @_,
3329 ); 3511 );
3330 3512
3331 if ($self->{anim} && $self->{animspeed}) { 3513 if ($self->{anim} && $self->{animspeed}) {
3332 CFPlus::weaken (my $widget = $self); 3514 CFPlus::weaken (my $widget = $self);
3333 3515
3516 $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed};
3517 $widget->{anim_start} = $self->{animspeed} * Event::time / $self->{animspeed};
3334 $self->{timer} = Event->timer ( 3518 $self->{timer} = Event->timer (
3335 at => $self->{animspeed} * int $::NOW / $self->{animspeed},
3336 hard => 1, 3519 parked => 1,
3337 interval => $self->{animspeed},
3338 cb => sub { 3520 cb => sub {
3521 return unless $::CONN && $widget;
3522
3339 ++$widget->{frame}; 3523 ++$widget->{frame};
3524 $widget->update_face;
3340 $widget->update; 3525 $widget->update;
3526
3527 $widget->update_timer;
3341 }, 3528 },
3342 ); 3529 );
3530
3531 $self->update_face;
3532 $self->update_timer;
3343 } 3533 }
3344 3534
3345 $self 3535 $self
3346} 3536}
3347 3537
3538sub update_timer {
3539 my ($self) = @_;
3540
3541 return unless $self->{timer};
3542
3543 if ($self->{visible}) {
3544 $self->{timer}->at (
3545 $self->{anim_start}
3546 + $self->{animspeed}
3547 * int 1.5 + (Event::time - $self->{anim_start}) / $self->{animspeed}
3548 );
3549 $self->{timer}->start;
3550 } else {
3551 $self->{timer}->stop;
3552 }
3553}
3554
3555sub update_face {
3556 my ($self) = @_;
3557
3558 return unless $::CONN;
3559
3560 if (my $anim = $::CONN->{anim}[$self->{anim}]) {
3561 if ($anim && @$anim) {
3562 delete $self->{wait_face};
3563 $self->{face} = $anim->[ $self->{frame} % @$anim ];
3564 }
3565 }
3566}
3567
3348sub size_request { 3568sub size_request {
3349 (32, 8) 3569 my ($self) = @_;
3570
3571 if ($::CONN) {
3572 if (my $faceid = $::CONN->{faceid}[$self->{face}]) {
3573 if (my $tex = $::CONN->{texture}[$faceid]) {
3574 return ($self->{size_w} || $tex->{w}, $self->{size_h} || $tex->{h});
3575 } else {
3576 $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub {
3577 $self->realloc;
3578 });
3579 }
3580 }
3581 }
3582
3583 ($self->{size_w} || 8, $self->{size_h} || 8)
3350} 3584}
3351 3585
3352sub update { 3586sub update {
3353 my ($self) = @_; 3587 my ($self) = @_;
3354 3588
3355 return unless $self->{visible}; 3589 return unless $self->{visible};
3356 3590
3357 $self->SUPER::update; 3591 $self->SUPER::update;
3358} 3592}
3359 3593
3594sub invoke_visibility_change {
3595 my ($self) = @_;
3596
3597 $self->update_timer;
3598
3599 0
3600}
3601
3360sub _draw { 3602sub _draw {
3361 my ($self) = @_; 3603 my ($self) = @_;
3362 3604
3363 return unless $::CONN; 3605 return unless $::CONN;
3364 3606
3365 $self->SUPER::_draw; 3607 $self->SUPER::_draw;
3366 3608
3367 my $face;
3368
3369 if ($self->{frame}) {
3370 my $anim = $::CONN->{anim}[$self->{anim}]; 3609 my $faceid = $::CONN->{faceid}[$self->{face}]
3371 3610 or return;
3372 $face = $anim->[ $self->{frame} % @$anim ]
3373 if $anim && @$anim;
3374 }
3375 3611
3376 my $tex = $::CONN->{texture}[$::CONN->{faceid}[$face || $self->{face}]]; 3612 my $tex = $::CONN->{texture}[$faceid];
3377 3613
3378 if ($tex) { 3614 if ($tex) {
3379 glEnable GL_TEXTURE_2D; 3615 glEnable GL_TEXTURE_2D;
3380 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 3616 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
3381 glColor 0, 0, 0, 1; 3617 glColor 0, 0, 0, 1;
3385} 3621}
3386 3622
3387sub destroy { 3623sub destroy {
3388 my ($self) = @_; 3624 my ($self) = @_;
3389 3625
3390 $self->{timer}->cancel 3626 (delete $self->{timer})->cancel
3391 if $self->{timer}; 3627 if $self->{timer};
3392 3628
3393 $self->SUPER::destroy; 3629 $self->SUPER::destroy;
3394} 3630}
3395 3631
4039 while ($self->{post_alloc_hook}) { 4275 while ($self->{post_alloc_hook}) {
4040 $_->() 4276 $_->()
4041 for values %{delete $self->{post_alloc_hook}}; 4277 for values %{delete $self->{post_alloc_hook}};
4042 } 4278 }
4043 4279
4044
4045 glViewport 0, 0, $::WIDTH, $::HEIGHT; 4280 glViewport 0, 0, $::WIDTH, $::HEIGHT;
4046 glClearColor +($::CFG->{fow_intensity}) x 3, 1; 4281 glClearColor +($::CFG->{fow_intensity}) x 3, 1;
4047 glClear GL_COLOR_BUFFER_BIT; 4282 glClear GL_COLOR_BUFFER_BIT;
4048 4283
4049 glMatrixMode GL_PROJECTION; 4284 glMatrixMode GL_PROJECTION;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines