… | |
… | |
7 | |
7 | |
8 | use CFClient; |
8 | use CFClient; |
9 | |
9 | |
10 | our ($FOCUS, $HOVER, $GRAB); # various widgets |
10 | our ($FOCUS, $HOVER, $GRAB); # various widgets |
11 | |
11 | |
12 | our $TOPLEVEL; |
12 | our $ROOT; |
13 | our $BUTTON_STATE; |
13 | our $BUTTON_STATE; |
14 | |
14 | |
15 | # class methods for events |
15 | # class methods for events |
16 | sub feed_sdl_key_down_event { |
16 | sub feed_sdl_key_down_event { |
17 | $FOCUS->key_down ($_[0]) if $FOCUS; |
17 | $FOCUS->key_down ($_[0]) if $FOCUS; |
… | |
… | |
21 | $FOCUS->key_up ($_[0]) if $FOCUS; |
21 | $FOCUS->key_up ($_[0]) if $FOCUS; |
22 | } |
22 | } |
23 | |
23 | |
24 | sub feed_sdl_button_down_event { |
24 | sub feed_sdl_button_down_event { |
25 | my ($ev) = @_; |
25 | my ($ev) = @_; |
26 | my ($x, $y) = ($ev->motion_x, $ev->motion_y); |
26 | my ($x, $y) = ($ev->{x}, $ev->{y}); |
27 | |
27 | |
28 | if (!$BUTTON_STATE) { |
28 | if (!$BUTTON_STATE) { |
29 | my $widget = $TOPLEVEL->find_widget ($x, $y); |
29 | my $widget = $ROOT->find_widget ($x, $y); |
30 | |
30 | |
31 | $GRAB = $widget; |
31 | $GRAB = $widget; |
32 | $GRAB->update if $GRAB; |
32 | $GRAB->update if $GRAB; |
33 | } |
33 | } |
34 | |
34 | |
35 | $BUTTON_STATE |= 1 << ($ev->button - 1); |
35 | $BUTTON_STATE |= 1 << ($ev->{button} - 1); |
36 | |
36 | |
37 | $GRAB->button_down ($ev, $GRAB->translate ($x, $y)) if $GRAB; |
37 | $GRAB->button_down ($ev, $GRAB->coord2local ($x, $y)) if $GRAB; |
38 | } |
38 | } |
39 | |
39 | |
40 | sub feed_sdl_button_up_event { |
40 | sub feed_sdl_button_up_event { |
41 | my ($ev) = @_; |
41 | my ($ev) = @_; |
42 | my ($x, $y) = ($ev->motion_x, $ev->motion_y); |
42 | my ($x, $y) = ($ev->{x}, $ev->{y}); |
43 | |
43 | |
44 | my $widget = $GRAB || $TOPLEVEL->find_widget ($x, $y); |
44 | my $widget = $GRAB || $ROOT->find_widget ($x, $y); |
45 | |
45 | |
46 | $BUTTON_STATE &= ~(1 << ($ev->button - 1)); |
46 | $BUTTON_STATE &= ~(1 << ($ev->{button} - 1)); |
47 | |
47 | |
48 | $GRAB->button_up ($ev, $GRAB->translate ($x, $y)) if $GRAB; |
48 | $GRAB->button_up ($ev, $GRAB->coord2local ($x, $y)) if $GRAB; |
49 | |
49 | |
50 | if (!$BUTTON_STATE) { |
50 | if (!$BUTTON_STATE) { |
51 | my $grab = $GRAB; undef $GRAB; |
51 | my $grab = $GRAB; undef $GRAB; |
52 | $grab->update if $grab; |
52 | $grab->update if $grab; |
53 | $GRAB->update if $GRAB; |
53 | $GRAB->update if $GRAB; |
54 | } |
54 | } |
55 | } |
55 | } |
56 | |
56 | |
57 | sub feed_sdl_motion_event { |
57 | sub feed_sdl_motion_event { |
58 | my ($ev) = @_; |
58 | my ($ev) = @_; |
59 | my ($x, $y) = ($ev->motion_x, $ev->motion_y); |
59 | my ($x, $y) = ($ev->{x}, $ev->{y}); |
60 | |
60 | |
61 | my $widget = $GRAB || $TOPLEVEL->find_widget ($x, $y); |
61 | my $widget = $GRAB || $ROOT->find_widget ($x, $y); |
62 | |
62 | |
63 | if ($widget != $HOVER) { |
63 | if ($widget != $HOVER) { |
64 | my $hover = $HOVER; $HOVER = $widget; |
64 | my $hover = $HOVER; $HOVER = $widget; |
65 | |
65 | |
66 | $hover->update if $hover && $hover->{can_hover}; |
66 | $hover->update if $hover && $hover->{can_hover}; |
67 | $HOVER->update if $HOVER && $HOVER->{can_hover}; |
67 | $HOVER->update if $HOVER && $HOVER->{can_hover}; |
68 | } |
68 | } |
69 | |
69 | |
70 | $HOVER->mouse_motion ($ev, $HOVER->translate ($x, $y)) if $HOVER; |
70 | $HOVER->mouse_motion ($ev, $HOVER->coord2local ($x, $y)) if $HOVER; |
71 | } |
71 | } |
72 | |
72 | |
73 | # convert position array to integers |
73 | # convert position array to integers |
74 | sub harmonize { |
74 | sub harmonize { |
75 | my ($vals) = @_; |
75 | my ($vals) = @_; |
76 | |
76 | |
77 | my $rem = 0; |
77 | my $rem = 0; |
78 | |
78 | |
79 | for ($vals) { |
79 | for (@$vals) { |
80 | my $i = int $_ + $rem; |
80 | my $i = int $_ + $rem; |
81 | $rem += $_ - $i; |
81 | $rem += $_ - $i; |
82 | $_ = $i; |
82 | $_ = $i; |
83 | } |
83 | } |
84 | } |
84 | } |
… | |
… | |
87 | |
87 | |
88 | package CFClient::UI::Base; |
88 | package CFClient::UI::Base; |
89 | |
89 | |
90 | use strict; |
90 | use strict; |
91 | |
91 | |
92 | use SDL::OpenGL; |
92 | use CFClient::OpenGL; |
93 | |
93 | |
94 | sub new { |
94 | sub new { |
95 | my $class = shift; |
95 | my $class = shift; |
96 | |
96 | |
97 | my $self = bless { |
97 | my $self = bless { |
98 | x => 0, |
98 | x => 0, |
99 | y => 0, |
99 | y => 0, |
100 | z => 0, |
100 | z => 0, |
101 | w => -1, |
|
|
102 | h => -1, |
|
|
103 | @_ |
101 | @_ |
104 | }, $class; |
102 | }, $class; |
105 | |
103 | |
106 | for (keys %$self) { |
104 | for (keys %$self) { |
107 | if (/^connect_(.*)$/) { |
105 | if (/^connect_(.*)$/) { |
… | |
… | |
110 | } |
108 | } |
111 | |
109 | |
112 | $self |
110 | $self |
113 | } |
111 | } |
114 | |
112 | |
|
|
113 | sub show { |
|
|
114 | my ($self) = @_; |
|
|
115 | |
|
|
116 | return if $self->{parent}; |
|
|
117 | |
|
|
118 | $CFClient::UI::ROOT->add ($self); |
|
|
119 | } |
|
|
120 | |
|
|
121 | sub hide { |
|
|
122 | my ($self) = @_; |
|
|
123 | |
|
|
124 | return unless $self->{parent}; |
|
|
125 | |
|
|
126 | $self->{parent}->remove ($self); |
|
|
127 | } |
|
|
128 | |
115 | sub move { |
129 | sub move { |
116 | my ($self, $x, $y, $z) = @_; |
130 | my ($self, $x, $y, $z) = @_; |
|
|
131 | |
117 | $self->{x} = $x; |
132 | $self->{x} = int $x; |
118 | $self->{y} = $y; |
133 | $self->{y} = int $y; |
119 | $self->{z} = $z if defined $z; |
134 | $self->{z} = $z if defined $z; |
|
|
135 | |
|
|
136 | $self->update; |
120 | } |
137 | } |
121 | |
138 | |
122 | sub needs_redraw { |
139 | sub needs_redraw { |
123 | 0 |
140 | 0 |
124 | } |
141 | } |
… | |
… | |
126 | sub size_request { |
143 | sub size_request { |
127 | require Carp; |
144 | require Carp; |
128 | Carp::confess "size_request is abtract"; |
145 | Carp::confess "size_request is abtract"; |
129 | } |
146 | } |
130 | |
147 | |
131 | sub _size_allocate { |
148 | sub configure { |
132 | my ($self, $x, $y, $w, $h) = @_; |
149 | my ($self, $x, $y, $w, $h) = @_; |
133 | |
150 | |
|
|
151 | if ($self->{aspect}) { |
|
|
152 | my $w2 = List::Util::min $w, int $h * $self->{aspect}; |
|
|
153 | my $h2 = List::Util::min $h, int $w / $self->{aspect}; |
|
|
154 | |
|
|
155 | # use alignment to adjust x, y |
|
|
156 | |
|
|
157 | $x += ($w - $w2) * 0.5; |
|
|
158 | $y += ($h - $h2) * 0.5; |
|
|
159 | |
|
|
160 | ($w, $h) = ($w2, $h2); |
|
|
161 | } |
|
|
162 | |
|
|
163 | if ($self->{x} != $x || $self->{y} != $y) { |
134 | $self->{x} = $x; |
164 | $self->{x} = $x; |
135 | $self->{y} = $y; |
165 | $self->{y} = $y; |
|
|
166 | $self->update; |
|
|
167 | } |
136 | |
168 | |
137 | return unless $self->{w} != $w || $self->{h} != $h; |
169 | if ($self->{w} != $w || $self->{h} != $h) { |
138 | |
|
|
139 | $self->{w} = $w; |
170 | $self->{w} = $w; |
140 | $self->{h} = $h; |
171 | $self->{h} = $h; |
141 | |
172 | |
|
|
173 | $self->size_allocate ($w, $h); |
|
|
174 | $self->update; |
142 | 1 |
175 | } |
143 | } |
176 | } |
144 | |
177 | |
145 | sub size_allocate { |
178 | sub size_allocate { |
|
|
179 | # nothing to be done |
|
|
180 | } |
|
|
181 | |
|
|
182 | # return top left coordinates |
|
|
183 | sub _topleft { |
146 | my ($self, $x, $y, $w, $h) = @_; |
184 | my ($self, $x, $y) = @_; |
147 | |
185 | |
148 | $self->_size_allocate ($x, $y, $w, $h); |
186 | $self->{parent}->_topleft ($x + $self->{x}, $y + $self->{y}); |
149 | } |
187 | } |
150 | |
188 | |
151 | # translate global coordinates to local coordinate system |
189 | # translate global coordinates to local coordinate system |
152 | sub translate { |
190 | sub coord2local { |
153 | my ($self, $x, $y) = @_; |
191 | my ($self, $x, $y) = @_; |
154 | |
192 | |
155 | $self->{parent}->translate ($x - $self->{x}, $y - $self->{y}); |
193 | my ($X, $Y) = $self->_topleft; |
|
|
194 | ($x - $X, $y - $Y) |
|
|
195 | } |
|
|
196 | |
|
|
197 | # translate local coordinates to global coordinate system |
|
|
198 | sub coord2global { |
|
|
199 | my ($self, $x, $y) = @_; |
|
|
200 | |
|
|
201 | my ($X, $Y) = $self->_topleft; |
|
|
202 | ($x + $X, $y + $Y) |
156 | } |
203 | } |
157 | |
204 | |
158 | sub focus_in { |
205 | sub focus_in { |
159 | my ($self) = @_; |
206 | my ($self) = @_; |
160 | |
207 | |
161 | return if $FOCUS == $self; |
208 | return if $FOCUS == $self; |
162 | return unless $self->{can_focus}; |
209 | return unless $self->{can_focus}; |
163 | |
210 | |
164 | my $focus = $FOCUS; $FOCUS = $self; |
211 | my $focus = $FOCUS; $FOCUS = $self; |
|
|
212 | |
|
|
213 | $self->emit (focus_in => $focus); |
|
|
214 | |
165 | $focus->update if $focus; |
215 | $focus->update if $focus; |
166 | $FOCUS->update; |
216 | $FOCUS->update; |
167 | } |
217 | } |
168 | |
218 | |
169 | sub focus_out { |
219 | sub focus_out { |
170 | my ($self) = @_; |
220 | my ($self) = @_; |
171 | |
221 | |
172 | return unless $FOCUS == $self; |
222 | return unless $FOCUS == $self; |
173 | |
223 | |
174 | my $focus = $FOCUS; undef $FOCUS; |
224 | my $focus = $FOCUS; undef $FOCUS; |
|
|
225 | |
|
|
226 | $self->emit (focus_out => $focus); |
|
|
227 | |
175 | $focus->update if $focus; #? |
228 | $focus->update if $focus; #? |
176 | } |
229 | } |
177 | |
230 | |
178 | sub mouse_motion { } |
231 | sub mouse_motion { } |
179 | sub button_up { } |
232 | sub button_up { } |
… | |
… | |
203 | glPopMatrix; |
256 | glPopMatrix; |
204 | |
257 | |
205 | if ($self == $HOVER && $self->{can_hover}) { |
258 | if ($self == $HOVER && $self->{can_hover}) { |
206 | my ($x, $y) = @$self{qw(x y)}; |
259 | my ($x, $y) = @$self{qw(x y)}; |
207 | |
260 | |
208 | glColor 0, 0, 1, 0.2; |
261 | glColor 1, 0.8, 0.5, 0.2; |
209 | glEnable GL_BLEND; |
262 | glEnable GL_BLEND; |
210 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
263 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
211 | glBegin GL_QUADS; |
264 | glBegin GL_QUADS; |
212 | glVertex $x , $y; |
265 | glVertex $x , $y; |
213 | glVertex $x + $self->{w}, $y; |
266 | glVertex $x + $self->{w}, $y; |
… | |
… | |
233 | |
286 | |
234 | () |
287 | () |
235 | } |
288 | } |
236 | |
289 | |
237 | sub set_parent { |
290 | sub set_parent { |
238 | my ($self, $par) = @_; |
291 | my ($self, $parent) = @_; |
239 | |
292 | |
240 | $self->{parent} = $par; |
|
|
241 | Scalar::Util::weaken $self->{parent}; |
293 | Scalar::Util::weaken ($self->{parent} = $parent); |
242 | } |
294 | } |
243 | |
295 | |
244 | sub get_parent { |
296 | sub check_size { |
245 | $_[0]->{parent} |
297 | my ($self) = @_; |
|
|
298 | |
|
|
299 | my ($w, $h) = $self->size_request; |
|
|
300 | |
|
|
301 | if ($w != $self->{req_w} || $h != $self->{req_h}) { |
|
|
302 | $self->{req_w} = $w; |
|
|
303 | $self->{req_h} = $h; |
|
|
304 | |
|
|
305 | $self->{parent}->check_size |
|
|
306 | if $self->{parent}; |
|
|
307 | } |
246 | } |
308 | } |
247 | |
309 | |
248 | sub update { |
310 | sub update { |
249 | my ($self) = @_; |
311 | my ($self) = @_; |
250 | |
312 | |
… | |
… | |
253 | } |
315 | } |
254 | |
316 | |
255 | sub connect { |
317 | sub connect { |
256 | my ($self, $signal, $cb) = @_; |
318 | my ($self, $signal, $cb) = @_; |
257 | |
319 | |
258 | push @{ $self->{cb}{$signal} }, $cb; |
320 | push @{ $self->{signal_cb}{$signal} }, $cb; |
259 | } |
321 | } |
260 | |
322 | |
261 | sub emit { |
323 | sub emit { |
262 | my ($self, $signal, @args) = @_; |
324 | my ($self, $signal, @args) = @_; |
263 | |
325 | |
|
|
326 | for my $cb (@{$self->{signal_cb}{$signal} || []}) { |
264 | $_->($self, @args) |
327 | $cb->($self, @args); |
265 | for @{$self->{cb}{$signal} || []}; |
328 | } |
266 | } |
329 | } |
267 | |
330 | |
268 | sub DESTROY { |
331 | sub DESTROY { |
269 | my ($self) = @_; |
332 | my ($self) = @_; |
270 | |
333 | |
… | |
… | |
276 | package CFClient::UI::DrawBG; |
339 | package CFClient::UI::DrawBG; |
277 | |
340 | |
278 | our @ISA = CFClient::UI::Base::; |
341 | our @ISA = CFClient::UI::Base::; |
279 | |
342 | |
280 | use strict; |
343 | use strict; |
281 | use SDL::OpenGL; |
344 | use CFClient::OpenGL; |
282 | |
345 | |
283 | sub new { |
346 | sub new { |
284 | my $class = shift; |
347 | my $class = shift; |
285 | |
348 | |
286 | # range [value, low, high, page] |
349 | # range [value, low, high, page] |
… | |
… | |
339 | |
402 | |
340 | $self |
403 | $self |
341 | } |
404 | } |
342 | |
405 | |
343 | sub add { |
406 | sub add { |
344 | my ($self, $chld) = @_; |
407 | my ($self, $child) = @_; |
345 | |
408 | |
346 | $chld->set_parent ($self); |
409 | $child->set_parent ($self); |
|
|
410 | |
|
|
411 | use sort 'stable'; |
347 | |
412 | |
348 | $self->{children} = [ |
413 | $self->{children} = [ |
349 | sort { $a->{z} <=> $b->{z} } |
414 | sort { $a->{z} <=> $b->{z} } |
350 | @{$self->{children}}, $chld |
415 | @{$self->{children}}, $child |
351 | ]; |
416 | ]; |
352 | |
417 | |
353 | $self->{w} = $self->{h} = -1; |
418 | $child->check_size; |
354 | $self->update; |
|
|
355 | } |
419 | } |
356 | |
420 | |
357 | sub remove { |
421 | sub remove { |
358 | my ($self, $widget) = @_; |
422 | my ($self, $child) = @_; |
359 | |
423 | |
|
|
424 | delete $child->{parent}; |
|
|
425 | |
360 | $self->{children} = [ grep $_ != $widget, @{ $self->{children} } ]; |
426 | $self->{children} = [ grep $_ != $child, @{ $self->{children} } ]; |
361 | |
427 | |
362 | $self->size_allocate (0, 0, $self->{w}, $self->{h}); |
428 | $self->check_size; |
363 | } |
429 | } |
364 | |
430 | |
365 | sub find_widget { |
431 | sub find_widget { |
366 | my ($self, $x, $y) = @_; |
432 | my ($self, $x, $y) = @_; |
367 | |
433 | |
… | |
… | |
397 | |
463 | |
398 | $class->SUPER::new (children => [$child], %arg) |
464 | $class->SUPER::new (children => [$child], %arg) |
399 | } |
465 | } |
400 | |
466 | |
401 | sub add { |
467 | sub add { |
402 | my ($self, $widget) = @_; |
468 | my ($self, $child) = @_; |
403 | |
469 | |
404 | $self->{children} = []; |
470 | $self->{children} = []; |
405 | |
471 | |
406 | $self->SUPER::add ($widget); |
472 | $self->SUPER::add ($child); |
407 | } |
473 | } |
408 | |
474 | |
409 | sub remove { |
475 | sub remove { |
410 | my ($self, $widget) = @_; |
476 | my ($self, $widget) = @_; |
411 | |
477 | |
… | |
… | |
420 | sub size_request { |
486 | sub size_request { |
421 | $_[0]{children}[0]->size_request |
487 | $_[0]{children}[0]->size_request |
422 | } |
488 | } |
423 | |
489 | |
424 | sub size_allocate { |
490 | sub size_allocate { |
425 | my ($self, $x, $y, $w, $h) = @_; |
491 | my ($self, $w, $h) = @_; |
426 | |
492 | |
427 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
428 | |
|
|
429 | $self->{children}[0]->size_allocate (0, 0, $w, $h); |
493 | $self->{children}[0]->configure (0, 0, $w, $h); |
430 | } |
494 | } |
431 | |
495 | |
432 | ############################################################################# |
496 | ############################################################################# |
433 | |
497 | |
434 | package CFClient::UI::Window; |
498 | package CFClient::UI::Window; |
435 | |
499 | |
436 | our @ISA = CFClient::UI::Bin::; |
500 | our @ISA = CFClient::UI::Bin::; |
437 | |
501 | |
438 | use SDL::OpenGL; |
502 | use CFClient::OpenGL; |
439 | |
503 | |
440 | sub new { |
504 | sub new { |
441 | my ($class, %arg) = @_; |
505 | my ($class, %arg) = @_; |
442 | |
506 | |
443 | my $self = $class->SUPER::new (%arg); |
507 | my $self = $class->SUPER::new (%arg); |
… | |
… | |
460 | $self->child->draw; |
524 | $self->child->draw; |
461 | }; |
525 | }; |
462 | } |
526 | } |
463 | |
527 | |
464 | sub size_allocate { |
528 | sub size_allocate { |
465 | my ($self, $x, $y, $w, $h) = @_; |
529 | my ($self, $w, $h) = @_; |
466 | |
530 | |
467 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
468 | |
|
|
469 | $self->child->size_allocate (0, 0, $w, $h); |
531 | $self->child->configure (0, 0, $w, $h); |
470 | |
532 | |
471 | $self->render_chld; |
533 | $self->render_chld; |
472 | } |
534 | } |
473 | |
535 | |
474 | sub _draw { |
536 | sub _draw { |
… | |
… | |
490 | glDisable GL_TEXTURE_2D; |
552 | glDisable GL_TEXTURE_2D; |
491 | } |
553 | } |
492 | |
554 | |
493 | ############################################################################# |
555 | ############################################################################# |
494 | |
556 | |
|
|
557 | package CFClient::UI::ViewPort; |
|
|
558 | |
|
|
559 | our @ISA = CFClient::UI::Window::; |
|
|
560 | |
|
|
561 | sub new { die } |
|
|
562 | |
|
|
563 | sub size_request { |
|
|
564 | my ($self) = @_; |
|
|
565 | |
|
|
566 | @$self{qw(child_w child_h)} = $self->child->size_request; |
|
|
567 | $self->child->size_allocate (0, 0, @$self{qw(child_w child_h)}); |
|
|
568 | |
|
|
569 | @$self{qw(child_w child_h)} |
|
|
570 | } |
|
|
571 | |
|
|
572 | sub _draw { |
|
|
573 | my ($self) = @_; |
|
|
574 | |
|
|
575 | $self->{children}[1]->draw; |
|
|
576 | } |
|
|
577 | |
|
|
578 | |
|
|
579 | ############################################################################# |
|
|
580 | |
495 | package CFClient::UI::Frame; |
581 | package CFClient::UI::Frame; |
496 | |
582 | |
497 | our @ISA = CFClient::UI::Bin::; |
583 | our @ISA = CFClient::UI::Bin::; |
498 | |
584 | |
499 | use SDL::OpenGL; |
585 | use CFClient::OpenGL; |
500 | |
586 | |
501 | sub size_request { |
587 | sub size_request { |
502 | my ($self) = @_; |
588 | my ($self) = @_; |
503 | my $chld = $self->child |
589 | my $chld = $self->child |
504 | or return (0, 0); |
590 | or return (0, 0); |
… | |
… | |
509 | } |
595 | } |
510 | |
596 | |
511 | sub size_allocate { |
597 | sub size_allocate { |
512 | my ($self, $x, $y, $w, $h) = @_; |
598 | my ($self, $x, $y, $w, $h) = @_; |
513 | |
599 | |
514 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
515 | |
|
|
516 | $self->child->size_allocate (2, 2, $w - 4, $h - 4); |
600 | $self->child->configure (2, 2, $w - 4, $h - 4); |
517 | } |
601 | } |
518 | |
602 | |
519 | sub _draw { |
603 | sub _draw { |
520 | my ($self) = @_; |
604 | my ($self) = @_; |
521 | |
605 | |
… | |
… | |
538 | |
622 | |
539 | package CFClient::UI::FancyFrame; |
623 | package CFClient::UI::FancyFrame; |
540 | |
624 | |
541 | our @ISA = CFClient::UI::Bin::; |
625 | our @ISA = CFClient::UI::Bin::; |
542 | |
626 | |
543 | use SDL::OpenGL; |
627 | use CFClient::OpenGL; |
544 | |
628 | |
545 | my @tex = |
629 | my @tex = |
546 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
630 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
547 | qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
631 | qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
548 | |
632 | |
549 | sub new { |
633 | sub new { |
550 | my $class = shift; |
634 | my $class = shift; |
551 | |
635 | |
552 | # TODO: user_x, user_y, overwrite moveto? |
636 | # TODO: user_x, user_y, overwrite moveto? |
553 | |
637 | |
554 | $class->SUPER::new ( |
638 | my $self = $class->SUPER::new ( |
555 | bg => [1, 1, 1, 1], |
639 | bg => [1, 1, 1, 1], |
556 | border_bg => [1, 1, 1, 1], |
640 | border_bg => [1, 1, 1, 1], |
557 | border => $::FONTSIZE * 0.8, |
641 | border => 0.8, |
558 | @_ |
642 | @_ |
|
|
643 | ); |
|
|
644 | |
|
|
645 | $self->{title} &&= new CFClient::UI::Label |
|
|
646 | align => 0, |
|
|
647 | valign => 1, |
|
|
648 | text => $self->{title}, |
|
|
649 | fontsize => 1; |
|
|
650 | |
|
|
651 | $self |
|
|
652 | } |
|
|
653 | |
|
|
654 | sub border { |
|
|
655 | int $_[0]{border} * $::FONTSIZE |
|
|
656 | } |
|
|
657 | |
|
|
658 | sub size_request { |
|
|
659 | my ($self) = @_; |
|
|
660 | |
|
|
661 | return ($self->{user_w}, $self->{user_h}) if $self->{user_w} && $self->{user_h}; |
|
|
662 | |
|
|
663 | my ($w, $h) = $self->SUPER::size_request; |
|
|
664 | |
|
|
665 | ( |
|
|
666 | $w + $self->border * 2, |
|
|
667 | $h + $self->border * 2, |
559 | ) |
668 | ) |
560 | } |
669 | } |
561 | |
670 | |
562 | sub size_request { |
|
|
563 | my ($self) = @_; |
|
|
564 | |
|
|
565 | return ($self->{user_w}, $self->{user_h}) if $self->{user_w} && $self->{user_h}; |
|
|
566 | |
|
|
567 | my ($w, $h) = $self->SUPER::size_request; |
|
|
568 | |
|
|
569 | ( |
|
|
570 | $w + $self->{border} * 2, |
|
|
571 | $h + $self->{border} * 2, |
|
|
572 | ) |
|
|
573 | } |
|
|
574 | |
|
|
575 | sub size_allocate { |
671 | sub size_allocate { |
576 | my ($self, $x, $y, $w, $h) = @_; |
672 | my ($self, $w, $h) = @_; |
577 | |
673 | |
578 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
579 | |
|
|
580 | $h -= List::Util::max 0, $self->{border} * 2; |
674 | $h -= List::Util::max 0, $self->border * 2; |
581 | $w -= List::Util::max 0, $self->{border} * 2; |
675 | $w -= List::Util::max 0, $self->border * 2; |
582 | |
676 | |
|
|
677 | $self->{title}->configure ($self->border, $self->border - $::FONTSIZE * 2, $w, $::FONTSIZE * 2) |
|
|
678 | if $self->{title}; |
|
|
679 | |
583 | $self->child->size_allocate ($self->{border}, $self->{border}, $w, $h); |
680 | $self->child->configure ($self->border, $self->border, $w, $h); |
584 | } |
681 | } |
585 | |
682 | |
586 | sub button_down { |
683 | sub button_down { |
587 | my ($self, $ev, $x, $y) = @_; |
684 | my ($self, $ev, $x, $y) = @_; |
588 | |
685 | |
|
|
686 | my $border = $self->border; |
|
|
687 | |
589 | if ($x < $self->{w} && $x >= $self->{w} - $self->{border} |
688 | if ($x < $self->{w} && $x >= $self->{w} - $border |
590 | && $y < $self->{h} && $y >= $self->{h} - $self->{border}) { |
689 | && $y < $self->{h} && $y >= $self->{h} - $border) { |
591 | |
690 | |
592 | my ($ox, $oy) = ($ev->button_x, $ev->button_y); |
691 | my ($ox, $oy) = ($ev->{x}, $ev->{y}); |
593 | my ($bw, $bh) = ($self->{w}, $self->{h}); |
692 | my ($bw, $bh) = ($self->{w}, $self->{h}); |
594 | |
693 | |
595 | $self->{motion} = sub { |
694 | $self->{motion} = sub { |
596 | my ($ev, $x, $y) = @_; |
695 | my ($ev, $x, $y) = @_; |
597 | |
696 | |
598 | ($x, $y) = ($ev->motion_x, $ev->motion_y); |
697 | ($x, $y) = ($ev->{x}, $ev->{y}); |
599 | |
698 | |
600 | $self->{user_w} = $bw + $x - $ox; |
699 | $self->{user_w} = $bw + $x - $ox; |
601 | $self->{user_h} = $bh + $y - $oy; |
700 | $self->{user_h} = $bh + $y - $oy; |
602 | $self->update; |
701 | $self->check_size; |
603 | }; |
702 | }; |
604 | |
703 | |
605 | } elsif ($x >= 0 && $x < $self->{w} |
704 | } elsif ($x >= 0 && $x < $self->{w} |
606 | && $y >= 0 && $y < $self->{border}) { |
705 | && $y >= 0 && $y < $border) { |
607 | |
706 | |
608 | my ($ox, $oy) = ($ev->button_x, $ev->button_y); |
707 | my ($ox, $oy) = ($ev->{x}, $ev->{y}); |
609 | my ($bx, $by) = ($self->{x}, $self->{y}); |
708 | my ($bx, $by) = ($self->{x}, $self->{y}); |
610 | |
709 | |
611 | $self->{motion} = sub { |
710 | $self->{motion} = sub { |
612 | my ($ev, $x, $y) = @_; |
711 | my ($ev, $x, $y) = @_; |
613 | |
712 | |
614 | ($x, $y) = ($ev->motion_x, $ev->motion_y); |
713 | ($x, $y) = ($ev->{x}, $ev->{y}); |
615 | |
714 | |
616 | $self->move ($bx + $x - $ox, $by + $y - $oy); |
715 | $self->move ($bx + $x - $ox, $by + $y - $oy); |
617 | $self->update; |
716 | $self->update; |
618 | }; |
717 | }; |
619 | } |
718 | } |
… | |
… | |
640 | glEnable GL_BLEND; |
739 | glEnable GL_BLEND; |
641 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
740 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
642 | glEnable GL_TEXTURE_2D; |
741 | glEnable GL_TEXTURE_2D; |
643 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
742 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
644 | |
743 | |
|
|
744 | my $border = $self->border; |
|
|
745 | |
645 | glColor @{ $self->{border_bg} }; |
746 | glColor @{ $self->{border_bg} }; |
646 | $tex[1]->draw_quad (0, 0, $w, $self->{border}); |
747 | $tex[1]->draw_quad (0, 0, $w, $border); |
647 | $tex[3]->draw_quad (0, $self->{border}, $self->{border}, $ch); |
748 | $tex[3]->draw_quad (0, $border, $border, $ch); |
648 | $tex[2]->draw_quad ($w - $self->{border}, $self->{border}, $self->{border}, $ch); |
749 | $tex[2]->draw_quad ($w - $border, $border, $border, $ch); |
649 | $tex[4]->draw_quad (0, $h - $self->{border}, $w, $self->{border}); |
750 | $tex[4]->draw_quad (0, $h - $border, $w, $border); |
650 | |
751 | |
651 | my $bg = $tex[0]; |
752 | my $bg = $tex[0]; |
652 | |
753 | |
653 | # TODO: repeat texture not scale |
754 | # TODO: repeat texture not scale |
654 | my $rep_x = $cw / $bg->{w}; |
755 | my $rep_x = $cw / $bg->{w}; |
… | |
… | |
657 | glColor @{ $self->{bg} }; |
758 | glColor @{ $self->{bg} }; |
658 | |
759 | |
659 | $bg->{s} = $rep_x; |
760 | $bg->{s} = $rep_x; |
660 | $bg->{t} = $rep_y; |
761 | $bg->{t} = $rep_y; |
661 | $bg->{wrap_mode} = 1; |
762 | $bg->{wrap_mode} = 1; |
662 | $bg->draw_quad ($self->{border}, $self->{border}, $cw, $ch); |
763 | $bg->draw_quad ($border, $border, $cw, $ch); |
663 | |
764 | |
664 | glDisable GL_TEXTURE_2D; |
765 | glDisable GL_TEXTURE_2D; |
665 | glDisable GL_BLEND; |
766 | glDisable GL_BLEND; |
666 | |
767 | |
|
|
768 | $self->{title}->draw if $self->{title}; |
667 | $self->child->draw; |
769 | $self->child->draw; |
668 | } |
770 | } |
669 | |
771 | |
670 | ############################################################################# |
772 | ############################################################################# |
671 | |
773 | |
… | |
… | |
673 | |
775 | |
674 | our @ISA = CFClient::UI::Base::; |
776 | our @ISA = CFClient::UI::Base::; |
675 | |
777 | |
676 | use List::Util qw(max sum); |
778 | use List::Util qw(max sum); |
677 | |
779 | |
678 | use SDL::OpenGL; |
780 | use CFClient::OpenGL; |
679 | |
781 | |
680 | sub new { |
782 | sub new { |
681 | my $class = shift; |
783 | my $class = shift; |
682 | |
784 | |
683 | $class->SUPER::new ( |
785 | $class->SUPER::new ( |
… | |
… | |
685 | @_ |
787 | @_ |
686 | ) |
788 | ) |
687 | } |
789 | } |
688 | |
790 | |
689 | sub add { |
791 | sub add { |
690 | my ($self, $x, $y, $chld) = @_; |
792 | my ($self, $x, $y, $child) = @_; |
691 | |
793 | |
|
|
794 | $child->set_parent ($self); |
692 | $self->{children}[$y][$x] = $chld; |
795 | $self->{children}[$y][$x] = $child; |
693 | $chld->set_parent ($self); |
|
|
694 | |
796 | |
695 | $self->{w} = $self->{h} = -1; |
797 | $child->check_size; |
|
|
798 | } |
|
|
799 | |
|
|
800 | # TODO: move to container class maybe? send childs a signal on removal? |
|
|
801 | sub clear { |
|
|
802 | my ($self) = @_; |
|
|
803 | |
|
|
804 | delete $self->{children}; |
696 | $self->update; |
805 | $self->update; |
697 | } |
806 | } |
698 | |
807 | |
699 | sub get_wh { |
808 | sub get_wh { |
700 | my ($self) = @_; |
809 | my ($self) = @_; |
… | |
… | |
728 | (sum @$hs), |
837 | (sum @$hs), |
729 | ) |
838 | ) |
730 | } |
839 | } |
731 | |
840 | |
732 | sub size_allocate { |
841 | sub size_allocate { |
733 | my ($self, $x, $y, $w, $h) = @_; |
842 | my ($self, $w, $h) = @_; |
734 | |
|
|
735 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
736 | |
843 | |
737 | my ($ws, $hs) = $self->get_wh; |
844 | my ($ws, $hs) = $self->get_wh; |
738 | |
845 | |
739 | my $req_w = sum @$ws; |
846 | my $req_w = sum @$ws; |
740 | my $req_h = sum @$hs; |
847 | my $req_h = sum @$hs; |
… | |
… | |
762 | |
869 | |
763 | for my $c (0 .. $#$row) { |
870 | for my $c (0 .. $#$row) { |
764 | my $col_w = $ws->[$c]; |
871 | my $col_w = $ws->[$c]; |
765 | |
872 | |
766 | if (my $widget = $row->[$c]) { |
873 | if (my $widget = $row->[$c]) { |
767 | $widget->size_allocate ($x, $y, $col_w, $row_h); |
874 | $widget->configure ($x, $y, $col_w, $row_h); |
768 | } |
875 | } |
769 | |
876 | |
770 | $x += $col_w; |
877 | $x += $col_w; |
771 | } |
878 | } |
772 | |
879 | |
… | |
… | |
817 | (List::Util::max map $_->[1], @alloc), |
924 | (List::Util::max map $_->[1], @alloc), |
818 | ) |
925 | ) |
819 | } |
926 | } |
820 | |
927 | |
821 | sub size_allocate { |
928 | sub size_allocate { |
822 | my ($self, $x, $y, $w, $h) = @_; |
929 | my ($self, $w, $h) = @_; |
823 | |
|
|
824 | $self->_size_allocate ($x, $y, $w, $h); |
|
|
825 | |
930 | |
826 | ($h, $w) = ($w, $h); |
931 | ($h, $w) = ($w, $h); |
827 | |
932 | |
828 | my $children = $self->{children}; |
933 | my $children = $self->{children}; |
829 | |
934 | |
… | |
… | |
851 | |
956 | |
852 | my $y = 0; |
957 | my $y = 0; |
853 | for (0 .. $#$children) { |
958 | for (0 .. $#$children) { |
854 | my $child = $children->[$_]; |
959 | my $child = $children->[$_]; |
855 | my $h = $h[$_]; |
960 | my $h = $h[$_]; |
856 | $child->size_allocate ($y, 0, $h, $w); |
961 | $child->configure ($y, 0, $h, $w); |
857 | |
962 | |
858 | $y += $h; |
963 | $y += $h; |
859 | } |
964 | } |
|
|
965 | |
|
|
966 | 1 |
860 | } |
967 | } |
861 | |
968 | |
862 | ############################################################################# |
969 | ############################################################################# |
863 | |
970 | |
864 | package CFClient::UI::VBox; |
971 | package CFClient::UI::VBox; |
… | |
… | |
877 | (List::Util::sum map $_->[1], @alloc), |
984 | (List::Util::sum map $_->[1], @alloc), |
878 | ) |
985 | ) |
879 | } |
986 | } |
880 | |
987 | |
881 | sub size_allocate { |
988 | sub size_allocate { |
882 | my ($self, $x, $y, $w, $h) = @_; |
989 | my ($self, $w, $h) = @_; |
883 | |
|
|
884 | $self->_size_allocate ($x, $y, $w, $h); |
|
|
885 | |
990 | |
886 | my $children = $self->{children}; |
991 | my $children = $self->{children}; |
887 | |
992 | |
888 | my @h = map +($_->size_request)[1], @$children; |
993 | my @h = map +($_->size_request)[1], @$children; |
889 | |
994 | |
… | |
… | |
907 | |
1012 | |
908 | my $y = 0; |
1013 | my $y = 0; |
909 | for (0 .. $#$children) { |
1014 | for (0 .. $#$children) { |
910 | my $child = $children->[$_]; |
1015 | my $child = $children->[$_]; |
911 | my $h = $h[$_]; |
1016 | my $h = $h[$_]; |
912 | $child->size_allocate (0, $y, $w, $h); |
1017 | $child->configure (0, $y, $w, $h); |
913 | |
1018 | |
914 | $y += $h; |
1019 | $y += $h; |
915 | } |
1020 | } |
|
|
1021 | |
|
|
1022 | 1 |
916 | } |
1023 | } |
917 | |
1024 | |
918 | ############################################################################# |
1025 | ############################################################################# |
919 | |
1026 | |
920 | package CFClient::UI::Label; |
1027 | package CFClient::UI::Label; |
921 | |
1028 | |
922 | our @ISA = CFClient::UI::Base::; |
1029 | our @ISA = CFClient::UI::Base::; |
923 | |
1030 | |
924 | use SDL::OpenGL; |
1031 | use CFClient::OpenGL; |
925 | |
1032 | |
926 | sub new { |
1033 | sub new { |
927 | my ($class, %arg) = @_; |
1034 | my ($class, %arg) = @_; |
928 | |
1035 | |
929 | my $self = $class->SUPER::new ( |
1036 | my $self = $class->SUPER::new ( |
930 | fg => [1, 1, 1], |
1037 | fg => [1, 1, 1], |
931 | fontsize => $::FONTSIZE, |
1038 | fontsize => 1, |
932 | text => "", |
1039 | text => "", |
933 | align => -1, |
1040 | align => -1, |
|
|
1041 | valign => -1, |
934 | padding => 2, |
1042 | padding => 2, |
935 | layout => new CFClient::Layout, |
1043 | layout => new CFClient::Layout, |
936 | %arg |
1044 | %arg |
937 | ); |
1045 | ); |
938 | |
1046 | |
939 | $self->set_text ($self->{text}); |
1047 | if (exists $self->{template}) { |
|
|
1048 | my $layout = new CFClient::Layout; |
|
|
1049 | $layout->set_text (delete $self->{template}); |
|
|
1050 | $self->{template} = $layout; |
|
|
1051 | } |
|
|
1052 | |
|
|
1053 | $self->set_text (delete $self->{text}) if exists $self->{text}; |
|
|
1054 | $self->set_markup (delete $self->{markup}) if exists $self->{markup}; |
940 | |
1055 | |
941 | $self |
1056 | $self |
942 | } |
1057 | } |
943 | |
1058 | |
944 | sub escape_text { |
1059 | sub escape_text { |
… | |
… | |
952 | } |
1067 | } |
953 | |
1068 | |
954 | sub set_text { |
1069 | sub set_text { |
955 | my ($self, $text) = @_; |
1070 | my ($self, $text) = @_; |
956 | |
1071 | |
957 | $self->{text} = $text; |
|
|
958 | $self->{layout}->set_markup ($text); |
1072 | $self->{layout}->set_text ($text); |
959 | |
1073 | |
960 | delete $self->{texture}; |
1074 | delete $self->{texture}; |
961 | # $self->{w} = $self->{h} = -1; |
|
|
962 | $self->update; |
1075 | $self->update; |
963 | } |
1076 | } |
964 | |
1077 | |
965 | sub get_text { |
1078 | sub set_markup { |
966 | my ($self, $text) = @_; |
1079 | my ($self, $markup) = @_; |
967 | |
1080 | |
968 | $self->{text} |
1081 | $self->{layout}->set_markup ($markup); |
|
|
1082 | |
|
|
1083 | delete $self->{texture}; |
|
|
1084 | $self->update; |
969 | } |
1085 | } |
970 | |
1086 | |
971 | sub size_request { |
1087 | sub size_request { |
972 | my ($self) = @_; |
1088 | my ($self) = @_; |
973 | |
1089 | |
974 | $self->{layout}->set_width; |
1090 | $self->{layout}->set_width; |
975 | $self->{layout}->set_height ($self->{fontsize}); |
1091 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
|
|
1092 | |
976 | my ($w, $h) = $self->{layout}->size; |
1093 | my ($w, $h) = $self->{layout}->size; |
|
|
1094 | |
|
|
1095 | if (exists $self->{template}) { |
|
|
1096 | $self->{template}->set_height ($self->{fontsize} * $::FONTSIZE); |
|
|
1097 | |
|
|
1098 | my ($w2, $h2) = $self->{template}->size; |
|
|
1099 | |
|
|
1100 | $w = List::Util::max $w, $w2; |
|
|
1101 | $h = List::Util::max $h, $h2; |
|
|
1102 | } |
977 | |
1103 | |
978 | ( |
1104 | ( |
979 | $w + $self->{padding} * 2, |
1105 | $w + $self->{padding} * 2, |
980 | $h + $self->{padding} * 2, |
1106 | $h + $self->{padding} * 2, |
981 | ) |
1107 | ) |
982 | } |
1108 | } |
983 | |
1109 | |
984 | sub size_allocate { |
1110 | sub size_allocate { |
985 | my ($self, $x, $y, $w, $h) = @_; |
1111 | my ($self, $w, $h) = @_; |
986 | |
|
|
987 | $self->_size_allocate ($x, $y, $w, $h) or return; |
|
|
988 | |
1112 | |
989 | delete $self->{texture}; |
1113 | delete $self->{texture}; |
990 | } |
1114 | } |
991 | |
1115 | |
992 | sub update { |
1116 | sub set_fontsize { |
993 | my ($self) = @_; |
1117 | my ($self, $fontsize) = @_; |
994 | |
1118 | |
995 | delete $self->{texture}; |
1119 | $self->{fontsize} = $fontsize; |
996 | $self->SUPER::update; |
1120 | $self->update; |
997 | } |
1121 | } |
998 | |
1122 | |
999 | sub _draw { |
1123 | sub _draw { |
1000 | my ($self) = @_; |
1124 | my ($self) = @_; |
1001 | |
1125 | |
1002 | my $tex = $self->{texture} ||= do { |
1126 | my $tex = $self->{texture} ||= do { |
1003 | $self->{layout}->set_width ($self->{w}); |
1127 | $self->{layout}->set_width ($self->{w}); |
1004 | $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{fontsize}); |
1128 | $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize} * $::FONTSIZE); |
1005 | new_from_layout CFClient::Texture $self->{layout} |
1129 | new_from_layout CFClient::Texture $self->{layout} |
1006 | }; |
1130 | }; |
1007 | |
1131 | |
1008 | glEnable GL_BLEND; |
1132 | glEnable GL_BLEND; |
1009 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1133 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1010 | glEnable GL_TEXTURE_2D; |
1134 | glEnable GL_TEXTURE_2D; |
1011 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1135 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1012 | |
1136 | |
1013 | glColor @{$self->{fg}}; |
1137 | glColor @{$self->{fg}}; |
1014 | |
1138 | |
1015 | my $x = |
1139 | $self->{ox} = int ( |
1016 | $self->{align} < 0 ? $self->{padding} |
1140 | $self->{align} < 0 ? $self->{padding} |
1017 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
1141 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
1018 | : ($self->{w} - $tex->{w}) * 0.5; |
1142 | : ($self->{w} - $tex->{w}) * 0.5 |
|
|
1143 | ); |
1019 | |
1144 | |
1020 | $tex->draw_quad (int $x, int +($self->{h} - $tex->{h}) * 0.5); |
1145 | $self->{oy} = int ( |
|
|
1146 | $self->{valign} < 0 ? $self->{padding} |
|
|
1147 | : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding} |
|
|
1148 | : ($self->{h} - $tex->{h}) * 0.5 |
|
|
1149 | ); |
|
|
1150 | |
|
|
1151 | $tex->draw_quad ($self->{ox}, $self->{oy}); |
1021 | |
1152 | |
1022 | glDisable GL_TEXTURE_2D; |
1153 | glDisable GL_TEXTURE_2D; |
1023 | glDisable GL_BLEND; |
1154 | glDisable GL_BLEND; |
1024 | } |
1155 | } |
1025 | |
1156 | |
1026 | ############################################################################# |
1157 | ############################################################################# |
1027 | |
1158 | |
1028 | package CFClient::UI::Entry; |
1159 | package CFClient::UI::EntryBase; |
1029 | |
1160 | |
1030 | our @ISA = CFClient::UI::Label::; |
1161 | our @ISA = CFClient::UI::Label::; |
1031 | |
1162 | |
1032 | use SDL; |
1163 | use CFClient::OpenGL; |
1033 | use SDL::OpenGL; |
|
|
1034 | |
1164 | |
1035 | sub new { |
1165 | sub new { |
1036 | my $class = shift; |
1166 | my $class = shift; |
1037 | |
1167 | |
1038 | $class->SUPER::new ( |
1168 | $class->SUPER::new ( |
… | |
… | |
1040 | bg => [0, 0, 0, 0.2], |
1170 | bg => [0, 0, 0, 0.2], |
1041 | active_bg => [1, 1, 1, 0.5], |
1171 | active_bg => [1, 1, 1, 0.5], |
1042 | active_fg => [0, 0, 0], |
1172 | active_fg => [0, 0, 0], |
1043 | can_hover => 1, |
1173 | can_hover => 1, |
1044 | can_focus => 1, |
1174 | can_focus => 1, |
|
|
1175 | valign => 0, |
1045 | @_ |
1176 | @_ |
1046 | ) |
1177 | ) |
1047 | } |
1178 | } |
1048 | |
1179 | |
1049 | sub _set_text { |
1180 | sub _set_text { |
1050 | my ($self, $text) = @_; |
1181 | my ($self, $text) = @_; |
1051 | |
1182 | |
1052 | my $old_text = $self->{text}; |
1183 | delete $self->{cur_h}; |
|
|
1184 | |
|
|
1185 | return if $self->{text} eq $text; |
|
|
1186 | |
|
|
1187 | delete $self->{texture}; |
1053 | |
1188 | |
1054 | $self->{last_activity} = $::NOW; |
1189 | $self->{last_activity} = $::NOW; |
1055 | |
|
|
1056 | $self->{text} = $text; |
1190 | $self->{text} = $text; |
1057 | $self->{layout}->set_width ($self->{w}); |
|
|
1058 | $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{fontsize}); |
|
|
1059 | |
1191 | |
1060 | $text =~ s/./*/g if $self->{hidden}; |
1192 | $text =~ s/./*/g if $self->{hidden}; |
|
|
1193 | $self->{layout}->set_text ("$text "); |
1061 | |
1194 | |
1062 | $self->{layout}->set_markup ($self->escape_text ($text) . " "); |
1195 | $self->emit (changed => $self->{text}); |
|
|
1196 | } |
1063 | |
1197 | |
1064 | $text = substr $text, 0, $self->{cursor}; |
1198 | sub get_text { |
1065 | utf8::encode $text; |
1199 | $_[0]{text} |
1066 | |
|
|
1067 | @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text); |
|
|
1068 | |
|
|
1069 | $self->emit (changed => $self->{text}) # XXX: is this the right place to do this? |
|
|
1070 | if $old_text ne $self->{text}; |
|
|
1071 | } |
1200 | } |
1072 | |
1201 | |
1073 | sub size_request { |
1202 | sub size_request { |
1074 | my ($self) = @_; |
1203 | my ($self) = @_; |
1075 | |
1204 | |
… | |
… | |
1077 | |
1206 | |
1078 | ($w + 1, $h) # add 1 for cursor |
1207 | ($w + 1, $h) # add 1 for cursor |
1079 | } |
1208 | } |
1080 | |
1209 | |
1081 | sub size_allocate { |
1210 | sub size_allocate { |
1082 | my ($self, $x, $y, $w, $h) = @_; |
1211 | my ($self, $w, $h) = @_; |
1083 | |
|
|
1084 | $self->SUPER::size_allocate ($x, $y, $w, $h); |
|
|
1085 | |
1212 | |
1086 | $self->_set_text ($self->{text}); |
1213 | $self->_set_text ($self->{text}); |
1087 | } |
1214 | } |
1088 | |
1215 | |
1089 | sub set_text { |
1216 | sub set_text { |
… | |
… | |
1095 | } |
1222 | } |
1096 | |
1223 | |
1097 | sub key_down { |
1224 | sub key_down { |
1098 | my ($self, $ev) = @_; |
1225 | my ($self, $ev) = @_; |
1099 | |
1226 | |
1100 | my $mod = $ev->key_mod; |
1227 | my $mod = $ev->{mod}; |
1101 | my $sym = $ev->key_sym; |
1228 | my $sym = $ev->{sym}; |
1102 | |
|
|
1103 | my $uni = $ev->key_unicode; |
1229 | my $uni = $ev->{unicode}; |
1104 | |
1230 | |
1105 | my $text = $self->get_text; |
1231 | my $text = $self->get_text; |
1106 | |
1232 | |
1107 | if ($sym == SDLK_BACKSPACE) { |
1233 | if ($sym == 8) { |
1108 | substr $text, --$self->{cursor}, 1, "" if $self->{cursor}; |
1234 | substr $text, --$self->{cursor}, 1, "" if $self->{cursor}; |
1109 | } elsif ($sym == SDLK_DELETE) { |
1235 | } elsif ($sym == 127) { |
1110 | substr $text, $self->{cursor}, 1, ""; |
1236 | substr $text, $self->{cursor}, 1, ""; |
1111 | } elsif ($sym == SDLK_LEFT) { |
1237 | } elsif ($sym == CFClient::SDLK_LEFT) { |
1112 | --$self->{cursor} if $self->{cursor}; |
1238 | --$self->{cursor} if $self->{cursor}; |
1113 | } elsif ($sym == SDLK_RIGHT) { |
1239 | } elsif ($sym == CFClient::SDLK_RIGHT) { |
1114 | ++$self->{cursor} if $self->{cursor} < length $self->{text}; |
1240 | ++$self->{cursor} if $self->{cursor} < length $self->{text}; |
1115 | } elsif ($sym == SDLK_HOME) { |
1241 | } elsif ($sym == CFClient::SDLK_HOME) { |
1116 | $self->{cursor} = 0; |
1242 | $self->{cursor} = 0; |
1117 | } elsif ($sym == SDLK_END) { |
1243 | } elsif ($sym == CFClient::SDLK_END) { |
1118 | $self->{cursor} = length $text; |
1244 | $self->{cursor} = length $text; |
1119 | } elsif ($sym == SDLK_ESCAPE) { |
1245 | } elsif ($sym == 27) { |
1120 | $self->emit ('escape'); |
1246 | $self->emit ('escape'); |
1121 | } elsif ($uni) { |
1247 | } elsif ($uni) { |
1122 | substr $text, $self->{cursor}++, 0, chr $uni; |
1248 | substr $text, $self->{cursor}++, 0, chr $uni; |
1123 | } |
1249 | } |
1124 | |
1250 | |
… | |
… | |
1179 | |
1305 | |
1180 | $self->SUPER::_draw; |
1306 | $self->SUPER::_draw; |
1181 | |
1307 | |
1182 | #TODO: force update every cursor change :( |
1308 | #TODO: force update every cursor change :( |
1183 | if ($FOCUS == $self && (($::NOW - $self->{last_activity}) & 1023) < 600) { |
1309 | if ($FOCUS == $self && (($::NOW - $self->{last_activity}) & 1023) < 600) { |
|
|
1310 | |
|
|
1311 | unless (exists $self->{cur_h}) { |
|
|
1312 | my $text = substr $self->{text}, 0, $self->{cursor}; |
|
|
1313 | utf8::encode $text; |
|
|
1314 | |
|
|
1315 | @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text) |
|
|
1316 | } |
|
|
1317 | |
1184 | glColor @{$self->{fg}}; |
1318 | glColor @{$self->{fg}}; |
1185 | glBegin GL_LINES; |
1319 | glBegin GL_LINES; |
1186 | glVertex $self->{cur_x}, $self->{cur_y}; |
|
|
1187 | glVertex $self->{cur_x}, $self->{cur_y} + $self->{cur_h}; |
1320 | glVertex $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy}; |
|
|
1321 | glVertex $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy} + $self->{cur_h}; |
1188 | glEnd; |
1322 | glEnd; |
1189 | } |
1323 | } |
1190 | } |
1324 | } |
1191 | |
1325 | |
1192 | package CFClient::UI::LineEntry; |
1326 | package CFClient::UI::Entry; |
1193 | |
1327 | |
1194 | our @ISA = CFClient::UI::Entry::; |
1328 | our @ISA = CFClient::UI::EntryBase::; |
1195 | |
1329 | |
1196 | use SDL; |
1330 | use CFClient::OpenGL; |
1197 | use SDL::OpenGL; |
|
|
1198 | |
1331 | |
1199 | sub key_down { |
1332 | sub key_down { |
1200 | my ($self, $ev) = @_; |
1333 | my ($self, $ev) = @_; |
1201 | |
1334 | |
1202 | my $sym = $ev->key_sym; |
1335 | my $sym = $ev->{sym}; |
1203 | |
1336 | |
1204 | if ($sym == SDLK_RETURN) { |
1337 | if ($sym == 13) { |
1205 | $self->emit (activate => $self->get_text); |
1338 | $self->emit (activate => $self->get_text); |
1206 | $self->update; |
1339 | $self->update; |
1207 | |
1340 | |
1208 | } else { |
1341 | } else { |
1209 | $self->SUPER::key_down ($ev); |
1342 | $self->SUPER::key_down ($ev); |
… | |
… | |
1215 | |
1348 | |
1216 | package CFClient::UI::Button; |
1349 | package CFClient::UI::Button; |
1217 | |
1350 | |
1218 | our @ISA = CFClient::UI::Label::; |
1351 | our @ISA = CFClient::UI::Label::; |
1219 | |
1352 | |
1220 | use SDL; |
1353 | use CFClient::OpenGL; |
1221 | use SDL::OpenGL; |
|
|
1222 | |
1354 | |
1223 | my @tex = |
1355 | my @tex = |
1224 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
1356 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1225 | qw(b1_button_active.png); |
1357 | qw(b1_button_active.png); |
1226 | |
1358 | |
1227 | sub new { |
1359 | sub new { |
1228 | my $class = shift; |
1360 | my $class = shift; |
1229 | |
1361 | |
1230 | $class->SUPER::new ( |
1362 | $class->SUPER::new ( |
1231 | padding => 4, |
1363 | padding => 4, |
1232 | fg => [1, 1, 1], |
1364 | fg => [1, 1, 1], |
1233 | bg => [1, 1, 1, 0.2], |
1365 | bg => [1, 1, 1, 0.2], |
1234 | active_fg => [1, 1, 0], |
1366 | active_fg => [0, 0, 1], |
1235 | can_hover => 1, |
1367 | can_hover => 1, |
|
|
1368 | align => 0, |
|
|
1369 | valign => 0, |
1236 | @_ |
1370 | @_ |
1237 | ) |
1371 | ) |
1238 | } |
1372 | } |
1239 | |
1373 | |
1240 | sub button_up { |
1374 | sub button_up { |
… | |
… | |
1248 | |
1382 | |
1249 | sub _draw { |
1383 | sub _draw { |
1250 | my ($self) = @_; |
1384 | my ($self) = @_; |
1251 | |
1385 | |
1252 | local $self->{fg} = $self->{fg}; |
1386 | local $self->{fg} = $self->{fg}; |
1253 | my $tex = $tex[0]; |
|
|
1254 | |
|
|
1255 | glEnable GL_BLEND; |
|
|
1256 | glEnable GL_TEXTURE_2D; |
|
|
1257 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1258 | |
1387 | |
1259 | if ($GRAB == $self) { |
1388 | if ($GRAB == $self) { |
1260 | $self->{fg} = $self->{active_fg}; |
1389 | $self->{fg} = $self->{active_fg}; |
1261 | } |
1390 | } |
1262 | |
1391 | |
1263 | glBindTexture GL_TEXTURE_2D, $tex->{name}; |
1392 | glEnable GL_BLEND; |
|
|
1393 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1394 | glEnable GL_TEXTURE_2D; |
1264 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1395 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
1396 | glColor 0, 0, 0, 1; |
1265 | |
1397 | |
1266 | $tex->draw_quad (0, 0, $self->{w}, $self->{h}); |
1398 | $tex[0]->draw_quad (0, 0, $self->{w}, $self->{h}); |
1267 | |
1399 | |
1268 | glDisable GL_TEXTURE_2D; |
1400 | glDisable GL_TEXTURE_2D; |
1269 | glDisable GL_BLEND; |
1401 | glDisable GL_BLEND; |
1270 | |
1402 | |
1271 | $self->SUPER::_draw; |
1403 | $self->SUPER::_draw; |
… | |
… | |
1276 | package CFClient::UI::CheckBox; |
1408 | package CFClient::UI::CheckBox; |
1277 | |
1409 | |
1278 | our @ISA = CFClient::UI::DrawBG::; |
1410 | our @ISA = CFClient::UI::DrawBG::; |
1279 | |
1411 | |
1280 | my @tex = |
1412 | my @tex = |
1281 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
1413 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1282 | qw(c1_checkbox_bg.png c1_checkbox_active.png); |
1414 | qw(c1_checkbox_bg.png c1_checkbox_active.png); |
1283 | |
1415 | |
1284 | use SDL; |
1416 | use CFClient::OpenGL; |
1285 | use SDL::OpenGL; |
|
|
1286 | |
1417 | |
1287 | sub new { |
1418 | sub new { |
1288 | my $class = shift; |
1419 | my $class = shift; |
1289 | |
1420 | |
1290 | $class->SUPER::new ( |
1421 | $class->SUPER::new ( |
… | |
… | |
1301 | my ($self) = @_; |
1432 | my ($self) = @_; |
1302 | |
1433 | |
1303 | ($self->{padding} * 2 + 6) x 2 |
1434 | ($self->{padding} * 2 + 6) x 2 |
1304 | } |
1435 | } |
1305 | |
1436 | |
1306 | sub size_allocate { |
|
|
1307 | my ($self, $x, $y, $w, $h) = @_; |
|
|
1308 | |
|
|
1309 | $self->_size_allocate ($x, $y, $w, $h); |
|
|
1310 | } |
|
|
1311 | |
|
|
1312 | sub button_down { |
1437 | sub button_down { |
1313 | my ($self, $ev, $x, $y) = @_; |
1438 | my ($self, $ev, $x, $y) = @_; |
1314 | |
1439 | |
1315 | if ($x >= $self->{padding} && $x < $self->{w} - $self->{padding} |
1440 | if ($x >= $self->{padding} && $x < $self->{w} - $self->{padding} |
1316 | && $y >= $self->{padding} && $y < $self->{h} - $self->{padding}) { |
1441 | && $y >= $self->{padding} && $y < $self->{h} - $self->{padding}) { |
… | |
… | |
1342 | glDisable GL_BLEND; |
1467 | glDisable GL_BLEND; |
1343 | } |
1468 | } |
1344 | |
1469 | |
1345 | ############################################################################# |
1470 | ############################################################################# |
1346 | |
1471 | |
|
|
1472 | package CFClient::UI::Image; |
|
|
1473 | |
|
|
1474 | our @ISA = CFClient::UI::Base::; |
|
|
1475 | |
|
|
1476 | use CFClient::OpenGL; |
|
|
1477 | use Carp qw/confess/; |
|
|
1478 | |
|
|
1479 | our %loaded_images; |
|
|
1480 | |
|
|
1481 | sub new { |
|
|
1482 | my $class = shift; |
|
|
1483 | |
|
|
1484 | my $self = $class->SUPER::new (@_); |
|
|
1485 | |
|
|
1486 | $self->{image} or confess "Image has 'image' not set. This is a fatal error!"; |
|
|
1487 | |
|
|
1488 | $loaded_images{$self->{image}} ||= |
|
|
1489 | new_from_file CFClient::Texture CFClient::find_rcfile $self->{image}, mipmap => 1; |
|
|
1490 | |
|
|
1491 | my $tex = $self->{tex} = $loaded_images{$self->{image}}; |
|
|
1492 | |
|
|
1493 | $self->{aspect} = $tex->{w} / $tex->{h}; |
|
|
1494 | |
|
|
1495 | $self |
|
|
1496 | } |
|
|
1497 | |
|
|
1498 | sub size_request { |
|
|
1499 | my ($self) = @_; |
|
|
1500 | |
|
|
1501 | ($self->{tex}->{w}, $self->{tex}->{h}) |
|
|
1502 | } |
|
|
1503 | |
|
|
1504 | sub _draw { |
|
|
1505 | my ($self) = @_; |
|
|
1506 | |
|
|
1507 | my $tex = $self->{tex}; |
|
|
1508 | |
|
|
1509 | my ($w, $h) = ($self->{w}, $self->{h}); |
|
|
1510 | |
|
|
1511 | if ($self->{rot90}) { |
|
|
1512 | glRotate 90, 0, 0, 1; |
|
|
1513 | glTranslate 0, -$self->{w}, 0; |
|
|
1514 | |
|
|
1515 | ($w, $h) = ($h, $w); |
|
|
1516 | } |
|
|
1517 | |
|
|
1518 | glEnable GL_BLEND; |
|
|
1519 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1520 | glEnable GL_TEXTURE_2D; |
|
|
1521 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
1522 | |
|
|
1523 | $tex->draw_quad (0, 0, $w, $h); |
|
|
1524 | |
|
|
1525 | glDisable GL_BLEND; |
|
|
1526 | glDisable GL_TEXTURE_2D; |
|
|
1527 | } |
|
|
1528 | |
|
|
1529 | ############################################################################# |
|
|
1530 | |
|
|
1531 | package CFClient::UI::VGauge; |
|
|
1532 | |
|
|
1533 | our @ISA = CFClient::UI::Base::; |
|
|
1534 | |
|
|
1535 | use CFClient::OpenGL; |
|
|
1536 | |
|
|
1537 | my %tex = ( |
|
|
1538 | food => [ |
|
|
1539 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
|
|
1540 | qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ |
|
|
1541 | ], |
|
|
1542 | grace => [ |
|
|
1543 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
|
|
1544 | qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png/ |
|
|
1545 | ], |
|
|
1546 | hp => [ |
|
|
1547 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
|
|
1548 | qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ |
|
|
1549 | ], |
|
|
1550 | mana => [ |
|
|
1551 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
|
|
1552 | qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png/ |
|
|
1553 | ], |
|
|
1554 | ); |
|
|
1555 | |
|
|
1556 | # eg. VGauge->new (gauge => 'food'), default gauge: food |
|
|
1557 | sub new { |
|
|
1558 | my $class = shift; |
|
|
1559 | |
|
|
1560 | my $self = $class->SUPER::new ( |
|
|
1561 | type => 'food', |
|
|
1562 | @_ |
|
|
1563 | ); |
|
|
1564 | |
|
|
1565 | $self->{aspect} = $tex{$self->{type}}[0]{w} / $tex{$self->{type}}[0]{h}; |
|
|
1566 | |
|
|
1567 | $self |
|
|
1568 | } |
|
|
1569 | |
|
|
1570 | sub size_request { |
|
|
1571 | my ($self) = @_; |
|
|
1572 | |
|
|
1573 | #my $tex = $tex{$self->{type}}[0]; |
|
|
1574 | #@$tex{qw(w h)} |
|
|
1575 | (0, 0) |
|
|
1576 | } |
|
|
1577 | |
|
|
1578 | sub set_max { |
|
|
1579 | my ($self, $max) = @_; |
|
|
1580 | |
|
|
1581 | $self->{max_val} = $max; |
|
|
1582 | } |
|
|
1583 | |
|
|
1584 | sub set_value { |
|
|
1585 | my ($self, $val, $max) = @_; |
|
|
1586 | |
|
|
1587 | $self->set_max ($max) |
|
|
1588 | if defined $max; |
|
|
1589 | |
|
|
1590 | $max = $self->{max_val}; |
|
|
1591 | $self->{val} = $val; |
|
|
1592 | |
|
|
1593 | $self->update; |
|
|
1594 | } |
|
|
1595 | |
|
|
1596 | sub _draw { |
|
|
1597 | my ($self) = @_; |
|
|
1598 | |
|
|
1599 | my $tex = $tex{$self->{type}}; |
|
|
1600 | |
|
|
1601 | my ($w, $h) = ($self->{w}, $self->{h}); |
|
|
1602 | |
|
|
1603 | if ($self->{vertical}) { |
|
|
1604 | glRotate 90, 0, 0, 1; |
|
|
1605 | glTranslate 0, -$self->{w}, 0; |
|
|
1606 | |
|
|
1607 | ($w, $h) = ($h, $w); |
|
|
1608 | } |
|
|
1609 | |
|
|
1610 | my $ycut = $self->{val} / ($self->{max_val} || 1); |
|
|
1611 | $ycut = 1 if $self->{val} > $self->{max_val}; |
|
|
1612 | |
|
|
1613 | my $t1 = $tex->[0]; |
|
|
1614 | my $t2 = $tex->[1]; |
|
|
1615 | |
|
|
1616 | glEnable GL_BLEND; |
|
|
1617 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1618 | glEnable GL_TEXTURE_2D; |
|
|
1619 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
1620 | |
|
|
1621 | my $h1 = $self->{h} - $ycut * $self->{h}; |
|
|
1622 | my $h2 = $ycut * $self->{h}; |
|
|
1623 | |
|
|
1624 | glBindTexture GL_TEXTURE_2D, $t1->{name}; |
|
|
1625 | glBegin GL_QUADS; |
|
|
1626 | glTexCoord 0 , 0; glVertex 0 , 0; |
|
|
1627 | glTexCoord 0 , $t1->{t} * (1 - $ycut); glVertex 0 , $h1; |
|
|
1628 | glTexCoord $t1->{s}, $t1->{t} * (1 - $ycut); glVertex $w, $h1; |
|
|
1629 | glTexCoord $t1->{s}, 0; glVertex $w, 0; |
|
|
1630 | glEnd; |
|
|
1631 | |
|
|
1632 | glBindTexture GL_TEXTURE_2D, $t2->{name}; |
|
|
1633 | glBegin GL_QUADS; |
|
|
1634 | glTexCoord 0 , $t2->{t} * (1 - $ycut); glVertex 0 , $h1; |
|
|
1635 | glTexCoord 0 , $t2->{t}; glVertex 0 , $h1 + $h2; |
|
|
1636 | glTexCoord $t2->{s}, $t2->{t}; glVertex $w, $h1 + $h2; |
|
|
1637 | glTexCoord $t2->{s}, $t2->{t} * (1 - $ycut); glVertex $w, $h1; |
|
|
1638 | glEnd; |
|
|
1639 | |
|
|
1640 | glDisable GL_BLEND; |
|
|
1641 | glDisable GL_TEXTURE_2D; |
|
|
1642 | } |
|
|
1643 | |
|
|
1644 | ############################################################################# |
|
|
1645 | |
|
|
1646 | package CFClient::UI::Gauge; |
|
|
1647 | |
|
|
1648 | our @ISA = CFClient::UI::VBox::; |
|
|
1649 | |
|
|
1650 | sub new { |
|
|
1651 | my ($class, %arg) = shift; |
|
|
1652 | |
|
|
1653 | my $self = $class->SUPER::new ( |
|
|
1654 | @_, |
|
|
1655 | ); |
|
|
1656 | |
|
|
1657 | $self->add ($self->{value} = new CFClient::UI::Label valign => 1, align => 0, template => "999"); |
|
|
1658 | $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1); |
|
|
1659 | $self->add ($self->{max} = new CFClient::UI::Label valign => 1, align => 0, template => "999"); |
|
|
1660 | |
|
|
1661 | $self |
|
|
1662 | } |
|
|
1663 | |
|
|
1664 | sub set_fontsize { |
|
|
1665 | my ($self, $fsize) = @_; |
|
|
1666 | |
|
|
1667 | $self->{value}->set_fontsize ($fsize); |
|
|
1668 | $self->{max} ->set_fontsize ($fsize); |
|
|
1669 | $self->update; |
|
|
1670 | } |
|
|
1671 | |
|
|
1672 | sub set_value { |
|
|
1673 | my ($self, $val, $max) = @_; |
|
|
1674 | |
|
|
1675 | $self->set_max ($max) |
|
|
1676 | if defined $max; |
|
|
1677 | |
|
|
1678 | $self->{gauge}->set_value ($val, $max); |
|
|
1679 | $self->{value}->set_text ($val); |
|
|
1680 | } |
|
|
1681 | |
|
|
1682 | sub set_max { |
|
|
1683 | my ($self, $max) = @_; |
|
|
1684 | |
|
|
1685 | $self->{gauge}->set_max ($max); |
|
|
1686 | $self->{max}->set_text ($max); |
|
|
1687 | } |
|
|
1688 | |
|
|
1689 | ############################################################################# |
|
|
1690 | |
1347 | package CFClient::UI::Slider; |
1691 | package CFClient::UI::Slider; |
1348 | |
1692 | |
1349 | use strict; |
1693 | use strict; |
1350 | |
1694 | |
1351 | use SDL::OpenGL; |
1695 | use CFClient::OpenGL; |
1352 | |
1696 | |
1353 | our @ISA = CFClient::UI::DrawBG::; |
1697 | our @ISA = CFClient::UI::DrawBG::; |
1354 | |
1698 | |
1355 | my @tex = |
1699 | my @tex = |
1356 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
1700 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
… | |
… | |
1366 | # TODO: calculations are off |
1710 | # TODO: calculations are off |
1367 | my $self = $class->SUPER::new ( |
1711 | my $self = $class->SUPER::new ( |
1368 | fg => [1, 1, 1], |
1712 | fg => [1, 1, 1], |
1369 | active_fg => [0, 0, 0], |
1713 | active_fg => [0, 0, 0], |
1370 | range => [0, 0, 100, 10], |
1714 | range => [0, 0, 100, 10], |
1371 | req_w => 40, |
1715 | req_w => 20, |
1372 | req_h => 13, |
1716 | req_h => 20, |
1373 | vertical => 0, |
1717 | vertical => 0, |
1374 | can_hover => 1, |
1718 | can_hover => 1, |
1375 | inner_pad => 5, |
1719 | inner_pad => 5, |
1376 | @_ |
1720 | @_ |
1377 | ); |
1721 | ); |
… | |
… | |
1481 | |
1825 | |
1482 | package CFClient::UI::TextView; |
1826 | package CFClient::UI::TextView; |
1483 | |
1827 | |
1484 | our @ISA = CFClient::UI::HBox::; |
1828 | our @ISA = CFClient::UI::HBox::; |
1485 | |
1829 | |
1486 | use SDL::OpenGL; |
1830 | use CFClient::OpenGL; |
1487 | |
1831 | |
1488 | sub new { |
1832 | sub new { |
1489 | my $class = shift; |
1833 | my $class = shift; |
1490 | |
1834 | |
1491 | my $self = $class->SUPER::new ( |
1835 | my $self = $class->SUPER::new ( |
1492 | req_w => $::WIDTH / 6, |
|
|
1493 | req_h => $::HEIGHT / 6, |
|
|
1494 | fontsize => $::FONTSIZE, |
1836 | fontsize => 1, |
1495 | @_, |
1837 | @_, |
1496 | |
1838 | |
1497 | layout => (new CFClient::Layout), |
1839 | layout => (new CFClient::Layout), |
1498 | par => [], |
1840 | par => [], |
1499 | height => 0, |
1841 | height => 0, |
… | |
… | |
1520 | sub text_height { |
1862 | sub text_height { |
1521 | my ($self, $text) = @_; |
1863 | my ($self, $text) = @_; |
1522 | |
1864 | |
1523 | my $layout = $self->{layout}; |
1865 | my $layout = $self->{layout}; |
1524 | |
1866 | |
1525 | $layout->set_height ($self->{fontsize}); |
1867 | $layout->set_height ($self->{fontsize} * $::FONTSIZE); |
1526 | $layout->set_width ($self->{w}); |
1868 | $layout->set_width ($self->{w}); |
1527 | $layout->set_text ($text); |
1869 | $layout->set_text ($text); |
1528 | |
1870 | |
1529 | ($layout->size)[1] |
1871 | ($layout->size)[1] |
1530 | } |
1872 | } |
… | |
… | |
1534 | |
1876 | |
1535 | $self->{need_reflow}++; |
1877 | $self->{need_reflow}++; |
1536 | $self->update; |
1878 | $self->update; |
1537 | } |
1879 | } |
1538 | |
1880 | |
1539 | sub size_request { |
|
|
1540 | my ($self) = @_; |
|
|
1541 | |
|
|
1542 | ($self->{req_w}, $self->{req_h}) |
|
|
1543 | } |
|
|
1544 | |
|
|
1545 | sub size_allocate { |
1881 | sub size_allocate { |
1546 | my ($self, $x, $y, $w, $h) = @_; |
1882 | my ($self, $w, $h) = @_; |
1547 | |
1883 | |
1548 | $self->SUPER::size_allocate ($x, $y, $w, $h); |
1884 | $self->SUPER::size_allocate ($w, $h); |
1549 | |
1885 | |
1550 | $self->{layout}->set_height ($self->{fontsize}); |
1886 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1551 | $self->{layout}->set_width ($self->{w}); |
1887 | $self->{layout}->set_width ($self->{children}[0]{w}); |
1552 | |
1888 | |
1553 | $self->reflow; |
1889 | $self->reflow; |
1554 | } |
1890 | } |
1555 | |
1891 | |
1556 | sub add_paragraph { |
1892 | sub add_paragraph { |
… | |
… | |
1575 | |
1911 | |
1576 | return unless $self->{h} > 0; |
1912 | return unless $self->{h} > 0; |
1577 | |
1913 | |
1578 | delete $self->{texture}; |
1914 | delete $self->{texture}; |
1579 | |
1915 | |
1580 | $TOPLEVEL->on_refresh ($self, sub { |
1916 | $ROOT->on_refresh ($self, sub { |
1581 | if (delete $self->{need_reflow}) { |
1917 | if (delete $self->{need_reflow}) { |
1582 | my $height = 0; |
1918 | my $height = 0; |
1583 | |
1919 | |
1584 | $height += $_->[0] = $self->text_height ($_->[2]) |
1920 | $height += $_->[0] = $self->text_height ($_->[2]) |
1585 | for @{$self->{par}}; |
1921 | for @{$self->{par}}; |
… | |
… | |
1643 | |
1979 | |
1644 | } |
1980 | } |
1645 | |
1981 | |
1646 | ############################################################################# |
1982 | ############################################################################# |
1647 | |
1983 | |
1648 | package CFClient::UI::MapWidget; |
|
|
1649 | |
|
|
1650 | use strict; |
|
|
1651 | |
|
|
1652 | use List::Util qw(min max); |
|
|
1653 | |
|
|
1654 | use SDL; |
|
|
1655 | use SDL::OpenGL; |
|
|
1656 | |
|
|
1657 | our @ISA = CFClient::UI::Base::; |
|
|
1658 | |
|
|
1659 | sub new { |
|
|
1660 | my $class = shift; |
|
|
1661 | |
|
|
1662 | $class->SUPER::new ( |
|
|
1663 | z => -1, |
|
|
1664 | can_focus => 1, |
|
|
1665 | list => (glGenLists 1), |
|
|
1666 | @_ |
|
|
1667 | ) |
|
|
1668 | } |
|
|
1669 | |
|
|
1670 | sub key_down { |
|
|
1671 | print "MAPKEYDOWN\n"; |
|
|
1672 | } |
|
|
1673 | |
|
|
1674 | sub key_up { |
|
|
1675 | } |
|
|
1676 | |
|
|
1677 | sub button_down { |
|
|
1678 | my ($self, $ev, $x, $y) = @_; |
|
|
1679 | |
|
|
1680 | $self->focus_in; |
|
|
1681 | |
|
|
1682 | if ($ev->button == 2) { |
|
|
1683 | my ($ox, $oy) = ($ev->button_x, $ev->button_y); |
|
|
1684 | my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); |
|
|
1685 | |
|
|
1686 | $self->{motion} = sub { |
|
|
1687 | my ($ev, $x, $y) = @_; |
|
|
1688 | |
|
|
1689 | ($x, $y) = ($ev->motion_x, $ev->motion_y); |
|
|
1690 | |
|
|
1691 | $::CFG->{map_shift_x} = $bw + $x - $ox; |
|
|
1692 | $::CFG->{map_shift_y} = $bh + $y - $oy; |
|
|
1693 | |
|
|
1694 | $self->update; |
|
|
1695 | }; |
|
|
1696 | } |
|
|
1697 | } |
|
|
1698 | |
|
|
1699 | sub button_up { |
|
|
1700 | my ($self, $ev, $x, $y) = @_; |
|
|
1701 | |
|
|
1702 | delete $self->{motion}; |
|
|
1703 | } |
|
|
1704 | |
|
|
1705 | sub mouse_motion { |
|
|
1706 | my ($self, $ev, $x, $y) = @_; |
|
|
1707 | |
|
|
1708 | $self->{motion}->($ev, $x, $y) if $self->{motion}; |
|
|
1709 | } |
|
|
1710 | |
|
|
1711 | sub size_request { |
|
|
1712 | ( |
|
|
1713 | 1 + 32 * int $::WIDTH / 32, |
|
|
1714 | 1 + 32 * int $::HEIGHT / 32, |
|
|
1715 | ) |
|
|
1716 | } |
|
|
1717 | |
|
|
1718 | sub update { |
|
|
1719 | my ($self) = @_; |
|
|
1720 | |
|
|
1721 | $self->{need_update} = 1; |
|
|
1722 | $self->SUPER::update; |
|
|
1723 | } |
|
|
1724 | |
|
|
1725 | sub draw { |
|
|
1726 | my ($self) = @_; |
|
|
1727 | |
|
|
1728 | if (delete $self->{need_update}) { |
|
|
1729 | glNewList $self->{list}, GL_COMPILE; |
|
|
1730 | |
|
|
1731 | if ($::MAP) { |
|
|
1732 | my $sw = int $::WIDTH / 32; |
|
|
1733 | my $sh = int $::HEIGHT / 32; |
|
|
1734 | |
|
|
1735 | my $sx = $::CFG->{map_shift_x}; my $sx0 = $sx & 31; $sx = ($sx - $sx0) / 32; |
|
|
1736 | my $sy = $::CFG->{map_shift_y}; my $sy0 = $sy & 31; $sy = ($sy - $sy0) / 32; |
|
|
1737 | |
|
|
1738 | glTranslate $sx0 - 32, $sy0 - 32, 0; |
|
|
1739 | |
|
|
1740 | my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); |
|
|
1741 | |
|
|
1742 | if ($::CFG->{fow_enable}) { |
|
|
1743 | if ($::CFG->{fow_smooth}) { # smooth fog of war |
|
|
1744 | glConvolutionParameter GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER; |
|
|
1745 | glConvolutionFilter2D |
|
|
1746 | GL_CONVOLUTION_2D, |
|
|
1747 | GL_ALPHA, |
|
|
1748 | 3, 3, |
|
|
1749 | GL_ALPHA, GL_FLOAT, |
|
|
1750 | pack "f*", |
|
|
1751 | 0.1, 0.1, 0.1, |
|
|
1752 | 0.1, 0.2, 0.1, |
|
|
1753 | 0.1, 0.1, 0.1, |
|
|
1754 | ; |
|
|
1755 | glEnable GL_CONVOLUTION_2D; |
|
|
1756 | } |
|
|
1757 | |
|
|
1758 | my $tex = new CFClient::Texture |
|
|
1759 | w => $w, |
|
|
1760 | h => $h, |
|
|
1761 | data => $data, |
|
|
1762 | internalformat => GL_ALPHA, |
|
|
1763 | format => GL_ALPHA; |
|
|
1764 | |
|
|
1765 | glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth}; |
|
|
1766 | |
|
|
1767 | glEnable GL_BLEND; |
|
|
1768 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1769 | glEnable GL_TEXTURE_2D; |
|
|
1770 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
|
|
1771 | |
|
|
1772 | glColor +($::CFG->{fow_intensity}) x 3, 1; |
|
|
1773 | $tex->draw_quad (0, 0, $w * 32, $h * 32); |
|
|
1774 | |
|
|
1775 | glDisable GL_TEXTURE_2D; |
|
|
1776 | glDisable GL_BLEND; |
|
|
1777 | } |
|
|
1778 | |
|
|
1779 | # HACK BEGIN |
|
|
1780 | { |
|
|
1781 | glTranslate -($sx0 - 32), -($sy0 - 32), 0;#remove |
|
|
1782 | my ($w, $h) = (250, 250); |
|
|
1783 | |
|
|
1784 | glEnable GL_BLEND; |
|
|
1785 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1786 | glEnable GL_TEXTURE_2D; |
|
|
1787 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
1788 | |
|
|
1789 | CFClient::Texture->new ( |
|
|
1790 | w => $w, |
|
|
1791 | h => $h, |
|
|
1792 | data => $::MAP->mapmap ($w, $h), |
|
|
1793 | type => GL_UNSIGNED_INT_8_8_8_8_REV |
|
|
1794 | )->draw_quad (100, 100); |
|
|
1795 | |
|
|
1796 | glDisable GL_TEXTURE_2D; |
|
|
1797 | glDisable GL_BLEND; |
|
|
1798 | } |
|
|
1799 | # HACK END |
|
|
1800 | } |
|
|
1801 | |
|
|
1802 | glEndList; |
|
|
1803 | } |
|
|
1804 | |
|
|
1805 | glPushMatrix; |
|
|
1806 | glCallList $self->{list}; |
|
|
1807 | glPopMatrix; |
|
|
1808 | |
|
|
1809 | if ($FOCUS != $self) { |
|
|
1810 | glColor 64/255, 64/255, 64/255; |
|
|
1811 | glLogicOp GL_AND; |
|
|
1812 | glEnable GL_COLOR_LOGIC_OP; |
|
|
1813 | glBegin GL_QUADS; |
|
|
1814 | glVertex 0, 0; |
|
|
1815 | glVertex 0, $::HEIGHT; |
|
|
1816 | glVertex $::WIDTH, $::HEIGHT; |
|
|
1817 | glVertex $::WIDTH, 0; |
|
|
1818 | glEnd; |
|
|
1819 | glDisable GL_COLOR_LOGIC_OP; |
|
|
1820 | } |
|
|
1821 | } |
|
|
1822 | |
|
|
1823 | my %DIR = ( |
|
|
1824 | SDLK_KP8, [1, "north"], |
|
|
1825 | SDLK_KP9, [2, "northeast"], |
|
|
1826 | SDLK_KP6, [3, "east"], |
|
|
1827 | SDLK_KP3, [4, "southeast"], |
|
|
1828 | SDLK_KP2, [5, "south"], |
|
|
1829 | SDLK_KP1, [6, "southwest"], |
|
|
1830 | SDLK_KP4, [7, "west"], |
|
|
1831 | SDLK_KP7, [8, "northwest"], |
|
|
1832 | |
|
|
1833 | SDLK_UP, [1, "north"], |
|
|
1834 | SDLK_RIGHT, [3, "east"], |
|
|
1835 | SDLK_DOWN, [5, "south"], |
|
|
1836 | SDLK_LEFT, [7, "west"], |
|
|
1837 | ); |
|
|
1838 | |
|
|
1839 | sub key_down { |
|
|
1840 | my ($self, $ev) = @_; |
|
|
1841 | |
|
|
1842 | my $mod = $ev->key_mod; |
|
|
1843 | my $sym = $ev->key_sym; |
|
|
1844 | |
|
|
1845 | if ($sym == SDLK_KP5) { |
|
|
1846 | $::CONN->user_send ("command stay fire"); |
|
|
1847 | } elsif ($sym == SDLK_a) { |
|
|
1848 | $::CONN->user_send ("command apply"); |
|
|
1849 | } elsif ($sym == SDLK_QUOTE) { |
|
|
1850 | $self->emit ('activate_console'); |
|
|
1851 | } elsif ($sym == SDLK_SLASH) { |
|
|
1852 | $self->emit ('activate_console' => '/'); |
|
|
1853 | } elsif (exists $DIR{$sym}) { |
|
|
1854 | if ($mod & KMOD_SHIFT) { |
|
|
1855 | $self->{shft}++; |
|
|
1856 | $::CONN->user_send ("command fire $DIR{$sym}[0]"); |
|
|
1857 | } elsif ($mod & KMOD_CTRL) { |
|
|
1858 | $self->{ctrl}++; |
|
|
1859 | $::CONN->user_send ("command run $DIR{$sym}[0]"); |
|
|
1860 | } else { |
|
|
1861 | $::CONN->user_send ("command $DIR{$sym}[1]"); |
|
|
1862 | } |
|
|
1863 | } |
|
|
1864 | } |
|
|
1865 | |
|
|
1866 | sub key_up { |
|
|
1867 | my ($self, $ev) = @_; |
|
|
1868 | |
|
|
1869 | my $mod = $ev->key_mod; |
|
|
1870 | my $sym = $ev->key_sym; |
|
|
1871 | |
|
|
1872 | if (!($mod & KMOD_SHIFT) && delete $self->{shft}) { |
|
|
1873 | $::CONN->user_send ("command fire_stop"); |
|
|
1874 | } |
|
|
1875 | if (!($mod & KMOD_CTRL ) && delete $self->{ctrl}) { |
|
|
1876 | $::CONN->user_send ("command run_stop"); |
|
|
1877 | } |
|
|
1878 | } |
|
|
1879 | |
|
|
1880 | ############################################################################# |
|
|
1881 | |
|
|
1882 | package CFClient::UI::Animator; |
1984 | package CFClient::UI::Animator; |
1883 | |
1985 | |
1884 | use SDL::OpenGL; |
1986 | use CFClient::OpenGL; |
1885 | |
1987 | |
1886 | our @ISA = CFClient::UI::Bin::; |
1988 | our @ISA = CFClient::UI::Bin::; |
1887 | |
1989 | |
1888 | sub moveto { |
1990 | sub moveto { |
1889 | my ($self, $x, $y) = @_; |
1991 | my ($self, $x, $y) = @_; |
… | |
… | |
1945 | sub toggle_flopper { |
2047 | sub toggle_flopper { |
1946 | my ($self) = @_; |
2048 | my ($self) = @_; |
1947 | |
2049 | |
1948 | # TODO: use animation |
2050 | # TODO: use animation |
1949 | if ($self->{state} = !$self->{state}) { |
2051 | if ($self->{state} = !$self->{state}) { |
1950 | $CFClient::UI::TOPLEVEL->add ($self->{other}); |
2052 | $CFClient::UI::ROOT->add ($self->{other}); |
1951 | $self->{other}->move ( |
2053 | $self->{other}->move ($self->coord2global (0, $self->{h})); |
1952 | ($::WIDTH - $self->{other}{w}) * 0.5, |
2054 | $self->emit ("open"); |
1953 | ($::HEIGHT - $self->{other}{h}) * 0.5, |
|
|
1954 | ); |
|
|
1955 | } else { |
2055 | } else { |
1956 | $CFClient::UI::TOPLEVEL->remove ($self->{other}); |
2056 | $CFClient::UI::ROOT->remove ($self->{other}); |
|
|
2057 | $self->emit ("close"); |
1957 | } |
2058 | } |
1958 | } |
|
|
1959 | |
2059 | |
1960 | ############################################################################# |
2060 | $self->emit (changed => $self->{state}); |
|
|
2061 | } |
1961 | |
2062 | |
|
|
2063 | ############################################################################# |
|
|
2064 | |
1962 | package CFClient::UI::Toplevel; |
2065 | package CFClient::UI::Root; |
1963 | |
2066 | |
1964 | our @ISA = CFClient::UI::Container::; |
2067 | our @ISA = CFClient::UI::Container::; |
1965 | |
2068 | |
1966 | use SDL::OpenGL; |
2069 | use CFClient::OpenGL; |
|
|
2070 | |
|
|
2071 | sub check_size { |
|
|
2072 | my ($self) = @_; |
|
|
2073 | |
|
|
2074 | $self->configure (0, 0, $::WITH, $::HEIGHT); |
|
|
2075 | } |
1967 | |
2076 | |
1968 | sub size_request { |
2077 | sub size_request { |
1969 | ($::WIDTH, $::HEIGHT) |
2078 | ($::WIDTH, $::HEIGHT) |
1970 | } |
2079 | } |
1971 | |
2080 | |
1972 | sub size_allocate { |
2081 | sub configure { |
1973 | my ($self, $x, $y, $w, $h) = @_; |
2082 | my ($self, $x, $y, $w, $h) = @_; |
1974 | |
2083 | |
1975 | $self->_size_allocate ($x, $y, $w, $h); |
2084 | $self->SUPER::configure ($x, $y, $w, $h); |
1976 | |
2085 | |
1977 | $_->size_allocate ($_->{x}, $_->{y}, $_->size_request) |
2086 | $_->configure ($_->{x}, $_->{y}, $_->size_request) |
1978 | for @{$self->{children}}; |
2087 | for @{$self->{children}}; |
1979 | } |
2088 | } |
1980 | |
2089 | |
1981 | sub translate { |
2090 | sub _topleft { |
1982 | my ($self, $x, $y) = @_; |
2091 | my ($self, $x, $y) = @_; |
1983 | |
2092 | |
1984 | ($x, $y) |
2093 | ($x, $y) |
1985 | } |
2094 | } |
1986 | |
2095 | |
1987 | sub update { |
2096 | sub update { |
1988 | my ($self) = @_; |
2097 | my ($self) = @_; |
1989 | |
2098 | |
1990 | $self->size_allocate (0, 0, $::WIDTH, $::HEIGHT); |
2099 | $self->check_size; |
1991 | ::refresh (); |
2100 | ::refresh (); |
1992 | } |
2101 | } |
1993 | |
2102 | |
1994 | sub add { |
2103 | sub add { |
1995 | my ($self, $widget) = @_; |
2104 | my ($self, $child) = @_; |
1996 | |
2105 | |
|
|
2106 | # integerize window positions |
|
|
2107 | $child->{x} = int $child->{x}; |
|
|
2108 | $child->{y} = int $child->{y}; |
|
|
2109 | |
1997 | $self->SUPER::add ($widget); |
2110 | $self->SUPER::add ($child); |
1998 | |
|
|
1999 | $widget->size_allocate ($widget->{x}, $widget->{y}, $widget->size_request); |
|
|
2000 | } |
2111 | } |
2001 | |
2112 | |
2002 | sub on_refresh { |
2113 | sub on_refresh { |
2003 | my ($self, $id, $cb) = @_; |
2114 | my ($self, $id, $cb) = @_; |
2004 | |
2115 | |
… | |
… | |
2027 | |
2138 | |
2028 | ############################################################################# |
2139 | ############################################################################# |
2029 | |
2140 | |
2030 | package CFClient::UI; |
2141 | package CFClient::UI; |
2031 | |
2142 | |
2032 | $TOPLEVEL = new CFClient::UI::Toplevel; |
2143 | $ROOT = new CFClient::UI::Root; |
2033 | |
2144 | |
2034 | 1 |
2145 | 1 |
2035 | |
2146 | |