mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 23:00:42 +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 DoTouchScreenMenu (void);
|
||||||
void DoBatteryEngaged (gliderPtr);
|
void DoBatteryEngaged (gliderPtr);
|
||||||
void DoHeliumEngaged (gliderPtr);
|
void DoHeliumEngaged (gliderPtr);
|
||||||
|
void DoEndGame (void);
|
||||||
void QuerySaveGame (Boolean &save, Boolean &cancel);
|
void QuerySaveGame (Boolean &save, Boolean &cancel);
|
||||||
|
|
||||||
|
|
||||||
@@ -72,27 +73,10 @@ void LogDemoKey (char keyIs)
|
|||||||
void DoCommandKey (void)
|
void DoCommandKey (void)
|
||||||
{
|
{
|
||||||
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
|
|
||||||
if (theKeys->IsSet(PL_KEY_ASCII('Q')))
|
if (theKeys->IsSet(PL_KEY_ASCII('Q')))
|
||||||
{
|
{
|
||||||
Boolean wantCancel = false;
|
DoEndGame();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
else if ((theKeys->IsSet(PL_KEY_ASCII('S'))) && (!twoPlayerGame))
|
else if ((theKeys->IsSet(PL_KEY_ASCII('S'))) && (!twoPlayerGame))
|
||||||
{
|
{
|
||||||
@@ -337,24 +321,7 @@ void DoTouchScreenMenu(void)
|
|||||||
switch (highlightedItem)
|
switch (highlightedItem)
|
||||||
{
|
{
|
||||||
case TouchScreenMenuItems::kQuit:
|
case TouchScreenMenuItems::kQuit:
|
||||||
{
|
DoEndGame();
|
||||||
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;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case TouchScreenMenuItems::kSave:
|
case TouchScreenMenuItems::kSave:
|
||||||
assert(!twoPlayerGame);
|
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
|
//-------------------------------------------------------------- QuerySaveGame
|
||||||
|
|
||||||
void QuerySaveGame (Boolean &save, Boolean &cancel)
|
void QuerySaveGame (Boolean &save, Boolean &cancel)
|
||||||
|
Reference in New Issue
Block a user