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.99 by elmex, Fri Apr 14 10:57:35 2006 UTC vs.
Revision 1.101 by elmex, Fri Apr 14 11:43:51 2006 UTC

639 # TODO: repeat texture not scale 639 # TODO: repeat texture not scale
640 my $rep_x = $cw / $bg->{w}; 640 my $rep_x = $cw / $bg->{w};
641 my $rep_y = $ch / $bg->{h}; 641 my $rep_y = $ch / $bg->{h};
642 642
643 glColor @{ $self->{bg} }; 643 glColor @{ $self->{bg} };
644
645 $bg->{s} = $rep_x;
646 $bg->{t} = $rep_y;
647 $bg->{wrap_mode} = 1;
644 $bg->draw_quad ($self->{border}, $self->{border}, $cw, $ch); 648 $bg->draw_quad ($self->{border}, $self->{border}, $cw, $ch);
645 649
646 glDisable GL_TEXTURE_2D; 650 glDisable GL_TEXTURE_2D;
647 glDisable GL_BLEND; 651 glDisable GL_BLEND;
648 652
1023} 1027}
1024 1028
1025sub _set_text { 1029sub _set_text {
1026 my ($self, $text) = @_; 1030 my ($self, $text) = @_;
1027 1031
1032 my $old_text = $self->{text};
1033
1028 $self->{last_activity} = $::NOW; 1034 $self->{last_activity} = $::NOW;
1029 1035
1030 $self->{text} = $text; 1036 $self->{text} = $text;
1031 $self->{layout}->set_width ($self->{w}); 1037 $self->{layout}->set_width ($self->{w});
1032 $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{height}); 1038 $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{height});
1037 1043
1038 $text = substr $text, 0, $self->{cursor}; 1044 $text = substr $text, 0, $self->{cursor};
1039 utf8::encode $text; 1045 utf8::encode $text;
1040 1046
1041 @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text); 1047 @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text);
1048
1049 $self->emit (changed => $self->{text}) # XXX: is this the right place to do this?
1050 if $old_text ne $self->{text};
1042} 1051}
1043 1052
1044sub size_request { 1053sub size_request {
1045 my ($self) = @_; 1054 my ($self) = @_;
1046 1055
1085 ++$self->{cursor} if $self->{cursor} < length $self->{text}; 1094 ++$self->{cursor} if $self->{cursor} < length $self->{text};
1086 } elsif ($sym == SDLK_HOME) { 1095 } elsif ($sym == SDLK_HOME) {
1087 $self->{cursor} = 0; 1096 $self->{cursor} = 0;
1088 } elsif ($sym == SDLK_END) { 1097 } elsif ($sym == SDLK_END) {
1089 $self->{cursor} = length $text; 1098 $self->{cursor} = length $text;
1099 } elsif ($sym == SDLK_ESCAPE) {
1100 $self->emit ('escape');
1090 } elsif ($uni) { 1101 } elsif ($uni) {
1091 substr $text, $self->{cursor}++, 0, chr $uni; 1102 substr $text, $self->{cursor}++, 0, chr $uni;
1092 } 1103 }
1093 1104
1094 $self->_set_text ($text); 1105 $self->_set_text ($text);
1641 1652
1642 if ($sym == SDLK_KP5) { 1653 if ($sym == SDLK_KP5) {
1643 $::CONN->user_send ("command stay fire"); 1654 $::CONN->user_send ("command stay fire");
1644 } elsif ($sym == SDLK_a) { 1655 } elsif ($sym == SDLK_a) {
1645 $::CONN->user_send ("command apply"); 1656 $::CONN->user_send ("command apply");
1657 } elsif ($sym == SDLK_QUOTE) {
1658 $self->emit ('activate_console');
1646 } elsif (exists $DIR{$sym}) { 1659 } elsif (exists $DIR{$sym}) {
1647 if ($mod & KMOD_SHIFT) { 1660 if ($mod & KMOD_SHIFT) {
1648 $self->{shft}++; 1661 $self->{shft}++;
1649 $::CONN->user_send ("command fire $DIR{$sym}[0]"); 1662 $::CONN->user_send ("command fire $DIR{$sym}[0]");
1650 } elsif ($mod & KMOD_CTRL) { 1663 } elsif ($mod & KMOD_CTRL) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines