mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +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" :
|
"add" :
|
||||||
{
|
{
|
||||||
"DITL/1017.json" : "ApplicationResourcePatches/DITL/1017.json",
|
"DITL/1017.json" : "ApplicationResourcePatches/DITL/1017.json",
|
||||||
|
"DITL/1041.json" : "ApplicationResourcePatches/DITL/1041.json",
|
||||||
"DITL/2000.json" : "ApplicationResourcePatches/DITL/2000.json",
|
"DITL/2000.json" : "ApplicationResourcePatches/DITL/2000.json",
|
||||||
"DITL/2001.json" : "ApplicationResourcePatches/DITL/2001.json",
|
"DITL/2001.json" : "ApplicationResourcePatches/DITL/2001.json",
|
||||||
"DITL/2002.json" : "ApplicationResourcePatches/DITL/2002.json",
|
"DITL/2002.json" : "ApplicationResourcePatches/DITL/2002.json",
|
||||||
|
@@ -425,7 +425,7 @@ void HandleBands (void); // --- RubberBands.c
|
|||||||
Boolean AddBand (gliderPtr, SInt16, SInt16, Boolean);
|
Boolean AddBand (gliderPtr, SInt16, SInt16, Boolean);
|
||||||
void KillAllBands (void);
|
void KillAllBands (void);
|
||||||
|
|
||||||
void SaveGame2 (void); // --- SavedGames.c
|
Boolean SaveGame2 (void); // --- SavedGames.c
|
||||||
Boolean OpenSavedGame (void);
|
Boolean OpenSavedGame (void);
|
||||||
//void SaveGame (Boolean);
|
//void SaveGame (Boolean);
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ void DoPause (void);
|
|||||||
void DoTouchScreenMenu (void);
|
void DoTouchScreenMenu (void);
|
||||||
void DoBatteryEngaged (gliderPtr);
|
void DoBatteryEngaged (gliderPtr);
|
||||||
void DoHeliumEngaged (gliderPtr);
|
void DoHeliumEngaged (gliderPtr);
|
||||||
Boolean QuerySaveGame (void);
|
void QuerySaveGame (Boolean &save, Boolean &cancel);
|
||||||
|
|
||||||
|
|
||||||
demoPtr demoData;
|
demoPtr demoData;
|
||||||
@@ -75,13 +75,24 @@ void DoCommandKey (void)
|
|||||||
|
|
||||||
if (theKeys->IsSet(PL_KEY_ASCII('Q')))
|
if (theKeys->IsSet(PL_KEY_ASCII('Q')))
|
||||||
{
|
{
|
||||||
|
Boolean wantCancel = false;
|
||||||
playing = false;
|
playing = false;
|
||||||
paused = false;
|
paused = false;
|
||||||
if ((!twoPlayerGame) && (!demoGoing))
|
if ((!twoPlayerGame) && (!demoGoing))
|
||||||
{
|
{
|
||||||
if (QuerySaveGame())
|
Boolean wantSave = false;
|
||||||
SaveGame2(); // New save game.
|
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))
|
||||||
{
|
{
|
||||||
@@ -326,12 +337,23 @@ void DoTouchScreenMenu(void)
|
|||||||
switch (highlightedItem)
|
switch (highlightedItem)
|
||||||
{
|
{
|
||||||
case TouchScreenMenuItems::kQuit:
|
case TouchScreenMenuItems::kQuit:
|
||||||
playing = false;
|
|
||||||
paused = false;
|
|
||||||
if ((!twoPlayerGame) && (!demoGoing))
|
|
||||||
{
|
{
|
||||||
if (QuerySaveGame())
|
Boolean wantCancel = false;
|
||||||
SaveGame2(); // New save game.
|
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:
|
||||||
@@ -793,19 +815,19 @@ void GetInput (gliderPtr thisGlider)
|
|||||||
|
|
||||||
//-------------------------------------------------------------- QuerySaveGame
|
//-------------------------------------------------------------- QuerySaveGame
|
||||||
|
|
||||||
Boolean QuerySaveGame (void)
|
void QuerySaveGame (Boolean &save, Boolean &cancel)
|
||||||
{
|
{
|
||||||
#define kSaveGameAlert 1041
|
#define kSaveGameAlert 1041
|
||||||
#define kYesSaveGameButton 1
|
#define kYesSaveGameButton 1
|
||||||
|
#define kNoButton 2
|
||||||
|
#define kCancelButton 3
|
||||||
short hitWhat;
|
short hitWhat;
|
||||||
|
|
||||||
InitCursor();
|
InitCursor();
|
||||||
FlushEvents();
|
FlushEvents();
|
||||||
// CenterAlert(kSaveGameAlert);
|
// CenterAlert(kSaveGameAlert);
|
||||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSaveGameAlert, nullptr);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSaveGameAlert, nullptr);
|
||||||
if (hitWhat == kYesSaveGameButton)
|
save = (hitWhat == kYesSaveGameButton);
|
||||||
return (true);
|
cancel = (hitWhat == kCancelButton);
|
||||||
else
|
|
||||||
return (false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -116,7 +116,7 @@ static PortabilityLayer::FileBrowserUI_DetailsCallbackAPI GetSavedGameDetailsAPI
|
|||||||
|
|
||||||
//-------------------------------------------------------------- SaveGame2
|
//-------------------------------------------------------------- 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.
|
// 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.
|
// To avoid that, clear all state here.
|
||||||
@@ -146,7 +146,7 @@ void SaveGame2 (void)
|
|||||||
if (savedGame == nil)
|
if (savedGame == nil)
|
||||||
{
|
{
|
||||||
YellowAlert(kYellowFailedSaveGame, PLErrors::kOutOfMemory);
|
YellowAlert(kYellowFailedSaveGame, PLErrors::kOutOfMemory);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(savedGame, 0, byteCount);
|
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()))
|
if (!fm->PromptSaveFile(spec.m_dir, 'gliG', savePath, savePathLength, sizeof(spec.m_name), PLPasStr(gameNameStr), PSTR("Save Game"), GetSavedGameDetailsAPI()))
|
||||||
{
|
{
|
||||||
mm->Release(savedGame);
|
mm->Release(savedGame);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(savePathLength < sizeof(spec.m_name) - 1);
|
assert(savePathLength < sizeof(spec.m_name) - 1);
|
||||||
@@ -179,7 +179,7 @@ void SaveGame2 (void)
|
|||||||
if (!fm->DeleteFile(spec.m_dir, spec.m_name))
|
if (!fm->DeleteFile(spec.m_dir, spec.m_name))
|
||||||
{
|
{
|
||||||
CheckFileError(PLErrors::kAccessDenied, PSTR("Saved Game"));
|
CheckFileError(PLErrors::kAccessDenied, PSTR("Saved Game"));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,6 +233,8 @@ void SaveGame2 (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mm->Release(savedGame);
|
mm->Release(savedGame);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- SavedGameMismatchError
|
//-------------------------------------------------------------- SavedGameMismatchError
|
||||||
|
Reference in New Issue
Block a user