… | |
… | |
112 | $self |
112 | $self |
113 | } |
113 | } |
114 | |
114 | |
115 | sub move { |
115 | sub move { |
116 | my ($self, $x, $y, $z) = @_; |
116 | my ($self, $x, $y, $z) = @_; |
|
|
117 | |
117 | $self->{x} = int $x; |
118 | $self->{x} = int $x; |
118 | $self->{y} = int $y; |
119 | $self->{y} = int $y; |
119 | $self->{z} = $z if defined $z; |
120 | $self->{z} = $z if defined $z; |
|
|
121 | |
|
|
122 | $self->update; |
120 | } |
123 | } |
121 | |
124 | |
122 | sub needs_redraw { |
125 | sub needs_redraw { |
123 | 0 |
126 | 0 |
124 | } |
127 | } |
… | |
… | |
126 | sub size_request { |
129 | sub size_request { |
127 | require Carp; |
130 | require Carp; |
128 | Carp::confess "size_request is abtract"; |
131 | Carp::confess "size_request is abtract"; |
129 | } |
132 | } |
130 | |
133 | |
131 | sub _size_allocate { |
134 | sub configure { |
132 | my ($self, $x, $y, $w, $h) = @_; |
135 | my ($self, $x, $y, $w, $h) = @_; |
133 | |
136 | |
134 | $self->{x} = $x; |
137 | $self->{x} = $x; |
135 | $self->{y} = $y; |
138 | $self->{y} = $y; |
136 | |
139 | |
137 | return unless $self->{w} != $w || $self->{h} != $h; |
140 | return unless $self->{w} != $w || $self->{h} != $h; |
138 | |
141 | |
139 | $self->{w} = $w; |
142 | $self->{w} = $w; |
140 | $self->{h} = $h; |
143 | $self->{h} = $h; |
141 | |
144 | |
142 | 1 |
145 | $self->size_allocate ($w, $h); |
143 | } |
146 | } |
144 | |
147 | |
145 | sub size_allocate { |
148 | sub size_allocate { |
146 | my ($self, $x, $y, $w, $h) = @_; |
149 | # nothing to be done |
147 | |
|
|
148 | $self->_size_allocate ($x, $y, $w, $h); |
|
|
149 | } |
150 | } |
150 | |
151 | |
151 | # return top left coordinates |
152 | # return top left coordinates |
152 | sub _topleft { |
153 | sub _topleft { |
153 | my ($self, $x, $y) = @_; |
154 | my ($self, $x, $y) = @_; |
… | |
… | |
271 | $self->{req_w} = $w; |
272 | $self->{req_w} = $w; |
272 | $self->{req_h} = $h; |
273 | $self->{req_h} = $h; |
273 | |
274 | |
274 | $self->{parent}->check_size |
275 | $self->{parent}->check_size |
275 | if $self->{parent}; |
276 | if $self->{parent}; |
|
|
277 | |
|
|
278 | $self->size_allocate ($w, $h); |
|
|
279 | $self->update; |
276 | } |
280 | } |
277 | } |
281 | } |
278 | |
282 | |
279 | sub update { |
283 | sub update { |
280 | my ($self) = @_; |
284 | my ($self) = @_; |
… | |
… | |
284 | } |
288 | } |
285 | |
289 | |
286 | sub connect { |
290 | sub connect { |
287 | my ($self, $signal, $cb) = @_; |
291 | my ($self, $signal, $cb) = @_; |
288 | |
292 | |
289 | push @{ $self->{cb}{$signal} }, $cb; |
293 | push @{ $self->{signal_cb}{$signal} }, $cb; |
290 | } |
294 | } |
291 | |
295 | |
292 | sub emit { |
296 | sub emit { |
293 | my ($self, $signal, @args) = @_; |
297 | my ($self, $signal, @args) = @_; |
294 | |
298 | |
|
|
299 | for my $cb (@{$self->{signal_cb}{$signal} || []}) { |
295 | $_->($self, @args) |
300 | $cb->($self, @args); |
296 | for @{$self->{cb}{$signal} || []}; |
301 | } |
297 | } |
302 | } |
298 | |
303 | |
299 | sub DESTROY { |
304 | sub DESTROY { |
300 | my ($self) = @_; |
305 | my ($self) = @_; |
301 | |
306 | |
… | |
… | |
382 | sort { $a->{z} <=> $b->{z} } |
387 | sort { $a->{z} <=> $b->{z} } |
383 | @{$self->{children}}, $child |
388 | @{$self->{children}}, $child |
384 | ]; |
389 | ]; |
385 | |
390 | |
386 | $self->{w} = $self->{h} = -1; |
391 | $self->{w} = $self->{h} = -1; |
387 | $self->update; |
392 | |
|
|
393 | $child->check_size; |
388 | } |
394 | } |
389 | |
395 | |
390 | sub remove { |
396 | sub remove { |
391 | my ($self, $widget) = @_; |
397 | my ($self, $widget) = @_; |
392 | |
398 | |
… | |
… | |
453 | sub size_request { |
459 | sub size_request { |
454 | $_[0]{children}[0]->size_request |
460 | $_[0]{children}[0]->size_request |
455 | } |
461 | } |
456 | |
462 | |
457 | sub size_allocate { |
463 | sub size_allocate { |
458 | my ($self, $x, $y, $w, $h) = @_; |
464 | my ($self, $w, $h) = @_; |
459 | |
465 | |
460 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
461 | |
|
|
462 | $self->{children}[0]->size_allocate (0, 0, $w, $h); |
466 | $self->{children}[0]->configure (0, 0, $w, $h); |
463 | } |
467 | } |
464 | |
468 | |
465 | ############################################################################# |
469 | ############################################################################# |
466 | |
470 | |
467 | package CFClient::UI::Window; |
471 | package CFClient::UI::Window; |
… | |
… | |
493 | $self->child->draw; |
497 | $self->child->draw; |
494 | }; |
498 | }; |
495 | } |
499 | } |
496 | |
500 | |
497 | sub size_allocate { |
501 | sub size_allocate { |
498 | my ($self, $x, $y, $w, $h) = @_; |
502 | my ($self, $w, $h) = @_; |
499 | |
503 | |
500 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
501 | |
|
|
502 | $self->child->size_allocate (0, 0, $w, $h); |
504 | $self->child->configure (0, 0, $w, $h); |
503 | |
505 | |
504 | $self->render_chld; |
506 | $self->render_chld; |
505 | } |
507 | } |
506 | |
508 | |
507 | sub _draw { |
509 | sub _draw { |
… | |
… | |
538 | $self->child->size_allocate (0, 0, @$self{qw(child_w child_h)}); |
540 | $self->child->size_allocate (0, 0, @$self{qw(child_w child_h)}); |
539 | |
541 | |
540 | @$self{qw(child_w child_h)} |
542 | @$self{qw(child_w child_h)} |
541 | } |
543 | } |
542 | |
544 | |
543 | sub size_allocate { |
|
|
544 | my ($self, $x, $y, $w, $h) = @_; |
|
|
545 | |
|
|
546 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
547 | } |
|
|
548 | |
|
|
549 | sub _draw { |
545 | sub _draw { |
550 | my ($self) = @_; |
546 | my ($self) = @_; |
551 | |
547 | |
552 | $self->{children}[1]->draw; |
548 | $self->{children}[1]->draw; |
553 | } |
549 | } |
… | |
… | |
572 | } |
568 | } |
573 | |
569 | |
574 | sub size_allocate { |
570 | sub size_allocate { |
575 | my ($self, $x, $y, $w, $h) = @_; |
571 | my ($self, $x, $y, $w, $h) = @_; |
576 | |
572 | |
577 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
578 | |
|
|
579 | $self->child->size_allocate (2, 2, $w - 4, $h - 4); |
573 | $self->child->configure (2, 2, $w - 4, $h - 4); |
580 | } |
574 | } |
581 | |
575 | |
582 | sub _draw { |
576 | sub _draw { |
583 | my ($self) = @_; |
577 | my ($self) = @_; |
584 | |
578 | |
… | |
… | |
634 | $h + $self->{border} * 2, |
628 | $h + $self->{border} * 2, |
635 | ) |
629 | ) |
636 | } |
630 | } |
637 | |
631 | |
638 | sub size_allocate { |
632 | sub size_allocate { |
639 | my ($self, $x, $y, $w, $h) = @_; |
633 | my ($self, $w, $h) = @_; |
640 | |
|
|
641 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
642 | |
634 | |
643 | $h -= List::Util::max 0, $self->{border} * 2; |
635 | $h -= List::Util::max 0, $self->{border} * 2; |
644 | $w -= List::Util::max 0, $self->{border} * 2; |
636 | $w -= List::Util::max 0, $self->{border} * 2; |
645 | |
637 | |
646 | $self->child->size_allocate ($self->{border}, $self->{border}, $w, $h); |
638 | $self->child->configure ($self->{border}, $self->{border}, $w, $h); |
647 | } |
639 | } |
648 | |
640 | |
649 | sub button_down { |
641 | sub button_down { |
650 | my ($self, $ev, $x, $y) = @_; |
642 | my ($self, $ev, $x, $y) = @_; |
651 | |
643 | |
… | |
… | |
660 | |
652 | |
661 | ($x, $y) = ($ev->motion_x, $ev->motion_y); |
653 | ($x, $y) = ($ev->motion_x, $ev->motion_y); |
662 | |
654 | |
663 | $self->{user_w} = $bw + $x - $ox; |
655 | $self->{user_w} = $bw + $x - $ox; |
664 | $self->{user_h} = $bh + $y - $oy; |
656 | $self->{user_h} = $bh + $y - $oy; |
665 | $self->update; |
657 | $self->check_size; |
666 | }; |
658 | }; |
667 | |
659 | |
668 | } elsif ($x >= 0 && $x < $self->{w} |
660 | } elsif ($x >= 0 && $x < $self->{w} |
669 | && $y >= 0 && $y < $self->{border}) { |
661 | && $y >= 0 && $y < $self->{border}) { |
670 | |
662 | |
… | |
… | |
754 | |
746 | |
755 | $child->set_parent ($self); |
747 | $child->set_parent ($self); |
756 | $self->{children}[$y][$x] = $child; |
748 | $self->{children}[$y][$x] = $child; |
757 | |
749 | |
758 | $self->{w} = $self->{h} = -1; |
750 | $self->{w} = $self->{h} = -1; |
759 | $self->update; |
751 | |
|
|
752 | $child->check_size; |
760 | } |
753 | } |
761 | |
754 | |
762 | # TODO: move to container class maybe? send childs a signal on removal? |
755 | # TODO: move to container class maybe? send childs a signal on removal? |
763 | sub clear { |
756 | sub clear { |
764 | my ($self) = @_; |
757 | my ($self) = @_; |
… | |
… | |
799 | (sum @$hs), |
792 | (sum @$hs), |
800 | ) |
793 | ) |
801 | } |
794 | } |
802 | |
795 | |
803 | sub size_allocate { |
796 | sub size_allocate { |
804 | my ($self, $x, $y, $w, $h) = @_; |
797 | my ($self, $w, $h) = @_; |
805 | |
|
|
806 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
807 | |
798 | |
808 | my ($ws, $hs) = $self->get_wh; |
799 | my ($ws, $hs) = $self->get_wh; |
809 | |
800 | |
810 | my $req_w = sum @$ws; |
801 | my $req_w = sum @$ws; |
811 | my $req_h = sum @$hs; |
802 | my $req_h = sum @$hs; |
… | |
… | |
833 | |
824 | |
834 | for my $c (0 .. $#$row) { |
825 | for my $c (0 .. $#$row) { |
835 | my $col_w = $ws->[$c]; |
826 | my $col_w = $ws->[$c]; |
836 | |
827 | |
837 | if (my $widget = $row->[$c]) { |
828 | if (my $widget = $row->[$c]) { |
838 | $widget->size_allocate ($x, $y, $col_w, $row_h); |
829 | $widget->configure ($x, $y, $col_w, $row_h); |
839 | } |
830 | } |
840 | |
831 | |
841 | $x += $col_w; |
832 | $x += $col_w; |
842 | } |
833 | } |
843 | |
834 | |
… | |
… | |
888 | (List::Util::max map $_->[1], @alloc), |
879 | (List::Util::max map $_->[1], @alloc), |
889 | ) |
880 | ) |
890 | } |
881 | } |
891 | |
882 | |
892 | sub size_allocate { |
883 | sub size_allocate { |
893 | my ($self, $x, $y, $w, $h) = @_; |
884 | my ($self, $w, $h) = @_; |
894 | |
|
|
895 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
896 | |
885 | |
897 | ($h, $w) = ($w, $h); |
886 | ($h, $w) = ($w, $h); |
898 | |
887 | |
899 | my $children = $self->{children}; |
888 | my $children = $self->{children}; |
900 | |
889 | |
… | |
… | |
922 | |
911 | |
923 | my $y = 0; |
912 | my $y = 0; |
924 | for (0 .. $#$children) { |
913 | for (0 .. $#$children) { |
925 | my $child = $children->[$_]; |
914 | my $child = $children->[$_]; |
926 | my $h = $h[$_]; |
915 | my $h = $h[$_]; |
927 | $child->size_allocate ($y, 0, $h, $w); |
916 | $child->configure ($y, 0, $h, $w); |
928 | |
917 | |
929 | $y += $h; |
918 | $y += $h; |
930 | } |
919 | } |
931 | |
920 | |
932 | 1 |
921 | 1 |
… | |
… | |
950 | (List::Util::sum map $_->[1], @alloc), |
939 | (List::Util::sum map $_->[1], @alloc), |
951 | ) |
940 | ) |
952 | } |
941 | } |
953 | |
942 | |
954 | sub size_allocate { |
943 | sub size_allocate { |
955 | my ($self, $x, $y, $w, $h) = @_; |
944 | my ($self, $w, $h) = @_; |
956 | |
|
|
957 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
958 | |
945 | |
959 | my $children = $self->{children}; |
946 | my $children = $self->{children}; |
960 | |
947 | |
961 | my @h = map +($_->size_request)[1], @$children; |
948 | my @h = map +($_->size_request)[1], @$children; |
962 | |
949 | |
… | |
… | |
980 | |
967 | |
981 | my $y = 0; |
968 | my $y = 0; |
982 | for (0 .. $#$children) { |
969 | for (0 .. $#$children) { |
983 | my $child = $children->[$_]; |
970 | my $child = $children->[$_]; |
984 | my $h = $h[$_]; |
971 | my $h = $h[$_]; |
985 | $child->size_allocate (0, $y, $w, $h); |
972 | $child->configure (0, $y, $w, $h); |
986 | |
973 | |
987 | $y += $h; |
974 | $y += $h; |
988 | } |
975 | } |
989 | |
976 | |
990 | 1 |
977 | 1 |
… | |
… | |
1061 | $h + $self->{padding} * 2, |
1048 | $h + $self->{padding} * 2, |
1062 | ) |
1049 | ) |
1063 | } |
1050 | } |
1064 | |
1051 | |
1065 | sub size_allocate { |
1052 | sub size_allocate { |
1066 | my ($self, $x, $y, $w, $h) = @_; |
1053 | my ($self, $w, $h) = @_; |
1067 | |
|
|
1068 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
1069 | |
1054 | |
1070 | delete $self->{texture}; |
1055 | delete $self->{texture}; |
1071 | } |
1056 | } |
1072 | |
1057 | |
1073 | sub update { |
1058 | sub update { |
… | |
… | |
1162 | |
1147 | |
1163 | ($w + 1, $h) # add 1 for cursor |
1148 | ($w + 1, $h) # add 1 for cursor |
1164 | } |
1149 | } |
1165 | |
1150 | |
1166 | sub size_allocate { |
1151 | sub size_allocate { |
1167 | my ($self, $x, $y, $w, $h) = @_; |
1152 | my ($self, $w, $h) = @_; |
1168 | |
|
|
1169 | $self->SUPER::size_allocate ($x, $y, $w, $h) or return; |
|
|
1170 | |
1153 | |
1171 | $self->_set_text ($self->{text}); |
1154 | $self->_set_text ($self->{text}); |
1172 | } |
1155 | } |
1173 | |
1156 | |
1174 | sub set_text { |
1157 | sub set_text { |
… | |
… | |
1324 | padding => 4, |
1307 | padding => 4, |
1325 | fg => [1, 1, 1], |
1308 | fg => [1, 1, 1], |
1326 | bg => [1, 1, 1, 0.2], |
1309 | bg => [1, 1, 1, 0.2], |
1327 | active_fg => [0, 0, 1], |
1310 | active_fg => [0, 0, 1], |
1328 | can_hover => 1, |
1311 | can_hover => 1, |
|
|
1312 | align => 0, |
|
|
1313 | valign => 0, |
1329 | @_ |
1314 | @_ |
1330 | ) |
1315 | ) |
1331 | } |
1316 | } |
1332 | |
1317 | |
1333 | sub button_up { |
1318 | sub button_up { |
… | |
… | |
1390 | |
1375 | |
1391 | sub size_request { |
1376 | sub size_request { |
1392 | my ($self) = @_; |
1377 | my ($self) = @_; |
1393 | |
1378 | |
1394 | ($self->{padding} * 2 + 6) x 2 |
1379 | ($self->{padding} * 2 + 6) x 2 |
1395 | } |
|
|
1396 | |
|
|
1397 | sub size_allocate { |
|
|
1398 | my ($self, $x, $y, $w, $h) = @_; |
|
|
1399 | |
|
|
1400 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
1401 | } |
1380 | } |
1402 | |
1381 | |
1403 | sub button_down { |
1382 | sub button_down { |
1404 | my ($self, $ev, $x, $y) = @_; |
1383 | my ($self, $ev, $x, $y) = @_; |
1405 | |
1384 | |
… | |
… | |
1470 | } |
1449 | } |
1471 | |
1450 | |
1472 | sub size_request { |
1451 | sub size_request { |
1473 | my ($self) = @_; |
1452 | my ($self) = @_; |
1474 | |
1453 | |
1475 | ($self->{w}, $self->{h}) |
1454 | my $tex = $tex{$self->{gauge}}[0]; |
|
|
1455 | |
|
|
1456 | @$tex{qw(w h)} |
1476 | } |
1457 | } |
1477 | |
1458 | |
1478 | sub set_max { |
1459 | sub set_max { |
1479 | my ($self, $max) = @_; |
1460 | my ($self, $max) = @_; |
|
|
1461 | |
1480 | $self->{max_val} = $max; |
1462 | $self->{max_val} = $max; |
1481 | } |
1463 | } |
1482 | |
1464 | |
1483 | sub set_value { |
1465 | sub set_value { |
1484 | my ($self, $val, $max) = @_; |
1466 | my ($self, $val, $max) = @_; |
… | |
… | |
1513 | my $h1 = $self->{h} - $ycut * $self->{h}; |
1495 | my $h1 = $self->{h} - $ycut * $self->{h}; |
1514 | my $h2 = $ycut * $self->{h}; |
1496 | my $h2 = $ycut * $self->{h}; |
1515 | |
1497 | |
1516 | my $yp = 0; |
1498 | my $yp = 0; |
1517 | |
1499 | |
1518 | glBindTexture (GL_TEXTURE_2D, $t1->{name}); |
1500 | glBindTexture GL_TEXTURE_2D, $t1->{name}; |
1519 | glBegin (GL_QUADS); |
1501 | glBegin GL_QUADS; |
1520 | glTexCoord (0, 0); glVertex (0 , $yp); |
1502 | glTexCoord 0 , 0; glVertex 0 , $yp; |
1521 | glTexCoord (0, (1 - $ycut)); glVertex (0 , $yp + $h1); |
1503 | glTexCoord 0 , $t1->{t} * (1 - $ycut); glVertex 0 , $yp + $h1; |
1522 | glTexCoord (1, (1 - $ycut)); glVertex (0 + $w, $yp + $h1); |
1504 | glTexCoord $t1->{s}, $t1->{t} * (1 - $ycut); glVertex 0 + $w, $yp + $h1; |
1523 | glTexCoord (1, 0); glVertex (0 + $w, $yp); |
1505 | glTexCoord $t1->{s}, 0; glVertex 0 + $w, $yp; |
1524 | glEnd (); |
1506 | glEnd; |
1525 | |
1507 | |
1526 | $yp += $h1; |
1508 | $yp += $h1; |
1527 | |
1509 | |
1528 | glBindTexture (GL_TEXTURE_2D, $t2->{name}); |
1510 | glBindTexture GL_TEXTURE_2D, $t2->{name}; |
1529 | glBegin (GL_QUADS); |
1511 | glBegin GL_QUADS; |
1530 | glTexCoord (0, (1 - $ycut)); glVertex (0 , $yp); |
1512 | glTexCoord 0 , $t2->{t} * (1 - $ycut); glVertex 0 , $yp; |
1531 | glTexCoord (0, 1); glVertex (0 , $yp + $h2); |
1513 | glTexCoord 0 , $t2->{t}; glVertex 0 , $yp + $h2; |
1532 | glTexCoord (1, 1); glVertex (0 + $w, $yp + $h2); |
1514 | glTexCoord $t2->{s}, $t2->{t}; glVertex 0 + $w, $yp + $h2; |
1533 | glTexCoord (1, (1 - $ycut)); glVertex (0 + $w, $yp); |
1515 | glTexCoord $t2->{s}, $t2->{t} * (1 - $ycut); glVertex 0 + $w, $yp; |
1534 | glEnd (); |
1516 | glEnd; |
1535 | |
1517 | |
1536 | glDisable GL_BLEND; |
1518 | glDisable GL_BLEND; |
1537 | glDisable GL_TEXTURE_2D; |
1519 | glDisable GL_TEXTURE_2D; |
1538 | } |
1520 | } |
1539 | |
1521 | |
… | |
… | |
1736 | |
1718 | |
1737 | ($self->{req_w}, $self->{req_h}) |
1719 | ($self->{req_w}, $self->{req_h}) |
1738 | } |
1720 | } |
1739 | |
1721 | |
1740 | sub size_allocate { |
1722 | sub size_allocate { |
1741 | my ($self, $x, $y, $w, $h) = @_; |
1723 | my ($self, $w, $h) = @_; |
1742 | |
|
|
1743 | $self->SUPER::size_allocate ($x, $y, $w, $h) or return; |
|
|
1744 | |
1724 | |
1745 | $self->{layout}->set_height ($self->{fontsize}); |
1725 | $self->{layout}->set_height ($self->{fontsize}); |
1746 | $self->{layout}->set_width ($self->{w}); |
1726 | $self->{layout}->set_width ($self->{w}); |
1747 | |
1727 | |
1748 | $self->reflow; |
1728 | $self->reflow; |
… | |
… | |
1934 | glTranslate $sx0 - 32, $sy0 - 32, 0; |
1914 | glTranslate $sx0 - 32, $sy0 - 32, 0; |
1935 | |
1915 | |
1936 | my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); |
1916 | my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); |
1937 | |
1917 | |
1938 | if ($::CFG->{fow_enable}) { |
1918 | if ($::CFG->{fow_enable}) { |
1939 | if ($::CFG->{fow_smooth}) { # smooth fog of war |
1919 | if ($::CFG->{fow_smooth} && $CFClient::GL_VERSION >= 1.2) { # smooth fog of war |
1940 | glConvolutionParameter GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER; |
1920 | glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER); |
1941 | glConvolutionFilter2D |
1921 | glConvolutionFilter2D ( |
1942 | GL_CONVOLUTION_2D, |
1922 | GL_CONVOLUTION_2D, |
1943 | GL_ALPHA, |
1923 | GL_ALPHA, |
1944 | 3, 3, |
1924 | 3, 3, |
1945 | GL_ALPHA, GL_FLOAT, |
1925 | GL_ALPHA, GL_FLOAT, |
1946 | pack "f*", |
1926 | pack "f*", |
1947 | 0.1, 0.1, 0.1, |
1927 | 0.1, 0.1, 0.1, |
1948 | 0.1, 0.2, 0.1, |
1928 | 0.1, 0.2, 0.1, |
1949 | 0.1, 0.1, 0.1, |
1929 | 0.1, 0.1, 0.1, |
1950 | ; |
1930 | ); |
1951 | glEnable GL_CONVOLUTION_2D; |
1931 | glEnable GL_CONVOLUTION_2D; |
1952 | } |
1932 | } |
1953 | |
1933 | |
1954 | $self->{fow_texture} = new CFClient::Texture |
1934 | $self->{fow_texture} = new CFClient::Texture |
1955 | w => $w, |
1935 | w => $w, |
… | |
… | |
1985 | $self->{mapmap_texture} = |
1965 | $self->{mapmap_texture} = |
1986 | new CFClient::Texture |
1966 | new CFClient::Texture |
1987 | w => $w, |
1967 | w => $w, |
1988 | h => $h, |
1968 | h => $h, |
1989 | data => $::MAP->mapmap ($w, $h), |
1969 | data => $::MAP->mapmap ($w, $h), |
1990 | type => GL_UNSIGNED_INT_8_8_8_8_REV; |
1970 | type => $CFClient::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE; |
1991 | |
1971 | |
1992 | $self->{mapmap_texture}->draw_quad (100, 100); |
1972 | $self->{mapmap_texture}->draw_quad (100, 100); |
1993 | |
1973 | |
1994 | glDisable GL_TEXTURE_2D; |
1974 | glDisable GL_TEXTURE_2D; |
1995 | glDisable GL_BLEND; |
1975 | glDisable GL_BLEND; |
… | |
… | |
2165 | use SDL::OpenGL; |
2145 | use SDL::OpenGL; |
2166 | |
2146 | |
2167 | sub check_size { |
2147 | sub check_size { |
2168 | my ($self) = @_; |
2148 | my ($self) = @_; |
2169 | |
2149 | |
2170 | $self->size_allocate (0, 0, $::WITH, $::HEIGHT); |
2150 | $self->configure (0, 0, $::WITH, $::HEIGHT); |
2171 | } |
2151 | } |
2172 | |
2152 | |
2173 | sub size_request { |
2153 | sub size_request { |
2174 | ($::WIDTH, $::HEIGHT) |
2154 | ($::WIDTH, $::HEIGHT) |
2175 | } |
2155 | } |
2176 | |
2156 | |
2177 | sub size_allocate { |
2157 | sub configure { |
2178 | my ($self, $x, $y, $w, $h) = @_; |
2158 | my ($self, $x, $y, $w, $h) = @_; |
2179 | |
2159 | |
2180 | $self->_size_allocate ($x, $y, $w, $h); |
2160 | $self->SUPER::configure ($x, $y, $w, $h); |
2181 | |
2161 | |
2182 | $_->size_allocate ($_->{x}, $_->{y}, $_->size_request) |
2162 | $_->configure ($_->{x}, $_->{y}, $_->size_request) |
2183 | for @{$self->{children}}; |
2163 | for @{$self->{children}}; |
2184 | } |
2164 | } |
2185 | |
2165 | |
2186 | sub _topleft { |
2166 | sub _topleft { |
2187 | my ($self, $x, $y) = @_; |
2167 | my ($self, $x, $y) = @_; |
… | |
… | |
2195 | $self->check_size; |
2175 | $self->check_size; |
2196 | ::refresh (); |
2176 | ::refresh (); |
2197 | } |
2177 | } |
2198 | |
2178 | |
2199 | sub add { |
2179 | sub add { |
2200 | my ($self, $widget) = @_; |
2180 | my ($self, $child) = @_; |
2201 | |
2181 | |
2202 | $self->SUPER::add ($widget); |
2182 | $self->SUPER::add ($child); |
2203 | |
|
|
2204 | $widget->size_allocate (int $widget->{x}, int $widget->{y}, $widget->size_request); |
|
|
2205 | } |
2183 | } |
2206 | |
2184 | |
2207 | sub on_refresh { |
2185 | sub on_refresh { |
2208 | my ($self, $id, $cb) = @_; |
2186 | my ($self, $id, $cb) = @_; |
2209 | |
2187 | |