… | |
… | |
1111 | |
1111 | |
1112 | package CFClient::UI::EntryBase; |
1112 | package CFClient::UI::EntryBase; |
1113 | |
1113 | |
1114 | our @ISA = CFClient::UI::Label::; |
1114 | our @ISA = CFClient::UI::Label::; |
1115 | |
1115 | |
1116 | use SDL; |
|
|
1117 | use SDL::OpenGL; |
1116 | use SDL::OpenGL; |
1118 | |
1117 | |
1119 | sub new { |
1118 | sub 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 | |
1281 | package CFClient::UI::Entry; |
1280 | package CFClient::UI::Entry; |
1282 | |
1281 | |
1283 | our @ISA = CFClient::UI::EntryBase::; |
1282 | our @ISA = CFClient::UI::EntryBase::; |
1284 | |
1283 | |
1285 | use SDL; |
|
|
1286 | use SDL::OpenGL; |
1284 | use SDL::OpenGL; |
1287 | |
1285 | |
1288 | sub key_down { |
1286 | sub 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 | |
1305 | package CFClient::UI::Button; |
1303 | package CFClient::UI::Button; |
1306 | |
1304 | |
1307 | our @ISA = CFClient::UI::Label::; |
1305 | our @ISA = CFClient::UI::Label::; |
1308 | |
1306 | |
1309 | use SDL; |
|
|
1310 | use SDL::OpenGL; |
1307 | use SDL::OpenGL; |
1311 | |
1308 | |
1312 | my @tex = |
1309 | my @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 | |
1369 | my @tex = |
1366 | my @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 | |
1373 | use SDL; |
|
|
1374 | use SDL::OpenGL; |
1370 | use SDL::OpenGL; |
1375 | |
1371 | |
1376 | sub new { |
1372 | sub new { |
1377 | my $class = shift; |
1373 | my $class = shift; |
1378 | |
1374 | |