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.135 by root, Wed Apr 19 06:21:07 2006 UTC vs.
Revision 1.136 by root, Wed Apr 19 20:46:44 2006 UTC

1111 1111
1112package CFClient::UI::EntryBase; 1112package CFClient::UI::EntryBase;
1113 1113
1114our @ISA = CFClient::UI::Label::; 1114our @ISA = CFClient::UI::Label::;
1115 1115
1116use SDL;
1117use SDL::OpenGL; 1116use SDL::OpenGL;
1118 1117
1119sub new { 1118sub new {
1120 my $class = shift; 1119 my $class = shift;
1121 1120
1183 1182
1184 my $uni = $ev->key_unicode; 1183 my $uni = $ev->key_unicode;
1185 1184
1186 my $text = $self->get_text; 1185 my $text = $self->get_text;
1187 1186
1188 if ($sym == SDLK_BACKSPACE) { 1187 if ($sym == 8) {
1189 substr $text, --$self->{cursor}, 1, "" if $self->{cursor}; 1188 substr $text, --$self->{cursor}, 1, "" if $self->{cursor};
1190 } elsif ($sym == SDLK_DELETE) { 1189 } elsif ($sym == 127) {
1191 substr $text, $self->{cursor}, 1, ""; 1190 substr $text, $self->{cursor}, 1, "";
1192 } elsif ($sym == SDLK_LEFT) { 1191 } elsif ($sym == CFClient::SDLK_LEFT) {
1193 --$self->{cursor} if $self->{cursor}; 1192 --$self->{cursor} if $self->{cursor};
1194 } elsif ($sym == SDLK_RIGHT) { 1193 } elsif ($sym == CFClient::SDLK_RIGHT) {
1195 ++$self->{cursor} if $self->{cursor} < length $self->{text}; 1194 ++$self->{cursor} if $self->{cursor} < length $self->{text};
1196 } elsif ($sym == SDLK_HOME) { 1195 } elsif ($sym == CFClient::SDLK_HOME) {
1197 $self->{cursor} = 0; 1196 $self->{cursor} = 0;
1198 } elsif ($sym == SDLK_END) { 1197 } elsif ($sym == CFClient::SDLK_END) {
1199 $self->{cursor} = length $text; 1198 $self->{cursor} = length $text;
1200 } elsif ($sym == SDLK_ESCAPE) { 1199 } elsif ($sym == 27) {
1201 $self->emit ('escape'); 1200 $self->emit ('escape');
1202 } elsif ($uni) { 1201 } elsif ($uni) {
1203 substr $text, $self->{cursor}++, 0, chr $uni; 1202 substr $text, $self->{cursor}++, 0, chr $uni;
1204 } 1203 }
1205 1204
1280 1279
1281package CFClient::UI::Entry; 1280package CFClient::UI::Entry;
1282 1281
1283our @ISA = CFClient::UI::EntryBase::; 1282our @ISA = CFClient::UI::EntryBase::;
1284 1283
1285use SDL;
1286use SDL::OpenGL; 1284use SDL::OpenGL;
1287 1285
1288sub key_down { 1286sub key_down {
1289 my ($self, $ev) = @_; 1287 my ($self, $ev) = @_;
1290 1288
1291 my $sym = $ev->key_sym; 1289 my $sym = $ev->key_sym;
1292 1290
1293 if ($sym == SDLK_RETURN) { 1291 if ($sym == 13) {
1294 $self->emit (activate => $self->get_text); 1292 $self->emit (activate => $self->get_text);
1295 $self->update; 1293 $self->update;
1296 1294
1297 } else { 1295 } else {
1298 $self->SUPER::key_down ($ev); 1296 $self->SUPER::key_down ($ev);
1304 1302
1305package CFClient::UI::Button; 1303package CFClient::UI::Button;
1306 1304
1307our @ISA = CFClient::UI::Label::; 1305our @ISA = CFClient::UI::Label::;
1308 1306
1309use SDL;
1310use SDL::OpenGL; 1307use SDL::OpenGL;
1311 1308
1312my @tex = 1309my @tex =
1313 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } 1310 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1314 qw(b1_button_active.png); 1311 qw(b1_button_active.png);
1368 1365
1369my @tex = 1366my @tex =
1370 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } 1367 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1371 qw(c1_checkbox_bg.png c1_checkbox_active.png); 1368 qw(c1_checkbox_bg.png c1_checkbox_active.png);
1372 1369
1373use SDL;
1374use SDL::OpenGL; 1370use SDL::OpenGL;
1375 1371
1376sub new { 1372sub new {
1377 my $class = shift; 1373 my $class = shift;
1378 1374

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines