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.81 by root, Wed Apr 12 00:40:45 2006 UTC vs.
Revision 1.85 by elmex, Wed Apr 12 12:55:56 2006 UTC

133 my ($self, $x, $y, $w, $h) = @_; 133 my ($self, $x, $y, $w, $h) = @_;
134 134
135 $self->_size_allocate ($x, $y, $w, $h); 135 $self->_size_allocate ($x, $y, $w, $h);
136} 136}
137 137
138# translate global koordinates to local coordinate system 138# translate global coordinates to local coordinate system
139sub translate { 139sub translate {
140 my ($self, $x, $y) = @_; 140 my ($self, $x, $y) = @_;
141 141
142 $self->{parent}->translate ($x - $self->{x}, $y - $self->{y}); 142 $self->{parent}->translate ($x - $self->{x}, $y - $self->{y});
143} 143}
637 637
638 my $bg = $tex[0]; 638 my $bg = $tex[0];
639 639
640 glBindTexture GL_TEXTURE_2D, $bg->{name}; 640 glBindTexture GL_TEXTURE_2D, $bg->{name};
641 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 641 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
642 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT;
643 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT;
644 642
645 my $rep_x = $cw / $bg->{w}; 643 my $rep_x = $cw / $bg->{w};
646 my $rep_y = $ch / $bg->{h}; 644 my $rep_y = $ch / $bg->{h};
647 645
648 $bg->draw_quad ($left->{w}, $top->{h}, $cw, $ch); 646 $bg->draw_quad ($left->{w}, $top->{h}, $cw, $ch);
743 741
744 my $x = 0; 742 my $x = 0;
745 my $row_h = $hs->[$r]; 743 my $row_h = $hs->[$r];
746 744
747 for my $c (0 .. $#$row) { 745 for my $c (0 .. $#$row) {
748 my $widget = $row->[$c]
749 or next;
750
751 my $col_w = $ws->[$c]; 746 my $col_w = $ws->[$c];
752 747
748 if (my $widget = $row->[$c]) {
753 $widget->size_allocate ($x, $y, $col_w, $row_h); 749 $widget->size_allocate ($x, $y, $col_w, $row_h);
750 }
754 751
755 $x += $col_w; 752 $x += $col_w;
756 } 753 }
757 754
758 $y += $row_h; 755 $y += $row_h;
1000 my $x = 997 my $x =
1001 $self->{align} < 0 ? $self->{padding} 998 $self->{align} < 0 ? $self->{padding}
1002 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} 999 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding}
1003 : ($self->{w} - $tex->{w}) * 0.5; 1000 : ($self->{w} - $tex->{w}) * 0.5;
1004 1001
1005 $tex->draw_quad ($x, $self->{padding}); 1002 glTranslate $x, ($self->{h} - $tex->{h}) * 0.5, 0;
1003 $tex->draw_quad (0, 0);
1006 1004
1007 glDisable GL_TEXTURE_2D; 1005 glDisable GL_TEXTURE_2D;
1008 glDisable GL_BLEND; 1006 glDisable GL_BLEND;
1009} 1007}
1010 1008
1034 1032
1035 $self->{last_activity} = $::NOW; 1033 $self->{last_activity} = $::NOW;
1036 1034
1037 $self->{text} = $text; 1035 $self->{text} = $text;
1038 $self->{layout}->set_width ($self->{w}); 1036 $self->{layout}->set_width ($self->{w});
1037 $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{height});
1039 1038
1040 $text =~ s/./*/g if $self->{hidden}; 1039 $text =~ s/./*/g if $self->{hidden};
1041 1040
1042 $self->{layout}->set_markup ($self->escape_text ($text) . " "); 1041 $self->{layout}->set_markup ($self->escape_text ($text) . " ");
1043 1042
1171our @ISA = CFClient::UI::Label::; 1170our @ISA = CFClient::UI::Label::;
1172 1171
1173use SDL; 1172use SDL;
1174use SDL::OpenGL; 1173use SDL::OpenGL;
1175 1174
1175my @tex =
1176 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1177 qw(b1_button_active.png);
1178
1176sub new { 1179sub new {
1177 my $class = shift; 1180 my $class = shift;
1178 1181
1179 $class->SUPER::new ( 1182 $class->SUPER::new (
1180 padding => 4, 1183 padding => 4,
1181 fg => [1, 1, 1], 1184 fg => [1, 1, 1],
1182 bg => [1, 1, 1, 0.2], 1185 bg => [1, 1, 1, 0.2],
1183 active_bg => [0, 0, 0, 0.5],
1184 active_fg => [1, 1, 0], 1186 active_fg => [1, 1, 0],
1187# active_bg => [0, 0, 0, 0.5],
1185 border_fg => [1, 1, 0], 1188# border_fg => [1, 1, 0],
1186 @_ 1189 @_
1187 ) 1190 )
1188} 1191}
1189 1192
1190sub button_up { 1193sub button_up {
1198 1201
1199sub _draw { 1202sub _draw {
1200 my ($self) = @_; 1203 my ($self) = @_;
1201 1204
1202 local $self->{fg} = $self->{fg}; 1205 local $self->{fg} = $self->{fg};
1206 my $tex = $tex[0];
1203 1207
1204 glEnable GL_BLEND; 1208 glEnable GL_BLEND;
1209 glEnable GL_TEXTURE_2D;
1205 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 1210 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1206 1211
1207 glTranslate 0.375, 0.375, 0; # make line and polyogon coordinates behave similarly
1208
1209 glBegin GL_LINE_LOOP;
1210 glColor @{$self->{border_fg}};
1211 glVertex 1 , 1;
1212 glVertex 1 , $self->{h} - 2;
1213 glVertex $self->{w} - 2, $self->{h} - 2;
1214 glVertex $self->{w} - 2, 1;
1215 glEnd;
1216
1217 if ($GRAB == $self) { 1212 if ($GRAB == $self) {
1218 glColor @{$self->{active_bg}};
1219 $self->{fg} = $self->{active_fg}; 1213 $self->{fg} = $self->{active_fg};
1220 } else {
1221 glColor @{$self->{bg}};
1222 } 1214 }
1223 1215
1224 glBegin GL_QUADS; 1216 glBindTexture GL_TEXTURE_2D, $tex->{name};
1225 glVertex 2 , 2; 1217 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1226 glVertex 2 , $self->{h} - 2; 1218
1227 glVertex $self->{w} - 2, $self->{h} - 2; 1219 $tex->draw_quad (0, 0, $self->{w}, $self->{h});
1228 glVertex $self->{w} - 2, 2; 1220
1229 glEnd; 1221 glDisable GL_TEXTURE_2D;
1230 glDisable GL_BLEND; 1222 glDisable GL_BLEND;
1231 1223
1232 $self->SUPER::_draw; 1224 $self->SUPER::_draw;
1233} 1225}
1234 1226
1507 my $mod = $ev->key_mod; 1499 my $mod = $ev->key_mod;
1508 my $sym = $ev->key_sym; 1500 my $sym = $ev->key_sym;
1509 1501
1510 if ($sym == SDLK_KP5) { 1502 if ($sym == SDLK_KP5) {
1511 $::CONN->send ("command stay fire"); 1503 $::CONN->send ("command stay fire");
1504 } elsif ($sym == SDLK_a) {
1505 $::CONN->send ("command apply");
1512 } elsif (exists $DIR{$sym}) { 1506 } elsif (exists $DIR{$sym}) {
1513 if ($mod & KMOD_SHIFT) { 1507 if ($mod & KMOD_SHIFT) {
1514 $self->{shft}++; 1508 $self->{shft}++;
1515 $::CONN->send ("command fire $DIR{$sym}[0]"); 1509 $::CONN->send ("command fire $DIR{$sym}[0]");
1516 } elsif ($mod & KMOD_CTRL) { 1510 } elsif ($mod & KMOD_CTRL) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines