Merge branch 'master' into mac

# Conflicts:
#	GpApp/Main.cpp
This commit is contained in:
Madthijs
2021-05-11 14:28:46 +02:00
76 changed files with 3895 additions and 1365 deletions

View File

@@ -309,7 +309,7 @@ void DoAboutFramework (void)
static const int kAboutFrameworkDialogTemplateID = 2000;
static const int kAboutOpenSourceButton = 2;
const Rect windowRect = Rect::Create(0, 0, 272, 450);
const Rect windowRect = Rect::Create(0, 0, 320, 450);
PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(windowRect, PortabilityLayer::WindowStyleFlags::kAlert, true, 0, 0, PSTR(""));
@@ -319,6 +319,7 @@ void DoAboutFramework (void)
int16_t verticalPoint = 16 + font->GetMetrics().m_ascent;
int16_t horizontalOffset = 16;
int16_t creditsHorizontalOffset = 80;
const int16_t spacing = 12;
PortabilityLayer::DialogManager *dialogManager = PortabilityLayer::DialogManager::GetInstance();
@@ -333,23 +334,28 @@ void DoAboutFramework (void)
Window *window = dialog->GetWindow();
DrawSurface *surface = window->GetDrawSurface();
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 0), PSTR(GP_APPLICATION_NAME " " GP_APPLICATION_VERSION_STRING " \xa9" GP_APPLICATION_COPYRIGHT_STRING), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 2), PSTR(GP_APPLICATION_NAME " is an unoffical third-party port of Glider PRO."), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 4), PSTR("This software is not maintained by, supported by, endorsed by, or"), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 5), PSTR("otherwise associated with the authors or publishers of Glider PRO."), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 7), PSTR("Please do not contact any of them regarding issues that you have"), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 8), PSTR("with " GP_APPLICATION_NAME "."), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 10), PSTR("If you would like to contribute to this project, visit:"), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 11), PSTR(GP_APPLICATION_WEBSITE_STRING), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 13), PSTR("To report a problem or request support, submit an issue via"), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 14), PSTR("the website above."), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 16), PSTR("For more information, please see the accompanying documentation."), blackColor, font);
int lineNum = 0;
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * (lineNum++)), PSTR(GP_APPLICATION_NAME " " GP_APPLICATION_VERSION_STRING " \xa9" GP_APPLICATION_COPYRIGHT_STRING), blackColor, font);
(lineNum++);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * (lineNum)), PSTR("Credits:"), blackColor, font);
surface->DrawString(Point::Create(creditsHorizontalOffset, verticalPoint + spacing * (lineNum++)), PSTR("Eric Lasota - Programming, admin"), blackColor, font);
(lineNum++);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * (lineNum++)), PSTR(GP_APPLICATION_NAME " is an unoffical third-party port of Glider PRO."), blackColor, font);
(lineNum++);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * (lineNum++)), PSTR("This software is not maintained by, supported by, endorsed by, or"), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * (lineNum++)), PSTR("otherwise associated with the authors or publishers of Glider PRO."), blackColor, font);
(lineNum++);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * (lineNum++)), PSTR("Please do not contact any of them regarding issues that you have"), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * (lineNum++)), PSTR("with " GP_APPLICATION_NAME "."), blackColor, font);
(lineNum++);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * (lineNum++)), PSTR("If you would like to contribute to this project, visit:"), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * (lineNum++)), PSTR(GP_APPLICATION_WEBSITE_STRING), blackColor, font);
(lineNum++);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * (lineNum++)), PSTR("To report a problem or request support, submit an issue via"), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * (lineNum++)), PSTR("the website above."), blackColor, font);
(lineNum++);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * (lineNum++)), PSTR("For more information, please see the accompanying documentation."), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, windowRect.bottom - 16), PSTR("Build: " __DATE__ " " __TIME__ " " ABOUT_DIALOG_CONFIGURATION_TAG), blackColor, fontLight);

View File

@@ -75,6 +75,9 @@ namespace PortabilityLayer
#define iObjectWindow 20
#define iCoordinateWindow 21
#define iExportGliderPROHouse 1
#define iDownloadHouse 2
//-------------------------------------------------------------- Structs
/*
typedef short SICN[16];

View File

@@ -115,7 +115,8 @@
#define kTransInSound 60 // <20><> <20><>
#define kBonusSound 61 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kHissSound 62 //
#define kTriggerSound 63
#define kPingSound 63 //
#define kTriggerSound 64 // This must be the last one
#define kHitWallPriority 100 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define kScoreTikPriority 101 // <20><>
@@ -177,6 +178,7 @@
#define kFollowPriority 904
#define kTransInPriority 905
#define kTransOutPriority 906
#define kPingPriority 907
#define kTriggerPriority 999
#define kArrowCursor 0
@@ -187,6 +189,7 @@
#define kGameMenuID 129
#define kOptionsMenuID 130
#define kHouseMenuID 131
#define kExportMenuID 132
#define kSplashMode 0
#define kEditMode 1

View File

@@ -106,6 +106,7 @@ Boolean ReadScoresFromDisk (void);
Boolean CreateNewHouse (void); // --- House.c
Boolean InitializeEmptyHouse (void);
Boolean InitializeEmptyHouseInEditor (void);
SInt16 RealRoomNumberCount (void);
SInt16 GetFirstRoomNumber (void);
void WhereDoesGliderBegin (Rect *, SInt16);
@@ -119,12 +120,13 @@ void GenerateRetroLinks (void);
void DoGoToDialog (void);
void ConvertHouseVer1To2 (void);
void ShiftWholeHouse (SInt16);
void ExportHouse (void);
void DownloadHouse (void);
void DoHouseInfo (void); // --- HouseInfo.c
Boolean OpenHouse (Boolean load); // --- HouseIO.c
Boolean OpenSpecificHouse (const VFileSpec &);
Boolean SaveHouseAs (void);
Boolean ReadHouse (GpIOStream *houseStream, bool untrusted);
Boolean WriteHouse (Boolean);
Boolean CloseHouse (void);

View File

@@ -51,40 +51,70 @@ extern short numberRooms, mapLeftRoom, mapTopRoom, numStarsRemaining;
extern Boolean houseOpen, noRoomAtAll;
extern Boolean twoPlayerGame, wardBitSet, phoneBitSet;
struct FBUI_House_Context
{
FBUI_House_Context();
static void FBUI_House_DrawLabels(DrawSurface *surface, const Point &basePoint)
bool m_deletedAny;
};
FBUI_House_Context::FBUI_House_Context()
: m_deletedAny(false)
{
}
static void FBUI_House_DrawFileDetails(DrawSurface *surface, const Point &basePoint, const Rect &constraintRect, void *fileDetails)
static void FBUI_House_DrawLabels(void *context, DrawSurface *surface, const Point &basePoint)
{
}
static void *FBUI_House_LoadFileDetails(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
static void FBUI_House_DrawFileDetails(void *context, DrawSurface *surface, const Point &basePoint, const Rect &constraintRect, void *fileDetails)
{
}
static void *FBUI_House_LoadFileDetails(void *context, PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
{
return nullptr;
}
static void FBUI_House_FreeFileDetails(void *fileDetails)
static void FBUI_House_FreeFileDetails(void *context, void *fileDetails)
{
}
static bool FBUI_House_FilterFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
static bool FBUI_House_FilterFile(void *context, PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
{
PortabilityLayer::CompositeFile *cfile = PortabilityLayer::FileManager::GetInstance()->OpenCompositeFile(dirID, filename);
return PortabilityLayer::ResTypeIDCodec::Decode(cfile->GetProperties().m_fileType) == 'gliH';
}
static PortabilityLayer::FileBrowserUI_DetailsCallbackAPI GetHouseDetailsAPI()
static bool FBUI_House_IsDeleteValid(void *context, PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
{
if (dirID != PortabilityLayer::VirtualDirectories::kUserData)
return false;
return !StrCmp::EqualCaseInsensitive(thisHouseName, filename);
}
static void FBUI_House_OnDeleted(void *context, PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
{
if (dirID != PortabilityLayer::VirtualDirectories::kUserData)
return;
static_cast<FBUI_House_Context*>(context)->m_deletedAny = true;
}
static PortabilityLayer::FileBrowserUI_DetailsCallbackAPI GetHouseDetailsAPI(FBUI_House_Context *context)
{
PortabilityLayer::FileBrowserUI_DetailsCallbackAPI api;
api.m_context = context;
api.m_drawLabelsCallback = FBUI_House_DrawLabels;
api.m_drawFileDetailsCallback = FBUI_House_DrawFileDetails;
api.m_loadFileDetailsCallback = FBUI_House_LoadFileDetails;
api.m_freeFileDetailsCallback = FBUI_House_FreeFileDetails;
api.m_filterFileCallback = FBUI_House_FilterFile;
api.m_isDeleteValidCallback = FBUI_House_IsDeleteValid;
api.m_onDeletedCallback = FBUI_House_OnDeleted;
return api;
}
@@ -109,8 +139,18 @@ Boolean CreateNewHouse (void)
char savePath[sizeof(theSpec.m_name) + 1];
size_t savePathLength = 0;
if (!fm->PromptSaveFile(theSpec.m_dir, ".gpf", savePath, savePathLength, sizeof(theSpec.m_name), PSTR("My House"), PSTR("Create House"), true, GetHouseDetailsAPI()))
FBUI_House_Context fbuiContext;
if (!fm->PromptSaveFile(theSpec.m_dir, ".gpf", savePath, savePathLength, sizeof(theSpec.m_name), PSTR("My House"), PSTR("Create House"), true, GetHouseDetailsAPI(&fbuiContext)))
{
if (fbuiContext.m_deletedAny)
{
BuildHouseList();
InitCursor();
}
return false;
}
assert(savePathLength < sizeof(theSpec.m_name) - 1);
@@ -165,24 +205,26 @@ Boolean CreateNewHouse (void)
// Initializes all the structures for an empty (new) house.
#ifndef COMPILEDEMO
Boolean InitializeEmptyHouse (void)
{
houseType *thisHousePtr;
Str255 tempStr;
if (thisHouse != nil)
thisHouse.Dispose();
thisHouse = NewHandle(sizeof(houseType) - sizeof(roomType)).StaticCast<houseType>();
const size_t houseSizeNoRooms = sizeof(sizeof(houseType) - sizeof(roomType));
thisHouse = NewHandle(houseSizeNoRooms).StaticCast<houseType>();
if (thisHouse == nil)
{
YellowAlert(kYellowUnaccounted, 1);
return (false);
}
thisHousePtr = *thisHouse;
thisHousePtr->version = kHouseVersion;
thisHousePtr->firstRoom = -1;
thisHousePtr->timeStamp = 0L;
@@ -190,17 +232,17 @@ Boolean InitializeEmptyHouse (void)
thisHousePtr->initial.h = 32;
thisHousePtr->initial.v = 32;
ZeroHighScores();
GetLocalizedString(11, tempStr);
PasStringCopy(tempStr, thisHousePtr->banner);
GetLocalizedString(12, tempStr);
PasStringCopy(tempStr, thisHousePtr->trailer);
thisHousePtr->hasGame = false;
thisHousePtr->nRooms = 0;
wardBitSet = false;
phoneBitSet = false;
numberRooms = 0;
mapLeftRoom = 60;
mapTopRoom = 50;
@@ -211,10 +253,17 @@ Boolean InitializeEmptyHouse (void)
UpdateMapWindow();
noRoomAtAll = true;
fileDirty = true;
return (true);
}
Boolean InitializeEmptyHouseInEditor (void)
{
if (!InitializeEmptyHouse())
return (false);
UpdateMenus(false);
ReflectCurrentRoom(true);
return (true);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -9,6 +9,7 @@
#include "Externs.h"
#include "Environ.h"
#include "IGpDisplayDriver.h"
#include "IGpSystemServices.h"
#include "GpApplicationName.h"
#include "Map.h"
#include "MenuManager.h"
@@ -32,7 +33,7 @@ extern WindowPtr mapWindow, toolsWindow, linkWindow;
extern Rect boardSrcRect, localRoomsDest[];
extern IGpCursor *handCursor, *vertCursor, *horiCursor;
extern IGpCursor *diagCursor;
extern MenuHandle appleMenu, gameMenu, optionsMenu, houseMenu;
extern MenuHandle appleMenu, gameMenu, optionsMenu, houseMenu, exportMenu;
extern long incrementModeTime;
extern UInt32 doubleTime;
extern short fadeInSequence[], idleMode;
@@ -50,6 +51,8 @@ extern Boolean twoPlayerGame, paused, hasMirror, splashDrawn;
void InitializeMenus (void)
{
PortabilityLayer::MenuManager *mm = PortabilityLayer::MenuManager::GetInstance();
appleMenu = GetMenu(kAppleMenuID);
if (appleMenu == nil)
RedAlert(kErrFailedResourceLoad);
@@ -70,12 +73,16 @@ void InitializeMenus (void)
if (!thisMac.isTouchscreen)
{
menusUp = true;
PortabilityLayer::MenuManager::GetInstance()->SetMenuVisible(true);
mm->SetMenuVisible(true);
}
houseMenu = GetMenu(kHouseMenuID);
if (houseMenu == nil)
RedAlert(kErrFailedResourceLoad);
exportMenu = mm->CreateMenu(PSTR("Import/Export"), kExportMenuID, true, 100, 16, 0);
mm->AppendMenuItem(exportMenu, 0, 0, 0, 0, true, false, PSTR("Export Glider PRO\xaa House..."));
mm->AppendMenuItem(exportMenu, 0, 0, 0, 0, false, false, PSTR("Download House..."));
UpdateMenus(false);
}

View File

@@ -585,7 +585,7 @@ int AppStartup()
FlushResolutionChange();
}
ShowInitialLaunchDisclaimer();
ShowInitialLaunchDisclaimer();
}
if (thisMac.isResolutionDirty)

View File

@@ -6,7 +6,7 @@
//============================================================================
//#include <Balloons.h>
#include "PLDrivers.h"
#include "PLNumberFormatting.h"
#include "PLKeyEncoding.h"
#include "PLHacks.h"
@@ -17,6 +17,7 @@
#include "Externs.h"
#include "Environ.h"
#include "House.h"
#include "IGpSystemServices.h"
#include "MenuManager.h"
#include "ObjectEdit.h"
@@ -32,7 +33,7 @@ void UpdateMenusHouseClosed (void);
void HeyYourPissingAHighScore (void);
MenuHandle appleMenu, gameMenu, optionsMenu, houseMenu;
MenuHandle appleMenu, gameMenu, optionsMenu, houseMenu, exportMenu;
Boolean menusUp, resumedSavedGame;
@@ -71,12 +72,12 @@ void UpdateMenusNonEditMode (void)
DisableMenuItem(gameMenu, iOpenSavedGame);
if (houseOpen)
{
EnableMenuItem(gameMenu, iLoadHouse);
EnableMenuItem(optionsMenu, iEditor);
EnableMenuItem(optionsMenu, iHighScores);
}
else
{
DisableMenuItem(gameMenu, iLoadHouse);
DisableMenuItem(optionsMenu, iEditor);
DisableMenuItem(optionsMenu, iHighScores);
}
}
@@ -85,7 +86,7 @@ void UpdateMenusNonEditMode (void)
EnableMenuItem(gameMenu, iNewGame);
EnableMenuItem(gameMenu, iTwoPlayer);
EnableMenuItem(gameMenu, iOpenSavedGame);
EnableMenuItem(gameMenu, iLoadHouse);
EnableMenuItem(optionsMenu, iEditor);
EnableMenuItem(optionsMenu, iHighScores);
}
if (demoHouseIndex == -1)
@@ -141,6 +142,19 @@ void UpdateMenusHouseOpen (void)
EnableMenuItem(houseMenu, iSendBack);
}
}
if (houseUnlocked)
{
EnableMenuItem(exportMenu, iExportGliderPROHouse);
if (PLDrivers::GetSystemServices()->GetOperatingSystem() == GpOperatingSystems::kWeb)
EnableMenuItem(exportMenu, iDownloadHouse);
}
else
{
DisableMenuItem(exportMenu, iExportGliderPROHouse);
if (PLDrivers::GetSystemServices()->GetOperatingSystem() == GpOperatingSystems::kWeb)
DisableMenuItem(exportMenu, iDownloadHouse);
}
}
//-------------------------------------------------------------- UpdateMenusHouseClosed
@@ -159,6 +173,8 @@ void UpdateMenusHouseClosed (void)
DisableMenuItem(houseMenu, iPaste);
DisableMenuItem(houseMenu, iClear);
DisableMenuItem(houseMenu, iDuplicate);
DisableMenuItem(exportMenu, iExportGliderPROHouse);
}
//-------------------------------------------------------------- UpdateClipboardMenus
@@ -254,12 +270,19 @@ void UpdateMenus (Boolean newMode)
{
PortabilityLayer::MenuManager *mm = PortabilityLayer::MenuManager::GetInstance();
if (theMode == kEditMode)
{
InsertMenu(houseMenu, 0);
InsertMenu(exportMenu, 0);
}
else
{
THandle<Menu> houseMenu = mm->GetMenuByID(kHouseMenuID);
if (houseMenu)
mm->RemoveMenu(houseMenu);
THandle<Menu> exportMenu = mm->GetMenuByID(kExportMenuID);
if (exportMenu)
mm->RemoveMenu(exportMenu);
}
}
@@ -465,6 +488,22 @@ void DoOptionsMenu (short theItem)
//-------------------------------------------------------------- DoHouseMenu
// Handle the user selecting an item from the House menu (only in Edit mode).
void DoExportMenu(short theItem)
{
switch (theItem)
{
case iExportGliderPROHouse:
ExportHouse();
break;
case iDownloadHouse:
DownloadHouse();
break;
};
}
//-------------------------------------------------------------- DoHouseMenu
// Handle the user selecting an item from the House menu (only in Edit mode).
void DoHouseMenu (short theItem)
{
#ifndef COMPILEDEMO
@@ -476,7 +515,7 @@ void DoHouseMenu (short theItem)
case iNewHouse:
if (CreateNewHouse())
{
whoCares = InitializeEmptyHouse();
whoCares = InitializeEmptyHouseInEditor();
whoCares = WriteHouse(false); // Save initial house so it's not an empty file if reloaded immediately
OpenCloseEditWindows();
}
@@ -647,6 +686,10 @@ void DoMenuChoice (long menuChoice)
case kHouseMenuID:
DoHouseMenu(theItem);
break;
case kExportMenuID:
DoExportMenu(theItem);
break;
}
}

View File

@@ -41,7 +41,11 @@ static const int kStarsOffset = 180;
static const int kGlidersOffset = 260;
static const int kScoreOffset = 320;
static void FBUI_Save_DrawLabels(DrawSurface *surface, const Point &basePoint)
struct FBUI_Save_Context
{
};
static void FBUI_Save_DrawLabels(void *context, DrawSurface *surface, const Point &basePoint)
{
PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black());
PortabilityLayer::RenderedFont *rfont = GetFont(PortabilityLayer::FontPresets::kSystem12Bold);
@@ -51,7 +55,7 @@ static void FBUI_Save_DrawLabels(DrawSurface *surface, const Point &basePoint)
surface->DrawString(basePoint + Point::Create(kScoreOffset, 0), PSTR("Score"), blackColor, rfont);
}
static void FBUI_Save_DrawFileDetails(DrawSurface *surface, const Point &basePoint, const Rect &constraintRect, void *fileDetails)
static void FBUI_Save_DrawFileDetails(void *context, DrawSurface *surface, const Point &basePoint, const Rect &constraintRect, void *fileDetails)
{
PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black());
PortabilityLayer::RenderedFont *rfont = GetFont(PortabilityLayer::FontPresets::kSystem12Bold);
@@ -70,7 +74,7 @@ static void FBUI_Save_DrawFileDetails(DrawSurface *surface, const Point &basePoi
surface->DrawString(basePoint + Point::Create(kScoreOffset, 0), numStr, blackColor, rfont);
}
static void *FBUI_Save_LoadFileDetails(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
static void *FBUI_Save_LoadFileDetails(void *context, PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
{
GpIOStream *stream = nullptr;
if (PortabilityLayer::FileManager::GetInstance()->OpenNonCompositeFile(dirID, filename, ".sav", PortabilityLayer::EFilePermission_Read, GpFileCreationDispositions::kOpenExisting, stream) != PLErrors::kNone)
@@ -97,25 +101,37 @@ static void *FBUI_Save_LoadFileDetails(PortabilityLayer::VirtualDirectory_t dirI
return gameData;
}
static void FBUI_Save_FreeFileDetails(void *fileDetails)
static void FBUI_Save_FreeFileDetails(void *context, void *fileDetails)
{
PortabilityLayer::MemoryManager::GetInstance()->Release(fileDetails);
}
static bool FBUI_Save_FilterFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
static bool FBUI_Save_FilterFile(void *context, PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
{
return true;
}
static PortabilityLayer::FileBrowserUI_DetailsCallbackAPI GetSavedGameDetailsAPI()
static bool FBUI_Save_IsDeleteValid(void *context, PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
{
return true;
}
static void FBUI_Save_OnDeleted(void *context, PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
{
}
static PortabilityLayer::FileBrowserUI_DetailsCallbackAPI GetSavedGameDetailsAPI(FBUI_Save_Context *context)
{
PortabilityLayer::FileBrowserUI_DetailsCallbackAPI api;
api.m_context = context;
api.m_drawLabelsCallback = FBUI_Save_DrawLabels;
api.m_drawFileDetailsCallback = FBUI_Save_DrawFileDetails;
api.m_loadFileDetailsCallback = FBUI_Save_LoadFileDetails;
api.m_freeFileDetailsCallback = FBUI_Save_FreeFileDetails;
api.m_filterFileCallback = FBUI_Save_FilterFile;
api.m_isDeleteValidCallback = FBUI_Save_IsDeleteValid;
api.m_onDeletedCallback = FBUI_Save_OnDeleted;
return api;
}
@@ -169,7 +185,8 @@ Boolean SaveGame2 (void)
char savePath[sizeof(spec.m_name) + 1];
size_t savePathLength = 0;
if (!fm->PromptSaveFile(spec.m_dir, ".sav", savePath, savePathLength, sizeof(spec.m_name), PLPasStr(gameNameStr), PSTR("Save Game"), false, GetSavedGameDetailsAPI()))
FBUI_Save_Context context;
if (!fm->PromptSaveFile(spec.m_dir, ".sav", savePath, savePathLength, sizeof(spec.m_name), PLPasStr(gameNameStr), PSTR("Save Game"), false, GetSavedGameDetailsAPI(&context)))
{
mm->Release(savedGame);
return false;
@@ -266,7 +283,8 @@ Boolean OpenSavedGame (void)
char savePath[sizeof(spec.m_name) + 1];
size_t savePathLength = 0;
if (!fm->PromptOpenFile(spec.m_dir, ".sav", savePath, savePathLength, sizeof(spec.m_name), PSTR("Open Saved Game"), false, GetSavedGameDetailsAPI()))
FBUI_Save_Context context;
if (!fm->PromptOpenFile(spec.m_dir, ".sav", savePath, savePathLength, sizeof(spec.m_name), PSTR("Open Saved Game"), false, GetSavedGameDetailsAPI(&context)))
return false;
assert(savePathLength < sizeof(spec.m_name) - 1);

View File

@@ -23,7 +23,7 @@
#define kBaseBufferSoundID 1000
#define kMaxSounds 64
#define kMaxSounds 65
void CallBack0 (PortabilityLayer::AudioChannel *);
@@ -38,7 +38,7 @@ IGpAudioBuffer *ParseAndConvertSound(const THandle<void> &handle);
PortabilityLayer::AudioChannel *channel0, *channel1, *channel2;
IGpAudioBuffer *theSoundData[kMaxSounds];
short numSoundsLoaded;
Boolean soundLoaded[kMaxSounds], dontLoadSounds;
Boolean dontLoadSounds;
Boolean channelOpen, isSoundOn, failedSound;
//============================================================== Functions
@@ -341,6 +341,14 @@ void CloseSoundChannels (void)
channelOpen = false;
}
//-------------------------------------------------------------- PingBeep
void PingBeep (int duration)
{
PlayPrioritySound(kPingSound, kPingPriority);
}
//-------------------------------------------------------------- InitSound
void InitSound (void)
@@ -376,6 +384,8 @@ void InitSound (void)
failedSound = true;
}
}
SetBeepFunction (PingBeep);
}
//-------------------------------------------------------------- KillSound
@@ -404,23 +414,23 @@ void TellHerNoSounds (void)
//-------------------------------------------------------------- ParseAndConvertSound
IGpAudioBuffer *ParseAndConvertSoundChecked(const THandle<void> &handle)
bool ParseAndConvertSoundChecked(const THandle<void> &handle, void const*& outDataContents, size_t &outDataSize)
{
const uint8_t *dataStart = static_cast<const uint8_t*>(*handle);
const size_t size = handle.MMBlock()->m_size;
if (size < sizeof(PortabilityLayer::RIFFTag))
return nullptr;
return false;
PortabilityLayer::RIFFTag mainRiffTag;
memcpy(&mainRiffTag, dataStart, sizeof(PortabilityLayer::RIFFTag));
if (mainRiffTag.m_tag != PortabilityLayer::WaveConstants::kRiffChunkID)
return nullptr;
return false;
const uint32_t riffSize = mainRiffTag.m_chunkSize;
if (riffSize < 4 || riffSize - 4 > size - sizeof(PortabilityLayer::RIFFTag))
return nullptr;
return false;
const uint8_t *riffStart = dataStart + sizeof(PortabilityLayer::RIFFTag);
const uint8_t *riffEnd = riffStart + riffSize;
@@ -432,7 +442,7 @@ IGpAudioBuffer *ParseAndConvertSoundChecked(const THandle<void> &handle)
memcpy(&waveMarker, riffStart, 4);
if (waveMarker != PortabilityLayer::WaveConstants::kWaveChunkID)
return nullptr;
return false;
const uint8_t *tagSearchLoc = riffStart + 4;
@@ -440,7 +450,7 @@ IGpAudioBuffer *ParseAndConvertSoundChecked(const THandle<void> &handle)
while (tagSearchLoc != riffEnd)
{
if (riffEnd - tagSearchLoc < sizeof(PortabilityLayer::RIFFTag))
return nullptr;
return false;
PortabilityLayer::RIFFTag riffTag;
memcpy(&riffTag, tagSearchLoc, sizeof(PortabilityLayer::RIFFTag));
@@ -453,20 +463,20 @@ IGpAudioBuffer *ParseAndConvertSoundChecked(const THandle<void> &handle)
const uint32_t riffTagSizeUnpadded = riffTag.m_chunkSize;
if (riffTagSizeUnpadded == 0xffffffffU)
return nullptr;
return false;
const uint32_t riffTagSizePadded = riffTagSizeUnpadded + (riffTagSizeUnpadded & 1);
tagSearchLoc += sizeof(PortabilityLayer::RIFFTag);
if (riffEnd - tagSearchLoc < riffTagSizePadded)
return nullptr;
return false;
tagSearchLoc += riffTagSizePadded;
}
if (formatTagLoc == nullptr || dataTagLoc == nullptr)
return nullptr;
return false;
PortabilityLayer::RIFFTag fmtTag;
memcpy(&fmtTag, formatTagLoc, sizeof(PortabilityLayer::RIFFTag));
@@ -500,7 +510,7 @@ IGpAudioBuffer *ParseAndConvertSoundChecked(const THandle<void> &handle)
copyableSize = sizeof(PortabilityLayer::WaveFormatChunkV1);
}
else
return nullptr;
return false;
memcpy(&formatChunkV3, formatContents, copyableSize);
@@ -508,23 +518,22 @@ IGpAudioBuffer *ParseAndConvertSoundChecked(const THandle<void> &handle)
const PortabilityLayer::WaveFormatChunkV1 formatChunkV1 = formatChunkV2.m_v1;
if (formatChunkV1.m_bitsPerSample != 8)
return nullptr;
return false;
if (formatChunkV1.m_formatCode != PortabilityLayer::WaveConstants::kFormatPCM ||
formatChunkV1.m_numChannels != 1 ||
formatChunkV1.m_blockAlignmentBytes != 1 ||
formatChunkV1.m_bitsPerSample != 8)
return nullptr;
return false;
uint32_t dataSize = dataTag.m_chunkSize;
if (dataSize > 0x1000000 || dataSize < 1)
return nullptr;
return false;
IGpAudioDriver *audioDriver = PLDrivers::GetAudioDriver();
if (!audioDriver)
return nullptr;
outDataContents = dataContents;
outDataSize = dataSize;
return audioDriver->CreateBuffer(dataContents, dataSize);
return true;
}
IGpAudioBuffer *ParseAndConvertSound(const THandle<void> &handle)
@@ -532,6 +541,14 @@ IGpAudioBuffer *ParseAndConvertSound(const THandle<void> &handle)
if (!handle)
return nullptr;
IGpAudioBuffer *buffer = ParseAndConvertSoundChecked(handle);
return buffer;
IGpAudioDriver *audioDriver = PLDrivers::GetAudioDriver();
if (!audioDriver)
return nullptr;
const void *dataContents = nullptr;
size_t dataSize = 0;
if (!ParseAndConvertSoundChecked(handle, dataContents, dataSize))
return nullptr;
return audioDriver->CreateBuffer(dataContents, dataSize);
}