mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 14:53:52 +00:00
Move “end game” logic into common function
This commit is contained in:
@@ -42,6 +42,7 @@ void DoPause (void);
|
||||
void DoTouchScreenMenu (void);
|
||||
void DoBatteryEngaged (gliderPtr);
|
||||
void DoHeliumEngaged (gliderPtr);
|
||||
void DoEndGame (void);
|
||||
void QuerySaveGame (Boolean &save, Boolean &cancel);
|
||||
|
||||
|
||||
@@ -75,24 +76,7 @@ void DoCommandKey (void)
|
||||
|
||||
if (theKeys->IsSet(PL_KEY_ASCII('Q')))
|
||||
{
|
||||
Boolean wantCancel = false;
|
||||
playing = false;
|
||||
paused = false;
|
||||
if ((!twoPlayerGame) && (!demoGoing))
|
||||
{
|
||||
Boolean wantSave = false;
|
||||
QuerySaveGame(wantSave, wantCancel);
|
||||
|
||||
if (wantSave)
|
||||
{
|
||||
// New save game.
|
||||
if (!SaveGame2())
|
||||
wantCancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (wantCancel)
|
||||
playing = true;
|
||||
DoEndGame();
|
||||
}
|
||||
else if ((theKeys->IsSet(PL_KEY_ASCII('S'))) && (!twoPlayerGame))
|
||||
{
|
||||
@@ -337,24 +321,7 @@ void DoTouchScreenMenu(void)
|
||||
switch (highlightedItem)
|
||||
{
|
||||
case TouchScreenMenuItems::kQuit:
|
||||
{
|
||||
Boolean wantCancel = false;
|
||||
playing = false;
|
||||
paused = false;
|
||||
if ((!twoPlayerGame) && (!demoGoing))
|
||||
{
|
||||
Boolean wantSave = false;
|
||||
QuerySaveGame(wantSave, wantCancel);
|
||||
if (wantSave)
|
||||
{
|
||||
if (!SaveGame2()) // New save game.
|
||||
wantCancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (wantCancel)
|
||||
playing = true;
|
||||
}
|
||||
DoEndGame();
|
||||
break;
|
||||
case TouchScreenMenuItems::kSave:
|
||||
assert(!twoPlayerGame);
|
||||
@@ -813,6 +780,28 @@ void GetInput (gliderPtr thisGlider)
|
||||
}
|
||||
}
|
||||
|
||||
void DoEndGame() {
|
||||
Boolean wantCancel = false;
|
||||
playing = false;
|
||||
paused = false;
|
||||
quitting = false;
|
||||
if ((!twoPlayerGame) && (!demoGoing))
|
||||
{
|
||||
Boolean wantSave = false;
|
||||
QuerySaveGame(wantSave, wantCancel);
|
||||
if (wantSave)
|
||||
{
|
||||
if (!SaveGame2()) // New save game.
|
||||
wantCancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (wantCancel)
|
||||
{
|
||||
playing = true;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- QuerySaveGame
|
||||
|
||||
void QuerySaveGame (Boolean &save, Boolean &cancel)
|
||||
|
Reference in New Issue
Block a user