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.125 by root, Mon Apr 17 20:52:15 2006 UTC vs.
Revision 1.151 by root, Sun Apr 23 00:57:39 2006 UTC

8use CFClient; 8use CFClient;
9 9
10our ($FOCUS, $HOVER, $GRAB); # various widgets 10our ($FOCUS, $HOVER, $GRAB); # various widgets
11 11
12our $ROOT; 12our $ROOT;
13our $TOOLTIP;
13our $BUTTON_STATE; 14our $BUTTON_STATE;
15
16sub check_tooltip {
17 if (!$GRAB) {
18 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) {
19 if (exists $widget->{tooltip}) {
20
21 if ($TOOLTIP->{owner} != $widget) {
22 $TOOLTIP->{owner} = $widget;
23 $TOOLTIP->set_text ($widget->{tooltip});
24 $TOOLTIP->move ($widget->coord2global ($widget->{w}, 0));
25 $TOOLTIP->show;
26 }
27
28 return;
29 }
30 }
31 }
32
33 $TOOLTIP->hide;
34 delete $TOOLTIP->{owner};
35}
14 36
15# class methods for events 37# class methods for events
16sub feed_sdl_key_down_event { 38sub feed_sdl_key_down_event {
17 $FOCUS->key_down ($_[0]) if $FOCUS; 39 $FOCUS->key_down ($_[0]) if $FOCUS;
18} 40}
21 $FOCUS->key_up ($_[0]) if $FOCUS; 43 $FOCUS->key_up ($_[0]) if $FOCUS;
22} 44}
23 45
24sub feed_sdl_button_down_event { 46sub feed_sdl_button_down_event {
25 my ($ev) = @_; 47 my ($ev) = @_;
26 my ($x, $y) = ($ev->motion_x, $ev->motion_y); 48 my ($x, $y) = ($ev->{x}, $ev->{y});
27 49
28 if (!$BUTTON_STATE) { 50 if (!$BUTTON_STATE) {
29 my $widget = $ROOT->find_widget ($x, $y); 51 my $widget = $ROOT->find_widget ($x, $y);
30 52
31 $GRAB = $widget; 53 $GRAB = $widget;
32 $GRAB->update if $GRAB; 54 $GRAB->update if $GRAB;
33 }
34 55
56 check_tooltip;
57 }
58
35 $BUTTON_STATE |= 1 << ($ev->button - 1); 59 $BUTTON_STATE |= 1 << ($ev->{button} - 1);
36 60
37 $GRAB->button_down ($ev, $GRAB->coord2local ($x, $y)) if $GRAB; 61 $GRAB->button_down ($ev, $GRAB->coord2local ($x, $y)) if $GRAB;
38} 62}
39 63
40sub feed_sdl_button_up_event { 64sub feed_sdl_button_up_event {
41 my ($ev) = @_; 65 my ($ev) = @_;
42 my ($x, $y) = ($ev->motion_x, $ev->motion_y); 66 my ($x, $y) = ($ev->{x}, $ev->{y});
43 67
44 my $widget = $GRAB || $ROOT->find_widget ($x, $y); 68 my $widget = $GRAB || $ROOT->find_widget ($x, $y);
45 69
46 $BUTTON_STATE &= ~(1 << ($ev->button - 1)); 70 $BUTTON_STATE &= ~(1 << ($ev->{button} - 1));
47 71
48 $GRAB->button_up ($ev, $GRAB->coord2local ($x, $y)) if $GRAB; 72 $GRAB->button_up ($ev, $GRAB->coord2local ($x, $y)) if $GRAB;
49 73
50 if (!$BUTTON_STATE) { 74 if (!$BUTTON_STATE) {
51 my $grab = $GRAB; undef $GRAB; 75 my $grab = $GRAB; undef $GRAB;
52 $grab->update if $grab; 76 $grab->update if $grab;
53 $GRAB->update if $GRAB; 77 $GRAB->update if $GRAB;
78
79 check_tooltip;
54 } 80 }
55} 81}
56 82
57sub feed_sdl_motion_event { 83sub feed_sdl_motion_event {
58 my ($ev) = @_; 84 my ($ev) = @_;
59 my ($x, $y) = ($ev->motion_x, $ev->motion_y); 85 my ($x, $y) = ($ev->{x}, $ev->{y});
60 86
61 my $widget = $GRAB || $ROOT->find_widget ($x, $y); 87 my $widget = $GRAB || $ROOT->find_widget ($x, $y);
62 88
63 if ($widget != $HOVER) { 89 if ($widget != $HOVER) {
64 my $hover = $HOVER; $HOVER = $widget; 90 my $hover = $HOVER; $HOVER = $widget;
65 91
66 $hover->update if $hover && $hover->{can_hover}; 92 $hover->update if $hover && $hover->{can_hover};
67 $HOVER->update if $HOVER && $HOVER->{can_hover}; 93 $HOVER->update if $HOVER && $HOVER->{can_hover};
94
95 check_tooltip;
68 } 96 }
69 97
70 $HOVER->mouse_motion ($ev, $HOVER->coord2local ($x, $y)) if $HOVER; 98 $HOVER->mouse_motion ($ev, $HOVER->coord2local ($x, $y)) if $HOVER;
71} 99}
72 100
87 115
88package CFClient::UI::Base; 116package CFClient::UI::Base;
89 117
90use strict; 118use strict;
91 119
92use SDL::OpenGL; 120use CFClient::OpenGL;
93 121
94sub new { 122sub new {
95 my $class = shift; 123 my $class = shift;
96 124
97 my $self = bless { 125 my $self = bless {
98 x => 0, 126 x => 0,
99 y => 0, 127 y => 0,
100 z => 0, 128 z => 0,
101 w => -1, 129 can_events => 1,
102 h => -1,
103 @_ 130 @_
104 }, $class; 131 }, $class;
105 132
106 for (keys %$self) { 133 for (keys %$self) {
107 if (/^connect_(.*)$/) { 134 if (/^connect_(.*)$/) {
110 } 137 }
111 138
112 $self 139 $self
113} 140}
114 141
142sub show {
143 my ($self) = @_;
144
145 return if $self->{parent};
146
147 $CFClient::UI::ROOT->add ($self);
148}
149
150sub hide {
151 my ($self) = @_;
152
153 return unless $self->{parent};
154
155 $self->{parent}->remove ($self);
156}
157
115sub move { 158sub move {
116 my ($self, $x, $y, $z) = @_; 159 my ($self, $x, $y, $z) = @_;
160
117 $self->{x} = int $x; 161 $self->{x} = int $x;
118 $self->{y} = int $y; 162 $self->{y} = int $y;
119 $self->{z} = $z if defined $z; 163 $self->{z} = $z if defined $z;
164
165 $self->update;
120} 166}
121 167
122sub needs_redraw { 168sub needs_redraw {
123 0 169 0
124} 170}
125 171
126sub size_request { 172sub size_request {
127 require Carp; 173 require Carp;
128 Carp::confess "size_request is abtract"; 174 Carp::confess "size_request is abstract";
129} 175}
130 176
131sub _size_allocate { 177sub configure {
132 my ($self, $x, $y, $w, $h) = @_; 178 my ($self, $x, $y, $w, $h) = @_;
133 179
180 if ($self->{aspect}) {
181 my $w2 = List::Util::min $w, int $h * $self->{aspect};
182 my $h2 = List::Util::min $h, int $w / $self->{aspect};
183
184 # use alignment to adjust x, y
185
186 $x += int +($w - $w2) * 0.5;
187 $y += int +($h - $h2) * 0.5;
188
189 ($w, $h) = ($w2, $h2);
190 }
191
192 if ($self->{x} != $x || $self->{y} != $y) {
134 $self->{x} = $x; 193 $self->{x} = $x;
135 $self->{y} = $y; 194 $self->{y} = $y;
195 $self->update;
196 }
136 197
137 return unless $self->{w} != $w || $self->{h} != $h; 198 if ($self->{w} != $w || $self->{h} != $h) {
138
139 $self->{w} = $w; 199 $self->{w} = $w;
140 $self->{h} = $h; 200 $self->{h} = $h;
141 201
202 $self->size_allocate ($w, $h);
203 $self->update;
142 1 204 }
143} 205}
144 206
145sub size_allocate { 207sub size_allocate {
146 my ($self, $x, $y, $w, $h) = @_; 208 # nothing to be done
147
148 $self->_size_allocate ($x, $y, $w, $h);
149} 209}
150 210
151# return top left coordinates 211# return top left coordinates
152sub _topleft { 212sub _topleft {
153 my ($self, $x, $y) = @_; 213 my ($self, $x, $y) = @_;
247} 307}
248 308
249sub find_widget { 309sub find_widget {
250 my ($self, $x, $y) = @_; 310 my ($self, $x, $y) = @_;
251 311
312 return () unless $self->{can_events};
313
252 return $self 314 return $self
253 if $x >= $self->{x} && $x < $self->{x} + $self->{w} 315 if $x >= $self->{x} && $x < $self->{x} + $self->{w}
254 && $y >= $self->{y} && $y < $self->{y} + $self->{h}; 316 && $y >= $self->{y} && $y < $self->{y} + $self->{h};
255 317
256 () 318 ()
263} 325}
264 326
265sub check_size { 327sub check_size {
266 my ($self) = @_; 328 my ($self) = @_;
267 329
330 return unless $self->{parent};
331
268 my ($w, $h) = $self->size_request; 332 my ($w, $h) = $self->size_request;
269 333
270 if ($w != $self->{req_w} || $h != $self->{req_h}) { 334 if ($w != $self->{req_w} || $h != $self->{req_h}) {
271 $self->{req_w} = $w; 335 $self->{req_w} = $w;
272 $self->{req_h} = $h; 336 $self->{req_h} = $h;
273 337
274 $self->{parent}->check_size 338 $self->{parent}->check_size;
275 if $self->{parent};
276 } 339 }
277} 340}
278 341
279sub update { 342sub update {
280 my ($self) = @_; 343 my ($self) = @_;
284} 347}
285 348
286sub connect { 349sub connect {
287 my ($self, $signal, $cb) = @_; 350 my ($self, $signal, $cb) = @_;
288 351
289 push @{ $self->{cb}{$signal} }, $cb; 352 push @{ $self->{signal_cb}{$signal} }, $cb;
290} 353}
291 354
292sub emit { 355sub emit {
293 my ($self, $signal, @args) = @_; 356 my ($self, $signal, @args) = @_;
294 357
358 for my $cb (@{$self->{signal_cb}{$signal} || []}) {
295 $_->($self, @args) 359 $cb->($self, @args);
296 for @{$self->{cb}{$signal} || []}; 360 }
297} 361}
298 362
299sub DESTROY { 363sub DESTROY {
300 my ($self) = @_; 364 my ($self) = @_;
301 365
307package CFClient::UI::DrawBG; 371package CFClient::UI::DrawBG;
308 372
309our @ISA = CFClient::UI::Base::; 373our @ISA = CFClient::UI::Base::;
310 374
311use strict; 375use strict;
312use SDL::OpenGL; 376use CFClient::OpenGL;
313 377
314sub new { 378sub new {
315 my $class = shift; 379 my $class = shift;
316 380
317 # range [value, low, high, page] 381 # range [value, low, high, page]
346 410
347package CFClient::UI::Empty; 411package CFClient::UI::Empty;
348 412
349our @ISA = CFClient::UI::Base::; 413our @ISA = CFClient::UI::Base::;
350 414
415sub new {
416 my ($class, %arg) = @_;
417 $class->SUPER::new (can_events => 0, %arg);
418}
419
351sub size_request { 420sub size_request {
352 (0, 0) 421 (0, 0)
353} 422}
354 423
355sub draw { } 424sub draw { }
363sub new { 432sub new {
364 my ($class, %arg) = @_; 433 my ($class, %arg) = @_;
365 434
366 my $children = delete $arg{children} || []; 435 my $children = delete $arg{children} || [];
367 436
368 my $self = $class->SUPER::new (children => [], %arg); 437 my $self = $class->SUPER::new (children => [], can_events => 0, %arg);
369 $self->add ($_) for @$children; 438 $self->add ($_) for @$children;
370 439
371 $self 440 $self
372} 441}
373 442
381 $self->{children} = [ 450 $self->{children} = [
382 sort { $a->{z} <=> $b->{z} } 451 sort { $a->{z} <=> $b->{z} }
383 @{$self->{children}}, $child 452 @{$self->{children}}, $child
384 ]; 453 ];
385 454
386 $self->{w} = $self->{h} = -1; 455 $child->check_size;
456}
457
458sub remove {
459 my ($self, $child) = @_;
460
461 delete $child->{parent};
462
463 $self->{children} = [ grep $_ != $child, @{ $self->{children} } ];
464
465 $self->check_size;
387 $self->update; 466 $self->update;
388}
389
390sub remove {
391 my ($self, $widget) = @_;
392
393 $self->{children} = [ grep $_ != $widget, @{ $self->{children} } ];
394
395 $self->check_size;
396} 467}
397 468
398sub find_widget { 469sub find_widget {
399 my ($self, $x, $y) = @_; 470 my ($self, $x, $y) = @_;
400 471
430 501
431 $class->SUPER::new (children => [$child], %arg) 502 $class->SUPER::new (children => [$child], %arg)
432} 503}
433 504
434sub add { 505sub add {
435 my ($self, $widget) = @_; 506 my ($self, $child) = @_;
436 507
437 $self->{children} = []; 508 $self->{children} = [];
438 509
439 $self->SUPER::add ($widget); 510 $self->SUPER::add ($child);
440} 511}
441 512
442sub remove { 513sub remove {
443 my ($self, $widget) = @_; 514 my ($self, $widget) = @_;
444 515
453sub size_request { 524sub size_request {
454 $_[0]{children}[0]->size_request 525 $_[0]{children}[0]->size_request
455} 526}
456 527
457sub size_allocate { 528sub size_allocate {
458 my ($self, $x, $y, $w, $h) = @_; 529 my ($self, $w, $h) = @_;
459 530
460 $self->_size_allocate ($x, $y, $w, $h) or return;
461
462 $self->{children}[0]->size_allocate (0, 0, $w, $h); 531 $self->{children}[0]->configure (0, 0, $w, $h);
463} 532}
464 533
465############################################################################# 534#############################################################################
466 535
467package CFClient::UI::Window; 536package CFClient::UI::Window;
468 537
469our @ISA = CFClient::UI::Bin::; 538our @ISA = CFClient::UI::Bin::;
470 539
471use SDL::OpenGL; 540use CFClient::OpenGL;
472 541
473sub new { 542sub new {
474 my ($class, %arg) = @_; 543 my ($class, %arg) = @_;
475 544
476 my $self = $class->SUPER::new (%arg); 545 my $self = $class->SUPER::new (%arg);
493 $self->child->draw; 562 $self->child->draw;
494 }; 563 };
495} 564}
496 565
497sub size_allocate { 566sub size_allocate {
498 my ($self, $x, $y, $w, $h) = @_; 567 my ($self, $w, $h) = @_;
499 568
500 $self->_size_allocate ($x, $y, $w, $h) or return;
501
502 $self->child->size_allocate (0, 0, $w, $h); 569 $self->child->configure (0, 0, $w, $h);
503 570
504 $self->render_chld; 571 $self->render_chld;
505} 572}
506 573
507sub _draw { 574sub _draw {
532sub new { die } 599sub new { die }
533 600
534sub size_request { 601sub size_request {
535 my ($self) = @_; 602 my ($self) = @_;
536 603
537 @$self{qw(child_w child_h)} = $self->child->size_request; 604 @$self{qw(child_w child_h)} = @{$self->child}{qw(req_w req_h)};
538 $self->child->size_allocate (0, 0, @$self{qw(child_w child_h)}); 605 $self->child->size_allocate (0, 0, @$self{qw(child_w child_h)});
539 606
540 @$self{qw(child_w child_h)} 607 @$self{qw(child_w child_h)}
541} 608}
542 609
543sub size_allocate {
544 my ($self, $x, $y, $w, $h) = @_;
545
546 $self->_size_allocate ($x, $y, $w, $h) or return;
547}
548
549sub _draw { 610sub _draw {
550 my ($self) = @_; 611 my ($self) = @_;
551 612
552 $self->{children}[1]->draw; 613 $self->{children}[1]->draw;
553} 614}
557 618
558package CFClient::UI::Frame; 619package CFClient::UI::Frame;
559 620
560our @ISA = CFClient::UI::Bin::; 621our @ISA = CFClient::UI::Bin::;
561 622
562use SDL::OpenGL; 623use CFClient::OpenGL;
563
564sub size_request {
565 my ($self) = @_;
566 my $chld = $self->child
567 or return (0, 0);
568
569 $chld->move (2, 2);
570
571 map { $_ + 4 } $chld->size_request;
572}
573
574sub size_allocate {
575 my ($self, $x, $y, $w, $h) = @_;
576
577 $self->_size_allocate ($x, $y, $w, $h) or return;
578
579 $self->child->size_allocate (2, 2, $w - 4, $h - 4);
580}
581
582sub _draw {
583 my ($self) = @_;
584
585 my $chld = $self->child;
586
587 my ($w, $h) = $chld->size_request;
588
589 glBegin GL_QUADS;
590 glColor 0, 0, 0;
591 glVertex 0 , 0;
592 glVertex 0 , $h + 4;
593 glVertex $w + 4 , $h + 4;
594 glVertex $w + 4 , 0;
595 glEnd;
596
597 $chld->draw;
598}
599
600#############################################################################
601
602package CFClient::UI::FancyFrame;
603
604our @ISA = CFClient::UI::Bin::;
605
606use SDL::OpenGL;
607
608my @tex =
609 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
610 qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png);
611 624
612sub new { 625sub new {
613 my $class = shift; 626 my $class = shift;
614 627
615 # TODO: user_x, user_y, overwrite moveto?
616
617 $class->SUPER::new ( 628 my $self = $class->SUPER::new (
618 bg => [1, 1, 1, 1], 629 bg => [1, 1, 1, 1],
619 border_bg => [1, 1, 1, 1], 630 border_bg => [1, 1, 1, 1],
620 border => int $::FONTSIZE * 0.8, 631 border => 0.8,
621 @_ 632 @_
633 );
634
635 $self
636}
637
638sub set_size {
639 my ($self, $w, $h) = @_;
640 $self->{req_w} = $w;
641 $self->{req_h} = $h;
642 $self->check_size;
643}
644
645sub size_request {
646 my ($self) = @_;
647 ($self->{req_w}, $self->{req_h})
648}
649
650sub size_allocate {
651 my ($self, $w, $h) = @_;
652 $self->{w} = $w;
653 $self->{h} = $h;
654 $self->child->configure (0, 0, $w, $h);
655}
656
657sub _draw {
658 my ($self) = @_;
659
660 my ($w, $h) = ($self->{w}, $self->{h});
661
662 glEnable GL_BLEND;
663 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
664 glEnable GL_TEXTURE_2D;
665 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
666
667# glBegin GL_QUADS;
668# glColor 0, 0, 0, 0;
669# glVertex 0 , 0;
670# glVertex 0 , $h;
671# glVertex $w, $h;
672# glVertex $w, 0;
673# glEnd;
674
675
676 $self->child->draw;
677 glDisable GL_BLEND;
678 glDisable GL_TEXTURE_2D;
679}
680
681#############################################################################
682
683package CFClient::UI::FancyFrame;
684
685our @ISA = CFClient::UI::Bin::;
686
687use CFClient::OpenGL;
688
689my @tex =
690 map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 }
691 qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png);
692
693sub new {
694 my $class = shift;
695
696 # TODO: user_x, user_y, overwrite moveto?
697
698 my $self = $class->SUPER::new (
699 bg => [1, 1, 1, 1],
700 border_bg => [1, 1, 1, 1],
701 border => 0.8,
702 can_events => 1,
703 @_
704 );
705
706 $self->{title} &&= new CFClient::UI::Label
707 align => 0,
708 valign => 1,
709 text => $self->{title},
710 fontsize => 1;
711
712 $self
713}
714
715sub border {
716 int $_[0]{border} * $::FONTSIZE
717}
718
719sub size_request {
720 my ($self) = @_;
721
722 return ($self->{user_w}, $self->{user_h}) if $self->{user_w} && $self->{user_h};
723
724 my ($w, $h) = $self->SUPER::size_request;
725
726 (
727 $w + $self->border * 2,
728 $h + $self->border * 2,
622 ) 729 )
623} 730}
624 731
625sub size_request {
626 my ($self) = @_;
627
628 return ($self->{user_w}, $self->{user_h}) if $self->{user_w} && $self->{user_h};
629
630 my ($w, $h) = $self->SUPER::size_request;
631
632 (
633 $w + $self->{border} * 2,
634 $h + $self->{border} * 2,
635 )
636}
637
638sub size_allocate { 732sub size_allocate {
639 my ($self, $x, $y, $w, $h) = @_; 733 my ($self, $w, $h) = @_;
640 734
641 $self->_size_allocate ($x, $y, $w, $h) or return;
642
643 $h -= List::Util::max 0, $self->{border} * 2; 735 $h -= List::Util::max 0, $self->border * 2;
644 $w -= List::Util::max 0, $self->{border} * 2; 736 $w -= List::Util::max 0, $self->border * 2;
645 737
738 $self->{title}->configure ($self->border, $self->border - $::FONTSIZE * 2, $w, $::FONTSIZE * 2)
739 if $self->{title};
740
646 $self->child->size_allocate ($self->{border}, $self->{border}, $w, $h); 741 $self->child->configure ($self->border, $self->border, $w, $h);
647} 742}
648 743
649sub button_down { 744sub button_down {
650 my ($self, $ev, $x, $y) = @_; 745 my ($self, $ev, $x, $y) = @_;
651 746
747 my $border = $self->border;
748
652 if ($x < $self->{w} && $x >= $self->{w} - $self->{border} 749 if ($x < $self->{w} && $x >= $self->{w} - $border
653 && $y < $self->{h} && $y >= $self->{h} - $self->{border}) { 750 && $y < $self->{h} && $y >= $self->{h} - $border) {
654 751
655 my ($ox, $oy) = ($ev->button_x, $ev->button_y); 752 my ($ox, $oy) = ($ev->{x}, $ev->{y});
656 my ($bw, $bh) = ($self->{w}, $self->{h}); 753 my ($bw, $bh) = ($self->{w}, $self->{h});
657 754
658 $self->{motion} = sub { 755 $self->{motion} = sub {
659 my ($ev, $x, $y) = @_; 756 my ($ev, $x, $y) = @_;
660 757
661 ($x, $y) = ($ev->motion_x, $ev->motion_y); 758 ($x, $y) = ($ev->{x}, $ev->{y});
662 759
663 $self->{user_w} = $bw + $x - $ox; 760 $self->{user_w} = $bw + $x - $ox;
664 $self->{user_h} = $bh + $y - $oy; 761 $self->{user_h} = $bh + $y - $oy;
665 $self->update; 762 $self->check_size;
666 }; 763 };
667 764
668 } elsif ($x >= 0 && $x < $self->{w} 765 } elsif ($x >= 0 && $x < $self->{w}
669 && $y >= 0 && $y < $self->{border}) { 766 && $y >= 0 && $y < $border) {
670 767
671 my ($ox, $oy) = ($ev->button_x, $ev->button_y); 768 my ($ox, $oy) = ($ev->{x}, $ev->{y});
672 my ($bx, $by) = ($self->{x}, $self->{y}); 769 my ($bx, $by) = ($self->{x}, $self->{y});
673 770
674 $self->{motion} = sub { 771 $self->{motion} = sub {
675 my ($ev, $x, $y) = @_; 772 my ($ev, $x, $y) = @_;
676 773
677 ($x, $y) = ($ev->motion_x, $ev->motion_y); 774 ($x, $y) = ($ev->{x}, $ev->{y});
678 775
679 $self->move ($bx + $x - $ox, $by + $y - $oy); 776 $self->move ($bx + $x - $ox, $by + $y - $oy);
680 $self->update; 777 $self->update;
681 }; 778 };
682 } 779 }
703 glEnable GL_BLEND; 800 glEnable GL_BLEND;
704 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 801 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
705 glEnable GL_TEXTURE_2D; 802 glEnable GL_TEXTURE_2D;
706 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 803 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
707 804
805 my $border = $self->border;
806
708 glColor @{ $self->{border_bg} }; 807 glColor @{ $self->{border_bg} };
709 $tex[1]->draw_quad (0, 0, $w, $self->{border}); 808 $tex[1]->draw_quad (0, 0, $w, $border);
710 $tex[3]->draw_quad (0, $self->{border}, $self->{border}, $ch); 809 $tex[3]->draw_quad (0, $border, $border, $ch);
711 $tex[2]->draw_quad ($w - $self->{border}, $self->{border}, $self->{border}, $ch); 810 $tex[2]->draw_quad ($w - $border, $border, $border, $ch);
712 $tex[4]->draw_quad (0, $h - $self->{border}, $w, $self->{border}); 811 $tex[4]->draw_quad (0, $h - $border, $w, $border);
713 812
714 my $bg = $tex[0]; 813 my $bg = $tex[0];
715 814
716 # TODO: repeat texture not scale 815 # TODO: repeat texture not scale
717 my $rep_x = $cw / $bg->{w}; 816 my $rep_x = $cw / $bg->{w};
720 glColor @{ $self->{bg} }; 819 glColor @{ $self->{bg} };
721 820
722 $bg->{s} = $rep_x; 821 $bg->{s} = $rep_x;
723 $bg->{t} = $rep_y; 822 $bg->{t} = $rep_y;
724 $bg->{wrap_mode} = 1; 823 $bg->{wrap_mode} = 1;
725 $bg->draw_quad ($self->{border}, $self->{border}, $cw, $ch); 824 $bg->draw_quad ($border, $border, $cw, $ch);
726 825
727 glDisable GL_TEXTURE_2D; 826 glDisable GL_TEXTURE_2D;
728 glDisable GL_BLEND; 827 glDisable GL_BLEND;
729 828
829 $self->{title}->draw if $self->{title};
730 $self->child->draw; 830 $self->child->draw;
731} 831}
732 832
733############################################################################# 833#############################################################################
734 834
736 836
737our @ISA = CFClient::UI::Base::; 837our @ISA = CFClient::UI::Base::;
738 838
739use List::Util qw(max sum); 839use List::Util qw(max sum);
740 840
741use SDL::OpenGL; 841use CFClient::OpenGL;
742 842
743sub new { 843sub new {
744 my $class = shift; 844 my $class = shift;
745 845
746 $class->SUPER::new ( 846 $class->SUPER::new (
753 my ($self, $x, $y, $child) = @_; 853 my ($self, $x, $y, $child) = @_;
754 854
755 $child->set_parent ($self); 855 $child->set_parent ($self);
756 $self->{children}[$y][$x] = $child; 856 $self->{children}[$y][$x] = $child;
757 857
758 $self->{w} = $self->{h} = -1; 858 $child->check_size;
759 $self->update;
760} 859}
761 860
762# TODO: move to container class maybe? send childs a signal on removal? 861# TODO: move to container class maybe? send childs a signal on removal?
763sub clear { 862sub clear {
764 my ($self) = @_; 863 my ($self) = @_;
777 or next; 876 or next;
778 877
779 for my $x (0 .. $#$row) { 878 for my $x (0 .. $#$row) {
780 my $widget = $row->[$x] 879 my $widget = $row->[$x]
781 or next; 880 or next;
782 my ($w, $h) = $widget->size_request; 881 my ($w, $h) = @$widget{qw(req_w req_h)};
783 882
784 $w[$x] = max $w[$x], $w; 883 $w[$x] = max $w[$x], $w;
785 $h[$y] = max $h[$y], $h; 884 $h[$y] = max $h[$y], $h;
786 } 885 }
787 } 886 }
799 (sum @$hs), 898 (sum @$hs),
800 ) 899 )
801} 900}
802 901
803sub size_allocate { 902sub size_allocate {
804 my ($self, $x, $y, $w, $h) = @_; 903 my ($self, $w, $h) = @_;
805
806 $self->_size_allocate ($x, $y, $w, $h) or return;
807 904
808 my ($ws, $hs) = $self->get_wh; 905 my ($ws, $hs) = $self->get_wh;
809 906
810 my $req_w = sum @$ws; 907 my $req_w = sum @$ws;
811 my $req_h = sum @$hs; 908 my $req_h = sum @$hs;
833 930
834 for my $c (0 .. $#$row) { 931 for my $c (0 .. $#$row) {
835 my $col_w = $ws->[$c]; 932 my $col_w = $ws->[$c];
836 933
837 if (my $widget = $row->[$c]) { 934 if (my $widget = $row->[$c]) {
838 $widget->size_allocate ($x, $y, $col_w, $row_h); 935 $widget->configure ($x, $y, $col_w, $row_h);
839 } 936 }
840 937
841 $x += $col_w; 938 $x += $col_w;
842 } 939 }
843 940
888 (List::Util::max map $_->[1], @alloc), 985 (List::Util::max map $_->[1], @alloc),
889 ) 986 )
890} 987}
891 988
892sub size_allocate { 989sub size_allocate {
893 my ($self, $x, $y, $w, $h) = @_; 990 my ($self, $w, $h) = @_;
894
895 $self->_size_allocate ($x, $y, $w, $h) or return;
896 991
897 ($h, $w) = ($w, $h); 992 ($h, $w) = ($w, $h);
898 993
899 my $children = $self->{children}; 994 my $children = $self->{children};
900 995
901 my @h = map +($_->size_request)[0], @$children; 996 my @h = map $_->{req_w}, @$children;
902 997
903 my $req_h = List::Util::sum @h; 998 my $req_h = List::Util::sum @h;
904 999
905 if ($req_h > $h) { 1000 if ($req_h > $h) {
906 # ah well, not enough space 1001 # ah well, not enough space
922 1017
923 my $y = 0; 1018 my $y = 0;
924 for (0 .. $#$children) { 1019 for (0 .. $#$children) {
925 my $child = $children->[$_]; 1020 my $child = $children->[$_];
926 my $h = $h[$_]; 1021 my $h = $h[$_];
927 $child->size_allocate ($y, 0, $h, $w); 1022 $child->configure ($y, 0, $h, $w);
928 1023
929 $y += $h; 1024 $y += $h;
930 } 1025 }
931 1026
932 1 1027 1
950 (List::Util::sum map $_->[1], @alloc), 1045 (List::Util::sum map $_->[1], @alloc),
951 ) 1046 )
952} 1047}
953 1048
954sub size_allocate { 1049sub size_allocate {
955 my ($self, $x, $y, $w, $h) = @_; 1050 my ($self, $w, $h) = @_;
956
957 $self->_size_allocate ($x, $y, $w, $h) or return;
958 1051
959 my $children = $self->{children}; 1052 my $children = $self->{children};
960 1053
961 my @h = map +($_->size_request)[1], @$children; 1054 my @h = map $_->{req_h}, @$children;
962 1055
963 my $req_h = List::Util::sum @h; 1056 my $req_h = List::Util::sum @h;
964 1057
965 if ($req_h > $h) { 1058 if ($req_h > $h) {
966 # ah well, not enough space 1059 # ah well, not enough space
980 1073
981 my $y = 0; 1074 my $y = 0;
982 for (0 .. $#$children) { 1075 for (0 .. $#$children) {
983 my $child = $children->[$_]; 1076 my $child = $children->[$_];
984 my $h = $h[$_]; 1077 my $h = $h[$_];
985 $child->size_allocate (0, $y, $w, $h); 1078 $child->configure (0, $y, $w, $h);
986 1079
987 $y += $h; 1080 $y += $h;
988 } 1081 }
989 1082
990 1 1083 1
994 1087
995package CFClient::UI::Label; 1088package CFClient::UI::Label;
996 1089
997our @ISA = CFClient::UI::Base::; 1090our @ISA = CFClient::UI::Base::;
998 1091
999use SDL::OpenGL; 1092use CFClient::OpenGL;
1000 1093
1001sub new { 1094sub new {
1002 my ($class, %arg) = @_; 1095 my ($class, %arg) = @_;
1003 1096
1004 my $self = $class->SUPER::new ( 1097 my $self = $class->SUPER::new (
1005 fg => [1, 1, 1], 1098 fg => [1, 1, 1],
1006 fontsize => $::FONTSIZE, 1099 fontsize => 1,
1007 text => "", 1100 text => "",
1008 align => -1, 1101 align => -1,
1009 valign => -1, 1102 valign => -1,
1010 padding => 2, 1103 padding => 2,
1011 layout => new CFClient::Layout, 1104 layout => new CFClient::Layout,
1105 can_events => 0,
1012 %arg 1106 %arg
1013 ); 1107 );
1014 1108
1015 $self->{xxx}++ if $self->{text} eq "Client Setup" && $self->{align};#d# 1109 if (exists $self->{template}) {
1110 my $layout = new CFClient::Layout;
1111 $layout->set_text (delete $self->{template});
1112 $self->{template} = $layout;
1113 }
1016 1114
1017 $self->set_text (delete $self->{text}) if exists $self->{text}; 1115 $self->set_text (delete $self->{text}) if exists $self->{text};
1018 $self->set_markup (delete $self->{markup}) if exists $self->{markup}; 1116 $self->set_markup (delete $self->{markup}) if exists $self->{markup};
1019 1117
1020 $self 1118 $self
1034 my ($self, $text) = @_; 1132 my ($self, $text) = @_;
1035 1133
1036 $self->{layout}->set_text ($text); 1134 $self->{layout}->set_text ($text);
1037 1135
1038 delete $self->{texture}; 1136 delete $self->{texture};
1137 $self->check_size;
1039 $self->update; 1138 $self->update;
1040} 1139}
1041 1140
1042sub set_markup { 1141sub set_markup {
1043 my ($self, $markup) = @_; 1142 my ($self, $markup) = @_;
1044 1143
1045 $self->{layout}->set_markup ($markup); 1144 $self->{layout}->set_markup ($markup);
1046 1145
1047 delete $self->{texture}; 1146 delete $self->{texture};
1147 $self->check_size;
1048 $self->update; 1148 $self->update;
1049} 1149}
1050 1150
1051sub size_request { 1151sub size_request {
1052 my ($self) = @_; 1152 my ($self) = @_;
1053 1153
1054 $self->{layout}->set_width; 1154 $self->{layout}->set_width;
1055 $self->{layout}->set_height ($self->{fontsize}); 1155 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE);
1056 1156
1057 my ($w, $h) = $self->{layout}->size; 1157 my ($w, $h) = $self->{layout}->size;
1158
1159 if (exists $self->{template}) {
1160 $self->{template}->set_height ($self->{fontsize} * $::FONTSIZE);
1161
1162 my ($w2, $h2) = $self->{template}->size;
1163
1164 $w = List::Util::max $w, $w2;
1165 $h = List::Util::max $h, $h2;
1166 }
1058 1167
1059 ( 1168 (
1060 $w + $self->{padding} * 2, 1169 $w + $self->{padding} * 2,
1061 $h + $self->{padding} * 2, 1170 $h + $self->{padding} * 2,
1062 ) 1171 )
1063} 1172}
1064 1173
1065sub size_allocate { 1174sub size_allocate {
1066 my ($self, $x, $y, $w, $h) = @_; 1175 my ($self, $w, $h) = @_;
1067
1068 $self->_size_allocate ($x, $y, $w, $h) or return;
1069 1176
1070 delete $self->{texture}; 1177 delete $self->{texture};
1071} 1178}
1072 1179
1073sub update { 1180sub set_fontsize {
1074 my ($self) = @_; 1181 my ($self, $fontsize) = @_;
1075 1182
1076 delete $self->{texture}; 1183 $self->{fontsize} = $fontsize;
1077 $self->SUPER::update; 1184 $self->check_size;
1078} 1185}
1079 1186
1080sub _draw { 1187sub _draw {
1081 my ($self) = @_; 1188 my ($self) = @_;
1082 1189
1083 my $tex = $self->{texture} ||= do { 1190 my $tex = $self->{texture} ||= do {
1084 $self->{layout}->set_width ($self->{w}); 1191 $self->{layout}->set_width ($self->{w});
1085 $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize}); 1192 $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize} * $::FONTSIZE);
1086 new_from_layout CFClient::Texture $self->{layout} 1193 new_from_layout CFClient::Texture $self->{layout}
1087 }; 1194 };
1088 1195
1089 glEnable GL_BLEND; 1196 glEnable GL_BLEND;
1090 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 1197 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1115 1222
1116package CFClient::UI::EntryBase; 1223package CFClient::UI::EntryBase;
1117 1224
1118our @ISA = CFClient::UI::Label::; 1225our @ISA = CFClient::UI::Label::;
1119 1226
1120use SDL; 1227use CFClient::OpenGL;
1121use SDL::OpenGL;
1122 1228
1123sub new { 1229sub new {
1124 my $class = shift; 1230 my $class = shift;
1125 1231
1126 $class->SUPER::new ( 1232 $class->SUPER::new (
1129 active_bg => [1, 1, 1, 0.5], 1235 active_bg => [1, 1, 1, 0.5],
1130 active_fg => [0, 0, 0], 1236 active_fg => [0, 0, 0],
1131 can_hover => 1, 1237 can_hover => 1,
1132 can_focus => 1, 1238 can_focus => 1,
1133 valign => 0, 1239 valign => 0,
1240 can_events => 1,
1134 @_ 1241 @_
1135 ) 1242 )
1136} 1243}
1137 1244
1138sub _set_text { 1245sub _set_text {
1140 1247
1141 delete $self->{cur_h}; 1248 delete $self->{cur_h};
1142 1249
1143 return if $self->{text} eq $text; 1250 return if $self->{text} eq $text;
1144 1251
1252 delete $self->{texture};
1253
1145 $self->{last_activity} = $::NOW; 1254 $self->{last_activity} = $::NOW;
1146 $self->{text} = $text; 1255 $self->{text} = $text;
1147 1256
1148 $text =~ s/./*/g if $self->{hidden}; 1257 $text =~ s/./*/g if $self->{hidden};
1149 $self->{layout}->set_text ("$text "); 1258 $self->{layout}->set_text ("$text ");
1162 1271
1163 ($w + 1, $h) # add 1 for cursor 1272 ($w + 1, $h) # add 1 for cursor
1164} 1273}
1165 1274
1166sub size_allocate { 1275sub size_allocate {
1167 my ($self, $x, $y, $w, $h) = @_; 1276 my ($self, $w, $h) = @_;
1168 1277
1169 $self->SUPER::size_allocate ($x, $y, $w, $h) or return; 1278 $self->_set_text (delete $self->{text});#d# don't check for == inside _set_text
1170
1171 $self->_set_text ($self->{text});
1172} 1279}
1173 1280
1174sub set_text { 1281sub set_text {
1175 my ($self, $text) = @_; 1282 my ($self, $text) = @_;
1176 1283
1180} 1287}
1181 1288
1182sub key_down { 1289sub key_down {
1183 my ($self, $ev) = @_; 1290 my ($self, $ev) = @_;
1184 1291
1185 my $mod = $ev->key_mod; 1292 my $mod = $ev->{mod};
1186 my $sym = $ev->key_sym; 1293 my $sym = $ev->{sym};
1187
1188 my $uni = $ev->key_unicode; 1294 my $uni = $ev->{unicode};
1189 1295
1190 my $text = $self->get_text; 1296 my $text = $self->get_text;
1191 1297
1192 if ($sym == SDLK_BACKSPACE) { 1298 if ($sym == 8) {
1193 substr $text, --$self->{cursor}, 1, "" if $self->{cursor}; 1299 substr $text, --$self->{cursor}, 1, "" if $self->{cursor};
1194 } elsif ($sym == SDLK_DELETE) { 1300 } elsif ($sym == 127) {
1195 substr $text, $self->{cursor}, 1, ""; 1301 substr $text, $self->{cursor}, 1, "";
1196 } elsif ($sym == SDLK_LEFT) { 1302 } elsif ($sym == CFClient::SDLK_LEFT) {
1197 --$self->{cursor} if $self->{cursor}; 1303 --$self->{cursor} if $self->{cursor};
1198 } elsif ($sym == SDLK_RIGHT) { 1304 } elsif ($sym == CFClient::SDLK_RIGHT) {
1199 ++$self->{cursor} if $self->{cursor} < length $self->{text}; 1305 ++$self->{cursor} if $self->{cursor} < length $self->{text};
1200 } elsif ($sym == SDLK_HOME) { 1306 } elsif ($sym == CFClient::SDLK_HOME) {
1201 $self->{cursor} = 0; 1307 $self->{cursor} = 0;
1202 } elsif ($sym == SDLK_END) { 1308 } elsif ($sym == CFClient::SDLK_END) {
1203 $self->{cursor} = length $text; 1309 $self->{cursor} = length $text;
1204 } elsif ($sym == SDLK_ESCAPE) { 1310 } elsif ($sym == 27) {
1205 $self->emit ('escape'); 1311 $self->emit ('escape');
1206 } elsif ($uni) { 1312 } elsif ($uni) {
1207 substr $text, $self->{cursor}++, 0, chr $uni; 1313 substr $text, $self->{cursor}++, 0, chr $uni;
1208 } 1314 }
1209 1315
1284 1390
1285package CFClient::UI::Entry; 1391package CFClient::UI::Entry;
1286 1392
1287our @ISA = CFClient::UI::EntryBase::; 1393our @ISA = CFClient::UI::EntryBase::;
1288 1394
1289use SDL; 1395use CFClient::OpenGL;
1290use SDL::OpenGL;
1291 1396
1292sub key_down { 1397sub key_down {
1293 my ($self, $ev) = @_; 1398 my ($self, $ev) = @_;
1294 1399
1295 my $sym = $ev->key_sym; 1400 my $sym = $ev->{sym};
1296 1401
1297 if ($sym == SDLK_RETURN) { 1402 if ($sym == 13) {
1298 $self->emit (activate => $self->get_text); 1403 $self->emit (activate => $self->get_text);
1299 $self->update; 1404 $self->update;
1300 1405
1301 } else { 1406 } else {
1302 $self->SUPER::key_down ($ev); 1407 $self->SUPER::key_down ($ev);
1308 1413
1309package CFClient::UI::Button; 1414package CFClient::UI::Button;
1310 1415
1311our @ISA = CFClient::UI::Label::; 1416our @ISA = CFClient::UI::Label::;
1312 1417
1313use SDL; 1418use CFClient::OpenGL;
1314use SDL::OpenGL;
1315 1419
1316my @tex = 1420my @tex =
1317 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } 1421 map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 }
1318 qw(b1_button_active.png); 1422 qw(b1_button_active.png);
1319 1423
1320sub new { 1424sub new {
1321 my $class = shift; 1425 my $class = shift;
1322 1426
1324 padding => 4, 1428 padding => 4,
1325 fg => [1, 1, 1], 1429 fg => [1, 1, 1],
1326 bg => [1, 1, 1, 0.2], 1430 bg => [1, 1, 1, 0.2],
1327 active_fg => [0, 0, 1], 1431 active_fg => [0, 0, 1],
1328 can_hover => 1, 1432 can_hover => 1,
1433 align => 0,
1434 valign => 0,
1435 can_events => 1,
1329 @_ 1436 @_
1330 ) 1437 )
1331} 1438}
1332 1439
1333sub button_up { 1440sub button_up {
1367package CFClient::UI::CheckBox; 1474package CFClient::UI::CheckBox;
1368 1475
1369our @ISA = CFClient::UI::DrawBG::; 1476our @ISA = CFClient::UI::DrawBG::;
1370 1477
1371my @tex = 1478my @tex =
1372 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } 1479 map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 }
1373 qw(c1_checkbox_bg.png c1_checkbox_active.png); 1480 qw(c1_checkbox_bg.png c1_checkbox_active.png);
1374 1481
1375use SDL; 1482use CFClient::OpenGL;
1376use SDL::OpenGL;
1377 1483
1378sub new { 1484sub new {
1379 my $class = shift; 1485 my $class = shift;
1380 1486
1381 $class->SUPER::new ( 1487 $class->SUPER::new (
1392 my ($self) = @_; 1498 my ($self) = @_;
1393 1499
1394 ($self->{padding} * 2 + 6) x 2 1500 ($self->{padding} * 2 + 6) x 2
1395} 1501}
1396 1502
1397sub size_allocate {
1398 my ($self, $x, $y, $w, $h) = @_;
1399
1400 $self->_size_allocate ($x, $y, $w, $h) or return;
1401}
1402
1403sub button_down { 1503sub button_down {
1404 my ($self, $ev, $x, $y) = @_; 1504 my ($self, $ev, $x, $y) = @_;
1405 1505
1406 if ($x >= $self->{padding} && $x < $self->{w} - $self->{padding} 1506 if ($x >= $self->{padding} && $x < $self->{w} - $self->{padding}
1407 && $y >= $self->{padding} && $y < $self->{h} - $self->{padding}) { 1507 && $y >= $self->{padding} && $y < $self->{h} - $self->{padding}) {
1433 glDisable GL_BLEND; 1533 glDisable GL_BLEND;
1434} 1534}
1435 1535
1436############################################################################# 1536#############################################################################
1437 1537
1438package CFClient::UI::VGauge; 1538package CFClient::UI::Image;
1439 1539
1440our @ISA = CFClient::UI::Base::; 1540our @ISA = CFClient::UI::Base::;
1441 1541
1442use SDL::OpenGL; 1542use CFClient::OpenGL;
1543use Carp qw/confess/;
1443 1544
1444my %tex = ( 1545our %loaded_images;
1445 food => [
1446 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1447 qw/g1_food_gauge_empty.png g1_food_gauge_full.png/
1448 ],
1449 grace => [
1450 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1451 qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png/
1452 ],
1453 hp => [
1454 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1455 qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/
1456 ],
1457 mana => [
1458 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1459 qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png/
1460 ],
1461);
1462 1546
1463# eg. VGauge->new (gauge => 'food'), default gauge: food
1464sub new { 1547sub new {
1465 my $class = shift; 1548 my $class = shift;
1466 1549
1467 my $self = $class->SUPER::new (gauge => 'food', @_); 1550 my $self = $class->SUPER::new (can_events => 0, @_);
1551
1552 $self->{image} or confess "Image has 'image' not set. This is a fatal error!";
1553
1554 $loaded_images{$self->{image}} ||=
1555 new_from_file CFClient::Texture CFClient::find_rcfile $self->{image}, mipmap => 1;
1556
1557 my $tex = $self->{tex} = $loaded_images{$self->{image}};
1558
1559 Scalar::Util::weaken $loaded_images{$self->{image}};
1560
1561 $self->{aspect} = $tex->{w} / $tex->{h};
1468 1562
1469 $self 1563 $self
1470} 1564}
1471 1565
1472sub size_request { 1566sub size_request {
1473 my ($self) = @_; 1567 my ($self) = @_;
1474 1568
1475 ($self->{w}, $self->{h}) 1569 ($self->{tex}->{w}, $self->{tex}->{h})
1476}
1477
1478sub set_max {
1479 my ($self, $max) = @_;
1480 $self->{max_val} = $max;
1481}
1482
1483sub set_value {
1484 my ($self, $val, $max) = @_;
1485
1486 $self->set_max ($max)
1487 if defined $max;
1488
1489 $max = $self->{max_val};
1490 $self->{val} = $val;
1491
1492 $self->update;
1493} 1570}
1494 1571
1495sub _draw { 1572sub _draw {
1496 my ($self) = @_; 1573 my ($self) = @_;
1497 1574
1498 my $tex = $tex{$self->{gauge}}; 1575 my $tex = $self->{tex};
1499 1576
1500 my ($w, $h) = ($self->{w}, $self->{h}); 1577 my ($w, $h) = ($self->{w}, $self->{h});
1501 1578
1502 my $ycut = $self->{val} / ($self->{max_val} || 1); 1579 if ($self->{rot90}) {
1503 $ycut = 1 if $self->{val} > $self->{max_val}; 1580 glRotate 90, 0, 0, 1;
1581 glTranslate 0, -$self->{w}, 0;
1504 1582
1505 my $t1 = $tex->[0]; 1583 ($w, $h) = ($h, $w);
1506 my $t2 = $tex->[1]; 1584 }
1507 1585
1508 glEnable GL_BLEND; 1586 glEnable GL_BLEND;
1509 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 1587 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1510 glEnable GL_TEXTURE_2D; 1588 glEnable GL_TEXTURE_2D;
1511 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 1589 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1512 1590
1591 $tex->draw_quad (0, 0, $w, $h);
1592
1593 glDisable GL_BLEND;
1594 glDisable GL_TEXTURE_2D;
1595}
1596
1597#############################################################################
1598
1599package CFClient::UI::VGauge;
1600
1601our @ISA = CFClient::UI::Base::;
1602
1603use CFClient::OpenGL;
1604
1605my %tex = (
1606 food => [
1607 map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 }
1608 qw/g1_food_gauge_empty.png g1_food_gauge_full.png/
1609 ],
1610 grace => [
1611 map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 }
1612 qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png/
1613 ],
1614 hp => [
1615 map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 }
1616 qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/
1617 ],
1618 mana => [
1619 map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 }
1620 qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png/
1621 ],
1622);
1623
1624# eg. VGauge->new (gauge => 'food'), default gauge: food
1625sub new {
1626 my $class = shift;
1627
1628 my $self = $class->SUPER::new (
1629 type => 'food',
1630 @_
1631 );
1632
1633 $self->{aspect} = $tex{$self->{type}}[0]{w} / $tex{$self->{type}}[0]{h};
1634
1635 $self
1636}
1637
1638sub size_request {
1639 my ($self) = @_;
1640
1641 #my $tex = $tex{$self->{type}}[0];
1642 #@$tex{qw(w h)}
1643 (0, 0)
1644}
1645
1646sub set_max {
1647 my ($self, $max) = @_;
1648
1649 $self->{max_val} = $max;
1650}
1651
1652sub set_value {
1653 my ($self, $val, $max) = @_;
1654
1655 $self->set_max ($max)
1656 if defined $max;
1657
1658 $max = $self->{max_val};
1659 $self->{val} = $val;
1660
1661 $self->update;
1662}
1663
1664sub _draw {
1665 my ($self) = @_;
1666
1667 my $tex = $tex{$self->{type}};
1668
1669 my ($w, $h) = ($self->{w}, $self->{h});
1670
1671 if ($self->{vertical}) {
1672 glRotate 90, 0, 0, 1;
1673 glTranslate 0, -$self->{w}, 0;
1674
1675 ($w, $h) = ($h, $w);
1676 }
1677
1678 my $ycut = $self->{val} / ($self->{max_val} || 1);
1679 $ycut = 1 if $self->{val} > $self->{max_val};
1680
1681 my $t1 = $tex->[0];
1682 my $t2 = $tex->[1];
1683
1684 glEnable GL_BLEND;
1685 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1686 glEnable GL_TEXTURE_2D;
1687 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1688
1513 my $h1 = $self->{h} - $ycut * $self->{h}; 1689 my $h1 = $self->{h} - $ycut * $self->{h};
1514 my $h2 = $ycut * $self->{h}; 1690 my $h2 = $ycut * $self->{h};
1515 1691
1516 my $yp = 0;
1517
1518 glBindTexture (GL_TEXTURE_2D, $t1->{name}); 1692 glBindTexture GL_TEXTURE_2D, $t1->{name};
1519 glBegin (GL_QUADS); 1693 glBegin GL_QUADS;
1520 glTexCoord (0, 0); glVertex (0 , $yp); 1694 glTexCoord 0 , 0; glVertex 0 , 0;
1521 glTexCoord (0, (1 - $ycut)); glVertex (0 , $yp + $h1); 1695 glTexCoord 0 , $t1->{t} * (1 - $ycut); glVertex 0 , $h1;
1522 glTexCoord (1, (1 - $ycut)); glVertex (0 + $w, $yp + $h1); 1696 glTexCoord $t1->{s}, $t1->{t} * (1 - $ycut); glVertex $w, $h1;
1523 glTexCoord (1, 0); glVertex (0 + $w, $yp); 1697 glTexCoord $t1->{s}, 0; glVertex $w, 0;
1524 glEnd (); 1698 glEnd;
1525 1699
1526 $yp += $h1;
1527
1528 glBindTexture (GL_TEXTURE_2D, $t2->{name}); 1700 glBindTexture GL_TEXTURE_2D, $t2->{name};
1529 glBegin (GL_QUADS); 1701 glBegin GL_QUADS;
1530 glTexCoord (0, (1 - $ycut)); glVertex (0 , $yp); 1702 glTexCoord 0 , $t2->{t} * (1 - $ycut); glVertex 0 , $h1;
1531 glTexCoord (0, 1); glVertex (0 , $yp + $h2); 1703 glTexCoord 0 , $t2->{t}; glVertex 0 , $h1 + $h2;
1532 glTexCoord (1, 1); glVertex (0 + $w, $yp + $h2); 1704 glTexCoord $t2->{s}, $t2->{t}; glVertex $w, $h1 + $h2;
1533 glTexCoord (1, (1 - $ycut)); glVertex (0 + $w, $yp); 1705 glTexCoord $t2->{s}, $t2->{t} * (1 - $ycut); glVertex $w, $h1;
1534 glEnd (); 1706 glEnd;
1535 1707
1536 glDisable GL_BLEND; 1708 glDisable GL_BLEND;
1537 glDisable GL_TEXTURE_2D; 1709 glDisable GL_TEXTURE_2D;
1538} 1710}
1539 1711
1540############################################################################# 1712#############################################################################
1541 1713
1714package CFClient::UI::Gauge;
1715
1716our @ISA = CFClient::UI::VBox::;
1717
1718sub new {
1719 my ($class, %arg) = @_;
1720
1721 my $self = $class->SUPER::new (
1722 tooltip => $arg{type},
1723 %arg,
1724 );
1725
1726 $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999");
1727 $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1);
1728 $self->add ($self->{max} = new CFClient::UI::Label valign => -1, align => 0, template => "999");
1729
1730 $self
1731}
1732
1733sub set_fontsize {
1734 my ($self, $fsize) = @_;
1735
1736 $self->{value}->set_fontsize ($fsize);
1737 $self->{max} ->set_fontsize ($fsize);
1738}
1739
1740sub set_value {
1741 my ($self, $val, $max) = @_;
1742
1743 $self->set_max ($max)
1744 if defined $max;
1745
1746 $self->{gauge}->set_value ($val, $max);
1747 $self->{value}->set_text ($val);
1748}
1749
1750sub set_max {
1751 my ($self, $max) = @_;
1752
1753 $self->{gauge}->set_max ($max);
1754 $self->{max}->set_text ($max);
1755}
1756
1757#############################################################################
1758
1542package CFClient::UI::Slider; 1759package CFClient::UI::Slider;
1543 1760
1544use strict; 1761use strict;
1545 1762
1546use SDL::OpenGL; 1763use CFClient::OpenGL;
1547 1764
1548our @ISA = CFClient::UI::DrawBG::; 1765our @ISA = CFClient::UI::DrawBG::;
1549 1766
1550my @tex = 1767my @tex =
1551 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } 1768 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1561 # TODO: calculations are off 1778 # TODO: calculations are off
1562 my $self = $class->SUPER::new ( 1779 my $self = $class->SUPER::new (
1563 fg => [1, 1, 1], 1780 fg => [1, 1, 1],
1564 active_fg => [0, 0, 0], 1781 active_fg => [0, 0, 0],
1565 range => [0, 0, 100, 10], 1782 range => [0, 0, 100, 10],
1566 req_w => 40, 1783 req_w => 20,
1567 req_h => 13, 1784 req_h => 20,
1568 vertical => 0, 1785 vertical => 0,
1569 can_hover => 1, 1786 can_hover => 1,
1570 inner_pad => 5, 1787 inner_pad => 5,
1571 @_ 1788 @_
1572 ); 1789 );
1676 1893
1677package CFClient::UI::TextView; 1894package CFClient::UI::TextView;
1678 1895
1679our @ISA = CFClient::UI::HBox::; 1896our @ISA = CFClient::UI::HBox::;
1680 1897
1681use SDL::OpenGL; 1898use CFClient::OpenGL;
1682 1899
1683sub new { 1900sub new {
1684 my $class = shift; 1901 my $class = shift;
1685 1902
1686 my $self = $class->SUPER::new ( 1903 my $self = $class->SUPER::new (
1687 req_w => $::WIDTH / 6,
1688 req_h => $::HEIGHT / 6,
1689 fontsize => $::FONTSIZE, 1904 fontsize => 1,
1690 @_, 1905 @_,
1691 1906
1692 layout => (new CFClient::Layout), 1907 layout => (new CFClient::Layout),
1693 par => [], 1908 par => [],
1694 height => 0, 1909 height => 0,
1715sub text_height { 1930sub text_height {
1716 my ($self, $text) = @_; 1931 my ($self, $text) = @_;
1717 1932
1718 my $layout = $self->{layout}; 1933 my $layout = $self->{layout};
1719 1934
1720 $layout->set_height ($self->{fontsize}); 1935 $layout->set_height ($self->{fontsize} * $::FONTSIZE);
1721 $layout->set_width ($self->{w}); 1936 $layout->set_width ($self->{w});
1722 $layout->set_text ($text); 1937 $layout->set_text ($text);
1723 1938
1724 ($layout->size)[1] 1939 ($layout->size)[1]
1725} 1940}
1729 1944
1730 $self->{need_reflow}++; 1945 $self->{need_reflow}++;
1731 $self->update; 1946 $self->update;
1732} 1947}
1733 1948
1734sub size_request {
1735 my ($self) = @_;
1736
1737 ($self->{req_w}, $self->{req_h})
1738}
1739
1740sub size_allocate { 1949sub size_allocate {
1741 my ($self, $x, $y, $w, $h) = @_; 1950 my ($self, $w, $h) = @_;
1742 1951
1743 $self->SUPER::size_allocate ($x, $y, $w, $h) or return; 1952 $self->SUPER::size_allocate ($w, $h);
1744 1953
1745 $self->{layout}->set_height ($self->{fontsize}); 1954 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE);
1746 $self->{layout}->set_width ($self->{w}); 1955 $self->{layout}->set_width ($self->{children}[0]{w});
1747 1956
1748 $self->reflow; 1957 $self->reflow;
1749 $self->update;
1750} 1958}
1751 1959
1752sub add_paragraph { 1960sub add_paragraph {
1753 my ($self, $color, $text) = @_; 1961 my ($self, $color, $text) = @_;
1754 1962
1839 2047
1840} 2048}
1841 2049
1842############################################################################# 2050#############################################################################
1843 2051
1844package CFClient::UI::MapWidget;
1845
1846use strict;
1847
1848use List::Util qw(min max);
1849
1850use SDL;
1851use SDL::OpenGL;
1852
1853our @ISA = CFClient::UI::Base::;
1854
1855sub new {
1856 my $class = shift;
1857
1858 $class->SUPER::new (
1859 z => -1,
1860 can_focus => 1,
1861 list => (glGenLists 1),
1862 @_
1863 )
1864}
1865
1866sub key_down {
1867 print "MAPKEYDOWN\n";
1868}
1869
1870sub key_up {
1871}
1872
1873sub button_down {
1874 my ($self, $ev, $x, $y) = @_;
1875
1876 $self->focus_in;
1877
1878 if ($ev->button == 2) {
1879 my ($ox, $oy) = ($ev->button_x, $ev->button_y);
1880 my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y});
1881
1882 $self->{motion} = sub {
1883 my ($ev, $x, $y) = @_;
1884
1885 ($x, $y) = ($ev->motion_x, $ev->motion_y);
1886
1887 $::CFG->{map_shift_x} = $bw + $x - $ox;
1888 $::CFG->{map_shift_y} = $bh + $y - $oy;
1889
1890 $self->update;
1891 };
1892 }
1893}
1894
1895sub button_up {
1896 my ($self, $ev, $x, $y) = @_;
1897
1898 delete $self->{motion};
1899}
1900
1901sub mouse_motion {
1902 my ($self, $ev, $x, $y) = @_;
1903
1904 $self->{motion}->($ev, $x, $y) if $self->{motion};
1905}
1906
1907sub size_request {
1908 (
1909 1 + 32 * int $::WIDTH / 32,
1910 1 + 32 * int $::HEIGHT / 32,
1911 )
1912}
1913
1914sub update {
1915 my ($self) = @_;
1916
1917 $self->{need_update} = 1;
1918 $self->SUPER::update;
1919}
1920
1921sub draw {
1922 my ($self) = @_;
1923
1924 if (delete $self->{need_update}) {
1925 glNewList $self->{list}, GL_COMPILE;
1926
1927 if ($::MAP) {
1928 my $sw = int $::WIDTH / 32;
1929 my $sh = int $::HEIGHT / 32;
1930
1931 my $sx = $::CFG->{map_shift_x}; my $sx0 = $sx & 31; $sx = ($sx - $sx0) / 32;
1932 my $sy = $::CFG->{map_shift_y}; my $sy0 = $sy & 31; $sy = ($sy - $sy0) / 32;
1933
1934 glTranslate $sx0 - 32, $sy0 - 32, 0;
1935
1936 my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1);
1937
1938 if ($::CFG->{fow_enable}) {
1939 if ($::CFG->{fow_smooth}) { # smooth fog of war
1940 glConvolutionParameter GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER;
1941 glConvolutionFilter2D
1942 GL_CONVOLUTION_2D,
1943 GL_ALPHA,
1944 3, 3,
1945 GL_ALPHA, GL_FLOAT,
1946 pack "f*",
1947 0.1, 0.1, 0.1,
1948 0.1, 0.2, 0.1,
1949 0.1, 0.1, 0.1,
1950 ;
1951 glEnable GL_CONVOLUTION_2D;
1952 }
1953
1954 $self->{fow_texture} = new CFClient::Texture
1955 w => $w,
1956 h => $h,
1957 data => $data,
1958 internalformat => GL_ALPHA,
1959 format => GL_ALPHA;
1960
1961 glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth};
1962
1963 glEnable GL_BLEND;
1964 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1965 glEnable GL_TEXTURE_2D;
1966 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
1967
1968 glColor +($::CFG->{fow_intensity}) x 3, 1;
1969 $self->{fow_texture}->draw_quad (0, 0, $w * 32, $h * 32);
1970
1971 glDisable GL_TEXTURE_2D;
1972 glDisable GL_BLEND;
1973 }
1974
1975 # HACK BEGIN
1976 {
1977 glTranslate -($sx0 - 32), -($sy0 - 32), 0;#remove
1978 my ($w, $h) = (250, 250);
1979
1980 glEnable GL_BLEND;
1981 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1982 glEnable GL_TEXTURE_2D;
1983 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1984
1985 $self->{mapmap_texture} =
1986 new CFClient::Texture
1987 w => $w,
1988 h => $h,
1989 data => $::MAP->mapmap ($w, $h),
1990 type => GL_UNSIGNED_INT_8_8_8_8_REV;
1991
1992 $self->{mapmap_texture}->draw_quad (100, 100);
1993
1994 glDisable GL_TEXTURE_2D;
1995 glDisable GL_BLEND;
1996 }
1997 # HACK END
1998 }
1999
2000 glEndList;
2001 }
2002
2003 glPushMatrix;
2004 glCallList $self->{list};
2005 glPopMatrix;
2006
2007 if ($FOCUS != $self) {
2008 glColor 64/255, 64/255, 64/255;
2009 glLogicOp GL_AND;
2010 glEnable GL_COLOR_LOGIC_OP;
2011 glBegin GL_QUADS;
2012 glVertex 0, 0;
2013 glVertex 0, $::HEIGHT;
2014 glVertex $::WIDTH, $::HEIGHT;
2015 glVertex $::WIDTH, 0;
2016 glEnd;
2017 glDisable GL_COLOR_LOGIC_OP;
2018 }
2019}
2020
2021my %DIR = (
2022 SDLK_KP8, [1, "north"],
2023 SDLK_KP9, [2, "northeast"],
2024 SDLK_KP6, [3, "east"],
2025 SDLK_KP3, [4, "southeast"],
2026 SDLK_KP2, [5, "south"],
2027 SDLK_KP1, [6, "southwest"],
2028 SDLK_KP4, [7, "west"],
2029 SDLK_KP7, [8, "northwest"],
2030
2031 SDLK_UP, [1, "north"],
2032 SDLK_RIGHT, [3, "east"],
2033 SDLK_DOWN, [5, "south"],
2034 SDLK_LEFT, [7, "west"],
2035);
2036
2037sub key_down {
2038 my ($self, $ev) = @_;
2039
2040 my $mod = $ev->key_mod;
2041 my $sym = $ev->key_sym;
2042
2043 if ($sym == SDLK_KP5) {
2044 $::CONN->user_send ("stay fire");
2045 } elsif ($sym == SDLK_a) {
2046 $::CONN->user_send ("apply");
2047 } elsif ($sym == SDLK_QUOTE) {
2048 $self->emit ('activate_console');
2049 } elsif ($sym == SDLK_SLASH) {
2050 $self->emit ('activate_console' => '/');
2051 } elsif (exists $DIR{$sym}) {
2052 if ($mod & KMOD_SHIFT) {
2053 $self->{shft}++;
2054 $::CONN->user_send ("fire $DIR{$sym}[0]");
2055 } elsif ($mod & KMOD_CTRL) {
2056 $self->{ctrl}++;
2057 $::CONN->user_send ("run $DIR{$sym}[0]");
2058 } else {
2059 $::CONN->user_send ("$DIR{$sym}[1]");
2060 }
2061 }
2062}
2063
2064sub key_up {
2065 my ($self, $ev) = @_;
2066
2067 my $mod = $ev->key_mod;
2068 my $sym = $ev->key_sym;
2069
2070 if (!($mod & KMOD_SHIFT) && delete $self->{shft}) {
2071 $::CONN->user_send ("fire_stop");
2072 }
2073 if (!($mod & KMOD_CTRL ) && delete $self->{ctrl}) {
2074 $::CONN->user_send ("run_stop");
2075 }
2076}
2077
2078#############################################################################
2079
2080package CFClient::UI::Animator; 2052package CFClient::UI::Animator;
2081 2053
2082use SDL::OpenGL; 2054use CFClient::OpenGL;
2083 2055
2084our @ISA = CFClient::UI::Bin::; 2056our @ISA = CFClient::UI::Bin::;
2085 2057
2086sub moveto { 2058sub moveto {
2087 my ($self, $x, $y) = @_; 2059 my ($self, $x, $y) = @_;
2127 my $class = shift; 2099 my $class = shift;
2128 2100
2129 my $self = $class->SUPER::new ( 2101 my $self = $class->SUPER::new (
2130 state => 0, 2102 state => 0,
2131 connect_activate => \&toggle_flopper, 2103 connect_activate => \&toggle_flopper,
2104 can_events => 1,
2132 @_ 2105 @_
2133 ); 2106 );
2134 2107
2135 if ($self->{state}) { 2108 if ($self->{state}) {
2136 $self->{state} = 0; 2109 $self->{state} = 0;
2160 2133
2161package CFClient::UI::Root; 2134package CFClient::UI::Root;
2162 2135
2163our @ISA = CFClient::UI::Container::; 2136our @ISA = CFClient::UI::Container::;
2164 2137
2165use SDL::OpenGL; 2138use CFClient::OpenGL;
2166 2139
2167sub check_size { 2140sub check_size {
2168 my ($self) = @_; 2141 my ($self) = @_;
2169 2142
2170 $self->size_allocate (0, 0, $::WITH, $::HEIGHT); 2143 $self->configure (0, 0, $::WIDTH, $::HEIGHT);
2171} 2144}
2172 2145
2173sub size_request { 2146sub size_request {
2174 ($::WIDTH, $::HEIGHT) 2147 ($::WIDTH, $::HEIGHT)
2175} 2148}
2176 2149
2177sub size_allocate { 2150sub configure {
2178 my ($self, $x, $y, $w, $h) = @_; 2151 my ($self, $x, $y, $w, $h) = @_;
2179 2152
2180 $self->_size_allocate ($x, $y, $w, $h); 2153 $self->SUPER::configure ($x, $y, $w, $h);
2181 2154
2182 $_->size_allocate ($_->{x}, $_->{y}, $_->size_request)
2183 for @{$self->{children}}; 2155 for my $child (@{$self->{children}}) {
2156 my ($X, $Y, $W, $H) = @$child{qw(x y req_w req_h)};
2157
2158 $X = List::Util::max 0, List::Util::min $w - $W, $X;
2159 $Y = List::Util::max 0, List::Util::min $h - $H, $Y;
2160 $child->configure ($X, $Y, $W,$H);
2161 }
2184} 2162}
2185 2163
2186sub _topleft { 2164sub _topleft {
2187 my ($self, $x, $y) = @_; 2165 my ($self, $x, $y) = @_;
2188 2166
2195 $self->check_size; 2173 $self->check_size;
2196 ::refresh (); 2174 ::refresh ();
2197} 2175}
2198 2176
2199sub add { 2177sub add {
2200 my ($self, $widget) = @_; 2178 my ($self, $child) = @_;
2201 2179
2180 # integerize window positions
2181 $child->{x} = int $child->{x};
2182 $child->{y} = int $child->{y};
2183
2202 $self->SUPER::add ($widget); 2184 $self->SUPER::add ($child);
2203
2204 $widget->size_allocate (int $widget->{x}, int $widget->{y}, $widget->size_request);
2205} 2185}
2206 2186
2207sub on_refresh { 2187sub on_refresh {
2208 my ($self, $id, $cb) = @_; 2188 my ($self, $id, $cb) = @_;
2209 2189
2233############################################################################# 2213#############################################################################
2234 2214
2235package CFClient::UI; 2215package CFClient::UI;
2236 2216
2237$ROOT = new CFClient::UI::Root; 2217$ROOT = new CFClient::UI::Root;
2218$TOOLTIP = new CFClient::UI::Label fontsize => 0.8, can_events => 0;
2238 2219
22391 22201
2240 2221

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines