mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-22 22:45:39 +00:00
Add cancel option to save game prompt
This commit is contained in:
45
ApplicationResourcePatches/DITL/1041.json
Normal file
45
ApplicationResourcePatches/DITL/1041.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"items" :
|
||||
[
|
||||
{
|
||||
"name" : "Save First",
|
||||
"itemType" : "Button",
|
||||
"pos" : [ 174, 48 ],
|
||||
"size" : [ 80, 20 ],
|
||||
"id" : 0,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
"name" : "Don't Save",
|
||||
"itemType" : "Button",
|
||||
"pos" : [ 82, 48 ],
|
||||
"size" : [ 80, 20 ],
|
||||
"id" : 0,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
"name" : "Cancel",
|
||||
"itemType" : "Button",
|
||||
"pos" : [ 20, 48 ],
|
||||
"size" : [ 50, 20 ],
|
||||
"id" : 0,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
"name" : "Do you want to save the state of the game before quitting?",
|
||||
"itemType" : "Label",
|
||||
"pos" : [ 8, 8 ],
|
||||
"size" : [ 201, 32 ],
|
||||
"id" : 0,
|
||||
"enabled" : false
|
||||
},
|
||||
{
|
||||
"name" : "",
|
||||
"itemType" : "Icon",
|
||||
"pos" : [ 222, 8 ],
|
||||
"size" : [ 32, 32 ],
|
||||
"id" : 1072,
|
||||
"enabled" : false
|
||||
}
|
||||
]
|
||||
}
|
@@ -2,6 +2,7 @@
|
||||
"add" :
|
||||
{
|
||||
"DITL/1017.json" : "ApplicationResourcePatches/DITL/1017.json",
|
||||
"DITL/1041.json" : "ApplicationResourcePatches/DITL/1041.json",
|
||||
"DITL/2000.json" : "ApplicationResourcePatches/DITL/2000.json",
|
||||
"DITL/2001.json" : "ApplicationResourcePatches/DITL/2001.json",
|
||||
"DITL/2002.json" : "ApplicationResourcePatches/DITL/2002.json",
|
||||
|
@@ -425,7 +425,7 @@ void HandleBands (void); // --- RubberBands.c
|
||||
Boolean AddBand (gliderPtr, SInt16, SInt16, Boolean);
|
||||
void KillAllBands (void);
|
||||
|
||||
void SaveGame2 (void); // --- SavedGames.c
|
||||
Boolean SaveGame2 (void); // --- SavedGames.c
|
||||
Boolean OpenSavedGame (void);
|
||||
//void SaveGame (Boolean);
|
||||
|
||||
|
@@ -42,7 +42,7 @@ void DoPause (void);
|
||||
void DoTouchScreenMenu (void);
|
||||
void DoBatteryEngaged (gliderPtr);
|
||||
void DoHeliumEngaged (gliderPtr);
|
||||
Boolean QuerySaveGame (void);
|
||||
void QuerySaveGame (Boolean &save, Boolean &cancel);
|
||||
|
||||
|
||||
demoPtr demoData;
|
||||
@@ -75,13 +75,24 @@ void DoCommandKey (void)
|
||||
|
||||
if (theKeys->IsSet(PL_KEY_ASCII('Q')))
|
||||
{
|
||||
Boolean wantCancel = false;
|
||||
playing = false;
|
||||
paused = false;
|
||||
if ((!twoPlayerGame) && (!demoGoing))
|
||||
{
|
||||
if (QuerySaveGame())
|
||||
SaveGame2(); // New save game.
|
||||
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))
|
||||
{
|
||||
@@ -326,12 +337,23 @@ void DoTouchScreenMenu(void)
|
||||
switch (highlightedItem)
|
||||
{
|
||||
case TouchScreenMenuItems::kQuit:
|
||||
playing = false;
|
||||
paused = false;
|
||||
if ((!twoPlayerGame) && (!demoGoing))
|
||||
{
|
||||
if (QuerySaveGame())
|
||||
SaveGame2(); // New save game.
|
||||
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;
|
||||
case TouchScreenMenuItems::kSave:
|
||||
@@ -793,19 +815,19 @@ void GetInput (gliderPtr thisGlider)
|
||||
|
||||
//-------------------------------------------------------------- QuerySaveGame
|
||||
|
||||
Boolean QuerySaveGame (void)
|
||||
void QuerySaveGame (Boolean &save, Boolean &cancel)
|
||||
{
|
||||
#define kSaveGameAlert 1041
|
||||
#define kYesSaveGameButton 1
|
||||
#define kNoButton 2
|
||||
#define kCancelButton 3
|
||||
short hitWhat;
|
||||
|
||||
InitCursor();
|
||||
FlushEvents();
|
||||
// CenterAlert(kSaveGameAlert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSaveGameAlert, nullptr);
|
||||
if (hitWhat == kYesSaveGameButton)
|
||||
return (true);
|
||||
else
|
||||
return (false);
|
||||
save = (hitWhat == kYesSaveGameButton);
|
||||
cancel = (hitWhat == kCancelButton);
|
||||
}
|
||||
|
||||
|
@@ -116,7 +116,7 @@ static PortabilityLayer::FileBrowserUI_DetailsCallbackAPI GetSavedGameDetailsAPI
|
||||
|
||||
//-------------------------------------------------------------- SaveGame2
|
||||
|
||||
void SaveGame2 (void)
|
||||
Boolean SaveGame2 (void)
|
||||
{
|
||||
// Bringing up the save file UI can cause key/mouse events to be missed, resulting in state being stuck when this comes back.
|
||||
// To avoid that, clear all state here.
|
||||
@@ -146,7 +146,7 @@ void SaveGame2 (void)
|
||||
if (savedGame == nil)
|
||||
{
|
||||
YellowAlert(kYellowFailedSaveGame, PLErrors::kOutOfMemory);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
memset(savedGame, 0, byteCount);
|
||||
@@ -166,7 +166,7 @@ void SaveGame2 (void)
|
||||
if (!fm->PromptSaveFile(spec.m_dir, 'gliG', savePath, savePathLength, sizeof(spec.m_name), PLPasStr(gameNameStr), PSTR("Save Game"), GetSavedGameDetailsAPI()))
|
||||
{
|
||||
mm->Release(savedGame);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(savePathLength < sizeof(spec.m_name) - 1);
|
||||
@@ -179,7 +179,7 @@ void SaveGame2 (void)
|
||||
if (!fm->DeleteFile(spec.m_dir, spec.m_name))
|
||||
{
|
||||
CheckFileError(PLErrors::kAccessDenied, PSTR("Saved Game"));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,6 +233,8 @@ void SaveGame2 (void)
|
||||
}
|
||||
|
||||
mm->Release(savedGame);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- SavedGameMismatchError
|
||||
|
Reference in New Issue
Block a user