Skip to content

Commit

Permalink
Fix entering a new highscore not working
Browse files Browse the repository at this point in the history
This fixes both a crash on reaching a new highscore, as well as entering
of a new highscore not working.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  • Loading branch information
jwrdegoede committed Oct 29, 2012
1 parent 4f6c46e commit 46a70ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion lib/Games/PangZero.pm
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ sub HandleEvents {
$MenuEvents{LEFT} = 1 if $keypressed == SDLK_LEFT();
$MenuEvents{RIGHT} = 1 if $keypressed == SDLK_RIGHT();
$MenuEvents{BUTTON} = 1 if $keypressed == SDLK_RETURN();
$MenuEvents{BACKSP} = 1 if $keypressed == SDLK_BACKSPACE;
$LastUnicodeKey = $event->key_unicode() if $UnicodeMode;
}
}
Expand Down Expand Up @@ -351,7 +352,7 @@ sub MainLoop {
@Games::PangZero::Highscore::UnsavedHighScores = ();
$Game->Run();

bless $Game, 'Menu';
bless $Game, 'Games::PangZero::Menu';
$Game->{abortgame} = 0;
{
my @gameObjects = @GameObjects;
Expand Down
15 changes: 7 additions & 8 deletions lib/Games/PangZero/Highscore.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ sub MergeUnsavedHighScores {
@Games::PangZero::UnsavedHighScores = ();
my $newHighScore = &InputPlayerNames($table);
if ($newHighScore) {
$Game->RunHighScore( $Games::PangZero::DifficultyLevelIndex, $table, 0 );
$Games::PangZero::Game->RunHighScore( $Games::PangZero::DifficultyLevelIndex, $table, 0 );
}
}

Expand Down Expand Up @@ -97,16 +97,15 @@ sub InputPlayerName {

while (1) {
$Games::PangZero::LastUnicodeKey = 0;
$Game->MenuAdvance();
last if $Game->{abortgame};
if (%Events) {
my ($key) = %Events;
if ($key == SDLK_BACKSPACE) {
$Games::PangZero::Game->MenuAdvance();
last if $Games::PangZero::Game->{abortgame};
if (%Games::PangZero::Events) {
if ($Games::PangZero::MenuEvents{BACKSP}) {
substr($name, -2, 1, ''); # Remove next to last char
$nameMenuItem->SetText($name);
} elsif ($key == SDLK_RETURN) {
} elsif ($Games::PangZero::MenuEvents{BUTTON}) {
last;
} elsif ($LastUnicodeKey < 127 and $Games::PangZero::LastUnicodeKey >= 32 and length($name) < 9) {
} elsif ($Games::PangZero::LastUnicodeKey < 127 and $Games::PangZero::LastUnicodeKey >= 32 and length($name) < 9) {
substr($name, -1, 0, chr($Games::PangZero::LastUnicodeKey)); # Insert before last char
$nameMenuItem->SetText($name);
}
Expand Down

0 comments on commit 46a70ff

Please sign in to comment.