… | |
… | |
134 | for (@$vals) { |
134 | for (@$vals) { |
135 | my $i = int $_ + $rem; |
135 | my $i = int $_ + $rem; |
136 | $rem += $_ - $i; |
136 | $rem += $_ - $i; |
137 | $_ = $i; |
137 | $_ = $i; |
138 | } |
138 | } |
|
|
139 | } |
|
|
140 | |
|
|
141 | sub full_refresh { |
|
|
142 | # make a copy, otherwise for complains about freed values. |
|
|
143 | my @widgets = values %WIDGET; |
|
|
144 | |
|
|
145 | $_->update |
|
|
146 | for @widgets; |
139 | } |
147 | } |
140 | |
148 | |
141 | # call when resolution changes etc. |
149 | # call when resolution changes etc. |
142 | sub rescale_widgets { |
150 | sub rescale_widgets { |
143 | my ($sx, $sy) = @_; |
151 | my ($sx, $sy) = @_; |
… | |
… | |
198 | %$self = (); |
206 | %$self = (); |
199 | } |
207 | } |
200 | |
208 | |
201 | sub show { |
209 | sub show { |
202 | my ($self) = @_; |
210 | my ($self) = @_; |
203 | |
|
|
204 | return if $self->{parent}; |
211 | return if $self->{parent}; |
205 | |
212 | |
206 | $CFClient::UI::ROOT->add ($self); |
213 | $CFClient::UI::ROOT->add ($self); |
207 | } |
214 | } |
208 | |
215 | |
… | |
… | |
419 | Scalar::Util::weaken ($self->{parent} = $parent); |
426 | Scalar::Util::weaken ($self->{parent} = $parent); |
420 | |
427 | |
421 | # TODO: req_w _does_change after ->reconfigure |
428 | # TODO: req_w _does_change after ->reconfigure |
422 | $self->check_size |
429 | $self->check_size |
423 | unless exists $self->{req_w}; |
430 | unless exists $self->{req_w}; |
|
|
431 | |
|
|
432 | $self->show; |
424 | } |
433 | } |
425 | |
434 | |
426 | sub check_size { |
435 | sub check_size { |
427 | my ($self, $forced) = @_; |
436 | my ($self, $forced) = @_; |
428 | |
437 | |
… | |
… | |
691 | $self->{texture} = new_from_opengl CFClient::Texture $self->{w}, $self->{h}, sub { |
700 | $self->{texture} = new_from_opengl CFClient::Texture $self->{w}, $self->{h}, sub { |
692 | glClearColor 0, 0, 0, 0; |
701 | glClearColor 0, 0, 0, 0; |
693 | glClear GL_COLOR_BUFFER_BIT; |
702 | glClear GL_COLOR_BUFFER_BIT; |
694 | |
703 | |
695 | $self->_render; |
704 | $self->_render; |
696 | # glColorMask 1, 1, 1, 0; |
|
|
697 | # glEnable GL_BLEND; |
|
|
698 | # glBlendFunc GL_SRC_ALPHA, GL_ZERO; |
|
|
699 | # glRasterPos 0, 0; |
|
|
700 | # glCopyPixels 0, 0, $self->{w}, $self->{h}; |
|
|
701 | # glDisable GL_BLEND; |
|
|
702 | # glColorMask 1, 1, 1, 1; |
|
|
703 | }; |
705 | }; |
704 | } |
706 | } |
705 | |
707 | |
706 | sub _draw { |
708 | sub _draw { |
707 | my ($self) = @_; |
709 | my ($self) = @_; |
… | |
… | |
711 | my $tex = $self->{texture} |
713 | my $tex = $self->{texture} |
712 | or return; |
714 | or return; |
713 | |
715 | |
714 | glEnable GL_TEXTURE_2D; |
716 | glEnable GL_TEXTURE_2D; |
715 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
717 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
716 | glColor 0, 0, 0, 1; |
718 | glColor 1, 1, 1, 1; |
717 | |
719 | |
718 | $tex->draw_quad_alpha_premultiplied (0, 0, $w, $h); |
720 | $tex->draw_quad_alpha_premultiplied (0, 0, $w, $h); |
719 | |
721 | |
720 | glDisable GL_TEXTURE_2D; |
722 | glDisable GL_TEXTURE_2D; |
721 | } |
723 | } |
… | |
… | |
804 | $self->{vp}->set_offset (0, $_[1] * ($self->{vp}{child_h} - $self->{vp}{h})); |
806 | $self->{vp}->set_offset (0, $_[1] * ($self->{vp}{child_h} - $self->{vp}{h})); |
805 | }, |
807 | }, |
806 | ; |
808 | ; |
807 | |
809 | |
808 | $self = $class->SUPER::new ( |
810 | $self = $class->SUPER::new ( |
809 | vp => (new CFClient::UI::ViewPort), |
811 | vp => (new CFClient::UI::ViewPort expand => 1), |
810 | slider => $slider, |
812 | slider => $slider, |
811 | @_, |
813 | @_, |
812 | ); |
814 | ); |
813 | |
815 | |
814 | $self->{vp}->add ($self->{scrolled}); |
816 | $self->{vp}->add ($self->{scrolled}); |
… | |
… | |
2057 | range => [0, 0, 100, 10], |
2059 | range => [0, 0, 100, 10], |
2058 | req_w => $::WIDTH / 80, |
2060 | req_w => $::WIDTH / 80, |
2059 | req_h => $::WIDTH / 80, |
2061 | req_h => $::WIDTH / 80, |
2060 | vertical => 0, |
2062 | vertical => 0, |
2061 | can_hover => 1, |
2063 | can_hover => 1, |
2062 | inner_pad => .05, |
2064 | inner_pad => 0.02, |
2063 | @_ |
2065 | @_ |
2064 | ); |
2066 | ); |
2065 | |
2067 | |
2066 | $self->set_value ($self->{range}[0]); |
2068 | $self->set_value ($self->{range}[0]); |
2067 | $self->update; |
2069 | $self->update; |
… | |
… | |
2214 | |
2216 | |
2215 | $self->{fontsize} = $fontsize; |
2217 | $self->{fontsize} = $fontsize; |
2216 | $self->reflow; |
2218 | $self->reflow; |
2217 | } |
2219 | } |
2218 | |
2220 | |
|
|
2221 | sub size_allocate { |
|
|
2222 | my ($self, $w, $h) = @_; |
|
|
2223 | |
|
|
2224 | $self->SUPER::size_allocate ($w, $h); |
|
|
2225 | |
|
|
2226 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
|
|
2227 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
|
|
2228 | $self->{layout}->set_width ($self->{children}[0]{w}); |
|
|
2229 | |
|
|
2230 | $self->reflow; |
|
|
2231 | } |
|
|
2232 | |
2219 | sub text_height { |
2233 | sub text_height { |
2220 | my ($self, $text) = @_; |
2234 | my ($self, $text, $indent) = @_; |
2221 | |
2235 | |
2222 | my $layout = $self->{layout}; |
2236 | my $layout = $self->{layout}; |
2223 | |
2237 | |
2224 | $layout->set_height ($self->{fontsize} * $::FONTSIZE); |
2238 | $layout->set_height ($self->{fontsize} * $::FONTSIZE); |
2225 | $layout->set_width ($self->{children}[0]{w}); |
2239 | $layout->set_width ($self->{children}[0]{w} - $indent); |
2226 | $layout->set_markup ($text); |
2240 | $layout->set_markup ($text); |
2227 | |
2241 | |
2228 | ($layout->size)[1] |
2242 | ($layout->size)[1] |
2229 | } |
2243 | } |
2230 | |
2244 | |
… | |
… | |
2233 | |
2247 | |
2234 | $self->{need_reflow}++; |
2248 | $self->{need_reflow}++; |
2235 | $self->update; |
2249 | $self->update; |
2236 | } |
2250 | } |
2237 | |
2251 | |
2238 | sub size_allocate { |
|
|
2239 | my ($self, $w, $h) = @_; |
|
|
2240 | |
|
|
2241 | $self->SUPER::size_allocate ($w, $h); |
|
|
2242 | |
|
|
2243 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
|
|
2244 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
|
|
2245 | $self->{layout}->set_width ($self->{children}[0]{w}); |
|
|
2246 | |
|
|
2247 | $self->reflow; |
|
|
2248 | } |
|
|
2249 | |
|
|
2250 | sub add_paragraph { |
2252 | sub add_paragraph { |
2251 | my ($self, $color, $text) = @_; |
2253 | my ($self, $color, $text, $indent) = @_; |
2252 | |
2254 | |
2253 | #TODO: intelligently "reformat" paragraph |
2255 | #TODO: intelligently "reformat" paragraph |
2254 | |
2256 | |
|
|
2257 | for my $line (split /\n/, $text) { |
2255 | my $height = $self->text_height ($text); |
2258 | my $height = $self->text_height ($line); |
2256 | |
|
|
2257 | $self->{height} += $height; |
2259 | $self->{height} += $height; |
2258 | |
|
|
2259 | push @{$self->{par}}, [$height, $color, $text]; |
2260 | push @{$self->{par}}, [$height, $color, $indent, $line]; |
|
|
2261 | } |
2260 | |
2262 | |
2261 | $self->{children}[1]{range} = [$self->{height} - $self->{h}, 0, $self->{height}, $self->{h}]; |
2263 | $self->{children}[1]{range} = [$self->{height} - $self->{h}, 0, $self->{height}, $self->{h}]; |
2262 | $self->{children}[1]->update; |
2264 | $self->{children}[1]->update; |
2263 | } |
2265 | } |
2264 | |
2266 | |
… | |
… | |
2273 | |
2275 | |
2274 | $ROOT->on_post_alloc ($self, sub { |
2276 | $ROOT->on_post_alloc ($self, sub { |
2275 | if (delete $self->{need_reflow}) { |
2277 | if (delete $self->{need_reflow}) { |
2276 | my $height = 0; |
2278 | my $height = 0; |
2277 | |
2279 | |
2278 | $height += $_->[0] = $self->text_height ($_->[2]) |
2280 | $height += $_->[0] = $self->text_height ($_->[3], $_->[2]) |
2279 | for @{$self->{par}}; |
2281 | for @{$self->{par}}; |
2280 | |
2282 | |
2281 | $self->{height} = $height; |
2283 | $self->{height} = $height; |
2282 | |
2284 | |
2283 | $self->{children}[1]{range} = [$height - $self->{h}, 0, $height, $self->{h}]; |
2285 | $self->{children}[1]{range} = [$height - $self->{h}, 0, $height, $self->{h}]; |
|
|
2286 | $self->{children}[1]->update; |
2284 | |
2287 | |
2285 | delete $self->{texture}; |
2288 | delete $self->{texture}; |
2286 | } |
2289 | } |
2287 | |
2290 | |
2288 | $self->{texture} ||= new_from_opengl CFClient::Texture $self->{children}[0]{w}, $self->{children}[0]{h}, sub { |
2291 | $self->{texture} ||= new_from_opengl CFClient::Texture $self->{children}[0]{w}, $self->{children}[0]{h}, sub { |
2289 | glClearColor 0, 0, 0, 0; |
2292 | glClearColor 0.5, 0.5, 0.5, 0; |
2290 | glClear GL_COLOR_BUFFER_BIT; |
2293 | glClear GL_COLOR_BUFFER_BIT; |
2291 | |
|
|
2292 | glEnable GL_TEXTURE_2D; |
|
|
2293 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
2294 | |
2294 | |
2295 | my $top = int $self->{children}[1]{range}[0]; |
2295 | my $top = int $self->{children}[1]{range}[0]; |
2296 | |
2296 | |
2297 | my $y0 = $top; |
2297 | my $y0 = $top; |
2298 | my $y1 = $top + $self->{h}; |
2298 | my $y1 = $top + $self->{h}; |
… | |
… | |
2301 | |
2301 | |
2302 | my $layout = $self->{layout}; |
2302 | my $layout = $self->{layout}; |
2303 | |
2303 | |
2304 | $layout->set_font ($self->{font}) if $self->{font}; |
2304 | $layout->set_font ($self->{font}) if $self->{font}; |
2305 | |
2305 | |
|
|
2306 | glEnable GL_BLEND; |
|
|
2307 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
|
|
2308 | |
2306 | for my $par (@{$self->{par}}) { |
2309 | for my $par (@{$self->{par}}) { |
2307 | my $h = $par->[0]; |
2310 | my $h = $par->[0]; |
2308 | |
2311 | |
2309 | if ($y0 < $y + $h && $y < $y1) { |
2312 | if ($y0 < $y + $h && $y < $y1) { |
2310 | $layout->set_foreground (@{ $par->[1] }); |
2313 | $layout->set_foreground (@{ $par->[1] }); |
|
|
2314 | $layout->set_width ($self->{w} - $par->[2]); |
2311 | $layout->set_markup ($par->[2]); |
2315 | $layout->set_markup ($par->[3]); |
2312 | |
2316 | |
2313 | my ($W, $H) = $layout->size; |
2317 | my ($w, $h, $data, $format, $internalformat) = $layout->render; |
2314 | CFClient::Texture->new_from_layout ($layout)->draw_quad_alpha_premultiplied (0, $y - $y0); |
2318 | |
|
|
2319 | glRasterPos $par->[2], $y - $y0; |
|
|
2320 | glDrawPixels $w, $h, $format, GL_UNSIGNED_BYTE, $data; |
2315 | } |
2321 | } |
2316 | |
2322 | |
2317 | $y += $h; |
2323 | $y += $h; |
2318 | } |
2324 | } |
2319 | |
2325 | |
2320 | glDisable GL_TEXTURE_2D; |
2326 | glDisable GL_BLEND; |
2321 | }; |
2327 | }; |
2322 | }); |
2328 | }); |
2323 | } |
2329 | } |
2324 | |
2330 | |
2325 | sub _draw { |
2331 | sub _draw { |
2326 | my ($self) = @_; |
2332 | my ($self) = @_; |
2327 | |
2333 | |
2328 | glEnable GL_TEXTURE_2D; |
2334 | glEnable GL_TEXTURE_2D; |
2329 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2335 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2330 | glColor 1, 1, 1, 1; |
2336 | glColor 1, 1, 1, 1; |
2331 | $self->{texture}->draw_quad_alpha_premultiplied (0, 0, $self->{children}[0]{w}, $self->{children}[0]{h}); |
2337 | $self->{texture}->draw_quad_alpha (0, 0, $self->{children}[0]{w}, $self->{children}[0]{h}); |
2332 | glDisable GL_TEXTURE_2D; |
2338 | glDisable GL_TEXTURE_2D; |
2333 | |
2339 | |
2334 | $self->{children}[1]->draw; |
2340 | $self->{children}[1]->draw; |
2335 | |
2341 | |
2336 | } |
2342 | } |
… | |
… | |
2496 | use CFClient::OpenGL; |
2502 | use CFClient::OpenGL; |
2497 | |
2503 | |
2498 | sub new { |
2504 | sub new { |
2499 | my $class = shift; |
2505 | my $class = shift; |
2500 | |
2506 | |
2501 | $class->SUPER::new ( |
2507 | my $self = $class->SUPER::new ( |
2502 | aspect => 1, |
2508 | aspect => 1, |
2503 | @_, |
2509 | @_, |
2504 | ) |
2510 | ); |
|
|
2511 | |
|
|
2512 | if ($self->{anim} && $self->{animspeed}) { |
|
|
2513 | Scalar::Util::weaken (my $widget = $self); |
|
|
2514 | |
|
|
2515 | $self->{timer} = Event->timer ( |
|
|
2516 | at => $self->{animspeed} * int $::NOW / $self->{animspeed}, |
|
|
2517 | hard => 1, |
|
|
2518 | interval => $self->{animspeed}, |
|
|
2519 | cb => sub { |
|
|
2520 | ++$widget->{frame}; |
|
|
2521 | $widget->update; |
|
|
2522 | }, |
|
|
2523 | ); |
|
|
2524 | } |
|
|
2525 | |
|
|
2526 | $self |
2505 | } |
2527 | } |
2506 | |
2528 | |
2507 | sub size_request { |
2529 | sub size_request { |
2508 | (32, 8) |
2530 | (32, 8) |
2509 | } |
2531 | } |
2510 | |
2532 | |
|
|
2533 | sub update { |
|
|
2534 | my ($self) = @_; |
|
|
2535 | |
|
|
2536 | return unless $self->{visible}; |
|
|
2537 | |
|
|
2538 | $self->SUPER::update; |
|
|
2539 | } |
|
|
2540 | |
2511 | sub _draw { |
2541 | sub _draw { |
2512 | my ($self) = @_; |
2542 | my ($self) = @_; |
2513 | |
2543 | |
2514 | return unless $::CONN;#d# manage and cache textures differently |
2544 | return unless $::CONN;#d# manage and cache textures differently |
|
|
2545 | |
|
|
2546 | my $face; |
|
|
2547 | |
|
|
2548 | if ($self->{frame}) { |
|
|
2549 | my $anim = $::CONN->{anim}[$self->{anim}]; |
|
|
2550 | |
|
|
2551 | $face = $anim->[ $self->{frame} % @$anim ] |
|
|
2552 | if $anim && @$anim; |
|
|
2553 | } |
|
|
2554 | |
2515 | my $tex = $::CONN->{texture}[$::CONN->{faceid}[$self->{face}]]; |
2555 | my $tex = $::CONN->{texture}[$::CONN->{faceid}[$face || $self->{face}]]; |
2516 | |
2556 | |
2517 | # TODO animation |
|
|
2518 | if ($tex) { |
2557 | if ($tex) { |
2519 | glEnable GL_TEXTURE_2D; |
2558 | glEnable GL_TEXTURE_2D; |
2520 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2559 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2521 | glColor 1, 1, 1, 1; |
2560 | glColor 1, 1, 1, 1; |
2522 | $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
2561 | $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
2523 | glDisable GL_TEXTURE_2D; |
2562 | glDisable GL_TEXTURE_2D; |
2524 | } |
2563 | } |
2525 | } |
2564 | } |
2526 | |
2565 | |
|
|
2566 | sub DESTROY { |
|
|
2567 | my ($self) = @_; |
|
|
2568 | |
|
|
2569 | $self->{timer}->cancel |
|
|
2570 | if $self->{timer}; |
|
|
2571 | |
|
|
2572 | $self->SUPER::DESTROY; |
|
|
2573 | } |
|
|
2574 | |
2527 | ############################################################################# |
2575 | ############################################################################# |
2528 | |
2576 | |
2529 | package CFClient::UI::InventoryItem; |
2577 | package CFClient::UI::InventoryItem; |
2530 | |
2578 | |
2531 | our @ISA = CFClient::UI::HBox::; |
2579 | our @ISA = CFClient::UI::HBox::; |
… | |
… | |
2534 | my ($item) = @_; |
2582 | my ($item) = @_; |
2535 | |
2583 | |
2536 | my $desc = |
2584 | my $desc = |
2537 | $item->{nrof} < 2 |
2585 | $item->{nrof} < 2 |
2538 | ? $item->{name} |
2586 | ? $item->{name} |
2539 | : "$item->{nrof} $item->{name_pl}"; |
2587 | : "$item->{nrof} × $item->{name_pl}"; |
2540 | |
2588 | |
2541 | $item->{flags} & Crossfire::Protocol::F_OPEN |
2589 | $item->{flags} & Crossfire::Protocol::F_OPEN |
2542 | and $desc .= " (open)"; |
2590 | and $desc .= " (open)"; |
2543 | $item->{flags} & Crossfire::Protocol::F_APPLIED |
2591 | $item->{flags} & Crossfire::Protocol::F_APPLIED |
2544 | and $desc .= " (applied)"; |
2592 | and $desc .= " (applied)"; |
… | |
… | |
2564 | my $item = delete $args{item}; |
2612 | my $item = delete $args{item}; |
2565 | |
2613 | |
2566 | my $desc = _item_to_desc ($item); |
2614 | my $desc = _item_to_desc ($item); |
2567 | |
2615 | |
2568 | my $self = $class->SUPER::new ( |
2616 | my $self = $class->SUPER::new ( |
2569 | can_hover => 1, |
2617 | can_hover => 1, |
2570 | can_events => 1, |
2618 | can_events => 1, |
2571 | tooltip => ((CFClient::UI::Label::escape $desc) |
2619 | tooltip => ((CFClient::UI::Label::escape $desc) |
2572 | . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"), |
2620 | . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"), |
2573 | connect_button_down => sub { |
2621 | connect_button_down => sub { |
2574 | my ($self, $ev, $x, $y) = @_; |
2622 | my ($self, $ev, $x, $y) = @_; |
2575 | |
2623 | |
2576 | # todo: maybe put examine on 1? but should just be a tooltip :( |
2624 | # todo: maybe put examine on 1? but should just be a tooltip :( |
… | |
… | |
2585 | } elsif ($ev->{button} == 2) { |
2633 | } elsif ($ev->{button} == 2) { |
2586 | $::CONN->send ("apply $item->{tag}"); |
2634 | $::CONN->send ("apply $item->{tag}"); |
2587 | } elsif ($ev->{button} == 3) { |
2635 | } elsif ($ev->{button} == 3) { |
2588 | my @menu_items = ( |
2636 | my @menu_items = ( |
2589 | ["examine", sub { $::CONN->send ("examine $item->{tag}") }], |
2637 | ["examine", sub { $::CONN->send ("examine $item->{tag}") }], |
2590 | ["mark", sub { $::CONN->send ("mark $item->{tag}") }], |
2638 | ["mark", sub { $::CONN->send ("mark ". pack "N", $item->{tag}) }], |
2591 | ["apply", sub { $::CONN->send ("apply $item->{tag}") }], |
2639 | ["apply", sub { $::CONN->send ("apply $item->{tag}") }], |
|
|
2640 | ( |
|
|
2641 | $item->{flags} & Crossfire::Protocol::F_LOCKED |
|
|
2642 | ? ( |
|
|
2643 | ["unlock", sub { $::CONN->send ("lock " . pack "CN", 0, $item->{tag}) }], |
|
|
2644 | ) |
|
|
2645 | : ( |
|
|
2646 | ["lock", sub { $::CONN->send ("lock " . pack "CN", 1, $item->{tag}) }], |
2592 | ["drop", sub { $::CONN->send ("move $main::OPENCONT $item->{tag} 0") }], |
2647 | ["drop", sub { $::CONN->send ("move $main::OPENCONT $item->{tag} 0") }], |
2593 | [ |
2648 | ) |
2594 | $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock", |
|
|
2595 | sub { $::CONN->send ("lock $item->{tag}") }, |
|
|
2596 | ], |
2649 | ), |
2597 | ); |
2650 | ); |
2598 | |
2651 | |
2599 | CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); |
2652 | CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); |
2600 | } |
2653 | } |
2601 | |
2654 | |
… | |
… | |
2944 | $child->{x} = int $child->{x}; |
2997 | $child->{x} = int $child->{x}; |
2945 | $child->{y} = int $child->{y}; |
2998 | $child->{y} = int $child->{y}; |
2946 | } |
2999 | } |
2947 | |
3000 | |
2948 | $self->SUPER::add (@children); |
3001 | $self->SUPER::add (@children); |
|
|
3002 | |
|
|
3003 | while (@children) { |
|
|
3004 | my $w = pop @children; |
|
|
3005 | push @children, $w->children; |
|
|
3006 | $w->{visible} = 1; |
|
|
3007 | } |
|
|
3008 | } |
|
|
3009 | |
|
|
3010 | sub remove { |
|
|
3011 | my ($self, @children) = @_; |
|
|
3012 | |
|
|
3013 | $self->SUPER::remove (@children); |
|
|
3014 | |
|
|
3015 | while (@children) { |
|
|
3016 | my $w = pop @children; |
|
|
3017 | push @children, $w->children; |
|
|
3018 | delete $w->{visible}; |
|
|
3019 | } |
2949 | } |
3020 | } |
2950 | |
3021 | |
2951 | sub on_refresh { |
3022 | sub on_refresh { |
2952 | my ($self, $id, $cb) = @_; |
3023 | my ($self, $id, $cb) = @_; |
2953 | |
3024 | |
… | |
… | |
3022 | glClearColor +($::CFG->{fow_intensity}) x 3, 1; |
3093 | glClearColor +($::CFG->{fow_intensity}) x 3, 1; |
3023 | glClear GL_COLOR_BUFFER_BIT; |
3094 | glClear GL_COLOR_BUFFER_BIT; |
3024 | |
3095 | |
3025 | glMatrixMode GL_PROJECTION; |
3096 | glMatrixMode GL_PROJECTION; |
3026 | glLoadIdentity; |
3097 | glLoadIdentity; |
3027 | glOrtho 0, $::WIDTH, $::HEIGHT, 0, -10000 , 10000; |
3098 | glOrtho 0, $::WIDTH, $::HEIGHT, 0, -10000, 10000; |
3028 | glMatrixMode GL_MODELVIEW; |
3099 | glMatrixMode GL_MODELVIEW; |
3029 | glLoadIdentity; |
3100 | glLoadIdentity; |
3030 | |
3101 | |
3031 | $self->_draw; |
3102 | $self->_draw; |
3032 | } |
3103 | } |