mirror of
https://github.com/jonthysell/MacLO.git
synced 2025-01-28 19:33:04 +00:00
Add PICT override code
This commit is contained in:
parent
56f52ad87c
commit
d709703a64
@ -1,9 +1,13 @@
|
|||||||
// Copyright (c) Jon Thysell <http://jonthysell.com>
|
// Copyright (c) Jon Thysell <http://jonthysell.com>
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
|
#include <OSUtils.h>
|
||||||
|
|
||||||
#include "Bitmaps.h"
|
#include "Bitmaps.h"
|
||||||
|
|
||||||
#define TitlePictResID BaseResID
|
#define BasePictResID BaseResID
|
||||||
|
|
||||||
|
#define TitlePictResID 0
|
||||||
#define NumCharPictBaseResID (TitlePictResID + 1)
|
#define NumCharPictBaseResID (TitlePictResID + 1)
|
||||||
#define ACharPictResID (NumCharPictBaseResID + NumCharPictCount)
|
#define ACharPictResID (NumCharPictBaseResID + NumCharPictCount)
|
||||||
#define BCharPictResID (ACharPictResID + 1)
|
#define BCharPictResID (ACharPictResID + 1)
|
||||||
@ -16,14 +20,22 @@
|
|||||||
#define LightOffPictResID (SoundOnPictResID + 1)
|
#define LightOffPictResID (SoundOnPictResID + 1)
|
||||||
#define LightOnPictResID (LightOffPictResID + 1)
|
#define LightOnPictResID (LightOffPictResID + 1)
|
||||||
|
|
||||||
#define StarRectPadding 2
|
#define TotalPictCount (LightOnPictResID + 1)
|
||||||
|
|
||||||
|
#define StarRectPadding 2
|
||||||
|
|
||||||
|
int16_t Bitmaps_GetOverrideBaseResID();
|
||||||
|
|
||||||
|
PicHandle Bitmaps_GetPict(const int16_t holidayResID, const int16_t offset);
|
||||||
|
|
||||||
void Bitmaps_Init(Bitmaps *pBitmaps)
|
void Bitmaps_Init(Bitmaps *pBitmaps)
|
||||||
{
|
{
|
||||||
int16_t i;
|
int16_t i, baseResID;
|
||||||
|
|
||||||
|
baseResID = Bitmaps_GetOverrideBaseResID();
|
||||||
|
|
||||||
// Load title
|
// Load title
|
||||||
pBitmaps->TitlePict = GetPicture(TitlePictResID);
|
pBitmaps->TitlePict = Bitmaps_GetPict(baseResID, TitlePictResID);
|
||||||
if (pBitmaps->TitlePict == nil)
|
if (pBitmaps->TitlePict == nil)
|
||||||
{
|
{
|
||||||
ShowError("\pTitle PICT resource missing!", true);
|
ShowError("\pTitle PICT resource missing!", true);
|
||||||
@ -32,7 +44,7 @@ void Bitmaps_Init(Bitmaps *pBitmaps)
|
|||||||
// Load number chars
|
// Load number chars
|
||||||
for (i = 0; i < NumCharPictCount; i++)
|
for (i = 0; i < NumCharPictCount; i++)
|
||||||
{
|
{
|
||||||
pBitmaps->NumCharPicts[i] = GetPicture(NumCharPictBaseResID + i);
|
pBitmaps->NumCharPicts[i] = Bitmaps_GetPict(baseResID, NumCharPictBaseResID + i);
|
||||||
if (pBitmaps->NumCharPicts[i] == nil)
|
if (pBitmaps->NumCharPicts[i] == nil)
|
||||||
{
|
{
|
||||||
ShowError("\pNumber char PICT resource missing!", true);
|
ShowError("\pNumber char PICT resource missing!", true);
|
||||||
@ -40,21 +52,21 @@ void Bitmaps_Init(Bitmaps *pBitmaps)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load "A" char
|
// Load "A" char
|
||||||
pBitmaps->ACharPict = GetPicture(ACharPictResID);
|
pBitmaps->ACharPict = Bitmaps_GetPict(baseResID, ACharPictResID);
|
||||||
if (pBitmaps->ACharPict == nil)
|
if (pBitmaps->ACharPict == nil)
|
||||||
{
|
{
|
||||||
ShowError("\pA char PICT resource missing!", true);
|
ShowError("\pA char PICT resource missing!", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load "B" char
|
// Load "B" char
|
||||||
pBitmaps->BCharPict = GetPicture(BCharPictResID);
|
pBitmaps->BCharPict = Bitmaps_GetPict(baseResID, BCharPictResID);
|
||||||
if (pBitmaps->BCharPict == nil)
|
if (pBitmaps->BCharPict == nil)
|
||||||
{
|
{
|
||||||
ShowError("\pB char PICT resource missing!", true);
|
ShowError("\pB char PICT resource missing!", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load "/" char
|
// Load "/" char
|
||||||
pBitmaps->SlashCharPict = GetPicture(SlashCharPictResID);
|
pBitmaps->SlashCharPict = Bitmaps_GetPict(baseResID, SlashCharPictResID);
|
||||||
if (pBitmaps->SlashCharPict == nil)
|
if (pBitmaps->SlashCharPict == nil)
|
||||||
{
|
{
|
||||||
ShowError("\pSlash char PICT resource missing!", true);
|
ShowError("\pSlash char PICT resource missing!", true);
|
||||||
@ -63,7 +75,7 @@ void Bitmaps_Init(Bitmaps *pBitmaps)
|
|||||||
// Load half-stars
|
// Load half-stars
|
||||||
for (i = 0; i < StarPictCount; i++)
|
for (i = 0; i < StarPictCount; i++)
|
||||||
{
|
{
|
||||||
pBitmaps->StarPicts[i] = GetPicture(StarPictBaseResID + i);
|
pBitmaps->StarPicts[i] = Bitmaps_GetPict(baseResID, StarPictBaseResID + i);
|
||||||
if (pBitmaps->StarPicts[i] == nil)
|
if (pBitmaps->StarPicts[i] == nil)
|
||||||
{
|
{
|
||||||
ShowError("\pStar PICT resource missing!", true);
|
ShowError("\pStar PICT resource missing!", true);
|
||||||
@ -71,55 +83,85 @@ void Bitmaps_Init(Bitmaps *pBitmaps)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load slash char
|
// Load slash char
|
||||||
pBitmaps->SlashCharPict = GetPicture(SlashCharPictResID);
|
pBitmaps->SlashCharPict = Bitmaps_GetPict(baseResID, SlashCharPictResID);
|
||||||
if (pBitmaps->SlashCharPict == nil)
|
if (pBitmaps->SlashCharPict == nil)
|
||||||
{
|
{
|
||||||
ShowError("\pSlash char PICT resource missing!", true);
|
ShowError("\pSlash char PICT resource missing!", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load next button
|
// Load next button
|
||||||
pBitmaps->NextButtonPict = GetPicture(NextButtonPictResID);
|
pBitmaps->NextButtonPict = Bitmaps_GetPict(baseResID, NextButtonPictResID);
|
||||||
if (pBitmaps->NextButtonPict == nil)
|
if (pBitmaps->NextButtonPict == nil)
|
||||||
{
|
{
|
||||||
ShowError("\pNext button PICT resource missing!", true);
|
ShowError("\pNext button PICT resource missing!", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load retry button
|
// Load retry button
|
||||||
pBitmaps->RetryButtonPict = GetPicture(RetryButtonPictResID);
|
pBitmaps->RetryButtonPict = Bitmaps_GetPict(baseResID, RetryButtonPictResID);
|
||||||
if (pBitmaps->RetryButtonPict == nil)
|
if (pBitmaps->RetryButtonPict == nil)
|
||||||
{
|
{
|
||||||
ShowError("\pRetry button PICT resource missing!", true);
|
ShowError("\pRetry button PICT resource missing!", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load sound off
|
// Load sound off
|
||||||
pBitmaps->SoundOffPict = GetPicture(SoundOffPictResID);
|
pBitmaps->SoundOffPict = Bitmaps_GetPict(baseResID, SoundOffPictResID);
|
||||||
if (pBitmaps->SoundOffPict == nil)
|
if (pBitmaps->SoundOffPict == nil)
|
||||||
{
|
{
|
||||||
ShowError("\pSound off PICT resource missing!", true);
|
ShowError("\pSound off PICT resource missing!", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load sound on
|
// Load sound on
|
||||||
pBitmaps->SoundOnPict = GetPicture(SoundOnPictResID);
|
pBitmaps->SoundOnPict = Bitmaps_GetPict(baseResID, SoundOnPictResID);
|
||||||
if (pBitmaps->SoundOnPict == nil)
|
if (pBitmaps->SoundOnPict == nil)
|
||||||
{
|
{
|
||||||
ShowError("\pSound on PICT resource missing!", true);
|
ShowError("\pSound on PICT resource missing!", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load light off
|
// Load light off
|
||||||
pBitmaps->LightOffPict = GetPicture(LightOffPictResID);
|
pBitmaps->LightOffPict = Bitmaps_GetPict(baseResID, LightOffPictResID);
|
||||||
if (pBitmaps->LightOffPict == nil)
|
if (pBitmaps->LightOffPict == nil)
|
||||||
{
|
{
|
||||||
ShowError("\pLight off PICT resource missing!", true);
|
ShowError("\pLight off PICT resource missing!", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load light on
|
// Load light on
|
||||||
pBitmaps->LightOnPict = GetPicture(LightOnPictResID);
|
pBitmaps->LightOnPict = Bitmaps_GetPict(baseResID, LightOnPictResID);
|
||||||
if (pBitmaps->LightOnPict == nil)
|
if (pBitmaps->LightOnPict == nil)
|
||||||
{
|
{
|
||||||
ShowError("\pLight on PICT resource missing!", true);
|
ShowError("\pLight on PICT resource missing!", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t Bitmaps_GetOverrideBaseResID()
|
||||||
|
{
|
||||||
|
uint32_t seconds;
|
||||||
|
DateTimeRec dateTime;
|
||||||
|
int16_t dayOfYear;
|
||||||
|
|
||||||
|
GetDateTime(&seconds);
|
||||||
|
Secs2Date(seconds, &dateTime);
|
||||||
|
|
||||||
|
// Calculate "day number" (1 - 366, always assume leap year)
|
||||||
|
dayOfYear = MonthOffset[dateTime.month - 1];
|
||||||
|
dayOfYear += dateTime.day;
|
||||||
|
|
||||||
|
return BasePictResID + (dayOfYear * TotalPictCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
PicHandle Bitmaps_GetPict(const int16_t baseResID, const int16_t offset)
|
||||||
|
{
|
||||||
|
PicHandle pic;
|
||||||
|
pic = GetPicture(baseResID + offset);
|
||||||
|
|
||||||
|
if (pic == nil)
|
||||||
|
{
|
||||||
|
// No override pic, get default
|
||||||
|
pic = GetPicture(BasePictResID + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pic;
|
||||||
|
}
|
||||||
|
|
||||||
void Bitmaps_GetNumberRect(const Bitmaps *pBitmaps, const uint32_t number, const uint8_t scale, Rect *pDestRect)
|
void Bitmaps_GetNumberRect(const Bitmaps *pBitmaps, const uint32_t number, const uint8_t scale, Rect *pDestRect)
|
||||||
{
|
{
|
||||||
bool started;
|
bool started;
|
||||||
|
@ -3,6 +3,21 @@
|
|||||||
|
|
||||||
#include "MacCommon.h"
|
#include "MacCommon.h"
|
||||||
|
|
||||||
|
const int16_t MonthOffset[] = {
|
||||||
|
0, // Jan
|
||||||
|
31, // Feb
|
||||||
|
60, // Mar
|
||||||
|
91, // Apr
|
||||||
|
121, // May
|
||||||
|
152, // Jun
|
||||||
|
182, // Jul
|
||||||
|
213, // Aug
|
||||||
|
244, // Sep
|
||||||
|
274, // Oct
|
||||||
|
305, // Nov
|
||||||
|
335, // Dec
|
||||||
|
};
|
||||||
|
|
||||||
void ShowError(Str255 message, bool isFatal)
|
void ShowError(Str255 message, bool isFatal)
|
||||||
{
|
{
|
||||||
ParamText(message, EmptyString, EmptyString, EmptyString);
|
ParamText(message, EmptyString, EmptyString, EmptyString);
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#define ErrorAlertResID BaseResID
|
#define ErrorAlertResID BaseResID
|
||||||
|
|
||||||
|
extern const int16_t MonthOffset[];
|
||||||
|
|
||||||
typedef enum eBoxAlignment
|
typedef enum eBoxAlignment
|
||||||
{
|
{
|
||||||
Top,
|
Top,
|
||||||
|
BIN
src/MacLO.pi.bin
BIN
src/MacLO.pi.bin
Binary file not shown.
Binary file not shown.
@ -10,8 +10,7 @@
|
|||||||
#define LightSize 50
|
#define LightSize 50
|
||||||
#define LightCornerSize 12
|
#define LightCornerSize 12
|
||||||
|
|
||||||
#define HUDMargin PlayfieldMargin
|
#define HUDMargin PlayfieldMargin
|
||||||
#define HUDCornerSize PlayfieldCornerSize
|
|
||||||
|
|
||||||
#define LevelTextScale 3
|
#define LevelTextScale 3
|
||||||
#define HalfStarScale 2
|
#define HalfStarScale 2
|
||||||
@ -105,13 +104,11 @@ void PlayScene_Draw(const GameWindow *pGameWindow, bool fullRefresh)
|
|||||||
{
|
{
|
||||||
// Draw ON light
|
// Draw ON light
|
||||||
DrawPicture(pGameWindow->Bitmaps.LightOnPict, &lightRect);
|
DrawPicture(pGameWindow->Bitmaps.LightOnPict, &lightRect);
|
||||||
//FillRoundRect(&lightRect, LightCornerSize, LightCornerSize, white);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Draw OFF light
|
// Draw OFF light
|
||||||
DrawPicture(pGameWindow->Bitmaps.LightOffPict, &lightRect);
|
DrawPicture(pGameWindow->Bitmaps.LightOffPict, &lightRect);
|
||||||
//FillRoundRect(&lightRect, LightCornerSize, LightCornerSize, dkGray);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,7 +143,6 @@ void PlayScene_Draw(const GameWindow *pGameWindow, bool fullRefresh)
|
|||||||
// Draw sound button
|
// Draw sound button
|
||||||
MoveTo(pGameWindow->PlayScene.SoundButtonRect.left, pGameWindow->PlayScene.SoundButtonRect.top);
|
MoveTo(pGameWindow->PlayScene.SoundButtonRect.left, pGameWindow->PlayScene.SoundButtonRect.top);
|
||||||
Bitmaps_DrawSound(&(pGameWindow->Bitmaps), pGameWindow->Sounds.Enabled, 1);
|
Bitmaps_DrawSound(&(pGameWindow->Bitmaps), pGameWindow->Sounds.Enabled, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayScene_Click(GameWindow *pGameWindow, const Point *pPosition)
|
void PlayScene_Click(GameWindow *pGameWindow, const Point *pPosition)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user