mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-22 22:45:39 +00:00
Compare commits
76 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2fe1ea2ee7 | ||
|
0931f25f23 | ||
|
7f4d782c0d | ||
|
f2cda23b0f | ||
|
6292705968 | ||
|
6931b3f505 | ||
|
d70a5b3bfc | ||
|
f0913d0d6a | ||
|
80584eb781 | ||
|
fe4a8a55c6 | ||
|
55ec6c516c | ||
|
3917e1a370 | ||
|
6715bcb030 | ||
|
c981a97a20 | ||
|
a5562f96e0 | ||
|
d97bd8ad1c | ||
|
a43f32ab88 | ||
|
e94d1511b1 | ||
|
95e4eb4e34 | ||
|
15bdb97c38 | ||
|
e7246c1444 | ||
|
35b8e922d7 | ||
|
3090f70ee6 | ||
|
484e18a9af | ||
|
83d37a7c94 | ||
|
fc043af3a1 | ||
|
2ebd3f2cf3 | ||
|
ebab2ee188 | ||
|
032e44d981 | ||
|
7961ca3af7 | ||
|
6851025147 | ||
|
f0b1d6fff9 | ||
|
70e0948847 | ||
|
a698286087 | ||
|
b75313fd7b | ||
|
cab862ed8b | ||
|
553e343abe | ||
|
0aa36b27a9 | ||
|
f6185b1c78 | ||
|
ff29d5b92c | ||
|
964c9b8858 | ||
|
8a48726b2e | ||
|
de06669239 | ||
|
c0abd77dc4 | ||
|
754b988f09 | ||
|
1c57a51316 | ||
|
80abb498af | ||
|
29cc376438 | ||
|
ef12c471a7 | ||
|
8f4ecfafe1 | ||
|
3c3f9e3675 | ||
|
5c640b72eb | ||
|
9d0f2c35b3 | ||
|
7df624d9b1 | ||
|
29fbe83e8d | ||
|
ad3a878a16 | ||
|
f0e7379db6 | ||
|
e34fec38a2 | ||
|
76db422456 | ||
|
396d107608 | ||
|
30b39c6991 | ||
|
9dafba1092 | ||
|
801408077a | ||
|
2c073937c3 | ||
|
bbd147e1ab | ||
|
66a111dd23 | ||
|
2febed5d2a | ||
|
b47813330a | ||
|
0f630a74a2 | ||
|
edc43e0bed | ||
|
2aca0b6b28 | ||
|
f9a101486c | ||
|
dbf3303145 | ||
|
a28a4cd73d | ||
|
4c6e646133 | ||
|
a13f90bd71 |
@@ -46,6 +46,9 @@ EndProject
|
||||
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "ReleasePackageInstaller", "ReleasePackageInstaller\ReleasePackageInstaller.wixproj", "{D26BD501-28A7-4849-8130-FB5EA0A2B82F}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{7EFF1E21-C375-45EA-A069-4E2232C8A72B} = {7EFF1E21-C375-45EA-A069-4E2232C8A72B}
|
||||
{B852D549-4020-4477-8BFB-E199FF78B047} = {B852D549-4020-4477-8BFB-E199FF78B047}
|
||||
{2FF15659-5C72-48B8-B55B-3C658E4125B5} = {2FF15659-5C72-48B8-B55B-3C658E4125B5}
|
||||
{36DAF5FA-6ADB-4F20-9810-1610DE0AE653} = {36DAF5FA-6ADB-4F20-9810-1610DE0AE653}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WindowsUnicodeToolShim", "WindowsUnicodeToolShim\WindowsUnicodeToolShim.vcxproj", "{15009625-1120-405E-8BBA-69A16CD6713D}"
|
||||
@@ -58,6 +61,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GpFontHandler_FreeType2", "
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AerofoilSDL", "AerofoilSDL\AerofoilSDL.vcxproj", "{33542FF0-0473-4802-BC79-3B8261790F65}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MergeGPF", "MergeGPF\MergeGPF.vcxproj", "{36DAF5FA-6ADB-4F20-9810-1610DE0AE653}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@@ -166,6 +171,10 @@ Global
|
||||
{33542FF0-0473-4802-BC79-3B8261790F65}.Debug|x64.Build.0 = Debug|x64
|
||||
{33542FF0-0473-4802-BC79-3B8261790F65}.Release|x64.ActiveCfg = Release|x64
|
||||
{33542FF0-0473-4802-BC79-3B8261790F65}.Release|x64.Build.0 = Release|x64
|
||||
{36DAF5FA-6ADB-4F20-9810-1610DE0AE653}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{36DAF5FA-6ADB-4F20-9810-1610DE0AE653}.Debug|x64.Build.0 = Debug|x64
|
||||
{36DAF5FA-6ADB-4F20-9810-1610DE0AE653}.Release|x64.ActiveCfg = Release|x64
|
||||
{36DAF5FA-6ADB-4F20-9810-1610DE0AE653}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@@ -28,7 +28,7 @@ namespace GpFiberStarter_Win32
|
||||
}
|
||||
}
|
||||
|
||||
IGpFiber *GpFiberStarter::StartFiber(PortabilityLayer::HostSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
|
||||
IGpFiber *GpFiberStarter::StartFiber(IGpSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
|
||||
{
|
||||
ULONG_PTR lowLimit;
|
||||
ULONG_PTR highLimit;
|
||||
|
@@ -99,24 +99,6 @@ bool GpFileStream_Win32::SeekEnd(GpUFilePos_t loc)
|
||||
return SetFilePointerEx(m_handle, li, nullptr, FILE_END) != 0;
|
||||
}
|
||||
|
||||
bool GpFileStream_Win32::Truncate(GpUFilePos_t loc)
|
||||
{
|
||||
if (!m_writeable)
|
||||
return false;
|
||||
|
||||
GpUFilePos_t oldPos = Tell();
|
||||
if (!SeekStart(loc))
|
||||
return false;
|
||||
|
||||
if (!SetEndOfFile(m_handle))
|
||||
return false;
|
||||
|
||||
if (!SeekStart(oldPos))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GpUFilePos_t GpFileStream_Win32::Size() const
|
||||
{
|
||||
LARGE_INTEGER fsize;
|
||||
|
@@ -17,7 +17,6 @@ public:
|
||||
bool SeekStart(GpUFilePos_t loc) override;
|
||||
bool SeekCurrent(GpFilePos_t loc) override;
|
||||
bool SeekEnd(GpUFilePos_t loc) override;
|
||||
bool Truncate(GpUFilePos_t loc) override;
|
||||
GpUFilePos_t Size() const override;
|
||||
GpUFilePos_t Tell() const override;
|
||||
void Close() override;
|
||||
|
@@ -3,8 +3,7 @@
|
||||
#include "GpApplicationName.h"
|
||||
#include "GpFileStream_Win32.h"
|
||||
#include "GpWindows.h"
|
||||
#include "GpMemoryBuffer.h"
|
||||
#include "HostDirectoryCursor.h"
|
||||
#include "IGpDirectoryCursor.h"
|
||||
|
||||
#include <string>
|
||||
#include <Shlwapi.h>
|
||||
@@ -15,7 +14,7 @@
|
||||
|
||||
extern GpWindowsGlobals g_gpWindowsGlobals;
|
||||
|
||||
class GpDirectoryCursor_Win32 final : public PortabilityLayer::HostDirectoryCursor
|
||||
class GpDirectoryCursor_Win32 final : public IGpDirectoryCursor
|
||||
{
|
||||
public:
|
||||
static GpDirectoryCursor_Win32 *Create(const HANDLE &handle, const WIN32_FIND_DATAW &findData);
|
||||
@@ -192,24 +191,24 @@ bool GpFileSystem_Win32::FileExists(PortabilityLayer::VirtualDirectory_t virtual
|
||||
return PathFileExistsW(winPath) != 0;
|
||||
}
|
||||
|
||||
bool GpFileSystem_Win32::FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool *exists)
|
||||
bool GpFileSystem_Win32::FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &exists)
|
||||
{
|
||||
wchar_t winPath[MAX_PATH + 1];
|
||||
|
||||
if (!ResolvePath(virtualDirectory, &path, 1, winPath))
|
||||
{
|
||||
*exists = false;
|
||||
exists = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD attribs = GetFileAttributesW(winPath);
|
||||
if (attribs == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
*exists = false;
|
||||
exists = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
*exists = true;
|
||||
exists = true;
|
||||
return (attribs & FILE_ATTRIBUTE_READONLY) != 0;
|
||||
}
|
||||
|
||||
@@ -273,7 +272,7 @@ bool GpFileSystem_Win32::DeleteFile(PortabilityLayer::VirtualDirectory_t virtual
|
||||
return false;
|
||||
}
|
||||
|
||||
PortabilityLayer::HostDirectoryCursor *GpFileSystem_Win32::ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths)
|
||||
IGpDirectoryCursor *GpFileSystem_Win32::ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths)
|
||||
{
|
||||
wchar_t winPath[MAX_PATH + 2];
|
||||
|
||||
@@ -320,11 +319,6 @@ bool GpFileSystem_Win32::ValidateFilePathUnicodeChar(uint32_t c) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GpFileSystem_Win32::IsVirtualDirectoryLooseResources(PortabilityLayer::VirtualDirectory_t virtualDir) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void GpFileSystem_Win32::SetMainThreadRelay(IGpThreadRelay *relay)
|
||||
{
|
||||
(void)relay;
|
||||
@@ -342,7 +336,7 @@ bool GpFileSystem_Win32::ValidateFilePath(const char *str, size_t length) const
|
||||
if (c >= '0' && c <= '9')
|
||||
continue;
|
||||
|
||||
if (c == '_' || c == '.' || c == '\'')
|
||||
if (c == '_' || c == '.' || c == '\'' || c == '!')
|
||||
continue;
|
||||
|
||||
if (c == ' ' && i != 0 && i != length - 1)
|
||||
|
@@ -1,28 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "HostFileSystem.h"
|
||||
#include "IGpFileSystem.h"
|
||||
|
||||
#include "GpCoreDefs.h"
|
||||
#include "GpWindows.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class GpFileSystem_Win32 final : public PortabilityLayer::HostFileSystem
|
||||
class GpFileSystem_Win32 final : public IGpFileSystem
|
||||
{
|
||||
public:
|
||||
GpFileSystem_Win32();
|
||||
|
||||
bool FileExists(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path) override;
|
||||
bool FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool *exists) override;
|
||||
bool FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &exists) override;
|
||||
GpIOStream *OpenFileNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths, bool writeAccess, GpFileCreationDisposition_t createDisposition) override;
|
||||
bool DeleteFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &existed) override;
|
||||
PortabilityLayer::HostDirectoryCursor *ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths) override;
|
||||
IGpDirectoryCursor *ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths) override;
|
||||
|
||||
bool ValidateFilePath(const char *path, size_t sz) const override;
|
||||
bool ValidateFilePathUnicodeChar(uint32_t ch) const override;
|
||||
|
||||
bool IsVirtualDirectoryLooseResources(PortabilityLayer::VirtualDirectory_t virtualDir) const override;
|
||||
|
||||
void SetMainThreadRelay(IGpThreadRelay *relay) override;
|
||||
void SetDelayCallback(DelayCallback_t delayCallback) override;
|
||||
|
||||
|
@@ -12,10 +12,9 @@
|
||||
#include "GpAppInterface.h"
|
||||
#include "GpSystemServices_Win32.h"
|
||||
#include "GpVOSEvent.h"
|
||||
#include "IGpFileSystem.h"
|
||||
#include "IGpVOSEventQueue.h"
|
||||
|
||||
#include "HostFileSystem.h"
|
||||
|
||||
#include "GpWindows.h"
|
||||
|
||||
#include "resource.h"
|
||||
@@ -414,9 +413,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
|
||||
IGpLogDriver *logger = GpLogDriver_Win32::GetInstance();
|
||||
|
||||
GpAppInterface_Get()->PL_HostFileSystem_SetInstance(GpFileSystem_Win32::GetInstance());
|
||||
GpAppInterface_Get()->PL_HostSystemServices_SetInstance(GpSystemServices_Win32::GetInstance());
|
||||
GpAppInterface_Get()->PL_HostLogDriver_SetInstance(GpLogDriver_Win32::GetInstance());
|
||||
GpDriverCollection *drivers = GpAppInterface_Get()->PL_GetDriverCollection();
|
||||
|
||||
drivers->SetDriver<GpDriverIDs::kFileSystem>(GpFileSystem_Win32::GetInstance());
|
||||
drivers->SetDriver<GpDriverIDs::kSystemServices>(GpSystemServices_Win32::GetInstance());
|
||||
drivers->SetDriver<GpDriverIDs::kLog>(GpLogDriver_Win32::GetInstance());
|
||||
|
||||
g_gpWindowsGlobals.m_hInstance = hInstance;
|
||||
g_gpWindowsGlobals.m_hPrevInstance = hPrevInstance;
|
||||
|
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "HostMutex.h"
|
||||
#include "IGpMutex.h"
|
||||
|
||||
#include "GpWindows.h"
|
||||
|
||||
class GpMutex_Win32 final : public PortabilityLayer::HostMutex
|
||||
class GpMutex_Win32 final : public IGpMutex
|
||||
{
|
||||
public:
|
||||
void Destroy() override;
|
||||
|
@@ -1,19 +1,122 @@
|
||||
#include "GpSystemServices_Win32.h"
|
||||
#include "GpMutex_Win32.h"
|
||||
#include "GpThreadEvent_Win32.h"
|
||||
#include "GpWindows.h"
|
||||
|
||||
#include "IGpClipboardContents.h"
|
||||
|
||||
#include "UTF16.h"
|
||||
#include "UTF8.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
|
||||
#pragma push_macro("CreateMutex")
|
||||
#ifdef CreateMutex
|
||||
#undef CreateMutex
|
||||
#endif
|
||||
|
||||
extern GpWindowsGlobals g_gpWindowsGlobals;
|
||||
|
||||
namespace GpSystemServices_Win32_Private
|
||||
{
|
||||
class RefCountedClipboard
|
||||
{
|
||||
public:
|
||||
RefCountedClipboard();
|
||||
|
||||
protected:
|
||||
virtual ~RefCountedClipboard();
|
||||
|
||||
void AddRef();
|
||||
void DecRef();
|
||||
|
||||
unsigned int m_refCount;
|
||||
};
|
||||
|
||||
class TextClipboard : public RefCountedClipboard, public IGpClipboardContentsText
|
||||
{
|
||||
public:
|
||||
TextClipboard(const uint8_t *utf8Text, size_t utf8Size);
|
||||
~TextClipboard() override;
|
||||
|
||||
GpClipboardContentsType_t GetContentsType() const override;
|
||||
void Destroy() override;
|
||||
IGpClipboardContents *Clone() const override;
|
||||
const uint8_t *GetBytes() const override;
|
||||
size_t GetSize() const override;
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> m_utf8Text;
|
||||
};
|
||||
|
||||
|
||||
RefCountedClipboard::RefCountedClipboard()
|
||||
: m_refCount(1)
|
||||
{
|
||||
}
|
||||
|
||||
RefCountedClipboard::~RefCountedClipboard()
|
||||
{
|
||||
}
|
||||
|
||||
void RefCountedClipboard::AddRef()
|
||||
{
|
||||
m_refCount++;
|
||||
}
|
||||
|
||||
void RefCountedClipboard::DecRef()
|
||||
{
|
||||
unsigned int rc = --m_refCount;
|
||||
if (rc == 0)
|
||||
delete this;
|
||||
}
|
||||
|
||||
TextClipboard::TextClipboard(const uint8_t *utf8Text, size_t utf8Size)
|
||||
{
|
||||
m_utf8Text.resize(utf8Size);
|
||||
if (utf8Size > 0)
|
||||
memcpy(&m_utf8Text[0], utf8Text, utf8Size);
|
||||
}
|
||||
|
||||
TextClipboard::~TextClipboard()
|
||||
{
|
||||
}
|
||||
|
||||
GpClipboardContentsType_t TextClipboard::GetContentsType() const
|
||||
{
|
||||
return GpClipboardContentsTypes::kText;
|
||||
}
|
||||
|
||||
void TextClipboard::Destroy()
|
||||
{
|
||||
this->DecRef();
|
||||
}
|
||||
|
||||
IGpClipboardContents *TextClipboard::Clone() const
|
||||
{
|
||||
const_cast<TextClipboard*>(this)->AddRef();
|
||||
return const_cast<TextClipboard*>(this);
|
||||
}
|
||||
|
||||
const uint8_t *TextClipboard::GetBytes() const
|
||||
{
|
||||
if (m_utf8Text.size() == 0)
|
||||
return nullptr;
|
||||
return &m_utf8Text[0];
|
||||
}
|
||||
|
||||
size_t TextClipboard::GetSize() const
|
||||
{
|
||||
return m_utf8Text.size();
|
||||
}
|
||||
}
|
||||
|
||||
struct GpSystemServices_Win32_ThreadStartParams
|
||||
{
|
||||
GpSystemServices_Win32::ThreadFunc_t m_threadFunc;
|
||||
void *m_threadContext;
|
||||
PortabilityLayer::HostThreadEvent *m_threadStartEvent;
|
||||
IGpThreadEvent *m_threadStartEvent;
|
||||
};
|
||||
|
||||
static DWORD WINAPI StaticStartThread(LPVOID lpThreadParameter)
|
||||
@@ -22,7 +125,7 @@ static DWORD WINAPI StaticStartThread(LPVOID lpThreadParameter)
|
||||
|
||||
GpSystemServices_Win32::ThreadFunc_t threadFunc = threadParams->m_threadFunc;
|
||||
void *threadContext = threadParams->m_threadContext;
|
||||
PortabilityLayer::HostThreadEvent *threadStartEvent = threadParams->m_threadStartEvent;
|
||||
IGpThreadEvent *threadStartEvent = threadParams->m_threadStartEvent;
|
||||
|
||||
threadStartEvent->Signal();
|
||||
|
||||
@@ -34,6 +137,10 @@ GpSystemServices_Win32::GpSystemServices_Win32()
|
||||
{
|
||||
}
|
||||
|
||||
GpSystemServices_Win32::~GpSystemServices_Win32()
|
||||
{
|
||||
}
|
||||
|
||||
int64_t GpSystemServices_Win32::GetTime() const
|
||||
{
|
||||
SYSTEMTIME epochStart;
|
||||
@@ -72,24 +179,24 @@ void GpSystemServices_Win32::GetLocalDateTime(unsigned int &year, unsigned int &
|
||||
second = localTime.wSecond;
|
||||
}
|
||||
|
||||
PortabilityLayer::HostMutex *GpSystemServices_Win32::CreateMutex()
|
||||
IGpMutex *GpSystemServices_Win32::CreateMutex()
|
||||
{
|
||||
return GpMutex_Win32::Create();
|
||||
}
|
||||
|
||||
PortabilityLayer::HostMutex *GpSystemServices_Win32::CreateRecursiveMutex()
|
||||
IGpMutex *GpSystemServices_Win32::CreateRecursiveMutex()
|
||||
{
|
||||
return GpMutex_Win32::Create();
|
||||
}
|
||||
|
||||
PortabilityLayer::HostThreadEvent *GpSystemServices_Win32::CreateThreadEvent(bool autoReset, bool startSignaled)
|
||||
IGpThreadEvent *GpSystemServices_Win32::CreateThreadEvent(bool autoReset, bool startSignaled)
|
||||
{
|
||||
return GpThreadEvent_Win32::Create(autoReset, startSignaled);
|
||||
}
|
||||
|
||||
void *GpSystemServices_Win32::CreateThread(ThreadFunc_t threadFunc, void *context)
|
||||
{
|
||||
PortabilityLayer::HostThreadEvent *evt = CreateThreadEvent(true, false);
|
||||
IGpThreadEvent *evt = CreateThreadEvent(true, false);
|
||||
if (!evt)
|
||||
return nullptr;
|
||||
|
||||
@@ -144,6 +251,16 @@ bool GpSystemServices_Win32::IsTextInputObstructive() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GpSystemServices_Win32::IsFullscreenPreferred() const
|
||||
{
|
||||
return !m_isTouchscreenSimulation;
|
||||
}
|
||||
|
||||
bool GpSystemServices_Win32::IsFullscreenOnStartup() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int GpSystemServices_Win32::GetCPUCount() const
|
||||
{
|
||||
SYSTEM_INFO sysInfo;
|
||||
@@ -161,6 +278,95 @@ bool GpSystemServices_Win32::IsTextInputEnabled() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GpSystemServices_Win32::AreFontResourcesSeekable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
IGpClipboardContents *GpSystemServices_Win32::GetClipboardContents() const
|
||||
{
|
||||
IGpClipboardContents *cbObject = nullptr;
|
||||
|
||||
if (IsClipboardFormatAvailable(CF_UNICODETEXT))
|
||||
{
|
||||
if (OpenClipboard(g_gpWindowsGlobals.m_hwnd))
|
||||
{
|
||||
HGLOBAL textHandle = GetClipboardData(CF_UNICODETEXT);
|
||||
if (textHandle)
|
||||
{
|
||||
const wchar_t *str = static_cast<const wchar_t*>(GlobalLock(textHandle));
|
||||
if (str)
|
||||
{
|
||||
if (str[0] == 0)
|
||||
cbObject = new GpSystemServices_Win32_Private::TextClipboard(nullptr, 0);
|
||||
else
|
||||
{
|
||||
int bytesRequired = WideCharToMultiByte(CP_UTF8, 0, str, -1, nullptr, 0, nullptr, nullptr);
|
||||
|
||||
if (bytesRequired > 0)
|
||||
{
|
||||
std::vector<char> decodedText;
|
||||
decodedText.resize(bytesRequired);
|
||||
WideCharToMultiByte(CP_UTF8, 0, str, -1, &decodedText[0], bytesRequired, nullptr, nullptr);
|
||||
|
||||
cbObject = new GpSystemServices_Win32_Private::TextClipboard(reinterpret_cast<const uint8_t*>(&decodedText[0]), decodedText.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
GlobalUnlock(textHandle);
|
||||
}
|
||||
}
|
||||
CloseClipboard();
|
||||
}
|
||||
}
|
||||
|
||||
return cbObject;
|
||||
}
|
||||
|
||||
void GpSystemServices_Win32::SetClipboardContents(IGpClipboardContents *contents)
|
||||
{
|
||||
if (!contents)
|
||||
return;
|
||||
|
||||
if (contents->GetContentsType() == GpClipboardContentsTypes::kText)
|
||||
{
|
||||
IGpClipboardContentsText *textContents = static_cast<IGpClipboardContentsText*>(contents);
|
||||
|
||||
if (OpenClipboard(g_gpWindowsGlobals.m_hwnd))
|
||||
{
|
||||
if (EmptyClipboard())
|
||||
{
|
||||
int wcharsRequired = MultiByteToWideChar(CP_UTF8, 0, reinterpret_cast<const char*>(textContents->GetBytes()), textContents->GetSize(), nullptr, 0);
|
||||
|
||||
std::vector<wchar_t> wideChars;
|
||||
|
||||
if (wcharsRequired)
|
||||
{
|
||||
wideChars.resize(wcharsRequired + 1);
|
||||
MultiByteToWideChar(CP_UTF8, 0, reinterpret_cast<const char*>(textContents->GetBytes()), textContents->GetSize(), &wideChars[0], wcharsRequired);
|
||||
}
|
||||
else
|
||||
wideChars.resize(1);
|
||||
|
||||
wideChars[wideChars.size() - 1] = static_cast<wchar_t>(0);
|
||||
|
||||
HGLOBAL textObject = GlobalAlloc(GMEM_MOVEABLE, wideChars.size() * sizeof(wchar_t));
|
||||
if (textObject)
|
||||
{
|
||||
wchar_t *buffer = static_cast<wchar_t*>(GlobalLock(textObject));
|
||||
memcpy(buffer, &wideChars[0], wideChars.size() * sizeof(wchar_t));
|
||||
GlobalUnlock(textObject);
|
||||
|
||||
SetClipboardData(CF_UNICODETEXT, textObject);
|
||||
}
|
||||
}
|
||||
|
||||
CloseClipboard();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GpSystemServices_Win32::SetTouchscreenSimulation(bool isTouchscreenSimulation)
|
||||
{
|
||||
m_isTouchscreenSimulation = isTouchscreenSimulation;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "HostSystemServices.h"
|
||||
#include "IGpSystemServices.h"
|
||||
#include "GpCoreDefs.h"
|
||||
#include "GpWindows.h"
|
||||
|
||||
@@ -15,25 +15,31 @@
|
||||
#endif
|
||||
|
||||
|
||||
class GpSystemServices_Win32 final : public PortabilityLayer::HostSystemServices
|
||||
class GpSystemServices_Win32 final : public IGpSystemServices
|
||||
{
|
||||
public:
|
||||
GpSystemServices_Win32();
|
||||
~GpSystemServices_Win32();
|
||||
|
||||
int64_t GetTime() const override;
|
||||
void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const override;
|
||||
PortabilityLayer::HostMutex *CreateMutex() override;
|
||||
PortabilityLayer::HostMutex *CreateRecursiveMutex() override;
|
||||
IGpMutex *CreateMutex() override;
|
||||
IGpMutex *CreateRecursiveMutex() override;
|
||||
void *CreateThread(ThreadFunc_t threadFunc, void *context) override;
|
||||
PortabilityLayer::HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
|
||||
IGpThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
|
||||
uint64_t GetFreeMemoryCosmetic() const override;
|
||||
void Beep() const override;
|
||||
bool IsTouchscreen() const override;
|
||||
bool IsUsingMouseAsTouch() const override;
|
||||
bool IsTextInputObstructive() const override;
|
||||
bool IsFullscreenPreferred() const override;
|
||||
bool IsFullscreenOnStartup() const override;
|
||||
unsigned int GetCPUCount() const override;
|
||||
void SetTextInputEnabled(bool isEnabled) override;
|
||||
bool IsTextInputEnabled() const override;
|
||||
bool AreFontResourcesSeekable() const override;
|
||||
IGpClipboardContents *GetClipboardContents() const override;
|
||||
void SetClipboardContents(IGpClipboardContents *contents) override;
|
||||
|
||||
void SetTouchscreenSimulation(bool isTouchscreenSimulation);
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "HostThreadEvent.h"
|
||||
#include "IGpThreadEvent.h"
|
||||
|
||||
#include "GpWindows.h"
|
||||
|
||||
class GpThreadEvent_Win32 final : public PortabilityLayer::HostThreadEvent
|
||||
class GpThreadEvent_Win32 final : public IGpThreadEvent
|
||||
{
|
||||
public:
|
||||
void Wait() override;
|
||||
|
@@ -15,8 +15,8 @@ android {
|
||||
}
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
versionCode 4
|
||||
versionName "1.0.9b2"
|
||||
versionCode 11
|
||||
versionName "1.0.15"
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
arguments "APP_PLATFORM=android-16"
|
||||
@@ -66,7 +66,7 @@ android {
|
||||
}
|
||||
|
||||
aaptOptions {
|
||||
noCompress 'gpa'
|
||||
noCompress 'gpf'
|
||||
}
|
||||
}
|
||||
|
||||
|
1
AerofoilAndroid/app/jni/AerofoilPortable
Symbolic link
1
AerofoilAndroid/app/jni/AerofoilPortable
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../AerofoilPortable
|
@@ -9,6 +9,7 @@ SDL_PATH := ../SDL
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include \
|
||||
$(LOCAL_PATH)/../GpShell \
|
||||
$(LOCAL_PATH)/../GpCommon \
|
||||
$(LOCAL_PATH)/../AerofoilPortable \
|
||||
$(LOCAL_PATH)/../AerofoilSDL \
|
||||
$(LOCAL_PATH)/../Common \
|
||||
$(LOCAL_PATH)/../PortabilityLayer
|
||||
@@ -23,7 +24,7 @@ LOCAL_SRC_FILES := \
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := SDL2
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := GpShell GpFontHandler_FreeType2 AerofoilSDL GpApp
|
||||
LOCAL_STATIC_LIBRARIES := GpShell GpFontHandler_FreeType2 AerofoilPortable AerofoilSDL GpApp
|
||||
|
||||
LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog
|
||||
|
||||
|
@@ -1,12 +1,14 @@
|
||||
#define _LARGEFILE64_SOURCE
|
||||
#include "GpFileSystem_Android.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "HostDirectoryCursor.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "HostMutex.h"
|
||||
#include "IGpDirectoryCursor.h"
|
||||
#include "IGpSystemServices.h"
|
||||
#include "IGpMutex.h"
|
||||
#include "IGpThreadRelay.h"
|
||||
#include "VirtualDirectory.h"
|
||||
|
||||
#include "PLDrivers.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_rwops.h"
|
||||
|
||||
@@ -40,7 +42,6 @@ public:
|
||||
bool SeekStart(GpUFilePos_t loc) override;
|
||||
bool SeekCurrent(GpFilePos_t loc) override;
|
||||
bool SeekEnd(GpUFilePos_t loc) override;
|
||||
bool Truncate(GpUFilePos_t loc) override;
|
||||
GpUFilePos_t Size() const override;
|
||||
GpUFilePos_t Tell() const override;
|
||||
void Close() override;
|
||||
@@ -68,7 +69,6 @@ public:
|
||||
bool SeekStart(GpUFilePos_t loc) override;
|
||||
bool SeekCurrent(GpFilePos_t loc) override;
|
||||
bool SeekEnd(GpUFilePos_t loc) override;
|
||||
bool Truncate(GpUFilePos_t loc) override;
|
||||
GpUFilePos_t Size() const override;
|
||||
GpUFilePos_t Tell() const override;
|
||||
void Close() override;
|
||||
@@ -94,7 +94,6 @@ public:
|
||||
bool SeekStart(GpUFilePos_t loc) override;
|
||||
bool SeekCurrent(GpFilePos_t loc) override;
|
||||
bool SeekEnd(GpUFilePos_t loc) override;
|
||||
bool Truncate(GpUFilePos_t loc) override;
|
||||
GpUFilePos_t Size() const override;
|
||||
GpUFilePos_t Tell() const override;
|
||||
void Close() override;
|
||||
@@ -166,11 +165,6 @@ bool GpFileStream_PFD::SeekEnd(GpUFilePos_t loc)
|
||||
return lseek64(m_fd, loc, SEEK_END) >= 0;
|
||||
}
|
||||
|
||||
bool GpFileStream_PFD::Truncate(GpUFilePos_t loc)
|
||||
{
|
||||
return ftruncate64(m_fd, static_cast<off64_t>(loc)) >= 0;
|
||||
}
|
||||
|
||||
GpUFilePos_t GpFileStream_PFD::Size() const
|
||||
{
|
||||
struct stat64 s;
|
||||
@@ -249,11 +243,6 @@ bool GpFileStream_SDLRWops::SeekEnd(GpUFilePos_t loc)
|
||||
return m_rw->seek(m_rw, -static_cast<Sint64>(loc), RW_SEEK_END) >= 0;
|
||||
}
|
||||
|
||||
bool GpFileStream_SDLRWops::Truncate(GpUFilePos_t loc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
GpUFilePos_t GpFileStream_SDLRWops::Size() const
|
||||
{
|
||||
return m_rw->size(m_rw);
|
||||
@@ -344,12 +333,6 @@ bool GpFileStream_Android_File::SeekEnd(GpUFilePos_t loc)
|
||||
return lseek64(m_fd, -static_cast<off64_t>(loc), SEEK_END) >= 0;
|
||||
}
|
||||
|
||||
bool GpFileStream_Android_File::Truncate(GpUFilePos_t loc)
|
||||
{
|
||||
fflush(m_f);
|
||||
return ftruncate64(m_fd, static_cast<off64_t>(loc)) >= 0;
|
||||
}
|
||||
|
||||
GpUFilePos_t GpFileStream_Android_File::Size() const
|
||||
{
|
||||
fflush(m_f);
|
||||
@@ -380,7 +363,7 @@ void GpFileStream_Android_File::Flush()
|
||||
bool GpFileSystem_Android::OpenSourceExportFD(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *const *paths, size_t numPaths, int &fd, jobject &pfd)
|
||||
{
|
||||
if (!m_sourceExportMutex)
|
||||
m_sourceExportMutex = PortabilityLayer::HostSystemServices::GetInstance()->CreateMutex();
|
||||
m_sourceExportMutex = PLDrivers::GetSystemServices()->CreateMutex();
|
||||
|
||||
m_sourceExportWaiting = true;
|
||||
m_sourceExportCancelled = false;
|
||||
@@ -550,26 +533,26 @@ bool GpFileSystem_Android::FileExists(PortabilityLayer::VirtualDirectory_t virtu
|
||||
return stat(resolvedPath.c_str(), &s) == 0;
|
||||
}
|
||||
|
||||
bool GpFileSystem_Android::FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool *exists)
|
||||
bool GpFileSystem_Android::FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &exists)
|
||||
{
|
||||
std::string resolvedPath;
|
||||
bool isAsset;
|
||||
if (!ResolvePath(virtualDirectory, &path, 1, resolvedPath, isAsset))
|
||||
{
|
||||
if (exists)
|
||||
*exists = false;
|
||||
exists = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isAsset)
|
||||
{
|
||||
if (exists)
|
||||
*exists = this->FileExists(virtualDirectory, path);
|
||||
exists = this->FileExists(virtualDirectory, path);
|
||||
return true;
|
||||
}
|
||||
|
||||
int permissions = access(resolvedPath.c_str(), W_OK | F_OK);
|
||||
*exists = ((permissions & F_OK) != 0);
|
||||
exists = ((permissions & F_OK) != 0);
|
||||
return ((permissions & W_OK) != 0);
|
||||
}
|
||||
|
||||
@@ -696,7 +679,7 @@ bool GpFileSystem_Android::DeleteFile(PortabilityLayer::VirtualDirectory_t virtu
|
||||
return true;
|
||||
}
|
||||
|
||||
PortabilityLayer::HostDirectoryCursor *GpFileSystem_Android::ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *const *paths, size_t numPaths)
|
||||
IGpDirectoryCursor *GpFileSystem_Android::ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *const *paths, size_t numPaths)
|
||||
{
|
||||
ScanDirectoryNestedContext ctx;
|
||||
ctx.m_this = this;
|
||||
@@ -715,7 +698,7 @@ void GpFileSystem_Android::ScanDirectoryNestedThunk(void *context)
|
||||
ctx->m_returnValue = ctx->m_this->ScanDirectoryNestedInternal(ctx->m_virtualDirectory, ctx->m_paths, ctx->m_numPaths);
|
||||
}
|
||||
|
||||
PortabilityLayer::HostDirectoryCursor *GpFileSystem_Android::ScanDirectoryNestedInternal(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *const *paths, size_t numPaths)
|
||||
IGpDirectoryCursor *GpFileSystem_Android::ScanDirectoryNestedInternal(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *const *paths, size_t numPaths)
|
||||
{
|
||||
if (virtualDirectory == PortabilityLayer::VirtualDirectories::kGameData || virtualDirectory == PortabilityLayer::VirtualDirectories::kApplicationData)
|
||||
return ScanAssetDirectory(virtualDirectory, paths, numPaths);
|
||||
@@ -731,7 +714,7 @@ bool GpFileSystem_Android::ValidateFilePath(const char *path, size_t length) con
|
||||
if (c >= '0' && c <= '9')
|
||||
continue;
|
||||
|
||||
if (c == '_' || c == '.' || c == '\'')
|
||||
if (c == '_' || c == '.' || c == '\'' || c == '!')
|
||||
continue;
|
||||
|
||||
if (c == ' ' && i != 0 && i != length - 1)
|
||||
@@ -769,11 +752,6 @@ bool GpFileSystem_Android::ValidateFilePathUnicodeChar(uint32_t c) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GpFileSystem_Android::IsVirtualDirectoryLooseResources(PortabilityLayer::VirtualDirectory_t virtualDir) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void GpFileSystem_Android::SetMainThreadRelay(IGpThreadRelay *relay)
|
||||
{
|
||||
m_relay = relay;
|
||||
@@ -809,7 +787,7 @@ GpFileSystem_Android *GpFileSystem_Android::GetInstance()
|
||||
return &ms_instance;
|
||||
}
|
||||
|
||||
class GpDirectoryCursor_StringList final : public PortabilityLayer::HostDirectoryCursor
|
||||
class GpDirectoryCursor_StringList final : public IGpDirectoryCursor
|
||||
{
|
||||
public:
|
||||
explicit GpDirectoryCursor_StringList(std::vector<std::string> &paths);
|
||||
@@ -847,7 +825,7 @@ void GpDirectoryCursor_StringList::Destroy()
|
||||
delete this;
|
||||
}
|
||||
|
||||
class GpDirectoryCursor_POSIX final : public PortabilityLayer::HostDirectoryCursor
|
||||
class GpDirectoryCursor_POSIX final : public IGpDirectoryCursor
|
||||
{
|
||||
public:
|
||||
explicit GpDirectoryCursor_POSIX(DIR *dir);
|
||||
@@ -885,7 +863,7 @@ void GpDirectoryCursor_POSIX::Destroy()
|
||||
delete this;
|
||||
}
|
||||
|
||||
PortabilityLayer::HostDirectoryCursor *GpFileSystem_Android::ScanAssetDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths)
|
||||
IGpDirectoryCursor *GpFileSystem_Android::ScanAssetDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths)
|
||||
{
|
||||
|
||||
std::string resolvedPath;
|
||||
@@ -919,7 +897,7 @@ PortabilityLayer::HostDirectoryCursor *GpFileSystem_Android::ScanAssetDirectory(
|
||||
return new GpDirectoryCursor_StringList(subPaths);
|
||||
}
|
||||
|
||||
PortabilityLayer::HostDirectoryCursor *GpFileSystem_Android::ScanStorageDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths)
|
||||
IGpDirectoryCursor *GpFileSystem_Android::ScanStorageDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths)
|
||||
{
|
||||
std::string resolvedPath;
|
||||
std::vector<std::string> subPaths;
|
||||
|
@@ -1,18 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "HostFileSystem.h"
|
||||
#include "IGpFileSystem.h"
|
||||
|
||||
#include "GpCoreDefs.h"
|
||||
|
||||
#include <jni.h>
|
||||
#include <string>
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class HostMutex;
|
||||
}
|
||||
struct IGpMutex;
|
||||
|
||||
class GpFileSystem_Android final : public PortabilityLayer::HostFileSystem
|
||||
class GpFileSystem_Android final : public IGpFileSystem
|
||||
{
|
||||
public:
|
||||
GpFileSystem_Android();
|
||||
@@ -22,16 +19,14 @@ public:
|
||||
void ShutdownJNI();
|
||||
|
||||
bool FileExists(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path) override;
|
||||
bool FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool *exists) override;
|
||||
bool FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &exists) override;
|
||||
GpIOStream *OpenFileNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* subPaths, size_t numSubPaths, bool writeAccess, GpFileCreationDisposition_t createDisposition) override;
|
||||
bool DeleteFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &existed) override;
|
||||
PortabilityLayer::HostDirectoryCursor *ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths) override;
|
||||
IGpDirectoryCursor *ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths) override;
|
||||
|
||||
bool ValidateFilePath(const char *path, size_t pathLen) const override;
|
||||
bool ValidateFilePathUnicodeChar(uint32_t ch) const override;
|
||||
|
||||
bool IsVirtualDirectoryLooseResources(PortabilityLayer::VirtualDirectory_t virtualDir) const override;
|
||||
|
||||
void SetMainThreadRelay(IGpThreadRelay *relay) override;
|
||||
void SetDelayCallback(DelayCallback_t delayCallback) override;
|
||||
|
||||
@@ -45,17 +40,17 @@ private:
|
||||
{
|
||||
GpFileSystem_Android *m_this;
|
||||
|
||||
PortabilityLayer::HostDirectoryCursor *m_returnValue;
|
||||
IGpDirectoryCursor *m_returnValue;
|
||||
PortabilityLayer::VirtualDirectory_t m_virtualDirectory;
|
||||
char const *const *m_paths;
|
||||
size_t m_numPaths;
|
||||
};
|
||||
|
||||
static void ScanDirectoryNestedThunk(void *context);
|
||||
PortabilityLayer::HostDirectoryCursor *ScanDirectoryNestedInternal(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths);
|
||||
IGpDirectoryCursor *ScanDirectoryNestedInternal(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths);
|
||||
|
||||
PortabilityLayer::HostDirectoryCursor *ScanAssetDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths);
|
||||
PortabilityLayer::HostDirectoryCursor *ScanStorageDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths);
|
||||
IGpDirectoryCursor *ScanAssetDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths);
|
||||
IGpDirectoryCursor *ScanStorageDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths);
|
||||
|
||||
bool OpenSourceExportFD(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths, int &fd, jobject &pfd);
|
||||
bool ResolvePath(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths, std::string &resolution, bool &isAsset);
|
||||
@@ -68,7 +63,7 @@ private:
|
||||
jmethodID m_selectSourceExportPathMID;
|
||||
jmethodID m_closeSourceExportPFDMID;
|
||||
|
||||
PortabilityLayer::HostMutex *m_sourceExportMutex;
|
||||
IGpMutex *m_sourceExportMutex;
|
||||
int m_sourceExportFD;
|
||||
bool m_sourceExportWaiting;
|
||||
bool m_sourceExportCancelled;
|
||||
|
@@ -8,14 +8,15 @@
|
||||
#include "GpFileSystem_Android.h"
|
||||
#include "GpFontHandlerFactory.h"
|
||||
#include "GpInputDriverFactory.h"
|
||||
#include "GpInputDriver_SDL_Gamepad.h"
|
||||
#include "GpAppInterface.h"
|
||||
#include "GpSystemServices_Android.h"
|
||||
#include "GpVOSEvent.h"
|
||||
#include "IGpVOSEventQueue.h"
|
||||
#include "IGpLogDriver.h"
|
||||
|
||||
#include "HostFileSystem.h"
|
||||
#include "HostThreadEvent.h"
|
||||
#include "IGpFileSystem.h"
|
||||
#include "IGpThreadEvent.h"
|
||||
|
||||
#include "GpAndroid.h"
|
||||
|
||||
@@ -81,9 +82,10 @@ int main(int argc, char* argv[])
|
||||
|
||||
GpFileSystem_Android::GetInstance()->InitJNI();
|
||||
|
||||
GpAppInterface_Get()->PL_HostFileSystem_SetInstance(GpFileSystem_Android::GetInstance());
|
||||
GpAppInterface_Get()->PL_HostSystemServices_SetInstance(GpSystemServices_Android::GetInstance());
|
||||
GpAppInterface_Get()->PL_HostLogDriver_SetInstance(GpLogDriver_Android::GetInstance());
|
||||
GpDriverCollection *drivers = GpAppInterface_Get()->PL_GetDriverCollection();
|
||||
drivers->SetDriver<GpDriverIDs::kFileSystem>(GpFileSystem_Android::GetInstance());
|
||||
drivers->SetDriver<GpDriverIDs::kSystemServices>(GpSystemServices_Android::GetInstance());
|
||||
drivers->SetDriver<GpDriverIDs::kLog>(GpLogDriver_Android::GetInstance());
|
||||
|
||||
g_gpGlobalConfig.m_displayDriverType = EGpDisplayDriverType_SDL_GL2;
|
||||
|
||||
@@ -115,3 +117,8 @@ int main(int argc, char* argv[])
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
IGpInputDriverSDLGamepad *IGpInputDriverSDLGamepad::GetInstance()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
@@ -1,18 +1,16 @@
|
||||
#include "GpSystemServices_Android.h"
|
||||
#include "HostMutex.h"
|
||||
#include "HostThreadEvent.h"
|
||||
|
||||
#include "IGpThreadEvent.h"
|
||||
#include "SDL.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <unistd.h>
|
||||
|
||||
struct GpSystemServices_Android_ThreadStartParams
|
||||
{
|
||||
GpSystemServices_Android::ThreadFunc_t m_threadFunc;
|
||||
void *m_threadContext;
|
||||
PortabilityLayer::HostThreadEvent *m_threadStartEvent;
|
||||
IGpThreadEvent *m_threadStartEvent;
|
||||
};
|
||||
|
||||
static int SDLCALL StaticStartThread(void *lpThreadParameter)
|
||||
@@ -21,185 +19,21 @@ static int SDLCALL StaticStartThread(void *lpThreadParameter)
|
||||
|
||||
GpSystemServices_Android::ThreadFunc_t threadFunc = threadParams->m_threadFunc;
|
||||
void *threadContext = threadParams->m_threadContext;
|
||||
PortabilityLayer::HostThreadEvent *threadStartEvent = threadParams->m_threadStartEvent;
|
||||
IGpThreadEvent *threadStartEvent = threadParams->m_threadStartEvent;
|
||||
|
||||
threadStartEvent->Signal();
|
||||
|
||||
return threadFunc(threadContext);
|
||||
}
|
||||
|
||||
template<class TMutex>
|
||||
class GpMutex_Cpp11 final : public PortabilityLayer::HostMutex
|
||||
{
|
||||
public:
|
||||
GpMutex_Cpp11();
|
||||
~GpMutex_Cpp11();
|
||||
|
||||
void Destroy() override;
|
||||
|
||||
void Lock() override;
|
||||
void Unlock() override;
|
||||
|
||||
private:
|
||||
TMutex m_mutex;
|
||||
};
|
||||
|
||||
template<class TMutex>
|
||||
GpMutex_Cpp11<TMutex>::GpMutex_Cpp11()
|
||||
{
|
||||
}
|
||||
|
||||
template<class TMutex>
|
||||
GpMutex_Cpp11<TMutex>::~GpMutex_Cpp11()
|
||||
{
|
||||
}
|
||||
|
||||
template<class TMutex>
|
||||
void GpMutex_Cpp11<TMutex>::Destroy()
|
||||
{
|
||||
this->~GpMutex_Cpp11();
|
||||
free(this);
|
||||
}
|
||||
|
||||
template<class TMutex>
|
||||
void GpMutex_Cpp11<TMutex>::Lock()
|
||||
{
|
||||
m_mutex.lock();
|
||||
}
|
||||
|
||||
template<class TMutex>
|
||||
void GpMutex_Cpp11<TMutex>::Unlock()
|
||||
{
|
||||
m_mutex.unlock();
|
||||
}
|
||||
|
||||
typedef GpMutex_Cpp11<std::mutex> GpMutex_Cpp11_Vanilla;
|
||||
typedef GpMutex_Cpp11<std::recursive_mutex> GpMutex_Cpp11_Recursive;
|
||||
|
||||
|
||||
class GpThreadEvent_Cpp11 final : public PortabilityLayer::HostThreadEvent
|
||||
{
|
||||
public:
|
||||
GpThreadEvent_Cpp11(bool autoReset, bool startSignaled);
|
||||
~GpThreadEvent_Cpp11();
|
||||
|
||||
void Wait() override;
|
||||
bool WaitTimed(uint32_t msec) override;
|
||||
void Signal() override;
|
||||
void Destroy() override;
|
||||
|
||||
private:
|
||||
std::mutex m_mutex;
|
||||
std::condition_variable m_cvar;
|
||||
bool m_flag;
|
||||
bool m_autoReset;
|
||||
};
|
||||
|
||||
GpThreadEvent_Cpp11::GpThreadEvent_Cpp11(bool autoReset, bool startSignaled)
|
||||
: m_flag(startSignaled)
|
||||
, m_autoReset(autoReset)
|
||||
{
|
||||
}
|
||||
|
||||
GpThreadEvent_Cpp11::~GpThreadEvent_Cpp11()
|
||||
{
|
||||
}
|
||||
|
||||
void GpThreadEvent_Cpp11::Wait()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
if (m_autoReset)
|
||||
{
|
||||
m_cvar.wait(lock,[&]()->bool{
|
||||
if (m_flag)
|
||||
{
|
||||
m_flag = false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
});
|
||||
}
|
||||
else
|
||||
m_cvar.wait(lock,[&]()->bool{ return m_flag; });
|
||||
}
|
||||
|
||||
bool GpThreadEvent_Cpp11::WaitTimed(uint32_t msec)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
if (m_autoReset)
|
||||
{
|
||||
if (!m_cvar.wait_for(lock, std::chrono::milliseconds(msec), [&]()->bool{
|
||||
if (m_flag)
|
||||
{
|
||||
m_flag = false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_cvar.wait_for(lock, std::chrono::milliseconds(msec), [&]()->bool{ return m_flag; }))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void GpThreadEvent_Cpp11::Signal()
|
||||
{
|
||||
m_mutex.lock();
|
||||
m_flag = true;
|
||||
m_mutex.unlock();
|
||||
if (m_autoReset)
|
||||
m_cvar.notify_one();
|
||||
else
|
||||
m_cvar.notify_all();
|
||||
}
|
||||
|
||||
void GpThreadEvent_Cpp11::Destroy()
|
||||
{
|
||||
this->~GpThreadEvent_Cpp11();
|
||||
free(this);
|
||||
}
|
||||
|
||||
GpSystemServices_Android::GpSystemServices_Android()
|
||||
: m_textInputEnabled(false)
|
||||
{
|
||||
}
|
||||
|
||||
int64_t GpSystemServices_Android::GetTime() const
|
||||
{
|
||||
time_t t = time(nullptr);
|
||||
return static_cast<int64_t>(t) - 2082844800;
|
||||
}
|
||||
|
||||
void GpSystemServices_Android::GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const
|
||||
{
|
||||
time_t t = time(nullptr);
|
||||
tm *tmObject = localtime(&t);
|
||||
year = static_cast<unsigned int>(tmObject->tm_year);
|
||||
month = static_cast<unsigned int>(tmObject->tm_mon + 1);
|
||||
hour = static_cast<unsigned int>(tmObject->tm_hour);
|
||||
minute = static_cast<unsigned int>(tmObject->tm_min);
|
||||
second = static_cast<unsigned int>(tmObject->tm_sec);
|
||||
}
|
||||
|
||||
PortabilityLayer::HostMutex *GpSystemServices_Android::CreateMutex()
|
||||
{
|
||||
GpMutex_Cpp11_Vanilla *mutex = static_cast<GpMutex_Cpp11_Vanilla*>(malloc(sizeof(GpMutex_Cpp11_Vanilla)));
|
||||
if (!mutex)
|
||||
return nullptr;
|
||||
|
||||
return new (mutex) GpMutex_Cpp11_Vanilla();
|
||||
}
|
||||
|
||||
|
||||
void *GpSystemServices_Android::CreateThread(ThreadFunc_t threadFunc, void *context)
|
||||
{
|
||||
PortabilityLayer::HostThreadEvent *evt = CreateThreadEvent(true, false);
|
||||
IGpThreadEvent *evt = CreateThreadEvent(true, false);
|
||||
if (!evt)
|
||||
return nullptr;
|
||||
|
||||
@@ -221,31 +55,6 @@ void *GpSystemServices_Android::CreateThread(ThreadFunc_t threadFunc, void *cont
|
||||
return thread;
|
||||
}
|
||||
|
||||
PortabilityLayer::HostMutex *GpSystemServices_Android::CreateRecursiveMutex()
|
||||
{
|
||||
GpMutex_Cpp11_Recursive *mutex = static_cast<GpMutex_Cpp11_Recursive*>(malloc(sizeof(GpMutex_Cpp11_Recursive)));
|
||||
if (!mutex)
|
||||
return nullptr;
|
||||
|
||||
return new (mutex) GpMutex_Cpp11_Recursive();
|
||||
}
|
||||
|
||||
PortabilityLayer::HostThreadEvent *GpSystemServices_Android::CreateThreadEvent(bool autoReset, bool startSignaled)
|
||||
{
|
||||
GpThreadEvent_Cpp11 *evt = static_cast<GpThreadEvent_Cpp11*>(malloc(sizeof(GpThreadEvent_Cpp11)));
|
||||
if (!evt)
|
||||
return nullptr;
|
||||
|
||||
return new (evt) GpThreadEvent_Cpp11(autoReset, startSignaled);
|
||||
}
|
||||
|
||||
uint64_t GpSystemServices_Android::GetFreeMemoryCosmetic() const
|
||||
{
|
||||
long pages = sysconf(_SC_AVPHYS_PAGES);
|
||||
long pageSize = sysconf(_SC_PAGE_SIZE);
|
||||
return pages * pageSize;
|
||||
}
|
||||
|
||||
void GpSystemServices_Android::Beep() const
|
||||
{
|
||||
}
|
||||
@@ -265,6 +74,16 @@ bool GpSystemServices_Android::IsTextInputObstructive() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GpSystemServices_Android::IsFullscreenPreferred() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GpSystemServices_Android::IsFullscreenOnStartup() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int GpSystemServices_Android::GetCPUCount() const
|
||||
{
|
||||
return SDL_GetCPUCount();
|
||||
@@ -280,6 +99,20 @@ bool GpSystemServices_Android::IsTextInputEnabled() const
|
||||
return m_textInputEnabled;
|
||||
}
|
||||
|
||||
bool GpSystemServices_Android::AreFontResourcesSeekable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IGpClipboardContents *GpSystemServices_Android::GetClipboardContents() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GpSystemServices_Android::SetClipboardContents(IGpClipboardContents *contents)
|
||||
{
|
||||
}
|
||||
|
||||
GpSystemServices_Android *GpSystemServices_Android::GetInstance()
|
||||
{
|
||||
return &ms_instance;
|
||||
|
@@ -1,27 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "HostSystemServices.h"
|
||||
#include "GpSystemServices_POSIX.h"
|
||||
#include "GpCoreDefs.h"
|
||||
|
||||
class GpSystemServices_Android final : public PortabilityLayer::HostSystemServices
|
||||
class GpSystemServices_Android final : public GpSystemServices_POSIX
|
||||
{
|
||||
public:
|
||||
GpSystemServices_Android();
|
||||
|
||||
int64_t GetTime() const override;
|
||||
void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const override;
|
||||
PortabilityLayer::HostMutex *CreateMutex() override;
|
||||
PortabilityLayer::HostMutex *CreateRecursiveMutex() override;
|
||||
void *CreateThread(ThreadFunc_t threadFunc, void *context) override;
|
||||
PortabilityLayer::HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
|
||||
uint64_t GetFreeMemoryCosmetic() const override;
|
||||
void Beep() const override;
|
||||
bool IsTouchscreen() const override;
|
||||
bool IsUsingMouseAsTouch() const override;
|
||||
bool IsTextInputObstructive() const override;
|
||||
bool IsFullscreenPreferred() const override;
|
||||
bool IsFullscreenOnStartup() const override;
|
||||
unsigned int GetCPUCount() const override;
|
||||
void SetTextInputEnabled(bool isEnabled) override;
|
||||
bool IsTextInputEnabled() const override;
|
||||
bool AreFontResourcesSeekable() const override;
|
||||
IGpClipboardContents *GetClipboardContents() const override;
|
||||
void SetClipboardContents(IGpClipboardContents *contents) override;
|
||||
|
||||
void FlushTextInputEnabled();
|
||||
|
||||
|
@@ -41,9 +41,13 @@
|
||||
<!-- Allow writing to external storage -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<!-- Allow access to Bluetooth devices -->
|
||||
<!--
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
-->
|
||||
<!-- Allow access to the vibrator -->
|
||||
<!--
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
-->
|
||||
|
||||
<!-- if you want to capture audio, uncomment this. -->
|
||||
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
|
||||
|
@@ -6,7 +6,7 @@ buildscript {
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:4.1.1'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
@@ -7,6 +7,6 @@ mkdir Packaged
|
||||
cd Packaged
|
||||
rmdir /S /Q Houses
|
||||
mkdir Houses
|
||||
copy ..\..\..\..\..\..\Packaged\*.gpa .\
|
||||
copy ..\..\..\..\..\..\Packaged\*.gpf .\
|
||||
copy ..\..\..\..\..\..\Packaged\Houses\* Houses\
|
||||
cd ..
|
||||
|
@@ -6,3 +6,4 @@ git archive -0 --format zip -o AerofoilAndroid\app\src\main\assets\Packaged\Sour
|
||||
tools\7z.exe d AerofoilAndroid\app\src\main\assets\Packaged\SourceCode.zip GliderProData\
|
||||
cd AerofoilAndroid\app\src\main\assets\Packaged
|
||||
rename SourceCode.zip SourceCode.pkg
|
||||
pause
|
||||
|
@@ -5,6 +5,7 @@ call remove_symlinks.bat
|
||||
|
||||
|
||||
mklink /D app\jni\AerofoilSDL ..\..\..\AerofoilSDL
|
||||
mklink /D app\jni\AerofoilPortable ..\..\..\AerofoilPortable
|
||||
mklink /D app\jni\Common ..\..\..\Common
|
||||
mklink /D app\jni\SDL2 ..\..\..\SDL2-2.0.12
|
||||
mklink /D app\jni\GpApp ..\..\..\GpApp
|
||||
|
@@ -2,6 +2,7 @@
|
||||
@cd /d "%~dp0"
|
||||
|
||||
rmdir app\jni\AerofoilSDL
|
||||
rmdir app\jni\AerofoilPortable
|
||||
rmdir app\jni\Common
|
||||
rmdir app\jni\SDL2
|
||||
rmdir app\jni\GpShell
|
||||
|
20
AerofoilPortable/Android.mk
Normal file
20
AerofoilPortable/Android.mk
Normal file
@@ -0,0 +1,20 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := AerofoilPortable
|
||||
|
||||
LOCAL_C_INCLUDES := \
|
||||
$(LOCAL_PATH)/../GpCommon \
|
||||
$(LOCAL_PATH)/../GpShell \
|
||||
$(LOCAL_PATH)/../Common \
|
||||
$(LOCAL_PATH)/../PortabilityLayer
|
||||
|
||||
LOCAL_CFLAGS := -DGP_DEBUG_CONFIG=0
|
||||
|
||||
# Add your application source files here...
|
||||
LOCAL_SRC_FILES := \
|
||||
GpThreadEvent_Cpp11.cpp \
|
||||
GpSystemServices_POSIX.cpp
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
66
AerofoilPortable/GpMutex_Cpp11.h
Normal file
66
AerofoilPortable/GpMutex_Cpp11.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include "IGpMutex.h"
|
||||
#include <mutex>
|
||||
|
||||
template<class TMutex>
|
||||
class GpMutex_Cpp11 final : public IGpMutex
|
||||
{
|
||||
public:
|
||||
~GpMutex_Cpp11();
|
||||
|
||||
void Destroy() override;
|
||||
static GpMutex_Cpp11<TMutex> *Create();
|
||||
|
||||
void Lock() override;
|
||||
void Unlock() override;
|
||||
|
||||
private:
|
||||
GpMutex_Cpp11();
|
||||
|
||||
TMutex m_mutex;
|
||||
};
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
template<class TMutex>
|
||||
GpMutex_Cpp11<TMutex>::GpMutex_Cpp11()
|
||||
{
|
||||
}
|
||||
|
||||
template<class TMutex>
|
||||
GpMutex_Cpp11<TMutex>::~GpMutex_Cpp11()
|
||||
{
|
||||
}
|
||||
|
||||
template<class TMutex>
|
||||
void GpMutex_Cpp11<TMutex>::Destroy()
|
||||
{
|
||||
this->~GpMutex_Cpp11();
|
||||
free(this);
|
||||
}
|
||||
|
||||
template<class TMutex>
|
||||
GpMutex_Cpp11<TMutex> *GpMutex_Cpp11<TMutex>::Create()
|
||||
{
|
||||
GpMutex_Cpp11<TMutex> *mutex = static_cast<GpMutex_Cpp11<TMutex>*>(malloc(sizeof(GpMutex_Cpp11<TMutex>)));
|
||||
if (!mutex)
|
||||
return nullptr;
|
||||
|
||||
return new (mutex) GpMutex_Cpp11<TMutex>();
|
||||
}
|
||||
|
||||
template<class TMutex>
|
||||
void GpMutex_Cpp11<TMutex>::Lock()
|
||||
{
|
||||
m_mutex.lock();
|
||||
}
|
||||
|
||||
template<class TMutex>
|
||||
void GpMutex_Cpp11<TMutex>::Unlock()
|
||||
{
|
||||
m_mutex.unlock();
|
||||
}
|
||||
|
||||
typedef GpMutex_Cpp11<std::mutex> GpMutex_Cpp11_NonRecursive;
|
||||
typedef GpMutex_Cpp11<std::recursive_mutex> GpMutex_Cpp11_Recursive;
|
50
AerofoilPortable/GpSystemServices_POSIX.cpp
Normal file
50
AerofoilPortable/GpSystemServices_POSIX.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "GpSystemServices_POSIX.h"
|
||||
|
||||
#include "GpMutex_Cpp11.h"
|
||||
#include "GpThreadEvent_Cpp11.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
GpSystemServices_POSIX::GpSystemServices_POSIX()
|
||||
{
|
||||
}
|
||||
|
||||
int64_t GpSystemServices_POSIX::GetTime() const
|
||||
{
|
||||
time_t t = time(nullptr);
|
||||
return static_cast<int64_t>(t) - 2082844800;
|
||||
}
|
||||
|
||||
void GpSystemServices_POSIX::GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const
|
||||
{
|
||||
time_t t = time(nullptr);
|
||||
tm *tmObject = localtime(&t);
|
||||
year = static_cast<unsigned int>(tmObject->tm_year);
|
||||
month = static_cast<unsigned int>(tmObject->tm_mon + 1);
|
||||
hour = static_cast<unsigned int>(tmObject->tm_hour);
|
||||
minute = static_cast<unsigned int>(tmObject->tm_min);
|
||||
second = static_cast<unsigned int>(tmObject->tm_sec);
|
||||
}
|
||||
|
||||
IGpMutex *GpSystemServices_POSIX::CreateMutex()
|
||||
{
|
||||
return GpMutex_Cpp11_NonRecursive::Create();
|
||||
}
|
||||
|
||||
IGpMutex *GpSystemServices_POSIX::CreateRecursiveMutex()
|
||||
{
|
||||
return GpMutex_Cpp11_Recursive::Create();
|
||||
}
|
||||
|
||||
IGpThreadEvent *GpSystemServices_POSIX::CreateThreadEvent(bool autoReset, bool startSignaled)
|
||||
{
|
||||
return GpThreadEvent_Cpp11::Create(autoReset, startSignaled);
|
||||
}
|
||||
|
||||
uint64_t GpSystemServices_POSIX::GetFreeMemoryCosmetic() const
|
||||
{
|
||||
long pages = sysconf(_SC_AVPHYS_PAGES);
|
||||
long pageSize = sysconf(_SC_PAGE_SIZE);
|
||||
return pages * pageSize;
|
||||
}
|
17
AerofoilPortable/GpSystemServices_POSIX.h
Normal file
17
AerofoilPortable/GpSystemServices_POSIX.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "IGpSystemServices.h"
|
||||
#include "GpCoreDefs.h"
|
||||
|
||||
class GpSystemServices_POSIX : public IGpSystemServices
|
||||
{
|
||||
public:
|
||||
GpSystemServices_POSIX();
|
||||
|
||||
int64_t GetTime() const override;
|
||||
void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const override;
|
||||
IGpMutex *CreateMutex() override;
|
||||
IGpMutex *CreateRecursiveMutex() override;
|
||||
IGpThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
|
||||
uint64_t GetFreeMemoryCosmetic() const override;
|
||||
};
|
82
AerofoilPortable/GpThreadEvent_Cpp11.cpp
Normal file
82
AerofoilPortable/GpThreadEvent_Cpp11.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
#include "GpThreadEvent_Cpp11.h"
|
||||
|
||||
GpThreadEvent_Cpp11::GpThreadEvent_Cpp11(bool autoReset, bool startSignaled)
|
||||
: m_flag(startSignaled)
|
||||
, m_autoReset(autoReset)
|
||||
{
|
||||
}
|
||||
|
||||
GpThreadEvent_Cpp11::~GpThreadEvent_Cpp11()
|
||||
{
|
||||
}
|
||||
|
||||
void GpThreadEvent_Cpp11::Wait()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
if (m_autoReset)
|
||||
{
|
||||
m_cvar.wait(lock,[&]()->bool{
|
||||
if (m_flag)
|
||||
{
|
||||
m_flag = false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
});
|
||||
}
|
||||
else
|
||||
m_cvar.wait(lock,[&]()->bool{ return m_flag; });
|
||||
}
|
||||
|
||||
bool GpThreadEvent_Cpp11::WaitTimed(uint32_t msec)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
if (m_autoReset)
|
||||
{
|
||||
if (!m_cvar.wait_for(lock, std::chrono::milliseconds(msec), [&]()->bool{
|
||||
if (m_flag)
|
||||
{
|
||||
m_flag = false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_cvar.wait_for(lock, std::chrono::milliseconds(msec), [&]()->bool{ return m_flag; }))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void GpThreadEvent_Cpp11::Signal()
|
||||
{
|
||||
m_mutex.lock();
|
||||
m_flag = true;
|
||||
m_mutex.unlock();
|
||||
if (m_autoReset)
|
||||
m_cvar.notify_one();
|
||||
else
|
||||
m_cvar.notify_all();
|
||||
}
|
||||
|
||||
void GpThreadEvent_Cpp11::Destroy()
|
||||
{
|
||||
this->~GpThreadEvent_Cpp11();
|
||||
free(this);
|
||||
}
|
||||
|
||||
|
||||
GpThreadEvent_Cpp11 *GpThreadEvent_Cpp11::Create(bool autoReset, bool startSignaled)
|
||||
{
|
||||
GpThreadEvent_Cpp11 *evt = static_cast<GpThreadEvent_Cpp11*>(malloc(sizeof(GpThreadEvent_Cpp11)));
|
||||
if (!evt)
|
||||
return nullptr;
|
||||
|
||||
return new (evt) GpThreadEvent_Cpp11(autoReset, startSignaled);
|
||||
}
|
||||
|
28
AerofoilPortable/GpThreadEvent_Cpp11.h
Normal file
28
AerofoilPortable/GpThreadEvent_Cpp11.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "IGpThreadEvent.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
class GpThreadEvent_Cpp11 final : public IGpThreadEvent
|
||||
{
|
||||
public:
|
||||
~GpThreadEvent_Cpp11();
|
||||
|
||||
void Wait() override;
|
||||
bool WaitTimed(uint32_t msec) override;
|
||||
void Signal() override;
|
||||
void Destroy() override;
|
||||
|
||||
static GpThreadEvent_Cpp11 *Create(bool autoReset, bool startSignaled);
|
||||
|
||||
private:
|
||||
GpThreadEvent_Cpp11(bool autoReset, bool startSignaled);
|
||||
GpThreadEvent_Cpp11() = delete;
|
||||
|
||||
std::mutex m_mutex;
|
||||
std::condition_variable m_cvar;
|
||||
bool m_flag;
|
||||
bool m_autoReset;
|
||||
};
|
@@ -95,8 +95,10 @@
|
||||
<ClCompile Include="GpDisplayDriver_SDL_GL2.cpp" />
|
||||
<ClCompile Include="GpFiberStarter_SDL.cpp" />
|
||||
<ClCompile Include="GpFiber_SDL.cpp" />
|
||||
<ClCompile Include="GpInputDriver_SDL_Gamepad.cpp" />
|
||||
<ClCompile Include="GpMain_SDL_Win32.cpp" />
|
||||
<ClCompile Include="ShaderCode\CopyQuadP.cpp" />
|
||||
<ClCompile Include="ShaderCode\DrawQuad32P.cpp" />
|
||||
<ClCompile Include="ShaderCode\DrawQuadPaletteP.cpp" />
|
||||
<ClCompile Include="ShaderCode\DrawQuadV.cpp" />
|
||||
<ClCompile Include="ShaderCode\ScaleQuadP.cpp" />
|
||||
@@ -111,15 +113,13 @@
|
||||
<ProjectReference Include="..\GpFontHandler_FreeType2\GpFontHandler_FreeType2.vcxproj">
|
||||
<Project>{4b564030-8985-4975-91e1-e1b2c16ae2a1}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\GpInputDriver_XInput\GpInputDriver_XInput.vcxproj">
|
||||
<Project>{17b96f07-ef92-47cd-95a5-8e6ee38ab564}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\GpShell\GpShell.vcxproj">
|
||||
<Project>{10cf9b5f-61d0-4b5b-89f4-810b58fc053d}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="GpFiber_SDL.h" />
|
||||
<ClInclude Include="GpInputDriver_SDL_Gamepad.h" />
|
||||
<ClInclude Include="ShaderCode\DrawQuadPixelConstants.h" />
|
||||
<ClInclude Include="ShaderCode\Functions.h" />
|
||||
</ItemGroup>
|
||||
|
@@ -66,6 +66,12 @@
|
||||
<ClCompile Include="ShaderCode\CopyQuadP.cpp">
|
||||
<Filter>Source Files\ShaderCode</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ShaderCode\DrawQuad32P.cpp">
|
||||
<Filter>Source Files\ShaderCode</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GpInputDriver_SDL_Gamepad.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ShaderCode\Functions.h">
|
||||
@@ -77,5 +83,8 @@
|
||||
<ClInclude Include="GpFiber_SDL.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GpInputDriver_SDL_Gamepad.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -23,6 +23,7 @@ LOCAL_SRC_FILES := \
|
||||
GpFiberStarter_SDL.cpp \
|
||||
ShaderCode/CopyQuadP.cpp \
|
||||
ShaderCode/DrawQuadPaletteP.cpp \
|
||||
ShaderCode/DrawQuad32P.cpp \
|
||||
ShaderCode/DrawQuadV.cpp \
|
||||
ShaderCode/ScaleQuadP.cpp
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
#include "IGpAudioDriver.h"
|
||||
#include "IGpAudioChannel.h"
|
||||
#include "IGpAudioChannelCallbacks.h"
|
||||
#include "IGpMutex.h"
|
||||
#include "IGpPrefsHandler.h"
|
||||
#include "IGpSystemServices.h"
|
||||
#include "GpAudioDriverProperties.h"
|
||||
#include "CoreDefs.h"
|
||||
|
||||
#include "HostMutex.h"
|
||||
#include "HostSystemServices.h"
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "GpRingBuffer.h"
|
||||
@@ -93,7 +93,7 @@ private:
|
||||
bool Init(GpAudioDriver_SDL2 *driver);
|
||||
|
||||
IGpAudioChannelCallbacks *m_callbacks;
|
||||
PortabilityLayer::HostMutex *m_mutex;
|
||||
IGpMutex *m_mutex;
|
||||
GpAudioDriver_SDL2 *m_owner;
|
||||
|
||||
SDL_atomic_t m_refCount;
|
||||
@@ -131,11 +131,12 @@ private:
|
||||
void RefillMixChunk(GpAudioChannel_SDL2 *const*channels, size_t numChannels);
|
||||
|
||||
GpAudioDriverProperties m_properties;
|
||||
PortabilityLayer::HostMutex *m_mutex;
|
||||
PortabilityLayer::HostMutex *m_mixState;
|
||||
IGpMutex *m_mutex;
|
||||
IGpMutex *m_mixState;
|
||||
|
||||
static const size_t kMaxChannels = 16;
|
||||
static const size_t kMixChunkSize = 256;
|
||||
static const int16_t kMaxAudioVolumeScale = 25;
|
||||
|
||||
GpAudioChannel_SDL2 *m_channels[kMaxChannels];
|
||||
size_t m_numChannels;
|
||||
@@ -144,6 +145,8 @@ private:
|
||||
|
||||
GP_ALIGNED(GP_SYSTEM_MEMORY_ALIGNMENT) int16_t m_mixChunk[kMixChunkSize];
|
||||
size_t m_mixChunkReadOffset;
|
||||
|
||||
int16_t m_audioVolumeScale;
|
||||
};
|
||||
|
||||
GpAudioChannelBufferChain_SDL2::GpAudioChannelBufferChain_SDL2()
|
||||
@@ -353,6 +356,7 @@ GpAudioDriver_SDL2::GpAudioDriver_SDL2(const GpAudioDriverProperties &properties
|
||||
, m_numChannels(0)
|
||||
, m_sdlAudioRunning(false)
|
||||
, m_mixChunkReadOffset(kMixChunkSize)
|
||||
, m_audioVolumeScale(kMaxAudioVolumeScale)
|
||||
|
||||
{
|
||||
for (size_t i = 0; i < kMaxChannels; i++)
|
||||
@@ -395,6 +399,9 @@ IGpAudioChannel *GpAudioDriver_SDL2::CreateChannel()
|
||||
|
||||
void GpAudioDriver_SDL2::SetMasterVolume(uint32_t vol, uint32_t maxVolume)
|
||||
{
|
||||
double scale = vol * static_cast<uint64_t>(kMaxAudioVolumeScale) / maxVolume;
|
||||
|
||||
m_audioVolumeScale = static_cast<int16_t>(scale);
|
||||
}
|
||||
|
||||
void GpAudioDriver_SDL2::Shutdown()
|
||||
@@ -527,6 +534,8 @@ void GpAudioDriver_SDL2::RefillMixChunk(GpAudioChannel_SDL2 *const*channels, siz
|
||||
|
||||
bool noAudio = true;
|
||||
|
||||
const int16_t audioVolumeScale = m_audioVolumeScale;
|
||||
|
||||
for (size_t i = 0; i < numChannels; i++)
|
||||
{
|
||||
channels[i]->Consume(audioMixBuffer, kMixChunkSize);
|
||||
@@ -535,12 +544,12 @@ void GpAudioDriver_SDL2::RefillMixChunk(GpAudioChannel_SDL2 *const*channels, siz
|
||||
{
|
||||
noAudio = false;
|
||||
for (size_t j = 0; j < kMixChunkSize; j++)
|
||||
m_mixChunk[j] = (audioMixBuffer[j] - 0x80) * 25;
|
||||
m_mixChunk[j] = (static_cast<int16_t>(audioMixBuffer[j]) - 0x80) * audioVolumeScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t j = 0; j < kMixChunkSize; j++)
|
||||
m_mixChunk[j] += (audioMixBuffer[j] - 0x80) * 25;
|
||||
m_mixChunk[j] += (static_cast<int16_t>(audioMixBuffer[j]) - 0x80) * audioVolumeScale;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -6,11 +6,12 @@
|
||||
#include "GpDisplayDriverProperties.h"
|
||||
#include "GpVOSEvent.h"
|
||||
#include "GpRingBuffer.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "GpInputDriver_SDL_Gamepad.h"
|
||||
#include "IGpCursor.h"
|
||||
#include "IGpDisplayDriverSurface.h"
|
||||
#include "IGpLogDriver.h"
|
||||
#include "IGpPrefsHandler.h"
|
||||
#include "IGpSystemServices.h"
|
||||
#include "IGpVOSEventQueue.h"
|
||||
|
||||
#include "SDL_events.h"
|
||||
@@ -39,6 +40,13 @@ class GpDisplayDriver_SDL_GL2;
|
||||
|
||||
static GpDisplayDriverSurfaceEffects gs_defaultEffects;
|
||||
|
||||
static const char *kPrefsIdentifier = "GpDisplayDriverSDL_GL2";
|
||||
static uint32_t kPrefsVersion = 1;
|
||||
|
||||
struct GpDisplayDriver_SDL_GL2_Prefs
|
||||
{
|
||||
bool m_isFullScreen;
|
||||
};
|
||||
|
||||
namespace DeleteMe
|
||||
{
|
||||
@@ -108,17 +116,13 @@ namespace GpBinarizedShaders
|
||||
|
||||
extern const char *g_drawQuadPalettePF_GL2;
|
||||
extern const char *g_drawQuadPalettePNF_GL2;
|
||||
extern const char *g_drawQuadRGBPF_GL2;
|
||||
extern const char *g_drawQuadRGBPNF_GL2;
|
||||
extern const char *g_drawQuad15BitPF_GL2;
|
||||
extern const char *g_drawQuad15BitPNF_GL2;
|
||||
extern const char *g_drawQuad32PF_GL2;
|
||||
extern const char *g_drawQuad32PNF_GL2;
|
||||
|
||||
extern const char *g_drawQuadPaletteICCPF_GL2;
|
||||
extern const char *g_drawQuadPaletteICCPNF_GL2;
|
||||
extern const char *g_drawQuadRGBICCPF_GL2;
|
||||
extern const char *g_drawQuadRGBICCPNF_GL2;
|
||||
extern const char *g_drawQuad15BitICCPF_GL2;
|
||||
extern const char *g_drawQuad15BitICCPNF_GL2;
|
||||
extern const char *g_drawQuad32ICCPF_GL2;
|
||||
extern const char *g_drawQuad32ICCPNF_GL2;
|
||||
|
||||
extern const char *g_copyQuadP_GL2;
|
||||
extern const char *g_scaleQuadP_GL2;
|
||||
@@ -731,7 +735,7 @@ public:
|
||||
|
||||
void Run() override;
|
||||
void Shutdown() override;
|
||||
void GetDisplayResolution(unsigned int *width, unsigned int *height) override;
|
||||
void GetInitialDisplayResolution(unsigned int *width, unsigned int *height) override;
|
||||
IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, size_t pitch, GpPixelFormat_t pixelFormat, SurfaceInvalidateCallback_t invalidateCallback, void *invalidateContext) override;
|
||||
void DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height, const GpDisplayDriverSurfaceEffects *effects) override;
|
||||
IGpCursor *CreateBWCursor(size_t width, size_t height, const void *pixelData, const void *maskData, size_t hotSpotX, size_t hotSpotY) override;
|
||||
@@ -849,12 +853,16 @@ private:
|
||||
|
||||
DrawQuadProgram m_drawQuadPaletteNoFlickerProgram;
|
||||
DrawQuadProgram m_drawQuadPaletteFlickerProgram;
|
||||
DrawQuadProgram m_drawQuadRGBProgram;
|
||||
DrawQuadProgram m_drawQuad15BitProgram;
|
||||
DrawQuadProgram m_drawQuad15NoFlickerProgram;
|
||||
DrawQuadProgram m_drawQuad15FlickerProgram;
|
||||
DrawQuadProgram m_drawQuad32NoFlickerProgram;
|
||||
DrawQuadProgram m_drawQuad32FlickerProgram;
|
||||
DrawQuadProgram m_drawQuadPaletteICCNoFlickerProgram;
|
||||
DrawQuadProgram m_drawQuadPaletteICCFlickerProgram;
|
||||
DrawQuadProgram m_drawQuadRGBICCProgram;
|
||||
DrawQuadProgram m_drawQuad15BitICCProgram;
|
||||
DrawQuadProgram m_drawQuad15ICCNoFlickerProgram;
|
||||
DrawQuadProgram m_drawQuad15ICCFlickerProgram;
|
||||
DrawQuadProgram m_drawQuad32ICCNoFlickerProgram;
|
||||
DrawQuadProgram m_drawQuad32ICCFlickerProgram;
|
||||
};
|
||||
|
||||
InstancedResources m_res;
|
||||
@@ -886,6 +894,8 @@ private:
|
||||
uint32_t m_windowHeightPhysical;
|
||||
uint32_t m_windowWidthVirtual; // Virtual resolution is the resolution reported to the game
|
||||
uint32_t m_windowHeightVirtual;
|
||||
uint32_t m_initialWidthVirtual; // Virtual resolution is the resolution reported to the game
|
||||
uint32_t m_initialHeightVirtual;
|
||||
float m_pixelScaleX;
|
||||
float m_pixelScaleY;
|
||||
bool m_useUpscaleFilter;
|
||||
@@ -897,7 +907,7 @@ private:
|
||||
bool m_mouseIsInClientArea;
|
||||
|
||||
IGpFiber *m_vosFiber;
|
||||
PortabilityLayer::HostThreadEvent *m_vosEvent;
|
||||
IGpThreadEvent *m_vosEvent;
|
||||
|
||||
float m_bgColor[4];
|
||||
bool m_bgIsDark;
|
||||
@@ -1178,6 +1188,8 @@ GpDisplayDriver_SDL_GL2::GpDisplayDriver_SDL_GL2(const GpDisplayDriverProperties
|
||||
, m_windowHeightPhysical(480)
|
||||
, m_windowWidthVirtual(640)
|
||||
, m_windowHeightVirtual(480)
|
||||
, m_initialWidthVirtual(640)
|
||||
, m_initialHeightVirtual(480)
|
||||
, m_pixelScaleX(1.0f)
|
||||
, m_pixelScaleY(1.0f)
|
||||
, m_useUpscaleFilter(false)
|
||||
@@ -1215,7 +1227,7 @@ GpDisplayDriver_SDL_GL2::GpDisplayDriver_SDL_GL2(const GpDisplayDriverProperties
|
||||
m_bgColor[3] = 1.f;
|
||||
|
||||
// Stupid hack to detect mobile...
|
||||
m_isFullScreenDesired = m_properties.m_systemServices->IsTouchscreen() && !m_properties.m_systemServices->IsUsingMouseAsTouch();
|
||||
m_isFullScreenDesired = m_properties.m_systemServices->IsFullscreenOnStartup();
|
||||
|
||||
const intmax_t periodNum = std::chrono::high_resolution_clock::period::num;
|
||||
const intmax_t periodDen = std::chrono::high_resolution_clock::period::den;
|
||||
@@ -1838,7 +1850,7 @@ void GpDisplayDriver_SDL_GL2::Run()
|
||||
m_vosFiber = new GpFiber_SDL(nullptr, m_vosEvent);
|
||||
|
||||
uint32_t windowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
|
||||
if (m_isFullScreenDesired)
|
||||
if (m_properties.m_systemServices->IsFullscreenOnStartup())
|
||||
{
|
||||
windowFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
m_isFullScreen = true;
|
||||
@@ -1897,24 +1909,43 @@ void GpDisplayDriver_SDL_GL2::Run()
|
||||
if (!m_gl.LookUpFunctions())
|
||||
return;
|
||||
|
||||
m_initialWidthVirtual = m_windowWidthVirtual;
|
||||
m_initialHeightVirtual = m_windowHeightVirtual;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
SDL_Event msg;
|
||||
if (SDL_PollEvent(&msg) != 0)
|
||||
{
|
||||
if (msg.type == SDL_MOUSEMOTION)
|
||||
switch (msg.type)
|
||||
{
|
||||
if (!m_mouseIsInClientArea)
|
||||
m_mouseIsInClientArea = true;
|
||||
}
|
||||
//else if (msg.type == SDL_MOUSELEAVE) // Does SDL support this??
|
||||
case SDL_MOUSEMOTION:
|
||||
{
|
||||
if (!m_mouseIsInClientArea)
|
||||
m_mouseIsInClientArea = true;
|
||||
}
|
||||
break;
|
||||
//case SDL_MOUSELEAVE: // Does SDL support this??
|
||||
// m_mouseIsInClientArea = false;
|
||||
else if (msg.type == SDL_RENDER_DEVICE_RESET || msg.type == SDL_RENDER_TARGETS_RESET)
|
||||
{
|
||||
if (logger)
|
||||
logger->Printf(IGpLogDriver::Category_Information, "Triggering GL context reset due to device loss (Type: %i)", static_cast<int>(msg.type));
|
||||
// break;
|
||||
case SDL_RENDER_DEVICE_RESET:
|
||||
case SDL_RENDER_TARGETS_RESET:
|
||||
{
|
||||
if (logger)
|
||||
logger->Printf(IGpLogDriver::Category_Information, "Triggering GL context reset due to device loss (Type: %i)", static_cast<int>(msg.type));
|
||||
|
||||
m_contextLost = true;
|
||||
m_contextLost = true;
|
||||
}
|
||||
break;
|
||||
case SDL_CONTROLLERAXISMOTION:
|
||||
case SDL_CONTROLLERBUTTONDOWN:
|
||||
case SDL_CONTROLLERBUTTONUP:
|
||||
case SDL_CONTROLLERDEVICEADDED:
|
||||
case SDL_CONTROLLERDEVICEREMOVED:
|
||||
case SDL_CONTROLLERDEVICEREMAPPED:
|
||||
if (IGpInputDriverSDLGamepad *gamepadDriver = IGpInputDriverSDLGamepad::GetInstance())
|
||||
gamepadDriver->ProcessSDLEvent(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
TranslateSDLMessage(&msg, m_properties.m_eventQueue, m_pixelScaleX, m_pixelScaleY, obstructiveTextInput);
|
||||
@@ -2052,13 +2083,13 @@ void GpDisplayDriver_SDL_GL2::Shutdown()
|
||||
free(this);
|
||||
}
|
||||
|
||||
void GpDisplayDriver_SDL_GL2::GetDisplayResolution(unsigned int *width, unsigned int *height)
|
||||
void GpDisplayDriver_SDL_GL2::GetInitialDisplayResolution(unsigned int *width, unsigned int *height)
|
||||
{
|
||||
if (width)
|
||||
*width = m_windowWidthVirtual;
|
||||
*width = m_initialWidthVirtual;
|
||||
|
||||
if (height)
|
||||
*height = m_windowHeightVirtual;
|
||||
*height = m_initialHeightVirtual;
|
||||
}
|
||||
|
||||
IGpDisplayDriverSurface *GpDisplayDriver_SDL_GL2::CreateSurface(size_t width, size_t height, size_t pitch, GpPixelFormat_t pixelFormat, SurfaceInvalidateCallback_t invalidateCallback, void *invalidateContext)
|
||||
@@ -2110,7 +2141,20 @@ void GpDisplayDriver_SDL_GL2::DrawSurface(IGpDisplayDriverSurface *surface, int3
|
||||
}
|
||||
else if (pixelFormat == GpPixelFormats::kRGB32)
|
||||
{
|
||||
return;
|
||||
if (m_useICCProfile)
|
||||
{
|
||||
if (effects->m_flicker)
|
||||
program = &m_res.m_drawQuad32ICCFlickerProgram;
|
||||
else
|
||||
program = &m_res.m_drawQuad32ICCNoFlickerProgram;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (effects->m_flicker)
|
||||
program = &m_res.m_drawQuad32FlickerProgram;
|
||||
else
|
||||
program = &m_res.m_drawQuad32NoFlickerProgram;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2338,11 +2382,19 @@ bool GpDisplayDriver_SDL_GL2::SupportsSizedFormats() const
|
||||
|
||||
void GpDisplayDriver_SDL_GL2::ApplyPrefs(const void *identifier, size_t identifierSize, const void *contents, size_t contentsSize, uint32_t version)
|
||||
{
|
||||
if (version == kPrefsVersion && identifierSize == strlen(kPrefsIdentifier) && !memcmp(identifier, kPrefsIdentifier, identifierSize))
|
||||
{
|
||||
const GpDisplayDriver_SDL_GL2_Prefs *prefs = static_cast<const GpDisplayDriver_SDL_GL2_Prefs *>(contents);
|
||||
m_isFullScreenDesired = prefs->m_isFullScreen;
|
||||
}
|
||||
}
|
||||
|
||||
bool GpDisplayDriver_SDL_GL2::SavePrefs(void *context, WritePrefsFunc_t writeFunc)
|
||||
bool GpDisplayDriver_SDL_GL2::SavePrefs(void *context, IGpPrefsHandler::WritePrefsFunc_t writeFunc)
|
||||
{
|
||||
return true;
|
||||
GpDisplayDriver_SDL_GL2_Prefs prefs;
|
||||
prefs.m_isFullScreen = m_isFullScreenDesired;
|
||||
|
||||
return writeFunc(context, kPrefsIdentifier, strlen(kPrefsIdentifier), &prefs, sizeof(prefs), kPrefsVersion);
|
||||
}
|
||||
|
||||
void GpDisplayDriver_SDL_GL2::UnlinkSurface(GpDisplayDriverSurface_GL2 *surface, GpDisplayDriverSurface_GL2 *prev, GpDisplayDriverSurface_GL2 *next)
|
||||
@@ -2410,6 +2462,8 @@ bool GpDisplayDriver_SDL_GL2::InitResources(uint32_t physicalWidth, uint32_t phy
|
||||
|
||||
if ((m_pixelScaleX < 2.0f && m_pixelScaleX > 1.0f) || (m_pixelScaleY < 2.0f && m_pixelScaleY > 1.0f))
|
||||
m_useUpscaleFilter = true;
|
||||
else
|
||||
m_useUpscaleFilter = false;
|
||||
|
||||
CheckGLError(m_gl, logger);
|
||||
|
||||
@@ -2487,23 +2541,29 @@ bool GpDisplayDriver_SDL_GL2::InitResources(uint32_t physicalWidth, uint32_t phy
|
||||
}
|
||||
|
||||
GpComPtr<GpGLShader<GL_VERTEX_SHADER>> drawQuadVertexShader = CreateShader<GL_VERTEX_SHADER>(GpBinarizedShaders::g_drawQuadV_GL2);
|
||||
|
||||
GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> drawQuadPaletteFlickerPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuadPalettePF_GL2);
|
||||
GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> drawQuadPaletteNoFlickerPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuadPalettePNF_GL2);
|
||||
//m_drawQuadRGBPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuadRGBP_GL2);
|
||||
//m_drawQuad15BitPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuad15BitP_GL2);
|
||||
GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> drawQuad32FlickerPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuad32PF_GL2);
|
||||
GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> drawQuad32NoFlickerPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuad32PNF_GL2);
|
||||
|
||||
GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> drawQuadPaletteICCFPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuadPaletteICCPF_GL2);
|
||||
GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> drawQuadPaletteICCNFPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuadPaletteICCPNF_GL2);
|
||||
//m_drawQuadRGBICCPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuadRGBICCP_GL2);
|
||||
//m_drawQuad15BitICCPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuad15BitICCP_GL2);
|
||||
GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> drawQuad32ICCFPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuad32ICCPF_GL2);
|
||||
GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> drawQuad32ICCNFPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuad32ICCPNF_GL2);
|
||||
|
||||
GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> scaleQuadPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_scaleQuadP_GL2);
|
||||
GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> copyQuadPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_copyQuadP_GL2);
|
||||
|
||||
if (!m_res.m_drawQuadPaletteFlickerProgram.Link(this, drawQuadVertexShader, drawQuadPaletteFlickerPixelShader)
|
||||
|| !m_res.m_drawQuadPaletteNoFlickerProgram.Link(this, drawQuadVertexShader, drawQuadPaletteFlickerPixelShader)
|
||||
//|| !m_drawQuadRGBProgram.Link(this, drawQuadVertexShader, drawQuadRGBPixelShader)
|
||||
//|| !m_drawQuad15BitProgram.Link(this, drawQuadVertexShader, drawQuad15BitPixelShader)
|
||||
|| !m_res.m_drawQuadPaletteNoFlickerProgram.Link(this, drawQuadVertexShader, drawQuadPaletteNoFlickerPixelShader)
|
||||
|| !m_res.m_drawQuad32FlickerProgram.Link(this, drawQuadVertexShader, drawQuad32FlickerPixelShader)
|
||||
|| !m_res.m_drawQuad32NoFlickerProgram.Link(this, drawQuadVertexShader, drawQuad32NoFlickerPixelShader)
|
||||
|| !m_res.m_drawQuadPaletteICCFlickerProgram.Link(this, drawQuadVertexShader, drawQuadPaletteICCFPixelShader)
|
||||
|| !m_res.m_drawQuadPaletteICCNoFlickerProgram.Link(this, drawQuadVertexShader, drawQuadPaletteICCNFPixelShader)
|
||||
|| !m_res.m_drawQuad32ICCFlickerProgram.Link(this, drawQuadVertexShader, drawQuad32ICCFPixelShader)
|
||||
|| !m_res.m_drawQuad32ICCNoFlickerProgram.Link(this, drawQuadVertexShader, drawQuad32ICCNFPixelShader)
|
||||
|
||||
//|| !m_drawQuadRGBICCProgram.Link(this, drawQuadVertexShader, drawQuadRGBICCPixelShader)
|
||||
//|| !m_drawQuad15BitICCProgram.Link(this, drawQuadVertexShader, drawQuad15BitICCPixelShader)
|
||||
|| !m_res.m_scaleQuadProgram.Link(this, drawQuadVertexShader, scaleQuadPixelShader)
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#include "GpFiberStarter.h"
|
||||
#include "GpFiber_SDL.h"
|
||||
|
||||
#include "HostSystemServices.h"
|
||||
#include "HostThreadEvent.h"
|
||||
#include "IGpSystemServices.h"
|
||||
#include "IGpThreadEvent.h"
|
||||
|
||||
#include "SDL_thread.h"
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace GpFiberStarter_SDL
|
||||
struct FiberStartState
|
||||
{
|
||||
GpFiberStarter::ThreadFunc_t m_threadFunc;
|
||||
PortabilityLayer::HostThreadEvent *m_creatingReturnEvent;
|
||||
PortabilityLayer::HostThreadEvent *m_creatingWakeEvent;
|
||||
IGpThreadEvent *m_creatingReturnEvent;
|
||||
IGpThreadEvent *m_creatingWakeEvent;
|
||||
void *m_context;
|
||||
};
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace GpFiberStarter_SDL
|
||||
const FiberStartState *tss = static_cast<const FiberStartState*>(lpThreadParameter);
|
||||
|
||||
GpFiberStarter::ThreadFunc_t threadFunc = tss->m_threadFunc;
|
||||
PortabilityLayer::HostThreadEvent *creatingReturnEvent = tss->m_creatingReturnEvent;
|
||||
PortabilityLayer::HostThreadEvent *wakeEvent = tss->m_creatingWakeEvent;
|
||||
IGpThreadEvent *creatingReturnEvent = tss->m_creatingReturnEvent;
|
||||
IGpThreadEvent *wakeEvent = tss->m_creatingWakeEvent;
|
||||
void *context = tss->m_context;
|
||||
creatingReturnEvent->Signal();
|
||||
|
||||
@@ -36,13 +36,13 @@ namespace GpFiberStarter_SDL
|
||||
}
|
||||
}
|
||||
|
||||
IGpFiber *GpFiberStarter::StartFiber(PortabilityLayer::HostSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
|
||||
IGpFiber *GpFiberStarter::StartFiber(IGpSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
|
||||
{
|
||||
PortabilityLayer::HostThreadEvent *returnEvent = systemServices->CreateThreadEvent(true, false);
|
||||
IGpThreadEvent *returnEvent = systemServices->CreateThreadEvent(true, false);
|
||||
if (!returnEvent)
|
||||
return nullptr;
|
||||
|
||||
PortabilityLayer::HostThreadEvent *wakeEvent = systemServices->CreateThreadEvent(true, false);
|
||||
IGpThreadEvent *wakeEvent = systemServices->CreateThreadEvent(true, false);
|
||||
if (!wakeEvent)
|
||||
{
|
||||
returnEvent->Destroy();
|
||||
|
@@ -1,8 +1,7 @@
|
||||
#include "GpFiber_SDL.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "HostThreadEvent.h"
|
||||
#include "IGpThreadEvent.h"
|
||||
|
||||
GpFiber_SDL::GpFiber_SDL(SDL_Thread *thread, PortabilityLayer::HostThreadEvent *threadEvent)
|
||||
GpFiber_SDL::GpFiber_SDL(SDL_Thread *thread, IGpThreadEvent *threadEvent)
|
||||
: m_event(threadEvent)
|
||||
, m_thread(thread)
|
||||
{
|
||||
|
@@ -3,16 +3,12 @@
|
||||
#include "IGpFiber.h"
|
||||
#include "SDL_thread.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class HostSystemServices;
|
||||
class HostThreadEvent;
|
||||
}
|
||||
struct IGpThreadEvent;
|
||||
|
||||
class GpFiber_SDL final : public IGpFiber
|
||||
{
|
||||
public:
|
||||
explicit GpFiber_SDL(SDL_Thread *thread, PortabilityLayer::HostThreadEvent *threadEvent);
|
||||
explicit GpFiber_SDL(SDL_Thread *thread, IGpThreadEvent *threadEvent);
|
||||
~GpFiber_SDL();
|
||||
|
||||
void YieldTo(IGpFiber *fromFiber) override;
|
||||
@@ -23,6 +19,6 @@ private:
|
||||
static int SDLCALL InternalThreadFunction(void *data);
|
||||
|
||||
bool m_isDestroying;
|
||||
PortabilityLayer::HostThreadEvent *m_event;
|
||||
IGpThreadEvent *m_event;
|
||||
SDL_Thread *m_thread;
|
||||
};
|
||||
|
309
AerofoilSDL/GpInputDriver_SDL_Gamepad.cpp
Normal file
309
AerofoilSDL/GpInputDriver_SDL_Gamepad.cpp
Normal file
@@ -0,0 +1,309 @@
|
||||
#include "GpInputDriver_SDL_Gamepad.h"
|
||||
#include "GpVOSEvent.h"
|
||||
#include "GpWindows.h"
|
||||
#include "IGpVOSEventQueue.h"
|
||||
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_joystick.h"
|
||||
#include "SDL_gamecontroller.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <algorithm>
|
||||
#include <new>
|
||||
#include <vector>
|
||||
|
||||
class GpInputDriverSDLGamepad final : public IGpInputDriverSDLGamepad
|
||||
{
|
||||
public:
|
||||
void ProcessInput() override;
|
||||
void Shutdown() override;
|
||||
|
||||
IGpPrefsHandler *GetPrefsHandler() const override;
|
||||
|
||||
static GpInputDriverSDLGamepad *Create(const GpInputDriverProperties &props);
|
||||
|
||||
void ProcessSDLEvent(const SDL_Event &evt) override;
|
||||
|
||||
private:
|
||||
static const int kMaxPlayers = 2;
|
||||
|
||||
GpInputDriverSDLGamepad(const GpInputDriverProperties &props);
|
||||
~GpInputDriverSDLGamepad();
|
||||
|
||||
bool FindJoystickPlayer(uint8_t &playerNum, SDL_JoystickID joystickID);
|
||||
|
||||
void HandleDeviceAdded(SDL_JoystickID joystickID);
|
||||
void HandleDeviceRemoved(SDL_JoystickID joystickID);
|
||||
|
||||
std::vector<GpVOSEvent> m_pendingEvents;
|
||||
|
||||
GpInputDriverProperties m_properties;
|
||||
|
||||
SDL_JoystickID m_playerJoystickIDs[kMaxPlayers];
|
||||
SDL_GameController *m_playerControllers[kMaxPlayers];
|
||||
bool m_playerButtonDown[kMaxPlayers][GpGamepadButtons::kCount];
|
||||
};
|
||||
|
||||
static GpInputDriverSDLGamepad *gs_instance = nullptr;
|
||||
|
||||
IGpInputDriverSDLGamepad *IGpInputDriverSDLGamepad::GetInstance()
|
||||
{
|
||||
return gs_instance;
|
||||
}
|
||||
|
||||
void GpInputDriverSDLGamepad::ProcessInput()
|
||||
{
|
||||
for (size_t i = 0; i < m_pendingEvents.size(); i++)
|
||||
{
|
||||
if (GpVOSEvent *evt = m_properties.m_eventQueue->QueueEvent())
|
||||
*evt = m_pendingEvents[i];
|
||||
}
|
||||
|
||||
m_pendingEvents.clear();
|
||||
}
|
||||
|
||||
void GpInputDriverSDLGamepad::Shutdown()
|
||||
{
|
||||
this->~GpInputDriverSDLGamepad();
|
||||
free(this);
|
||||
|
||||
gs_instance = nullptr;
|
||||
}
|
||||
|
||||
IGpPrefsHandler *GpInputDriverSDLGamepad::GetPrefsHandler() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GpInputDriverSDLGamepad *GpInputDriverSDLGamepad::Create(const GpInputDriverProperties &props)
|
||||
{
|
||||
void *storage = malloc(sizeof(GpInputDriverSDLGamepad));
|
||||
if (!storage)
|
||||
return nullptr;
|
||||
|
||||
GpInputDriverSDLGamepad *driver = new (storage) GpInputDriverSDLGamepad(props);
|
||||
gs_instance = driver;
|
||||
return driver;
|
||||
}
|
||||
|
||||
GpInputDriverSDLGamepad::GpInputDriverSDLGamepad(const GpInputDriverProperties &props)
|
||||
: m_properties(props)
|
||||
{
|
||||
for (int i = 0; i < kMaxPlayers; i++)
|
||||
{
|
||||
m_playerJoystickIDs[i] = -1;
|
||||
m_playerControllers[i] = nullptr;
|
||||
|
||||
for (int j = 0; j < GpGamepadButtons::kCount; j++)
|
||||
m_playerButtonDown[i][j] = false;
|
||||
}
|
||||
}
|
||||
|
||||
GpInputDriverSDLGamepad::~GpInputDriverSDLGamepad()
|
||||
{
|
||||
for (int i = 0; i < kMaxPlayers; i++)
|
||||
{
|
||||
if (m_playerControllers[i])
|
||||
SDL_GameControllerClose(m_playerControllers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
bool GpInputDriverSDLGamepad::FindJoystickPlayer(uint8_t &playerNum, SDL_JoystickID joystickID)
|
||||
{
|
||||
for (int i = 0; i < kMaxPlayers; i++)
|
||||
{
|
||||
if (m_playerJoystickIDs[i] == joystickID)
|
||||
{
|
||||
playerNum = static_cast<uint8_t>(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void GpInputDriverSDLGamepad::HandleDeviceAdded(SDL_JoystickID joystickID)
|
||||
{
|
||||
for (int i = 0; i < kMaxPlayers; i++)
|
||||
{
|
||||
if (m_playerJoystickIDs[i] == -1)
|
||||
{
|
||||
SDL_GameController *controller = SDL_GameControllerOpen(joystickID);
|
||||
if (controller)
|
||||
{
|
||||
m_playerJoystickIDs[i] = joystickID;
|
||||
m_playerControllers[i] = controller;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GpInputDriverSDLGamepad::HandleDeviceRemoved(SDL_JoystickID joystickID)
|
||||
{
|
||||
int playerNum = 0;
|
||||
bool foundPlayer = false;
|
||||
for (int i = 0; i < kMaxPlayers; i++)
|
||||
{
|
||||
if (m_playerJoystickIDs[i] == joystickID)
|
||||
{
|
||||
SDL_GameControllerClose(m_playerControllers[i]);
|
||||
|
||||
m_playerJoystickIDs[i] = -1;
|
||||
m_playerControllers[i] = nullptr;
|
||||
|
||||
playerNum = i;
|
||||
foundPlayer = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundPlayer)
|
||||
return;
|
||||
|
||||
for (int axis = 0; axis < GpGamepadAxes::kCount; axis++)
|
||||
{
|
||||
GpVOSEvent evt;
|
||||
evt.m_eventType = GpVOSEventTypes::kGamepadInput;
|
||||
evt.m_event.m_gamepadInputEvent.m_eventType = GpGamepadInputEventTypes::kAnalogAxisChanged;
|
||||
evt.m_event.m_gamepadInputEvent.m_event.m_analogAxisEvent.m_axis = static_cast<GpGamepadAxis_t>(axis);
|
||||
evt.m_event.m_gamepadInputEvent.m_event.m_analogAxisEvent.m_player = playerNum;
|
||||
evt.m_event.m_gamepadInputEvent.m_event.m_analogAxisEvent.m_state = 0;
|
||||
|
||||
m_pendingEvents.push_back(evt);
|
||||
}
|
||||
|
||||
for (int button = 0; button < GpGamepadButtons::kCount; button++)
|
||||
{
|
||||
if (m_playerButtonDown[playerNum][button])
|
||||
{
|
||||
m_playerButtonDown[playerNum][button] = false;
|
||||
|
||||
|
||||
|
||||
GpVOSEvent evt;
|
||||
evt.m_eventType = GpVOSEventTypes::kKeyboardInput;
|
||||
evt.m_event.m_keyboardInputEvent.m_eventType = GpKeyboardInputEventTypes::kUp;
|
||||
evt.m_event.m_keyboardInputEvent.m_keyIDSubset = GpKeyIDSubsets::kGamepadButton;
|
||||
evt.m_event.m_keyboardInputEvent.m_key.m_gamepadKey.m_player = playerNum;
|
||||
evt.m_event.m_keyboardInputEvent.m_key.m_gamepadKey.m_button = static_cast<GpGamepadButton_t>(button);
|
||||
evt.m_event.m_keyboardInputEvent.m_repeatCount = 0;
|
||||
|
||||
m_pendingEvents.push_back(evt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GpInputDriverSDLGamepad::ProcessSDLEvent(const SDL_Event &msg)
|
||||
{
|
||||
IGpVOSEventQueue *evtQueue = m_properties.m_eventQueue;
|
||||
|
||||
switch (msg.type)
|
||||
{
|
||||
case SDL_CONTROLLERAXISMOTION:
|
||||
{
|
||||
const SDL_ControllerAxisEvent &axisMsg = msg.caxis;
|
||||
GpGamepadAxis_t axis = GpGamepadAxes::kCount;
|
||||
|
||||
uint8_t playerNumber = 0;
|
||||
if (!FindJoystickPlayer(playerNumber, axisMsg.which))
|
||||
break;
|
||||
|
||||
if (axisMsg.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT)
|
||||
axis = GpGamepadAxes::kLeftTrigger;
|
||||
else if (axisMsg.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT)
|
||||
axis = GpGamepadAxes::kRightTrigger;
|
||||
else if (axisMsg.axis == SDL_CONTROLLER_AXIS_LEFTX)
|
||||
axis = GpGamepadAxes::kLeftStickX;
|
||||
else if (axisMsg.axis == SDL_CONTROLLER_AXIS_LEFTY)
|
||||
axis = GpGamepadAxes::kLeftStickY;
|
||||
else if (axisMsg.axis == SDL_CONTROLLER_AXIS_RIGHTX)
|
||||
axis = GpGamepadAxes::kRightStickX;
|
||||
else if (axisMsg.axis == SDL_CONTROLLER_AXIS_RIGHTY)
|
||||
axis = GpGamepadAxes::kRightStickY;
|
||||
else
|
||||
break;
|
||||
|
||||
GpVOSEvent evt;
|
||||
evt.m_eventType = GpVOSEventTypes::kGamepadInput;
|
||||
evt.m_event.m_gamepadInputEvent.m_eventType = GpGamepadInputEventTypes::kAnalogAxisChanged;
|
||||
evt.m_event.m_gamepadInputEvent.m_event.m_analogAxisEvent.m_axis = axis;
|
||||
evt.m_event.m_gamepadInputEvent.m_event.m_analogAxisEvent.m_player = playerNumber;
|
||||
evt.m_event.m_gamepadInputEvent.m_event.m_analogAxisEvent.m_state = std::max<int16_t>(-32767, axisMsg.value);
|
||||
|
||||
m_pendingEvents.push_back(evt);
|
||||
}
|
||||
break;
|
||||
case SDL_CONTROLLERBUTTONDOWN:
|
||||
case SDL_CONTROLLERBUTTONUP:
|
||||
{
|
||||
const bool isDown = (msg.type == SDL_CONTROLLERBUTTONDOWN);
|
||||
const SDL_ControllerButtonEvent &buttonMsg = msg.cbutton;
|
||||
|
||||
GpGamepadButton_t gpButton = GpGamepadButtons::kCount;
|
||||
|
||||
uint8_t playerNumber = 0;
|
||||
if (!FindJoystickPlayer(playerNumber, buttonMsg.which))
|
||||
break;
|
||||
|
||||
if (buttonMsg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
gpButton = GpGamepadButtons::kFaceRight;
|
||||
else if (buttonMsg.button == SDL_CONTROLLER_BUTTON_B)
|
||||
gpButton = GpGamepadButtons::kFaceDown;
|
||||
else if (buttonMsg.button == SDL_CONTROLLER_BUTTON_X)
|
||||
gpButton = GpGamepadButtons::kFaceUp;
|
||||
else if (buttonMsg.button == SDL_CONTROLLER_BUTTON_Y)
|
||||
gpButton = GpGamepadButtons::kFaceLeft;
|
||||
else if (buttonMsg.button == SDL_CONTROLLER_BUTTON_START)
|
||||
gpButton = GpGamepadButtons::kMisc1;
|
||||
else if (buttonMsg.button == SDL_CONTROLLER_BUTTON_BACK)
|
||||
gpButton = GpGamepadButtons::kMisc2;
|
||||
else if (buttonMsg.button == SDL_CONTROLLER_BUTTON_LEFTSTICK)
|
||||
gpButton = GpGamepadButtons::kLeftStick;
|
||||
else if (buttonMsg.button == SDL_CONTROLLER_BUTTON_RIGHTSTICK)
|
||||
gpButton = GpGamepadButtons::kRightStick;
|
||||
else if (buttonMsg.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER)
|
||||
gpButton = GpGamepadButtons::kLeftBumper;
|
||||
else if (buttonMsg.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER)
|
||||
gpButton = GpGamepadButtons::kRightBumper;
|
||||
else if (buttonMsg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
|
||||
gpButton = GpGamepadButtons::kDPadUp;
|
||||
else if (buttonMsg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
|
||||
gpButton = GpGamepadButtons::kDPadDown;
|
||||
else if (buttonMsg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT)
|
||||
gpButton = GpGamepadButtons::kDPadLeft;
|
||||
else if (buttonMsg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
|
||||
gpButton = GpGamepadButtons::kDPadRight;
|
||||
else
|
||||
break;
|
||||
|
||||
m_playerButtonDown[playerNumber][gpButton] = isDown;
|
||||
|
||||
GpVOSEvent evt;
|
||||
evt.m_eventType = GpVOSEventTypes::kKeyboardInput;
|
||||
evt.m_event.m_keyboardInputEvent.m_eventType = (isDown ? GpKeyboardInputEventTypes::kDown : GpKeyboardInputEventTypes::kUp);
|
||||
evt.m_event.m_keyboardInputEvent.m_keyIDSubset = GpKeyIDSubsets::kGamepadButton;
|
||||
evt.m_event.m_keyboardInputEvent.m_key.m_gamepadKey.m_player = playerNumber;
|
||||
evt.m_event.m_keyboardInputEvent.m_key.m_gamepadKey.m_button = gpButton;
|
||||
evt.m_event.m_keyboardInputEvent.m_repeatCount = 0;
|
||||
|
||||
m_pendingEvents.push_back(evt);
|
||||
}
|
||||
break;
|
||||
case SDL_CONTROLLERDEVICEADDED:
|
||||
HandleDeviceAdded(msg.cdevice.which);
|
||||
break;
|
||||
case SDL_CONTROLLERDEVICEREMOVED:
|
||||
HandleDeviceRemoved(msg.cdevice.which);
|
||||
break;
|
||||
case SDL_CONTROLLERDEVICEREMAPPED:
|
||||
// Not really sure what to do here, just re-add it
|
||||
HandleDeviceRemoved(msg.cdevice.which);
|
||||
HandleDeviceAdded(msg.cdevice.which);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IGpInputDriver *GpDriver_CreateInputDriver_SDL2_Gamepad(const GpInputDriverProperties &properties)
|
||||
{
|
||||
return GpInputDriverSDLGamepad::Create(properties);
|
||||
}
|
14
AerofoilSDL/GpInputDriver_SDL_Gamepad.h
Normal file
14
AerofoilSDL/GpInputDriver_SDL_Gamepad.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "IGpInputDriver.h"
|
||||
#include "GpInputDriverProperties.h"
|
||||
#include "GpVOSEvent.h"
|
||||
|
||||
union SDL_Event;
|
||||
|
||||
struct IGpInputDriverSDLGamepad : public IGpInputDriver
|
||||
{
|
||||
virtual void ProcessSDLEvent(const SDL_Event &evt) = 0;
|
||||
|
||||
static IGpInputDriverSDLGamepad *GetInstance();
|
||||
};
|
@@ -13,10 +13,10 @@
|
||||
#include "GpAppInterface.h"
|
||||
#include "GpSystemServices_Win32.h"
|
||||
#include "GpVOSEvent.h"
|
||||
#include "IGpVOSEventQueue.h"
|
||||
|
||||
#include "HostFileSystem.h"
|
||||
#include "HostThreadEvent.h"
|
||||
#include "IGpFileSystem.h"
|
||||
#include "IGpThreadEvent.h"
|
||||
#include "IGpVOSEventQueue.h"
|
||||
|
||||
#include "GpWindows.h"
|
||||
|
||||
@@ -29,16 +29,16 @@
|
||||
|
||||
GpWindowsGlobals g_gpWindowsGlobals;
|
||||
|
||||
extern "C" __declspec(dllimport) IGpInputDriver *GpDriver_CreateInputDriver_XInput(const GpInputDriverProperties &properties);
|
||||
extern "C" __declspec(dllimport) IGpFontHandler *GpDriver_CreateFontHandler_FreeType2(const GpFontHandlerProperties &properties);
|
||||
|
||||
IGpDisplayDriver *GpDriver_CreateDisplayDriver_SDL_GL2(const GpDisplayDriverProperties &properties);
|
||||
IGpAudioDriver *GpDriver_CreateAudioDriver_SDL(const GpAudioDriverProperties &properties);
|
||||
IGpInputDriver *GpDriver_CreateInputDriver_SDL2_Gamepad(const GpInputDriverProperties &properties);
|
||||
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) < 0)
|
||||
return -1;
|
||||
|
||||
LPWSTR cmdLine = GetCommandLineW();
|
||||
@@ -56,10 +56,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
}
|
||||
|
||||
IGpLogDriver *logger = GpLogDriver_Win32::GetInstance();
|
||||
GpDriverCollection *drivers = GpAppInterface_Get()->PL_GetDriverCollection();
|
||||
|
||||
GpAppInterface_Get()->PL_HostFileSystem_SetInstance(GpFileSystem_Win32::GetInstance());
|
||||
GpAppInterface_Get()->PL_HostSystemServices_SetInstance(GpSystemServices_Win32::GetInstance());
|
||||
GpAppInterface_Get()->PL_HostLogDriver_SetInstance(GpLogDriver_Win32::GetInstance());
|
||||
drivers->SetDriver<GpDriverIDs::kFileSystem>(GpFileSystem_Win32::GetInstance());
|
||||
drivers->SetDriver<GpDriverIDs::kSystemServices>(GpSystemServices_Win32::GetInstance());
|
||||
drivers->SetDriver<GpDriverIDs::kLog>(GpLogDriver_Win32::GetInstance());
|
||||
|
||||
g_gpWindowsGlobals.m_hInstance = hInstance;
|
||||
g_gpWindowsGlobals.m_hPrevInstance = hPrevInstance;
|
||||
@@ -78,7 +79,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
|
||||
EGpInputDriverType inputDrivers[] =
|
||||
{
|
||||
EGpInputDriverType_XInput
|
||||
EGpInputDriverType_SDL2_Gamepad
|
||||
};
|
||||
|
||||
g_gpGlobalConfig.m_inputDriverTypes = inputDrivers;
|
||||
@@ -90,7 +91,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
|
||||
GpDisplayDriverFactory::RegisterDisplayDriverFactory(EGpDisplayDriverType_SDL_GL2, GpDriver_CreateDisplayDriver_SDL_GL2);
|
||||
GpAudioDriverFactory::RegisterAudioDriverFactory(EGpAudioDriverType_SDL2, GpDriver_CreateAudioDriver_SDL);
|
||||
GpInputDriverFactory::RegisterInputDriverFactory(EGpInputDriverType_XInput, GpDriver_CreateInputDriver_XInput);
|
||||
GpInputDriverFactory::RegisterInputDriverFactory(EGpInputDriverType_SDL2_Gamepad, GpDriver_CreateInputDriver_SDL2_Gamepad);
|
||||
GpFontHandlerFactory::RegisterFontHandlerFactory(EGpFontHandlerType_FreeType2, GpDriver_CreateFontHandler_FreeType2);
|
||||
|
||||
if (logger)
|
||||
|
35
AerofoilSDL/ShaderCode/DrawQuad32P.cpp
Normal file
35
AerofoilSDL/ShaderCode/DrawQuad32P.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "Functions.h"
|
||||
#include "DrawQuadPixelConstants.h"
|
||||
|
||||
#define GP_GL_SHADER_CODE_DRAWQUAD32P_GLSL \
|
||||
"\n"\
|
||||
"varying vec4 texCoord;\n"\
|
||||
"uniform sampler2D surfaceTexture;\n"\
|
||||
"uniform sampler2D paletteTexture;\n"\
|
||||
"\n"\
|
||||
"vec3 SamplePixel(vec2 tc)\n"\
|
||||
"{\n"\
|
||||
" return texture2D(surfaceTexture, tc).rgb;\n"\
|
||||
"}\n"\
|
||||
"\n"\
|
||||
"void main()\n"\
|
||||
"{\n"\
|
||||
" vec4 resultColor = vec4(SamplePixel(texCoord.xy), 1.0);\n"\
|
||||
" resultColor *= constants_Modulation;\n"\
|
||||
"#ifdef ENABLE_FLICKER\n"\
|
||||
" resultColor = ApplyFlicker(constants_FlickerAxis, texCoord.zw, constants_FlickerStartThreshold, constants_FlickerEndThreshold, resultColor * constants_Modulation);\n"\
|
||||
" if (resultColor.a < 1.0)\n"\
|
||||
" discard;\n"\
|
||||
"#endif\n"\
|
||||
" resultColor = ApplyDesaturation(constants_Desaturation, resultColor);\n"\
|
||||
"\n"\
|
||||
" gl_FragColor = vec4(ApplyColorSpaceTransform(resultColor.rgb), resultColor.a);\n"\
|
||||
"}\n"
|
||||
|
||||
namespace GpBinarizedShaders
|
||||
{
|
||||
const char *g_drawQuad32PF_GL2 = "#define ENABLE_FLICKER\n" GP_GL_SHADER_CODE_MEDIUM_PRECISION_PREFIX GP_GL_SHADER_CODE_DRAWQUADPIXELCONSTANTS_H GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_DRAWQUAD32P_GLSL;
|
||||
const char *g_drawQuad32PNF_GL2 = GP_GL_SHADER_CODE_MEDIUM_PRECISION_PREFIX GP_GL_SHADER_CODE_DRAWQUADPIXELCONSTANTS_H GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_DRAWQUAD32P_GLSL;
|
||||
const char *g_drawQuad32ICCPF_GL2 = "#define USE_ICC_PROFILE\n" "#define ENABLE_FLICKER\n" GP_GL_SHADER_CODE_MEDIUM_PRECISION_PREFIX GP_GL_SHADER_CODE_DRAWQUADPIXELCONSTANTS_H GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_DRAWQUAD32P_GLSL;
|
||||
const char *g_drawQuad32ICCPNF_GL2 = "#define USE_ICC_PROFILE\n" GP_GL_SHADER_CODE_MEDIUM_PRECISION_PREFIX GP_GL_SHADER_CODE_DRAWQUADPIXELCONSTANTS_H GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_DRAWQUAD32P_GLSL;
|
||||
}
|
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
|
||||
}
|
||||
]
|
||||
}
|
@@ -22,7 +22,7 @@
|
||||
"itemType" : "CustomControl",
|
||||
"pos" : [ 17, 33 ],
|
||||
"size" : [ 401, 190 ],
|
||||
"id" : 2,
|
||||
"id" : 3,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
@@ -30,9 +30,17 @@
|
||||
"itemType" : "CustomControl",
|
||||
"pos" : [ 418, 32 ],
|
||||
"size" : [ 16, 192 ],
|
||||
"id" : 3,
|
||||
"id" : 4,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
"name" : "Delete",
|
||||
"itemType" : "Button",
|
||||
"pos" : [ 228, 240 ],
|
||||
"size" : [ 58, 20 ],
|
||||
"id" : 5,
|
||||
"enabled" : false
|
||||
},
|
||||
{
|
||||
"name" : "^0",
|
||||
"itemType" : "Label",
|
||||
|
@@ -18,7 +18,7 @@
|
||||
"enabled" : false
|
||||
},
|
||||
{
|
||||
"name" : "Aerofoil ©2019-2020 Eric Lasota",
|
||||
"name" : "Aerofoil ©2019-2021 Eric Lasota",
|
||||
"itemType" : "Label",
|
||||
"pos" : [ 16, 21 ],
|
||||
"size" : [ 406, 20 ],
|
||||
|
29
ApplicationResourcePatches/DITL/2008.json
Normal file
29
ApplicationResourcePatches/DITL/2008.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"items" :
|
||||
[
|
||||
{
|
||||
"name" : "No",
|
||||
"itemType" : "Button",
|
||||
"pos" : [ 253, 99 ],
|
||||
"size" : [ 58, 20 ],
|
||||
"id" : 1,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
"name" : "Yes",
|
||||
"itemType" : "Button",
|
||||
"pos" : [ 184, 99 ],
|
||||
"size" : [ 58, 20 ],
|
||||
"id" : 2,
|
||||
"enabled" : true
|
||||
},
|
||||
{
|
||||
"name" : "Are you sure that you want to delete this file?",
|
||||
"itemType" : "Label",
|
||||
"pos" : [ 16, 16 ],
|
||||
"size" : [ 295, 74 ],
|
||||
"id" : 0,
|
||||
"enabled" : false
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 7.1 KiB |
BIN
ApplicationResourcePatches/PICT/1303.bmp
Normal file
BIN
ApplicationResourcePatches/PICT/1303.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
@@ -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",
|
||||
@@ -10,9 +11,11 @@
|
||||
"DITL/2005.json" : "ApplicationResourcePatches/DITL/2005.json",
|
||||
"DITL/2006.json" : "ApplicationResourcePatches/DITL/2006.json",
|
||||
"DITL/2007.json" : "ApplicationResourcePatches/DITL/2007.json",
|
||||
"DITL/2008.json" : "ApplicationResourcePatches/DITL/2008.json",
|
||||
"PICT/1300.bmp" : "ApplicationResourcePatches/PICT/1300.bmp",
|
||||
"PICT/1301.bmp" : "ApplicationResourcePatches/PICT/1301.bmp",
|
||||
"PICT/1302.bmp" : "ApplicationResourcePatches/PICT/1302.bmp",
|
||||
"PICT/1303.bmp" : "ApplicationResourcePatches/PICT/1303.bmp",
|
||||
"PICT/1971.bmp" : "ApplicationResourcePatches/PICT/1971.bmp",
|
||||
"PICT/1972.bmp" : "ApplicationResourcePatches/PICT/1972.bmp",
|
||||
"PICT/1973.bmp" : "ApplicationResourcePatches/PICT/1973.bmp",
|
||||
|
@@ -21,7 +21,8 @@ const D3D_SHADER_MACRO drawQuadDefs[] =
|
||||
|
||||
const D3D_SHADER_MACRO drawQuadICCProfileDefs[] =
|
||||
{
|
||||
{ "USE_ICC_PROFILE", nullptr }
|
||||
{ "USE_ICC_PROFILE", nullptr },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
const CompileJob kCompileJobs[] =
|
||||
@@ -108,7 +109,7 @@ int main(int argc, const char **argv)
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
fprintf(stderr, "Compile failure error: %x", static_cast<int>(result));
|
||||
fprintf(stderr, "Compile failure error: %x\n", static_cast<int>(result));
|
||||
}
|
||||
|
||||
if (errorMsgs)
|
||||
|
@@ -2,14 +2,17 @@ rmdir /S /Q Packaged
|
||||
|
||||
mkdir Packaged
|
||||
mkdir Packaged\Houses
|
||||
mkdir Packaged\WinCursors
|
||||
|
||||
x64\Release\MiniRez.exe "GliderProData\Glider PRO.r" Packaged\ApplicationResources.gpr
|
||||
|
||||
x64\Release\gpr2gpa.exe "Packaged\ApplicationResources.gpr" "DefaultTimestamp.timestamp" "Packaged\ApplicationResources.gpa" "ApplicationResourcePatches\manifest.json"
|
||||
x64\Release\FTagData.exe "DefaultTimestamp.timestamp" "Packaged\ApplicationResources.gpf" data ozm5 0 0 locked
|
||||
|
||||
x64\Release\MergeGPF.exe "Packaged\ApplicationResources.gpf"
|
||||
|
||||
x64\Release\ConvertColorCursors.exe
|
||||
|
||||
attrib -R Packaged\ApplicationResources.gpf
|
||||
attrib -R Packaged\Houses\*
|
||||
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\Art Museum.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\Art Museum"
|
||||
@@ -18,7 +21,6 @@ x64\Release\hqx2gp.exe "GliderProData\Houses\Castle o' the Air.binhex" "DefaultT
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\CD Demo House.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\CD Demo House"
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\Davis Station.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\Davis Station"
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\Demo House.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\Demo House"
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\Empty House.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\Empty House"
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\Fun House.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\Fun House"
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\Grand Prix.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\Grand Prix"
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\ImagineHouse PRO II.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\ImagineHouse PRO II"
|
||||
@@ -28,7 +30,6 @@ x64\Release\hqx2gp.exe "GliderProData\Houses\Leviathan.binhex" "DefaultTimestamp
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\Metropolis.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\Metropolis"
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\Nemo's Market.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\Nemo's Market"
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\Rainbow's End.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\Rainbow's End"
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\Sampler.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\Sampler"
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\Slumberland.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\Slumberland"
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\SpacePods.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\SpacePods"
|
||||
x64\Release\hqx2gp.exe "GliderProData\Houses\Teddy World.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\Teddy World"
|
||||
@@ -41,17 +42,15 @@ x64\Release\gpr2gpa.exe "Packaged\Houses\Castle o' the Air.gpr" "DefaultTimestam
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\CD Demo House.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\CD Demo House.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Davis Station.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Davis Station.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Demo House.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Demo House.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Empty House.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Empty House.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Fun House.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Fun House.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Grand Prix.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Grand Prix.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\ImagineHouse PRO II.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\ImagineHouse PRO II.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\In The Mirror.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\In The Mirror.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Grand Prix.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Grand Prix.gpa" "HousePatches\GrandPrix.json"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\ImagineHouse PRO II.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\ImagineHouse PRO II.gpa" "HousePatches\ImagineHousePROII.json"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\In The Mirror.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\In The Mirror.gpa" "HousePatches\InTheMirror.json"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Land of Illusion.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Land of Illusion.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Leviathan.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Leviathan.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Leviathan.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Leviathan.gpa" "HousePatches\Leviathan.json"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Metropolis.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Metropolis.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Nemo's Market.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Nemo's Market.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Rainbow's End.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Rainbow's End.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Sampler.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Sampler.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Rainbow's End.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Rainbow's End.gpa" "HousePatches\RainbowsEnd.json"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Slumberland.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Slumberland.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\SpacePods.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\SpacePods.gpa"
|
||||
x64\Release\gpr2gpa.exe "Packaged\Houses\Teddy World.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Teddy World.gpa"
|
||||
@@ -74,11 +73,52 @@ x64\Release\FTagData.exe "DefaultTimestamp.timestamp" "Packaged\Houses\SpacePods
|
||||
x64\Release\FTagData.exe "DefaultTimestamp.timestamp" "Packaged\Houses\Teddy World.mov.gpf" MooV ozm5 0 0 locked
|
||||
x64\Release\FTagData.exe "DefaultTimestamp.timestamp" "Packaged\Houses\Titanic.mov.gpf" MooV ozm5 0 0 locked
|
||||
|
||||
del /Q Packaged\Houses\*.gpr
|
||||
del /Q Packaged\ApplicationResources.gpr
|
||||
|
||||
copy /Y GliderProData\ConvertedMovies\*.mov.gpa Packaged\Houses\
|
||||
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Art Museum.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\California or Bust!.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Castle o' the Air.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\CD Demo House.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Davis Station.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Demo House.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Fun House.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Grand Prix.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\ImagineHouse PRO II.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\In The Mirror.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Land of Illusion.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Leviathan.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Metropolis.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Nemo's Market.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Rainbow's End.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Slumberland.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\SpacePods.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Teddy World.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\The Asylum Pro.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Titanic.gpf"
|
||||
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Art Museum.mov.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Castle o' the Air.mov.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\CD Demo House.mov.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Davis Station.mov.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Demo House.mov.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Grand Prix.mov.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\ImagineHouse PRO II.mov.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Land of Illusion.mov.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Leviathan.mov.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Nemo's Market.mov.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Rainbow's End.mov.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Slumberland.mov.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\SpacePods.mov.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Teddy World.mov.gpf"
|
||||
x64\Release\MergeGPF.exe "Packaged\Houses\Titanic.mov.gpf"
|
||||
|
||||
del /Q Packaged\Houses\*.gpr
|
||||
del /Q Packaged\Houses\*.gpa
|
||||
del /Q Packaged\Houses\*.gpd
|
||||
del /Q Packaged\ApplicationResources.gpr
|
||||
del /Q Packaged\ApplicationResources.gpa
|
||||
|
||||
attrib +R Packaged\Houses\*
|
||||
attrib +R Packaged\ApplicationResources.gpf
|
||||
|
||||
pause
|
||||
|
@@ -2,6 +2,8 @@
|
||||
#include <string>
|
||||
#include <Windows.h>
|
||||
#include "MacFileInfo.h"
|
||||
#include "CFileStream.h"
|
||||
#include "CombinedTimestamp.h"
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
@@ -29,19 +31,16 @@ int main(int argc, const char **argv)
|
||||
FILE *tsF = nullptr;
|
||||
errno_t ferr = fopen_s(&tsF, timestampPath.c_str(), "rb");
|
||||
int64_t timestamp = 0;
|
||||
PortabilityLayer::CombinedTimestamp ts;
|
||||
|
||||
if (!ferr)
|
||||
{
|
||||
uint8_t encodedTimestamp[8];
|
||||
if (fread(encodedTimestamp, 1, 8, tsF) != 8)
|
||||
if (fread(&ts, 1, sizeof(ts), tsF) != sizeof(ts))
|
||||
{
|
||||
fprintf(stderr, "Error reading timestamp file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
timestamp |= static_cast<int64_t>(encodedTimestamp[i]) << (i * 8);
|
||||
|
||||
fclose(tsF);
|
||||
}
|
||||
|
||||
@@ -52,7 +51,7 @@ int main(int argc, const char **argv)
|
||||
mfp.m_yPos = atoi(argv[6]);
|
||||
mfp.m_finderFlags = 0;
|
||||
mfp.m_protected = 0;
|
||||
mfp.m_modifiedDate = mfp.m_creationDate = timestamp;
|
||||
mfp.m_modifiedTimeMacEpoch = mfp.m_createdTimeMacEpoch = timestamp;
|
||||
|
||||
for (int i = 7; i < argc; i++)
|
||||
{
|
||||
@@ -82,8 +81,11 @@ int main(int argc, const char **argv)
|
||||
errno_t err = fopen_s(&file, outPath.c_str(), "wb");
|
||||
if (!err)
|
||||
{
|
||||
fwrite(mps.m_data, PortabilityLayer::MacFilePropertiesSerialized::kSize, 1, file);
|
||||
fclose(file);
|
||||
PortabilityLayer::CFileStream stream(file);
|
||||
|
||||
mps.WriteAsPackage(stream, ts);
|
||||
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@@ -4,7 +4,24 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//============================================================================
|
||||
|
||||
#include "About.h"
|
||||
#include "DialogManager.h"
|
||||
#include "DialogUtils.h"
|
||||
#include "Environ.h"
|
||||
#include "Externs.h"
|
||||
#include "GpApplicationName.h"
|
||||
#include "GpBuildVersion.h"
|
||||
#include "IGpSystemServices.h"
|
||||
#include "RenderedFont.h"
|
||||
#include "GpRenderedFontMetrics.h"
|
||||
#include "ResolveCachingColor.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "ScanlineMask.h"
|
||||
#include "WindowDef.h"
|
||||
#include "WindowManager.h"
|
||||
|
||||
#include "PLArrayView.h"
|
||||
#include "PLDrivers.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLControlDefinitions.h"
|
||||
#include "FontFamily.h"
|
||||
@@ -19,21 +36,6 @@
|
||||
#include "PLSysCalls.h"
|
||||
#include "PLTimeTaggedVOSEvent.h"
|
||||
#include "PLWidgets.h"
|
||||
#include "About.h"
|
||||
#include "DialogManager.h"
|
||||
#include "DialogUtils.h"
|
||||
#include "Environ.h"
|
||||
#include "Externs.h"
|
||||
#include "GpApplicationName.h"
|
||||
#include "GpBuildVersion.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "RenderedFont.h"
|
||||
#include "GpRenderedFontMetrics.h"
|
||||
#include "ResolveCachingColor.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "ScanlineMask.h"
|
||||
#include "WindowDef.h"
|
||||
#include "WindowManager.h"
|
||||
|
||||
|
||||
static void HiLiteOkayButton (DrawSurface *surface);
|
||||
@@ -333,10 +335,10 @@ void DoAboutFramework (void)
|
||||
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\xaa."), 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 and publishers of Glider PRO\xaa."), 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);
|
||||
@@ -418,7 +420,7 @@ static void UpdateMainPict (Dialog *theDial)
|
||||
Str255 theStr, theStr2;
|
||||
uint64_t freeMemory;
|
||||
|
||||
freeMemory = PortabilityLayer::HostSystemServices::GetInstance()->GetFreeMemoryCosmetic();
|
||||
freeMemory = PLDrivers::GetSystemServices()->GetFreeMemoryCosmetic();
|
||||
|
||||
PasStringCopy(PSTR("Memory: "), theStr); // display free memory
|
||||
|
||||
|
@@ -5,17 +5,17 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//============================================================================
|
||||
|
||||
|
||||
#include "PLResources.h"
|
||||
#include "PLBigEndian.h"
|
||||
#include "Externs.h"
|
||||
#include "Environ.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "IGpCursor.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "MemoryManager.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
#include "PLDrivers.h"
|
||||
#include "PLResources.h"
|
||||
#include "PLBigEndian.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ IGpCursor *LoadColorCursor(int16_t resID)
|
||||
|
||||
mm->Release(colorValues);
|
||||
|
||||
IGpCursor *cursor = PortabilityLayer::HostDisplayDriver::GetInstance()->CreateColorCursor(width, height, pixelDataRGBA, cursorHeader->m_hotSpotX, cursorHeader->m_hotSpotY);
|
||||
IGpCursor *cursor = PLDrivers::GetDisplayDriver()->CreateColorCursor(width, height, pixelDataRGBA, cursorHeader->m_hotSpotX, cursorHeader->m_hotSpotY);
|
||||
|
||||
mm->Release(pixelDataRGBA);
|
||||
|
||||
@@ -251,7 +251,7 @@ Boolean GetColorCursors (acurHandle ballCursH, compiledAcurHandle compiledBallCu
|
||||
else // But, if the cursor loaded ok
|
||||
{ // add it to our list or cursor handles
|
||||
(*compiledBallCursH)->frame[i].hwCursor = hwCursor;
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(hwCursor);
|
||||
PLDrivers::GetDisplayDriver()->SetCursor(hwCursor);
|
||||
}
|
||||
}
|
||||
InitCursor(); // Show the cursor again (as arrow)
|
||||
@@ -343,10 +343,10 @@ void IncrementCursor (void)
|
||||
acur->index++;
|
||||
acur->index %= acur->n;
|
||||
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor);
|
||||
PLDrivers::GetDisplayDriver()->SetCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor);
|
||||
}
|
||||
else
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kWait);
|
||||
PLDrivers::GetDisplayDriver()->SetStandardCursor(EGpStandardCursors::kWait);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DecrementCursor
|
||||
@@ -363,10 +363,10 @@ void DecrementCursor (void)
|
||||
if (((*animCursorH)->index) < 0)
|
||||
(*animCursorH)->index = ((*animCursorH)->n) - 1;
|
||||
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor);
|
||||
PLDrivers::GetDisplayDriver()->SetCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor);
|
||||
}
|
||||
else
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kWait);
|
||||
PLDrivers::GetDisplayDriver()->SetStandardCursor(EGpStandardCursors::kWait);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- SpinCursor
|
||||
|
@@ -147,8 +147,6 @@ void CenterDialog (SInt16 dialogID)
|
||||
|
||||
void GetDialogRect (Rect *bounds, short dialogID)
|
||||
{
|
||||
Byte wasState;
|
||||
|
||||
Handle dlogHandle = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('DLOG', dialogID).StaticCast<void>();
|
||||
if (dlogHandle != nil)
|
||||
{
|
||||
@@ -343,10 +341,8 @@ void ZoomOutAlertRect (short alertID)
|
||||
|
||||
void FlashDialogButton (Dialog *theDialog, short itemNumber)
|
||||
{
|
||||
Rect itemRect;
|
||||
ControlHandle itemHandle;
|
||||
UInt32 dummyLong;
|
||||
short itemType;
|
||||
|
||||
PortabilityLayer::Widget *widget = theDialog->GetItems()[itemNumber - 1].GetWidget();
|
||||
|
||||
@@ -445,9 +441,7 @@ void ToggleDialogItemValue (Dialog *theDialog, short item)
|
||||
void SetDialogNumToStr (Dialog *theDialog, short item, long theNumber)
|
||||
{
|
||||
Str255 theString;
|
||||
Rect itemRect;
|
||||
ControlHandle itemHandle;
|
||||
short itemType;
|
||||
|
||||
NumToString(theNumber, theString);
|
||||
PortabilityLayer::Widget *widget = theDialog->GetItems()[item - 1].GetWidget();
|
||||
@@ -570,7 +564,7 @@ void DrawDialogUserText (Dialog *dial, short item, StringPtr text, Boolean inver
|
||||
{
|
||||
ControlHandle iHandle;
|
||||
Str255 stringCopy;
|
||||
short iType, i, inset;
|
||||
short inset;
|
||||
|
||||
DrawSurface *surface = dial->GetWindow()->GetDrawSurface();
|
||||
|
||||
@@ -622,9 +616,7 @@ void DrawDialogUserText (Dialog *dial, short item, StringPtr text, Boolean inver
|
||||
|
||||
void DrawDialogUserText2 (Dialog *dial, short item, StringPtr text)
|
||||
{
|
||||
;
|
||||
Str255 stringCopy;
|
||||
short iType;
|
||||
|
||||
DrawSurface *surface = dial->GetWindow()->GetDrawSurface();
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
|
@@ -5,18 +5,19 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//============================================================================
|
||||
|
||||
|
||||
#include "PLResources.h"
|
||||
#include "PLPasStr.h"
|
||||
#include "DisplayDeviceManager.h"
|
||||
#include "Externs.h"
|
||||
#include "Environ.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "MenuManager.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "IGpSystemServices.h"
|
||||
#include "Vec2i.h"
|
||||
#include "WindowManager.h"
|
||||
|
||||
#include "PLDrivers.h"
|
||||
#include "PLResources.h"
|
||||
#include "PLPasStr.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#define kSwitchDepthAlert 130
|
||||
@@ -301,8 +302,8 @@ void CheckOurEnvirons (void)
|
||||
thisMac.numScreens = HowManyUsableScreens(false, true, true);
|
||||
|
||||
thisMac.isResolutionDirty = true;
|
||||
thisMac.isTouchscreen = PortabilityLayer::HostSystemServices::GetInstance()->IsTouchscreen();
|
||||
thisMac.isMouseTouchscreen = PortabilityLayer::HostSystemServices::GetInstance()->IsUsingMouseAsTouch();
|
||||
thisMac.isTouchscreen = PLDrivers::GetSystemServices()->IsTouchscreen();
|
||||
thisMac.isMouseTouchscreen = PLDrivers::GetSystemServices()->IsUsingMouseAsTouch();
|
||||
|
||||
FlushResolutionChange();
|
||||
}
|
||||
@@ -415,16 +416,14 @@ void HandleDepthSwitching (void)
|
||||
|
||||
thisMac.isDepth = isDepthPref;
|
||||
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->SetUseICCProfile(isUseICCProfile != 0);
|
||||
PLDrivers::GetDisplayDriver()->SetUseICCProfile(isUseICCProfile != 0);
|
||||
}
|
||||
|
||||
void GetDeviceRect(Rect *rect)
|
||||
{
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&width, &height);
|
||||
PortabilityLayer::Vec2i displayResolution = PortabilityLayer::WindowManager::GetInstance()->GetDisplayResolution();
|
||||
|
||||
SetRect(rect, 0, 0, static_cast<short>(width), static_cast<short>(height));
|
||||
SetRect(rect, 0, 0, static_cast<short>(displayResolution.m_x), static_cast<short>(displayResolution.m_y));
|
||||
}
|
||||
|
||||
Boolean AreWeColorOrGrayscale()
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include "WindowManager.h"
|
||||
|
||||
|
||||
short BitchAboutColorDepth (void);
|
||||
void HandleMouseEvent (const GpMouseInputEvent &, uint32_t);
|
||||
void HandleKeyEvent (const KeyDownStates &keyStates, const GpKeyboardInputEvent &);
|
||||
void HandleUpdateEvent (EventRecord *);
|
||||
@@ -45,20 +44,6 @@ extern Boolean autoRoomEdit, newRoomNow, isPlayMusicIdle;
|
||||
|
||||
|
||||
//============================================================== Functions
|
||||
//-------------------------------------------------------------- BitchAboutColorDepth
|
||||
// Display a dialog that alerts the user that they have switched the bit<69>
|
||||
// depth of the monitor under our noses. They must return it to previous.
|
||||
|
||||
short BitchAboutColorDepth (void)
|
||||
{
|
||||
#define kColorSwitchedAlert 1042
|
||||
short sheSaid;
|
||||
|
||||
// CenterAlert(kColorSwitchedAlert);
|
||||
sheSaid = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kColorSwitchedAlert, nullptr);
|
||||
|
||||
return (sheSaid);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- HandleMouseEvent
|
||||
// Handle a mouse click event.
|
||||
|
@@ -118,7 +118,7 @@ typedef struct
|
||||
Boolean wasEscPauseKey;
|
||||
Boolean wasDoAutoDemo, wasAutoScale;
|
||||
Boolean wasDoBackground, wasHouseChecks;
|
||||
Boolean wasPrettyMap, wasBitchDialogs;
|
||||
Boolean wasPrettyMap, wasComplainDialogs;
|
||||
Boolean wasUseICCProfile;
|
||||
} prefsInfo;
|
||||
|
||||
|
@@ -48,6 +48,9 @@ Boolean CheckFileError (short resultCode, const PLPasStr &fileName)
|
||||
case PLErrors::kOutOfMemory:
|
||||
stringIndex = 7;
|
||||
break;
|
||||
case PLErrors::kFileIsBusy:
|
||||
stringIndex = 12;
|
||||
break;
|
||||
default:
|
||||
stringIndex = 1;
|
||||
break;
|
||||
|
@@ -121,10 +121,10 @@ void ShiftWholeHouse (SInt16);
|
||||
|
||||
void DoHouseInfo (void); // --- HouseInfo.c
|
||||
|
||||
Boolean OpenHouse (void); // --- HouseIO.c
|
||||
Boolean OpenHouse (Boolean load); // --- HouseIO.c
|
||||
Boolean OpenSpecificHouse (const VFileSpec &);
|
||||
Boolean SaveHouseAs (void);
|
||||
Boolean ReadHouse (void);
|
||||
Boolean ReadHouse (GpIOStream *houseStream);
|
||||
Boolean WriteHouse (Boolean);
|
||||
Boolean CloseHouse (void);
|
||||
void OpenHouseResFork (void);
|
||||
@@ -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);
|
||||
|
||||
@@ -461,7 +461,6 @@ void DumpTriggerSound (void);
|
||||
void InitSound (void);
|
||||
void KillSound (void);
|
||||
void TellHerNoSounds (void);
|
||||
void BitchAboutSM3 (void);
|
||||
|
||||
void InitScoreboardMap (void); // --- StructuresInit.c
|
||||
void InitGliderMap (void);
|
||||
|
@@ -1,20 +1,16 @@
|
||||
#include "GpAppInterface.h"
|
||||
|
||||
#include "DisplayDeviceManager.h"
|
||||
#include "HostAudioDriver.h"
|
||||
#include "HostFileSystem.h"
|
||||
#include "HostFontHandler.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "HostLogDriver.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "HostInputDriver.h"
|
||||
#include "HostVOSEventQueue.h"
|
||||
#include "MenuManager.h"
|
||||
#include "WindowManager.h"
|
||||
|
||||
#include "PLDrivers.h"
|
||||
#include "PLSysCalls.h"
|
||||
|
||||
int gpAppMain();
|
||||
void gpAppInit();
|
||||
|
||||
|
||||
class GpAppInterfaceImpl final : public GpAppInterface
|
||||
{
|
||||
public:
|
||||
@@ -23,14 +19,7 @@ public:
|
||||
|
||||
void PL_IncrementTickCounter(uint32_t count) override;
|
||||
void PL_Render(IGpDisplayDriver *displayDriver) override;
|
||||
void PL_HostFileSystem_SetInstance(PortabilityLayer::HostFileSystem *instance) override;
|
||||
void PL_HostDisplayDriver_SetInstance(IGpDisplayDriver *instance) override;
|
||||
void PL_HostInputDriver_SetInstances(IGpInputDriver *const* instances, size_t numInstances) override;
|
||||
void PL_HostSystemServices_SetInstance(PortabilityLayer::HostSystemServices *instance) override;
|
||||
void PL_HostAudioDriver_SetInstance(IGpAudioDriver *instance) override;
|
||||
void PL_HostLogDriver_SetInstance(IGpLogDriver *instance) override;
|
||||
void PL_HostFontHandler_SetInstance(IGpFontHandler *instance) override;
|
||||
void PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance) override;
|
||||
GpDriverCollection *PL_GetDriverCollection() override;
|
||||
void PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) override;
|
||||
bool PL_AdjustRequestedResolution(uint32_t &physicalWidth, uint32_t &physicalHeight, uint32_t &virtualWidth, uint32_t &virtualheight, float &pixelScaleX, float &pixelScaleY) override;
|
||||
};
|
||||
@@ -42,7 +31,7 @@ void GpAppInterfaceImpl::ApplicationInit()
|
||||
|
||||
int GpAppInterfaceImpl::ApplicationMain()
|
||||
{
|
||||
return gpAppMain();
|
||||
return PLSysCalls::MainExitWrapper(gpAppMain);
|
||||
}
|
||||
|
||||
void GpAppInterfaceImpl::PL_IncrementTickCounter(uint32_t count)
|
||||
@@ -56,44 +45,9 @@ void GpAppInterfaceImpl::PL_Render(IGpDisplayDriver *displayDriver)
|
||||
PortabilityLayer::MenuManager::GetInstance()->RenderFrame(displayDriver);
|
||||
}
|
||||
|
||||
void GpAppInterfaceImpl::PL_HostFileSystem_SetInstance(PortabilityLayer::HostFileSystem *instance)
|
||||
GpDriverCollection *GpAppInterfaceImpl::PL_GetDriverCollection()
|
||||
{
|
||||
PortabilityLayer::HostFileSystem::SetInstance(instance);
|
||||
}
|
||||
|
||||
void GpAppInterfaceImpl::PL_HostDisplayDriver_SetInstance(IGpDisplayDriver *instance)
|
||||
{
|
||||
PortabilityLayer::HostDisplayDriver::SetInstance(instance);
|
||||
}
|
||||
|
||||
void GpAppInterfaceImpl::PL_HostLogDriver_SetInstance(IGpLogDriver *instance)
|
||||
{
|
||||
PortabilityLayer::HostLogDriver::SetInstance(instance);
|
||||
}
|
||||
|
||||
void GpAppInterfaceImpl::PL_HostSystemServices_SetInstance(PortabilityLayer::HostSystemServices *instance)
|
||||
{
|
||||
PortabilityLayer::HostSystemServices::SetInstance(instance);
|
||||
}
|
||||
|
||||
void GpAppInterfaceImpl::PL_HostAudioDriver_SetInstance(IGpAudioDriver *instance)
|
||||
{
|
||||
PortabilityLayer::HostAudioDriver::SetInstance(instance);
|
||||
}
|
||||
|
||||
void GpAppInterfaceImpl::PL_HostInputDriver_SetInstances(IGpInputDriver *const* instances, size_t numInstances)
|
||||
{
|
||||
PortabilityLayer::HostInputDriver::SetInstances(instances, numInstances);
|
||||
}
|
||||
|
||||
void GpAppInterfaceImpl::PL_HostFontHandler_SetInstance(IGpFontHandler *instance)
|
||||
{
|
||||
PortabilityLayer::HostFontHandler::SetInstance(instance);
|
||||
}
|
||||
|
||||
void GpAppInterfaceImpl::PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance)
|
||||
{
|
||||
PortabilityLayer::HostVOSEventQueue::SetInstance(instance);
|
||||
return PLDrivers::GetDriverCollection();
|
||||
}
|
||||
|
||||
void GpAppInterfaceImpl::PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context)
|
||||
|
@@ -17,18 +17,22 @@
|
||||
#include "FileManager.h"
|
||||
#include "FontFamily.h"
|
||||
#include "FontManager.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "House.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "IGpSystemServices.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "MainWindow.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "PLTimeTaggedVOSEvent.h"
|
||||
#include "RectUtils.h"
|
||||
#include "RenderedFont.h"
|
||||
#include "ResolveCachingColor.h"
|
||||
#include "Utilities.h"
|
||||
#include "Vec2i.h"
|
||||
#include "WindowManager.h"
|
||||
|
||||
#include "PLDrivers.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "PLTimeTaggedVOSEvent.h"
|
||||
|
||||
#define kHighScoresPictID 1994
|
||||
#define kHighScoresMaskID 1998
|
||||
#define kHighNameDialogID 1020
|
||||
@@ -46,7 +50,7 @@ void GetHighScoreName (short);
|
||||
void UpdateBannerDialog (Dialog *);
|
||||
int16_t BannerFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt);
|
||||
void GetHighScoreBanner (void);
|
||||
Boolean OpenHighScoresFile (const VFileSpec &spec, GpIOStream *&outStream);
|
||||
Boolean OpenHighScoresFile (const VFileSpec &spec, GpIOStream *&outStream, Boolean write);
|
||||
|
||||
|
||||
Str31 highBanner;
|
||||
@@ -108,13 +112,12 @@ void DoHighScores (void)
|
||||
void DrawHighScores (DrawSurface *surface)
|
||||
{
|
||||
DrawSurface *tempMap, *tempMask;
|
||||
DrawSurface *wasCPort;
|
||||
PLError_t theErr;
|
||||
houseType *thisHousePtr;
|
||||
Rect tempRect, tempRect2;
|
||||
Str255 tempStr;
|
||||
short scoreLeft, bannerWidth, i, dropIt;
|
||||
char wasState;
|
||||
|
||||
PortabilityLayer::ResolveCachingColor blackColor = PortabilityLayer::RGBAColor::Create(0, 0, 0, 255);
|
||||
PortabilityLayer::ResolveCachingColor yellowColor = PortabilityLayer::RGBAColor::Create(255, 255, 0, 255);
|
||||
PortabilityLayer::ResolveCachingColor cyanColor = PortabilityLayer::RGBAColor::Create(0, 255, 255, 255);
|
||||
@@ -277,7 +280,6 @@ void SortHighScores (void)
|
||||
houseType *thisHousePtr;
|
||||
long greatest;
|
||||
short i, h, which;
|
||||
char wasState;
|
||||
|
||||
thisHousePtr = *thisHouse;
|
||||
|
||||
@@ -313,7 +315,6 @@ void ZeroHighScores (void)
|
||||
{
|
||||
houseType *thisHousePtr;
|
||||
short i;
|
||||
char wasState;
|
||||
|
||||
thisHousePtr = *thisHouse;
|
||||
|
||||
@@ -356,7 +357,6 @@ Boolean TestHighScore (void)
|
||||
{
|
||||
houseType *thisHousePtr;
|
||||
short placing, i;
|
||||
char wasState;
|
||||
|
||||
if (resumedSavedGame)
|
||||
return (false);
|
||||
@@ -384,7 +384,7 @@ Boolean TestHighScore (void)
|
||||
|
||||
if (placing != -1)
|
||||
{
|
||||
int64_t scoreTimestamp = PortabilityLayer::HostSystemServices::GetInstance()->GetTime();
|
||||
int64_t scoreTimestamp = PLDrivers::GetSystemServices()->GetTime();
|
||||
if (scoreTimestamp < 0)
|
||||
scoreTimestamp = 0;
|
||||
else if (scoreTimestamp > 0xffffffff)
|
||||
@@ -503,6 +503,18 @@ int16_t NameFilter (void *context, Dialog *dial, const TimeTaggedVOSEvent *evt)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void MoveDialogToTopOfScreen(Dialog *dial)
|
||||
{
|
||||
Window *window = dial->GetWindow();
|
||||
PortabilityLayer::Vec2i pos = window->GetPosition();
|
||||
|
||||
unsigned int height = PortabilityLayer::WindowManager::GetInstance()->GetDisplayResolution().m_y;
|
||||
|
||||
pos.m_y = (height - window->GetDrawSurface()->m_port.GetRect().Height()) / 8;
|
||||
|
||||
dial->GetWindow()->SetPosition(pos);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- GetHighScoreName
|
||||
// Brings up a dialog to get player's name (due to a high score).
|
||||
|
||||
@@ -530,6 +542,9 @@ void GetHighScoreName (short place)
|
||||
|
||||
UpdateNameDialog(theDial);
|
||||
|
||||
if (PLDrivers::GetSystemServices()->IsTextInputObstructive())
|
||||
MoveDialogToTopOfScreen(theDial);
|
||||
|
||||
Window *exclStack = theDial->GetWindow();
|
||||
wm->SwapExclusiveWindow(exclStack); // Push exclusive window for zooms
|
||||
|
||||
@@ -640,6 +655,9 @@ void GetHighScoreBanner (void)
|
||||
|
||||
UpdateBannerDialog(theDial);
|
||||
|
||||
if (PLDrivers::GetSystemServices()->IsTextInputObstructive())
|
||||
MoveDialogToTopOfScreen(theDial);
|
||||
|
||||
Window *exclStack = theDial->GetWindow();
|
||||
wm->SwapExclusiveWindow(exclStack); // Push exclusive window for zooms
|
||||
|
||||
@@ -668,23 +686,18 @@ void GetHighScoreBanner (void)
|
||||
|
||||
//-------------------------------------------------------------- OpenHighScoresFile
|
||||
|
||||
Boolean OpenHighScoresFile (const VFileSpec &scoreSpec, GpIOStream *&scoresStream)
|
||||
Boolean OpenHighScoresFile (const VFileSpec &spec, GpIOStream *&outStream, Boolean write)
|
||||
{
|
||||
PLError_t theErr;
|
||||
|
||||
PortabilityLayer::FileManager *fm = PortabilityLayer::FileManager::GetInstance();
|
||||
|
||||
theErr = fm->OpenFileData(scoreSpec.m_dir, scoreSpec.m_name, PortabilityLayer::EFilePermission_Any, scoresStream);
|
||||
|
||||
PLError_t theErr = fm->OpenNonCompositeFile(spec.m_dir, spec.m_name, ".dat", write ? PortabilityLayer::EFilePermission_Write : PortabilityLayer::EFilePermission_Read, write ? GpFileCreationDispositions::kCreateOrOverwrite : GpFileCreationDispositions::kOpenExisting, outStream);
|
||||
if (theErr == PLErrors::kFileNotFound)
|
||||
{
|
||||
theErr = fm->CreateFileAtCurrentTime(scoreSpec.m_dir, scoreSpec.m_name, 'ozm5', 'gliS');
|
||||
if (!CheckFileError(theErr, PSTR("New High Scores File")))
|
||||
return (false);
|
||||
theErr = fm->OpenFileData(scoreSpec.m_dir, scoreSpec.m_name, PortabilityLayer::EFilePermission_Any, scoresStream);
|
||||
if (!CheckFileError(theErr, PSTR("High Score")))
|
||||
return (false);
|
||||
outStream = nil;
|
||||
return (true);
|
||||
}
|
||||
else if (!CheckFileError(theErr, PSTR("High Score")))
|
||||
|
||||
if (!CheckFileError(theErr, PSTR("High Score")))
|
||||
return (false);
|
||||
|
||||
return (true);
|
||||
@@ -703,18 +716,11 @@ Boolean WriteScoresToDisk (void)
|
||||
GpIOStream *scoresStream = nil;
|
||||
|
||||
scoreSpec = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kHighScores, thisHouseName);
|
||||
if (!OpenHighScoresFile(scoreSpec, scoresStream))
|
||||
if (!OpenHighScoresFile(scoreSpec, scoresStream, true))
|
||||
{
|
||||
SysBeep(1);
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (!scoresStream->SeekStart(0))
|
||||
{
|
||||
CheckFileError(PLErrors::kIOError, PSTR("High Scores File"));
|
||||
scoresStream->Close();
|
||||
return(false);
|
||||
}
|
||||
|
||||
byteCount = sizeof(scoresType);
|
||||
theScores = &((*thisHouse)->highScores);
|
||||
@@ -726,13 +732,6 @@ Boolean WriteScoresToDisk (void)
|
||||
return(false);
|
||||
}
|
||||
|
||||
if (!scoresStream->Truncate(byteCount))
|
||||
{
|
||||
CheckFileError(PLErrors::kIOError, PSTR("High Scores File"));
|
||||
scoresStream->Close();
|
||||
return(false);
|
||||
}
|
||||
|
||||
scoresStream->Close();
|
||||
|
||||
return (true);
|
||||
@@ -759,15 +758,22 @@ Boolean ReadScoresFromDisk (void)
|
||||
short volRefNum;
|
||||
char wasState;
|
||||
GpIOStream *scoresStream = nil;
|
||||
|
||||
|
||||
VFileSpec scoreSpec = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kHighScores, thisHouseName);
|
||||
if (!OpenHighScoresFile(scoreSpec, scoresStream))
|
||||
if (!OpenHighScoresFile(scoreSpec, scoresStream, false))
|
||||
{
|
||||
SysBeep(1);
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (!scoresStream)
|
||||
return (false);
|
||||
|
||||
byteCount = scoresStream->Size();
|
||||
if (byteCount != sizeof(scoresType))
|
||||
{
|
||||
scoresStream->Close();
|
||||
return (false);
|
||||
}
|
||||
|
||||
theScores = &((*thisHouse)->highScores);
|
||||
|
||||
|
@@ -12,10 +12,13 @@
|
||||
#include "PLSysCalls.h"
|
||||
#include "DialogUtils.h"
|
||||
#include "Externs.h"
|
||||
#include "FileBrowserUI.h"
|
||||
#include "FileManager.h"
|
||||
#include "HostFileSystem.h"
|
||||
#include "FontFamily.h"
|
||||
#include "House.h"
|
||||
#include "MacFileInfo.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "PLStringCompare.h"
|
||||
#include "PLTimeTaggedVOSEvent.h"
|
||||
#include "RectUtils.h"
|
||||
#include "ResourceManager.h"
|
||||
@@ -30,6 +33,7 @@ void UpdateGoToDialog (Dialog *);
|
||||
int16_t GoToFilter (void *context, Dialog *dial, const TimeTaggedVOSEvent *evt);
|
||||
|
||||
extern PortabilityLayer::IResourceArchive *houseResFork;
|
||||
extern PortabilityLayer::CompositeFile *houseCFile;
|
||||
|
||||
|
||||
houseHand thisHouse;
|
||||
@@ -48,6 +52,43 @@ extern Boolean houseOpen, noRoomAtAll;
|
||||
extern Boolean twoPlayerGame, wardBitSet, phoneBitSet;
|
||||
|
||||
|
||||
static void FBUI_DrawLabels(DrawSurface *surface, const Point &basePoint)
|
||||
{
|
||||
}
|
||||
|
||||
static void FBUI_DrawFileDetails(DrawSurface *surface, const Point &basePoint, const Rect &constraintRect, void *fileDetails)
|
||||
{
|
||||
}
|
||||
|
||||
static void *FBUI_LoadFileDetails(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void FBUI_FreeFileDetails(void *fileDetails)
|
||||
{
|
||||
}
|
||||
|
||||
static bool FBUI_FilterFile(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()
|
||||
{
|
||||
PortabilityLayer::FileBrowserUI_DetailsCallbackAPI api;
|
||||
|
||||
api.m_drawLabelsCallback = FBUI_DrawLabels;
|
||||
api.m_drawFileDetailsCallback = FBUI_DrawFileDetails;
|
||||
api.m_loadFileDetailsCallback = FBUI_LoadFileDetails;
|
||||
api.m_freeFileDetailsCallback = FBUI_FreeFileDetails;
|
||||
api.m_filterFileCallback = FBUI_FilterFile;
|
||||
|
||||
return api;
|
||||
}
|
||||
|
||||
//============================================================== Functions
|
||||
//-------------------------------------------------------------- CreateNewHouse
|
||||
// Called to create a new house file.
|
||||
@@ -68,7 +109,7 @@ Boolean CreateNewHouse (void)
|
||||
char savePath[sizeof(theSpec.m_name) + 1];
|
||||
size_t savePathLength = 0;
|
||||
|
||||
if (!fm->PromptSaveFile(theSpec.m_dir, savePath, savePathLength, sizeof(theSpec.m_name), PSTR("My House"), PSTR("Create House")))
|
||||
if (!fm->PromptSaveFile(theSpec.m_dir, ".gpf", savePath, savePathLength, sizeof(theSpec.m_name), PSTR("My House"), PSTR("Create House"), true, GetHouseDetailsAPI()))
|
||||
return false;
|
||||
|
||||
assert(savePathLength < sizeof(theSpec.m_name) - 1);
|
||||
@@ -76,9 +117,16 @@ Boolean CreateNewHouse (void)
|
||||
theSpec.m_name[0] = static_cast<uint8_t>(savePathLength);
|
||||
memcpy(theSpec.m_name + 1, savePath, savePathLength);
|
||||
|
||||
if (fm->FileExists(theSpec.m_dir, theSpec.m_name))
|
||||
// Don't try to overwrite the current house
|
||||
if (houseCFile && theSpec.m_dir == houseCFile->GetDirectory() && !StrCmp::CompareCaseInsensitive(theSpec.m_name, houseCFile->GetFileName()))
|
||||
{
|
||||
if (!fm->DeleteFile(theSpec.m_dir, theSpec.m_name))
|
||||
CheckFileError(PLErrors::kFileIsBusy, theSpec.m_name);
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (fm->CompositeFileExists(theSpec.m_dir, theSpec.m_name))
|
||||
{
|
||||
if (!fm->DeleteCompositeFile(theSpec.m_dir, theSpec.m_name))
|
||||
{
|
||||
CheckFileError(PLErrors::kAccessDenied, theSpec.m_name);
|
||||
return (false);
|
||||
@@ -103,7 +151,7 @@ Boolean CreateNewHouse (void)
|
||||
AddExtraHouse(theSpec);
|
||||
BuildHouseList();
|
||||
InitCursor();
|
||||
if (!OpenHouse())
|
||||
if (!OpenHouse(false))
|
||||
return (false);
|
||||
|
||||
WriteOutPrefs();
|
||||
@@ -125,7 +173,7 @@ Boolean InitializeEmptyHouse (void)
|
||||
if (thisHouse != nil)
|
||||
thisHouse.Dispose();
|
||||
|
||||
thisHouse = NewHandle(sizeof(houseType)).StaticCast<houseType>();
|
||||
thisHouse = NewHandle(sizeof(houseType) - sizeof(roomType)).StaticCast<houseType>();
|
||||
|
||||
if (thisHouse == nil)
|
||||
{
|
||||
|
@@ -5,43 +5,41 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//============================================================================
|
||||
|
||||
#include "PLDialogs.h"
|
||||
#include "PLMovies.h"
|
||||
#include "PLResources.h"
|
||||
#include "PLStringCompare.h"
|
||||
#include "PLPasStr.h"
|
||||
#include "BitmapImage.h"
|
||||
#include "DialogManager.h"
|
||||
#include "Externs.h"
|
||||
#include "Environ.h"
|
||||
#include "FileManager.h"
|
||||
#include "HostFileSystem.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "House.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "House.h"
|
||||
#include "IGpSystemServices.h"
|
||||
#include "ObjectEdit.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
#include "PLDialogs.h"
|
||||
#include "PLDrivers.h"
|
||||
#include "PLMovies.h"
|
||||
#include "PLResources.h"
|
||||
#include "PLStringCompare.h"
|
||||
#include "PLPasStr.h"
|
||||
|
||||
#define kSaveChangesAlert 1002
|
||||
#define kSaveChanges 1
|
||||
#define kDiscardChanges 2
|
||||
|
||||
|
||||
void LoopMovie (void);
|
||||
void OpenHouseMovie (void);
|
||||
void CloseHouseMovie (void);
|
||||
Boolean IsFileReadOnly (const VFileSpec &);
|
||||
|
||||
|
||||
AnimationPlayer theMovie;
|
||||
Rect movieRect;
|
||||
PortabilityLayer::IResourceArchive *houseResFork;
|
||||
short wasHouseVersion;
|
||||
GpIOStream *houseStream;
|
||||
Boolean houseOpen, fileDirty;
|
||||
Boolean changeLockStateOfHouse, saveHouseLocked, houseIsReadOnly;
|
||||
Boolean hasMovie, tvInRoom;
|
||||
PortabilityLayer::CompositeFile *houseCFile;
|
||||
|
||||
|
||||
extern VFileSpec *theHousesSpecs;
|
||||
@@ -59,9 +57,7 @@ void OpenHouseMovie (void)
|
||||
{
|
||||
#ifdef COMPILEQT
|
||||
VFileSpec theSpec;
|
||||
VFileInfo finderInfo;
|
||||
Handle spaceSaver;
|
||||
PLError_t theErr;
|
||||
short movieRefNum;
|
||||
Boolean dataRefWasChanged;
|
||||
|
||||
@@ -69,19 +65,20 @@ void OpenHouseMovie (void)
|
||||
{
|
||||
theSpec = theHousesSpecs[thisHouseIndex];
|
||||
PasStringConcat(theSpec.m_name, PSTR(".mov"));
|
||||
|
||||
theErr = FSpGetFInfo(theSpec, finderInfo);
|
||||
if (theErr != PLErrors::kNone)
|
||||
return;
|
||||
|
||||
AnimationPackage *anim = AnimationPackage::Create();
|
||||
if (!anim)
|
||||
return;
|
||||
|
||||
if (!anim->Load(theSpec.m_dir, theSpec.m_name))
|
||||
PLError_t theErr = anim->Load(theSpec.m_dir, theSpec.m_name);
|
||||
|
||||
if (theErr != PLErrors::kNone)
|
||||
{
|
||||
anim->Destroy();
|
||||
YellowAlert(kYellowQTMovieNotLoaded, theErr);
|
||||
|
||||
if (theErr != PLErrors::kFileNotFound)
|
||||
YellowAlert(kYellowQTMovieNotLoaded, theErr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,7 +113,7 @@ void CloseHouseMovie (void)
|
||||
//-------------------------------------------------------------- OpenHouse
|
||||
// Opens a house (whatever current selection is). Returns true if all went well.
|
||||
|
||||
Boolean OpenHouse (void)
|
||||
Boolean OpenHouse (Boolean read)
|
||||
{
|
||||
PLError_t theErr;
|
||||
|
||||
@@ -132,12 +129,21 @@ Boolean OpenHouse (void)
|
||||
if (!StrCmp::EqualCaseInsensitive(theHousesSpecs[thisHouseIndex].name, "\pDemo House"))
|
||||
return (false);
|
||||
#endif
|
||||
|
||||
houseIsReadOnly = IsFileReadOnly(theHousesSpecs[thisHouseIndex]);
|
||||
|
||||
theErr = PortabilityLayer::FileManager::GetInstance()->OpenFileData(theHousesSpecs[thisHouseIndex].m_dir, theHousesSpecs[thisHouseIndex].m_name, PortabilityLayer::EFilePermission_Any, houseStream);
|
||||
if (!CheckFileError(theErr, thisHouseName))
|
||||
|
||||
houseCFile = PortabilityLayer::FileManager::GetInstance()->OpenCompositeFile(theHousesSpecs[thisHouseIndex].m_dir, theHousesSpecs[thisHouseIndex].m_name);
|
||||
if (!houseCFile)
|
||||
return (false);
|
||||
|
||||
houseIsReadOnly = houseCFile->IsDataReadOnly();
|
||||
|
||||
GpIOStream *houseStream = nil;
|
||||
theErr = houseCFile->OpenData(PortabilityLayer::EFilePermission_Any, GpFileCreationDispositions::kCreateOrOpen, houseStream);
|
||||
if (!CheckFileError(theErr, thisHouseName))
|
||||
{
|
||||
houseCFile->Close();
|
||||
houseCFile = nil;
|
||||
return (false);
|
||||
}
|
||||
|
||||
houseOpen = true;
|
||||
OpenHouseResFork();
|
||||
@@ -148,6 +154,16 @@ Boolean OpenHouse (void)
|
||||
tvInRoom = false;
|
||||
tvWithMovieNumber = -1;
|
||||
OpenHouseMovie();
|
||||
|
||||
if (read)
|
||||
{
|
||||
Boolean readOK = ReadHouse(houseStream);
|
||||
houseStream->Close();
|
||||
|
||||
return readOK;
|
||||
}
|
||||
|
||||
houseStream->Close();
|
||||
|
||||
return (true);
|
||||
}
|
||||
@@ -173,9 +189,7 @@ Boolean OpenSpecificHouse (const VFileSpec &specs)
|
||||
{
|
||||
thisHouseIndex = i;
|
||||
PasStringCopy(theHousesSpecs[thisHouseIndex].m_name, thisHouseName);
|
||||
if (OpenHouse())
|
||||
itOpened = ReadHouse();
|
||||
else
|
||||
if (!OpenHouse(true))
|
||||
itOpened = false;
|
||||
break;
|
||||
}
|
||||
@@ -527,7 +541,7 @@ bool ByteSwapHouse(housePtr house, size_t sizeInBytes, bool isSwappedAfter)
|
||||
return true;
|
||||
}
|
||||
|
||||
Boolean ReadHouse (void)
|
||||
Boolean ReadHouse (GpIOStream *houseStream)
|
||||
{
|
||||
long byteCount;
|
||||
PLError_t theErr;
|
||||
@@ -653,19 +667,27 @@ Boolean WriteHouse (Boolean checkIt)
|
||||
UInt32 timeStamp;
|
||||
long byteCount;
|
||||
PLError_t theErr;
|
||||
|
||||
|
||||
if ((housesFound < 1) || (thisHouseIndex == -1))
|
||||
return(false);
|
||||
|
||||
if (!houseOpen)
|
||||
{
|
||||
YellowAlert(kYellowUnaccounted, 4);
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (!houseStream->SeekStart(0))
|
||||
if (!houseCFile)
|
||||
{
|
||||
CheckFileError(PLErrors::kIOError, thisHouseName);
|
||||
return(false);
|
||||
YellowAlert(kYellowUnaccounted, 4);
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
||||
GpIOStream *houseStream = nil;
|
||||
theErr = houseCFile->OpenData(PortabilityLayer::EFilePermission_Write, GpFileCreationDispositions::kCreateOrOpen, houseStream);
|
||||
if (theErr != PLErrors::kNone)
|
||||
return (false);
|
||||
|
||||
CopyThisRoomToRoom();
|
||||
|
||||
if (checkIt)
|
||||
@@ -675,7 +697,7 @@ Boolean WriteHouse (Boolean checkIt)
|
||||
|
||||
if (fileDirty)
|
||||
{
|
||||
int64_t currentTime = PortabilityLayer::HostSystemServices::GetInstance()->GetTime();
|
||||
int64_t currentTime = PLDrivers::GetSystemServices()->GetTime();
|
||||
if (currentTime > 0x7fffffff)
|
||||
currentTime = 0x7fffffff;
|
||||
|
||||
@@ -699,6 +721,7 @@ Boolean WriteHouse (Boolean checkIt)
|
||||
{
|
||||
CheckFileError(PLErrors::kIOError, thisHouseName);
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount), false);
|
||||
houseStream->Close();
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -706,16 +729,13 @@ Boolean WriteHouse (Boolean checkIt)
|
||||
{
|
||||
CheckFileError(PLErrors::kIOError, thisHouseName);
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount), false);
|
||||
houseStream->Close();
|
||||
return(false);
|
||||
}
|
||||
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount), false);
|
||||
|
||||
if (!houseStream->Truncate(byteCount))
|
||||
{
|
||||
CheckFileError(PLErrors::kIOError, thisHouseName);
|
||||
return(false);
|
||||
}
|
||||
houseStream->Close();
|
||||
|
||||
if (changeLockStateOfHouse)
|
||||
{
|
||||
@@ -749,7 +769,11 @@ Boolean CloseHouse (void)
|
||||
CloseHouseResFork();
|
||||
CloseHouseMovie();
|
||||
|
||||
houseStream->Close();
|
||||
if (houseCFile)
|
||||
{
|
||||
houseCFile->Close();
|
||||
houseCFile = nil;
|
||||
}
|
||||
|
||||
houseOpen = false;
|
||||
|
||||
@@ -764,7 +788,7 @@ void OpenHouseResFork (void)
|
||||
PortabilityLayer::ResourceManager *rm = PortabilityLayer::ResourceManager::GetInstance();
|
||||
if (houseResFork == nullptr)
|
||||
{
|
||||
houseResFork = rm->LoadResFile(theHousesSpecs[thisHouseIndex].m_dir, theHousesSpecs[thisHouseIndex].m_name);
|
||||
houseResFork = rm->LoadResFile(houseCFile);
|
||||
if (!houseResFork)
|
||||
YellowAlert(kYellowFailedResOpen, PLErrors::kResourceError);
|
||||
}
|
||||
@@ -817,8 +841,7 @@ Boolean QuerySaveChanges (void)
|
||||
if (!quitting)
|
||||
{
|
||||
whoCares = CloseHouse();
|
||||
if (OpenHouse())
|
||||
whoCares = ReadHouse();
|
||||
OpenHouse(true);
|
||||
}
|
||||
UpdateMenus(false);
|
||||
return (true);
|
||||
@@ -850,13 +873,6 @@ void YellowAlert (short whichAlert, short identifier)
|
||||
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kYellowAlert, &substitutions);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- IsFileReadOnly
|
||||
|
||||
Boolean IsFileReadOnly (const VFileSpec &spec)
|
||||
{
|
||||
return PortabilityLayer::FileManager::GetInstance()->FileLocked(spec.m_dir, spec.m_name);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- LoadHousePicture
|
||||
|
||||
THandle<void> LoadHouseResource(const PortabilityLayer::ResTypeID &resTypeID, int16_t resID)
|
||||
|
@@ -6,16 +6,17 @@
|
||||
//============================================================================
|
||||
|
||||
|
||||
#include "PLNumberFormatting.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLPasStr.h"
|
||||
#include "Externs.h"
|
||||
#include "DialogManager.h"
|
||||
#include "DialogUtils.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
|
||||
#include "PLArrayView.h"
|
||||
#include "PLDrivers.h"
|
||||
#include "PLEditboxWidget.h"
|
||||
#include "PLNumberFormatting.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLPasStr.h"
|
||||
#include "PLTimeTaggedVOSEvent.h"
|
||||
|
||||
|
||||
@@ -179,7 +180,7 @@ int16_t HouseFilter(void *context, Dialog *dial, const TimeTaggedVOSEvent *evt)
|
||||
{
|
||||
if (houseCursorIs != kBeamCursor)
|
||||
{
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kIBeam);
|
||||
PLDrivers::GetDisplayDriver()->SetStandardCursor(EGpStandardCursors::kIBeam);
|
||||
houseCursorIs = kBeamCursor;
|
||||
}
|
||||
}
|
||||
|
@@ -602,8 +602,6 @@ Boolean KeepObjectLegal (void)
|
||||
#ifndef COMPILEDEMO
|
||||
void WrapBannerAndTrailer (void)
|
||||
{
|
||||
char wasState;
|
||||
|
||||
WrapText((*thisHouse)->banner, 40);
|
||||
WrapText((*thisHouse)->trailer, 64);
|
||||
}
|
||||
@@ -615,11 +613,10 @@ void WrapBannerAndTrailer (void)
|
||||
void ValidateNumberOfRooms (void)
|
||||
{
|
||||
long countedRooms, reportsRooms;
|
||||
char wasState;
|
||||
|
||||
reportsRooms = (long)(*thisHouse)->nRooms;
|
||||
countedRooms = (GetHandleSize(thisHouse.StaticCast<void>()) -
|
||||
sizeof(houseType)) / sizeof(roomType);
|
||||
sizeof(houseType)) / sizeof(roomType) + 1;
|
||||
if (reportsRooms != countedRooms)
|
||||
{
|
||||
(*thisHouse)->nRooms = (short)countedRooms;
|
||||
@@ -637,7 +634,6 @@ void CheckDuplicateFloorSuite (void)
|
||||
#define kRoomsTimesSuites 8192
|
||||
short i, numRooms, bitPlace;
|
||||
char *pidgeonHoles;
|
||||
char wasState;
|
||||
|
||||
pidgeonHoles = (char *)NewPtrClear(sizeof(char) * kRoomsTimesSuites);
|
||||
if (pidgeonHoles == nil)
|
||||
@@ -672,7 +668,6 @@ void CheckDuplicateFloorSuite (void)
|
||||
void CompressHouse (void)
|
||||
{
|
||||
short wasFirstRoom, roomNumber, probe;
|
||||
char wasState;
|
||||
Boolean compressing, probing;
|
||||
|
||||
wasFirstRoom = (*thisHouse)->firstRoom;
|
||||
@@ -720,7 +715,6 @@ void LopOffExtraRooms (void)
|
||||
{
|
||||
long newSize;
|
||||
short r, count;
|
||||
char wasState;
|
||||
Str255 message;
|
||||
|
||||
count = 0;
|
||||
@@ -756,7 +750,6 @@ void LopOffExtraRooms (void)
|
||||
void ValidateRoomNumbers (void)
|
||||
{
|
||||
short i, numRooms;
|
||||
char wasState;
|
||||
Str255 message;
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
@@ -796,7 +789,6 @@ void ValidateRoomNumbers (void)
|
||||
void CountUntitledRooms (void)
|
||||
{
|
||||
short i, numRooms;
|
||||
char wasState;
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
@@ -814,7 +806,6 @@ void CountUntitledRooms (void)
|
||||
void CheckRoomNameLength (void)
|
||||
{
|
||||
short i, numRooms;
|
||||
char wasState;
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
@@ -837,7 +828,6 @@ void CheckRoomNameLength (void)
|
||||
void MakeSureNumObjectsJives (void)
|
||||
{
|
||||
short i, h, numRooms, count;
|
||||
char wasState;
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
@@ -866,7 +856,6 @@ void MakeSureNumObjectsJives (void)
|
||||
void KeepAllObjectsLegal (void)
|
||||
{
|
||||
short i, h, numRooms;
|
||||
char wasState;
|
||||
Str255 message;
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
@@ -901,7 +890,6 @@ void KeepAllObjectsLegal (void)
|
||||
void CheckForStaircasePairs (void)
|
||||
{
|
||||
short i, h, g, numRooms, neighbor;
|
||||
char wasState;
|
||||
Boolean hasStairs;
|
||||
Str255 message;
|
||||
|
||||
|
@@ -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 kNoSaveGameButton 2
|
||||
#define kCancelSaveGameButton 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 == kCancelSaveGameButton);
|
||||
}
|
||||
|
||||
|
@@ -8,17 +8,17 @@
|
||||
|
||||
#include "Externs.h"
|
||||
#include "Environ.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "GpApplicationName.h"
|
||||
#include "Map.h"
|
||||
#include "MenuManager.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLPasStr.h"
|
||||
#include "RectUtils.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "Tools.h"
|
||||
|
||||
#include "PLDrivers.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLPasStr.h"
|
||||
|
||||
#define kHandCursorID 128
|
||||
#define kVertCursorID 129
|
||||
@@ -55,7 +55,6 @@ void InitializeMenus (void)
|
||||
RedAlert(kErrFailedResourceLoad);
|
||||
//AppendResMenu(appleMenu, 'DRVR'); // GP: We don't support this
|
||||
AppendMenuItem(appleMenu, 0, 0, 0, 0, true, false, PSTR("About " GP_APPLICATION_NAME "\xc9"));
|
||||
AppendMenuItem(appleMenu, 0, 0, 0, 0, true, false, PSTR("Export Source Code\xc9"));
|
||||
InsertMenu(appleMenu, 0);
|
||||
|
||||
gameMenu = GetMenu(kGameMenuID);
|
||||
@@ -102,7 +101,7 @@ IGpCursor *LoadBWCursor(int resID)
|
||||
|
||||
const BWCursor *cursorData = static_cast<const BWCursor *>(*resHdl);
|
||||
|
||||
IGpCursor *cursor = PortabilityLayer::HostDisplayDriver::GetInstance()->CreateBWCursor(16, 16, cursorData->m_pixels, cursorData->m_mask, cursorData->m_hotSpotX, cursorData->m_hotSpotY);
|
||||
IGpCursor *cursor = PLDrivers::GetDisplayDriver()->CreateBWCursor(16, 16, cursorData->m_pixels, cursorData->m_mask, cursorData->m_hotSpotX, cursorData->m_hotSpotY);
|
||||
resHdl.Dispose();
|
||||
|
||||
return cursor;
|
||||
@@ -176,8 +175,6 @@ void RecomputeInterfaceRects (void)
|
||||
|
||||
void VariableInit (void)
|
||||
{
|
||||
short i;
|
||||
|
||||
menusUp = false;
|
||||
quitting = false;
|
||||
houseOpen = false;
|
||||
|
680
GpApp/Main.cpp
680
GpApp/Main.cpp
@@ -8,34 +8,42 @@
|
||||
|
||||
#include "WindowDef.h"
|
||||
#include "BitmapImage.h"
|
||||
#include "PLApplication.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "PLSysCalls.h"
|
||||
#include "FileManager.h"
|
||||
#include "Externs.h"
|
||||
#include "Environ.h"
|
||||
#include "FontFamily.h"
|
||||
#include "FontManager.h"
|
||||
#include "GpApplicationName.h"
|
||||
#include "GpRenderedFontMetrics.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "HostThreadEvent.h"
|
||||
#include "IGpMutex.h"
|
||||
#include "IGpThreadEvent.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "IGpSystemServices.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "House.h"
|
||||
#include "MainMenuUI.h"
|
||||
#include "MemoryManager.h"
|
||||
#include "MenuManager.h"
|
||||
#include "QDPixMap.h"
|
||||
#include "QDStandardPalette.h"
|
||||
#include "RenderedFont.h"
|
||||
#include "ResolveCachingColor.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "PLTimeTaggedVOSEvent.h"
|
||||
#include "Utilities.h"
|
||||
#include "Vec2i.h"
|
||||
#include "WindowManager.h"
|
||||
#include "WorkerThread.h"
|
||||
|
||||
#include "PLApplication.h"
|
||||
#include "PLDrivers.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "PLSysCalls.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
|
||||
int loadScreenWindowPhase;
|
||||
int loadScreenRingStep;
|
||||
WindowPtr loadScreenWindow;
|
||||
Rect loadScreenProgressBarRect;
|
||||
@@ -43,11 +51,12 @@ int loadScreenProgress;
|
||||
DrawSurface *loadScreenRingSurface;
|
||||
|
||||
|
||||
#define kPrefsVersion 0x0038
|
||||
#define kPrefsVersion 0x0039
|
||||
|
||||
|
||||
void ReadInPrefs (void);
|
||||
void WriteOutPrefs (void);
|
||||
void HandleSplashResolutionChange (void);
|
||||
int main(int argc, const char **argv);
|
||||
|
||||
|
||||
@@ -62,7 +71,7 @@ extern Str15 leftName, rightName, batteryName, bandName;
|
||||
extern Str15 highName;
|
||||
//extern long encryptedNumber;
|
||||
extern short maxFiles, numNeighbors, willMaxFiles;
|
||||
extern GpIOStream *houseStream;
|
||||
extern PortabilityLayer::CompositeFile *houseCFile;
|
||||
extern short isEditH, isEditV, isMapH, isMapV;
|
||||
extern short isToolsH, isToolsV, isCoordH, isCoordV;
|
||||
extern short isLinkH, isLinkV, toolMode, mapLeftRoom, mapTopRoom;
|
||||
@@ -71,7 +80,7 @@ extern Boolean isMusicOn, isSoundOn, isPlayMusicIdle, isHouseChecks;
|
||||
extern Boolean houseOpen, isDoColorFade, isEscPauseKey;
|
||||
extern Boolean autoRoomEdit, doAutoDemo, doBackground;
|
||||
extern Boolean isMapOpen, isToolsOpen, isCoordOpen;
|
||||
extern Boolean doPrettyMap, doBitchDialogs;
|
||||
extern Boolean doPrettyMap, doComplainDialogs;
|
||||
//extern Boolean didValidation;
|
||||
|
||||
THandle<void> globalModulePrefs;
|
||||
@@ -159,7 +168,7 @@ void ReadInPrefs (void)
|
||||
isUseICCProfile = thePrefs.wasUseICCProfile;
|
||||
doBackground = thePrefs.wasDoBackground;
|
||||
doPrettyMap = thePrefs.wasPrettyMap;
|
||||
doBitchDialogs = thePrefs.wasBitchDialogs;
|
||||
doComplainDialogs = thePrefs.wasComplainDialogs;
|
||||
|
||||
if (modulePrefs)
|
||||
ApplyModulePrefs(&modulePrefs);
|
||||
@@ -217,12 +226,12 @@ void ReadInPrefs (void)
|
||||
isEditV = 41;
|
||||
isMapH = 3;
|
||||
// isMapV = qd.screenBits.bounds.bottom - 100;
|
||||
isMapV = 100;
|
||||
isMapV = 385;
|
||||
mapRoomsWide = 15;
|
||||
mapRoomsHigh = 4;
|
||||
// isToolsH = qd.screenBits.bounds.right - 120;
|
||||
isToolsH = 100;
|
||||
isToolsV = 35;
|
||||
isToolsH = 525;
|
||||
isToolsV = 41;
|
||||
isLinkH = 50;
|
||||
isLinkV = 80;
|
||||
// isCoordH = qd.screenBits.bounds.right - 55;
|
||||
@@ -244,10 +253,10 @@ void ReadInPrefs (void)
|
||||
isUseICCProfile = true;
|
||||
doBackground = false;
|
||||
doPrettyMap = false;
|
||||
doBitchDialogs = true;
|
||||
doComplainDialogs = true;
|
||||
|
||||
IGpDisplayDriver *displayDriver = PortabilityLayer::HostDisplayDriver::GetInstance();
|
||||
if (!displayDriver->IsFullScreen())
|
||||
IGpDisplayDriver *displayDriver = PLDrivers::GetDisplayDriver();
|
||||
if (PLDrivers::GetSystemServices()->IsFullscreenPreferred() != displayDriver->IsFullScreen())
|
||||
displayDriver->RequestToggleFullScreen(0);
|
||||
|
||||
modulePrefs.Dispose();
|
||||
@@ -345,7 +354,7 @@ void WriteOutPrefs (void)
|
||||
thePrefs.wasUseICCProfile = isUseICCProfile;
|
||||
thePrefs.wasDoBackground = doBackground;
|
||||
thePrefs.wasPrettyMap = doPrettyMap;
|
||||
thePrefs.wasBitchDialogs = doBitchDialogs;
|
||||
thePrefs.wasComplainDialogs = doComplainDialogs;
|
||||
|
||||
THandle<void> modulePrefs;
|
||||
|
||||
@@ -353,8 +362,6 @@ void WriteOutPrefs (void)
|
||||
SysBeep(1);
|
||||
|
||||
modulePrefs.Dispose();
|
||||
|
||||
UnivSetSoundVolume(wasVolume, thisMac.hasSM3);
|
||||
}
|
||||
|
||||
void StepLoadScreenRing()
|
||||
@@ -369,18 +376,173 @@ void StepLoadScreenRing()
|
||||
Rect ringDestRect = Rect::Create(8, 8, 24, 24);
|
||||
Rect ringSrcRect = Rect::Create(0, 0, 16, 16) + Point::Create((loadScreenRingStep / loadScreenStepGranularity) * 16, 0);
|
||||
|
||||
if (loadScreenWindowPhase == 0)
|
||||
{
|
||||
ringDestRect = Rect::Create(0, 0, 64, 64);
|
||||
|
||||
const int progression = (loadScreenRingStep / loadScreenStepGranularity);
|
||||
ringSrcRect = Rect::Create(0, 0, 64, 64) + Point::Create((progression % 6) * 64, (progression / 6) * 64);
|
||||
}
|
||||
|
||||
CopyBits(*loadScreenRingSurface->m_port.GetPixMap(), *loadScreenWindow->GetDrawSurface()->m_port.GetPixMap(), &ringSrcRect, &ringDestRect, srcCopy);
|
||||
loadScreenWindow->GetDrawSurface()->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
||||
}
|
||||
}
|
||||
|
||||
void StepLoadScreen(int steps)
|
||||
|
||||
void CreateLoadScreenWindow(int phase)
|
||||
{
|
||||
FlushResolutionChange();
|
||||
|
||||
if (loadScreenRingSurface)
|
||||
{
|
||||
DisposeGWorld(loadScreenRingSurface);
|
||||
loadScreenRingSurface = nullptr;
|
||||
}
|
||||
|
||||
if (loadScreenWindow)
|
||||
{
|
||||
PortabilityLayer::WindowManager::GetInstance()->DestroyWindow(loadScreenWindow);
|
||||
loadScreenWindow = nullptr;
|
||||
}
|
||||
|
||||
if (phase == 0)
|
||||
{
|
||||
static const int kLoadScreenHeight = 64;
|
||||
static const int kLoadScreenWidth = 64;
|
||||
static const int kLoadRingResource = 1303;
|
||||
|
||||
ForceSyncFrame();
|
||||
PLSysCalls::Sleep(1);
|
||||
|
||||
THandle<BitmapImage> loadRingImageH = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', kLoadRingResource).StaticCast<BitmapImage>();
|
||||
BitmapImage *loadRingImage = *loadRingImageH;
|
||||
|
||||
DrawSurface *loadRingSurface = nullptr;
|
||||
Rect loadRingRect = loadRingImage->GetRect();
|
||||
loadRingRect.right *= 2;
|
||||
loadRingRect.bottom *= 2;
|
||||
CreateOffScreenGWorld(&loadRingSurface, &loadRingRect);
|
||||
loadRingSurface->DrawPicture(loadRingImageH, loadRingRect, false);
|
||||
|
||||
int32_t lsX = (thisMac.fullScreen.Width() - kLoadScreenWidth) / 2;
|
||||
int32_t lsY = (thisMac.fullScreen.Height() - kLoadScreenHeight) / 2;
|
||||
|
||||
|
||||
const Rect loadScreenRect = Rect::Create(lsY, lsX, lsY + kLoadScreenHeight, lsX + kLoadScreenWidth);
|
||||
const Rect loadScreenLocalRect = Rect::Create(0, 0, loadScreenRect.Height(), loadScreenRect.Width());
|
||||
|
||||
PortabilityLayer::WindowDef def = PortabilityLayer::WindowDef::Create(loadScreenRect, PortabilityLayer::WindowStyleFlags::kBorderless, true, 0, 0, PSTR(""));
|
||||
|
||||
loadScreenWindow = PortabilityLayer::WindowManager::GetInstance()->CreateWindow(def);
|
||||
PortabilityLayer::WindowManager::GetInstance()->PutWindowBehind(loadScreenWindow, PL_GetPutInFrontWindowPtr());
|
||||
|
||||
DrawSurface *surface = loadScreenWindow->GetDrawSurface();
|
||||
PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black());
|
||||
|
||||
surface->FillRect(loadScreenLocalRect, blackColor);
|
||||
|
||||
loadScreenProgressBarRect = Rect::Create(0, 0, 0, 0);
|
||||
loadScreenProgress = 0;
|
||||
|
||||
Rect ringDestRect = Rect::Create(0, 0, 64, 64);
|
||||
Rect ringSrcRect = Rect::Create(0, 0, 64, 64);
|
||||
CopyBits(*loadRingSurface->m_port.GetPixMap(), *surface->m_port.GetPixMap(), &ringSrcRect, &ringDestRect, srcCopy);
|
||||
|
||||
loadRingImageH.Dispose();
|
||||
|
||||
loadScreenRingSurface = loadRingSurface;
|
||||
}
|
||||
else if (phase == 1)
|
||||
{
|
||||
static const int kLoadScreenHeight = 32;
|
||||
static const int kLoadRingResource = 1302;
|
||||
|
||||
int kLoadScreenWidth = 296;
|
||||
PLPasStr loadingText = PSTR("Loading...");
|
||||
|
||||
if (!isPrefsLoaded)
|
||||
{
|
||||
loadingText = PSTR("Getting some things ready...");
|
||||
kLoadScreenWidth = 440;
|
||||
}
|
||||
|
||||
ForceSyncFrame();
|
||||
PLSysCalls::Sleep(1);
|
||||
|
||||
THandle<BitmapImage> loadRingImageH = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', kLoadRingResource).StaticCast<BitmapImage>();
|
||||
BitmapImage *loadRingImage = *loadRingImageH;
|
||||
|
||||
DrawSurface *loadRingSurface = nullptr;
|
||||
Rect loadRingRect = loadRingImage->GetRect();
|
||||
CreateOffScreenGWorld(&loadRingSurface, &loadRingRect);
|
||||
loadRingSurface->DrawPicture(loadRingImageH, loadRingRect, false);
|
||||
|
||||
int32_t lsX = (thisMac.fullScreen.Width() - kLoadScreenWidth) / 2;
|
||||
int32_t lsY = (thisMac.fullScreen.Height() - kLoadScreenHeight) / 2;
|
||||
|
||||
|
||||
const Rect loadScreenRect = Rect::Create(lsY, lsX, lsY + kLoadScreenHeight, lsX + kLoadScreenWidth);
|
||||
const Rect loadScreenLocalRect = Rect::Create(0, 0, loadScreenRect.Height(), loadScreenRect.Width());
|
||||
|
||||
PortabilityLayer::WindowDef def = PortabilityLayer::WindowDef::Create(loadScreenRect, PortabilityLayer::WindowStyleFlags::kAlert, true, 0, 0, PSTR(""));
|
||||
|
||||
loadScreenWindow = PortabilityLayer::WindowManager::GetInstance()->CreateWindow(def);
|
||||
PortabilityLayer::WindowManager::GetInstance()->PutWindowBehind(loadScreenWindow, PL_GetPutInFrontWindowPtr());
|
||||
|
||||
DrawSurface *surface = loadScreenWindow->GetDrawSurface();
|
||||
PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black());
|
||||
PortabilityLayer::ResolveCachingColor whiteColor(StdColors::White());
|
||||
|
||||
surface->FillRect(loadScreenLocalRect, whiteColor);
|
||||
|
||||
PortabilityLayer::WindowManager::GetInstance()->FlickerWindowIn(loadScreenWindow, 32);
|
||||
|
||||
PortabilityLayer::RenderedFont *font = GetApplicationFont(18, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
int32_t textY = (kLoadScreenHeight + font->GetMetrics().m_ascent) / 2;
|
||||
surface->DrawString(Point::Create(4 + 16 + 8, textY), loadingText, blackColor, font);
|
||||
|
||||
static const int32_t loadBarPadding = 16;
|
||||
static const int32_t loadBarHeight = 10;
|
||||
int32_t loadBarStartX = static_cast<int32_t>(font->MeasureString(loadingText.UChars(), loadingText.Length())) + 4 + 16 + 8 + loadBarPadding;
|
||||
int32_t loadBarEndX = loadScreenLocalRect.right - loadBarPadding;
|
||||
|
||||
loadScreenProgressBarRect = Rect::Create((loadScreenLocalRect.Height() - loadBarHeight) / 2, loadBarStartX, (loadScreenLocalRect.Height() + loadBarHeight) / 2, loadBarEndX);
|
||||
|
||||
PortabilityLayer::ResolveCachingColor partialFillColor(PortabilityLayer::RGBAColor::Create(255, 255, 204, 255));
|
||||
surface->FrameRect(loadScreenProgressBarRect, blackColor);
|
||||
surface->FillRect(loadScreenProgressBarRect.Inset(1, 1), partialFillColor);
|
||||
|
||||
Rect ringDestRect = Rect::Create(8, 8, 24, 24);
|
||||
Rect ringSrcRect = Rect::Create(0, 0, 16, 16);
|
||||
CopyBits(*loadRingSurface->m_port.GetPixMap(), *surface->m_port.GetPixMap(), &ringSrcRect, &ringDestRect, srcCopy);
|
||||
|
||||
loadRingImageH.Dispose();
|
||||
|
||||
loadScreenRingSurface = loadRingSurface;
|
||||
}
|
||||
}
|
||||
|
||||
void StepLoadScreen(int steps, bool insertDelay)
|
||||
{
|
||||
if (loadScreenWindow)
|
||||
{
|
||||
Rect loadScreenProgressBarFillRect = loadScreenProgressBarRect.Inset(1, 1);
|
||||
static const int kLoadScreenPhaseSwitchBreakpoint = 20;
|
||||
|
||||
int oldProgress = loadScreenProgress;
|
||||
int loadScreenMax = 25;
|
||||
|
||||
if (loadScreenProgress + steps >= kLoadScreenPhaseSwitchBreakpoint && loadScreenWindowPhase == 0)
|
||||
{
|
||||
loadScreenWindowPhase = 1;
|
||||
CreateLoadScreenWindow(loadScreenWindowPhase);
|
||||
|
||||
// Reset old progress since the progress bar was redrawn
|
||||
oldProgress = 0;
|
||||
}
|
||||
|
||||
const Rect loadScreenProgressBarFillRect = loadScreenProgressBarRect.Inset(1, 1);
|
||||
|
||||
int loadScreenMax = 43;
|
||||
loadScreenProgress = loadScreenProgress + steps;
|
||||
if (loadScreenProgress > loadScreenMax)
|
||||
loadScreenProgress = loadScreenMax;
|
||||
@@ -393,7 +555,7 @@ void StepLoadScreen(int steps)
|
||||
loadScreenWindow->GetDrawSurface()->FillRect(Rect::Create(loadScreenProgressBarFillRect.top, loadScreenProgressBarFillRect.left + prevStep, loadScreenProgressBarFillRect.bottom, loadScreenProgressBarFillRect.left + thisStep), fillColor);
|
||||
ForceSyncFrame();
|
||||
|
||||
for (int i = 0; i < steps; i++)
|
||||
if (insertDelay)
|
||||
{
|
||||
StepLoadScreenRing();
|
||||
Delay(1, nullptr);
|
||||
@@ -409,72 +571,12 @@ void InitLoadingWindow()
|
||||
if (!thisMac.isTouchscreen)
|
||||
return;
|
||||
|
||||
static const int kLoadScreenHeight = 32;
|
||||
static const int kLoadRingResource = 1302;
|
||||
if (isPrefsLoaded)
|
||||
loadScreenWindowPhase = 1;
|
||||
else
|
||||
loadScreenWindowPhase = 0;
|
||||
|
||||
int kLoadScreenWidth = 296;
|
||||
PLPasStr loadingText = PSTR("Loading...");
|
||||
|
||||
if (!isPrefsLoaded)
|
||||
{
|
||||
loadingText = PSTR("Getting some things ready...");
|
||||
kLoadScreenWidth = 440;
|
||||
}
|
||||
|
||||
ForceSyncFrame();
|
||||
PLSysCalls::Sleep(1);
|
||||
|
||||
THandle<BitmapImage> loadRingImageH = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', kLoadRingResource).StaticCast<BitmapImage>();
|
||||
BitmapImage *loadRingImage = *loadRingImageH;
|
||||
|
||||
DrawSurface *loadRingSurface = nullptr;
|
||||
Rect loadRingRect = loadRingImage->GetRect();
|
||||
CreateOffScreenGWorld(&loadRingSurface, &loadRingRect);
|
||||
loadRingSurface->DrawPicture(loadRingImageH, loadRingRect);
|
||||
|
||||
int32_t lsX = (thisMac.fullScreen.Width() - kLoadScreenWidth) / 2;
|
||||
int32_t lsY = (thisMac.fullScreen.Height() - kLoadScreenHeight) / 2;
|
||||
|
||||
|
||||
const Rect loadScreenRect = Rect::Create(lsY, lsX, lsY + kLoadScreenHeight, lsX + kLoadScreenWidth);
|
||||
const Rect loadScreenLocalRect = Rect::Create(0, 0, loadScreenRect.Height(), loadScreenRect.Width());
|
||||
|
||||
PortabilityLayer::WindowDef def = PortabilityLayer::WindowDef::Create(loadScreenRect, PortabilityLayer::WindowStyleFlags::kAlert, true, 0, 0, PSTR(""));
|
||||
|
||||
loadScreenWindow = PortabilityLayer::WindowManager::GetInstance()->CreateWindow(def);
|
||||
PortabilityLayer::WindowManager::GetInstance()->PutWindowBehind(loadScreenWindow, PL_GetPutInFrontWindowPtr());
|
||||
|
||||
DrawSurface *surface = loadScreenWindow->GetDrawSurface();
|
||||
PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black());
|
||||
PortabilityLayer::ResolveCachingColor whiteColor(StdColors::White());
|
||||
|
||||
surface->FillRect(loadScreenLocalRect, whiteColor);
|
||||
|
||||
PortabilityLayer::WindowManager::GetInstance()->FlickerWindowIn(loadScreenWindow, 32);
|
||||
|
||||
PortabilityLayer::RenderedFont *font = GetApplicationFont(18, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
int32_t textY = (kLoadScreenHeight + font->GetMetrics().m_ascent) / 2;
|
||||
surface->DrawString(Point::Create(4+16+8, textY), loadingText, blackColor, font);
|
||||
|
||||
static const int32_t loadBarPadding = 16;
|
||||
static const int32_t loadBarHeight = 10;
|
||||
int32_t loadBarStartX = static_cast<int32_t>(font->MeasureString(loadingText.UChars(), loadingText.Length())) + 4 + 16 + 8 + loadBarPadding;
|
||||
int32_t loadBarEndX = loadScreenLocalRect.right - loadBarPadding;
|
||||
|
||||
loadScreenProgressBarRect = Rect::Create((loadScreenLocalRect.Height() - loadBarHeight) / 2, loadBarStartX, (loadScreenLocalRect.Height() + loadBarHeight) / 2, loadBarEndX);
|
||||
loadScreenProgress = 0;
|
||||
|
||||
PortabilityLayer::ResolveCachingColor partialFillColor(PortabilityLayer::RGBAColor::Create(255, 255, 204, 255));
|
||||
surface->FrameRect(loadScreenProgressBarRect, blackColor);
|
||||
surface->FillRect(loadScreenProgressBarRect.Inset(1, 1), partialFillColor);
|
||||
|
||||
Rect ringDestRect = Rect::Create(8, 8, 24, 24);
|
||||
Rect ringSrcRect = Rect::Create(0, 0, 16, 16);
|
||||
CopyBits(*loadRingSurface->m_port.GetPixMap(), *surface->m_port.GetPixMap(), &ringSrcRect, &ringDestRect, srcCopy);
|
||||
|
||||
loadRingImageH.Dispose();
|
||||
|
||||
loadScreenRingSurface = loadRingSurface;
|
||||
CreateLoadScreenWindow(loadScreenWindowPhase);
|
||||
}
|
||||
|
||||
enum PreloadFontCategory
|
||||
@@ -495,7 +597,7 @@ struct PreloadFontSpec
|
||||
|
||||
struct PreloadFontWorkSlot
|
||||
{
|
||||
PortabilityLayer::HostThreadEvent *m_completedEvent;
|
||||
IGpThreadEvent *m_completedEvent;
|
||||
PortabilityLayer::WorkerThread *m_workerThread;
|
||||
std::atomic<int> m_singleJobCompleted;
|
||||
const PreloadFontSpec *m_spec;
|
||||
@@ -540,12 +642,12 @@ void PreloadSingleFont (const PreloadFontSpec &spec)
|
||||
}
|
||||
}
|
||||
|
||||
void PreloadThreadFunc(void *context)
|
||||
void PreloadFontThreadFunc(void *context)
|
||||
{
|
||||
PreloadFontWorkSlot *wSlot = static_cast<PreloadFontWorkSlot*>(context);
|
||||
|
||||
PreloadSingleFont(*wSlot->m_spec);
|
||||
++wSlot->m_singleJobCompleted;
|
||||
wSlot->m_singleJobCompleted.fetch_add(1, std::memory_order_release);
|
||||
wSlot->m_completedEvent->Signal();
|
||||
}
|
||||
|
||||
@@ -553,6 +655,9 @@ void PreloadFonts()
|
||||
{
|
||||
static PreloadFontSpec specs[] =
|
||||
{
|
||||
// First entry should be the one needed to show the load screen
|
||||
{ FontCategory_Application, 18, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
|
||||
{ FontCategory_System, 9, PortabilityLayer::FontFamilyFlag_Bold, true },
|
||||
{ FontCategory_System, 10, PortabilityLayer::FontFamilyFlag_Bold, true },
|
||||
{ FontCategory_System, 12, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
@@ -561,7 +666,7 @@ void PreloadFonts()
|
||||
{ FontCategory_Application, 9, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
{ FontCategory_Application, 12, PortabilityLayer::FontFamilyFlag_Bold, true },
|
||||
{ FontCategory_Application, 14, PortabilityLayer::FontFamilyFlag_Bold, true },
|
||||
{ FontCategory_Application, 18, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
{ FontCategory_Application, 14, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
{ FontCategory_Application, 40, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
{ FontCategory_Handwriting, 24, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
{ FontCategory_Handwriting, 48, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
@@ -570,7 +675,6 @@ void PreloadFonts()
|
||||
|
||||
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
||||
|
||||
|
||||
const int numFontSpecs = sizeof(specs) / sizeof(specs[0]);
|
||||
|
||||
int queuedSpecs = 0;
|
||||
@@ -580,19 +684,19 @@ void PreloadFonts()
|
||||
// but we can do this to unclog the render thread.
|
||||
PreloadFontWorkSlot slot;
|
||||
slot.m_workerThread = PortabilityLayer::WorkerThread::Create();
|
||||
slot.m_completedEvent = PortabilityLayer::HostSystemServices::GetInstance()->CreateThreadEvent(true, false);
|
||||
slot.m_completedEvent = PLDrivers::GetSystemServices()->CreateThreadEvent(true, false);
|
||||
|
||||
while (completedSpecs < numFontSpecs)
|
||||
{
|
||||
if (slot.m_queued)
|
||||
{
|
||||
if (slot.m_singleJobCompleted.load(std::memory_order_relaxed) != 0)
|
||||
if (slot.m_singleJobCompleted.load(std::memory_order_acquire) != 0)
|
||||
{
|
||||
slot.m_completedEvent->Wait();
|
||||
slot.m_queued = false;
|
||||
completedSpecs++;
|
||||
|
||||
StepLoadScreen(1);
|
||||
StepLoadScreen(1, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,9 +705,9 @@ void PreloadFonts()
|
||||
if (queuedSpecs < numFontSpecs)
|
||||
{
|
||||
slot.m_queued = true;
|
||||
slot.m_singleJobCompleted.store(0);
|
||||
slot.m_spec = specs + queuedSpecs;
|
||||
slot.m_workerThread->AsyncExecuteTask(PreloadThreadFunc, &slot);
|
||||
slot.m_singleJobCompleted.store(0, std::memory_order_release);
|
||||
slot.m_workerThread->AsyncExecuteTask(PreloadFontThreadFunc, &slot);
|
||||
|
||||
queuedSpecs++;
|
||||
}
|
||||
@@ -613,6 +717,344 @@ void PreloadFonts()
|
||||
Delay(1, nullptr);
|
||||
}
|
||||
|
||||
PortabilityLayer::FontManager::GetInstance()->PurgeCache();
|
||||
}
|
||||
|
||||
struct PreloadAATableSpec
|
||||
{
|
||||
PortabilityLayer::RGBAColor m_color;
|
||||
bool m_isTone;
|
||||
};
|
||||
|
||||
struct PreloadAATableWorkSlot
|
||||
{
|
||||
IGpThreadEvent *m_completedEvent;
|
||||
IGpMutex *m_mutex;
|
||||
PortabilityLayer::WorkerThread *m_workerThread;
|
||||
std::atomic<int> m_singleJobCompleted;
|
||||
const PreloadAATableSpec *m_spec;
|
||||
bool m_queued;
|
||||
|
||||
PreloadAATableWorkSlot();
|
||||
~PreloadAATableWorkSlot();
|
||||
};
|
||||
|
||||
PreloadAATableWorkSlot::PreloadAATableWorkSlot()
|
||||
: m_completedEvent(nullptr)
|
||||
, m_workerThread(nullptr)
|
||||
, m_spec(nullptr)
|
||||
, m_queued(false)
|
||||
{
|
||||
}
|
||||
|
||||
PreloadAATableWorkSlot::~PreloadAATableWorkSlot()
|
||||
{
|
||||
if (m_workerThread)
|
||||
m_workerThread->Destroy();
|
||||
}
|
||||
|
||||
|
||||
void PreloadAATableThreadFunc(void *context)
|
||||
{
|
||||
PreloadAATableWorkSlot *wSlot = static_cast<PreloadAATableWorkSlot*>(context);
|
||||
|
||||
PortabilityLayer::StandardPalette *sp = PortabilityLayer::StandardPalette::GetInstance();
|
||||
|
||||
if (wSlot->m_spec->m_isTone)
|
||||
sp->GetCachedToneAATable(wSlot->m_spec->m_color.r, wSlot->m_mutex);
|
||||
else
|
||||
sp->GetCachedPaletteAATable(wSlot->m_spec->m_color, wSlot->m_mutex);
|
||||
|
||||
wSlot->m_singleJobCompleted.fetch_add(1, std::memory_order_release);
|
||||
wSlot->m_completedEvent->Signal();
|
||||
}
|
||||
|
||||
void PreloadAATables()
|
||||
{
|
||||
PortabilityLayer::StandardPalette *sp = PortabilityLayer::StandardPalette::GetInstance();
|
||||
PortabilityLayer::RGBAColor preloadColors[] =
|
||||
{
|
||||
PortabilityLayer::RGBAColor::Create(255, 255, 255, 255),
|
||||
PortabilityLayer::RGBAColor::Create(255, 51, 51, 255),
|
||||
PortabilityLayer::RGBAColor::Create(255, 0, 0, 255),
|
||||
PortabilityLayer::RGBAColor::Create(255, 255, 0, 255),
|
||||
PortabilityLayer::RGBAColor::Create(0, 255, 255, 255),
|
||||
PortabilityLayer::RGBAColor::Create(0, 0, 255, 255),
|
||||
PortabilityLayer::RGBAColor::Create(204, 102, 51, 255),
|
||||
};
|
||||
|
||||
const size_t numPalettePreloads = sizeof(preloadColors) / sizeof(preloadColors[0]);
|
||||
const size_t maxTonePreloads = numPalettePreloads * 3;
|
||||
|
||||
PreloadAATableSpec specs[numPalettePreloads + maxTonePreloads];
|
||||
for (size_t i = 0; i < numPalettePreloads; i++)
|
||||
{
|
||||
specs[i].m_color = preloadColors[i];
|
||||
specs[i].m_isTone = false;
|
||||
}
|
||||
|
||||
size_t numTonePreloads = 0;
|
||||
for (size_t i = 0; i < numPalettePreloads; i++)
|
||||
{
|
||||
const uint8_t rgb[3] = { preloadColors[i].r, preloadColors[i].g, preloadColors[i].b };
|
||||
|
||||
for (int ch = 0; ch < 3; ch++)
|
||||
{
|
||||
uint8_t tone = rgb[ch];
|
||||
|
||||
bool toneAlreadyQueued = false;
|
||||
for (size_t j = 0; j < numTonePreloads; j++)
|
||||
{
|
||||
if (specs[numPalettePreloads + j].m_color.r == tone)
|
||||
{
|
||||
toneAlreadyQueued = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!toneAlreadyQueued)
|
||||
{
|
||||
PreloadAATableSpec &spec = specs[i + numTonePreloads];
|
||||
numTonePreloads++;
|
||||
|
||||
spec.m_color = PortabilityLayer::RGBAColor::Create(tone, tone, tone, 255);
|
||||
spec.m_isTone = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
||||
|
||||
const int numAASpecs = numPalettePreloads + numTonePreloads;
|
||||
|
||||
unsigned int cpus = PLDrivers::GetSystemServices()->GetCPUCount();
|
||||
if (cpus < 2)
|
||||
{
|
||||
for (size_t i = 0; i < numAASpecs; i++)
|
||||
{
|
||||
PreloadAATableThreadFunc(specs + i);
|
||||
StepLoadScreen(1, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cpus -= 1;
|
||||
|
||||
int queuedSpecs = 0;
|
||||
int completedSpecs = 0;
|
||||
|
||||
PreloadAATableWorkSlot *slots = static_cast<PreloadAATableWorkSlot*>(mm->Alloc(sizeof(PreloadAATableWorkSlot) * cpus));
|
||||
|
||||
IGpMutex *mutex = PLDrivers::GetSystemServices()->CreateMutex();
|
||||
|
||||
for (unsigned int i = 0; i < cpus; i++)
|
||||
{
|
||||
PreloadAATableWorkSlot *slot = new (slots + i) PreloadAATableWorkSlot();
|
||||
slot->m_workerThread = PortabilityLayer::WorkerThread::Create();
|
||||
slot->m_completedEvent = PLDrivers::GetSystemServices()->CreateThreadEvent(true, false);
|
||||
slot->m_mutex = mutex;
|
||||
}
|
||||
|
||||
while (completedSpecs < numAASpecs)
|
||||
{
|
||||
int completedThisStep = 0;
|
||||
for (unsigned int i = 0; i < cpus; i++)
|
||||
{
|
||||
PreloadAATableWorkSlot &slot = slots[i];
|
||||
|
||||
if (slot.m_queued)
|
||||
{
|
||||
if (slot.m_singleJobCompleted.load(std::memory_order_acquire) != 0)
|
||||
{
|
||||
slot.m_completedEvent->Wait();
|
||||
slot.m_queued = false;
|
||||
completedSpecs++;
|
||||
|
||||
completedThisStep++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!slot.m_queued)
|
||||
{
|
||||
if (queuedSpecs < numAASpecs)
|
||||
{
|
||||
slot.m_queued = true;
|
||||
slot.m_spec = specs + queuedSpecs;
|
||||
slot.m_singleJobCompleted.store(0, std::memory_order_release);
|
||||
slot.m_workerThread->AsyncExecuteTask(PreloadAATableThreadFunc, &slot);
|
||||
|
||||
queuedSpecs++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (completedThisStep > 0)
|
||||
StepLoadScreen(completedThisStep, false);
|
||||
|
||||
StepLoadScreenRing();
|
||||
Delay(1, nullptr);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < cpus; i++)
|
||||
slots[i].~PreloadAATableWorkSlot();
|
||||
|
||||
mm->Release(slots);
|
||||
mutex->Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void ShowInitialLaunchDisclaimer()
|
||||
{
|
||||
const char *disclaimerLines[] =
|
||||
{
|
||||
GP_APPLICATION_NAME " is a port of John Calhoun\xd5s Glider PRO, based",
|
||||
"on the 2016 release of the game\xd5s source code and assets.",
|
||||
"",
|
||||
"Glider PRO, a sequel to the original Glider, was released in 1994",
|
||||
"for Apple Macintosh computers, and is widely recognized as one of",
|
||||
"of the most iconic Macintosh-exclusive games of the 1990\xd5s.",
|
||||
"",
|
||||
"I hope that by adapting it to be playable on modern systems, more",
|
||||
"people can appreciate this important piece of video game history.",
|
||||
"",
|
||||
"This software is an adaptation that attempts to restore the original work",
|
||||
"as accurately as possible, but some fonts, graphics, and sounds have been",
|
||||
"substituted or removed for copyright reasons, and some user interface",
|
||||
"components have been added or changed to improve compatibility.",
|
||||
"",
|
||||
"This software is not developed by, maintained by, supported by, endorsed by,",
|
||||
"or otherwise associated with the authors or publishers of Glider PRO.",
|
||||
"Any references to Glider PRO in this software are for historical accuracy",
|
||||
"and should not be interpreted as implying any form of endorsement."
|
||||
};
|
||||
|
||||
const size_t numLines = sizeof(disclaimerLines) / sizeof(disclaimerLines[0]);
|
||||
|
||||
PortabilityLayer::RenderedFont *rfont = GetApplicationFont(14, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *buttonFont = GetApplicationFont(18, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
|
||||
const int kButtonSpacing = 16;
|
||||
const int kButtonHeight = 32;
|
||||
|
||||
const PLPasStr buttonText = PLDrivers::GetSystemServices()->IsTouchscreen() ? PLPasStr(PSTR("Tap to Continue...")) : PLPasStr(PSTR("Click to Continue..."));
|
||||
const int32_t buttonTextWidth = buttonFont->MeasureString(buttonText.UChars(), buttonText.Length());
|
||||
const int32_t buttonWidth = buttonTextWidth + 16;
|
||||
|
||||
const int32_t linegap = rfont->GetMetrics().m_linegap;
|
||||
const int32_t ascent = rfont->GetMetrics().m_ascent;
|
||||
int32_t windowHeight = linegap * numLines + kButtonSpacing + kButtonHeight;
|
||||
|
||||
size_t widestLine = 0;
|
||||
for (size_t i = 0; i < numLines; i++)
|
||||
{
|
||||
const size_t lineWidth = rfont->MeasureCharStr(disclaimerLines[i], strlen(disclaimerLines[i]));
|
||||
if (lineWidth > widestLine)
|
||||
widestLine = lineWidth;
|
||||
}
|
||||
|
||||
if (widestLine > 640)
|
||||
widestLine = 640;
|
||||
|
||||
Rect windowRect = Rect::Create(0, 0, windowHeight, widestLine);
|
||||
|
||||
PortabilityLayer::WindowDef def = PortabilityLayer::WindowDef::Create(windowRect, PortabilityLayer::WindowStyleFlags::kBorderless, true, 0, 0, PSTR(""));
|
||||
|
||||
Window *disclaimerWindow = PortabilityLayer::WindowManager::GetInstance()->CreateWindow(def);
|
||||
PortabilityLayer::WindowManager::GetInstance()->PutWindowBehind(disclaimerWindow, PL_GetPutInFrontWindowPtr());
|
||||
|
||||
DrawSurface *surface = disclaimerWindow->GetDrawSurface();
|
||||
PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black());
|
||||
PortabilityLayer::ResolveCachingColor whiteColor(StdColors::White());
|
||||
|
||||
surface->FillRect(windowRect, blackColor);
|
||||
|
||||
int32_t wx = (static_cast<int32_t>(thisMac.fullScreen.Width()) - static_cast<int32_t>(surface->m_port.GetRect().Width())) / 2;
|
||||
int32_t wy = (static_cast<int32_t>(thisMac.fullScreen.Height()) - static_cast<int32_t>(surface->m_port.GetRect().Height())) / 2;
|
||||
|
||||
disclaimerWindow->SetPosition(PortabilityLayer::Vec2i(wx, wy));
|
||||
|
||||
|
||||
for (size_t i = 0; i < numLines; i++)
|
||||
{
|
||||
const size_t lineWidth = rfont->MeasureCharStr(disclaimerLines[i], strlen(disclaimerLines[i]));
|
||||
if (lineWidth > widestLine)
|
||||
widestLine = lineWidth;
|
||||
|
||||
int32_t xOffset = static_cast<int32_t>((widestLine - lineWidth) / 2);
|
||||
|
||||
Point drawPt = Point::Create(xOffset, linegap * i + (linegap + ascent) / 2);
|
||||
surface->DrawString(drawPt, PLPasStr(strlen(disclaimerLines[i]), disclaimerLines[i]), whiteColor, rfont);
|
||||
}
|
||||
|
||||
const int numTicksToEnable = 10 * 60;
|
||||
const int borderThickness = 2;
|
||||
|
||||
Rect buttonRect = Rect::Create(windowRect.bottom - kButtonHeight, windowRect.right - buttonWidth, windowRect.bottom, windowRect.right);
|
||||
|
||||
{
|
||||
int topYOffset = (buttonRect.Height() - borderThickness) / 2;
|
||||
surface->FillRect(Rect::Create(buttonRect.top + topYOffset, buttonRect.left, buttonRect.top + topYOffset + borderThickness, buttonRect.left + borderThickness), whiteColor);
|
||||
surface->FillRect(Rect::Create(buttonRect.top + topYOffset, buttonRect.right - borderThickness, buttonRect.top + topYOffset + borderThickness, buttonRect.right), whiteColor);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < numTicksToEnable; i++)
|
||||
{
|
||||
int bar = (buttonWidth - borderThickness * 6) * i / numTicksToEnable;
|
||||
|
||||
int topYOffset = (buttonRect.Height() - borderThickness) / 2;
|
||||
surface->FillRect(Rect::Create(buttonRect.top + topYOffset, buttonRect.left + borderThickness * 3, buttonRect.top + topYOffset + borderThickness, buttonRect.left + borderThickness * 3 + bar), whiteColor);
|
||||
|
||||
Delay(1, nullptr);
|
||||
}
|
||||
|
||||
const int numTicksToExpand = 15;
|
||||
for (int i = 0; i < numTicksToExpand; i++)
|
||||
{
|
||||
int height = buttonRect.Height() * i / numTicksToExpand;
|
||||
int topYOffset = (buttonRect.Height() - height) / 2;
|
||||
surface->FillRect(Rect::Create(buttonRect.top + topYOffset, buttonRect.left, buttonRect.top + topYOffset + height, buttonRect.right), whiteColor);
|
||||
|
||||
Delay(1, nullptr);
|
||||
}
|
||||
|
||||
Point textPoint;
|
||||
textPoint.h = (buttonRect.left + buttonRect.right - buttonTextWidth) / 2;
|
||||
textPoint.v = (buttonRect.top + buttonRect.bottom + ascent) / 2;
|
||||
|
||||
const int numTicksToFade = 15;
|
||||
for (int i = 0; i <= numTicksToFade; i++)
|
||||
{
|
||||
int intensity = 255 - (i * 255 / numTicksToFade);
|
||||
PortabilityLayer::ResolveCachingColor backgroundColor(PortabilityLayer::RGBAColor::Create(intensity, intensity, intensity, 255));
|
||||
|
||||
surface->FillRect(buttonRect, whiteColor);
|
||||
surface->FillRect(buttonRect.Inset(borderThickness, borderThickness), backgroundColor);
|
||||
|
||||
surface->DrawString(textPoint, buttonText, whiteColor, buttonFont);
|
||||
|
||||
Delay(1, nullptr);
|
||||
}
|
||||
|
||||
bool dismiss = false;
|
||||
|
||||
FlushEvents();
|
||||
|
||||
while (!dismiss)
|
||||
{
|
||||
TimeTaggedVOSEvent evt;
|
||||
while (WaitForEvent(&evt, 1))
|
||||
{
|
||||
if (evt.IsLMouseDownEvent())
|
||||
dismiss = true;
|
||||
}
|
||||
}
|
||||
|
||||
Delay(1, nullptr);
|
||||
|
||||
PortabilityLayer::WindowManager::GetInstance()->DestroyWindow(disclaimerWindow);
|
||||
|
||||
Delay(60, nullptr);
|
||||
}
|
||||
|
||||
void gpAppInit()
|
||||
@@ -653,8 +1095,10 @@ int gpAppMain()
|
||||
SpinCursor(2); // Tick once to let the display driver flush any resolution changes from prefs
|
||||
FlushResolutionChange();
|
||||
|
||||
InitLoadingWindow(); StepLoadScreen(2);
|
||||
PreloadFonts(); StepLoadScreen(2);
|
||||
InitLoadingWindow(); StepLoadScreen(2, true);
|
||||
PreloadAATables();
|
||||
assert(isPrefsLoaded || loadScreenWindowPhase == 0);
|
||||
PreloadFonts(); StepLoadScreen(2, true);
|
||||
|
||||
#if defined COMPILEDEMO
|
||||
copyGood = true;
|
||||
@@ -673,12 +1117,12 @@ int gpAppMain()
|
||||
// if ((thisMac.numScreens > 1) && (isUseSecondScreen))
|
||||
// ReflectSecondMonitorEnvirons(false, true, true);
|
||||
HandleDepthSwitching();
|
||||
VariableInit(); StepLoadScreen(2);
|
||||
GetExtraCursors(); StepLoadScreen(2);
|
||||
VariableInit(); StepLoadScreen(2, true);
|
||||
GetExtraCursors(); StepLoadScreen(2, true);
|
||||
InitMarquee();
|
||||
CreatePointers(); StepLoadScreen(2);
|
||||
CreatePointers(); StepLoadScreen(2, true);
|
||||
InitSrcRects();
|
||||
CreateOffscreens(); StepLoadScreen(2);
|
||||
CreateOffscreens(); StepLoadScreen(2, true);
|
||||
|
||||
if (loadScreenWindow)
|
||||
{
|
||||
@@ -693,12 +1137,28 @@ int gpAppMain()
|
||||
loadScreenRingSurface = nullptr;
|
||||
}
|
||||
|
||||
bool resolutionChanged = false;
|
||||
|
||||
if (!isPrefsLoaded)
|
||||
{
|
||||
WriteOutPrefs();
|
||||
|
||||
if (thisMac.isResolutionDirty)
|
||||
{
|
||||
resolutionChanged = true;
|
||||
FlushResolutionChange();
|
||||
}
|
||||
|
||||
ShowInitialLaunchDisclaimer();
|
||||
}
|
||||
|
||||
OpenMainWindow();
|
||||
if (thisMac.isResolutionDirty)
|
||||
resolutionChanged = true;
|
||||
|
||||
if (resolutionChanged)
|
||||
HandleSplashResolutionChange();
|
||||
else
|
||||
OpenMainWindow();
|
||||
|
||||
if (isDoColorFade)
|
||||
PortabilityLayer::WindowManager::GetInstance()->SetWindowDesaturation(mainWindow, 1.0);
|
||||
@@ -706,8 +1166,7 @@ int gpAppMain()
|
||||
InitSound(); SpinCursor(2);
|
||||
InitMusic(); SpinCursor(2);
|
||||
BuildHouseList();
|
||||
if (OpenHouse())
|
||||
whoCares = ReadHouse();
|
||||
OpenHouse(true);
|
||||
|
||||
PlayPrioritySound(kBirdSound, kBirdPriority);
|
||||
DelayTicks(6);
|
||||
@@ -740,7 +1199,8 @@ int gpAppMain()
|
||||
if (!CloseHouse())
|
||||
{
|
||||
CloseHouseResFork();
|
||||
houseStream->Close();
|
||||
if (houseCFile)
|
||||
houseCFile->Close();
|
||||
houseOpen = false;
|
||||
}
|
||||
}
|
||||
|
@@ -2,14 +2,9 @@
|
||||
|
||||
#include "FontFamily.h"
|
||||
#include "GpApplicationName.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "GliderProtos.h"
|
||||
#include "Externs.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "PLCore.h"
|
||||
#include "PLQDraw.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "PLSysCalls.h"
|
||||
#include "RenderedFont.h"
|
||||
#include "GpRenderedFontMetrics.h"
|
||||
#include "MainMenuUI.h"
|
||||
@@ -19,6 +14,12 @@
|
||||
#include "WindowManager.h"
|
||||
#include "Vec2i.h"
|
||||
|
||||
#include "PLCore.h"
|
||||
#include "PLDrivers.h"
|
||||
#include "PLQDraw.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "PLSysCalls.h"
|
||||
|
||||
struct MainMenuControlState
|
||||
{
|
||||
Window *m_window;
|
||||
@@ -168,8 +169,7 @@ static void DrawMainMenuControl(DrawSurface *surface, MainMenuUIState::ControlID
|
||||
|
||||
void StartScrollForPage()
|
||||
{
|
||||
unsigned int displayHeight = 0;
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
|
||||
unsigned int displayHeight = PortabilityLayer::WindowManager::GetInstance()->GetDisplayResolution().m_y;
|
||||
|
||||
DismissMainMenuUI();
|
||||
|
||||
@@ -262,8 +262,7 @@ void StartMainMenuUI()
|
||||
|
||||
static void DismissMainMenuUIPage()
|
||||
{
|
||||
unsigned int displayHeight = 0;
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
|
||||
unsigned int displayHeight = PortabilityLayer::WindowManager::GetInstance()->GetDisplayResolution().m_y;
|
||||
|
||||
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
|
||||
|
||||
@@ -292,8 +291,7 @@ void TickMainMenuUI()
|
||||
{
|
||||
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
|
||||
|
||||
unsigned int displayHeight = 0;
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
|
||||
unsigned int displayHeight = PortabilityLayer::WindowManager::GetInstance()->GetDisplayResolution().m_y;
|
||||
|
||||
mainMenu.m_scrollInStep -= MainMenuUIState::kControlScrollInDecay;
|
||||
mainMenu.m_scrollInOffset -= (mainMenu.m_scrollInStep >> MainMenuUIState::kControlScrollInDecayFalloffBits);
|
||||
@@ -327,8 +325,7 @@ void HandleMainMenuUIResolutionChange()
|
||||
{
|
||||
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
|
||||
|
||||
unsigned int displayHeight = 0;
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
|
||||
unsigned int displayHeight = PortabilityLayer::WindowManager::GetInstance()->GetDisplayResolution().m_y;
|
||||
|
||||
for (int i = 0; i < MainMenuUIState::Control_Count; i++)
|
||||
{
|
||||
|
@@ -5,12 +5,9 @@
|
||||
//============================================================================
|
||||
|
||||
|
||||
#include "PLNumberFormatting.h"
|
||||
#include "PLPasStr.h"
|
||||
#include "Externs.h"
|
||||
#include "Environ.h"
|
||||
#include "FontFamily.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "House.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "InputManager.h"
|
||||
@@ -23,6 +20,9 @@
|
||||
#include "WindowDef.h"
|
||||
#include "WindowManager.h"
|
||||
|
||||
#include "PLDrivers.h"
|
||||
#include "PLNumberFormatting.h"
|
||||
#include "PLPasStr.h"
|
||||
|
||||
#define kMainWindowID 128
|
||||
#define kEditWindowID 129
|
||||
|
@@ -53,7 +53,7 @@ short isMapH, isMapV, mapRoomsHigh, mapRoomsWide;
|
||||
short mapLeftRoom, mapTopRoom;
|
||||
Boolean isMapOpen, doPrettyMap;
|
||||
|
||||
extern Boolean doBitchDialogs;
|
||||
extern Boolean doComplainDialogs;
|
||||
|
||||
|
||||
//============================================================== Functions
|
||||
@@ -651,7 +651,7 @@ void HandleMapClick (const GpMouseInputEvent &theEvent)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (doBitchDialogs)
|
||||
if (doComplainDialogs)
|
||||
{
|
||||
if (QueryNewRoom())
|
||||
{
|
||||
|
@@ -6,7 +6,6 @@
|
||||
|
||||
|
||||
#include "Externs.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "InputManager.h"
|
||||
#include "Marquee.h"
|
||||
@@ -14,6 +13,8 @@
|
||||
#include "ObjectEdit.h"
|
||||
#include "RectUtils.h"
|
||||
|
||||
#include "PLDrivers.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -42,16 +43,23 @@ void DoMarquee (void)
|
||||
{
|
||||
if ((!theMarquee.active) || (theMarquee.paused))
|
||||
return;
|
||||
|
||||
DrawSurface *surface = mainWindow->GetDrawSurface();
|
||||
const uint8_t *pattern = theMarquee.pats[theMarquee.index];
|
||||
DrawMarquee(surface, pattern);
|
||||
theMarquee.index++;
|
||||
if (theMarquee.index >= kNumMarqueePats)
|
||||
theMarquee.index = 0;
|
||||
|
||||
pattern = theMarquee.pats[theMarquee.index];
|
||||
DrawMarquee(surface, pattern);
|
||||
theMarquee.step++;
|
||||
|
||||
if (theMarquee.step >= theMarquee.interval)
|
||||
{
|
||||
DrawSurface *surface = mainWindow->GetDrawSurface();
|
||||
const uint8_t *pattern = theMarquee.pats[theMarquee.index];
|
||||
DrawMarquee(surface, pattern);
|
||||
theMarquee.index++;
|
||||
if (theMarquee.index >= kNumMarqueePats)
|
||||
theMarquee.index = 0;
|
||||
|
||||
pattern = theMarquee.pats[theMarquee.index];
|
||||
DrawMarquee(surface, pattern);
|
||||
|
||||
theMarquee.step = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- StartMarquee
|
||||
@@ -222,7 +230,7 @@ void DragMarqueeRect (Window *window, DrawSurface *surface, Point start, Rect *t
|
||||
Point wasPt, newPt;
|
||||
short deltaH, deltaV;
|
||||
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(handCursor);
|
||||
PLDrivers::GetDisplayDriver()->SetCursor(handCursor);
|
||||
StopMarquee();
|
||||
|
||||
const uint8_t *pattern = theMarquee.pats[theMarquee.index];
|
||||
@@ -265,9 +273,9 @@ void DragMarqueeHandle (Window *window, DrawSurface *surface, Point start, short
|
||||
short deltaH, deltaV;
|
||||
|
||||
if ((theMarquee.direction == kAbove) || (theMarquee.direction == kBelow))
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(vertCursor);
|
||||
PLDrivers::GetDisplayDriver()->SetCursor(vertCursor);
|
||||
else
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(horiCursor);
|
||||
PLDrivers::GetDisplayDriver()->SetCursor(horiCursor);
|
||||
StopMarquee();
|
||||
|
||||
const uint8_t *pattern = theMarquee.pats[theMarquee.index];
|
||||
@@ -349,7 +357,7 @@ void DragMarqueeCorner (Window *window, DrawSurface *surface, Point start, short
|
||||
Point wasPt, newPt;
|
||||
short deltaH, deltaV;
|
||||
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(diagCursor);
|
||||
PLDrivers::GetDisplayDriver()->SetCursor(diagCursor);
|
||||
StopMarquee();
|
||||
|
||||
const uint8_t *pattern = theMarquee.pats[theMarquee.index];
|
||||
@@ -514,6 +522,8 @@ void InitMarquee (void)
|
||||
theMarquee.active = false;
|
||||
theMarquee.paused = false;
|
||||
theMarquee.handled = false;
|
||||
theMarquee.step = 0;
|
||||
theMarquee.interval = 2;
|
||||
gliderMarqueeUp = false;
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,7 @@ typedef struct
|
||||
{
|
||||
Pattern pats[kNumMarqueePats];
|
||||
Rect bounds, handle;
|
||||
short index, direction, dist;
|
||||
short index, direction, dist, step, interval;
|
||||
Boolean active, paused, handled;
|
||||
} marquee;
|
||||
|
||||
|
@@ -426,6 +426,7 @@ void DoOptionsMenu (short theItem)
|
||||
}
|
||||
|
||||
OpenMainWindow();
|
||||
RedrawSplashScreen();
|
||||
incrementModeTime = TickCount() + kIdleSplashTicks;
|
||||
}
|
||||
else if (theMode == kSplashMode) // switching to edit mode
|
||||
|
@@ -4,18 +4,18 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//============================================================================
|
||||
|
||||
|
||||
#include "PLResources.h"
|
||||
#include "PLSound.h"
|
||||
#include "DialogManager.h"
|
||||
#include "Environ.h"
|
||||
#include "Externs.h"
|
||||
#include "SoundSync.h"
|
||||
#include "HostMutex.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "IGpMutex.h"
|
||||
#include "IGpSystemServices.h"
|
||||
#include "MemoryManager.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
#include "PLDrivers.h"
|
||||
#include "PLResources.h"
|
||||
#include "PLSound.h"
|
||||
|
||||
#define kBaseBufferMusicID 2000
|
||||
#define kMaxMusic 7
|
||||
@@ -47,7 +47,7 @@ struct MusicState
|
||||
};
|
||||
|
||||
MusicState musicState;
|
||||
PortabilityLayer::HostMutex *musicMutex;
|
||||
IGpMutex *musicMutex;
|
||||
|
||||
|
||||
extern Boolean isSoundOn;
|
||||
@@ -337,7 +337,7 @@ void InitMusic (void)
|
||||
musicState.musicSoundID = musicScore[musicState.musicCursor];
|
||||
musicState.musicMode = kPlayWholeScoreMode;
|
||||
|
||||
musicMutex = PortabilityLayer::HostSystemServices::GetInstance()->CreateMutex();
|
||||
musicMutex = PLDrivers::GetSystemServices()->CreateMutex();
|
||||
|
||||
PL_NotYetImplemented_TODO("MusicSync");
|
||||
|
||||
|
@@ -1963,6 +1963,12 @@ void GetThisRoomsObjRects (void)
|
||||
|
||||
if ((noRoomAtAll) || (!houseUnlocked))
|
||||
{
|
||||
// clear object handles so they're not draggable
|
||||
QSetRect(&leftStartGliderDest, 0, 0, 0, 0);
|
||||
QSetRect(&rightStartGliderDest, 0, 0, 0, 0);
|
||||
for (i = 0; i < kMaxRoomObs; i++)
|
||||
QSetRect(&roomObjectRects[i], 0, 0, 0, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@@ -278,12 +278,11 @@ void DoDemoGame (void)
|
||||
whoCares = CloseHouse();
|
||||
thisHouseIndex = demoHouseIndex;
|
||||
PasStringCopy(theHousesSpecs[thisHouseIndex].m_name, thisHouseName);
|
||||
if (OpenHouse())
|
||||
if (OpenHouse(true))
|
||||
{
|
||||
if (thisMac.isTouchscreen)
|
||||
DismissMainMenuUI();
|
||||
|
||||
whoCares = ReadHouse();
|
||||
demoGoing = true;
|
||||
NewGame(kNewGameMode);
|
||||
|
||||
@@ -293,9 +292,9 @@ void DoDemoGame (void)
|
||||
whoCares = CloseHouse();
|
||||
thisHouseIndex = wasHouseIndex;
|
||||
PasStringCopy(theHousesSpecs[thisHouseIndex].m_name, thisHouseName);
|
||||
if (OpenHouse())
|
||||
whoCares = ReadHouse();
|
||||
OpenHouse(true);
|
||||
incrementModeTime = TickCount() + kIdleSplashTicks;
|
||||
RedrawSplashScreen();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- InitGlider
|
||||
|
@@ -16,14 +16,13 @@
|
||||
#include "IGpPrefsHandler.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "MemoryManager.h"
|
||||
#include "HostAudioDriver.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "HostInputDriver.h"
|
||||
|
||||
#include "PLDrivers.h"
|
||||
|
||||
|
||||
#define kPrefCreatorType 'ozm5'
|
||||
#define kPrefFileType 'gliP'
|
||||
#define kPrefFileName PSTR("Glider Prefs v2")
|
||||
#define kPrefFileName PSTR("Glider Prefs")
|
||||
#define kDefaultPrefFName PSTR("Preferences")
|
||||
#define kPrefsStringsID 160
|
||||
#define kNewPrefsAlertID 160
|
||||
@@ -68,16 +67,8 @@ Boolean WritePrefs (const prefsInfo *thePrefs, short versionNow, THandle<moduleP
|
||||
PasStringCopy(kPrefFileName, fileName);
|
||||
|
||||
VFileSpec theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kPrefs, fileName);
|
||||
if (!fm->FileExists(PortabilityLayer::VirtualDirectories::kPrefs, fileName))
|
||||
{
|
||||
theErr = fm->CreateFileAtCurrentTime(theSpecs.m_dir, theSpecs.m_name, kPrefCreatorType, kPrefFileType);
|
||||
if (theErr != PLErrors::kNone)
|
||||
{
|
||||
CheckFileError(theErr, PSTR("Preferences"));
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
theErr = fm->OpenFileData(theSpecs.m_dir, theSpecs.m_name, PortabilityLayer::EFilePermission_Write, fileStream);
|
||||
|
||||
theErr = fm->OpenNonCompositeFile(theSpecs.m_dir, theSpecs.m_name, ".dat", PortabilityLayer::EFilePermission_Write, GpFileCreationDispositions::kCreateOrOverwrite, fileStream);
|
||||
if (theErr != PLErrors::kNone)
|
||||
{
|
||||
CheckFileError(theErr, PSTR("Preferences"));
|
||||
@@ -202,10 +193,10 @@ PLError_t ReadPrefs (prefsInfo *thePrefs, short versionNeed, Boolean *isOldVersi
|
||||
|
||||
theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectory_t::kPrefs, fileName);
|
||||
|
||||
if (!PortabilityLayer::FileManager::GetInstance()->FileExists(theSpecs.m_dir, theSpecs.m_name))
|
||||
return PLErrors::kFileNotFound;
|
||||
theErr = fm->OpenNonCompositeFile(theSpecs.m_dir, theSpecs.m_name, ".dat", PortabilityLayer::EFilePermission_Read, GpFileCreationDispositions::kOpenExisting, fileStream);
|
||||
if (theErr == PLErrors::kFileNotFound)
|
||||
return theErr;
|
||||
|
||||
theErr = fm->OpenFileData(theSpecs.m_dir, theSpecs.m_name, PortabilityLayer::EFilePermission_Read, fileStream);
|
||||
if (theErr != PLErrors::kNone)
|
||||
{
|
||||
CheckFileError(theErr, PSTR("Preferences"));
|
||||
@@ -327,29 +318,29 @@ Boolean DeletePrefs ()
|
||||
|
||||
theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kPrefs, fileName);
|
||||
|
||||
return PortabilityLayer::FileManager::GetInstance()->DeleteFile(theSpecs.m_dir, theSpecs.m_name);
|
||||
return PortabilityLayer::FileManager::GetInstance()->DeleteNonCompositeFile(theSpecs.m_dir, theSpecs.m_name, ".dat");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- RunFunctionOnAllPrefsHandlers
|
||||
bool RunFunctionOnAllPrefsHandlers (void *context, bool (*func) (void *context, IGpPrefsHandler *handler))
|
||||
{
|
||||
IGpPrefsHandler *ddHandler = PortabilityLayer::HostDisplayDriver::GetInstance()->GetPrefsHandler();
|
||||
IGpPrefsHandler *ddHandler = PLDrivers::GetDisplayDriver()->GetPrefsHandler();
|
||||
if (ddHandler && !func(context, ddHandler))
|
||||
return false;
|
||||
|
||||
|
||||
if (IGpAudioDriver *audioDriver = PortabilityLayer::HostAudioDriver::GetInstance())
|
||||
if (IGpAudioDriver *audioDriver = PLDrivers::GetAudioDriver())
|
||||
{
|
||||
IGpPrefsHandler *adHandler = audioDriver->GetPrefsHandler();
|
||||
if (adHandler && !func(context, adHandler))
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t numInputDrivers = PortabilityLayer::HostInputDriver::NumInstances();
|
||||
size_t numInputDrivers = PLDrivers::GetNumInputDrivers();
|
||||
|
||||
for (size_t i = 0; i < numInputDrivers; i++)
|
||||
{
|
||||
IGpPrefsHandler *idHandler = PortabilityLayer::HostInputDriver::GetInstance(i)->GetPrefsHandler();
|
||||
IGpPrefsHandler *idHandler = PLDrivers::GetInputDriver(i)->GetPrefsHandler();
|
||||
if (idHandler && !func(context, idHandler))
|
||||
return false;
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ short numberRooms, thisRoomNumber, previousRoom;
|
||||
short leftThresh, rightThresh, lastBackground;
|
||||
Boolean autoRoomEdit, newRoomNow, noRoomAtAll;
|
||||
Boolean leftOpen, rightOpen, topOpen, bottomOpen;
|
||||
Boolean doBitchDialogs;
|
||||
Boolean doComplainDialogs;
|
||||
|
||||
extern short tempTiles[];
|
||||
|
||||
|
@@ -5,16 +5,9 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//============================================================================
|
||||
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLNumberFormatting.h"
|
||||
#include "PLResources.h"
|
||||
#include "PLSound.h"
|
||||
#include "PLPasStr.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "DialogManager.h"
|
||||
#include "DialogUtils.h"
|
||||
#include "Externs.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "RectUtils.h"
|
||||
#include "PLPopupMenuWidget.h"
|
||||
@@ -25,6 +18,13 @@
|
||||
#include "ResourceManager.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include "PLDrivers.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLNumberFormatting.h"
|
||||
#include "PLResources.h"
|
||||
#include "PLSound.h"
|
||||
#include "PLPasStr.h"
|
||||
#include "PLStandardColors.h"
|
||||
|
||||
#define kRoomInfoDialogID 1003
|
||||
#define kOriginalArtDialogID 1016
|
||||
@@ -54,7 +54,7 @@ void UpdateOriginalArt (Dialog *);
|
||||
int16_t OriginalArtFilter (void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt);
|
||||
Boolean PictIDExists (short);
|
||||
short GetFirstPICT (void);
|
||||
void BitchAboutPICTNotFound (void);
|
||||
void ComplainAboutPICTNotFound (void);
|
||||
|
||||
|
||||
Rect tileSrc, tileDest, tileSrcRect, editTETextBox;
|
||||
@@ -271,7 +271,7 @@ void HiliteTileOver (DrawSurface *surface, Point mouseIs)
|
||||
{
|
||||
if (cursorIs != kHandCursor)
|
||||
{
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(handCursor);
|
||||
PLDrivers::GetDisplayDriver()->SetCursor(handCursor);
|
||||
cursorIs = kHandCursor;
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ void HiliteTileOver (DrawSurface *surface, Point mouseIs)
|
||||
{
|
||||
if (cursorIs != kBeamCursor)
|
||||
{
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kIBeam);
|
||||
PLDrivers::GetDisplayDriver()->SetStandardCursor(EGpStandardCursors::kIBeam);
|
||||
cursorIs = kBeamCursor;
|
||||
}
|
||||
}
|
||||
@@ -441,7 +441,7 @@ void DoRoomInfo(void)
|
||||
// SetPort((GrafPtr)tileSrcMap);
|
||||
if ((tempBack > kStars) && (!PictIDExists(tempBack)))
|
||||
{
|
||||
BitchAboutPICTNotFound();
|
||||
ComplainAboutPICTNotFound();
|
||||
tempBack = kSimpleRoom;
|
||||
}
|
||||
if ((tempBack == 2002) || (tempBack == 2011) ||
|
||||
@@ -869,10 +869,10 @@ short GetFirstPICT (void)
|
||||
return resID;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- BitchAboutPICTNotFound
|
||||
//-------------------------------------------------------------- ComplainAboutPICTNotFound
|
||||
|
||||
#ifndef COMPILEDEMO
|
||||
void BitchAboutPICTNotFound (void)
|
||||
void ComplainAboutPICTNotFound (void)
|
||||
{
|
||||
short hitWhat;
|
||||
|
||||
|
@@ -9,16 +9,19 @@
|
||||
#include "PLStringCompare.h"
|
||||
#include "DialogManager.h"
|
||||
#include "Externs.h"
|
||||
#include "FileBrowserUI.h"
|
||||
#include "FileManager.h"
|
||||
#include "FontFamily.h"
|
||||
#include "House.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "InputManager.h"
|
||||
#include "MacFileInfo.h"
|
||||
#include "MemoryManager.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "ResolveCachingColor.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#define kSavedGameVersion 0x0200
|
||||
|
||||
|
||||
@@ -33,9 +36,93 @@ extern Boolean twoPlayerGame;
|
||||
|
||||
|
||||
//============================================================== Functions
|
||||
|
||||
static const int kStarsOffset = 180;
|
||||
static const int kGlidersOffset = 260;
|
||||
static const int kScoreOffset = 320;
|
||||
|
||||
static void FBUI_DrawLabels(DrawSurface *surface, const Point &basePoint)
|
||||
{
|
||||
PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black());
|
||||
PortabilityLayer::RenderedFont *rfont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
|
||||
surface->DrawString(basePoint + Point::Create(kStarsOffset, 0), PSTR("Stars Left"), blackColor, rfont);
|
||||
surface->DrawString(basePoint + Point::Create(kGlidersOffset, 0), PSTR("Gliders"), blackColor, rfont);
|
||||
surface->DrawString(basePoint + Point::Create(kScoreOffset, 0), PSTR("Score"), blackColor, rfont);
|
||||
}
|
||||
|
||||
static void FBUI_DrawFileDetails(DrawSurface *surface, const Point &basePoint, const Rect &constraintRect, void *fileDetails)
|
||||
{
|
||||
PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black());
|
||||
PortabilityLayer::RenderedFont *rfont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
|
||||
const game2Type *gameData = static_cast<const game2Type*>(fileDetails);
|
||||
|
||||
Str255 numStr;
|
||||
|
||||
NumToString(gameData->wasStarsLeft, numStr);
|
||||
surface->DrawString(basePoint + Point::Create(kStarsOffset, 0), numStr, blackColor, rfont);
|
||||
|
||||
NumToString(gameData->numGliders, numStr);
|
||||
surface->DrawString(basePoint + Point::Create(kGlidersOffset, 0), numStr, blackColor, rfont);
|
||||
|
||||
NumToString(gameData->score, numStr);
|
||||
surface->DrawString(basePoint + Point::Create(kScoreOffset, 0), numStr, blackColor, rfont);
|
||||
}
|
||||
|
||||
static void *FBUI_LoadFileDetails(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)
|
||||
return nullptr;
|
||||
|
||||
const size_t kPrefixSize = sizeof(game2Type) - sizeof(savedRoom);
|
||||
|
||||
game2Type *gameData = static_cast<game2Type*>(PortabilityLayer::MemoryManager::GetInstance()->Alloc(kPrefixSize));
|
||||
if (!gameData)
|
||||
{
|
||||
stream->Close();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (stream->Read(gameData, kPrefixSize) != kPrefixSize)
|
||||
{
|
||||
PortabilityLayer::MemoryManager::GetInstance()->Release(gameData);
|
||||
stream->Close();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
stream->Close();
|
||||
|
||||
return gameData;
|
||||
}
|
||||
|
||||
static void FBUI_FreeFileDetails(void *fileDetails)
|
||||
{
|
||||
PortabilityLayer::MemoryManager::GetInstance()->Release(fileDetails);
|
||||
}
|
||||
|
||||
static bool FBUI_FilterFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static PortabilityLayer::FileBrowserUI_DetailsCallbackAPI GetSavedGameDetailsAPI()
|
||||
{
|
||||
PortabilityLayer::FileBrowserUI_DetailsCallbackAPI api;
|
||||
|
||||
api.m_drawLabelsCallback = FBUI_DrawLabels;
|
||||
api.m_drawFileDetailsCallback = FBUI_DrawFileDetails;
|
||||
api.m_loadFileDetailsCallback = FBUI_LoadFileDetails;
|
||||
api.m_freeFileDetailsCallback = FBUI_FreeFileDetails;
|
||||
api.m_filterFileCallback = FBUI_FilterFile;
|
||||
|
||||
return api;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- 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.
|
||||
@@ -65,7 +152,7 @@ void SaveGame2 (void)
|
||||
if (savedGame == nil)
|
||||
{
|
||||
YellowAlert(kYellowFailedSaveGame, PLErrors::kOutOfMemory);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
memset(savedGame, 0, byteCount);
|
||||
@@ -82,25 +169,16 @@ void SaveGame2 (void)
|
||||
char savePath[sizeof(spec.m_name) + 1];
|
||||
size_t savePathLength = 0;
|
||||
|
||||
if (!fm->PromptSaveFile(spec.m_dir, savePath, savePathLength, sizeof(spec.m_name), PLPasStr(gameNameStr), PSTR("Save Game")))
|
||||
if (!fm->PromptSaveFile(spec.m_dir, ".sav", savePath, savePathLength, sizeof(spec.m_name), PLPasStr(gameNameStr), PSTR("Save Game"), false, GetSavedGameDetailsAPI()))
|
||||
{
|
||||
mm->Release(savedGame);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(savePathLength < sizeof(spec.m_name) - 1);
|
||||
|
||||
spec.m_name[0] = static_cast<uint8_t>(savePathLength);
|
||||
memcpy(spec.m_name + 1, savePath, savePathLength);
|
||||
|
||||
if (fm->FileExists(spec.m_dir, PLPasStr(spec.m_name)))
|
||||
{
|
||||
if (!fm->DeleteFile(spec.m_dir, spec.m_name))
|
||||
{
|
||||
CheckFileError(PLErrors::kAccessDenied, PSTR("Saved Game"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
thisHousePtr = *thisHouse;
|
||||
|
||||
@@ -135,23 +213,20 @@ void SaveGame2 (void)
|
||||
destRoom->objects[i] = srcRoom->objects[i];
|
||||
}
|
||||
|
||||
PLError_t theErr = fm->CreateFileAtCurrentTime(spec.m_dir, spec.m_name, 'ozm5', 'gliG');
|
||||
PLError_t theErr = fm->OpenNonCompositeFile(spec.m_dir, spec.m_name, ".sav", PortabilityLayer::EFilePermission_Write, GpFileCreationDispositions::kCreateOrOverwrite, gameStream);
|
||||
if (CheckFileError(theErr, PSTR("Saved Game")))
|
||||
{
|
||||
theErr = fm->OpenFileData(spec.m_dir, spec.m_name, PortabilityLayer::EFilePermission_Write, gameStream);
|
||||
|
||||
if (CheckFileError(theErr, PSTR("Saved Game")))
|
||||
if (gameStream->Write(savedGame, byteCount) != byteCount)
|
||||
{
|
||||
if (gameStream->Write(savedGame, byteCount) != byteCount)
|
||||
{
|
||||
CheckFileError(PLErrors::kIOError, PSTR("Saved Game"));
|
||||
}
|
||||
|
||||
gameStream->Close();
|
||||
CheckFileError(PLErrors::kIOError, PSTR("Saved Game"));
|
||||
}
|
||||
|
||||
gameStream->Close();
|
||||
}
|
||||
|
||||
mm->Release(savedGame);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- SavedGameMismatchError
|
||||
@@ -191,7 +266,7 @@ Boolean OpenSavedGame (void)
|
||||
char savePath[sizeof(spec.m_name) + 1];
|
||||
size_t savePathLength = 0;
|
||||
|
||||
if (!fm->PromptOpenFile(spec.m_dir, savePath, savePathLength, sizeof(spec.m_name), PSTR("Open Saved Game")))
|
||||
if (!fm->PromptOpenFile(spec.m_dir, ".sav", savePath, savePathLength, sizeof(spec.m_name), PSTR("Open Saved Game"), true, GetSavedGameDetailsAPI()))
|
||||
return false;
|
||||
|
||||
assert(savePathLength < sizeof(spec.m_name) - 1);
|
||||
@@ -199,15 +274,8 @@ Boolean OpenSavedGame (void)
|
||||
spec.m_name[0] = static_cast<uint8_t>(savePathLength);
|
||||
memcpy(spec.m_name + 1, savePath, savePathLength);
|
||||
|
||||
PortabilityLayer::MacFileProperties props;
|
||||
if (!fm->ReadFileProperties(spec.m_dir, spec.m_name, props))
|
||||
return false;
|
||||
|
||||
if (memcmp(props.m_fileType, "gliG", 4))
|
||||
return false;
|
||||
|
||||
GpIOStream *gameStream = nullptr;
|
||||
PLError_t theErr = fm->OpenFileData(spec.m_dir, spec.m_name, PortabilityLayer::EFilePermission_Read, gameStream);
|
||||
PLError_t theErr = fm->OpenNonCompositeFile(spec.m_dir, spec.m_name, ".sav", PortabilityLayer::EFilePermission_Read, GpFileCreationDispositions::kOpenExisting, gameStream);
|
||||
|
||||
if (!CheckFileError(theErr, PSTR("Saved Game")))
|
||||
return(false);
|
||||
|
@@ -101,18 +101,26 @@ void UpdateLoadDialog (Dialog *theDialog)
|
||||
|
||||
if (SectRect(&dialogRect, &tempRect, &dummyRect))
|
||||
{
|
||||
PortabilityLayer::IResourceArchive *resFile = PortabilityLayer::ResourceManager::GetInstance()->LoadResFile(theHousesSpecs[i].m_dir, theHousesSpecs[i].m_name);
|
||||
if (resFile != nullptr)
|
||||
PortabilityLayer::CompositeFile *cfile = PortabilityLayer::FileManager::GetInstance()->OpenCompositeFile(theHousesSpecs[i].m_dir, theHousesSpecs[i].m_name);
|
||||
|
||||
bool haveHouseIcon = false;
|
||||
GpIOStream *resStream = nil;
|
||||
|
||||
if (cfile)
|
||||
{
|
||||
if (!LargeIconPlot(surface, resFile, -16455, tempRect))
|
||||
PortabilityLayer::IResourceArchive *resFile = PortabilityLayer::ResourceManager::GetInstance()->LoadResFile(cfile);
|
||||
if (resFile != nullptr)
|
||||
{
|
||||
LoadDialogPICT(theDialog, kLoadIconFirstItem + i - housePage,
|
||||
kDefaultHousePict8);
|
||||
if (LargeIconPlot(surface, resFile, -16455, tempRect))
|
||||
haveHouseIcon = true;
|
||||
|
||||
resFile->Destroy();
|
||||
}
|
||||
|
||||
resFile->Destroy();
|
||||
cfile->Close();
|
||||
}
|
||||
else
|
||||
|
||||
if (!haveHouseIcon)
|
||||
LoadDialogPICT(theDialog, kLoadIconFirstItem + i - housePage,
|
||||
kDefaultHousePict8);
|
||||
}
|
||||
@@ -411,11 +419,8 @@ void DoLoadHouse (void)
|
||||
whoCares = CloseHouse();
|
||||
PasStringCopy(theHousesSpecs[thisHouseIndex].m_name,
|
||||
thisHouseName);
|
||||
if (OpenHouse())
|
||||
{
|
||||
whoCares = ReadHouse();
|
||||
if (OpenHouse(true))
|
||||
houseNameDirty = true;
|
||||
}
|
||||
}
|
||||
leaving = true;
|
||||
}
|
||||
@@ -452,11 +457,8 @@ void DoLoadHouse (void)
|
||||
whoCares = CloseHouse();
|
||||
PasStringCopy(theHousesSpecs[thisHouseIndex].m_name,
|
||||
thisHouseName);
|
||||
if (OpenHouse())
|
||||
{
|
||||
whoCares = ReadHouse();
|
||||
if (OpenHouse(true))
|
||||
houseNameDirty = true;
|
||||
}
|
||||
}
|
||||
leaving = true;
|
||||
}
|
||||
@@ -489,11 +491,8 @@ void DoLoadHouse (void)
|
||||
whoCares = CloseHouse();
|
||||
PasStringCopy(theHousesSpecs[thisHouseIndex].m_name,
|
||||
thisHouseName);
|
||||
if (OpenHouse())
|
||||
{
|
||||
whoCares = ReadHouse();
|
||||
if (OpenHouse(true))
|
||||
houseNameDirty = true;
|
||||
}
|
||||
}
|
||||
leaving = true;
|
||||
}
|
||||
@@ -596,7 +595,7 @@ void DoDirSearch (void)
|
||||
{
|
||||
theHousesSpecs[housesFound] = MakeVFileSpec(theDirs[currentDir], f->name);
|
||||
|
||||
if (fm->FileExists(theDirs[currentDir], f->name))
|
||||
if (fm->CompositeFileExists(theDirs[currentDir], f->name))
|
||||
housesFound++;
|
||||
}
|
||||
}
|
||||
|
@@ -5,22 +5,22 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//============================================================================
|
||||
|
||||
#include "PLArrayView.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLSound.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "PLTimeTaggedVOSEvent.h"
|
||||
#include "PLWidgets.h"
|
||||
#include "ResolveCachingColor.h"
|
||||
#include "DialogManager.h"
|
||||
#include "DialogUtils.h"
|
||||
#include "Externs.h"
|
||||
#include "Environ.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "House.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "WindowManager.h"
|
||||
|
||||
#include "PLArrayView.h"
|
||||
#include "PLDrivers.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLSound.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "PLTimeTaggedVOSEvent.h"
|
||||
#include "PLWidgets.h"
|
||||
|
||||
#define kMainPrefsDialID 1012
|
||||
#define kDisplayPrefsDialID 1017
|
||||
@@ -72,7 +72,7 @@
|
||||
#define kDoBackgroundCheck 11
|
||||
#define kDoErrorCheck 12
|
||||
#define kDoPrettyMapCheck 13
|
||||
#define kDoBitchDlgsCheck 14
|
||||
#define kDoComplainDlgsCheck 14
|
||||
|
||||
|
||||
void SetBrainsToDefaults (Dialog *);
|
||||
@@ -98,7 +98,7 @@ void SetAllDefaults (void);
|
||||
void FlashSettingsButton (DrawSurface *, short);
|
||||
void UpdateSettingsMain (Dialog *);
|
||||
int16_t PrefsFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt);
|
||||
void BitchAboutChanges (void);
|
||||
void ComplainAboutChanges (void);
|
||||
void WriteOutPrefs (void);
|
||||
|
||||
|
||||
@@ -109,11 +109,11 @@ long tempLeftMap, tempRightMap, tempBattMap, tempBandMap;
|
||||
short whichCtrl, wasDepthPref;
|
||||
Boolean wasFade, wasIdle, wasPlay, wasTransit, wasZooms, wasBackground;
|
||||
Boolean wasEscPauseKey, wasDemos, wasAutoScale, wasUseICCProfile, nextRestartChange, wasErrorCheck, wasFullscreenPref, needResolutionReset;
|
||||
Boolean wasPrettyMap, wasBitchDialogs;
|
||||
Boolean wasPrettyMap, wasComplainDialogs;
|
||||
|
||||
extern short numNeighbors, isDepthPref, maxFiles, willMaxFiles;
|
||||
extern Boolean isDoColorFade, isPlayMusicIdle, isAutoScale, isUseICCProfile;
|
||||
extern Boolean isHouseChecks, doBitchDialogs;
|
||||
extern Boolean isHouseChecks, doComplainDialogs;
|
||||
extern Boolean isEscPauseKey, failedMusic, isSoundOn, doBackground;
|
||||
extern Boolean isMusicOn, quickerTransitions, doAutoDemo;
|
||||
extern Boolean changeLockStateOfHouse, saveHouseLocked, doPrettyMap;
|
||||
@@ -135,14 +135,14 @@ void SetBrainsToDefaults (Dialog *theDialog)
|
||||
wasBackground = false;
|
||||
wasErrorCheck = true;
|
||||
wasPrettyMap = true;
|
||||
wasBitchDialogs = true;
|
||||
wasComplainDialogs = true;
|
||||
SetDialogItemValue(theDialog, kQuickTransitCheck, (short)wasTransit);
|
||||
SetDialogItemValue(theDialog, kDoZoomsCheck, (short)wasZooms);
|
||||
SetDialogItemValue(theDialog, kDoDemoCheck, (short)wasDemos);
|
||||
SetDialogItemValue(theDialog, kDoBackgroundCheck, (short)wasBackground);
|
||||
SetDialogItemValue(theDialog, kDoErrorCheck, (short)wasErrorCheck);
|
||||
SetDialogItemValue(theDialog, kDoPrettyMapCheck, (short)wasPrettyMap);
|
||||
SetDialogItemValue(theDialog, kDoBitchDlgsCheck, (short)wasBitchDialogs);
|
||||
SetDialogItemValue(theDialog, kDoComplainDlgsCheck, (short)wasComplainDialogs);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- UpdateSettingsBrains
|
||||
@@ -238,7 +238,7 @@ void DoBrainsPrefs (void)
|
||||
wasBackground = doBackground;
|
||||
wasErrorCheck = isHouseChecks;
|
||||
wasPrettyMap = doPrettyMap;
|
||||
wasBitchDialogs = doBitchDialogs;
|
||||
wasComplainDialogs = doComplainDialogs;
|
||||
|
||||
SetDialogItemValue(prefDlg, kQuickTransitCheck, (short)wasTransit);
|
||||
SetDialogItemValue(prefDlg, kDoZoomsCheck, (short)wasZooms);
|
||||
@@ -246,7 +246,7 @@ void DoBrainsPrefs (void)
|
||||
SetDialogItemValue(prefDlg, kDoBackgroundCheck, (short)wasBackground);
|
||||
SetDialogItemValue(prefDlg, kDoErrorCheck, (short)wasErrorCheck);
|
||||
SetDialogItemValue(prefDlg, kDoPrettyMapCheck, (short)wasPrettyMap);
|
||||
SetDialogItemValue(prefDlg, kDoBitchDlgsCheck, (short)wasBitchDialogs);
|
||||
SetDialogItemValue(prefDlg, kDoComplainDlgsCheck, (short)wasComplainDialogs);
|
||||
|
||||
UpdateSettingsBrains(prefDlg);
|
||||
|
||||
@@ -272,7 +272,7 @@ void DoBrainsPrefs (void)
|
||||
doBackground = wasBackground;
|
||||
isHouseChecks = wasErrorCheck;
|
||||
doPrettyMap = wasPrettyMap;
|
||||
doBitchDialogs = wasBitchDialogs;
|
||||
doComplainDialogs = wasComplainDialogs;
|
||||
leaving = true;
|
||||
break;
|
||||
|
||||
@@ -315,9 +315,9 @@ void DoBrainsPrefs (void)
|
||||
SetDialogItemValue(prefDlg, kDoPrettyMapCheck, (short)wasPrettyMap);
|
||||
break;
|
||||
|
||||
case kDoBitchDlgsCheck:
|
||||
wasBitchDialogs = !wasBitchDialogs;
|
||||
SetDialogItemValue(prefDlg, kDoBitchDlgsCheck, (short)wasBitchDialogs);
|
||||
case kDoComplainDlgsCheck:
|
||||
wasComplainDialogs = !wasComplainDialogs;
|
||||
SetDialogItemValue(prefDlg, kDoComplainDlgsCheck, (short)wasComplainDialogs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -637,7 +637,7 @@ void HandleSoundMusicChange (short newVolume, Boolean sayIt)
|
||||
|
||||
isSoundOn = (newVolume != 0);
|
||||
|
||||
if (wasIdle)
|
||||
if (wasIdle && theMode != kEditMode)
|
||||
{
|
||||
if (newVolume == 0)
|
||||
StopTheMusic();
|
||||
@@ -773,7 +773,7 @@ void DoSoundPrefs (void)
|
||||
case kCancelButton:
|
||||
UnivSetSoundVolume(wasLoudness, thisMac.hasSM3);
|
||||
HandleSoundMusicChange(wasLoudness, false);
|
||||
if (isPlayMusicIdle != wasIdle)
|
||||
if (isPlayMusicIdle != wasIdle && theMode != kEditMode)
|
||||
{
|
||||
if (isPlayMusicIdle)
|
||||
{
|
||||
@@ -831,7 +831,7 @@ void DoSoundPrefs (void)
|
||||
case kIdleMusicItem:
|
||||
wasIdle = !wasIdle;
|
||||
SetDialogItemValue(prefDlg, kIdleMusicItem, (short)wasIdle);
|
||||
if (wasIdle)
|
||||
if (wasIdle && theMode != kEditMode)
|
||||
{
|
||||
UnivGetSoundVolume(&tempVolume, thisMac.hasSM3);
|
||||
if (tempVolume != 0)
|
||||
@@ -1121,7 +1121,7 @@ void SetAllDefaults (void)
|
||||
doBackground = false;
|
||||
isHouseChecks = true;
|
||||
doPrettyMap = true;
|
||||
doBitchDialogs = true;
|
||||
doComplainDialogs = true;
|
||||
// Default control settings
|
||||
PasStringCopy(PSTR("lf arrow"), leftName);
|
||||
PasStringCopy(PSTR("rt arrow"), rightName);
|
||||
@@ -1285,7 +1285,7 @@ void DoSettingsMain (void)
|
||||
leaving = false;
|
||||
nextRestartChange = false;
|
||||
|
||||
wasFullscreenPref = PortabilityLayer::HostDisplayDriver::GetInstance()->IsFullScreen();
|
||||
wasFullscreenPref = PLDrivers::GetDisplayDriver()->IsFullScreen();
|
||||
|
||||
Window* exclWindow = prefDlg->GetWindow();
|
||||
|
||||
@@ -1340,11 +1340,11 @@ void DoSettingsMain (void)
|
||||
|
||||
if (nextRestartChange)
|
||||
{
|
||||
BitchAboutChanges();
|
||||
ComplainAboutChanges();
|
||||
nextRestartChange = false;
|
||||
}
|
||||
|
||||
IGpDisplayDriver *displayDriver = PortabilityLayer::HostDisplayDriver::GetInstance();
|
||||
IGpDisplayDriver *displayDriver = PLDrivers::GetDisplayDriver();
|
||||
|
||||
if (displayDriver->IsFullScreen() != (wasFullscreenPref != 0))
|
||||
{
|
||||
@@ -1354,18 +1354,18 @@ void DoSettingsMain (void)
|
||||
|
||||
if (needResolutionReset)
|
||||
{
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->RequestResetVirtualResolution();
|
||||
displayDriver->RequestResetVirtualResolution();
|
||||
needResolutionReset = false;
|
||||
}
|
||||
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->SetUseICCProfile(isUseICCProfile);
|
||||
displayDriver->SetUseICCProfile(isUseICCProfile);
|
||||
|
||||
WriteOutPrefs();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- BitchAboutChanges
|
||||
//-------------------------------------------------------------- ComplainAboutChanges
|
||||
|
||||
void BitchAboutChanges (void)
|
||||
void ComplainAboutChanges (void)
|
||||
{
|
||||
#define kChangesEffectAlert 1040
|
||||
short hitWhat;
|
||||
|
@@ -378,17 +378,6 @@ void TellHerNoSounds (void)
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMemForSoundsAlert, nullptr);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- BitchAboutSM3
|
||||
|
||||
void BitchAboutSM3 (void)
|
||||
{
|
||||
#define kNoSoundManager3Alert 1030
|
||||
short hitWhat;
|
||||
|
||||
// CenterAlert(kNoSoundManager3Alert);
|
||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoSoundManager3Alert, nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------- ParseAndConvertSound
|
||||
|
@@ -1,24 +1,27 @@
|
||||
#include "CombinedTimestamp.h"
|
||||
#include "DeflateCodec.h"
|
||||
#include "Environ.h"
|
||||
#include "FontFamily.h"
|
||||
#include "GpBuildVersion.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "HostDirectoryCursor.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "HostFileSystem.h"
|
||||
#include "GpFileCreationDisposition.h"
|
||||
#include "IGpDirectoryCursor.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "IGpFileSystem.h"
|
||||
#include "MemoryManager.h"
|
||||
#include "PLCore.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "PLSysCalls.h"
|
||||
#include "RenderedFont.h"
|
||||
#include "GpApplicationName.h"
|
||||
#include "GpRenderedFontMetrics.h"
|
||||
#include "ResolveCachingColor.h"
|
||||
#include "ZipFile.h"
|
||||
#include "Vec2i.h"
|
||||
#include "WindowDef.h"
|
||||
#include "WindowManager.h"
|
||||
#include "FontFamily.h"
|
||||
#include "ZipFile.h"
|
||||
|
||||
#include "PLCore.h"
|
||||
#include "PLDrivers.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "PLSysCalls.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@@ -93,41 +96,6 @@ SortableEntry SortableEntry::Create(const char *zipLocation, PortabilityLayer::V
|
||||
return entry;
|
||||
}
|
||||
|
||||
static void ConvertToMSDOSTimestamp(const PortabilityLayer::CombinedTimestamp &ts, uint16_t &msdosDate, uint16_t &msdosTime)
|
||||
{
|
||||
int32_t yearsSince1980 = ts.GetLocalYear() - 1980;
|
||||
uint8_t month = ts.m_localMonth;
|
||||
uint8_t day = ts.m_localDay;
|
||||
|
||||
uint8_t hour = ts.m_localHour;
|
||||
uint8_t minute = ts.m_localMinute;
|
||||
uint8_t second = ts.m_localSecond;
|
||||
|
||||
if (yearsSince1980 < 0)
|
||||
{
|
||||
// Time machine
|
||||
yearsSince1980 = 0;
|
||||
second = 0;
|
||||
minute = 0;
|
||||
hour = 0;
|
||||
day = 1;
|
||||
month = 1;
|
||||
}
|
||||
else if (yearsSince1980 > 127)
|
||||
{
|
||||
// I was promised flying cars, but it's 2107 and you're still flying paper airplanes...
|
||||
yearsSince1980 = 127;
|
||||
second = 59;
|
||||
minute = 59;
|
||||
hour = 23;
|
||||
day = 31;
|
||||
month = 12;
|
||||
}
|
||||
|
||||
msdosTime = (second / 2) | (minute << 5) | (hour << 11);
|
||||
msdosDate = day | (month << 5) | (yearsSince1980 << 9);
|
||||
}
|
||||
|
||||
static void InitSourceExportWindow(SourceExportState *state)
|
||||
{
|
||||
static const int kLoadScreenHeight = 32;
|
||||
@@ -138,9 +106,9 @@ static void InitSourceExportWindow(SourceExportState *state)
|
||||
|
||||
// We have to use this instead of thisMac.fullScreen because the resolution may change during the sleep call, especially on Android displays where
|
||||
// the status bar dismissal causes a major change in the virtual resolution.
|
||||
unsigned int displayWidth = 0;
|
||||
unsigned int displayHeight = 0;
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&displayWidth, &displayHeight);
|
||||
PortabilityLayer::Vec2i displaySize = PortabilityLayer::WindowManager::GetInstance()->GetDisplayResolution();
|
||||
unsigned int displayWidth = displaySize.m_x;
|
||||
unsigned int displayHeight = displaySize.m_y;
|
||||
|
||||
int32_t lsX = (static_cast<int32_t>(displayWidth) - kLoadScreenWidth) / 2;
|
||||
int32_t lsY = (static_cast<int32_t>(displayHeight) - kLoadScreenHeight) / 2;
|
||||
@@ -183,7 +151,7 @@ static void InitSourceExportWindow(SourceExportState *state)
|
||||
|
||||
static bool RetrieveSingleFileSize(PortabilityLayer::VirtualDirectory_t virtualDir, char const* const* paths, size_t numPaths, size_t &outSize)
|
||||
{
|
||||
GpIOStream *stream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFileNested(virtualDir, paths, numPaths, false, GpFileCreationDispositions::kOpenExisting);
|
||||
GpIOStream *stream = PLDrivers::GetFileSystem()->OpenFileNested(virtualDir, paths, numPaths, false, GpFileCreationDispositions::kOpenExisting);
|
||||
if (!stream)
|
||||
return false;
|
||||
|
||||
@@ -199,7 +167,7 @@ static bool RetrieveCompositeDirSize(PortabilityLayer::VirtualDirectory_t virtua
|
||||
size_t totalSize = 0;
|
||||
totalSizeOut = 0;
|
||||
|
||||
PortabilityLayer::HostDirectoryCursor *dirCursor = PortabilityLayer::HostFileSystem::GetInstance()->ScanDirectory(virtualDir);
|
||||
IGpDirectoryCursor *dirCursor = PLDrivers::GetFileSystem()->ScanDirectory(virtualDir);
|
||||
if (!dirCursor)
|
||||
return false;
|
||||
|
||||
@@ -400,9 +368,9 @@ static bool RepackDirectory(SourceExportState &state, GpIOStream *outStream, std
|
||||
|
||||
uint16_t dosDate = 0;
|
||||
uint16_t dosTime = 0;
|
||||
ConvertToMSDOSTimestamp(state.m_ts, dosDate, dosTime);
|
||||
state.m_ts.GetAsMSDOSTimestamp(dosDate, dosTime);
|
||||
|
||||
PortabilityLayer::HostDirectoryCursor *dirCursor = PortabilityLayer::HostFileSystem::GetInstance()->ScanDirectory(virtualDir);
|
||||
IGpDirectoryCursor *dirCursor = PLDrivers::GetFileSystem()->ScanDirectory(virtualDir);
|
||||
if (!dirCursor)
|
||||
return false;
|
||||
|
||||
@@ -425,7 +393,7 @@ static bool RepackDirectory(SourceExportState &state, GpIOStream *outStream, std
|
||||
|
||||
const bool shouldStore = (extension[3] == 'a');
|
||||
|
||||
state.m_fStream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(virtualDir, fpath, false, GpFileCreationDispositions::kOpenExisting);
|
||||
state.m_fStream = PLDrivers::GetFileSystem()->OpenFile(virtualDir, fpath, false, GpFileCreationDispositions::kOpenExisting);
|
||||
if (!state.m_fStream)
|
||||
return false;
|
||||
|
||||
@@ -607,7 +575,7 @@ static bool AddZipDirectory(GpIOStream *stream, std::vector<PortabilityLayer::Zi
|
||||
|
||||
uint16_t dosDate = 0;
|
||||
uint16_t dosTime = 0;
|
||||
ConvertToMSDOSTimestamp(ts, dosDate, dosTime);
|
||||
ts.GetAsMSDOSTimestamp(dosDate, dosTime);
|
||||
|
||||
GpUFilePos_t localHeaderPos = stream->Tell();
|
||||
|
||||
@@ -664,7 +632,7 @@ bool ExportSourceToStream (GpIOStream *stream)
|
||||
SourceExportState state;
|
||||
InitSourceExportWindow(&state);
|
||||
|
||||
state.m_tsStream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::VirtualDirectories::kApplicationData, "DefaultTimestamp.timestamp", false, GpFileCreationDispositions::kOpenExisting);
|
||||
state.m_tsStream = PLDrivers::GetFileSystem()->OpenFile(PortabilityLayer::VirtualDirectories::kApplicationData, "DefaultTimestamp.timestamp", false, GpFileCreationDispositions::kOpenExisting);
|
||||
if (!state.m_tsStream)
|
||||
return false;
|
||||
|
||||
@@ -673,7 +641,7 @@ bool ExportSourceToStream (GpIOStream *stream)
|
||||
state.m_tsStream->Close();
|
||||
state.m_tsStream = nullptr;
|
||||
|
||||
state.m_sourcePkgStream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::VirtualDirectories::kApplicationData, "SourceCode.pkg", false, GpFileCreationDispositions::kOpenExisting);
|
||||
state.m_sourcePkgStream = PLDrivers::GetFileSystem()->OpenFile(PortabilityLayer::VirtualDirectories::kApplicationData, "SourceCode.pkg", false, GpFileCreationDispositions::kOpenExisting);
|
||||
if (!state.m_sourcePkgStream)
|
||||
return false;
|
||||
|
||||
@@ -730,7 +698,7 @@ bool ExportSourceToStream (GpIOStream *stream)
|
||||
|
||||
void DoExportSourceCode (void)
|
||||
{
|
||||
GpIOStream *stream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::VirtualDirectories::kSourceExport, GP_APPLICATION_NAME "-" GP_APPLICATION_VERSION_STRING "-SourceCode.zip", true, GpFileCreationDispositions::kCreateOrOverwrite);
|
||||
GpIOStream *stream = PLDrivers::GetFileSystem()->OpenFile(PortabilityLayer::VirtualDirectories::kSourceExport, GP_APPLICATION_NAME "-" GP_APPLICATION_VERSION_STRING "-SourceCode.zip", true, GpFileCreationDispositions::kCreateOrOverwrite);
|
||||
if (!stream)
|
||||
return;
|
||||
|
||||
|
@@ -70,9 +70,9 @@ short WhichStringFirst (StringPtr p1, StringPtr p2)
|
||||
{
|
||||
if (!foundIt)
|
||||
{
|
||||
if (p1[0] < p2[0]) // shortest string wins
|
||||
if (p1[0] > p2[0]) // shortest string wins
|
||||
greater = 1;
|
||||
else if (p1[0] > p2[0])
|
||||
else if (p1[0] < p2[0])
|
||||
greater = 2;
|
||||
}
|
||||
foundIt = true;
|
||||
|
@@ -11,13 +11,13 @@
|
||||
#include "PLPasStr.h"
|
||||
#include "PLResources.h"
|
||||
#include "PLSound.h"
|
||||
#include "PLSysCalls.h"
|
||||
#include "PLTimeTaggedVOSEvent.h"
|
||||
#include "QDPixMap.h"
|
||||
#include "BitmapImage.h"
|
||||
#include "DialogManager.h"
|
||||
#include "DisplayDeviceManager.h"
|
||||
#include "Externs.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "IconLoader.h"
|
||||
#include "InputManager.h"
|
||||
#include "ResourceManager.h"
|
||||
@@ -115,9 +115,7 @@ void RedAlert (short errorNumber)
|
||||
// CenterAlert(rDeathAlertID);
|
||||
|
||||
dummyInt = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(rDeathAlertID, &substitutions);
|
||||
//ExitToShell();
|
||||
|
||||
PL_NotYetImplemented_TODO("Exit");
|
||||
PLSysCalls::Exit(-1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- CreateOffScreenBitMap
|
||||
|
@@ -3,6 +3,7 @@
|
||||
enum EGpInputDriverType
|
||||
{
|
||||
EGpInputDriverType_XInput,
|
||||
EGpInputDriverType_SDL2_Gamepad,
|
||||
|
||||
EGpInputDriverType_Count,
|
||||
};
|
||||
|
@@ -2,11 +2,7 @@
|
||||
|
||||
#include "EGpAudioDriverType.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class HostSystemServices;
|
||||
}
|
||||
|
||||
struct IGpSystemServices;
|
||||
struct IGpAudioDriver;
|
||||
struct IGpLogDriver;
|
||||
|
||||
@@ -18,5 +14,5 @@ struct GpAudioDriverProperties
|
||||
bool m_debug;
|
||||
|
||||
IGpLogDriver *m_logger;
|
||||
PortabilityLayer::HostSystemServices *m_systemServices;
|
||||
IGpSystemServices *m_systemServices;
|
||||
};
|
||||
|
@@ -2,8 +2,8 @@
|
||||
|
||||
#define GP_BUILD_VERSION_MAJOR 1
|
||||
#define GP_BUILD_VERSION_MINOR 0
|
||||
#define GP_BUILD_VERSION_UPDATE 9
|
||||
#define GP_BUILD_VERSION_UPDATE 15
|
||||
|
||||
#define GP_APPLICATION_VERSION_STRING "1.0.9"
|
||||
#define GP_APPLICATION_COPYRIGHT_STRING "2019-2020 Eric Lasota"
|
||||
#define GP_APPLICATION_VERSION_STRING "1.0.15"
|
||||
#define GP_APPLICATION_COPYRIGHT_STRING "2019-2021 Eric Lasota"
|
||||
#define GP_APPLICATION_WEBSITE_STRING "https://github.com/elasota/Aerofoil"
|
||||
|
11
GpCommon/GpClipboardContentsType.h
Normal file
11
GpCommon/GpClipboardContentsType.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
namespace GpClipboardContentsTypes
|
||||
{
|
||||
enum GpClipboardContentsType
|
||||
{
|
||||
kText,
|
||||
};
|
||||
}
|
||||
|
||||
typedef GpClipboardContentsTypes::GpClipboardContentsType GpClipboardContentsType_t;
|
@@ -9,11 +9,7 @@ struct IGpDisplayDriver;
|
||||
struct IGpFiber;
|
||||
struct IGpVOSEventQueue;
|
||||
struct IGpLogDriver;
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class HostSystemServices;
|
||||
}
|
||||
struct IGpSystemServices;
|
||||
|
||||
struct GpDisplayDriverProperties
|
||||
{
|
||||
@@ -46,5 +42,5 @@ struct GpDisplayDriverProperties
|
||||
|
||||
IGpVOSEventQueue *m_eventQueue;
|
||||
IGpLogDriver *m_logger;
|
||||
PortabilityLayer::HostSystemServices *m_systemServices;
|
||||
IGpSystemServices *m_systemServices;
|
||||
};
|
||||
|
132
GpCommon/GpDriverIndex.h
Normal file
132
GpCommon/GpDriverIndex.h
Normal file
@@ -0,0 +1,132 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreDefs.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace GpDriverIDs
|
||||
{
|
||||
enum GpDriverID
|
||||
{
|
||||
kAudio,
|
||||
kFileSystem,
|
||||
kDisplay,
|
||||
kLog,
|
||||
kInput,
|
||||
kSystemServices,
|
||||
kFont,
|
||||
kEventQueue,
|
||||
|
||||
kCount
|
||||
};
|
||||
}
|
||||
|
||||
typedef GpDriverIDs::GpDriverID GpDriverID_t;
|
||||
|
||||
template<int T>
|
||||
struct GpDriverIndex
|
||||
{
|
||||
};
|
||||
|
||||
#define GP_DEFINE_DRIVER(driverID, type) \
|
||||
struct type;\
|
||||
template<>\
|
||||
struct GpDriverIndex<GpDriverIDs::driverID>\
|
||||
{\
|
||||
typedef type Type_t;\
|
||||
static const bool kIsMultiDriver = false;\
|
||||
}
|
||||
|
||||
#define GP_DEFINE_MULTI_DRIVER(driverID, type) \
|
||||
struct type;\
|
||||
template<>\
|
||||
struct GpDriverIndex<GpDriverIDs::driverID>\
|
||||
{\
|
||||
typedef type Type_t;\
|
||||
static const bool kIsMultiDriver = true;\
|
||||
}
|
||||
|
||||
GP_DEFINE_DRIVER(kAudio, IGpAudioDriver);
|
||||
GP_DEFINE_DRIVER(kFileSystem, IGpFileSystem);
|
||||
GP_DEFINE_DRIVER(kDisplay, IGpDisplayDriver);
|
||||
GP_DEFINE_DRIVER(kLog, IGpLogDriver);
|
||||
GP_DEFINE_MULTI_DRIVER(kInput, IGpInputDriver);
|
||||
GP_DEFINE_DRIVER(kSystemServices, IGpSystemServices);
|
||||
GP_DEFINE_DRIVER(kFont, IGpFontHandler);
|
||||
GP_DEFINE_DRIVER(kEventQueue, IGpVOSEventQueue);
|
||||
|
||||
struct GpDriverCollection
|
||||
{
|
||||
GpDriverCollection();
|
||||
|
||||
template<GpDriverID_t T>
|
||||
void SetDriver(typename GpDriverIndex<T>::Type_t *driver);
|
||||
|
||||
template<GpDriverID_t T>
|
||||
void SetDrivers(typename GpDriverIndex<T>::Type_t *const* drivers, size_t numDrivers);
|
||||
|
||||
template<GpDriverID_t T>
|
||||
typename GpDriverIndex<T>::Type_t *GetDriver() const;
|
||||
|
||||
template<GpDriverID_t T>
|
||||
typename GpDriverIndex<T>::Type_t *GetDriver(size_t index) const;
|
||||
|
||||
template<GpDriverID_t T>
|
||||
size_t GetDriverCount() const;
|
||||
|
||||
private:
|
||||
struct DriverEntry
|
||||
{
|
||||
void *m_value;
|
||||
size_t m_numDrivers;
|
||||
};
|
||||
|
||||
DriverEntry m_drivers[GpDriverIDs::kCount];
|
||||
};
|
||||
|
||||
inline GpDriverCollection::GpDriverCollection()
|
||||
{
|
||||
for (int i = 0; i < GpDriverIDs::kCount; i++)
|
||||
{
|
||||
this->m_drivers[i].m_value = nullptr;
|
||||
this->m_drivers[i].m_numDrivers = 0;
|
||||
}
|
||||
}
|
||||
|
||||
template<GpDriverID_t T>
|
||||
void GpDriverCollection::SetDriver(typename GpDriverIndex<T>::Type_t *driver)
|
||||
{
|
||||
GP_STATIC_ASSERT(!GpDriverIndex<T>::kIsMultiDriver);
|
||||
m_drivers[T].m_numDrivers = 1;
|
||||
m_drivers[T].m_value = driver;
|
||||
}
|
||||
|
||||
template<GpDriverID_t T>
|
||||
void GpDriverCollection::SetDrivers(typename GpDriverIndex<T>::Type_t *const* drivers, size_t numDrivers)
|
||||
{
|
||||
GP_STATIC_ASSERT(GpDriverIndex<T>::kIsMultiDriver);
|
||||
m_drivers[T].m_numDrivers = numDrivers;
|
||||
m_drivers[T].m_value = const_cast<typename GpDriverIndex<T>::Type_t **>(drivers);
|
||||
}
|
||||
|
||||
template<GpDriverID_t T>
|
||||
inline typename GpDriverIndex<T>::Type_t *GpDriverCollection::GetDriver() const
|
||||
{
|
||||
GP_STATIC_ASSERT(!GpDriverIndex<T>::kIsMultiDriver);
|
||||
return static_cast<typename GpDriverIndex<T>::Type_t*>(this->m_drivers[T].m_value);
|
||||
}
|
||||
|
||||
template<GpDriverID_t T>
|
||||
inline typename GpDriverIndex<T>::Type_t *GpDriverCollection::GetDriver(size_t index) const
|
||||
{
|
||||
GP_STATIC_ASSERT(GpDriverIndex<T>::kIsMultiDriver);
|
||||
return static_cast<typename GpDriverIndex<T>::Type_t*const*>(this->m_drivers[T].m_value)[index];
|
||||
}
|
||||
|
||||
|
||||
template<GpDriverID_t T>
|
||||
size_t GpDriverCollection::GetDriverCount() const
|
||||
{
|
||||
GP_STATIC_ASSERT(GpDriverIndex<T>::kIsMultiDriver);
|
||||
return this->m_drivers[T].m_numDrivers;
|
||||
}
|
@@ -13,9 +13,23 @@ public:
|
||||
virtual bool SeekStart(GpUFilePos_t loc) = 0;
|
||||
virtual bool SeekCurrent(GpFilePos_t loc) = 0;
|
||||
virtual bool SeekEnd(GpUFilePos_t loc) = 0;
|
||||
virtual bool Truncate(GpUFilePos_t loc) = 0;
|
||||
virtual GpUFilePos_t Size() const = 0;
|
||||
virtual GpUFilePos_t Tell() const = 0;
|
||||
virtual void Close() = 0;
|
||||
virtual void Flush() = 0;
|
||||
|
||||
bool ReadExact(void *bytesOut, size_t size);
|
||||
bool WriteExact(const void *bytesOut, size_t size);
|
||||
};
|
||||
|
||||
inline bool GpIOStream::ReadExact(void *bytesOut, size_t size)
|
||||
{
|
||||
const size_t nRead = this->Read(bytesOut, size);
|
||||
return nRead == size;
|
||||
}
|
||||
|
||||
inline bool GpIOStream::WriteExact(const void *bytes, size_t size)
|
||||
{
|
||||
const size_t nWritten = this->Write(bytes, size);
|
||||
return nWritten == size;
|
||||
}
|
||||
|
16
GpCommon/IGpClipboardContents.h
Normal file
16
GpCommon/IGpClipboardContents.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "GpClipboardContentsType.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct IGpClipboardContents
|
||||
{
|
||||
virtual GpClipboardContentsType_t GetContentsType() const = 0;
|
||||
virtual void Destroy() = 0;
|
||||
virtual IGpClipboardContents *Clone() const = 0;
|
||||
};
|
||||
|
||||
struct IGpClipboardContentsText : public IGpClipboardContents
|
||||
{
|
||||
virtual const uint8_t *GetBytes() const = 0;
|
||||
virtual size_t GetSize() const = 0; // In bytes
|
||||
};
|
8
GpCommon/IGpDirectoryCursor.h
Normal file
8
GpCommon/IGpDirectoryCursor.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
struct IGpDirectoryCursor
|
||||
{
|
||||
public:
|
||||
virtual bool GetNext(const char *&outFileName) = 0;
|
||||
virtual void Destroy() = 0;
|
||||
};
|
@@ -31,7 +31,8 @@ struct IGpDisplayDriver
|
||||
virtual void Run() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
virtual void GetDisplayResolution(unsigned int *width, unsigned int *height) = 0;
|
||||
// Returns the initial resolution before any display resolution events are posted
|
||||
virtual void GetInitialDisplayResolution(unsigned int *width, unsigned int *height) = 0;
|
||||
|
||||
virtual IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, size_t pitch, GpPixelFormat_t pixelFormat, SurfaceInvalidateCallback_t invalidateCallback, void *invalidateContext) = 0;
|
||||
virtual void DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height, const GpDisplayDriverSurfaceEffects *effects) = 0;
|
||||
|
42
GpCommon/IGpFileSystem.h
Normal file
42
GpCommon/IGpFileSystem.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include "GpFileCreationDisposition.h"
|
||||
#include "VirtualDirectory.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class GpIOStream;
|
||||
struct IGpThreadRelay;
|
||||
struct IGpDirectoryCursor;
|
||||
|
||||
struct IGpFileSystem
|
||||
{
|
||||
public:
|
||||
typedef void(*DelayCallback_t)(uint32_t ticks);
|
||||
|
||||
virtual bool FileExists(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path) = 0;
|
||||
virtual bool FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &exists) = 0;
|
||||
virtual GpIOStream *OpenFileNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* subPaths, size_t numSubPaths, bool writeAccess, GpFileCreationDisposition_t createDisposition) = 0;
|
||||
virtual bool DeleteFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &existed) = 0;
|
||||
virtual IGpDirectoryCursor *ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths) = 0;
|
||||
|
||||
virtual bool ValidateFilePath(const char *path, size_t pathLen) const = 0;
|
||||
virtual bool ValidateFilePathUnicodeChar(uint32_t ch) const = 0;
|
||||
|
||||
virtual void SetMainThreadRelay(IGpThreadRelay *relay) = 0;
|
||||
virtual void SetDelayCallback(DelayCallback_t delayCallback) = 0;
|
||||
|
||||
// Helpers
|
||||
GpIOStream *OpenFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool writeAccess, GpFileCreationDisposition_t createDisposition);
|
||||
IGpDirectoryCursor *ScanDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory);
|
||||
};
|
||||
|
||||
inline GpIOStream *IGpFileSystem::OpenFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool writeAccess, GpFileCreationDisposition_t createDisposition)
|
||||
{
|
||||
return this->OpenFileNested(virtualDirectory, &path, 1, writeAccess, createDisposition);
|
||||
}
|
||||
|
||||
inline IGpDirectoryCursor *IGpFileSystem::ScanDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory)
|
||||
{
|
||||
return this->ScanDirectoryNested(virtualDirectory, nullptr, 0);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user