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.260 by elmex, Tue May 30 14:35:09 2006 UTC vs.
Revision 1.271 by root, Fri Jun 2 22:13:47 2006 UTC

40 40
41 $LAYOUT = $layout; 41 $LAYOUT = $layout;
42} 42}
43 43
44sub check_tooltip { 44sub check_tooltip {
45 return if $ENV{CFPLUS_DEBUG} & 8;
46
45 if (!$GRAB) { 47 if (!$GRAB) {
46 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { 48 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) {
47 if (length $widget->{tooltip}) { 49 if (length $widget->{tooltip}) {
48
49 if ($TOOLTIP->{owner} != $widget) { 50 if ($TOOLTIP->{owner} != $widget) {
50 $TOOLTIP->hide; 51 $TOOLTIP->hide;
51 52
52 $TOOLTIP->{owner} = $widget; 53 $TOOLTIP->{owner} = $widget;
53 54
170sub rescale_widgets { 171sub rescale_widgets {
171 my ($sx, $sy) = @_; 172 my ($sx, $sy) = @_;
172 173
173 for my $widget (values %WIDGET) { 174 for my $widget (values %WIDGET) {
174 if ($widget->{is_toplevel}) { 175 if ($widget->{is_toplevel}) {
175 $widget->{x} += $widget->{w} * 0.5 if $widget->{x} =~ /^[0-9.]+$/; 176 $widget->{x} += int $widget->{w} * 0.5 if $widget->{x} =~ /^[0-9.]+$/;
176 $widget->{y} += $widget->{h} * 0.5 if $widget->{y} =~ /^[0-9.]+$/; 177 $widget->{y} += int $widget->{h} * 0.5 if $widget->{y} =~ /^[0-9.]+$/;
177 178
178 $widget->{x} = int 0.5 + $widget->{x} * $sx if $widget->{x} =~ /^[0-9.]+$/; 179 $widget->{x} = int 0.5 + $widget->{x} * $sx if $widget->{x} =~ /^[0-9.]+$/;
179 $widget->{w} = int 0.5 + $widget->{w} * $sx if exists $widget->{w}; 180 $widget->{w} = int 0.5 + $widget->{w} * $sx if exists $widget->{w};
180 $widget->{force_w} = int 0.5 + $widget->{force_w} * $sx if exists $widget->{force_w}; 181 $widget->{force_w} = int 0.5 + $widget->{force_w} * $sx if exists $widget->{force_w};
181 $widget->{y} = int 0.5 + $widget->{y} * $sy if $widget->{y} =~ /^[0-9.]+$/; 182 $widget->{y} = int 0.5 + $widget->{y} * $sy if $widget->{y} =~ /^[0-9.]+$/;
182 $widget->{h} = int 0.5 + $widget->{h} * $sy if exists $widget->{h}; 183 $widget->{h} = int 0.5 + $widget->{h} * $sy if exists $widget->{h};
183 $widget->{force_h} = int 0.5 + $widget->{force_h} * $sy if exists $widget->{force_h}; 184 $widget->{force_h} = int 0.5 + $widget->{force_h} * $sy if exists $widget->{force_h};
184 185
185 $widget->{x} -= $widget->{w} * 0.5 if $widget->{x} =~ /^[0-9.]+$/; 186 $widget->{x} -= int $widget->{w} * 0.5 if $widget->{x} =~ /^[0-9.]+$/;
186 $widget->{y} -= $widget->{h} * 0.5 if $widget->{y} =~ /^[0-9.]+$/; 187 $widget->{y} -= int $widget->{h} * 0.5 if $widget->{y} =~ /^[0-9.]+$/;
187 188
188 } 189 }
189 } 190 }
190 191
191 reconfigure_widgets; 192 reconfigure_widgets;
438 439
439 $::MAPWIDGET->focus_in #d# focus mapwidget if no other widget has focus 440 $::MAPWIDGET->focus_in #d# focus mapwidget if no other widget has focus
440 unless $FOCUS; 441 unless $FOCUS;
441} 442}
442 443
443sub mouse_motion { } 444sub mouse_motion { 0 }
444sub button_up { } 445sub button_up { 0 }
445sub key_down { } 446sub key_down { 0 }
446sub key_up { } 447sub key_up { 0 }
447 448
448sub button_down { 449sub button_down {
449 my ($self, $ev, $x, $y) = @_; 450 my ($self, $ev, $x, $y) = @_;
450 451
451 $self->focus_in; 452 $self->focus_in;
452}
453 453
454sub w { $_[0]{w} = $_[1] if @_ > 1; $_[0]{w} } 454 0
455sub h { $_[0]{h} = $_[1] if @_ > 1; $_[0]{h} } 455}
456sub x { $_[0]{x} = $_[1] if @_ > 1; $_[0]{x} }
457sub y { $_[0]{y} = $_[1] if @_ > 1; $_[0]{y} }
458sub z { $_[0]{z} = $_[1] if @_ > 1; $_[0]{z} }
459 456
460sub find_widget { 457sub find_widget {
461 my ($self, $x, $y) = @_; 458 my ($self, $x, $y) = @_;
462 459
463 return () unless $self->{can_events}; 460 return () unless $self->{can_events};
525 522
526 $self->realloc; 523 $self->realloc;
527 $self->update; 524 $self->update;
528} 525}
529 526
527# using global variables seems a bit hacky, but passing through all drawing
528# functions seems pointless.
529our ($draw_x, $draw_y, $draw_w, $draw_h); # screen rectangle being drawn
530
530sub draw { 531sub draw {
531 my ($self) = @_; 532 my ($self) = @_;
532 533
533 return unless $self->{h} && $self->{w}; 534 return unless $self->{h} && $self->{w};
535
536 # update screen rectangle
537 local $draw_x = $draw_x + $self->{x};
538 local $draw_y = $draw_y + $self->{y};
539 local $draw_w = $draw_x + $self->{w};
540 local $draw_h = $draw_y + $self->{h};
541
542 # skip widgets that are entirely outside the drawing area
543 return if ($draw_x + $self->{w} < 0) || ($draw_x >= $draw_w)
544 || ($draw_y + $self->{h} < 0) || ($draw_y >= $draw_h);
534 545
535 glPushMatrix; 546 glPushMatrix;
536 glTranslate $self->{x}, $self->{y}, 0; 547 glTranslate $self->{x}, $self->{y}, 0;
537 $self->_draw; 548 $self->_draw;
538 glPopMatrix; 549 glPopMatrix;
803 $self->SUPER::size_allocate ($w, $h); 814 $self->SUPER::size_allocate ($w, $h);
804 $self->update; 815 $self->update;
805} 816}
806 817
807sub _render { 818sub _render {
819 my ($self) = @_;
820
808 $_[0]{children}[0]->draw; 821 $self->{children}[0]->draw;
809} 822}
810 823
811sub render_child { 824sub render_child {
812 my ($self) = @_; 825 my ($self) = @_;
813 826
814 $self->{texture} = new_from_opengl CFClient::Texture $self->{w}, $self->{h}, sub { 827 $self->{texture} = new_from_opengl CFClient::Texture $self->{w}, $self->{h}, sub {
815 glClearColor 0, 0, 0, 0; 828 glClearColor 0, 0, 0, 0;
816 glClear GL_COLOR_BUFFER_BIT; 829 glClear GL_COLOR_BUFFER_BIT;
817 830
831 {
832 package CFClient::UI::Base;
833
834 ($draw_x, $draw_y, $draw_w, $draw_h) =
835 (0, 0, $self->{w}, $self->{h});
836 }
837
818 $self->_render; 838 $self->_render;
819 }; 839 };
820} 840}
821 841
822sub _draw { 842sub _draw {
823 my ($self) = @_; 843 my ($self) = @_;
824 844
825 my ($w, $h) = ($self->w, $self->h); 845 my ($w, $h) = @$self{qw(w h)};
826 846
827 my $tex = $self->{texture} 847 my $tex = $self->{texture}
828 or return; 848 or return;
829 849
830 glEnable GL_TEXTURE_2D; 850 glEnable GL_TEXTURE_2D;
912 } 932 }
913} 933}
914 934
915sub _render { 935sub _render {
916 my ($self) = @_; 936 my ($self) = @_;
937
938 local $CFClient::UI::Base::draw_x = $CFClient::UI::Base::draw_x - $self->{view_x};
939 local $CFClient::UI::Base::draw_y = $CFClient::UI::Base::draw_y - $self->{view_y};
917 940
918 CFClient::OpenGL::glTranslate -$self->{view_x}, -$self->{view_y}; 941 CFClient::OpenGL::glTranslate -$self->{view_x}, -$self->{view_y};
919 942
920 $self->SUPER::_render; 943 $self->SUPER::_render;
921} 944}
1029my @border = 1052my @border =
1030 map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } 1053 map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 }
1031 qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); 1054 qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png);
1032 1055
1033sub new { 1056sub new {
1034 my $class = shift; 1057 my ($class, %arg) = @_;
1058
1059 my $title = delete $arg{title};
1035 1060
1036 my $self = $class->SUPER::new ( 1061 my $self = $class->SUPER::new (
1037 bg => [1, 1, 1, 1], 1062 bg => [1, 1, 1, 1],
1038 border_bg => [1, 1, 1, 1], 1063 border_bg => [1, 1, 1, 1],
1039 border => 0.6, 1064 border => 0.6,
1040 can_events => 1, 1065 can_events => 1,
1041 min_w => 16, 1066 min_w => 16,
1042 min_h => 16, 1067 min_h => 16,
1043 @_ 1068 %arg,
1044 ); 1069 );
1045 1070
1046 $self->{title} &&= new CFClient::UI::Label 1071 $self->{title} = new CFClient::UI::Label
1047 align => 0, 1072 align => 0,
1048 valign => 1, 1073 valign => 1,
1049 text => $self->{title}, 1074 text => $title,
1050 fontsize => $self->{border}; 1075 fontsize => $self->{border}
1076 if defined $title;
1051 1077
1052 $self 1078 $self
1079}
1080
1081sub add {
1082 my ($self, @widgets) = @_;
1083
1084 $self->SUPER::add (@widgets);
1085 $self->CFClient::UI::Container::add ($self->{title}) if $self->{title};
1053} 1086}
1054 1087
1055sub border { 1088sub border {
1056 int $_[0]{border} * $::FONTSIZE 1089 int $_[0]{border} * $::FONTSIZE
1057} 1090}
1058 1091
1059sub size_request { 1092sub size_request {
1060 my ($self) = @_; 1093 my ($self) = @_;
1094
1095 $self->{title}->size_request
1096 if $self->{title};
1061 1097
1062 my ($w, $h) = $self->SUPER::size_request; 1098 my ($w, $h) = $self->SUPER::size_request;
1063 1099
1064 ( 1100 (
1065 $w + $self->border * 2, 1101 $w + $self->border * 2,
1068} 1104}
1069 1105
1070sub size_allocate { 1106sub size_allocate {
1071 my ($self, $w, $h) = @_; 1107 my ($self, $w, $h) = @_;
1072 1108
1109 if ($self->{title}) {
1110 $self->{title}{w} = $w;
1111 $self->{title}{h} = $h;
1112 $self->{title}->size_allocate ($w, $h);
1113 }
1114
1115 my $border = $self->border;
1116
1073 $h -= List::Util::max 0, $self->border * 2; 1117 $h -= List::Util::max 0, $border * 2;
1074 $w -= List::Util::max 0, $self->border * 2; 1118 $w -= List::Util::max 0, $border * 2;
1075 1119
1076 $self->{title}->configure ($self->border, int $self->border - $::FONTSIZE * 2, $w, int $::FONTSIZE * 2)
1077 if $self->{title};
1078
1079 $self->child->configure ($self->border, $self->border, $w, $h); 1120 $self->child->configure ($border, $border, $w, $h);
1080} 1121}
1081 1122
1082sub button_down { 1123sub button_down {
1083 my ($self, $ev, $x, $y) = @_; 1124 my ($self, $ev, $x, $y) = @_;
1084 1125
1118 1159
1119 ($x, $y) = ($ev->{x}, $ev->{y}); 1160 ($x, $y) = ($ev->{x}, $ev->{y});
1120 1161
1121 $self->move_abs ($bx + $x - $ox, $by + $y - $oy); 1162 $self->move_abs ($bx + $x - $ox, $by + $y - $oy);
1122 }; 1163 };
1164 } else {
1165 return 0;
1166 }
1167
1123 } 1168 1
1124} 1169}
1125 1170
1126sub button_up { 1171sub button_up {
1127 my ($self, $ev, $x, $y) = @_; 1172 my ($self, $ev, $x, $y) = @_;
1128 1173
1129 delete $self->{motion}; 1174 !!delete $self->{motion}
1130} 1175}
1131 1176
1132sub mouse_motion { 1177sub mouse_motion {
1133 my ($self, $ev, $x, $y) = @_; 1178 my ($self, $ev, $x, $y) = @_;
1134 1179
1135 $self->{motion}->($ev, $x, $y) if $self->{motion}; 1180 $self->{motion}->($ev, $x, $y) if $self->{motion};
1181
1182 !!$self->{motion}
1136} 1183}
1137 1184
1138sub _draw { 1185sub _draw {
1139 my ($self) = @_; 1186 my ($self) = @_;
1140 1187
1188 my $child = $self->{children}[0];
1189
1141 my ($w, $h ) = ($self->{w}, $self->{h}); 1190 my ($w, $h ) = ($self->{w}, $self->{h});
1142 my ($cw, $ch) = ($self->child->{w}, $self->child->{h}); 1191 my ($cw, $ch) = ($child->{w}, $child->{h});
1143 1192
1144 glEnable GL_TEXTURE_2D; 1193 glEnable GL_TEXTURE_2D;
1145 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 1194 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
1146 1195
1147 my $border = $self->border; 1196 my $border = $self->border;
1162 $bg->draw_quad_alpha ($border, $border, $cw, $ch); 1211 $bg->draw_quad_alpha ($border, $border, $cw, $ch);
1163 } 1212 }
1164 1213
1165 glDisable GL_TEXTURE_2D; 1214 glDisable GL_TEXTURE_2D;
1166 1215
1167 $self->{title}->draw if $self->{title};
1168
1169 $self->child->draw; 1216 $child->draw;
1217
1218 if ($self->{title}) {
1219 glTranslate 0, $border - $self->{h};
1220 $self->{title}->_draw;
1221 }
1170} 1222}
1171 1223
1172############################################################################# 1224#############################################################################
1173 1225
1174package CFClient::UI::Table; 1226package CFClient::UI::Table;
1522} 1574}
1523 1575
1524sub size_allocate { 1576sub size_allocate {
1525 my ($self, $w, $h) = @_; 1577 my ($self, $w, $h) = @_;
1526 1578
1579 delete $self->{ox};
1580
1527 delete $self->{texture}; 1581 delete $self->{texture}
1582 unless $w >= $self->{req_w} && $self->{old_w} >= $self->{req_w};
1528} 1583}
1529 1584
1530sub set_fontsize { 1585sub set_fontsize {
1531 my ($self, $fontsize) = @_; 1586 my ($self, $fontsize) = @_;
1532 1587
1547 $self->{layout}->set_width ($self->{w}); 1602 $self->{layout}->set_width ($self->{w});
1548 $self->{layout}->set_ellipsise ($self->{ellipsise}); 1603 $self->{layout}->set_ellipsise ($self->{ellipsise});
1549 $self->{layout}->set_single_paragraph_mode ($self->{ellipsise}); 1604 $self->{layout}->set_single_paragraph_mode ($self->{ellipsise});
1550 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); 1605 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE);
1551 1606
1552 my $tex = new_from_layout CFClient::Texture $self->{layout}; 1607 new_from_layout CFClient::Texture $self->{layout}
1608 };
1553 1609
1610 unless (exists $self->{ox}) {
1554 $self->{ox} = int ($self->{align} < 0 ? $self->{padding_x} 1611 $self->{ox} = int ($self->{align} < 0 ? $self->{padding_x}
1555 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding_x} 1612 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding_x}
1556 : ($self->{w} - $tex->{w}) * 0.5); 1613 : ($self->{w} - $tex->{w}) * 0.5);
1557 1614
1558 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y} 1615 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y}
1559 : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding_y} 1616 : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding_y}
1560 : ($self->{h} - $tex->{h}) * 0.5); 1617 : ($self->{h} - $tex->{h}) * 0.5);
1561
1562 $tex
1563 }; 1618 };
1564 1619
1565 glEnable GL_TEXTURE_2D; 1620 glEnable GL_TEXTURE_2D;
1566 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 1621 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1567 1622
1662 $self->{cursor} = length $text; 1717 $self->{cursor} = length $text;
1663 } elsif ($uni == 27) { 1718 } elsif ($uni == 27) {
1664 $self->_emit ('escape'); 1719 $self->_emit ('escape');
1665 } elsif ($uni) { 1720 } elsif ($uni) {
1666 substr $text, $self->{cursor}++, 0, chr $uni; 1721 substr $text, $self->{cursor}++, 0, chr $uni;
1722 } else {
1723 return 0;
1667 } 1724 }
1668 1725
1669 $self->_set_text ($text); 1726 $self->_set_text ($text);
1670 1727
1671 $self->realloc; 1728 $self->realloc;
1729
1730 1
1672} 1731}
1673 1732
1674sub focus_in { 1733sub focus_in {
1675 my ($self) = @_; 1734 my ($self) = @_;
1676 1735
1691 utf8::encode $text; 1750 utf8::encode $text;
1692 $self->{cursor} = length substr $text, 0, $idx; 1751 $self->{cursor} = length substr $text, 0, $idx;
1693 1752
1694 $self->_set_text ($self->{text}); 1753 $self->_set_text ($self->{text});
1695 $self->update; 1754 $self->update;
1755
1756 1
1696} 1757}
1697 1758
1698sub mouse_motion { 1759sub mouse_motion {
1699 my ($self, $ev, $x, $y) = @_; 1760 my ($self, $ev, $x, $y) = @_;
1700# printf "M %d,%d %d,%d\n", $ev->motion_x, $ev->motion_y, $x, $y;#d# 1761# printf "M %d,%d %d,%d\n", $ev->motion_x, $ev->motion_y, $x, $y;#d#
1762
1763 0
1701} 1764}
1702 1765
1703sub _draw { 1766sub _draw {
1704 my ($self) = @_; 1767 my ($self) = @_;
1705 1768
1782 } else { 1845 } else {
1783 $self->set_text ($self->{history_saveback}); 1846 $self->set_text ($self->{history_saveback});
1784 } 1847 }
1785 1848
1786 } else { 1849 } else {
1787 $self->SUPER::key_down ($ev); 1850 return $self->SUPER::key_down ($ev)
1851 }
1852
1788 } 1853 1
1789
1790} 1854}
1791 1855
1792############################################################################# 1856#############################################################################
1793 1857
1794package CFClient::UI::Button; 1858package CFClient::UI::Button;
1823 my ($self, $ev, $x, $y) = @_; 1887 my ($self, $ev, $x, $y) = @_;
1824 1888
1825 $self->emit ("activate") 1889 $self->emit ("activate")
1826 if $x >= 0 && $x < $self->{w} 1890 if $x >= 0 && $x < $self->{w}
1827 && $y >= 0 && $y < $self->{h}; 1891 && $y >= 0 && $y < $self->{h};
1892
1893 1
1828} 1894}
1829 1895
1830sub _draw { 1896sub _draw {
1831 my ($self) = @_; 1897 my ($self) = @_;
1832 1898
1886 1952
1887 if ($x >= $self->{padding_x} && $x < $self->{w} - $self->{padding_x} 1953 if ($x >= $self->{padding_x} && $x < $self->{w} - $self->{padding_x}
1888 && $y >= $self->{padding_y} && $y < $self->{h} - $self->{padding_y}) { 1954 && $y >= $self->{padding_y} && $y < $self->{h} - $self->{padding_y}) {
1889 $self->{state} = !$self->{state}; 1955 $self->{state} = !$self->{state};
1890 $self->_emit (changed => $self->{state}); 1956 $self->_emit (changed => $self->{state});
1957 } else {
1958 return 0
1959 }
1960
1891 } 1961 1
1892} 1962}
1893 1963
1894sub _draw { 1964sub _draw {
1895 my ($self) = @_; 1965 my ($self) = @_;
1896 1966
2234 2304
2235 $self->SUPER::button_down ($ev, $x, $y); 2305 $self->SUPER::button_down ($ev, $x, $y);
2236 2306
2237 $self->{click} = [$self->{range}[0], $self->{vertical} ? $y : $x]; 2307 $self->{click} = [$self->{range}[0], $self->{vertical} ? $y : $x];
2238 2308
2239 $self->mouse_motion ($ev, $x, $y); 2309 $self->mouse_motion ($ev, $x, $y)
2240} 2310}
2241 2311
2242sub mouse_motion { 2312sub mouse_motion {
2243 my ($self, $ev, $x, $y) = @_; 2313 my ($self, $ev, $x, $y) = @_;
2244 2314
2248 my (undef, $lo, $hi, $page) = @{$self->{range}}; 2318 my (undef, $lo, $hi, $page) = @{$self->{range}};
2249 2319
2250 $x = ($x - $self->{click}[1]) / ($w * $self->{scale}); 2320 $x = ($x - $self->{click}[1]) / ($w * $self->{scale});
2251 2321
2252 $self->set_value ($self->{click}[0] + $x * ($hi - $page - $lo)); 2322 $self->set_value ($self->{click}[0] + $x * ($hi - $page - $lo));
2323 } else {
2324 return 0;
2325 }
2326
2253 } 2327 1
2254} 2328}
2255 2329
2256sub update { 2330sub update {
2257 my ($self) = @_; 2331 my ($self) = @_;
2258 2332
2780 $self->SUPER::DESTROY; 2854 $self->SUPER::DESTROY;
2781} 2855}
2782 2856
2783############################################################################# 2857#############################################################################
2784 2858
2785package CFClient::UI::Inventory;
2786
2787our @ISA = CFClient::UI::ScrolledWindow::;
2788
2789sub new {
2790 my $class = shift;
2791
2792 my $self = $class->SUPER::new (
2793 scrolled => (new CFClient::UI::Table col_expand => [0, 1, 0]),
2794 @_,
2795 );
2796
2797 $self
2798}
2799
2800sub set_items {
2801 my ($self, $items) = @_;
2802
2803 $self->{scrolled}->clear;
2804 return unless $items;
2805
2806 my @items = sort {
2807 ($a->{type} <=> $b->{type})
2808 or ($a->{name} cmp $b->{name})
2809 } @$items;
2810
2811 $self->{real_items} = \@items;
2812
2813 my $row = 0;
2814 for my $item (@items) {
2815 CFClient::Item::update_widgets $item;
2816
2817 $self->{scrolled}->add (0, $row, $item->{face_widget});
2818 $self->{scrolled}->add (1, $row, $item->{desc_widget});
2819 $self->{scrolled}->add (2, $row, $item->{weight_widget});
2820
2821 $row++;
2822 }
2823}
2824
2825#############################################################################
2826
2827package CFClient::UI::Menu; 2859package CFClient::UI::Menu;
2828 2860
2829our @ISA = CFClient::UI::FancyFrame::; 2861our @ISA = CFClient::UI::FancyFrame::;
2830 2862
2831use CFClient::OpenGL; 2863use CFClient::OpenGL;
2878 my ($self, $ev, $x, $y) = @_; 2910 my ($self, $ev, $x, $y) = @_;
2879 2911
2880 # TODO: should use vbox->find_widget or so 2912 # TODO: should use vbox->find_widget or so
2881 $HOVER = $ROOT->find_widget ($ev->{x}, $ev->{y}); 2913 $HOVER = $ROOT->find_widget ($ev->{x}, $ev->{y});
2882 $self->{hover} = $self->{item}{$HOVER}; 2914 $self->{hover} = $self->{item}{$HOVER};
2915
2916 0
2883} 2917}
2884 2918
2885sub button_up { 2919sub button_up {
2886 my ($self, $ev, $x, $y) = @_; 2920 my ($self, $ev, $x, $y) = @_;
2887 2921
2889 undef $GRAB; 2923 undef $GRAB;
2890 $self->hide; 2924 $self->hide;
2891 2925
2892 $self->_emit ("popdown"); 2926 $self->_emit ("popdown");
2893 $self->{hover}[1]->() if $self->{hover}; 2927 $self->{hover}[1]->() if $self->{hover};
2928 } else {
2929 return 0
2930 }
2931
2894 } 2932 1
2895} 2933}
2896 2934
2897############################################################################# 2935#############################################################################
2898 2936
2899package CFClient::UI::Statusbox; 2937package CFClient::UI::Statusbox;
3004 $self->SUPER::reconfigure; 3042 $self->SUPER::reconfigure;
3005} 3043}
3006 3044
3007############################################################################# 3045#############################################################################
3008 3046
3009package CFClient::UI::Root; 3047package CFClient::UI::Inventory;
3010 3048
3011our @ISA = CFClient::UI::Container::; 3049our @ISA = CFClient::UI::ScrolledWindow::;
3012
3013use CFClient::OpenGL;
3014 3050
3015sub new { 3051sub new {
3016 my $class = shift; 3052 my $class = shift;
3017 3053
3018 my $self = $class->SUPER::new ( 3054 my $self = $class->SUPER::new (
3019 visible => 1, 3055 scrolled => (new CFClient::UI::Table col_expand => [0, 1, 0]),
3020 @_, 3056 @_,
3021 ); 3057 );
3022 3058
3023 Scalar::Util::weaken ($self->{root} = $self);
3024
3025 $self 3059 $self
3026} 3060}
3027 3061
3028sub size_request { 3062sub set_items {
3029 my ($self) = @_; 3063 my ($self, $items) = @_;
3030 3064
3031 ($self->{w}, $self->{h}) 3065 $self->{scrolled}->clear;
3032} 3066 return unless $items;
3033 3067
3034sub _to_pixel { 3068 my @items = sort {
3035 my ($coord, $size, $max) = @_; 3069 ($a->{type} <=> $b->{type})
3070 or ($a->{name} cmp $b->{name})
3071 } @$items;
3036 3072
3037 $coord = 3073 $self->{real_items} = \@items;
3038 $coord eq "center" ? ($max - $size) * 0.5
3039 : $coord eq "max" ? $max
3040 : $coord;
3041 3074
3042 $coord = 0 if $coord < 0; 3075 my $row = 0;
3043 $coord = $max - $size if $coord > $max - $size; 3076 for my $item (@items) {
3077 CFClient::Item::update_widgets $item;
3044 3078
3045 int $coord + 0.5 3079 $self->{scrolled}->add (0, $row, $item->{face_widget});
3046} 3080 $self->{scrolled}->add (1, $row, $item->{desc_widget});
3081 $self->{scrolled}->add (2, $row, $item->{weight_widget});
3047 3082
3048sub size_allocate { 3083 $row++;
3049 my ($self, $w, $h) = @_;
3050
3051 for my $child ($self->children) {
3052 my ($X, $Y, $W, $H) = @$child{qw(x y req_w req_h)};
3053
3054 $X = $child->{force_x} if exists $child->{force_x};
3055 $Y = $child->{force_y} if exists $child->{force_y};
3056
3057 $X = _to_pixel $X, $W, $self->{w};
3058 $Y = _to_pixel $Y, $H, $self->{h};
3059
3060 $child->configure ($X, $Y, $W, $H);
3061 } 3084 }
3062}
3063
3064sub coord2local {
3065 my ($self, $x, $y) = @_;
3066
3067 ($x, $y)
3068}
3069
3070sub coord2global {
3071 my ($self, $x, $y) = @_;
3072
3073 ($x, $y)
3074}
3075
3076sub update {
3077 my ($self) = @_;
3078
3079 $::WANT_REFRESH++;
3080}
3081
3082sub add {
3083 my ($self, @children) = @_;
3084
3085 $_->{is_toplevel} = 1
3086 for @children;
3087
3088 $self->SUPER::add (@children);
3089}
3090
3091sub remove {
3092 my ($self, @children) = @_;
3093
3094 $self->SUPER::remove (@children);
3095
3096 delete $self->{is_toplevel}
3097 for @children;
3098
3099 while (@children) {
3100 my $w = pop @children;
3101 push @children, $w->children;
3102 $w->set_invisible;
3103 }
3104}
3105
3106sub on_refresh {
3107 my ($self, $id, $cb) = @_;
3108
3109 $self->{refresh_hook}{$id} = $cb;
3110}
3111
3112sub on_post_alloc {
3113 my ($self, $id, $cb) = @_;
3114
3115 $self->{post_alloc_hook}{$id} = $cb;
3116}
3117
3118sub draw {
3119 my ($self) = @_;
3120
3121 while ($self->{refresh_hook}) {
3122 $_->()
3123 for values %{delete $self->{refresh_hook}};
3124 }
3125
3126 if ($self->{realloc}) {
3127 my @queue;
3128
3129 while () {
3130 if ($self->{realloc}) {
3131 #TODO use array-of-depth approach
3132
3133 use sort 'stable';
3134
3135 @queue = sort { $a->{visible} <=> $b->{visible} }
3136 @queue, values %{delete $self->{realloc}};
3137 }
3138
3139 my $widget = pop @queue || last;
3140
3141 $widget->{visible} or last; # do not resize invisible widgets
3142
3143 my ($w, $h) = $widget->size_request;
3144
3145 $w = List::Util::max $widget->{min_w}, $w + $widget->{padding_x} * 2;
3146 $h = List::Util::max $widget->{min_h}, $h + $widget->{padding_y} * 2;
3147
3148 $w = $widget->{force_w} if exists $widget->{force_w};
3149 $h = $widget->{force_h} if exists $widget->{force_h};
3150
3151 if ($widget->{req_w} != $w || $widget->{req_h} != $h
3152 || delete $widget->{force_realloc}) {
3153 $widget->{req_w} = $w;
3154 $widget->{req_h} = $h;
3155
3156 $self->{size_alloc}{$widget+0} = $widget;
3157
3158 if (my $parent = $widget->{parent}) {
3159 $self->{realloc}{$parent+0} = $parent;
3160 #unshift @queue, $parent;
3161 $parent->{force_size_alloc} = 1;
3162 $self->{size_alloc}{$parent+0} = $parent;
3163 }
3164 }
3165
3166 delete $self->{realloc}{$widget+0};
3167 }
3168 }
3169
3170 while (my $size_alloc = delete $self->{size_alloc}) {
3171 my @queue = sort { $b->{visible} <=> $a->{visible} }
3172 values %$size_alloc;
3173
3174 while () {
3175 my $widget = pop @queue || last;
3176
3177 my ($w, $h) = @$widget{qw(alloc_w alloc_h)};
3178
3179 $w = 0 if $w < 0;
3180 $h = 0 if $h < 0;
3181
3182 $w = int $w + 0.5;
3183 $h = int $h + 0.5;
3184
3185 if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) {
3186 $widget->{w} = $w;
3187 $widget->{h} = $h;
3188
3189 $widget->emit (size_allocate => $w, $h);
3190 }
3191 }
3192 }
3193
3194 while ($self->{post_alloc_hook}) {
3195 $_->()
3196 for values %{delete $self->{post_alloc_hook}};
3197 }
3198
3199
3200 glViewport 0, 0, $::WIDTH, $::HEIGHT;
3201 glClearColor +($::CFG->{fow_intensity}) x 3, 1;
3202 glClear GL_COLOR_BUFFER_BIT;
3203
3204 glMatrixMode GL_PROJECTION;
3205 glLoadIdentity;
3206 glOrtho 0, $::WIDTH, $::HEIGHT, 0, -10000, 10000;
3207 glMatrixMode GL_MODELVIEW;
3208 glLoadIdentity;
3209
3210 $self->_draw;
3211} 3085}
3212 3086
3213############################################################################# 3087#############################################################################
3214 3088
3215package CFClient::UI::BindEditor; 3089package CFClient::UI::BindEditor;
3221 3095
3222 my $self = $class->SUPER::new (binding => [], commands => [], @_); 3096 my $self = $class->SUPER::new (binding => [], commands => [], @_);
3223 3097
3224 $self->add (my $vb = new CFClient::UI::VBox); 3098 $self->add (my $vb = new CFClient::UI::VBox);
3225 3099
3226 $vb->add (my $hb = new CFClient::UI::HBox);
3227 $hb->add (new CFClient::UI::Label text => "Key: ");
3228 $hb->add ($self->{keylbl} = new CFClient::UI::Label);
3229 $hb->add (new CFClient::UI::Button
3230 text => "bind",
3231 tooltip => "This opens a query where you have to press the key combination to bind the recorded actions",
3232 on_activate => sub {
3233 $self->ask_for_bind;
3234 });
3235 3100
3236 $vb->add (new CFClient::UI::Label text => "Actions:");
3237 $vb->add ($self->{rec_btn} = new CFClient::UI::Button 3101 $vb->add ($self->{rec_btn} = new CFClient::UI::Button
3238 text => "start recording", 3102 text => "start recording",
3239 tooltip => "Start/Stops recording of actions." 3103 tooltip => "Start/Stops recording of actions."
3240 ."All subsequent actions after the recording started will be captured." 3104 ."All subsequent actions after the recording started will be captured."
3241 ."The actions are displayed after the record was stopped." 3105 ."The actions are displayed after the record was stopped."
3246 } else { 3110 } else {
3247 $self->stop; 3111 $self->stop;
3248 } 3112 }
3249 }); 3113 });
3250 3114
3115 $vb->add (new CFClient::UI::Label text => "Actions:");
3251 $vb->add ($self->{cmdbox} = new CFClient::UI::VBox); 3116 $vb->add ($self->{cmdbox} = new CFClient::UI::VBox);
3117
3118 $vb->add (new CFClient::UI::Label text => "Bound to: ");
3119 $vb->add (my $hb = new CFClient::UI::HBox);
3120 $hb->add ($self->{keylbl} = new CFClient::UI::Label expand => 1);
3121 $hb->add (new CFClient::UI::Button
3122 text => "bind",
3123 tooltip => "This opens a query where you have to press the key combination to bind the recorded actions",
3124 on_activate => sub {
3125 $self->ask_for_bind;
3126 });
3252 3127
3253 $vb->add (my $hb = new CFClient::UI::HBox); 3128 $vb->add (my $hb = new CFClient::UI::HBox);
3254 $hb->add (new CFClient::UI::Button 3129 $hb->add (new CFClient::UI::Button
3255 text => "ok", 3130 text => "ok",
3131 expand => 1,
3256 tooltip => "This closes the binding editor and saves the binding", 3132 tooltip => "This closes the binding editor and saves the binding",
3257 on_activate => sub { 3133 on_activate => sub {
3258 $self->hide; 3134 $self->hide;
3259 $self->commit; 3135 $self->commit;
3260 }); 3136 });
3261 3137
3262 $hb->add (new CFClient::UI::Button 3138 $hb->add (new CFClient::UI::Button
3263 text => "cancel", 3139 text => "cancel",
3140 expand => 1,
3264 tooltip => "This closes the binding editor without saving", 3141 tooltip => "This closes the binding editor without saving",
3265 on_activate => sub { 3142 on_activate => sub {
3266 $self->hide; 3143 $self->hide;
3267 $self->{binding_cancel}->() 3144 $self->{binding_cancel}->()
3268 if $self->{binding_cancel}; 3145 if $self->{binding_cancel};
3280 $::STATUSBOX->add ("Bound actions to '".CFClient::Binder::keycombo_to_name ($mod, $sym) 3157 $::STATUSBOX->add ("Bound actions to '".CFClient::Binder::keycombo_to_name ($mod, $sym)
3281 ."'. Don't forget 'Save Config'!"); 3158 ."'. Don't forget 'Save Config'!");
3282 $self->{binding_change}->($mod, $sym, $cmds) 3159 $self->{binding_change}->($mod, $sym, $cmds)
3283 if $self->{binding_change}; 3160 if $self->{binding_change};
3284 } else { 3161 } else {
3285 $::STATUSBOX->add ("No action bound, no keys specified!"); 3162 $::STATUSBOX->add ("No action bound, no key or action specified!");
3286 $self->{binding_cancel}->() 3163 $self->{binding_cancel}->()
3287 if $self->{binding_cancel}; 3164 if $self->{binding_cancel};
3288 } 3165 }
3289} 3166}
3290 3167
3305 3182
3306 my $rec; 3183 my $rec;
3307 $rec = $::CONN->stop_record if $::CONN; 3184 $rec = $::CONN->stop_record if $::CONN;
3308 return unless ref $rec eq 'ARRAY'; 3185 return unless ref $rec eq 'ARRAY';
3309 $self->set_command_list ($rec); 3186 $self->set_command_list ($rec);
3187}
3188
3189
3190sub ask_for_bind_and_commit {
3191 my ($self) = @_;
3192 $self->ask_for_bind (1);
3310} 3193}
3311 3194
3312sub ask_for_bind { 3195sub ask_for_bind {
3313 my ($self, $commit) = @_; 3196 my ($self, $commit) = @_;
3314 3197
3318 $self->update_binding_widgets; 3201 $self->update_binding_widgets;
3319 $self->commit if $commit; 3202 $self->commit if $commit;
3320 }); 3203 });
3321} 3204}
3322 3205
3206# $mod and $sym are the modifiers and key symbol
3207# $cmds is a array ref of strings (the commands)
3208# $cb is the callback that is executed on OK
3209# $ccb is the callback that is executed on CANCEL and
3210# when the binding was unsuccessful on OK
3323sub set_binding { 3211sub set_binding {
3324 my ($self, $mod, $sym, $cmds, $cb, $ccb) = @_; 3212 my ($self, $mod, $sym, $cmds, $cb, $ccb) = @_;
3325 3213
3326 $self->clear_command_list; 3214 $self->clear_command_list;
3327 $self->{recording} = 0; 3215 $self->{recording} = 0;
3332 3220
3333 $self->{binding_change} = $cb; 3221 $self->{binding_change} = $cb;
3334 $self->{binding_cancel} = $ccb; 3222 $self->{binding_cancel} = $ccb;
3335 3223
3336 $self->update_binding_widgets; 3224 $self->update_binding_widgets;
3225}
3226
3227# this is a shortcut method that asks for a binding
3228# and then just binds it.
3229sub do_quick_binding {
3230 my ($self, $cmds) = @_;
3231 $self->set_binding (undef, undef, $cmds, sub {
3232 $::CFG->{bindings}->{$_[0]}->{$_[1]} = $_[2];
3233 });
3234 $self->ask_for_bind (1);
3337} 3235}
3338 3236
3339sub update_binding_widgets { 3237sub update_binding_widgets {
3340 my ($self) = @_; 3238 my ($self) = @_;
3341 my ($mod, $sym, $cmds) = $self->get_binding; 3239 my ($mod, $sym, $cmds) = $self->get_binding;
3367 3265
3368 for (@$cmds) { 3266 for (@$cmds) {
3369 $self->{cmdbox}->add (my $hb = new CFClient::UI::HBox); 3267 $self->{cmdbox}->add (my $hb = new CFClient::UI::HBox);
3370 3268
3371 my $i = $idx; 3269 my $i = $idx;
3270 $hb->add (new CFClient::UI::Label text => $_);
3372 $hb->add (new CFClient::UI::Button 3271 $hb->add (new CFClient::UI::Button
3373 text => "delete", 3272 text => "delete",
3374 tooltip => "Deletes the action from the record", 3273 tooltip => "Deletes the action from the record",
3375 on_activate => sub { 3274 on_activate => sub {
3376 $self->{cmdbox}->remove ($hb); 3275 $self->{cmdbox}->remove ($hb);
3377 $cmds->[$i] = undef; 3276 $cmds->[$i] = undef;
3378 }); 3277 });
3379 3278
3380 $hb->add (new CFClient::UI::Label text => $_);
3381 3279
3382 $idx++ 3280 $idx++
3383 } 3281 }
3384} 3282}
3385 3283
3284#############################################################################
3285
3286package CFClient::UI::SpellList;
3287
3288our @ISA = CFClient::UI::FancyFrame::;
3289
3290sub new {
3291 my $class = shift;
3292
3293 my $self = $class->SUPER::new (binding => [], commands => [], @_);
3294
3295 $self->add (new CFClient::UI::ScrolledWindow
3296 scrolled => $self->{spellbox} = new CFClient::UI::Table);
3297
3298 $self;
3299}
3300
3301# XXX: Do sorting? Argl...
3302sub add_spell {
3303 my ($self, $spell) = @_;
3304 $self->{spells}->{$spell->{name}} = $spell;
3305
3306 $self->{spellbox}->add (0, $self->{tbl_idx}, new CFClient::UI::Face
3307 face => $spell->{face},
3308 can_hover => 1,
3309 can_events => 1,
3310 tooltip => $spell->{message});
3311
3312 $self->{spellbox}->add (1, $self->{tbl_idx}, new CFClient::UI::Label
3313 text => $spell->{name},
3314 can_hover => 1,
3315 can_events => 1,
3316 tooltip => $spell->{message},
3317 expand => 1);
3318
3319 $self->{spellbox}->add (2, $self->{tbl_idx}, new CFClient::UI::Label
3320 text => (sprintf "lvl: %2d sp: %2d dmg: %2d",
3321 $spell->{level}, ($spell->{mana} || $spell->{grace}), $spell->{damage}),
3322 expand => 1);
3323
3324 $self->{spellbox}->add (3, $self->{tbl_idx}++, new CFClient::UI::Button
3325 text => "bind to key",
3326 on_activate => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) });
3327}
3328
3329sub rebuild_spell_list {
3330 my ($self) = @_;
3331 $self->{tbl_idx} = 0;
3332 $self->add_spell ($_) for values %{$self->{spells}};
3333}
3334
3335sub remove_spell {
3336 my ($self, $spell) = @_;
3337 delete $self->{spells}->{$spell->{name}};
3338 $self->rebuild_spell_list;
3339}
3340
3341#############################################################################
3342
3343package CFClient::UI::Root;
3344
3345our @ISA = CFClient::UI::Container::;
3346
3347use CFClient::OpenGL;
3348
3349sub new {
3350 my $class = shift;
3351
3352 my $self = $class->SUPER::new (
3353 visible => 1,
3354 @_,
3355 );
3356
3357 Scalar::Util::weaken ($self->{root} = $self);
3358
3359 $self
3360}
3361
3362sub size_request {
3363 my ($self) = @_;
3364
3365 ($self->{w}, $self->{h})
3366}
3367
3368sub _to_pixel {
3369 my ($coord, $size, $max) = @_;
3370
3371 $coord =
3372 $coord eq "center" ? ($max - $size) * 0.5
3373 : $coord eq "max" ? $max
3374 : $coord;
3375
3376 $coord = 0 if $coord < 0;
3377 $coord = $max - $size if $coord > $max - $size;
3378
3379 int $coord + 0.5
3380}
3381
3382sub size_allocate {
3383 my ($self, $w, $h) = @_;
3384
3385 for my $child ($self->children) {
3386 my ($X, $Y, $W, $H) = @$child{qw(x y req_w req_h)};
3387
3388 $X = $child->{force_x} if exists $child->{force_x};
3389 $Y = $child->{force_y} if exists $child->{force_y};
3390
3391 $X = _to_pixel $X, $W, $self->{w};
3392 $Y = _to_pixel $Y, $H, $self->{h};
3393
3394 $child->configure ($X, $Y, $W, $H);
3395 }
3396}
3397
3398sub coord2local {
3399 my ($self, $x, $y) = @_;
3400
3401 ($x, $y)
3402}
3403
3404sub coord2global {
3405 my ($self, $x, $y) = @_;
3406
3407 ($x, $y)
3408}
3409
3410sub update {
3411 my ($self) = @_;
3412
3413 $::WANT_REFRESH++;
3414}
3415
3416sub add {
3417 my ($self, @children) = @_;
3418
3419 $_->{is_toplevel} = 1
3420 for @children;
3421
3422 $self->SUPER::add (@children);
3423}
3424
3425sub remove {
3426 my ($self, @children) = @_;
3427
3428 $self->SUPER::remove (@children);
3429
3430 delete $self->{is_toplevel}
3431 for @children;
3432
3433 while (@children) {
3434 my $w = pop @children;
3435 push @children, $w->children;
3436 $w->set_invisible;
3437 }
3438}
3439
3440sub on_refresh {
3441 my ($self, $id, $cb) = @_;
3442
3443 $self->{refresh_hook}{$id} = $cb;
3444}
3445
3446sub on_post_alloc {
3447 my ($self, $id, $cb) = @_;
3448
3449 $self->{post_alloc_hook}{$id} = $cb;
3450}
3451
3452sub draw {
3453 my ($self) = @_;
3454
3455 while ($self->{refresh_hook}) {
3456 $_->()
3457 for values %{delete $self->{refresh_hook}};
3458 }
3459
3460 if ($self->{realloc}) {
3461 my %queue;
3462 my @queue;
3463 my $widget;
3464
3465 outer:
3466 while () {
3467 if (my $realloc = delete $self->{realloc}) {
3468 for $widget (values %$realloc) {
3469 $widget->{visible} or next; # do not resize invisible widgets
3470
3471 $queue{$widget+0}++ and next; # duplicates are common
3472
3473 push @{ $queue[$widget->{visible}] }, $widget;
3474 }
3475 }
3476
3477 while () {
3478 @queue or last outer;
3479
3480 $widget = pop @{ $queue[-1] || [] }
3481 and last;
3482
3483 pop @queue;
3484 }
3485
3486 delete $queue{$widget+0};
3487
3488 my ($w, $h) = $widget->size_request;
3489
3490 $w = List::Util::max $widget->{min_w}, $w + $widget->{padding_x} * 2;
3491 $h = List::Util::max $widget->{min_h}, $h + $widget->{padding_y} * 2;
3492
3493 $w = $widget->{force_w} if exists $widget->{force_w};
3494 $h = $widget->{force_h} if exists $widget->{force_h};
3495
3496 if ($widget->{req_w} != $w || $widget->{req_h} != $h
3497 || delete $widget->{force_realloc}) {
3498 $widget->{req_w} = $w;
3499 $widget->{req_h} = $h;
3500
3501 $self->{size_alloc}{$widget+0} = $widget;
3502
3503 if (my $parent = $widget->{parent}) {
3504 $self->{realloc}{$parent+0} = $parent
3505 unless $queue{$parent+0};
3506
3507 $parent->{force_size_alloc} = 1;
3508 $self->{size_alloc}{$parent+0} = $parent;
3509 }
3510 }
3511
3512 delete $self->{realloc}{$widget+0};
3513 }
3514 }
3515
3516 while (my $size_alloc = delete $self->{size_alloc}) {
3517 my @queue = sort { $b->{visible} <=> $a->{visible} }
3518 values %$size_alloc;
3519
3520 while () {
3521 my $widget = pop @queue || last;
3522
3523 my ($w, $h) = @$widget{qw(alloc_w alloc_h)};
3524
3525 $w = 0 if $w < 0;
3526 $h = 0 if $h < 0;
3527
3528 $w = int $w + 0.5;
3529 $h = int $h + 0.5;
3530
3531 if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) {
3532 $widget->{old_w} = $widget->{w};
3533 $widget->{old_h} = $widget->{h};
3534
3535 $widget->{w} = $w;
3536 $widget->{h} = $h;
3537
3538 $widget->emit (size_allocate => $w, $h);
3539 }
3540 }
3541 }
3542
3543 while ($self->{post_alloc_hook}) {
3544 $_->()
3545 for values %{delete $self->{post_alloc_hook}};
3546 }
3547
3548
3549 glViewport 0, 0, $::WIDTH, $::HEIGHT;
3550 glClearColor +($::CFG->{fow_intensity}) x 3, 1;
3551 glClear GL_COLOR_BUFFER_BIT;
3552
3553 glMatrixMode GL_PROJECTION;
3554 glLoadIdentity;
3555 glOrtho 0, $::WIDTH, $::HEIGHT, 0, -10000, 10000;
3556 glMatrixMode GL_MODELVIEW;
3557 glLoadIdentity;
3558
3559 {
3560 package CFClient::UI::Base;
3561
3562 ($draw_x, $draw_y, $draw_w, $draw_h) =
3563 (0, 0, $self->{w}, $self->{h});
3564 }
3565
3566 $self->_draw;
3567}
3386 3568
3387############################################################################# 3569#############################################################################
3388 3570
3389package CFClient::UI; 3571package CFClient::UI;
3390 3572

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines