Minor cleanup of resources

Made sure all resources are no longer marked as purgeable so they stay
in memory (not that we were running out), also cleaned up some other
code issues.
This commit is contained in:
Jon Thysell 2021-12-01 10:08:07 -08:00
parent 3542861603
commit 50a753b35e
10 changed files with 26 additions and 16 deletions

View File

@ -159,12 +159,12 @@ int16_t Bitmaps_GetOverrideBaseResID()
PicHandle Bitmaps_GetPict(const int16_t baseResID, const int16_t offset)
{
PicHandle pic;
pic = GetPicture(baseResID + offset);
pic = (PicHandle)Get1Resource('PICT', baseResID + offset);
if (pic == nil)
{
// No override pic, get default
pic = GetPicture(BasePictResID + offset);
pic = (PicHandle)Get1Resource('PICT', BasePictResID + offset);
}
return pic;

View File

@ -37,8 +37,22 @@ void GameEngine_Init(GameEngine *pGameEngine)
void GameEngine_NewGame(GameEngine *pGameEngine, const bool setB)
{
int8_t level, startLevel;
pGameEngine->SetB = setB;
GameEngine_StartLevel(pGameEngine, 0);
startLevel = 0;
for (level = 0; level < LevelCount; level++)
{
// Find the first uncompleted level
if (GameEngine_GetScore(pGameEngine, level) == 0)
{
startLevel = level;
break;
}
}
GameEngine_StartLevel(pGameEngine, startLevel);
}
void GameEngine_ResetGame(GameEngine *pGameEngine)
@ -52,7 +66,7 @@ void GameEngine_ResetGame(GameEngine *pGameEngine)
}
}
void GameEngine_StartLevel(GameEngine *pGameEngine, const uint8_t level)
void GameEngine_StartLevel(GameEngine *pGameEngine, const int8_t level)
{
GameEngine_LoadLevel(pGameEngine, level, pGameEngine->SetB);
}

View File

@ -32,7 +32,7 @@ void GameEngine_NewGame(GameEngine *pGameEngine, const bool setB);
void GameEngine_ResetGame(GameEngine *pGameEngine);
void GameEngine_StartLevel(GameEngine *pGameEngine, const uint8_t level);
void GameEngine_StartLevel(GameEngine *pGameEngine, const int8_t level);
void GameEngine_CompleteLevel(GameEngine *pGameEngine);

View File

@ -135,7 +135,7 @@ void GameWindow_Show(const GameWindow *pGameWindow)
void GameWindow_ClearScores(GameWindow *pGameWindow)
{
if (ShowConfirm("\pClear all scores?"))
if (ShowConfirm("\pAre you sure you want to clear all scores?"))
{
GameEngine_ResetGame(&(pGameWindow->Engine));
GameWindow_SetScene(pGameWindow, Title);

View File

@ -26,7 +26,6 @@ void LevelSelectScene_Init(GameWindow *pGameWindow)
GetScaledPicFrame(pGameWindow->Engine.SetB ? pGameWindow->Bitmaps.BCharPict : pGameWindow->Bitmaps.ACharPict, SetTextScale, &(pGameWindow->LevelSelectScene.SetRect));
GetBoxRect(pContentRect, Top, &r);
//GetBoxRect(&r, Top, &r);
CenterRect(&r, &(pGameWindow->LevelSelectScene.SetRect));
// Setup score
@ -37,21 +36,18 @@ void LevelSelectScene_Init(GameWindow *pGameWindow)
ConcatenateRect(&(pGameWindow->LevelSelectScene.ScoreRect), &r, &(pGameWindow->LevelSelectScene.ScoreRect));
GetBoxRect(pContentRect, Bottom, &r);
//GetBoxRect(&r, Bottom, &r);
CenterRect(&r, &(pGameWindow->LevelSelectScene.ScoreRect));
// Setup previous button
GetPictureRect(pGameWindow->Bitmaps.NextButtonPict, &(pGameWindow->LevelSelectScene.PrevButtonRect));
GetBoxRect(pContentRect, BottomLeft, &r);
//GetBoxRect(&r, Bottom, &r);
CenterRect(&r, &(pGameWindow->LevelSelectScene.PrevButtonRect));
// Setup next button
GetPictureRect(pGameWindow->Bitmaps.NextButtonPict, &(pGameWindow->LevelSelectScene.NextButtonRect));
GetBoxRect(pContentRect, BottomRight, &r);
//GetBoxRect(&r, Bottom, &r);
CenterRect(&r, &(pGameWindow->LevelSelectScene.NextButtonRect));
// Setup LevelGrid

View File

@ -6,7 +6,7 @@
#define ErrorAlertResID BaseResID
#define ConfirmAlertResID (ErrorAlertResID + 1)
#define YesResult 2
#define ConfirmYesResult 2
const int16_t MonthOffset[] = {
0, // Jan
@ -41,7 +41,7 @@ bool ShowConfirm(Str255 message)
ParamText(message, EmptyString, EmptyString, EmptyString);
result = CautionAlert(ConfirmAlertResID, NilFilterProc);
return result == YesResult;
return result == ConfirmYesResult;
}
void CenterRect(const Rect *pOuterRect, Rect *pInnerRect)

View File

@ -250,7 +250,7 @@ void MacLO_HandleGameMenuChoice(const int16_t item)
void MacLO_Quit()
{
if (ShowConfirm("\pQuit MacLO?"))
if (ShowConfirm("\pAre you sure you want to quit MacLO?"))
{
gExitApp = true;
}

Binary file not shown.

Binary file not shown.

View File

@ -16,19 +16,19 @@ void Sounds_Init(Sounds *pSounds)
{
pSounds->Enabled = DefaultEnabled;
pSounds->ClickSnd = GetResource('snd ', ClickSndResID);
pSounds->ClickSnd = Get1Resource('snd ', ClickSndResID);
if (pSounds->ClickSnd == nil)
{
ShowError("\pClick snd resource missing!", true);
}
pSounds->RetrySnd = GetResource('snd ', RetrySndResID);
pSounds->RetrySnd = Get1Resource('snd ', RetrySndResID);
if (pSounds->RetrySnd == nil)
{
ShowError("\pRetry snd resource missing!", true);
}
pSounds->DoneSnd = GetResource('snd ', DoneSndResID);
pSounds->DoneSnd = Get1Resource('snd ', DoneSndResID);
if (pSounds->DoneSnd == nil)
{
ShowError("\pDone snd resource missing!", true);