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.204 by root, Sun May 14 22:24:16 2006 UTC vs.
Revision 1.222 by root, Mon May 22 03:59:51 2006 UTC

136 $rem += $_ - $i; 136 $rem += $_ - $i;
137 $_ = $i; 137 $_ = $i;
138 } 138 }
139} 139}
140 140
141sub full_refresh {
142 # make a copy, otherwise for complains about freed values.
143 my @widgets = values %WIDGET;
144
145 $_->update
146 for @widgets;
147}
148
141# call when resolution changes etc. 149# call when resolution changes etc.
142sub rescale_widgets { 150sub rescale_widgets {
143 my ($sx, $sy) = @_; 151 my ($sx, $sy) = @_;
144 152
153 # make a copy, otherwise for complains about freed values.
145 for my $widget (values %WIDGET) { 154 my @widgets = values %WIDGET;
155
156 for my $widget (@widgets) {
146 if ($widget->{toplevel}) { 157 if ($widget->{toplevel}) {
147 $widget->{x} = int 0.5 + $widget->{x} * $sx if exists $widget->{x}; 158 $widget->{x} = int 0.5 + $widget->{x} * $sx if exists $widget->{x};
148 $widget->{w} = int 0.5 + $widget->{w} * $sx if exists $widget->{w}; 159 $widget->{w} = int 0.5 + $widget->{w} * $sx if exists $widget->{w};
149 $widget->{req_w} = int 0.5 + $widget->{req_w} * $sx if exists $widget->{req_w}; 160 $widget->{req_w} = int 0.5 + $widget->{req_w} * $sx if exists $widget->{req_w};
150 $widget->{user_w} = int 0.5 + $widget->{user_w} * $sx if exists $widget->{user_w}; 161 $widget->{user_w} = int 0.5 + $widget->{user_w} * $sx if exists $widget->{user_w};
195 %$self = (); 206 %$self = ();
196} 207}
197 208
198sub show { 209sub show {
199 my ($self) = @_; 210 my ($self) = @_;
200
201 return if $self->{parent}; 211 return if $self->{parent};
202 212
203 $CFClient::UI::ROOT->add ($self); 213 $CFClient::UI::ROOT->add ($self);
204} 214}
205 215
280sub set_max_size { 290sub set_max_size {
281 my ($self, $w, $h) = @_; 291 my ($self, $w, $h) = @_;
282 292
283 delete $self->{max_w}; $self->{max_w} = $w if $w; 293 delete $self->{max_w}; $self->{max_w} = $w if $w;
284 delete $self->{max_h}; $self->{max_h} = $h if $h; 294 delete $self->{max_h}; $self->{max_h} = $h if $h;
295}
296
297sub set_tooltip {
298 my ($self, $tooltip) = @_;
299
300 $self->{tooltip} = $tooltip;
301
302 if ($CFClient::UI::TOOLTIP->{owner} == $self) {
303 delete $CFClient::UI::TOOLTIP->{owner};
304 CFClient::UI::check_tooltip;
305 }
285} 306}
286 307
287# translate global coordinates to local coordinate system 308# translate global coordinates to local coordinate system
288sub coord2local { 309sub coord2local {
289 my ($self, $x, $y) = @_; 310 my ($self, $x, $y) = @_;
375 glVertex $self->{w}, 0; 396 glVertex $self->{w}, 0;
376 glVertex $self->{w}, $self->{h}; 397 glVertex $self->{w}, $self->{h};
377 glVertex 0 , $self->{h}; 398 glVertex 0 , $self->{h};
378 glEnd; 399 glEnd;
379 glPopMatrix; 400 glPopMatrix;
380 CFClient::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; 401 #CFClient::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw;
381 } 402 }
382} 403}
383 404
384sub _draw { 405sub _draw {
385 my ($self) = @_; 406 my ($self) = @_;
405 Scalar::Util::weaken ($self->{parent} = $parent); 426 Scalar::Util::weaken ($self->{parent} = $parent);
406 427
407 # TODO: req_w _does_change after ->reconfigure 428 # TODO: req_w _does_change after ->reconfigure
408 $self->check_size 429 $self->check_size
409 unless exists $self->{req_w}; 430 unless exists $self->{req_w};
431
432 $self->show;
410} 433}
411 434
412sub check_size { 435sub check_size {
413 my ($self, $forced) = @_; 436 my ($self, $forced) = @_;
414 437
455 my $class = shift; 478 my $class = shift;
456 479
457 # range [value, low, high, page] 480 # range [value, low, high, page]
458 481
459 $class->SUPER::new ( 482 $class->SUPER::new (
460 bg => [0, 0, 0, 0.2], 483 #bg => [0, 0, 0, 0.2],
461 active_bg => [1, 1, 1, 0.5], 484 #active_bg => [1, 1, 1, 0.5],
462 @_ 485 @_
463 ) 486 )
464} 487}
465 488
466sub _draw { 489sub _draw {
467 my ($self) = @_; 490 my ($self) = @_;
468 491
492 my $color = $FOCUS == $self && $self->{active_bg}
493 ? $self->{active_bg}
494 : $self->{bg};
495
496 if ($color && (@$color < 4 || $color->[3])) {
469 my ($w, $h) = @$self{qw(w h)}; 497 my ($w, $h) = @$self{qw(w h)};
470 498
471 glEnable GL_BLEND; 499 glEnable GL_BLEND;
472 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 500 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
473 glColor @{ $FOCUS == $self ? $self->{active_bg} : $self->{bg} }; 501 glColor @$color;
474 502
475 glBegin GL_QUADS; 503 glBegin GL_QUADS;
476 glVertex 0 , 0; 504 glVertex 0 , 0;
477 glVertex 0 , $h; 505 glVertex 0 , $h;
478 glVertex $w, $h; 506 glVertex $w, $h;
479 glVertex $w, 0; 507 glVertex $w, 0;
480 glEnd; 508 glEnd;
481 509
482 glDisable GL_BLEND; 510 glDisable GL_BLEND;
511 }
483} 512}
484 513
485############################################################################# 514#############################################################################
486 515
487package CFClient::UI::Empty; 516package CFClient::UI::Empty;
671 $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 {
672 glClearColor 0, 0, 0, 0; 701 glClearColor 0, 0, 0, 0;
673 glClear GL_COLOR_BUFFER_BIT; 702 glClear GL_COLOR_BUFFER_BIT;
674 703
675 $self->_render; 704 $self->_render;
676# glColorMask 1, 1, 1, 0;
677# glEnable GL_BLEND;
678# glBlendFunc GL_SRC_ALPHA, GL_ZERO;
679# glRasterPos 0, 0;
680# glCopyPixels 0, 0, $self->{w}, $self->{h};
681# glDisable GL_BLEND;
682# glColorMask 1, 1, 1, 1;
683 }; 705 };
684} 706}
685 707
686sub _draw { 708sub _draw {
687 my ($self) = @_; 709 my ($self) = @_;
691 my $tex = $self->{texture} 713 my $tex = $self->{texture}
692 or return; 714 or return;
693 715
694 glEnable GL_TEXTURE_2D; 716 glEnable GL_TEXTURE_2D;
695 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 717 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
696 glColor 0, 0, 0, 1; 718 glColor 1, 1, 1, 1;
697 719
698 $tex->draw_quad_alpha_premultiplied (0, 0, $w, $h); 720 $tex->draw_quad_alpha_premultiplied (0, 0, $w, $h);
699 721
700 glDisable GL_TEXTURE_2D; 722 glDisable GL_TEXTURE_2D;
701} 723}
784 $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}));
785 }, 807 },
786 ; 808 ;
787 809
788 $self = $class->SUPER::new ( 810 $self = $class->SUPER::new (
789 vp => (new CFClient::UI::ViewPort), 811 vp => (new CFClient::UI::ViewPort expand => 1),
790 slider => $slider, 812 slider => $slider,
791 @_, 813 @_,
792 ); 814 );
793 815
794 $self->{vp}->add ($self->{scrolled}); 816 $self->{vp}->add ($self->{scrolled});
895 my ($self, $w, $h) = @_; 917 my ($self, $w, $h) = @_;
896 918
897 $h -= List::Util::max 0, $self->border * 2; 919 $h -= List::Util::max 0, $self->border * 2;
898 $w -= List::Util::max 0, $self->border * 2; 920 $w -= List::Util::max 0, $self->border * 2;
899 921
900 $self->{title}->configure ($self->border, $self->border - $::FONTSIZE * 2, $w, $::FONTSIZE * 2) 922 $self->{title}->configure ($self->border, int $self->border - $::FONTSIZE * 2, $w, int $::FONTSIZE * 2)
901 if $self->{title}; 923 if $self->{title};
902 924
903 $self->child->configure ($self->border, $self->border, $w, $h); 925 $self->child->configure ($self->border, $self->border, $w, $h);
904} 926}
905 927
1266 1288
1267############################################################################# 1289#############################################################################
1268 1290
1269package CFClient::UI::Label; 1291package CFClient::UI::Label;
1270 1292
1271our @ISA = CFClient::UI::Base::; 1293our @ISA = CFClient::UI::DrawBG::;
1272 1294
1273use CFClient::OpenGL; 1295use CFClient::OpenGL;
1274 1296
1275sub new { 1297sub new {
1276 my ($class, %arg) = @_; 1298 my ($class, %arg) = @_;
1277 1299
1278 my $self = $class->SUPER::new ( 1300 my $self = $class->SUPER::new (
1279 fg => [1, 1, 1], 1301 fg => [1, 1, 1],
1302 #bg => none
1303 #active_bg => none
1280 #font => default_font 1304 #font => default_font
1281 #text => initial text 1305 #text => initial text
1282 #markup => initial narkup 1306 #markup => initial narkup
1307 #max_w => maximum pixel width
1308 ellipsise => 3, # end
1283 layout => (new CFClient::Layout), 1309 layout => (new CFClient::Layout),
1284 fontsize => 1, 1310 fontsize => 1,
1285 align => -1, 1311 align => -1,
1286 valign => -1, 1312 valign => -1,
1287 padding => 2, 1313 padding => 2,
1302 } 1328 }
1303 1329
1304 $self 1330 $self
1305} 1331}
1306 1332
1307sub escape { 1333sub escape($) {
1308 local $_ = $_[1]; 1334 local $_ = $_[0];
1309 1335
1310 s/&/&amp;/g; 1336 s/&/&amp;/g;
1311 s/>/&gt;/g; 1337 s/>/&gt;/g;
1312 s/</&lt;/g; 1338 s/</&lt;/g;
1313 1339
1314 $_[1] 1340 $_
1315} 1341}
1316 1342
1317sub update { 1343sub update {
1318 my ($self) = @_; 1344 my ($self) = @_;
1319 1345
1352sub size_request { 1378sub size_request {
1353 my ($self) = @_; 1379 my ($self) = @_;
1354 1380
1355 $self->{layout}->set_font ($self->{font}) if $self->{font}; 1381 $self->{layout}->set_font ($self->{font}) if $self->{font};
1356 $self->{layout}->set_width ($self->{max_w} || -1); 1382 $self->{layout}->set_width ($self->{max_w} || -1);
1383 $self->{layout}->set_ellipsise ($self->{ellipsise});
1384 $self->{layout}->set_single_paragraph_mode ($self->{ellipsise});
1357 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); 1385 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE);
1358 1386
1359 my ($w, $h) = $self->{layout}->size; 1387 my ($w, $h) = $self->{layout}->size;
1360 1388
1361 if (exists $self->{template}) { 1389 if (exists $self->{template}) {
1391} 1419}
1392 1420
1393sub _draw { 1421sub _draw {
1394 my ($self) = @_; 1422 my ($self) = @_;
1395 1423
1424 $self->SUPER::_draw; # draw background, if applicable
1425
1396 my $tex = $self->{texture} ||= do { 1426 my $tex = $self->{texture} ||= do {
1397 $self->{layout}->set_foreground (@{$self->{fg}}); 1427 $self->{layout}->set_foreground (@{$self->{fg}});
1398 $self->{layout}->set_font ($self->{font}) if $self->{font}; 1428 $self->{layout}->set_font ($self->{font}) if $self->{font};
1399 $self->{layout}->set_width ($self->{w}); 1429 $self->{layout}->set_width ($self->{w});
1430 $self->{layout}->set_ellipsise ($self->{ellipsise});
1431 $self->{layout}->set_single_paragraph_mode ($self->{ellipsise});
1400 $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize} * $::FONTSIZE); 1432 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE);
1401 1433
1402 my $tex = new_from_layout CFClient::Texture $self->{layout}; 1434 my $tex = new_from_layout CFClient::Texture $self->{layout};
1403 1435
1404 $self->{ox} = int $self->{align} < 0 ? $self->{padding} 1436 $self->{ox} = int ($self->{align} < 0 ? $self->{padding}
1405 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} 1437 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding}
1406 : ($self->{w} - $tex->{w}) * 0.5; 1438 : ($self->{w} - $tex->{w}) * 0.5);
1407 1439
1408 $self->{oy} = int $self->{valign} < 0 ? $self->{padding} 1440 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding}
1409 : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding} 1441 : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding}
1410 : ($self->{h} - $tex->{h}) * 0.5; 1442 : ($self->{h} - $tex->{h}) * 0.5);
1411 1443
1412 $tex 1444 $tex
1413 }; 1445 };
1414 1446
1415 glEnable GL_TEXTURE_2D; 1447 glEnable GL_TEXTURE_2D;
1470sub set_text { 1502sub set_text {
1471 my ($self, $text) = @_; 1503 my ($self, $text) = @_;
1472 1504
1473 $self->{cursor} = length $text; 1505 $self->{cursor} = length $text;
1474 $self->_set_text ($text); 1506 $self->_set_text ($text);
1507 $self->update;
1475 $self->check_size; 1508 $self->check_size;
1476 $self->update;
1477} 1509}
1478 1510
1479sub get_text { 1511sub get_text {
1480 $_[0]{text} 1512 $_[0]{text}
1481} 1513}
1521 substr $text, $self->{cursor}++, 0, chr $uni; 1553 substr $text, $self->{cursor}++, 0, chr $uni;
1522 } 1554 }
1523 1555
1524 $self->_set_text ($text); 1556 $self->_set_text ($text);
1525 $self->update; 1557 $self->update;
1558 $self->check_size;
1526} 1559}
1527 1560
1528sub focus_in { 1561sub focus_in {
1529 my ($self) = @_; 1562 my ($self) = @_;
1530 1563
1659 my $class = shift; 1692 my $class = shift;
1660 1693
1661 $class->SUPER::new ( 1694 $class->SUPER::new (
1662 padding => 4, 1695 padding => 4,
1663 fg => [1, 1, 1], 1696 fg => [1, 1, 1],
1664 bg => [1, 1, 1, 0.2],
1665 active_fg => [0, 0, 1], 1697 active_fg => [0, 0, 1],
1666 can_hover => 1, 1698 can_hover => 1,
1667 align => 0, 1699 align => 0,
1668 valign => 0, 1700 valign => 0,
1669 can_events => 1, 1701 can_events => 1,
1717 1749
1718 $class->SUPER::new ( 1750 $class->SUPER::new (
1719 padding => 2, 1751 padding => 2,
1720 fg => [1, 1, 1], 1752 fg => [1, 1, 1],
1721 active_fg => [1, 1, 0], 1753 active_fg => [1, 1, 0],
1754 bg => [0, 0, 0, 0.2],
1755 active_bg => [1, 1, 1, 0.5],
1722 state => 0, 1756 state => 0,
1723 can_hover => 1, 1757 can_hover => 1,
1724 @_ 1758 @_
1725 ) 1759 )
1726} 1760}
2010 qw(s1_slider.png s1_slider_bg.png); 2044 qw(s1_slider.png s1_slider_bg.png);
2011 2045
2012sub new { 2046sub new {
2013 my $class = shift; 2047 my $class = shift;
2014 2048
2015 # range [value, low, high, page] 2049 # range [value, low, high, page, unit]
2016 2050
2017 # TODO: 0-width page 2051 # TODO: 0-width page
2018 # TODO: req_w/h are wrong with vertical 2052 # TODO: req_w/h are wrong with vertical
2019 # TODO: calculations are off 2053 # TODO: calculations are off
2020 my $self = $class->SUPER::new ( 2054 my $self = $class->SUPER::new (
2021 fg => [1, 1, 1], 2055 fg => [1, 1, 1],
2022 active_fg => [0, 0, 0], 2056 active_fg => [0, 0, 0],
2057 bg => [0, 0, 0, 0.2],
2058 active_bg => [1, 1, 1, 0.5],
2023 range => [0, 0, 100, 10], 2059 range => [0, 0, 100, 10],
2024 req_w => $::WIDTH / 80, 2060 req_w => $::WIDTH / 80,
2025 req_h => $::WIDTH / 80, 2061 req_h => $::WIDTH / 80,
2026 vertical => 0, 2062 vertical => 0,
2027 can_hover => 1, 2063 can_hover => 1,
2028 inner_pad => 5, 2064 inner_pad => 0.02,
2029 @_ 2065 @_
2030 ); 2066 );
2031 2067
2068 $self->set_value ($self->{range}[0]);
2069 $self->update;
2070
2032 $self 2071 $self
2072}
2073
2074sub set_value {
2075 my ($self, $value) = @_;
2076
2077 my ($old_value, $lo, $hi, $page, $unit) = @{$self->{range}};
2078
2079 $hi = $lo + 1 if $hi <= $lo;
2080
2081 $value = $lo if $value < $lo;
2082 $value = $hi if $value > $hi;
2083
2084 $value = $lo + $unit * int +($value - $lo + $unit * 0.5) / $unit
2085 if $unit;
2086
2087 $page = $hi - $lo if $page > $hi - $lo;
2088
2089 @{$self->{range}} = ($value, $lo, $hi, $page, $unit);
2090
2091 if ($value != $old_value) {
2092 $self->emit (changed => $value);
2093 $self->update;
2094 }
2033} 2095}
2034 2096
2035sub size_request { 2097sub size_request {
2036 my ($self) = @_; 2098 my ($self) = @_;
2037 2099
2050 2112
2051sub mouse_motion { 2113sub mouse_motion {
2052 my ($self, $ev, $x, $y) = @_; 2114 my ($self, $ev, $x, $y) = @_;
2053 2115
2054 if ($GRAB == $self) { 2116 if ($GRAB == $self) {
2117 my ($x, $w) = $self->{vertical} ? ($y, $self->{h}) : ($x, $self->{w});
2118
2119 my (undef, $lo, $hi, $page) = @{$self->{range}};
2120
2121 $x = $x / ($w * (1 - 2 * $self->{inner_pad})) - $self->{inner_pad};
2122
2123 $self->set_value ($x * ($hi - $lo) + $lo);
2124 }
2125}
2126
2127sub update {
2128 my ($self) = @_;
2129
2130 $CFClient::UI::ROOT->on_post_alloc ($self => sub {
2131 $self->set_value ($self->{range}[0]);
2132
2055 my ($value, $lo, $hi, $page) = @{$self->{range}}; 2133 my ($value, $lo, $hi, $page) = @{$self->{range}};
2056 2134
2057 my ($x, $w) = $self->{vertical} ? ($y, $self->{h}) : ($x, $self->{w}); 2135 my $inner_w = 1 - 2 * $self->{inner_pad};
2058 2136
2059 my $inner_pad_px = $self->_calc_inner_pad_px ($w); 2137 $self->{scale} = ($inner_w / ($hi - $lo)) || 1;
2060 my $inner_w = $w - $inner_pad_px * 2; # * 2 for left & right
2061 2138
2062 $x -= $inner_pad_px; # substract the padding 2139 $page = $self->{scale} * $page || 10 / ($self->{w} || 1);
2063 $x = $x * ($hi - $lo) / $inner_w + $lo; 2140 $value = $self->{scale} * ($value - $lo);
2064 $x = $lo if $x < $lo;
2065 $x = $hi - $page if $x > $hi - $page;
2066 $self->{range}[0] = $x;
2067 2141
2068 $self->emit (changed => $x); 2142 $value = $self->{inner_pad} + ($value - $page * 0.5);
2069 $self->update; 2143
2144 $value = 0 if $value < 0;
2145 $page = 1 - $value if $value + $page > 1;
2146
2147 $self->{knob_x} = $value;
2148 $self->{knob_w} = $page;
2070 } 2149 });
2071}
2072 2150
2073# the inner_* stuff is for generating a padding for the slider handle, 2151 $self->SUPER::update;
2074# so that the handle doesn't leave the texture. This calculation isn't 100%
2075# correct propably, but it does the job for now
2076sub _calc_inner_pad_px {
2077 my ($self, $w) = @_;
2078 ($w / 100) * $self->{inner_pad} # % to pixels
2079} 2152}
2080 2153
2081sub _draw { 2154sub _draw {
2082 my ($self) = @_; 2155 my ($self) = @_;
2083 2156
2084 $self->SUPER::_draw (); 2157 $self->SUPER::_draw ();
2085 2158
2086 my ($w, $h) = @$self{qw(w h)}; 2159 glScale $self->{w}, $self->{h};
2087 2160
2088 if ($self->{vertical}) { 2161 if ($self->{vertical}) {
2089 # draw a vertical slider like a rotated horizontal slider 2162 # draw a vertical slider like a rotated horizontal slider
2090 2163
2164 glTranslate 1, 0, 0;
2091 glRotate 90, 0, 0, 1; 2165 glRotate 90, 0, 0, 1;
2092 glTranslate 0, -$self->{w}, 0;
2093
2094 ($w, $h) = ($h, $w);
2095 } 2166 }
2096 2167
2097 my $fg = $FOCUS == $self ? $self->{active_fg} : $self->{fg}; 2168 my $fg = $FOCUS == $self ? $self->{active_fg} : $self->{fg};
2098 my $bg = $FOCUS == $self ? $self->{active_bg} : $self->{bg}; 2169 my $bg = $FOCUS == $self ? $self->{active_bg} : $self->{bg};
2099 2170
2100 my ($value, $lo, $hi, $page) = @{$self->{range}};
2101
2102 $hi = $value + 1 if $lo == $hi;
2103
2104 my $inner_pad_px = $self->_calc_inner_pad_px ($w);
2105 my $inner_w = $w - $inner_pad_px * 2; # * 2 for left & right
2106
2107 $page = int $page * $inner_w / ($hi - $lo);
2108 $value = int +($value - $lo) * $inner_w / ($hi - $lo);
2109
2110 $w -= $page;
2111 $page &= ~1;
2112 glTranslate $page * 0.5, 0, 0;
2113 $page ||= 2;
2114
2115 my $knob_a = $inner_pad_px + ($value - $page * 0.5);
2116 my $knob_b = $inner_pad_px + ($value + $page * 0.5);
2117
2118 glEnable GL_TEXTURE_2D; 2171 glEnable GL_TEXTURE_2D;
2119 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 2172 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2120 2173
2121 # draw background 2174 # draw background
2122 $tex[1]->draw_quad_alpha (0, 0, $w, $h); 2175 $tex[1]->draw_quad_alpha (0, 0, 1, 1);
2123 2176
2124 # draw handle 2177 # draw handle
2125 $tex[0]->draw_quad_alpha ($knob_a, 0, $knob_b - $knob_a, $h); 2178 $tex[0]->draw_quad_alpha ($self->{knob_x}, 0, $self->{knob_w}, 1);
2126 2179
2127 glDisable GL_TEXTURE_2D; 2180 glDisable GL_TEXTURE_2D;
2128} 2181}
2129 2182
2130############################################################################# 2183#############################################################################
2163 2216
2164 $self->{fontsize} = $fontsize; 2217 $self->{fontsize} = $fontsize;
2165 $self->reflow; 2218 $self->reflow;
2166} 2219}
2167 2220
2221sub 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
2168sub text_height { 2233sub text_height {
2169 my ($self, $text) = @_; 2234 my ($self, $text, $indent) = @_;
2170 2235
2171 my $layout = $self->{layout}; 2236 my $layout = $self->{layout};
2172 2237
2173 $layout->set_height ($self->{fontsize} * $::FONTSIZE); 2238 $layout->set_height ($self->{fontsize} * $::FONTSIZE);
2174 $layout->set_width ($self->{children}[0]{w}); 2239 $layout->set_width ($self->{children}[0]{w} - $indent);
2175 $layout->set_markup ($text); 2240 $layout->set_markup ($text);
2176 2241
2177 ($layout->size)[1] 2242 ($layout->size)[1]
2178} 2243}
2179 2244
2182 2247
2183 $self->{need_reflow}++; 2248 $self->{need_reflow}++;
2184 $self->update; 2249 $self->update;
2185} 2250}
2186 2251
2187sub size_allocate {
2188 my ($self, $w, $h) = @_;
2189
2190 $self->SUPER::size_allocate ($w, $h);
2191
2192 $self->{layout}->set_font ($self->{font}) if $self->{font};
2193 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE);
2194 $self->{layout}->set_width ($self->{children}[0]{w});
2195
2196 $self->reflow;
2197}
2198
2199sub add_paragraph { 2252sub add_paragraph {
2200 my ($self, $color, $text) = @_; 2253 my ($self, $color, $text, $indent) = @_;
2201 2254
2202 #TODO: intelligently "reformat" paragraph 2255 #TODO: intelligently "reformat" paragraph
2203 2256
2257 for my $line (split /\n/, $text) {
2204 my $height = $self->text_height ($text); 2258 my $height = $self->text_height ($line);
2205
2206 $self->{height} += $height; 2259 $self->{height} += $height;
2207
2208 push @{$self->{par}}, [$height, $color, $text]; 2260 push @{$self->{par}}, [$height, $color, $indent, $line];
2261 }
2209 2262
2210 $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}];
2211 $self->{children}[1]->update; 2264 $self->{children}[1]->update;
2212} 2265}
2213 2266
2222 2275
2223 $ROOT->on_post_alloc ($self, sub { 2276 $ROOT->on_post_alloc ($self, sub {
2224 if (delete $self->{need_reflow}) { 2277 if (delete $self->{need_reflow}) {
2225 my $height = 0; 2278 my $height = 0;
2226 2279
2227 $height += $_->[0] = $self->text_height ($_->[2]) 2280 $height += $_->[0] = $self->text_height ($_->[3], $_->[2])
2228 for @{$self->{par}}; 2281 for @{$self->{par}};
2229 2282
2230 $self->{height} = $height; 2283 $self->{height} = $height;
2231 2284
2232 $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;
2233 2287
2234 delete $self->{texture}; 2288 delete $self->{texture};
2235 } 2289 }
2236 2290
2237 $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 {
2238 glClearColor 0, 0, 0, 0; 2292 glClearColor 0.5, 0.5, 0.5, 0;
2239 glClear GL_COLOR_BUFFER_BIT; 2293 glClear GL_COLOR_BUFFER_BIT;
2240
2241 glEnable GL_TEXTURE_2D;
2242 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2243 2294
2244 my $top = int $self->{children}[1]{range}[0]; 2295 my $top = int $self->{children}[1]{range}[0];
2245 2296
2246 my $y0 = $top; 2297 my $y0 = $top;
2247 my $y1 = $top + $self->{h}; 2298 my $y1 = $top + $self->{h};
2250 2301
2251 my $layout = $self->{layout}; 2302 my $layout = $self->{layout};
2252 2303
2253 $layout->set_font ($self->{font}) if $self->{font}; 2304 $layout->set_font ($self->{font}) if $self->{font};
2254 2305
2306 glEnable GL_BLEND;
2307 glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA;
2308
2255 for my $par (@{$self->{par}}) { 2309 for my $par (@{$self->{par}}) {
2256 my $h = $par->[0]; 2310 my $h = $par->[0];
2257 2311
2258 if ($y0 < $y + $h && $y < $y1) { 2312 if ($y0 < $y + $h && $y < $y1) {
2259 $layout->set_foreground (@{ $par->[1] }); 2313 $layout->set_foreground (@{ $par->[1] });
2314 $layout->set_width ($self->{w} - $par->[2]);
2260 $layout->set_markup ($par->[2]); 2315 $layout->set_markup ($par->[3]);
2261 2316
2262 my ($W, $H) = $layout->size; 2317 my ($w, $h, $data, $format, $internalformat) = $layout->render;
2263 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;
2264 } 2321 }
2265 2322
2266 $y += $h; 2323 $y += $h;
2267 } 2324 }
2268 2325
2269 glDisable GL_TEXTURE_2D; 2326 glDisable GL_BLEND;
2270 }; 2327 };
2271 }); 2328 });
2272} 2329}
2273 2330
2274sub _draw { 2331sub _draw {
2275 my ($self) = @_; 2332 my ($self) = @_;
2276 2333
2277 glEnable GL_TEXTURE_2D; 2334 glEnable GL_TEXTURE_2D;
2278 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 2335 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2279 glColor 1, 1, 1, 1; 2336 glColor 1, 1, 1, 1;
2280 $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});
2281 glDisable GL_TEXTURE_2D; 2338 glDisable GL_TEXTURE_2D;
2282 2339
2283 $self->{children}[1]->draw; 2340 $self->{children}[1]->draw;
2284 2341
2285} 2342}
2384 2441
2385sub set_tooltip_from { 2442sub set_tooltip_from {
2386 my ($self, $widget) = @_; 2443 my ($self, $widget) = @_;
2387 2444
2388 $self->add (new CFClient::UI::Label 2445 $self->add (new CFClient::UI::Label
2389 markup => $widget->{tooltip}, 2446 markup => $widget->{tooltip},
2390 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, 2447 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH,
2391 fontsize => 0.8, 2448 fontsize => 0.8,
2392 fg => [0, 0, 0, 1], 2449 fg => [0, 0, 0, 1],
2450 ellipsise => 0,
2393 font => ($widget->{tooltip_font} || $::FONT_PROP), 2451 font => ($widget->{tooltip_font} || $::FONT_PROP),
2394 ); 2452 );
2395} 2453}
2396 2454
2397sub size_request { 2455sub size_request {
2398 my ($self) = @_; 2456 my ($self) = @_;
2444use CFClient::OpenGL; 2502use CFClient::OpenGL;
2445 2503
2446sub new { 2504sub new {
2447 my $class = shift; 2505 my $class = shift;
2448 2506
2449 $class->SUPER::new ( 2507 my $self = $class->SUPER::new (
2450 aspect => 1, 2508 aspect => 1,
2451 @_, 2509 @_,
2452 ) 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
2453} 2527}
2454 2528
2455sub size_request { 2529sub size_request {
2456 (32, 8) 2530 (32, 8)
2457} 2531}
2458 2532
2533sub update {
2534 my ($self) = @_;
2535
2536 return unless $self->{visible};
2537
2538 $self->SUPER::update;
2539}
2540
2459sub _draw { 2541sub _draw {
2460 my ($self) = @_; 2542 my ($self) = @_;
2461 2543
2462 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
2463 my $tex = $::CONN->{texture}[$::CONN->{faceid}[$self->{face}]]; 2555 my $tex = $::CONN->{texture}[$::CONN->{faceid}[$face || $self->{face}]];
2464 2556
2465 # TODO animation
2466 if ($tex) { 2557 if ($tex) {
2467 glEnable GL_TEXTURE_2D; 2558 glEnable GL_TEXTURE_2D;
2468 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 2559 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2469 glColor 1, 1, 1, 1; 2560 glColor 1, 1, 1, 1;
2470 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); 2561 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h});
2471 glDisable GL_TEXTURE_2D; 2562 glDisable GL_TEXTURE_2D;
2472 } 2563 }
2473} 2564}
2474 2565
2566sub DESTROY {
2567 my ($self) = @_;
2568
2569 $self->{timer}->cancel
2570 if $self->{timer};
2571
2572 $self->SUPER::DESTROY;
2573}
2574
2475############################################################################# 2575#############################################################################
2476 2576
2477package CFClient::UI::InventoryItem; 2577package CFClient::UI::InventoryItem;
2478 2578
2479our @ISA = CFClient::UI::HBox::; 2579our @ISA = CFClient::UI::HBox::;
2580
2581sub _item_to_desc {
2582 my ($item) = @_;
2583
2584 my $desc =
2585 $item->{nrof} < 2
2586 ? $item->{name}
2587 : "$item->{nrof} × $item->{name_pl}";
2588
2589 $item->{flags} & Crossfire::Protocol::F_OPEN
2590 and $desc .= " (open)";
2591 $item->{flags} & Crossfire::Protocol::F_APPLIED
2592 and $desc .= " (applied)";
2593 $item->{flags} & Crossfire::Protocol::F_UNPAID
2594 and $desc .= " (unpaid)";
2595 $item->{flags} & Crossfire::Protocol::F_MAGIC
2596 and $desc .= " (magic)";
2597 $item->{flags} & Crossfire::Protocol::F_CURSED
2598 and $desc .= " (cursed)";
2599 $item->{flags} & Crossfire::Protocol::F_DAMNED
2600 and $desc .= " (damned)";
2601 $item->{flags} & Crossfire::Protocol::F_LOCKED
2602 and $desc .= " *";
2603
2604 $desc
2605}
2480 2606
2481sub new { 2607sub new {
2482 my $class = shift; 2608 my $class = shift;
2483 2609
2484 my %args = @_; 2610 my %args = @_;
2485 2611
2486 my $item = delete $args{item}; 2612 my $item = delete $args{item};
2487 2613
2488 my $desc = $item->{nrof} < 2 2614 my $desc = _item_to_desc ($item);
2489 ? $item->{name}
2490 : "$item->{nrof} $item->{name_pl}";
2491
2492 2615
2493 my $self = $class->SUPER::new ( 2616 my $self = $class->SUPER::new (
2494 can_hover => 1, 2617 can_hover => 1,
2495 can_events => 1, 2618 can_events => 1,
2496 tooltip => (CFClient::UI::Label->escape ($desc) 2619 tooltip => ((CFClient::UI::Label::escape $desc)
2497 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"), 2620 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"),
2498 connect_button_down => sub { 2621 connect_button_down => sub {
2499 my ($self, $ev, $x, $y) = @_; 2622 my ($self, $ev, $x, $y) = @_;
2500 2623
2501 # 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 :(
2502 if ($ev->{button} == 1) { 2625 if ($ev->{button} == 1) {
2626 my $targ = $::CONN->{player}{tag};
2627
2628 if ($item->{container} == $::CONN->{player}{tag}) {
2629 $targ = $main::OPENCONT;
2630 }
2631
2503 $::CONN->send ("move $::CONN->{player}{tag} $item->{tag} 0"); 2632 $::CONN->send ("move $targ $item->{tag} 0");
2504 } elsif ($ev->{button} == 2) { 2633 } elsif ($ev->{button} == 2) {
2505 $::CONN->send ("apply $item->{tag}"); 2634 $::CONN->send ("apply $item->{tag}");
2506 } elsif ($ev->{button} == 3) { 2635 } elsif ($ev->{button} == 3) {
2507 CFClient::UI::Menu->new ( 2636 my @menu_items = (
2508 items => [
2509 ["examine", sub { $::CONN->send ("examine $item->{tag}") }], 2637 ["examine", sub { $::CONN->send ("examine $item->{tag}") }],
2510 [
2511 $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock",
2512 sub { $::CONN->send ("lock $item->{tag}") },
2513 ],
2514 ["mark", sub { $::CONN->send ("mark $item->{tag}") }], 2638 ["mark", sub { $::CONN->send ("mark ". pack "N", $item->{tag}) }],
2515 ["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}) }],
2516 ["drop", sub { $::CONN->send ("move 0 $item->{tag} 0") }], 2647 ["drop", sub { $::CONN->send ("move $main::OPENCONT $item->{tag} 0") }],
2648 )
2517 ], 2649 ),
2518 )->popup ($ev); 2650 );
2651
2652 CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev);
2519 } 2653 }
2520 2654
2521 1 2655 1
2522 }, 2656 },
2523 %args 2657 %args
2524 ); 2658 );
2659
2525 2660
2526 $self->add (new CFClient::UI::Face 2661 $self->add (new CFClient::UI::Face
2527 can_events => 0, 2662 can_events => 0,
2528 face => $item->{face}, 2663 face => $item->{face},
2529 anim => $item->{anim}, 2664 anim => $item->{anim},
2530 animspeed => $item->{animspeed}, 2665 animspeed => $item->{animspeed},
2531 ); 2666 );
2532 2667
2533 $self->add (new CFClient::UI::Label 2668 $self->add ($self->{name_lbl} = new CFClient::UI::Label can_events => 0);
2534 can_events => 0, 2669
2535 text => $desc, 2670 $self->{item} = $item;
2536 ); 2671
2672 $self->update_item;
2537 2673
2538 $self 2674 $self
2675}
2676
2677sub update_item {
2678 my ($self) = @_;
2679
2680 my $desc = _item_to_desc ($self->{item});
2681
2682 $self->{name_lbl}->set_text ($desc);
2539} 2683}
2540 2684
2541############################################################################# 2685#############################################################################
2542 2686
2543package CFClient::UI::Inventory; 2687package CFClient::UI::Inventory;
2567 } @$items; 2711 } @$items;
2568 2712
2569 $self->{real_items} = \@items; 2713 $self->{real_items} = \@items;
2570 2714
2571 for my $item (@items) { 2715 for my $item (@items) {
2572 my $desc = $item->{nrof} < 2
2573 ? $item->{name}
2574 : "$item->{nrof} $item->{name_pl}";
2575
2576 $item = $item->{widget} ||= new CFClient::UI::InventoryItem item => $item; 2716 $item = $item->{widget} ||= new CFClient::UI::InventoryItem item => $item;
2717 $item->update_item ();
2577 } 2718 }
2578 2719
2579 $self->{scrolled}->add (@items); 2720 $self->{scrolled}->add (@items);
2580 2721
2581# $range->{range} = [$self->{pos}, 0, $self->{max_pos}, $page]; 2722# $range->{range} = [$self->{pos}, 0, $self->{max_pos}, $page];
2662 2803
2663package CFClient::UI::Statusbox; 2804package CFClient::UI::Statusbox;
2664 2805
2665our @ISA = CFClient::UI::VBox::; 2806our @ISA = CFClient::UI::VBox::;
2666 2807
2808sub new {
2809 my $class = shift;
2810
2811 $class->SUPER::new (
2812 fontsize => 0.8,
2813 @_,
2814 )
2815}
2816
2667sub reorder { 2817sub reorder {
2668 my ($self) = @_; 2818 my ($self) = @_;
2669 my $NOW = time; 2819 my $NOW = time;
2670 2820
2671 while (my ($k, $v) = each %{ $self->{item} }) { 2821 while (my ($k, $v) = each %{ $self->{item} }) {
2689 ? "<b>$item->{count} ×</b> $item->{text}" 2839 ? "<b>$item->{count} ×</b> $item->{text}"
2690 : $item->{text}; 2840 : $item->{text};
2691 2841
2692 for ($short) { 2842 for ($short) {
2693 s/^\s+//; 2843 s/^\s+//;
2694 s/\012.*/…/s; 2844 s/\s+/ /g;
2695 my $len = int 40 / $item->{fontsize};
2696 substr $_, $len, length, "…" if $len < length;
2697 } 2845 }
2698 2846
2699 new CFClient::UI::Label 2847 new CFClient::UI::Label
2700 markup => $short, 2848 markup => $short,
2701 tooltip => $item->{tooltip}, 2849 tooltip => $item->{tooltip},
2702 tooltip_font => $::FONT_PROP, 2850 tooltip_font => $::FONT_PROP,
2703 tooltip_width => 0.67, 2851 tooltip_width => 0.67,
2704 fontsize => $item->{fontsize}, 2852 fontsize => $item->{fontsize} || $self->{fontsize},
2853 max_w => $::WIDTH * 0.44,
2705 color => $item->{color}, 2854 fg => $item->{fg},
2706 can_events => 1, 2855 can_events => 1,
2707 can_hover => 1 2856 can_hover => 1
2708 }; 2857 };
2709 } 2858 }
2710 2859
2736 $self->{item}{$group} = { 2885 $self->{item}{$group} = {
2737 id => ++$self->{id}, 2886 id => ++$self->{id},
2738 text => $text, 2887 text => $text,
2739 timeout => $timeout, 2888 timeout => $timeout,
2740 tooltip => $text, 2889 tooltip => $text,
2741 fontsize => 0.8,
2742 color => [0.8, 0.8, 0.8, 0.8], 2890 fg => [0.8, 0.8, 0.8, 0.8],
2743 pri => 0, 2891 pri => 0,
2744 count => 1, 2892 count => 1,
2745 %arg, 2893 %arg,
2746 }; 2894 };
2747 } 2895 }
2748 2896
2749 $self->reorder; 2897 $self->reorder;
2750} 2898}
2751 2899
2900sub reconfigure {
2901 my ($self) = @_;
2902
2903 delete $_->{label}
2904 for values %{ $self->{item} || {} };
2905
2906 $self->reorder;
2907 $self->SUPER::reconfigure;
2908}
2909
2752############################################################################# 2910#############################################################################
2753 2911
2754package CFClient::UI::Root; 2912package CFClient::UI::Root;
2755 2913
2756our @ISA = CFClient::UI::Container::; 2914our @ISA = CFClient::UI::Container::;
2795 if $old_w && $old_h && ($old_w != $w || $old_h != $h); 2953 if $old_w && $old_h && ($old_w != $w || $old_h != $h);
2796 2954
2797 for my $child ($self->children) { 2955 for my $child ($self->children) {
2798 my ($X, $Y, $W, $H) = @$child{qw(x y req_w req_h)}; 2956 my ($X, $Y, $W, $H) = @$child{qw(x y req_w req_h)};
2799 2957
2958 $X = $child->{req_x} > 0 ? $child->{req_x} : $w - $W - $child->{req_x} + 1
2959 if exists $child->{req_x};
2960
2961 $Y = $child->{req_y} > 0 ? $child->{req_y} : $h - $H - $child->{req_y} + 1
2962 if exists $child->{req_y};
2963
2800 $X = List::Util::max 0, List::Util::min $w - $W, $X; 2964 $X = List::Util::max 0, List::Util::min $w - $W, int $X + 0.5;
2801 $Y = List::Util::max 0, List::Util::min $h - $H, $Y; 2965 $Y = List::Util::max 0, List::Util::min $h - $H, int $Y + 0.5;
2966
2802 $child->configure ($X, $Y, $W, $H); 2967 $child->configure ($X, $Y, $W, $H);
2803 } 2968 }
2804} 2969}
2805 2970
2806sub coord2local { 2971sub coord2local {
2832 $child->{x} = int $child->{x}; 2997 $child->{x} = int $child->{x};
2833 $child->{y} = int $child->{y}; 2998 $child->{y} = int $child->{y};
2834 } 2999 }
2835 3000
2836 $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
3010sub 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 }
2837} 3020}
2838 3021
2839sub on_refresh { 3022sub on_refresh {
2840 my ($self, $id, $cb) = @_; 3023 my ($self, $id, $cb) = @_;
2841 3024
2910 glClearColor +($::CFG->{fow_intensity}) x 3, 1; 3093 glClearColor +($::CFG->{fow_intensity}) x 3, 1;
2911 glClear GL_COLOR_BUFFER_BIT; 3094 glClear GL_COLOR_BUFFER_BIT;
2912 3095
2913 glMatrixMode GL_PROJECTION; 3096 glMatrixMode GL_PROJECTION;
2914 glLoadIdentity; 3097 glLoadIdentity;
2915 glOrtho 0, $::WIDTH, $::HEIGHT, 0, -10000 , 10000; 3098 glOrtho 0, $::WIDTH, $::HEIGHT, 0, -10000, 10000;
2916 glMatrixMode GL_MODELVIEW; 3099 glMatrixMode GL_MODELVIEW;
2917 glLoadIdentity; 3100 glLoadIdentity;
2918 3101
2919 $self->_draw; 3102 $self->_draw;
2920} 3103}
2922############################################################################# 3105#############################################################################
2923 3106
2924package CFClient::UI; 3107package CFClient::UI;
2925 3108
2926$ROOT = new CFClient::UI::Root; 3109$ROOT = new CFClient::UI::Root;
2927$TOOLTIP = new CFClient::UI::Tooltip; 3110$TOOLTIP = new CFClient::UI::Tooltip z => 900;
2928 3111
29291 31121
2930 3113

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines