Compare commits

...

76 Commits

Author SHA1 Message Date
elasota
2fe1ea2ee7 Fix objects being draggable when there is no room 2021-03-08 21:59:11 -05:00
elasota
0931f25f23 Fix wrong house sort order 2021-03-08 21:58:46 -05:00
elasota
7f4d782c0d Fix room count mismatch 2021-03-08 21:58:34 -05:00
elasota
f2cda23b0f Bump version to 1.0.15 2021-03-08 19:08:12 -05:00
elasota
6292705968 Fix insensitive compare not working properly with strings of different length 2021-03-08 19:07:31 -05:00
elasota
6931b3f505 EOL fix 2021-03-08 19:07:06 -05:00
elasota
d70a5b3bfc Add more optimizations 2021-03-07 05:45:24 -05:00
elasota
f0913d0d6a Add MergeGPF to installer project 2021-03-07 05:37:29 -05:00
elasota
80584eb781 Fix California or Bust! house on Android 2021-03-07 05:16:15 -05:00
elasota
fe4a8a55c6 Don't partially delete house when overwriting the current house 2021-03-07 05:08:01 -05:00
elasota
55ec6c516c Fix overwrite warnings not working 2021-03-07 05:07:23 -05:00
elasota
3917e1a370 File system refactor, bug fixes 2021-03-07 04:31:05 -05:00
elasota
6715bcb030 Fix music playing in the editor 2021-03-06 11:34:47 -05:00
elasota
c981a97a20 Fix fullscreen prefs not working in SDL. Add SDL GameController support. 2021-03-05 01:56:32 -05:00
elasota
a5562f96e0 Move portable things to AerofoilPortable. 2021-03-05 00:35:43 -05:00
elasota
d97bd8ad1c Move some C++11 types from Android to AerofoilSDL. 2021-03-01 01:06:56 -05:00
elasota
a43f32ab88 Fix trademark usage 2021-03-01 00:40:30 -05:00
elasota
e94d1511b1 Add 32-bit support to SDL version 2021-02-28 23:31:13 -05:00
elasota
95e4eb4e34 Bump version to 1.0.14, update copyright year 2021-02-28 23:01:53 -05:00
elasota
15bdb97c38 Add volume control to SDL audio driver. 2021-02-28 22:58:01 -05:00
elasota
e7246c1444 Reduce marquee speed 2021-02-20 15:26:44 -05:00
elasota
35b8e922d7 Fix Windows size minimum not working correctly 2021-02-20 15:16:47 -05:00
elasota
3090f70ee6 Bump version to 1.0.13 2021-02-20 15:16:31 -05:00
elasota
484e18a9af Fix resolution desync if resize occurs during the loading screen. 2021-02-20 15:11:31 -05:00
elasota
83d37a7c94 Add system clipboard support to Windows 2020-12-18 00:07:21 -05:00
elasota
fc043af3a1 Bump version to 1.0.12 2020-12-18 00:02:52 -05:00
elasota
2ebd3f2cf3 Whole-word selection in editboxes 2020-12-17 19:49:09 -05:00
elasota
ebab2ee188 Fix incorrect carat pulse timing 2020-12-17 19:48:57 -05:00
elasota
032e44d981 Fix some missing dependencies of ReleasePackageInstaller necessary to import resources. 2020-11-30 23:32:50 -05:00
elasota
7961ca3af7 Fixed some more cases where the screen resolution could become desynced during startup. 2020-11-30 19:02:42 -05:00
elasota
6851025147 Preload entire font file if the font file isn't efficiently seekable, which should fix very slow startup times on Android. 2020-11-30 18:43:17 -05:00
elasota
f0b1d6fff9 Add memory buffer stream 2020-11-30 18:42:35 -05:00
elasota
70e0948847 Log initial resolution 2020-11-30 18:42:22 -05:00
elasota
a698286087 Adjust disclaimer 2020-11-30 10:27:01 -05:00
elasota
b75313fd7b Commit resolution changes 2020-11-30 03:50:57 -05:00
elasota
cab862ed8b Fix exit to shell not working 2020-11-30 03:18:09 -05:00
elasota
553e343abe Fix display resolution desynchronizing with auto-position 2020-11-30 02:59:02 -05:00
elasota
0aa36b27a9 Remove Bluetooth and vibrate permissions 2020-11-30 00:24:58 -05:00
elasota
f6185b1c78 Bump version to 1.0.11 2020-11-30 00:24:23 -05:00
elasota
ff29d5b92c Updated disclaimer 2020-11-30 00:11:21 -05:00
elasota
964c9b8858 Reduce load ring images to grayscale 2020-11-28 11:46:07 -05:00
elasota
8a48726b2e Compress cached fonts 2020-11-28 11:45:51 -05:00
elasota
de06669239 Fix read overrun 2020-11-28 11:45:29 -05:00
elasota
c0abd77dc4 Add source package to PackageReleaseArchives (for itch.io distro) 2020-11-25 18:42:08 -05:00
elasota
754b988f09 Fix initial launch disclaimer always displaying 2020-11-25 18:12:31 -05:00
elasota
1c57a51316 Fix wrong house name displaying after quitting demo 2020-11-25 18:12:00 -05:00
elasota
80abb498af Add first-time launch disclaimer 2020-11-25 18:09:09 -05:00
elasota
29cc376438 Remove trademark symbols since there does not appear to be, or have ever been, a registered trademark. 2020-11-25 15:57:11 -05:00
elasota
ef12c471a7 Fix missing directory entries for resource additions that have no existing directory (i.e. LICS) 2020-11-25 15:51:12 -05:00
elasota
8f4ecfafe1 Speed up load screen 2020-11-25 15:35:12 -05:00
elasota
3c3f9e3675 Add 2-stage startup for mobile init so there's less black screen 2020-11-25 15:09:31 -05:00
elasota
5c640b72eb Code cleanup, move a lot of "Host" APIs to GpCommon 2020-11-25 12:05:59 -05:00
elasota
9d0f2c35b3 Bump version to 1.0.10 2020-11-24 09:42:25 -05:00
elasota
7df624d9b1 Remove "Empty House" (which is locked) and "Sampler" from distribution. 2020-11-24 09:39:43 -05:00
elasota
29fbe83e8d Remove sounds with questionable license status 2020-11-24 09:35:25 -05:00
elasota
ad3a878a16 Added pause to Android source copy script to check if it fails 2020-11-24 09:34:27 -05:00
elasota
f0e7379db6 Increase Android build number 2020-11-13 21:04:34 -05:00
elasota
e34fec38a2 Update readme with new platforms 2020-11-13 16:32:20 -05:00
elasota
76db422456 Fix define collision 2020-11-13 00:57:59 -05:00
elasota
396d107608 Bump Gradle to 4.1.1 2020-11-13 00:55:07 -05:00
elasota
30b39c6991 Add AA table caching 2020-11-13 00:52:10 -05:00
elasota
9dafba1092 Add cancel option to save game prompt 2020-11-12 19:16:47 -05:00
elasota
801408077a Use SV_POSITION instead to compute pixel coordinates instead of fiddling with the polygon. This should fix the image being offset by 1 pixel. 2020-11-12 19:15:50 -05:00
elasota
2c073937c3 Fix houses not being read-only in itch.io release 2020-11-12 19:13:22 -05:00
elasota
bbd147e1ab Fix broken shader compiler 2020-11-12 19:12:53 -05:00
elasota
66a111dd23 Restrict file browser UI by file type 2020-11-12 02:35:07 -05:00
elasota
2febed5d2a Remove "Export Source Code..." menu item 2020-11-12 01:50:36 -05:00
elasota
b47813330a EOL fixes 2020-11-10 20:05:11 -05:00
elasota
0f630a74a2 Add file details 2020-11-10 20:04:29 -05:00
elasota
edc43e0bed Remove crtdbg.h 2020-11-10 20:04:08 -05:00
elasota
2aca0b6b28 Move high scores up to fix overlap on some mobile resolutions 2020-11-10 19:02:18 -05:00
elasota
f9a101486c Add delete to resume game UI 2020-11-09 01:57:49 -05:00
elasota
dbf3303145 Preload AA tables to speed up high scores screen on mobile. 2020-11-09 00:05:01 -05:00
elasota
a28a4cd73d Clean up warnings 2020-11-08 13:40:47 -05:00
elasota
4c6e646133 Clean up language so we can bundle source without getting dinged on age rating. 2020-11-06 17:51:58 -05:00
elasota
a13f90bd71 Fix upscale filter crash 2020-11-04 17:44:22 -05:00
229 changed files with 6870 additions and 3454 deletions

View File

@@ -46,6 +46,9 @@ EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "ReleasePackageInstaller", "ReleasePackageInstaller\ReleasePackageInstaller.wixproj", "{D26BD501-28A7-4849-8130-FB5EA0A2B82F}" Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "ReleasePackageInstaller", "ReleasePackageInstaller\ReleasePackageInstaller.wixproj", "{D26BD501-28A7-4849-8130-FB5EA0A2B82F}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{7EFF1E21-C375-45EA-A069-4E2232C8A72B} = {7EFF1E21-C375-45EA-A069-4E2232C8A72B} {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 EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WindowsUnicodeToolShim", "WindowsUnicodeToolShim\WindowsUnicodeToolShim.vcxproj", "{15009625-1120-405E-8BBA-69A16CD6713D}" 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 EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AerofoilSDL", "AerofoilSDL\AerofoilSDL.vcxproj", "{33542FF0-0473-4802-BC79-3B8261790F65}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AerofoilSDL", "AerofoilSDL\AerofoilSDL.vcxproj", "{33542FF0-0473-4802-BC79-3B8261790F65}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MergeGPF", "MergeGPF\MergeGPF.vcxproj", "{36DAF5FA-6ADB-4F20-9810-1610DE0AE653}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 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}.Debug|x64.Build.0 = Debug|x64
{33542FF0-0473-4802-BC79-3B8261790F65}.Release|x64.ActiveCfg = Release|x64 {33542FF0-0473-4802-BC79-3B8261790F65}.Release|x64.ActiveCfg = Release|x64
{33542FF0-0473-4802-BC79-3B8261790F65}.Release|x64.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -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 lowLimit;
ULONG_PTR highLimit; ULONG_PTR highLimit;

View File

@@ -99,24 +99,6 @@ bool GpFileStream_Win32::SeekEnd(GpUFilePos_t loc)
return SetFilePointerEx(m_handle, li, nullptr, FILE_END) != 0; 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 GpUFilePos_t GpFileStream_Win32::Size() const
{ {
LARGE_INTEGER fsize; LARGE_INTEGER fsize;

View File

@@ -17,7 +17,6 @@ public:
bool SeekStart(GpUFilePos_t loc) override; bool SeekStart(GpUFilePos_t loc) override;
bool SeekCurrent(GpFilePos_t loc) override; bool SeekCurrent(GpFilePos_t loc) override;
bool SeekEnd(GpUFilePos_t loc) override; bool SeekEnd(GpUFilePos_t loc) override;
bool Truncate(GpUFilePos_t loc) override;
GpUFilePos_t Size() const override; GpUFilePos_t Size() const override;
GpUFilePos_t Tell() const override; GpUFilePos_t Tell() const override;
void Close() override; void Close() override;

View File

@@ -3,8 +3,7 @@
#include "GpApplicationName.h" #include "GpApplicationName.h"
#include "GpFileStream_Win32.h" #include "GpFileStream_Win32.h"
#include "GpWindows.h" #include "GpWindows.h"
#include "GpMemoryBuffer.h" #include "IGpDirectoryCursor.h"
#include "HostDirectoryCursor.h"
#include <string> #include <string>
#include <Shlwapi.h> #include <Shlwapi.h>
@@ -15,7 +14,7 @@
extern GpWindowsGlobals g_gpWindowsGlobals; extern GpWindowsGlobals g_gpWindowsGlobals;
class GpDirectoryCursor_Win32 final : public PortabilityLayer::HostDirectoryCursor class GpDirectoryCursor_Win32 final : public IGpDirectoryCursor
{ {
public: public:
static GpDirectoryCursor_Win32 *Create(const HANDLE &handle, const WIN32_FIND_DATAW &findData); 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; 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]; wchar_t winPath[MAX_PATH + 1];
if (!ResolvePath(virtualDirectory, &path, 1, winPath)) if (!ResolvePath(virtualDirectory, &path, 1, winPath))
{ {
*exists = false; exists = false;
return false; return false;
} }
DWORD attribs = GetFileAttributesW(winPath); DWORD attribs = GetFileAttributesW(winPath);
if (attribs == INVALID_FILE_ATTRIBUTES) if (attribs == INVALID_FILE_ATTRIBUTES)
{ {
*exists = false; exists = false;
return false; return false;
} }
*exists = true; exists = true;
return (attribs & FILE_ATTRIBUTE_READONLY) != 0; return (attribs & FILE_ATTRIBUTE_READONLY) != 0;
} }
@@ -273,7 +272,7 @@ bool GpFileSystem_Win32::DeleteFile(PortabilityLayer::VirtualDirectory_t virtual
return false; 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]; wchar_t winPath[MAX_PATH + 2];
@@ -320,11 +319,6 @@ bool GpFileSystem_Win32::ValidateFilePathUnicodeChar(uint32_t c) const
return false; return false;
} }
bool GpFileSystem_Win32::IsVirtualDirectoryLooseResources(PortabilityLayer::VirtualDirectory_t virtualDir) const
{
return false;
}
void GpFileSystem_Win32::SetMainThreadRelay(IGpThreadRelay *relay) void GpFileSystem_Win32::SetMainThreadRelay(IGpThreadRelay *relay)
{ {
(void)relay; (void)relay;
@@ -342,7 +336,7 @@ bool GpFileSystem_Win32::ValidateFilePath(const char *str, size_t length) const
if (c >= '0' && c <= '9') if (c >= '0' && c <= '9')
continue; continue;
if (c == '_' || c == '.' || c == '\'') if (c == '_' || c == '.' || c == '\'' || c == '!')
continue; continue;
if (c == ' ' && i != 0 && i != length - 1) if (c == ' ' && i != 0 && i != length - 1)

View File

@@ -1,28 +1,26 @@
#pragma once #pragma once
#include "HostFileSystem.h" #include "IGpFileSystem.h"
#include "GpCoreDefs.h" #include "GpCoreDefs.h"
#include "GpWindows.h" #include "GpWindows.h"
#include <string> #include <string>
class GpFileSystem_Win32 final : public PortabilityLayer::HostFileSystem class GpFileSystem_Win32 final : public IGpFileSystem
{ {
public: public:
GpFileSystem_Win32(); GpFileSystem_Win32();
bool FileExists(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path) override; 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; 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; 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 ValidateFilePath(const char *path, size_t sz) const override;
bool ValidateFilePathUnicodeChar(uint32_t ch) const override; bool ValidateFilePathUnicodeChar(uint32_t ch) const override;
bool IsVirtualDirectoryLooseResources(PortabilityLayer::VirtualDirectory_t virtualDir) const override;
void SetMainThreadRelay(IGpThreadRelay *relay) override; void SetMainThreadRelay(IGpThreadRelay *relay) override;
void SetDelayCallback(DelayCallback_t delayCallback) override; void SetDelayCallback(DelayCallback_t delayCallback) override;

View File

@@ -12,10 +12,9 @@
#include "GpAppInterface.h" #include "GpAppInterface.h"
#include "GpSystemServices_Win32.h" #include "GpSystemServices_Win32.h"
#include "GpVOSEvent.h" #include "GpVOSEvent.h"
#include "IGpFileSystem.h"
#include "IGpVOSEventQueue.h" #include "IGpVOSEventQueue.h"
#include "HostFileSystem.h"
#include "GpWindows.h" #include "GpWindows.h"
#include "resource.h" #include "resource.h"
@@ -414,9 +413,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
IGpLogDriver *logger = GpLogDriver_Win32::GetInstance(); IGpLogDriver *logger = GpLogDriver_Win32::GetInstance();
GpAppInterface_Get()->PL_HostFileSystem_SetInstance(GpFileSystem_Win32::GetInstance()); GpDriverCollection *drivers = GpAppInterface_Get()->PL_GetDriverCollection();
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_hInstance = hInstance;
g_gpWindowsGlobals.m_hPrevInstance = hPrevInstance; g_gpWindowsGlobals.m_hPrevInstance = hPrevInstance;

View File

@@ -1,10 +1,10 @@
#pragma once #pragma once
#include "HostMutex.h" #include "IGpMutex.h"
#include "GpWindows.h" #include "GpWindows.h"
class GpMutex_Win32 final : public PortabilityLayer::HostMutex class GpMutex_Win32 final : public IGpMutex
{ {
public: public:
void Destroy() override; void Destroy() override;

View File

@@ -1,19 +1,122 @@
#include "GpSystemServices_Win32.h" #include "GpSystemServices_Win32.h"
#include "GpMutex_Win32.h" #include "GpMutex_Win32.h"
#include "GpThreadEvent_Win32.h" #include "GpThreadEvent_Win32.h"
#include "GpWindows.h"
#include "IGpClipboardContents.h"
#include "UTF16.h"
#include "UTF8.h"
#include <assert.h> #include <assert.h>
#include <vector>
#pragma push_macro("CreateMutex") #pragma push_macro("CreateMutex")
#ifdef CreateMutex #ifdef CreateMutex
#undef CreateMutex #undef CreateMutex
#endif #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 struct GpSystemServices_Win32_ThreadStartParams
{ {
GpSystemServices_Win32::ThreadFunc_t m_threadFunc; GpSystemServices_Win32::ThreadFunc_t m_threadFunc;
void *m_threadContext; void *m_threadContext;
PortabilityLayer::HostThreadEvent *m_threadStartEvent; IGpThreadEvent *m_threadStartEvent;
}; };
static DWORD WINAPI StaticStartThread(LPVOID lpThreadParameter) static DWORD WINAPI StaticStartThread(LPVOID lpThreadParameter)
@@ -22,7 +125,7 @@ static DWORD WINAPI StaticStartThread(LPVOID lpThreadParameter)
GpSystemServices_Win32::ThreadFunc_t threadFunc = threadParams->m_threadFunc; GpSystemServices_Win32::ThreadFunc_t threadFunc = threadParams->m_threadFunc;
void *threadContext = threadParams->m_threadContext; void *threadContext = threadParams->m_threadContext;
PortabilityLayer::HostThreadEvent *threadStartEvent = threadParams->m_threadStartEvent; IGpThreadEvent *threadStartEvent = threadParams->m_threadStartEvent;
threadStartEvent->Signal(); threadStartEvent->Signal();
@@ -34,6 +137,10 @@ GpSystemServices_Win32::GpSystemServices_Win32()
{ {
} }
GpSystemServices_Win32::~GpSystemServices_Win32()
{
}
int64_t GpSystemServices_Win32::GetTime() const int64_t GpSystemServices_Win32::GetTime() const
{ {
SYSTEMTIME epochStart; SYSTEMTIME epochStart;
@@ -72,24 +179,24 @@ void GpSystemServices_Win32::GetLocalDateTime(unsigned int &year, unsigned int &
second = localTime.wSecond; second = localTime.wSecond;
} }
PortabilityLayer::HostMutex *GpSystemServices_Win32::CreateMutex() IGpMutex *GpSystemServices_Win32::CreateMutex()
{ {
return GpMutex_Win32::Create(); return GpMutex_Win32::Create();
} }
PortabilityLayer::HostMutex *GpSystemServices_Win32::CreateRecursiveMutex() IGpMutex *GpSystemServices_Win32::CreateRecursiveMutex()
{ {
return GpMutex_Win32::Create(); 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); return GpThreadEvent_Win32::Create(autoReset, startSignaled);
} }
void *GpSystemServices_Win32::CreateThread(ThreadFunc_t threadFunc, void *context) void *GpSystemServices_Win32::CreateThread(ThreadFunc_t threadFunc, void *context)
{ {
PortabilityLayer::HostThreadEvent *evt = CreateThreadEvent(true, false); IGpThreadEvent *evt = CreateThreadEvent(true, false);
if (!evt) if (!evt)
return nullptr; return nullptr;
@@ -144,6 +251,16 @@ bool GpSystemServices_Win32::IsTextInputObstructive() const
return false; return false;
} }
bool GpSystemServices_Win32::IsFullscreenPreferred() const
{
return !m_isTouchscreenSimulation;
}
bool GpSystemServices_Win32::IsFullscreenOnStartup() const
{
return false;
}
unsigned int GpSystemServices_Win32::GetCPUCount() const unsigned int GpSystemServices_Win32::GetCPUCount() const
{ {
SYSTEM_INFO sysInfo; SYSTEM_INFO sysInfo;
@@ -161,6 +278,95 @@ bool GpSystemServices_Win32::IsTextInputEnabled() const
return true; 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) void GpSystemServices_Win32::SetTouchscreenSimulation(bool isTouchscreenSimulation)
{ {
m_isTouchscreenSimulation = isTouchscreenSimulation; m_isTouchscreenSimulation = isTouchscreenSimulation;

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include "HostSystemServices.h" #include "IGpSystemServices.h"
#include "GpCoreDefs.h" #include "GpCoreDefs.h"
#include "GpWindows.h" #include "GpWindows.h"
@@ -15,25 +15,31 @@
#endif #endif
class GpSystemServices_Win32 final : public PortabilityLayer::HostSystemServices class GpSystemServices_Win32 final : public IGpSystemServices
{ {
public: public:
GpSystemServices_Win32(); GpSystemServices_Win32();
~GpSystemServices_Win32();
int64_t GetTime() const override; 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; 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; IGpMutex *CreateMutex() override;
PortabilityLayer::HostMutex *CreateRecursiveMutex() override; IGpMutex *CreateRecursiveMutex() override;
void *CreateThread(ThreadFunc_t threadFunc, void *context) 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; uint64_t GetFreeMemoryCosmetic() const override;
void Beep() const override; void Beep() const override;
bool IsTouchscreen() const override; bool IsTouchscreen() const override;
bool IsUsingMouseAsTouch() const override; bool IsUsingMouseAsTouch() const override;
bool IsTextInputObstructive() const override; bool IsTextInputObstructive() const override;
bool IsFullscreenPreferred() const override;
bool IsFullscreenOnStartup() const override;
unsigned int GetCPUCount() const override; unsigned int GetCPUCount() const override;
void SetTextInputEnabled(bool isEnabled) override; void SetTextInputEnabled(bool isEnabled) override;
bool IsTextInputEnabled() const override; bool IsTextInputEnabled() const override;
bool AreFontResourcesSeekable() const override;
IGpClipboardContents *GetClipboardContents() const override;
void SetClipboardContents(IGpClipboardContents *contents) override;
void SetTouchscreenSimulation(bool isTouchscreenSimulation); void SetTouchscreenSimulation(bool isTouchscreenSimulation);

View File

@@ -1,10 +1,10 @@
#pragma once #pragma once
#include "HostThreadEvent.h" #include "IGpThreadEvent.h"
#include "GpWindows.h" #include "GpWindows.h"
class GpThreadEvent_Win32 final : public PortabilityLayer::HostThreadEvent class GpThreadEvent_Win32 final : public IGpThreadEvent
{ {
public: public:
void Wait() override; void Wait() override;

View File

@@ -15,8 +15,8 @@ android {
} }
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 29 targetSdkVersion 29
versionCode 4 versionCode 11
versionName "1.0.9b2" versionName "1.0.15"
externalNativeBuild { externalNativeBuild {
ndkBuild { ndkBuild {
arguments "APP_PLATFORM=android-16" arguments "APP_PLATFORM=android-16"
@@ -66,7 +66,7 @@ android {
} }
aaptOptions { aaptOptions {
noCompress 'gpa' noCompress 'gpf'
} }
} }

View File

@@ -0,0 +1 @@
../../../AerofoilPortable

View File

@@ -9,6 +9,7 @@ SDL_PATH := ../SDL
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include \ LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include \
$(LOCAL_PATH)/../GpShell \ $(LOCAL_PATH)/../GpShell \
$(LOCAL_PATH)/../GpCommon \ $(LOCAL_PATH)/../GpCommon \
$(LOCAL_PATH)/../AerofoilPortable \
$(LOCAL_PATH)/../AerofoilSDL \ $(LOCAL_PATH)/../AerofoilSDL \
$(LOCAL_PATH)/../Common \ $(LOCAL_PATH)/../Common \
$(LOCAL_PATH)/../PortabilityLayer $(LOCAL_PATH)/../PortabilityLayer
@@ -23,7 +24,7 @@ LOCAL_SRC_FILES := \
LOCAL_SHARED_LIBRARIES := SDL2 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 LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog

View File

@@ -1,12 +1,14 @@
#define _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE
#include "GpFileSystem_Android.h" #include "GpFileSystem_Android.h"
#include "GpIOStream.h" #include "GpIOStream.h"
#include "HostDirectoryCursor.h" #include "IGpDirectoryCursor.h"
#include "HostSystemServices.h" #include "IGpSystemServices.h"
#include "HostMutex.h" #include "IGpMutex.h"
#include "IGpThreadRelay.h" #include "IGpThreadRelay.h"
#include "VirtualDirectory.h" #include "VirtualDirectory.h"
#include "PLDrivers.h"
#include "SDL.h" #include "SDL.h"
#include "SDL_rwops.h" #include "SDL_rwops.h"
@@ -40,7 +42,6 @@ public:
bool SeekStart(GpUFilePos_t loc) override; bool SeekStart(GpUFilePos_t loc) override;
bool SeekCurrent(GpFilePos_t loc) override; bool SeekCurrent(GpFilePos_t loc) override;
bool SeekEnd(GpUFilePos_t loc) override; bool SeekEnd(GpUFilePos_t loc) override;
bool Truncate(GpUFilePos_t loc) override;
GpUFilePos_t Size() const override; GpUFilePos_t Size() const override;
GpUFilePos_t Tell() const override; GpUFilePos_t Tell() const override;
void Close() override; void Close() override;
@@ -68,7 +69,6 @@ public:
bool SeekStart(GpUFilePos_t loc) override; bool SeekStart(GpUFilePos_t loc) override;
bool SeekCurrent(GpFilePos_t loc) override; bool SeekCurrent(GpFilePos_t loc) override;
bool SeekEnd(GpUFilePos_t loc) override; bool SeekEnd(GpUFilePos_t loc) override;
bool Truncate(GpUFilePos_t loc) override;
GpUFilePos_t Size() const override; GpUFilePos_t Size() const override;
GpUFilePos_t Tell() const override; GpUFilePos_t Tell() const override;
void Close() override; void Close() override;
@@ -94,7 +94,6 @@ public:
bool SeekStart(GpUFilePos_t loc) override; bool SeekStart(GpUFilePos_t loc) override;
bool SeekCurrent(GpFilePos_t loc) override; bool SeekCurrent(GpFilePos_t loc) override;
bool SeekEnd(GpUFilePos_t loc) override; bool SeekEnd(GpUFilePos_t loc) override;
bool Truncate(GpUFilePos_t loc) override;
GpUFilePos_t Size() const override; GpUFilePos_t Size() const override;
GpUFilePos_t Tell() const override; GpUFilePos_t Tell() const override;
void Close() override; void Close() override;
@@ -166,11 +165,6 @@ bool GpFileStream_PFD::SeekEnd(GpUFilePos_t loc)
return lseek64(m_fd, loc, SEEK_END) >= 0; 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 GpUFilePos_t GpFileStream_PFD::Size() const
{ {
struct stat64 s; 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; 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 GpUFilePos_t GpFileStream_SDLRWops::Size() const
{ {
return m_rw->size(m_rw); 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; 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 GpUFilePos_t GpFileStream_Android_File::Size() const
{ {
fflush(m_f); 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) bool GpFileSystem_Android::OpenSourceExportFD(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *const *paths, size_t numPaths, int &fd, jobject &pfd)
{ {
if (!m_sourceExportMutex) if (!m_sourceExportMutex)
m_sourceExportMutex = PortabilityLayer::HostSystemServices::GetInstance()->CreateMutex(); m_sourceExportMutex = PLDrivers::GetSystemServices()->CreateMutex();
m_sourceExportWaiting = true; m_sourceExportWaiting = true;
m_sourceExportCancelled = false; m_sourceExportCancelled = false;
@@ -550,26 +533,26 @@ bool GpFileSystem_Android::FileExists(PortabilityLayer::VirtualDirectory_t virtu
return stat(resolvedPath.c_str(), &s) == 0; 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; std::string resolvedPath;
bool isAsset; bool isAsset;
if (!ResolvePath(virtualDirectory, &path, 1, resolvedPath, isAsset)) if (!ResolvePath(virtualDirectory, &path, 1, resolvedPath, isAsset))
{ {
if (exists) if (exists)
*exists = false; exists = false;
return false; return false;
} }
if (isAsset) if (isAsset)
{ {
if (exists) if (exists)
*exists = this->FileExists(virtualDirectory, path); exists = this->FileExists(virtualDirectory, path);
return true; return true;
} }
int permissions = access(resolvedPath.c_str(), W_OK | F_OK); 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); return ((permissions & W_OK) != 0);
} }
@@ -696,7 +679,7 @@ bool GpFileSystem_Android::DeleteFile(PortabilityLayer::VirtualDirectory_t virtu
return true; 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; ScanDirectoryNestedContext ctx;
ctx.m_this = this; 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); 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) if (virtualDirectory == PortabilityLayer::VirtualDirectories::kGameData || virtualDirectory == PortabilityLayer::VirtualDirectories::kApplicationData)
return ScanAssetDirectory(virtualDirectory, paths, numPaths); 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') if (c >= '0' && c <= '9')
continue; continue;
if (c == '_' || c == '.' || c == '\'') if (c == '_' || c == '.' || c == '\'' || c == '!')
continue; continue;
if (c == ' ' && i != 0 && i != length - 1) if (c == ' ' && i != 0 && i != length - 1)
@@ -769,11 +752,6 @@ bool GpFileSystem_Android::ValidateFilePathUnicodeChar(uint32_t c) const
return false; return false;
} }
bool GpFileSystem_Android::IsVirtualDirectoryLooseResources(PortabilityLayer::VirtualDirectory_t virtualDir) const
{
return false;
}
void GpFileSystem_Android::SetMainThreadRelay(IGpThreadRelay *relay) void GpFileSystem_Android::SetMainThreadRelay(IGpThreadRelay *relay)
{ {
m_relay = relay; m_relay = relay;
@@ -809,7 +787,7 @@ GpFileSystem_Android *GpFileSystem_Android::GetInstance()
return &ms_instance; return &ms_instance;
} }
class GpDirectoryCursor_StringList final : public PortabilityLayer::HostDirectoryCursor class GpDirectoryCursor_StringList final : public IGpDirectoryCursor
{ {
public: public:
explicit GpDirectoryCursor_StringList(std::vector<std::string> &paths); explicit GpDirectoryCursor_StringList(std::vector<std::string> &paths);
@@ -847,7 +825,7 @@ void GpDirectoryCursor_StringList::Destroy()
delete this; delete this;
} }
class GpDirectoryCursor_POSIX final : public PortabilityLayer::HostDirectoryCursor class GpDirectoryCursor_POSIX final : public IGpDirectoryCursor
{ {
public: public:
explicit GpDirectoryCursor_POSIX(DIR *dir); explicit GpDirectoryCursor_POSIX(DIR *dir);
@@ -885,7 +863,7 @@ void GpDirectoryCursor_POSIX::Destroy()
delete this; 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; std::string resolvedPath;
@@ -919,7 +897,7 @@ PortabilityLayer::HostDirectoryCursor *GpFileSystem_Android::ScanAssetDirectory(
return new GpDirectoryCursor_StringList(subPaths); 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::string resolvedPath;
std::vector<std::string> subPaths; std::vector<std::string> subPaths;

View File

@@ -1,18 +1,15 @@
#pragma once #pragma once
#include "HostFileSystem.h" #include "IGpFileSystem.h"
#include "GpCoreDefs.h" #include "GpCoreDefs.h"
#include <jni.h> #include <jni.h>
#include <string> #include <string>
namespace PortabilityLayer struct IGpMutex;
{
class HostMutex;
}
class GpFileSystem_Android final : public PortabilityLayer::HostFileSystem class GpFileSystem_Android final : public IGpFileSystem
{ {
public: public:
GpFileSystem_Android(); GpFileSystem_Android();
@@ -22,16 +19,14 @@ public:
void ShutdownJNI(); void ShutdownJNI();
bool FileExists(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path) override; 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; 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; 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 ValidateFilePath(const char *path, size_t pathLen) const override;
bool ValidateFilePathUnicodeChar(uint32_t ch) const override; bool ValidateFilePathUnicodeChar(uint32_t ch) const override;
bool IsVirtualDirectoryLooseResources(PortabilityLayer::VirtualDirectory_t virtualDir) const override;
void SetMainThreadRelay(IGpThreadRelay *relay) override; void SetMainThreadRelay(IGpThreadRelay *relay) override;
void SetDelayCallback(DelayCallback_t delayCallback) override; void SetDelayCallback(DelayCallback_t delayCallback) override;
@@ -45,17 +40,17 @@ private:
{ {
GpFileSystem_Android *m_this; GpFileSystem_Android *m_this;
PortabilityLayer::HostDirectoryCursor *m_returnValue; IGpDirectoryCursor *m_returnValue;
PortabilityLayer::VirtualDirectory_t m_virtualDirectory; PortabilityLayer::VirtualDirectory_t m_virtualDirectory;
char const *const *m_paths; char const *const *m_paths;
size_t m_numPaths; size_t m_numPaths;
}; };
static void ScanDirectoryNestedThunk(void *context); 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); IGpDirectoryCursor *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 *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 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); 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_selectSourceExportPathMID;
jmethodID m_closeSourceExportPFDMID; jmethodID m_closeSourceExportPFDMID;
PortabilityLayer::HostMutex *m_sourceExportMutex; IGpMutex *m_sourceExportMutex;
int m_sourceExportFD; int m_sourceExportFD;
bool m_sourceExportWaiting; bool m_sourceExportWaiting;
bool m_sourceExportCancelled; bool m_sourceExportCancelled;

View File

@@ -8,14 +8,15 @@
#include "GpFileSystem_Android.h" #include "GpFileSystem_Android.h"
#include "GpFontHandlerFactory.h" #include "GpFontHandlerFactory.h"
#include "GpInputDriverFactory.h" #include "GpInputDriverFactory.h"
#include "GpInputDriver_SDL_Gamepad.h"
#include "GpAppInterface.h" #include "GpAppInterface.h"
#include "GpSystemServices_Android.h" #include "GpSystemServices_Android.h"
#include "GpVOSEvent.h" #include "GpVOSEvent.h"
#include "IGpVOSEventQueue.h" #include "IGpVOSEventQueue.h"
#include "IGpLogDriver.h" #include "IGpLogDriver.h"
#include "HostFileSystem.h" #include "IGpFileSystem.h"
#include "HostThreadEvent.h" #include "IGpThreadEvent.h"
#include "GpAndroid.h" #include "GpAndroid.h"
@@ -81,9 +82,10 @@ int main(int argc, char* argv[])
GpFileSystem_Android::GetInstance()->InitJNI(); GpFileSystem_Android::GetInstance()->InitJNI();
GpAppInterface_Get()->PL_HostFileSystem_SetInstance(GpFileSystem_Android::GetInstance()); GpDriverCollection *drivers = GpAppInterface_Get()->PL_GetDriverCollection();
GpAppInterface_Get()->PL_HostSystemServices_SetInstance(GpSystemServices_Android::GetInstance()); drivers->SetDriver<GpDriverIDs::kFileSystem>(GpFileSystem_Android::GetInstance());
GpAppInterface_Get()->PL_HostLogDriver_SetInstance(GpLogDriver_Android::GetInstance()); drivers->SetDriver<GpDriverIDs::kSystemServices>(GpSystemServices_Android::GetInstance());
drivers->SetDriver<GpDriverIDs::kLog>(GpLogDriver_Android::GetInstance());
g_gpGlobalConfig.m_displayDriverType = EGpDisplayDriverType_SDL_GL2; g_gpGlobalConfig.m_displayDriverType = EGpDisplayDriverType_SDL_GL2;
@@ -115,3 +117,8 @@ int main(int argc, char* argv[])
return returnCode; return returnCode;
} }
IGpInputDriverSDLGamepad *IGpInputDriverSDLGamepad::GetInstance()
{
return nullptr;
}

View File

@@ -1,18 +1,16 @@
#include "GpSystemServices_Android.h" #include "GpSystemServices_Android.h"
#include "HostMutex.h"
#include "HostThreadEvent.h" #include "IGpThreadEvent.h"
#include "SDL.h" #include "SDL.h"
#include <time.h> #include <time.h>
#include <mutex>
#include <condition_variable>
#include <unistd.h> #include <unistd.h>
struct GpSystemServices_Android_ThreadStartParams struct GpSystemServices_Android_ThreadStartParams
{ {
GpSystemServices_Android::ThreadFunc_t m_threadFunc; GpSystemServices_Android::ThreadFunc_t m_threadFunc;
void *m_threadContext; void *m_threadContext;
PortabilityLayer::HostThreadEvent *m_threadStartEvent; IGpThreadEvent *m_threadStartEvent;
}; };
static int SDLCALL StaticStartThread(void *lpThreadParameter) static int SDLCALL StaticStartThread(void *lpThreadParameter)
@@ -21,185 +19,21 @@ static int SDLCALL StaticStartThread(void *lpThreadParameter)
GpSystemServices_Android::ThreadFunc_t threadFunc = threadParams->m_threadFunc; GpSystemServices_Android::ThreadFunc_t threadFunc = threadParams->m_threadFunc;
void *threadContext = threadParams->m_threadContext; void *threadContext = threadParams->m_threadContext;
PortabilityLayer::HostThreadEvent *threadStartEvent = threadParams->m_threadStartEvent; IGpThreadEvent *threadStartEvent = threadParams->m_threadStartEvent;
threadStartEvent->Signal(); threadStartEvent->Signal();
return threadFunc(threadContext); 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() GpSystemServices_Android::GpSystemServices_Android()
: m_textInputEnabled(false) : 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) void *GpSystemServices_Android::CreateThread(ThreadFunc_t threadFunc, void *context)
{ {
PortabilityLayer::HostThreadEvent *evt = CreateThreadEvent(true, false); IGpThreadEvent *evt = CreateThreadEvent(true, false);
if (!evt) if (!evt)
return nullptr; return nullptr;
@@ -221,31 +55,6 @@ void *GpSystemServices_Android::CreateThread(ThreadFunc_t threadFunc, void *cont
return thread; 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 void GpSystemServices_Android::Beep() const
{ {
} }
@@ -265,6 +74,16 @@ bool GpSystemServices_Android::IsTextInputObstructive() const
return true; return true;
} }
bool GpSystemServices_Android::IsFullscreenPreferred() const
{
return true;
}
bool GpSystemServices_Android::IsFullscreenOnStartup() const
{
return true;
}
unsigned int GpSystemServices_Android::GetCPUCount() const unsigned int GpSystemServices_Android::GetCPUCount() const
{ {
return SDL_GetCPUCount(); return SDL_GetCPUCount();
@@ -280,6 +99,20 @@ bool GpSystemServices_Android::IsTextInputEnabled() const
return m_textInputEnabled; 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() GpSystemServices_Android *GpSystemServices_Android::GetInstance()
{ {
return &ms_instance; return &ms_instance;

View File

@@ -1,27 +1,26 @@
#pragma once #pragma once
#include "HostSystemServices.h" #include "GpSystemServices_POSIX.h"
#include "GpCoreDefs.h" #include "GpCoreDefs.h"
class GpSystemServices_Android final : public PortabilityLayer::HostSystemServices class GpSystemServices_Android final : public GpSystemServices_POSIX
{ {
public: public:
GpSystemServices_Android(); 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; 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; void Beep() const override;
bool IsTouchscreen() const override; bool IsTouchscreen() const override;
bool IsUsingMouseAsTouch() const override; bool IsUsingMouseAsTouch() const override;
bool IsTextInputObstructive() const override; bool IsTextInputObstructive() const override;
bool IsFullscreenPreferred() const override;
bool IsFullscreenOnStartup() const override;
unsigned int GetCPUCount() const override; unsigned int GetCPUCount() const override;
void SetTextInputEnabled(bool isEnabled) override; void SetTextInputEnabled(bool isEnabled) override;
bool IsTextInputEnabled() const override; bool IsTextInputEnabled() const override;
bool AreFontResourcesSeekable() const override;
IGpClipboardContents *GetClipboardContents() const override;
void SetClipboardContents(IGpClipboardContents *contents) override;
void FlushTextInputEnabled(); void FlushTextInputEnabled();

View File

@@ -41,9 +41,13 @@
<!-- Allow writing to external storage --> <!-- Allow writing to external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Allow access to Bluetooth devices --> <!-- Allow access to Bluetooth devices -->
<!--
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH" />
-->
<!-- Allow access to the vibrator --> <!-- Allow access to the vibrator -->
<!--
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
-->
<!-- if you want to capture audio, uncomment this. --> <!-- if you want to capture audio, uncomment this. -->
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> --> <!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->

View File

@@ -6,7 +6,7 @@ buildscript {
google() google()
} }
dependencies { 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 // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files

View File

@@ -7,6 +7,6 @@ mkdir Packaged
cd Packaged cd Packaged
rmdir /S /Q Houses rmdir /S /Q Houses
mkdir Houses mkdir Houses
copy ..\..\..\..\..\..\Packaged\*.gpa .\ copy ..\..\..\..\..\..\Packaged\*.gpf .\
copy ..\..\..\..\..\..\Packaged\Houses\* Houses\ copy ..\..\..\..\..\..\Packaged\Houses\* Houses\
cd .. cd ..

View File

@@ -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\ tools\7z.exe d AerofoilAndroid\app\src\main\assets\Packaged\SourceCode.zip GliderProData\
cd AerofoilAndroid\app\src\main\assets\Packaged cd AerofoilAndroid\app\src\main\assets\Packaged
rename SourceCode.zip SourceCode.pkg rename SourceCode.zip SourceCode.pkg
pause

View File

@@ -5,6 +5,7 @@ call remove_symlinks.bat
mklink /D app\jni\AerofoilSDL ..\..\..\AerofoilSDL mklink /D app\jni\AerofoilSDL ..\..\..\AerofoilSDL
mklink /D app\jni\AerofoilPortable ..\..\..\AerofoilPortable
mklink /D app\jni\Common ..\..\..\Common mklink /D app\jni\Common ..\..\..\Common
mklink /D app\jni\SDL2 ..\..\..\SDL2-2.0.12 mklink /D app\jni\SDL2 ..\..\..\SDL2-2.0.12
mklink /D app\jni\GpApp ..\..\..\GpApp mklink /D app\jni\GpApp ..\..\..\GpApp

View File

@@ -2,6 +2,7 @@
@cd /d "%~dp0" @cd /d "%~dp0"
rmdir app\jni\AerofoilSDL rmdir app\jni\AerofoilSDL
rmdir app\jni\AerofoilPortable
rmdir app\jni\Common rmdir app\jni\Common
rmdir app\jni\SDL2 rmdir app\jni\SDL2
rmdir app\jni\GpShell rmdir app\jni\GpShell

View 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)

View 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;

View 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;
}

View 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;
};

View 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);
}

View 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;
};

View File

@@ -95,8 +95,10 @@
<ClCompile Include="GpDisplayDriver_SDL_GL2.cpp" /> <ClCompile Include="GpDisplayDriver_SDL_GL2.cpp" />
<ClCompile Include="GpFiberStarter_SDL.cpp" /> <ClCompile Include="GpFiberStarter_SDL.cpp" />
<ClCompile Include="GpFiber_SDL.cpp" /> <ClCompile Include="GpFiber_SDL.cpp" />
<ClCompile Include="GpInputDriver_SDL_Gamepad.cpp" />
<ClCompile Include="GpMain_SDL_Win32.cpp" /> <ClCompile Include="GpMain_SDL_Win32.cpp" />
<ClCompile Include="ShaderCode\CopyQuadP.cpp" /> <ClCompile Include="ShaderCode\CopyQuadP.cpp" />
<ClCompile Include="ShaderCode\DrawQuad32P.cpp" />
<ClCompile Include="ShaderCode\DrawQuadPaletteP.cpp" /> <ClCompile Include="ShaderCode\DrawQuadPaletteP.cpp" />
<ClCompile Include="ShaderCode\DrawQuadV.cpp" /> <ClCompile Include="ShaderCode\DrawQuadV.cpp" />
<ClCompile Include="ShaderCode\ScaleQuadP.cpp" /> <ClCompile Include="ShaderCode\ScaleQuadP.cpp" />
@@ -111,15 +113,13 @@
<ProjectReference Include="..\GpFontHandler_FreeType2\GpFontHandler_FreeType2.vcxproj"> <ProjectReference Include="..\GpFontHandler_FreeType2\GpFontHandler_FreeType2.vcxproj">
<Project>{4b564030-8985-4975-91e1-e1b2c16ae2a1}</Project> <Project>{4b564030-8985-4975-91e1-e1b2c16ae2a1}</Project>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\GpInputDriver_XInput\GpInputDriver_XInput.vcxproj">
<Project>{17b96f07-ef92-47cd-95a5-8e6ee38ab564}</Project>
</ProjectReference>
<ProjectReference Include="..\GpShell\GpShell.vcxproj"> <ProjectReference Include="..\GpShell\GpShell.vcxproj">
<Project>{10cf9b5f-61d0-4b5b-89f4-810b58fc053d}</Project> <Project>{10cf9b5f-61d0-4b5b-89f4-810b58fc053d}</Project>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="GpFiber_SDL.h" /> <ClInclude Include="GpFiber_SDL.h" />
<ClInclude Include="GpInputDriver_SDL_Gamepad.h" />
<ClInclude Include="ShaderCode\DrawQuadPixelConstants.h" /> <ClInclude Include="ShaderCode\DrawQuadPixelConstants.h" />
<ClInclude Include="ShaderCode\Functions.h" /> <ClInclude Include="ShaderCode\Functions.h" />
</ItemGroup> </ItemGroup>

View File

@@ -66,6 +66,12 @@
<ClCompile Include="ShaderCode\CopyQuadP.cpp"> <ClCompile Include="ShaderCode\CopyQuadP.cpp">
<Filter>Source Files\ShaderCode</Filter> <Filter>Source Files\ShaderCode</Filter>
</ClCompile> </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>
<ItemGroup> <ItemGroup>
<ClInclude Include="ShaderCode\Functions.h"> <ClInclude Include="ShaderCode\Functions.h">
@@ -77,5 +83,8 @@
<ClInclude Include="GpFiber_SDL.h"> <ClInclude Include="GpFiber_SDL.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="GpInputDriver_SDL_Gamepad.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -23,6 +23,7 @@ LOCAL_SRC_FILES := \
GpFiberStarter_SDL.cpp \ GpFiberStarter_SDL.cpp \
ShaderCode/CopyQuadP.cpp \ ShaderCode/CopyQuadP.cpp \
ShaderCode/DrawQuadPaletteP.cpp \ ShaderCode/DrawQuadPaletteP.cpp \
ShaderCode/DrawQuad32P.cpp \
ShaderCode/DrawQuadV.cpp \ ShaderCode/DrawQuadV.cpp \
ShaderCode/ScaleQuadP.cpp ShaderCode/ScaleQuadP.cpp

View File

@@ -1,12 +1,12 @@
#include "IGpAudioDriver.h" #include "IGpAudioDriver.h"
#include "IGpAudioChannel.h" #include "IGpAudioChannel.h"
#include "IGpAudioChannelCallbacks.h" #include "IGpAudioChannelCallbacks.h"
#include "IGpMutex.h"
#include "IGpPrefsHandler.h" #include "IGpPrefsHandler.h"
#include "IGpSystemServices.h"
#include "GpAudioDriverProperties.h" #include "GpAudioDriverProperties.h"
#include "CoreDefs.h" #include "CoreDefs.h"
#include "HostMutex.h"
#include "HostSystemServices.h"
#include "SDL_audio.h" #include "SDL_audio.h"
#include "GpRingBuffer.h" #include "GpRingBuffer.h"
@@ -93,7 +93,7 @@ private:
bool Init(GpAudioDriver_SDL2 *driver); bool Init(GpAudioDriver_SDL2 *driver);
IGpAudioChannelCallbacks *m_callbacks; IGpAudioChannelCallbacks *m_callbacks;
PortabilityLayer::HostMutex *m_mutex; IGpMutex *m_mutex;
GpAudioDriver_SDL2 *m_owner; GpAudioDriver_SDL2 *m_owner;
SDL_atomic_t m_refCount; SDL_atomic_t m_refCount;
@@ -131,11 +131,12 @@ private:
void RefillMixChunk(GpAudioChannel_SDL2 *const*channels, size_t numChannels); void RefillMixChunk(GpAudioChannel_SDL2 *const*channels, size_t numChannels);
GpAudioDriverProperties m_properties; GpAudioDriverProperties m_properties;
PortabilityLayer::HostMutex *m_mutex; IGpMutex *m_mutex;
PortabilityLayer::HostMutex *m_mixState; IGpMutex *m_mixState;
static const size_t kMaxChannels = 16; static const size_t kMaxChannels = 16;
static const size_t kMixChunkSize = 256; static const size_t kMixChunkSize = 256;
static const int16_t kMaxAudioVolumeScale = 25;
GpAudioChannel_SDL2 *m_channels[kMaxChannels]; GpAudioChannel_SDL2 *m_channels[kMaxChannels];
size_t m_numChannels; size_t m_numChannels;
@@ -144,6 +145,8 @@ private:
GP_ALIGNED(GP_SYSTEM_MEMORY_ALIGNMENT) int16_t m_mixChunk[kMixChunkSize]; GP_ALIGNED(GP_SYSTEM_MEMORY_ALIGNMENT) int16_t m_mixChunk[kMixChunkSize];
size_t m_mixChunkReadOffset; size_t m_mixChunkReadOffset;
int16_t m_audioVolumeScale;
}; };
GpAudioChannelBufferChain_SDL2::GpAudioChannelBufferChain_SDL2() GpAudioChannelBufferChain_SDL2::GpAudioChannelBufferChain_SDL2()
@@ -353,6 +356,7 @@ GpAudioDriver_SDL2::GpAudioDriver_SDL2(const GpAudioDriverProperties &properties
, m_numChannels(0) , m_numChannels(0)
, m_sdlAudioRunning(false) , m_sdlAudioRunning(false)
, m_mixChunkReadOffset(kMixChunkSize) , m_mixChunkReadOffset(kMixChunkSize)
, m_audioVolumeScale(kMaxAudioVolumeScale)
{ {
for (size_t i = 0; i < kMaxChannels; i++) 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) 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() void GpAudioDriver_SDL2::Shutdown()
@@ -527,6 +534,8 @@ void GpAudioDriver_SDL2::RefillMixChunk(GpAudioChannel_SDL2 *const*channels, siz
bool noAudio = true; bool noAudio = true;
const int16_t audioVolumeScale = m_audioVolumeScale;
for (size_t i = 0; i < numChannels; i++) for (size_t i = 0; i < numChannels; i++)
{ {
channels[i]->Consume(audioMixBuffer, kMixChunkSize); channels[i]->Consume(audioMixBuffer, kMixChunkSize);
@@ -535,12 +544,12 @@ void GpAudioDriver_SDL2::RefillMixChunk(GpAudioChannel_SDL2 *const*channels, siz
{ {
noAudio = false; noAudio = false;
for (size_t j = 0; j < kMixChunkSize; j++) 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 else
{ {
for (size_t j = 0; j < kMixChunkSize; j++) 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;
} }
} }

View File

@@ -6,11 +6,12 @@
#include "GpDisplayDriverProperties.h" #include "GpDisplayDriverProperties.h"
#include "GpVOSEvent.h" #include "GpVOSEvent.h"
#include "GpRingBuffer.h" #include "GpRingBuffer.h"
#include "HostSystemServices.h" #include "GpInputDriver_SDL_Gamepad.h"
#include "IGpCursor.h" #include "IGpCursor.h"
#include "IGpDisplayDriverSurface.h" #include "IGpDisplayDriverSurface.h"
#include "IGpLogDriver.h" #include "IGpLogDriver.h"
#include "IGpPrefsHandler.h" #include "IGpPrefsHandler.h"
#include "IGpSystemServices.h"
#include "IGpVOSEventQueue.h" #include "IGpVOSEventQueue.h"
#include "SDL_events.h" #include "SDL_events.h"
@@ -39,6 +40,13 @@ class GpDisplayDriver_SDL_GL2;
static GpDisplayDriverSurfaceEffects gs_defaultEffects; 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 namespace DeleteMe
{ {
@@ -108,17 +116,13 @@ namespace GpBinarizedShaders
extern const char *g_drawQuadPalettePF_GL2; extern const char *g_drawQuadPalettePF_GL2;
extern const char *g_drawQuadPalettePNF_GL2; extern const char *g_drawQuadPalettePNF_GL2;
extern const char *g_drawQuadRGBPF_GL2; extern const char *g_drawQuad32PF_GL2;
extern const char *g_drawQuadRGBPNF_GL2; extern const char *g_drawQuad32PNF_GL2;
extern const char *g_drawQuad15BitPF_GL2;
extern const char *g_drawQuad15BitPNF_GL2;
extern const char *g_drawQuadPaletteICCPF_GL2; extern const char *g_drawQuadPaletteICCPF_GL2;
extern const char *g_drawQuadPaletteICCPNF_GL2; extern const char *g_drawQuadPaletteICCPNF_GL2;
extern const char *g_drawQuadRGBICCPF_GL2; extern const char *g_drawQuad32ICCPF_GL2;
extern const char *g_drawQuadRGBICCPNF_GL2; extern const char *g_drawQuad32ICCPNF_GL2;
extern const char *g_drawQuad15BitICCPF_GL2;
extern const char *g_drawQuad15BitICCPNF_GL2;
extern const char *g_copyQuadP_GL2; extern const char *g_copyQuadP_GL2;
extern const char *g_scaleQuadP_GL2; extern const char *g_scaleQuadP_GL2;
@@ -731,7 +735,7 @@ public:
void Run() override; void Run() override;
void Shutdown() 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; 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; 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; 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_drawQuadPaletteNoFlickerProgram;
DrawQuadProgram m_drawQuadPaletteFlickerProgram; DrawQuadProgram m_drawQuadPaletteFlickerProgram;
DrawQuadProgram m_drawQuadRGBProgram; DrawQuadProgram m_drawQuad15NoFlickerProgram;
DrawQuadProgram m_drawQuad15BitProgram; DrawQuadProgram m_drawQuad15FlickerProgram;
DrawQuadProgram m_drawQuad32NoFlickerProgram;
DrawQuadProgram m_drawQuad32FlickerProgram;
DrawQuadProgram m_drawQuadPaletteICCNoFlickerProgram; DrawQuadProgram m_drawQuadPaletteICCNoFlickerProgram;
DrawQuadProgram m_drawQuadPaletteICCFlickerProgram; DrawQuadProgram m_drawQuadPaletteICCFlickerProgram;
DrawQuadProgram m_drawQuadRGBICCProgram; DrawQuadProgram m_drawQuad15ICCNoFlickerProgram;
DrawQuadProgram m_drawQuad15BitICCProgram; DrawQuadProgram m_drawQuad15ICCFlickerProgram;
DrawQuadProgram m_drawQuad32ICCNoFlickerProgram;
DrawQuadProgram m_drawQuad32ICCFlickerProgram;
}; };
InstancedResources m_res; InstancedResources m_res;
@@ -886,6 +894,8 @@ private:
uint32_t m_windowHeightPhysical; uint32_t m_windowHeightPhysical;
uint32_t m_windowWidthVirtual; // Virtual resolution is the resolution reported to the game uint32_t m_windowWidthVirtual; // Virtual resolution is the resolution reported to the game
uint32_t m_windowHeightVirtual; 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_pixelScaleX;
float m_pixelScaleY; float m_pixelScaleY;
bool m_useUpscaleFilter; bool m_useUpscaleFilter;
@@ -897,7 +907,7 @@ private:
bool m_mouseIsInClientArea; bool m_mouseIsInClientArea;
IGpFiber *m_vosFiber; IGpFiber *m_vosFiber;
PortabilityLayer::HostThreadEvent *m_vosEvent; IGpThreadEvent *m_vosEvent;
float m_bgColor[4]; float m_bgColor[4];
bool m_bgIsDark; bool m_bgIsDark;
@@ -1178,6 +1188,8 @@ GpDisplayDriver_SDL_GL2::GpDisplayDriver_SDL_GL2(const GpDisplayDriverProperties
, m_windowHeightPhysical(480) , m_windowHeightPhysical(480)
, m_windowWidthVirtual(640) , m_windowWidthVirtual(640)
, m_windowHeightVirtual(480) , m_windowHeightVirtual(480)
, m_initialWidthVirtual(640)
, m_initialHeightVirtual(480)
, m_pixelScaleX(1.0f) , m_pixelScaleX(1.0f)
, m_pixelScaleY(1.0f) , m_pixelScaleY(1.0f)
, m_useUpscaleFilter(false) , m_useUpscaleFilter(false)
@@ -1215,7 +1227,7 @@ GpDisplayDriver_SDL_GL2::GpDisplayDriver_SDL_GL2(const GpDisplayDriverProperties
m_bgColor[3] = 1.f; m_bgColor[3] = 1.f;
// Stupid hack to detect mobile... // 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 periodNum = std::chrono::high_resolution_clock::period::num;
const intmax_t periodDen = std::chrono::high_resolution_clock::period::den; 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); m_vosFiber = new GpFiber_SDL(nullptr, m_vosEvent);
uint32_t windowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN; uint32_t windowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
if (m_isFullScreenDesired) if (m_properties.m_systemServices->IsFullscreenOnStartup())
{ {
windowFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP; windowFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
m_isFullScreen = true; m_isFullScreen = true;
@@ -1897,24 +1909,43 @@ void GpDisplayDriver_SDL_GL2::Run()
if (!m_gl.LookUpFunctions()) if (!m_gl.LookUpFunctions())
return; return;
m_initialWidthVirtual = m_windowWidthVirtual;
m_initialHeightVirtual = m_windowHeightVirtual;
for (;;) for (;;)
{ {
SDL_Event msg; SDL_Event msg;
if (SDL_PollEvent(&msg) != 0) if (SDL_PollEvent(&msg) != 0)
{ {
if (msg.type == SDL_MOUSEMOTION) switch (msg.type)
{ {
if (!m_mouseIsInClientArea) case SDL_MOUSEMOTION:
m_mouseIsInClientArea = true; {
} if (!m_mouseIsInClientArea)
//else if (msg.type == SDL_MOUSELEAVE) // Does SDL support this?? m_mouseIsInClientArea = true;
}
break;
//case SDL_MOUSELEAVE: // Does SDL support this??
// m_mouseIsInClientArea = false; // m_mouseIsInClientArea = false;
else if (msg.type == SDL_RENDER_DEVICE_RESET || msg.type == SDL_RENDER_TARGETS_RESET) // break;
{ case SDL_RENDER_DEVICE_RESET:
if (logger) case SDL_RENDER_TARGETS_RESET:
logger->Printf(IGpLogDriver::Category_Information, "Triggering GL context reset due to device loss (Type: %i)", static_cast<int>(msg.type)); {
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); TranslateSDLMessage(&msg, m_properties.m_eventQueue, m_pixelScaleX, m_pixelScaleY, obstructiveTextInput);
@@ -2052,13 +2083,13 @@ void GpDisplayDriver_SDL_GL2::Shutdown()
free(this); 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) if (width)
*width = m_windowWidthVirtual; *width = m_initialWidthVirtual;
if (height) 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) 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) 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 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) 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) 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)) if ((m_pixelScaleX < 2.0f && m_pixelScaleX > 1.0f) || (m_pixelScaleY < 2.0f && m_pixelScaleY > 1.0f))
m_useUpscaleFilter = true; m_useUpscaleFilter = true;
else
m_useUpscaleFilter = false;
CheckGLError(m_gl, logger); 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_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>> drawQuadPaletteFlickerPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuadPalettePF_GL2);
GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> drawQuadPaletteNoFlickerPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuadPalettePNF_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); GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> drawQuad32FlickerPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuad32PF_GL2);
//m_drawQuad15BitPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuad15BitP_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>> drawQuadPaletteICCFPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuadPaletteICCPF_GL2);
GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> drawQuadPaletteICCNFPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuadPaletteICCPNF_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); GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> drawQuad32ICCFPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuad32ICCPF_GL2);
//m_drawQuad15BitICCPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_drawQuad15BitICCP_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>> scaleQuadPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_scaleQuadP_GL2);
GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> copyQuadPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_copyQuadP_GL2); GpComPtr<GpGLShader<GL_FRAGMENT_SHADER>> copyQuadPixelShader = CreateShader<GL_FRAGMENT_SHADER>(GpBinarizedShaders::g_copyQuadP_GL2);
if (!m_res.m_drawQuadPaletteFlickerProgram.Link(this, drawQuadVertexShader, drawQuadPaletteFlickerPixelShader) if (!m_res.m_drawQuadPaletteFlickerProgram.Link(this, drawQuadVertexShader, drawQuadPaletteFlickerPixelShader)
|| !m_res.m_drawQuadPaletteNoFlickerProgram.Link(this, drawQuadVertexShader, drawQuadPaletteFlickerPixelShader) || !m_res.m_drawQuadPaletteNoFlickerProgram.Link(this, drawQuadVertexShader, drawQuadPaletteNoFlickerPixelShader)
//|| !m_drawQuadRGBProgram.Link(this, drawQuadVertexShader, drawQuadRGBPixelShader) || !m_res.m_drawQuad32FlickerProgram.Link(this, drawQuadVertexShader, drawQuad32FlickerPixelShader)
//|| !m_drawQuad15BitProgram.Link(this, drawQuadVertexShader, drawQuad15BitPixelShader) || !m_res.m_drawQuad32NoFlickerProgram.Link(this, drawQuadVertexShader, drawQuad32NoFlickerPixelShader)
|| !m_res.m_drawQuadPaletteICCFlickerProgram.Link(this, drawQuadVertexShader, drawQuadPaletteICCFPixelShader) || !m_res.m_drawQuadPaletteICCFlickerProgram.Link(this, drawQuadVertexShader, drawQuadPaletteICCFPixelShader)
|| !m_res.m_drawQuadPaletteICCNoFlickerProgram.Link(this, drawQuadVertexShader, drawQuadPaletteICCNFPixelShader) || !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_drawQuadRGBICCProgram.Link(this, drawQuadVertexShader, drawQuadRGBICCPixelShader)
//|| !m_drawQuad15BitICCProgram.Link(this, drawQuadVertexShader, drawQuad15BitICCPixelShader) //|| !m_drawQuad15BitICCProgram.Link(this, drawQuadVertexShader, drawQuad15BitICCPixelShader)
|| !m_res.m_scaleQuadProgram.Link(this, drawQuadVertexShader, scaleQuadPixelShader) || !m_res.m_scaleQuadProgram.Link(this, drawQuadVertexShader, scaleQuadPixelShader)

View File

@@ -1,8 +1,8 @@
#include "GpFiberStarter.h" #include "GpFiberStarter.h"
#include "GpFiber_SDL.h" #include "GpFiber_SDL.h"
#include "HostSystemServices.h" #include "IGpSystemServices.h"
#include "HostThreadEvent.h" #include "IGpThreadEvent.h"
#include "SDL_thread.h" #include "SDL_thread.h"
@@ -13,8 +13,8 @@ namespace GpFiberStarter_SDL
struct FiberStartState struct FiberStartState
{ {
GpFiberStarter::ThreadFunc_t m_threadFunc; GpFiberStarter::ThreadFunc_t m_threadFunc;
PortabilityLayer::HostThreadEvent *m_creatingReturnEvent; IGpThreadEvent *m_creatingReturnEvent;
PortabilityLayer::HostThreadEvent *m_creatingWakeEvent; IGpThreadEvent *m_creatingWakeEvent;
void *m_context; void *m_context;
}; };
@@ -23,8 +23,8 @@ namespace GpFiberStarter_SDL
const FiberStartState *tss = static_cast<const FiberStartState*>(lpThreadParameter); const FiberStartState *tss = static_cast<const FiberStartState*>(lpThreadParameter);
GpFiberStarter::ThreadFunc_t threadFunc = tss->m_threadFunc; GpFiberStarter::ThreadFunc_t threadFunc = tss->m_threadFunc;
PortabilityLayer::HostThreadEvent *creatingReturnEvent = tss->m_creatingReturnEvent; IGpThreadEvent *creatingReturnEvent = tss->m_creatingReturnEvent;
PortabilityLayer::HostThreadEvent *wakeEvent = tss->m_creatingWakeEvent; IGpThreadEvent *wakeEvent = tss->m_creatingWakeEvent;
void *context = tss->m_context; void *context = tss->m_context;
creatingReturnEvent->Signal(); 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) if (!returnEvent)
return nullptr; return nullptr;
PortabilityLayer::HostThreadEvent *wakeEvent = systemServices->CreateThreadEvent(true, false); IGpThreadEvent *wakeEvent = systemServices->CreateThreadEvent(true, false);
if (!wakeEvent) if (!wakeEvent)
{ {
returnEvent->Destroy(); returnEvent->Destroy();

View File

@@ -1,8 +1,7 @@
#include "GpFiber_SDL.h" #include "GpFiber_SDL.h"
#include "HostSystemServices.h" #include "IGpThreadEvent.h"
#include "HostThreadEvent.h"
GpFiber_SDL::GpFiber_SDL(SDL_Thread *thread, PortabilityLayer::HostThreadEvent *threadEvent) GpFiber_SDL::GpFiber_SDL(SDL_Thread *thread, IGpThreadEvent *threadEvent)
: m_event(threadEvent) : m_event(threadEvent)
, m_thread(thread) , m_thread(thread)
{ {

View File

@@ -3,16 +3,12 @@
#include "IGpFiber.h" #include "IGpFiber.h"
#include "SDL_thread.h" #include "SDL_thread.h"
namespace PortabilityLayer struct IGpThreadEvent;
{
class HostSystemServices;
class HostThreadEvent;
}
class GpFiber_SDL final : public IGpFiber class GpFiber_SDL final : public IGpFiber
{ {
public: public:
explicit GpFiber_SDL(SDL_Thread *thread, PortabilityLayer::HostThreadEvent *threadEvent); explicit GpFiber_SDL(SDL_Thread *thread, IGpThreadEvent *threadEvent);
~GpFiber_SDL(); ~GpFiber_SDL();
void YieldTo(IGpFiber *fromFiber) override; void YieldTo(IGpFiber *fromFiber) override;
@@ -23,6 +19,6 @@ private:
static int SDLCALL InternalThreadFunction(void *data); static int SDLCALL InternalThreadFunction(void *data);
bool m_isDestroying; bool m_isDestroying;
PortabilityLayer::HostThreadEvent *m_event; IGpThreadEvent *m_event;
SDL_Thread *m_thread; SDL_Thread *m_thread;
}; };

View 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);
}

View 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();
};

View File

@@ -13,10 +13,10 @@
#include "GpAppInterface.h" #include "GpAppInterface.h"
#include "GpSystemServices_Win32.h" #include "GpSystemServices_Win32.h"
#include "GpVOSEvent.h" #include "GpVOSEvent.h"
#include "IGpVOSEventQueue.h"
#include "HostFileSystem.h" #include "IGpFileSystem.h"
#include "HostThreadEvent.h" #include "IGpThreadEvent.h"
#include "IGpVOSEventQueue.h"
#include "GpWindows.h" #include "GpWindows.h"
@@ -29,16 +29,16 @@
GpWindowsGlobals g_gpWindowsGlobals; 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); extern "C" __declspec(dllimport) IGpFontHandler *GpDriver_CreateFontHandler_FreeType2(const GpFontHandlerProperties &properties);
IGpDisplayDriver *GpDriver_CreateDisplayDriver_SDL_GL2(const GpDisplayDriverProperties &properties); IGpDisplayDriver *GpDriver_CreateDisplayDriver_SDL_GL2(const GpDisplayDriverProperties &properties);
IGpAudioDriver *GpDriver_CreateAudioDriver_SDL(const GpAudioDriverProperties &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) 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; return -1;
LPWSTR cmdLine = GetCommandLineW(); LPWSTR cmdLine = GetCommandLineW();
@@ -56,10 +56,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
} }
IGpLogDriver *logger = GpLogDriver_Win32::GetInstance(); IGpLogDriver *logger = GpLogDriver_Win32::GetInstance();
GpDriverCollection *drivers = GpAppInterface_Get()->PL_GetDriverCollection();
GpAppInterface_Get()->PL_HostFileSystem_SetInstance(GpFileSystem_Win32::GetInstance()); drivers->SetDriver<GpDriverIDs::kFileSystem>(GpFileSystem_Win32::GetInstance());
GpAppInterface_Get()->PL_HostSystemServices_SetInstance(GpSystemServices_Win32::GetInstance()); drivers->SetDriver<GpDriverIDs::kSystemServices>(GpSystemServices_Win32::GetInstance());
GpAppInterface_Get()->PL_HostLogDriver_SetInstance(GpLogDriver_Win32::GetInstance()); drivers->SetDriver<GpDriverIDs::kLog>(GpLogDriver_Win32::GetInstance());
g_gpWindowsGlobals.m_hInstance = hInstance; g_gpWindowsGlobals.m_hInstance = hInstance;
g_gpWindowsGlobals.m_hPrevInstance = hPrevInstance; g_gpWindowsGlobals.m_hPrevInstance = hPrevInstance;
@@ -78,7 +79,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
EGpInputDriverType inputDrivers[] = EGpInputDriverType inputDrivers[] =
{ {
EGpInputDriverType_XInput EGpInputDriverType_SDL2_Gamepad
}; };
g_gpGlobalConfig.m_inputDriverTypes = inputDrivers; 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); GpDisplayDriverFactory::RegisterDisplayDriverFactory(EGpDisplayDriverType_SDL_GL2, GpDriver_CreateDisplayDriver_SDL_GL2);
GpAudioDriverFactory::RegisterAudioDriverFactory(EGpAudioDriverType_SDL2, GpDriver_CreateAudioDriver_SDL); 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); GpFontHandlerFactory::RegisterFontHandlerFactory(EGpFontHandlerType_FreeType2, GpDriver_CreateFontHandler_FreeType2);
if (logger) if (logger)

View 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;
}

View 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
}
]
}

View File

@@ -22,7 +22,7 @@
"itemType" : "CustomControl", "itemType" : "CustomControl",
"pos" : [ 17, 33 ], "pos" : [ 17, 33 ],
"size" : [ 401, 190 ], "size" : [ 401, 190 ],
"id" : 2, "id" : 3,
"enabled" : true "enabled" : true
}, },
{ {
@@ -30,9 +30,17 @@
"itemType" : "CustomControl", "itemType" : "CustomControl",
"pos" : [ 418, 32 ], "pos" : [ 418, 32 ],
"size" : [ 16, 192 ], "size" : [ 16, 192 ],
"id" : 3, "id" : 4,
"enabled" : true "enabled" : true
}, },
{
"name" : "Delete",
"itemType" : "Button",
"pos" : [ 228, 240 ],
"size" : [ 58, 20 ],
"id" : 5,
"enabled" : false
},
{ {
"name" : "^0", "name" : "^0",
"itemType" : "Label", "itemType" : "Label",

View File

@@ -18,7 +18,7 @@
"enabled" : false "enabled" : false
}, },
{ {
"name" : "Aerofoil ©2019-2020 Eric Lasota", "name" : "Aerofoil ©2019-2021 Eric Lasota",
"itemType" : "Label", "itemType" : "Label",
"pos" : [ 16, 21 ], "pos" : [ 16, 21 ],
"size" : [ 406, 20 ], "size" : [ 406, 20 ],

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -2,6 +2,7 @@
"add" : "add" :
{ {
"DITL/1017.json" : "ApplicationResourcePatches/DITL/1017.json", "DITL/1017.json" : "ApplicationResourcePatches/DITL/1017.json",
"DITL/1041.json" : "ApplicationResourcePatches/DITL/1041.json",
"DITL/2000.json" : "ApplicationResourcePatches/DITL/2000.json", "DITL/2000.json" : "ApplicationResourcePatches/DITL/2000.json",
"DITL/2001.json" : "ApplicationResourcePatches/DITL/2001.json", "DITL/2001.json" : "ApplicationResourcePatches/DITL/2001.json",
"DITL/2002.json" : "ApplicationResourcePatches/DITL/2002.json", "DITL/2002.json" : "ApplicationResourcePatches/DITL/2002.json",
@@ -10,9 +11,11 @@
"DITL/2005.json" : "ApplicationResourcePatches/DITL/2005.json", "DITL/2005.json" : "ApplicationResourcePatches/DITL/2005.json",
"DITL/2006.json" : "ApplicationResourcePatches/DITL/2006.json", "DITL/2006.json" : "ApplicationResourcePatches/DITL/2006.json",
"DITL/2007.json" : "ApplicationResourcePatches/DITL/2007.json", "DITL/2007.json" : "ApplicationResourcePatches/DITL/2007.json",
"DITL/2008.json" : "ApplicationResourcePatches/DITL/2008.json",
"PICT/1300.bmp" : "ApplicationResourcePatches/PICT/1300.bmp", "PICT/1300.bmp" : "ApplicationResourcePatches/PICT/1300.bmp",
"PICT/1301.bmp" : "ApplicationResourcePatches/PICT/1301.bmp", "PICT/1301.bmp" : "ApplicationResourcePatches/PICT/1301.bmp",
"PICT/1302.bmp" : "ApplicationResourcePatches/PICT/1302.bmp", "PICT/1302.bmp" : "ApplicationResourcePatches/PICT/1302.bmp",
"PICT/1303.bmp" : "ApplicationResourcePatches/PICT/1303.bmp",
"PICT/1971.bmp" : "ApplicationResourcePatches/PICT/1971.bmp", "PICT/1971.bmp" : "ApplicationResourcePatches/PICT/1971.bmp",
"PICT/1972.bmp" : "ApplicationResourcePatches/PICT/1972.bmp", "PICT/1972.bmp" : "ApplicationResourcePatches/PICT/1972.bmp",
"PICT/1973.bmp" : "ApplicationResourcePatches/PICT/1973.bmp", "PICT/1973.bmp" : "ApplicationResourcePatches/PICT/1973.bmp",

View File

@@ -21,7 +21,8 @@ const D3D_SHADER_MACRO drawQuadDefs[] =
const D3D_SHADER_MACRO drawQuadICCProfileDefs[] = const D3D_SHADER_MACRO drawQuadICCProfileDefs[] =
{ {
{ "USE_ICC_PROFILE", nullptr } { "USE_ICC_PROFILE", nullptr },
{ nullptr }
}; };
const CompileJob kCompileJobs[] = const CompileJob kCompileJobs[] =
@@ -108,7 +109,7 @@ int main(int argc, const char **argv)
if (result != S_OK) 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) if (errorMsgs)

View File

@@ -2,14 +2,17 @@ rmdir /S /Q Packaged
mkdir Packaged mkdir Packaged
mkdir Packaged\Houses mkdir Packaged\Houses
mkdir Packaged\WinCursors
x64\Release\MiniRez.exe "GliderProData\Glider PRO.r" Packaged\ApplicationResources.gpr 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\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 x64\Release\ConvertColorCursors.exe
attrib -R Packaged\ApplicationResources.gpf
attrib -R Packaged\Houses\* attrib -R Packaged\Houses\*
x64\Release\hqx2gp.exe "GliderProData\Houses\Art Museum.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\Art Museum" 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\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\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\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\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\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" 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\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\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\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\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\SpacePods.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\SpacePods"
x64\Release\hqx2gp.exe "GliderProData\Houses\Teddy World.binhex" "DefaultTimestamp.timestamp" "Packaged\Houses\Teddy World" 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\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\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\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\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\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" 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" 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\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\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\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\Rainbow's End.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Rainbow's End.gpa" "HousePatches\RainbowsEnd.json"
x64\Release\gpr2gpa.exe "Packaged\Houses\Sampler.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Sampler.gpa"
x64\Release\gpr2gpa.exe "Packaged\Houses\Slumberland.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Slumberland.gpa" 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\SpacePods.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\SpacePods.gpa"
x64\Release\gpr2gpa.exe "Packaged\Houses\Teddy World.gpr" "DefaultTimestamp.timestamp" "Packaged\Houses\Teddy World.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\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 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\ 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\Houses\*
attrib +R Packaged\ApplicationResources.gpf
pause pause

View File

@@ -2,6 +2,8 @@
#include <string> #include <string>
#include <Windows.h> #include <Windows.h>
#include "MacFileInfo.h" #include "MacFileInfo.h"
#include "CFileStream.h"
#include "CombinedTimestamp.h"
int main(int argc, const char **argv) int main(int argc, const char **argv)
{ {
@@ -29,19 +31,16 @@ int main(int argc, const char **argv)
FILE *tsF = nullptr; FILE *tsF = nullptr;
errno_t ferr = fopen_s(&tsF, timestampPath.c_str(), "rb"); errno_t ferr = fopen_s(&tsF, timestampPath.c_str(), "rb");
int64_t timestamp = 0; int64_t timestamp = 0;
PortabilityLayer::CombinedTimestamp ts;
if (!ferr) if (!ferr)
{ {
uint8_t encodedTimestamp[8]; if (fread(&ts, 1, sizeof(ts), tsF) != sizeof(ts))
if (fread(encodedTimestamp, 1, 8, tsF) != 8)
{ {
fprintf(stderr, "Error reading timestamp file"); fprintf(stderr, "Error reading timestamp file");
return -1; return -1;
} }
for (int i = 0; i < 8; i++)
timestamp |= static_cast<int64_t>(encodedTimestamp[i]) << (i * 8);
fclose(tsF); fclose(tsF);
} }
@@ -52,7 +51,7 @@ int main(int argc, const char **argv)
mfp.m_yPos = atoi(argv[6]); mfp.m_yPos = atoi(argv[6]);
mfp.m_finderFlags = 0; mfp.m_finderFlags = 0;
mfp.m_protected = 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++) 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"); errno_t err = fopen_s(&file, outPath.c_str(), "wb");
if (!err) if (!err)
{ {
fwrite(mps.m_data, PortabilityLayer::MacFilePropertiesSerialized::kSize, 1, file); PortabilityLayer::CFileStream stream(file);
fclose(file);
mps.WriteAsPackage(stream, ts);
stream.Close();
} }
return 0; return 0;

View File

@@ -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 "PLArrayView.h"
#include "PLDrivers.h"
#include "PLKeyEncoding.h" #include "PLKeyEncoding.h"
#include "PLControlDefinitions.h" #include "PLControlDefinitions.h"
#include "FontFamily.h" #include "FontFamily.h"
@@ -19,21 +36,6 @@
#include "PLSysCalls.h" #include "PLSysCalls.h"
#include "PLTimeTaggedVOSEvent.h" #include "PLTimeTaggedVOSEvent.h"
#include "PLWidgets.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); static void HiLiteOkayButton (DrawSurface *surface);
@@ -333,10 +335,10 @@ void DoAboutFramework (void)
DrawSurface *surface = window->GetDrawSurface(); 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 * 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 * 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 * 7), PSTR("Please do not contact any of them regarding issues that you have"), blackColor, font);
surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 8), PSTR("with " GP_APPLICATION_NAME "."), blackColor, font); surface->DrawString(Point::Create(horizontalOffset, verticalPoint + spacing * 8), PSTR("with " GP_APPLICATION_NAME "."), blackColor, font);
@@ -418,7 +420,7 @@ static void UpdateMainPict (Dialog *theDial)
Str255 theStr, theStr2; Str255 theStr, theStr2;
uint64_t freeMemory; uint64_t freeMemory;
freeMemory = PortabilityLayer::HostSystemServices::GetInstance()->GetFreeMemoryCosmetic(); freeMemory = PLDrivers::GetSystemServices()->GetFreeMemoryCosmetic();
PasStringCopy(PSTR("Memory: "), theStr); // display free memory PasStringCopy(PSTR("Memory: "), theStr); // display free memory

View File

@@ -5,17 +5,17 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
//============================================================================ //============================================================================
#include "PLResources.h"
#include "PLBigEndian.h"
#include "Externs.h" #include "Externs.h"
#include "Environ.h" #include "Environ.h"
#include "HostDisplayDriver.h"
#include "IGpCursor.h" #include "IGpCursor.h"
#include "IGpDisplayDriver.h" #include "IGpDisplayDriver.h"
#include "MemoryManager.h" #include "MemoryManager.h"
#include "ResourceManager.h" #include "ResourceManager.h"
#include "PLDrivers.h"
#include "PLResources.h"
#include "PLBigEndian.h"
#include <assert.h> #include <assert.h>
@@ -219,7 +219,7 @@ IGpCursor *LoadColorCursor(int16_t resID)
mm->Release(colorValues); 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); mm->Release(pixelDataRGBA);
@@ -251,7 +251,7 @@ Boolean GetColorCursors (acurHandle ballCursH, compiledAcurHandle compiledBallCu
else // But, if the cursor loaded ok else // But, if the cursor loaded ok
{ // add it to our list or cursor handles { // add it to our list or cursor handles
(*compiledBallCursH)->frame[i].hwCursor = hwCursor; (*compiledBallCursH)->frame[i].hwCursor = hwCursor;
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(hwCursor); PLDrivers::GetDisplayDriver()->SetCursor(hwCursor);
} }
} }
InitCursor(); // Show the cursor again (as arrow) InitCursor(); // Show the cursor again (as arrow)
@@ -343,10 +343,10 @@ void IncrementCursor (void)
acur->index++; acur->index++;
acur->index %= acur->n; acur->index %= acur->n;
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor); PLDrivers::GetDisplayDriver()->SetCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor);
} }
else else
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kWait); PLDrivers::GetDisplayDriver()->SetStandardCursor(EGpStandardCursors::kWait);
} }
//-------------------------------------------------------------- DecrementCursor //-------------------------------------------------------------- DecrementCursor
@@ -363,10 +363,10 @@ void DecrementCursor (void)
if (((*animCursorH)->index) < 0) if (((*animCursorH)->index) < 0)
(*animCursorH)->index = ((*animCursorH)->n) - 1; (*animCursorH)->index = ((*animCursorH)->n) - 1;
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor); PLDrivers::GetDisplayDriver()->SetCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor);
} }
else else
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kWait); PLDrivers::GetDisplayDriver()->SetStandardCursor(EGpStandardCursors::kWait);
} }
//-------------------------------------------------------------- SpinCursor //-------------------------------------------------------------- SpinCursor

View File

@@ -147,8 +147,6 @@ void CenterDialog (SInt16 dialogID)
void GetDialogRect (Rect *bounds, short dialogID) void GetDialogRect (Rect *bounds, short dialogID)
{ {
Byte wasState;
Handle dlogHandle = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('DLOG', dialogID).StaticCast<void>(); Handle dlogHandle = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('DLOG', dialogID).StaticCast<void>();
if (dlogHandle != nil) if (dlogHandle != nil)
{ {
@@ -343,10 +341,8 @@ void ZoomOutAlertRect (short alertID)
void FlashDialogButton (Dialog *theDialog, short itemNumber) void FlashDialogButton (Dialog *theDialog, short itemNumber)
{ {
Rect itemRect;
ControlHandle itemHandle; ControlHandle itemHandle;
UInt32 dummyLong; UInt32 dummyLong;
short itemType;
PortabilityLayer::Widget *widget = theDialog->GetItems()[itemNumber - 1].GetWidget(); 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) void SetDialogNumToStr (Dialog *theDialog, short item, long theNumber)
{ {
Str255 theString; Str255 theString;
Rect itemRect;
ControlHandle itemHandle; ControlHandle itemHandle;
short itemType;
NumToString(theNumber, theString); NumToString(theNumber, theString);
PortabilityLayer::Widget *widget = theDialog->GetItems()[item - 1].GetWidget(); PortabilityLayer::Widget *widget = theDialog->GetItems()[item - 1].GetWidget();
@@ -570,7 +564,7 @@ void DrawDialogUserText (Dialog *dial, short item, StringPtr text, Boolean inver
{ {
ControlHandle iHandle; ControlHandle iHandle;
Str255 stringCopy; Str255 stringCopy;
short iType, i, inset; short inset;
DrawSurface *surface = dial->GetWindow()->GetDrawSurface(); 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) void DrawDialogUserText2 (Dialog *dial, short item, StringPtr text)
{ {
;
Str255 stringCopy; Str255 stringCopy;
short iType;
DrawSurface *surface = dial->GetWindow()->GetDrawSurface(); DrawSurface *surface = dial->GetWindow()->GetDrawSurface();
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None, true); PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None, true);

View File

@@ -5,18 +5,19 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
//============================================================================ //============================================================================
#include "PLResources.h"
#include "PLPasStr.h"
#include "DisplayDeviceManager.h" #include "DisplayDeviceManager.h"
#include "Externs.h" #include "Externs.h"
#include "Environ.h" #include "Environ.h"
#include "HostDisplayDriver.h"
#include "HostSystemServices.h"
#include "MenuManager.h" #include "MenuManager.h"
#include "IGpDisplayDriver.h" #include "IGpDisplayDriver.h"
#include "IGpSystemServices.h"
#include "Vec2i.h"
#include "WindowManager.h" #include "WindowManager.h"
#include "PLDrivers.h"
#include "PLResources.h"
#include "PLPasStr.h"
#include <algorithm> #include <algorithm>
#define kSwitchDepthAlert 130 #define kSwitchDepthAlert 130
@@ -301,8 +302,8 @@ void CheckOurEnvirons (void)
thisMac.numScreens = HowManyUsableScreens(false, true, true); thisMac.numScreens = HowManyUsableScreens(false, true, true);
thisMac.isResolutionDirty = true; thisMac.isResolutionDirty = true;
thisMac.isTouchscreen = PortabilityLayer::HostSystemServices::GetInstance()->IsTouchscreen(); thisMac.isTouchscreen = PLDrivers::GetSystemServices()->IsTouchscreen();
thisMac.isMouseTouchscreen = PortabilityLayer::HostSystemServices::GetInstance()->IsUsingMouseAsTouch(); thisMac.isMouseTouchscreen = PLDrivers::GetSystemServices()->IsUsingMouseAsTouch();
FlushResolutionChange(); FlushResolutionChange();
} }
@@ -415,16 +416,14 @@ void HandleDepthSwitching (void)
thisMac.isDepth = isDepthPref; thisMac.isDepth = isDepthPref;
PortabilityLayer::HostDisplayDriver::GetInstance()->SetUseICCProfile(isUseICCProfile != 0); PLDrivers::GetDisplayDriver()->SetUseICCProfile(isUseICCProfile != 0);
} }
void GetDeviceRect(Rect *rect) void GetDeviceRect(Rect *rect)
{ {
unsigned int width; PortabilityLayer::Vec2i displayResolution = PortabilityLayer::WindowManager::GetInstance()->GetDisplayResolution();
unsigned int height;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&width, &height);
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() Boolean AreWeColorOrGrayscale()

View File

@@ -20,7 +20,6 @@
#include "WindowManager.h" #include "WindowManager.h"
short BitchAboutColorDepth (void);
void HandleMouseEvent (const GpMouseInputEvent &, uint32_t); void HandleMouseEvent (const GpMouseInputEvent &, uint32_t);
void HandleKeyEvent (const KeyDownStates &keyStates, const GpKeyboardInputEvent &); void HandleKeyEvent (const KeyDownStates &keyStates, const GpKeyboardInputEvent &);
void HandleUpdateEvent (EventRecord *); void HandleUpdateEvent (EventRecord *);
@@ -45,20 +44,6 @@ extern Boolean autoRoomEdit, newRoomNow, isPlayMusicIdle;
//============================================================== Functions //============================================================== 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 //-------------------------------------------------------------- HandleMouseEvent
// Handle a mouse click event. // Handle a mouse click event.

View File

@@ -118,7 +118,7 @@ typedef struct
Boolean wasEscPauseKey; Boolean wasEscPauseKey;
Boolean wasDoAutoDemo, wasAutoScale; Boolean wasDoAutoDemo, wasAutoScale;
Boolean wasDoBackground, wasHouseChecks; Boolean wasDoBackground, wasHouseChecks;
Boolean wasPrettyMap, wasBitchDialogs; Boolean wasPrettyMap, wasComplainDialogs;
Boolean wasUseICCProfile; Boolean wasUseICCProfile;
} prefsInfo; } prefsInfo;

View File

@@ -48,6 +48,9 @@ Boolean CheckFileError (short resultCode, const PLPasStr &fileName)
case PLErrors::kOutOfMemory: case PLErrors::kOutOfMemory:
stringIndex = 7; stringIndex = 7;
break; break;
case PLErrors::kFileIsBusy:
stringIndex = 12;
break;
default: default:
stringIndex = 1; stringIndex = 1;
break; break;

View File

@@ -121,10 +121,10 @@ void ShiftWholeHouse (SInt16);
void DoHouseInfo (void); // --- HouseInfo.c void DoHouseInfo (void); // --- HouseInfo.c
Boolean OpenHouse (void); // --- HouseIO.c Boolean OpenHouse (Boolean load); // --- HouseIO.c
Boolean OpenSpecificHouse (const VFileSpec &); Boolean OpenSpecificHouse (const VFileSpec &);
Boolean SaveHouseAs (void); Boolean SaveHouseAs (void);
Boolean ReadHouse (void); Boolean ReadHouse (GpIOStream *houseStream);
Boolean WriteHouse (Boolean); Boolean WriteHouse (Boolean);
Boolean CloseHouse (void); Boolean CloseHouse (void);
void OpenHouseResFork (void); void OpenHouseResFork (void);
@@ -425,7 +425,7 @@ void HandleBands (void); // --- RubberBands.c
Boolean AddBand (gliderPtr, SInt16, SInt16, Boolean); Boolean AddBand (gliderPtr, SInt16, SInt16, Boolean);
void KillAllBands (void); void KillAllBands (void);
void SaveGame2 (void); // --- SavedGames.c Boolean SaveGame2 (void); // --- SavedGames.c
Boolean OpenSavedGame (void); Boolean OpenSavedGame (void);
//void SaveGame (Boolean); //void SaveGame (Boolean);
@@ -461,7 +461,6 @@ void DumpTriggerSound (void);
void InitSound (void); void InitSound (void);
void KillSound (void); void KillSound (void);
void TellHerNoSounds (void); void TellHerNoSounds (void);
void BitchAboutSM3 (void);
void InitScoreboardMap (void); // --- StructuresInit.c void InitScoreboardMap (void); // --- StructuresInit.c
void InitGliderMap (void); void InitGliderMap (void);

View File

@@ -1,20 +1,16 @@
#include "GpAppInterface.h" #include "GpAppInterface.h"
#include "DisplayDeviceManager.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 "MenuManager.h"
#include "WindowManager.h" #include "WindowManager.h"
#include "PLDrivers.h"
#include "PLSysCalls.h"
int gpAppMain(); int gpAppMain();
void gpAppInit(); void gpAppInit();
class GpAppInterfaceImpl final : public GpAppInterface class GpAppInterfaceImpl final : public GpAppInterface
{ {
public: public:
@@ -23,14 +19,7 @@ public:
void PL_IncrementTickCounter(uint32_t count) override; void PL_IncrementTickCounter(uint32_t count) override;
void PL_Render(IGpDisplayDriver *displayDriver) override; void PL_Render(IGpDisplayDriver *displayDriver) override;
void PL_HostFileSystem_SetInstance(PortabilityLayer::HostFileSystem *instance) override; GpDriverCollection *PL_GetDriverCollection() 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;
void PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) 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; 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() int GpAppInterfaceImpl::ApplicationMain()
{ {
return gpAppMain(); return PLSysCalls::MainExitWrapper(gpAppMain);
} }
void GpAppInterfaceImpl::PL_IncrementTickCounter(uint32_t count) void GpAppInterfaceImpl::PL_IncrementTickCounter(uint32_t count)
@@ -56,44 +45,9 @@ void GpAppInterfaceImpl::PL_Render(IGpDisplayDriver *displayDriver)
PortabilityLayer::MenuManager::GetInstance()->RenderFrame(displayDriver); PortabilityLayer::MenuManager::GetInstance()->RenderFrame(displayDriver);
} }
void GpAppInterfaceImpl::PL_HostFileSystem_SetInstance(PortabilityLayer::HostFileSystem *instance) GpDriverCollection *GpAppInterfaceImpl::PL_GetDriverCollection()
{ {
PortabilityLayer::HostFileSystem::SetInstance(instance); return PLDrivers::GetDriverCollection();
}
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);
} }
void GpAppInterfaceImpl::PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) void GpAppInterfaceImpl::PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context)

View File

@@ -17,18 +17,22 @@
#include "FileManager.h" #include "FileManager.h"
#include "FontFamily.h" #include "FontFamily.h"
#include "FontManager.h" #include "FontManager.h"
#include "HostSystemServices.h"
#include "House.h" #include "House.h"
#include "IGpDisplayDriver.h"
#include "IGpSystemServices.h"
#include "GpIOStream.h" #include "GpIOStream.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "RectUtils.h" #include "RectUtils.h"
#include "RenderedFont.h" #include "RenderedFont.h"
#include "ResolveCachingColor.h" #include "ResolveCachingColor.h"
#include "Utilities.h" #include "Utilities.h"
#include "Vec2i.h"
#include "WindowManager.h" #include "WindowManager.h"
#include "PLDrivers.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#define kHighScoresPictID 1994 #define kHighScoresPictID 1994
#define kHighScoresMaskID 1998 #define kHighScoresMaskID 1998
#define kHighNameDialogID 1020 #define kHighNameDialogID 1020
@@ -46,7 +50,7 @@ void GetHighScoreName (short);
void UpdateBannerDialog (Dialog *); void UpdateBannerDialog (Dialog *);
int16_t BannerFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt); int16_t BannerFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt);
void GetHighScoreBanner (void); void GetHighScoreBanner (void);
Boolean OpenHighScoresFile (const VFileSpec &spec, GpIOStream *&outStream); Boolean OpenHighScoresFile (const VFileSpec &spec, GpIOStream *&outStream, Boolean write);
Str31 highBanner; Str31 highBanner;
@@ -108,13 +112,12 @@ void DoHighScores (void)
void DrawHighScores (DrawSurface *surface) void DrawHighScores (DrawSurface *surface)
{ {
DrawSurface *tempMap, *tempMask; DrawSurface *tempMap, *tempMask;
DrawSurface *wasCPort;
PLError_t theErr; PLError_t theErr;
houseType *thisHousePtr; houseType *thisHousePtr;
Rect tempRect, tempRect2; Rect tempRect, tempRect2;
Str255 tempStr; Str255 tempStr;
short scoreLeft, bannerWidth, i, dropIt; short scoreLeft, bannerWidth, i, dropIt;
char wasState;
PortabilityLayer::ResolveCachingColor blackColor = PortabilityLayer::RGBAColor::Create(0, 0, 0, 255); PortabilityLayer::ResolveCachingColor blackColor = PortabilityLayer::RGBAColor::Create(0, 0, 0, 255);
PortabilityLayer::ResolveCachingColor yellowColor = PortabilityLayer::RGBAColor::Create(255, 255, 0, 255); PortabilityLayer::ResolveCachingColor yellowColor = PortabilityLayer::RGBAColor::Create(255, 255, 0, 255);
PortabilityLayer::ResolveCachingColor cyanColor = PortabilityLayer::RGBAColor::Create(0, 255, 255, 255); PortabilityLayer::ResolveCachingColor cyanColor = PortabilityLayer::RGBAColor::Create(0, 255, 255, 255);
@@ -277,7 +280,6 @@ void SortHighScores (void)
houseType *thisHousePtr; houseType *thisHousePtr;
long greatest; long greatest;
short i, h, which; short i, h, which;
char wasState;
thisHousePtr = *thisHouse; thisHousePtr = *thisHouse;
@@ -313,7 +315,6 @@ void ZeroHighScores (void)
{ {
houseType *thisHousePtr; houseType *thisHousePtr;
short i; short i;
char wasState;
thisHousePtr = *thisHouse; thisHousePtr = *thisHouse;
@@ -356,7 +357,6 @@ Boolean TestHighScore (void)
{ {
houseType *thisHousePtr; houseType *thisHousePtr;
short placing, i; short placing, i;
char wasState;
if (resumedSavedGame) if (resumedSavedGame)
return (false); return (false);
@@ -384,7 +384,7 @@ Boolean TestHighScore (void)
if (placing != -1) if (placing != -1)
{ {
int64_t scoreTimestamp = PortabilityLayer::HostSystemServices::GetInstance()->GetTime(); int64_t scoreTimestamp = PLDrivers::GetSystemServices()->GetTime();
if (scoreTimestamp < 0) if (scoreTimestamp < 0)
scoreTimestamp = 0; scoreTimestamp = 0;
else if (scoreTimestamp > 0xffffffff) else if (scoreTimestamp > 0xffffffff)
@@ -503,6 +503,18 @@ int16_t NameFilter (void *context, Dialog *dial, const TimeTaggedVOSEvent *evt)
return -1; 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 //-------------------------------------------------------------- GetHighScoreName
// Brings up a dialog to get player's name (due to a high score). // Brings up a dialog to get player's name (due to a high score).
@@ -530,6 +542,9 @@ void GetHighScoreName (short place)
UpdateNameDialog(theDial); UpdateNameDialog(theDial);
if (PLDrivers::GetSystemServices()->IsTextInputObstructive())
MoveDialogToTopOfScreen(theDial);
Window *exclStack = theDial->GetWindow(); Window *exclStack = theDial->GetWindow();
wm->SwapExclusiveWindow(exclStack); // Push exclusive window for zooms wm->SwapExclusiveWindow(exclStack); // Push exclusive window for zooms
@@ -640,6 +655,9 @@ void GetHighScoreBanner (void)
UpdateBannerDialog(theDial); UpdateBannerDialog(theDial);
if (PLDrivers::GetSystemServices()->IsTextInputObstructive())
MoveDialogToTopOfScreen(theDial);
Window *exclStack = theDial->GetWindow(); Window *exclStack = theDial->GetWindow();
wm->SwapExclusiveWindow(exclStack); // Push exclusive window for zooms wm->SwapExclusiveWindow(exclStack); // Push exclusive window for zooms
@@ -668,23 +686,18 @@ void GetHighScoreBanner (void)
//-------------------------------------------------------------- OpenHighScoresFile //-------------------------------------------------------------- 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(); 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) if (theErr == PLErrors::kFileNotFound)
{ {
theErr = fm->CreateFileAtCurrentTime(scoreSpec.m_dir, scoreSpec.m_name, 'ozm5', 'gliS'); outStream = nil;
if (!CheckFileError(theErr, PSTR("New High Scores File"))) return (true);
return (false);
theErr = fm->OpenFileData(scoreSpec.m_dir, scoreSpec.m_name, PortabilityLayer::EFilePermission_Any, scoresStream);
if (!CheckFileError(theErr, PSTR("High Score")))
return (false);
} }
else if (!CheckFileError(theErr, PSTR("High Score")))
if (!CheckFileError(theErr, PSTR("High Score")))
return (false); return (false);
return (true); return (true);
@@ -703,18 +716,11 @@ Boolean WriteScoresToDisk (void)
GpIOStream *scoresStream = nil; GpIOStream *scoresStream = nil;
scoreSpec = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kHighScores, thisHouseName); scoreSpec = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kHighScores, thisHouseName);
if (!OpenHighScoresFile(scoreSpec, scoresStream)) if (!OpenHighScoresFile(scoreSpec, scoresStream, true))
{ {
SysBeep(1); SysBeep(1);
return (false); return (false);
} }
if (!scoresStream->SeekStart(0))
{
CheckFileError(PLErrors::kIOError, PSTR("High Scores File"));
scoresStream->Close();
return(false);
}
byteCount = sizeof(scoresType); byteCount = sizeof(scoresType);
theScores = &((*thisHouse)->highScores); theScores = &((*thisHouse)->highScores);
@@ -726,13 +732,6 @@ Boolean WriteScoresToDisk (void)
return(false); return(false);
} }
if (!scoresStream->Truncate(byteCount))
{
CheckFileError(PLErrors::kIOError, PSTR("High Scores File"));
scoresStream->Close();
return(false);
}
scoresStream->Close(); scoresStream->Close();
return (true); return (true);
@@ -759,15 +758,22 @@ Boolean ReadScoresFromDisk (void)
short volRefNum; short volRefNum;
char wasState; char wasState;
GpIOStream *scoresStream = nil; GpIOStream *scoresStream = nil;
VFileSpec scoreSpec = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kHighScores, thisHouseName); VFileSpec scoreSpec = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kHighScores, thisHouseName);
if (!OpenHighScoresFile(scoreSpec, scoresStream)) if (!OpenHighScoresFile(scoreSpec, scoresStream, false))
{ {
SysBeep(1);
return (false); return (false);
} }
if (!scoresStream)
return (false);
byteCount = scoresStream->Size(); byteCount = scoresStream->Size();
if (byteCount != sizeof(scoresType))
{
scoresStream->Close();
return (false);
}
theScores = &((*thisHouse)->highScores); theScores = &((*thisHouse)->highScores);

View File

@@ -12,10 +12,13 @@
#include "PLSysCalls.h" #include "PLSysCalls.h"
#include "DialogUtils.h" #include "DialogUtils.h"
#include "Externs.h" #include "Externs.h"
#include "FileBrowserUI.h"
#include "FileManager.h" #include "FileManager.h"
#include "HostFileSystem.h" #include "FontFamily.h"
#include "House.h" #include "House.h"
#include "MacFileInfo.h"
#include "PLStandardColors.h" #include "PLStandardColors.h"
#include "PLStringCompare.h"
#include "PLTimeTaggedVOSEvent.h" #include "PLTimeTaggedVOSEvent.h"
#include "RectUtils.h" #include "RectUtils.h"
#include "ResourceManager.h" #include "ResourceManager.h"
@@ -30,6 +33,7 @@ void UpdateGoToDialog (Dialog *);
int16_t GoToFilter (void *context, Dialog *dial, const TimeTaggedVOSEvent *evt); int16_t GoToFilter (void *context, Dialog *dial, const TimeTaggedVOSEvent *evt);
extern PortabilityLayer::IResourceArchive *houseResFork; extern PortabilityLayer::IResourceArchive *houseResFork;
extern PortabilityLayer::CompositeFile *houseCFile;
houseHand thisHouse; houseHand thisHouse;
@@ -48,6 +52,43 @@ extern Boolean houseOpen, noRoomAtAll;
extern Boolean twoPlayerGame, wardBitSet, phoneBitSet; 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 //============================================================== Functions
//-------------------------------------------------------------- CreateNewHouse //-------------------------------------------------------------- CreateNewHouse
// Called to create a new house file. // Called to create a new house file.
@@ -68,7 +109,7 @@ Boolean CreateNewHouse (void)
char savePath[sizeof(theSpec.m_name) + 1]; char savePath[sizeof(theSpec.m_name) + 1];
size_t savePathLength = 0; 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; return false;
assert(savePathLength < sizeof(theSpec.m_name) - 1); assert(savePathLength < sizeof(theSpec.m_name) - 1);
@@ -76,9 +117,16 @@ Boolean CreateNewHouse (void)
theSpec.m_name[0] = static_cast<uint8_t>(savePathLength); theSpec.m_name[0] = static_cast<uint8_t>(savePathLength);
memcpy(theSpec.m_name + 1, savePath, 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); CheckFileError(PLErrors::kAccessDenied, theSpec.m_name);
return (false); return (false);
@@ -103,7 +151,7 @@ Boolean CreateNewHouse (void)
AddExtraHouse(theSpec); AddExtraHouse(theSpec);
BuildHouseList(); BuildHouseList();
InitCursor(); InitCursor();
if (!OpenHouse()) if (!OpenHouse(false))
return (false); return (false);
WriteOutPrefs(); WriteOutPrefs();
@@ -125,7 +173,7 @@ Boolean InitializeEmptyHouse (void)
if (thisHouse != nil) if (thisHouse != nil)
thisHouse.Dispose(); thisHouse.Dispose();
thisHouse = NewHandle(sizeof(houseType)).StaticCast<houseType>(); thisHouse = NewHandle(sizeof(houseType) - sizeof(roomType)).StaticCast<houseType>();
if (thisHouse == nil) if (thisHouse == nil)
{ {

View File

@@ -5,43 +5,41 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
//============================================================================ //============================================================================
#include "PLDialogs.h"
#include "PLMovies.h"
#include "PLResources.h"
#include "PLStringCompare.h"
#include "PLPasStr.h"
#include "BitmapImage.h" #include "BitmapImage.h"
#include "DialogManager.h" #include "DialogManager.h"
#include "Externs.h" #include "Externs.h"
#include "Environ.h" #include "Environ.h"
#include "FileManager.h" #include "FileManager.h"
#include "HostFileSystem.h"
#include "HostSystemServices.h"
#include "House.h"
#include "GpIOStream.h" #include "GpIOStream.h"
#include "House.h"
#include "IGpSystemServices.h"
#include "ObjectEdit.h" #include "ObjectEdit.h"
#include "ResourceManager.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 kSaveChangesAlert 1002
#define kSaveChanges 1 #define kSaveChanges 1
#define kDiscardChanges 2 #define kDiscardChanges 2
void LoopMovie (void);
void OpenHouseMovie (void); void OpenHouseMovie (void);
void CloseHouseMovie (void); void CloseHouseMovie (void);
Boolean IsFileReadOnly (const VFileSpec &);
AnimationPlayer theMovie; AnimationPlayer theMovie;
Rect movieRect; Rect movieRect;
PortabilityLayer::IResourceArchive *houseResFork; PortabilityLayer::IResourceArchive *houseResFork;
short wasHouseVersion; short wasHouseVersion;
GpIOStream *houseStream;
Boolean houseOpen, fileDirty; Boolean houseOpen, fileDirty;
Boolean changeLockStateOfHouse, saveHouseLocked, houseIsReadOnly; Boolean changeLockStateOfHouse, saveHouseLocked, houseIsReadOnly;
Boolean hasMovie, tvInRoom; Boolean hasMovie, tvInRoom;
PortabilityLayer::CompositeFile *houseCFile;
extern VFileSpec *theHousesSpecs; extern VFileSpec *theHousesSpecs;
@@ -59,9 +57,7 @@ void OpenHouseMovie (void)
{ {
#ifdef COMPILEQT #ifdef COMPILEQT
VFileSpec theSpec; VFileSpec theSpec;
VFileInfo finderInfo;
Handle spaceSaver; Handle spaceSaver;
PLError_t theErr;
short movieRefNum; short movieRefNum;
Boolean dataRefWasChanged; Boolean dataRefWasChanged;
@@ -69,19 +65,20 @@ void OpenHouseMovie (void)
{ {
theSpec = theHousesSpecs[thisHouseIndex]; theSpec = theHousesSpecs[thisHouseIndex];
PasStringConcat(theSpec.m_name, PSTR(".mov")); PasStringConcat(theSpec.m_name, PSTR(".mov"));
theErr = FSpGetFInfo(theSpec, finderInfo);
if (theErr != PLErrors::kNone)
return;
AnimationPackage *anim = AnimationPackage::Create(); AnimationPackage *anim = AnimationPackage::Create();
if (!anim) if (!anim)
return; 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(); anim->Destroy();
YellowAlert(kYellowQTMovieNotLoaded, theErr);
if (theErr != PLErrors::kFileNotFound)
YellowAlert(kYellowQTMovieNotLoaded, theErr);
return; return;
} }
@@ -116,7 +113,7 @@ void CloseHouseMovie (void)
//-------------------------------------------------------------- OpenHouse //-------------------------------------------------------------- OpenHouse
// Opens a house (whatever current selection is). Returns true if all went well. // Opens a house (whatever current selection is). Returns true if all went well.
Boolean OpenHouse (void) Boolean OpenHouse (Boolean read)
{ {
PLError_t theErr; PLError_t theErr;
@@ -132,12 +129,21 @@ Boolean OpenHouse (void)
if (!StrCmp::EqualCaseInsensitive(theHousesSpecs[thisHouseIndex].name, "\pDemo House")) if (!StrCmp::EqualCaseInsensitive(theHousesSpecs[thisHouseIndex].name, "\pDemo House"))
return (false); return (false);
#endif #endif
houseIsReadOnly = IsFileReadOnly(theHousesSpecs[thisHouseIndex]); houseCFile = PortabilityLayer::FileManager::GetInstance()->OpenCompositeFile(theHousesSpecs[thisHouseIndex].m_dir, theHousesSpecs[thisHouseIndex].m_name);
if (!houseCFile)
theErr = PortabilityLayer::FileManager::GetInstance()->OpenFileData(theHousesSpecs[thisHouseIndex].m_dir, theHousesSpecs[thisHouseIndex].m_name, PortabilityLayer::EFilePermission_Any, houseStream);
if (!CheckFileError(theErr, thisHouseName))
return (false); 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; houseOpen = true;
OpenHouseResFork(); OpenHouseResFork();
@@ -148,6 +154,16 @@ Boolean OpenHouse (void)
tvInRoom = false; tvInRoom = false;
tvWithMovieNumber = -1; tvWithMovieNumber = -1;
OpenHouseMovie(); OpenHouseMovie();
if (read)
{
Boolean readOK = ReadHouse(houseStream);
houseStream->Close();
return readOK;
}
houseStream->Close();
return (true); return (true);
} }
@@ -173,9 +189,7 @@ Boolean OpenSpecificHouse (const VFileSpec &specs)
{ {
thisHouseIndex = i; thisHouseIndex = i;
PasStringCopy(theHousesSpecs[thisHouseIndex].m_name, thisHouseName); PasStringCopy(theHousesSpecs[thisHouseIndex].m_name, thisHouseName);
if (OpenHouse()) if (!OpenHouse(true))
itOpened = ReadHouse();
else
itOpened = false; itOpened = false;
break; break;
} }
@@ -527,7 +541,7 @@ bool ByteSwapHouse(housePtr house, size_t sizeInBytes, bool isSwappedAfter)
return true; return true;
} }
Boolean ReadHouse (void) Boolean ReadHouse (GpIOStream *houseStream)
{ {
long byteCount; long byteCount;
PLError_t theErr; PLError_t theErr;
@@ -653,19 +667,27 @@ Boolean WriteHouse (Boolean checkIt)
UInt32 timeStamp; UInt32 timeStamp;
long byteCount; long byteCount;
PLError_t theErr; PLError_t theErr;
if ((housesFound < 1) || (thisHouseIndex == -1))
return(false);
if (!houseOpen) if (!houseOpen)
{ {
YellowAlert(kYellowUnaccounted, 4); YellowAlert(kYellowUnaccounted, 4);
return (false); return (false);
} }
if (!houseStream->SeekStart(0)) if (!houseCFile)
{ {
CheckFileError(PLErrors::kIOError, thisHouseName); YellowAlert(kYellowUnaccounted, 4);
return(false); return (false);
} }
GpIOStream *houseStream = nil;
theErr = houseCFile->OpenData(PortabilityLayer::EFilePermission_Write, GpFileCreationDispositions::kCreateOrOpen, houseStream);
if (theErr != PLErrors::kNone)
return (false);
CopyThisRoomToRoom(); CopyThisRoomToRoom();
if (checkIt) if (checkIt)
@@ -675,7 +697,7 @@ Boolean WriteHouse (Boolean checkIt)
if (fileDirty) if (fileDirty)
{ {
int64_t currentTime = PortabilityLayer::HostSystemServices::GetInstance()->GetTime(); int64_t currentTime = PLDrivers::GetSystemServices()->GetTime();
if (currentTime > 0x7fffffff) if (currentTime > 0x7fffffff)
currentTime = 0x7fffffff; currentTime = 0x7fffffff;
@@ -699,6 +721,7 @@ Boolean WriteHouse (Boolean checkIt)
{ {
CheckFileError(PLErrors::kIOError, thisHouseName); CheckFileError(PLErrors::kIOError, thisHouseName);
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount), false); ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount), false);
houseStream->Close();
return(false); return(false);
} }
@@ -706,16 +729,13 @@ Boolean WriteHouse (Boolean checkIt)
{ {
CheckFileError(PLErrors::kIOError, thisHouseName); CheckFileError(PLErrors::kIOError, thisHouseName);
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount), false); ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount), false);
houseStream->Close();
return(false); return(false);
} }
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount), false); ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount), false);
if (!houseStream->Truncate(byteCount)) houseStream->Close();
{
CheckFileError(PLErrors::kIOError, thisHouseName);
return(false);
}
if (changeLockStateOfHouse) if (changeLockStateOfHouse)
{ {
@@ -749,7 +769,11 @@ Boolean CloseHouse (void)
CloseHouseResFork(); CloseHouseResFork();
CloseHouseMovie(); CloseHouseMovie();
houseStream->Close(); if (houseCFile)
{
houseCFile->Close();
houseCFile = nil;
}
houseOpen = false; houseOpen = false;
@@ -764,7 +788,7 @@ void OpenHouseResFork (void)
PortabilityLayer::ResourceManager *rm = PortabilityLayer::ResourceManager::GetInstance(); PortabilityLayer::ResourceManager *rm = PortabilityLayer::ResourceManager::GetInstance();
if (houseResFork == nullptr) if (houseResFork == nullptr)
{ {
houseResFork = rm->LoadResFile(theHousesSpecs[thisHouseIndex].m_dir, theHousesSpecs[thisHouseIndex].m_name); houseResFork = rm->LoadResFile(houseCFile);
if (!houseResFork) if (!houseResFork)
YellowAlert(kYellowFailedResOpen, PLErrors::kResourceError); YellowAlert(kYellowFailedResOpen, PLErrors::kResourceError);
} }
@@ -817,8 +841,7 @@ Boolean QuerySaveChanges (void)
if (!quitting) if (!quitting)
{ {
whoCares = CloseHouse(); whoCares = CloseHouse();
if (OpenHouse()) OpenHouse(true);
whoCares = ReadHouse();
} }
UpdateMenus(false); UpdateMenus(false);
return (true); return (true);
@@ -850,13 +873,6 @@ void YellowAlert (short whichAlert, short identifier)
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kYellowAlert, &substitutions); 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 //-------------------------------------------------------------- LoadHousePicture
THandle<void> LoadHouseResource(const PortabilityLayer::ResTypeID &resTypeID, int16_t resID) THandle<void> LoadHouseResource(const PortabilityLayer::ResTypeID &resTypeID, int16_t resID)

View File

@@ -6,16 +6,17 @@
//============================================================================ //============================================================================
#include "PLNumberFormatting.h"
#include "PLKeyEncoding.h"
#include "PLPasStr.h"
#include "Externs.h" #include "Externs.h"
#include "DialogManager.h" #include "DialogManager.h"
#include "DialogUtils.h" #include "DialogUtils.h"
#include "HostDisplayDriver.h"
#include "IGpDisplayDriver.h" #include "IGpDisplayDriver.h"
#include "PLArrayView.h" #include "PLArrayView.h"
#include "PLDrivers.h"
#include "PLEditboxWidget.h" #include "PLEditboxWidget.h"
#include "PLNumberFormatting.h"
#include "PLKeyEncoding.h"
#include "PLPasStr.h"
#include "PLTimeTaggedVOSEvent.h" #include "PLTimeTaggedVOSEvent.h"
@@ -179,7 +180,7 @@ int16_t HouseFilter(void *context, Dialog *dial, const TimeTaggedVOSEvent *evt)
{ {
if (houseCursorIs != kBeamCursor) if (houseCursorIs != kBeamCursor)
{ {
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kIBeam); PLDrivers::GetDisplayDriver()->SetStandardCursor(EGpStandardCursors::kIBeam);
houseCursorIs = kBeamCursor; houseCursorIs = kBeamCursor;
} }
} }

View File

@@ -602,8 +602,6 @@ Boolean KeepObjectLegal (void)
#ifndef COMPILEDEMO #ifndef COMPILEDEMO
void WrapBannerAndTrailer (void) void WrapBannerAndTrailer (void)
{ {
char wasState;
WrapText((*thisHouse)->banner, 40); WrapText((*thisHouse)->banner, 40);
WrapText((*thisHouse)->trailer, 64); WrapText((*thisHouse)->trailer, 64);
} }
@@ -615,11 +613,10 @@ void WrapBannerAndTrailer (void)
void ValidateNumberOfRooms (void) void ValidateNumberOfRooms (void)
{ {
long countedRooms, reportsRooms; long countedRooms, reportsRooms;
char wasState;
reportsRooms = (long)(*thisHouse)->nRooms; reportsRooms = (long)(*thisHouse)->nRooms;
countedRooms = (GetHandleSize(thisHouse.StaticCast<void>()) - countedRooms = (GetHandleSize(thisHouse.StaticCast<void>()) -
sizeof(houseType)) / sizeof(roomType); sizeof(houseType)) / sizeof(roomType) + 1;
if (reportsRooms != countedRooms) if (reportsRooms != countedRooms)
{ {
(*thisHouse)->nRooms = (short)countedRooms; (*thisHouse)->nRooms = (short)countedRooms;
@@ -637,7 +634,6 @@ void CheckDuplicateFloorSuite (void)
#define kRoomsTimesSuites 8192 #define kRoomsTimesSuites 8192
short i, numRooms, bitPlace; short i, numRooms, bitPlace;
char *pidgeonHoles; char *pidgeonHoles;
char wasState;
pidgeonHoles = (char *)NewPtrClear(sizeof(char) * kRoomsTimesSuites); pidgeonHoles = (char *)NewPtrClear(sizeof(char) * kRoomsTimesSuites);
if (pidgeonHoles == nil) if (pidgeonHoles == nil)
@@ -672,7 +668,6 @@ void CheckDuplicateFloorSuite (void)
void CompressHouse (void) void CompressHouse (void)
{ {
short wasFirstRoom, roomNumber, probe; short wasFirstRoom, roomNumber, probe;
char wasState;
Boolean compressing, probing; Boolean compressing, probing;
wasFirstRoom = (*thisHouse)->firstRoom; wasFirstRoom = (*thisHouse)->firstRoom;
@@ -720,7 +715,6 @@ void LopOffExtraRooms (void)
{ {
long newSize; long newSize;
short r, count; short r, count;
char wasState;
Str255 message; Str255 message;
count = 0; count = 0;
@@ -756,7 +750,6 @@ void LopOffExtraRooms (void)
void ValidateRoomNumbers (void) void ValidateRoomNumbers (void)
{ {
short i, numRooms; short i, numRooms;
char wasState;
Str255 message; Str255 message;
numRooms = (*thisHouse)->nRooms; numRooms = (*thisHouse)->nRooms;
@@ -796,7 +789,6 @@ void ValidateRoomNumbers (void)
void CountUntitledRooms (void) void CountUntitledRooms (void)
{ {
short i, numRooms; short i, numRooms;
char wasState;
numRooms = (*thisHouse)->nRooms; numRooms = (*thisHouse)->nRooms;
for (i = 0; i < numRooms; i++) for (i = 0; i < numRooms; i++)
@@ -814,7 +806,6 @@ void CountUntitledRooms (void)
void CheckRoomNameLength (void) void CheckRoomNameLength (void)
{ {
short i, numRooms; short i, numRooms;
char wasState;
numRooms = (*thisHouse)->nRooms; numRooms = (*thisHouse)->nRooms;
for (i = 0; i < numRooms; i++) for (i = 0; i < numRooms; i++)
@@ -837,7 +828,6 @@ void CheckRoomNameLength (void)
void MakeSureNumObjectsJives (void) void MakeSureNumObjectsJives (void)
{ {
short i, h, numRooms, count; short i, h, numRooms, count;
char wasState;
numRooms = (*thisHouse)->nRooms; numRooms = (*thisHouse)->nRooms;
for (i = 0; i < numRooms; i++) for (i = 0; i < numRooms; i++)
@@ -866,7 +856,6 @@ void MakeSureNumObjectsJives (void)
void KeepAllObjectsLegal (void) void KeepAllObjectsLegal (void)
{ {
short i, h, numRooms; short i, h, numRooms;
char wasState;
Str255 message; Str255 message;
numRooms = (*thisHouse)->nRooms; numRooms = (*thisHouse)->nRooms;
@@ -901,7 +890,6 @@ void KeepAllObjectsLegal (void)
void CheckForStaircasePairs (void) void CheckForStaircasePairs (void)
{ {
short i, h, g, numRooms, neighbor; short i, h, g, numRooms, neighbor;
char wasState;
Boolean hasStairs; Boolean hasStairs;
Str255 message; Str255 message;

View File

@@ -42,7 +42,7 @@ void DoPause (void);
void DoTouchScreenMenu (void); void DoTouchScreenMenu (void);
void DoBatteryEngaged (gliderPtr); void DoBatteryEngaged (gliderPtr);
void DoHeliumEngaged (gliderPtr); void DoHeliumEngaged (gliderPtr);
Boolean QuerySaveGame (void); void QuerySaveGame (Boolean &save, Boolean &cancel);
demoPtr demoData; demoPtr demoData;
@@ -75,13 +75,24 @@ void DoCommandKey (void)
if (theKeys->IsSet(PL_KEY_ASCII('Q'))) if (theKeys->IsSet(PL_KEY_ASCII('Q')))
{ {
Boolean wantCancel = false;
playing = false; playing = false;
paused = false; paused = false;
if ((!twoPlayerGame) && (!demoGoing)) if ((!twoPlayerGame) && (!demoGoing))
{ {
if (QuerySaveGame()) Boolean wantSave = false;
SaveGame2(); // New save game. QuerySaveGame(wantSave, wantCancel);
if (wantSave)
{
// New save game.
if (!SaveGame2())
wantCancel = true;
}
} }
if (wantCancel)
playing = true;
} }
else if ((theKeys->IsSet(PL_KEY_ASCII('S'))) && (!twoPlayerGame)) else if ((theKeys->IsSet(PL_KEY_ASCII('S'))) && (!twoPlayerGame))
{ {
@@ -326,12 +337,23 @@ void DoTouchScreenMenu(void)
switch (highlightedItem) switch (highlightedItem)
{ {
case TouchScreenMenuItems::kQuit: case TouchScreenMenuItems::kQuit:
playing = false;
paused = false;
if ((!twoPlayerGame) && (!demoGoing))
{ {
if (QuerySaveGame()) Boolean wantCancel = false;
SaveGame2(); // New save game. playing = false;
paused = false;
if ((!twoPlayerGame) && (!demoGoing))
{
Boolean wantSave = false;
QuerySaveGame(wantSave, wantCancel);
if (wantSave)
{
if (!SaveGame2()) // New save game.
wantCancel = true;
}
}
if (wantCancel)
playing = true;
} }
break; break;
case TouchScreenMenuItems::kSave: case TouchScreenMenuItems::kSave:
@@ -793,19 +815,19 @@ void GetInput (gliderPtr thisGlider)
//-------------------------------------------------------------- QuerySaveGame //-------------------------------------------------------------- QuerySaveGame
Boolean QuerySaveGame (void) void QuerySaveGame (Boolean &save, Boolean &cancel)
{ {
#define kSaveGameAlert 1041 #define kSaveGameAlert 1041
#define kYesSaveGameButton 1 #define kYesSaveGameButton 1
#define kNoSaveGameButton 2
#define kCancelSaveGameButton 3
short hitWhat; short hitWhat;
InitCursor(); InitCursor();
FlushEvents(); FlushEvents();
// CenterAlert(kSaveGameAlert); // CenterAlert(kSaveGameAlert);
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSaveGameAlert, nullptr); hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kSaveGameAlert, nullptr);
if (hitWhat == kYesSaveGameButton) save = (hitWhat == kYesSaveGameButton);
return (true); cancel = (hitWhat == kCancelSaveGameButton);
else
return (false);
} }

View File

@@ -8,17 +8,17 @@
#include "Externs.h" #include "Externs.h"
#include "Environ.h" #include "Environ.h"
#include "HostDisplayDriver.h"
#include "IGpDisplayDriver.h" #include "IGpDisplayDriver.h"
#include "GpApplicationName.h" #include "GpApplicationName.h"
#include "Map.h" #include "Map.h"
#include "MenuManager.h" #include "MenuManager.h"
#include "PLKeyEncoding.h"
#include "PLPasStr.h"
#include "RectUtils.h" #include "RectUtils.h"
#include "ResourceManager.h" #include "ResourceManager.h"
#include "Tools.h" #include "Tools.h"
#include "PLDrivers.h"
#include "PLKeyEncoding.h"
#include "PLPasStr.h"
#define kHandCursorID 128 #define kHandCursorID 128
#define kVertCursorID 129 #define kVertCursorID 129
@@ -55,7 +55,6 @@ void InitializeMenus (void)
RedAlert(kErrFailedResourceLoad); RedAlert(kErrFailedResourceLoad);
//AppendResMenu(appleMenu, 'DRVR'); // GP: We don't support this //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("About " GP_APPLICATION_NAME "\xc9"));
AppendMenuItem(appleMenu, 0, 0, 0, 0, true, false, PSTR("Export Source Code\xc9"));
InsertMenu(appleMenu, 0); InsertMenu(appleMenu, 0);
gameMenu = GetMenu(kGameMenuID); gameMenu = GetMenu(kGameMenuID);
@@ -102,7 +101,7 @@ IGpCursor *LoadBWCursor(int resID)
const BWCursor *cursorData = static_cast<const BWCursor *>(*resHdl); 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(); resHdl.Dispose();
return cursor; return cursor;
@@ -176,8 +175,6 @@ void RecomputeInterfaceRects (void)
void VariableInit (void) void VariableInit (void)
{ {
short i;
menusUp = false; menusUp = false;
quitting = false; quitting = false;
houseOpen = false; houseOpen = false;

View File

@@ -8,34 +8,42 @@
#include "WindowDef.h" #include "WindowDef.h"
#include "BitmapImage.h" #include "BitmapImage.h"
#include "PLApplication.h" #include "FileManager.h"
#include "PLKeyEncoding.h"
#include "PLStandardColors.h"
#include "PLSysCalls.h"
#include "Externs.h" #include "Externs.h"
#include "Environ.h" #include "Environ.h"
#include "FontFamily.h" #include "FontFamily.h"
#include "FontManager.h"
#include "GpApplicationName.h"
#include "GpRenderedFontMetrics.h" #include "GpRenderedFontMetrics.h"
#include "HostDisplayDriver.h" #include "IGpMutex.h"
#include "HostSystemServices.h" #include "IGpThreadEvent.h"
#include "HostThreadEvent.h"
#include "IGpDisplayDriver.h" #include "IGpDisplayDriver.h"
#include "IGpSystemServices.h"
#include "GpIOStream.h" #include "GpIOStream.h"
#include "House.h" #include "House.h"
#include "MainMenuUI.h" #include "MainMenuUI.h"
#include "MemoryManager.h" #include "MemoryManager.h"
#include "MenuManager.h" #include "MenuManager.h"
#include "QDPixMap.h" #include "QDPixMap.h"
#include "QDStandardPalette.h"
#include "RenderedFont.h" #include "RenderedFont.h"
#include "ResolveCachingColor.h" #include "ResolveCachingColor.h"
#include "ResourceManager.h" #include "ResourceManager.h"
#include "PLTimeTaggedVOSEvent.h"
#include "Utilities.h" #include "Utilities.h"
#include "Vec2i.h"
#include "WindowManager.h" #include "WindowManager.h"
#include "WorkerThread.h" #include "WorkerThread.h"
#include "PLApplication.h"
#include "PLDrivers.h"
#include "PLKeyEncoding.h"
#include "PLStandardColors.h"
#include "PLSysCalls.h"
#include <atomic> #include <atomic>
int loadScreenWindowPhase;
int loadScreenRingStep; int loadScreenRingStep;
WindowPtr loadScreenWindow; WindowPtr loadScreenWindow;
Rect loadScreenProgressBarRect; Rect loadScreenProgressBarRect;
@@ -43,11 +51,12 @@ int loadScreenProgress;
DrawSurface *loadScreenRingSurface; DrawSurface *loadScreenRingSurface;
#define kPrefsVersion 0x0038 #define kPrefsVersion 0x0039
void ReadInPrefs (void); void ReadInPrefs (void);
void WriteOutPrefs (void); void WriteOutPrefs (void);
void HandleSplashResolutionChange (void);
int main(int argc, const char **argv); int main(int argc, const char **argv);
@@ -62,7 +71,7 @@ extern Str15 leftName, rightName, batteryName, bandName;
extern Str15 highName; extern Str15 highName;
//extern long encryptedNumber; //extern long encryptedNumber;
extern short maxFiles, numNeighbors, willMaxFiles; extern short maxFiles, numNeighbors, willMaxFiles;
extern GpIOStream *houseStream; extern PortabilityLayer::CompositeFile *houseCFile;
extern short isEditH, isEditV, isMapH, isMapV; extern short isEditH, isEditV, isMapH, isMapV;
extern short isToolsH, isToolsV, isCoordH, isCoordV; extern short isToolsH, isToolsV, isCoordH, isCoordV;
extern short isLinkH, isLinkV, toolMode, mapLeftRoom, mapTopRoom; extern short isLinkH, isLinkV, toolMode, mapLeftRoom, mapTopRoom;
@@ -71,7 +80,7 @@ extern Boolean isMusicOn, isSoundOn, isPlayMusicIdle, isHouseChecks;
extern Boolean houseOpen, isDoColorFade, isEscPauseKey; extern Boolean houseOpen, isDoColorFade, isEscPauseKey;
extern Boolean autoRoomEdit, doAutoDemo, doBackground; extern Boolean autoRoomEdit, doAutoDemo, doBackground;
extern Boolean isMapOpen, isToolsOpen, isCoordOpen; extern Boolean isMapOpen, isToolsOpen, isCoordOpen;
extern Boolean doPrettyMap, doBitchDialogs; extern Boolean doPrettyMap, doComplainDialogs;
//extern Boolean didValidation; //extern Boolean didValidation;
THandle<void> globalModulePrefs; THandle<void> globalModulePrefs;
@@ -159,7 +168,7 @@ void ReadInPrefs (void)
isUseICCProfile = thePrefs.wasUseICCProfile; isUseICCProfile = thePrefs.wasUseICCProfile;
doBackground = thePrefs.wasDoBackground; doBackground = thePrefs.wasDoBackground;
doPrettyMap = thePrefs.wasPrettyMap; doPrettyMap = thePrefs.wasPrettyMap;
doBitchDialogs = thePrefs.wasBitchDialogs; doComplainDialogs = thePrefs.wasComplainDialogs;
if (modulePrefs) if (modulePrefs)
ApplyModulePrefs(&modulePrefs); ApplyModulePrefs(&modulePrefs);
@@ -217,12 +226,12 @@ void ReadInPrefs (void)
isEditV = 41; isEditV = 41;
isMapH = 3; isMapH = 3;
// isMapV = qd.screenBits.bounds.bottom - 100; // isMapV = qd.screenBits.bounds.bottom - 100;
isMapV = 100; isMapV = 385;
mapRoomsWide = 15; mapRoomsWide = 15;
mapRoomsHigh = 4; mapRoomsHigh = 4;
// isToolsH = qd.screenBits.bounds.right - 120; // isToolsH = qd.screenBits.bounds.right - 120;
isToolsH = 100; isToolsH = 525;
isToolsV = 35; isToolsV = 41;
isLinkH = 50; isLinkH = 50;
isLinkV = 80; isLinkV = 80;
// isCoordH = qd.screenBits.bounds.right - 55; // isCoordH = qd.screenBits.bounds.right - 55;
@@ -244,10 +253,10 @@ void ReadInPrefs (void)
isUseICCProfile = true; isUseICCProfile = true;
doBackground = false; doBackground = false;
doPrettyMap = false; doPrettyMap = false;
doBitchDialogs = true; doComplainDialogs = true;
IGpDisplayDriver *displayDriver = PortabilityLayer::HostDisplayDriver::GetInstance(); IGpDisplayDriver *displayDriver = PLDrivers::GetDisplayDriver();
if (!displayDriver->IsFullScreen()) if (PLDrivers::GetSystemServices()->IsFullscreenPreferred() != displayDriver->IsFullScreen())
displayDriver->RequestToggleFullScreen(0); displayDriver->RequestToggleFullScreen(0);
modulePrefs.Dispose(); modulePrefs.Dispose();
@@ -345,7 +354,7 @@ void WriteOutPrefs (void)
thePrefs.wasUseICCProfile = isUseICCProfile; thePrefs.wasUseICCProfile = isUseICCProfile;
thePrefs.wasDoBackground = doBackground; thePrefs.wasDoBackground = doBackground;
thePrefs.wasPrettyMap = doPrettyMap; thePrefs.wasPrettyMap = doPrettyMap;
thePrefs.wasBitchDialogs = doBitchDialogs; thePrefs.wasComplainDialogs = doComplainDialogs;
THandle<void> modulePrefs; THandle<void> modulePrefs;
@@ -353,8 +362,6 @@ void WriteOutPrefs (void)
SysBeep(1); SysBeep(1);
modulePrefs.Dispose(); modulePrefs.Dispose();
UnivSetSoundVolume(wasVolume, thisMac.hasSM3);
} }
void StepLoadScreenRing() void StepLoadScreenRing()
@@ -369,18 +376,173 @@ void StepLoadScreenRing()
Rect ringDestRect = Rect::Create(8, 8, 24, 24); Rect ringDestRect = Rect::Create(8, 8, 24, 24);
Rect ringSrcRect = Rect::Create(0, 0, 16, 16) + Point::Create((loadScreenRingStep / loadScreenStepGranularity) * 16, 0); 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); CopyBits(*loadScreenRingSurface->m_port.GetPixMap(), *loadScreenWindow->GetDrawSurface()->m_port.GetPixMap(), &ringSrcRect, &ringDestRect, srcCopy);
loadScreenWindow->GetDrawSurface()->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); 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) if (loadScreenWindow)
{ {
Rect loadScreenProgressBarFillRect = loadScreenProgressBarRect.Inset(1, 1); static const int kLoadScreenPhaseSwitchBreakpoint = 20;
int oldProgress = loadScreenProgress; 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; loadScreenProgress = loadScreenProgress + steps;
if (loadScreenProgress > loadScreenMax) if (loadScreenProgress > loadScreenMax)
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); loadScreenWindow->GetDrawSurface()->FillRect(Rect::Create(loadScreenProgressBarFillRect.top, loadScreenProgressBarFillRect.left + prevStep, loadScreenProgressBarFillRect.bottom, loadScreenProgressBarFillRect.left + thisStep), fillColor);
ForceSyncFrame(); ForceSyncFrame();
for (int i = 0; i < steps; i++) if (insertDelay)
{ {
StepLoadScreenRing(); StepLoadScreenRing();
Delay(1, nullptr); Delay(1, nullptr);
@@ -409,72 +571,12 @@ void InitLoadingWindow()
if (!thisMac.isTouchscreen) if (!thisMac.isTouchscreen)
return; return;
static const int kLoadScreenHeight = 32; if (isPrefsLoaded)
static const int kLoadRingResource = 1302; loadScreenWindowPhase = 1;
else
loadScreenWindowPhase = 0;
int kLoadScreenWidth = 296; CreateLoadScreenWindow(loadScreenWindowPhase);
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;
} }
enum PreloadFontCategory enum PreloadFontCategory
@@ -495,7 +597,7 @@ struct PreloadFontSpec
struct PreloadFontWorkSlot struct PreloadFontWorkSlot
{ {
PortabilityLayer::HostThreadEvent *m_completedEvent; IGpThreadEvent *m_completedEvent;
PortabilityLayer::WorkerThread *m_workerThread; PortabilityLayer::WorkerThread *m_workerThread;
std::atomic<int> m_singleJobCompleted; std::atomic<int> m_singleJobCompleted;
const PreloadFontSpec *m_spec; 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); PreloadFontWorkSlot *wSlot = static_cast<PreloadFontWorkSlot*>(context);
PreloadSingleFont(*wSlot->m_spec); PreloadSingleFont(*wSlot->m_spec);
++wSlot->m_singleJobCompleted; wSlot->m_singleJobCompleted.fetch_add(1, std::memory_order_release);
wSlot->m_completedEvent->Signal(); wSlot->m_completedEvent->Signal();
} }
@@ -553,6 +655,9 @@ void PreloadFonts()
{ {
static PreloadFontSpec specs[] = 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, 9, PortabilityLayer::FontFamilyFlag_Bold, true },
{ FontCategory_System, 10, PortabilityLayer::FontFamilyFlag_Bold, true }, { FontCategory_System, 10, PortabilityLayer::FontFamilyFlag_Bold, true },
{ FontCategory_System, 12, PortabilityLayer::FontFamilyFlag_None, true }, { FontCategory_System, 12, PortabilityLayer::FontFamilyFlag_None, true },
@@ -561,7 +666,7 @@ void PreloadFonts()
{ FontCategory_Application, 9, PortabilityLayer::FontFamilyFlag_None, true }, { FontCategory_Application, 9, PortabilityLayer::FontFamilyFlag_None, true },
{ FontCategory_Application, 12, PortabilityLayer::FontFamilyFlag_Bold, true }, { FontCategory_Application, 12, PortabilityLayer::FontFamilyFlag_Bold, true },
{ FontCategory_Application, 14, 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_Application, 40, PortabilityLayer::FontFamilyFlag_None, true },
{ FontCategory_Handwriting, 24, PortabilityLayer::FontFamilyFlag_None, true }, { FontCategory_Handwriting, 24, PortabilityLayer::FontFamilyFlag_None, true },
{ FontCategory_Handwriting, 48, PortabilityLayer::FontFamilyFlag_None, true }, { FontCategory_Handwriting, 48, PortabilityLayer::FontFamilyFlag_None, true },
@@ -570,7 +675,6 @@ void PreloadFonts()
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance(); PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
const int numFontSpecs = sizeof(specs) / sizeof(specs[0]); const int numFontSpecs = sizeof(specs) / sizeof(specs[0]);
int queuedSpecs = 0; int queuedSpecs = 0;
@@ -580,19 +684,19 @@ void PreloadFonts()
// but we can do this to unclog the render thread. // but we can do this to unclog the render thread.
PreloadFontWorkSlot slot; PreloadFontWorkSlot slot;
slot.m_workerThread = PortabilityLayer::WorkerThread::Create(); 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) while (completedSpecs < numFontSpecs)
{ {
if (slot.m_queued) 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_completedEvent->Wait();
slot.m_queued = false; slot.m_queued = false;
completedSpecs++; completedSpecs++;
StepLoadScreen(1); StepLoadScreen(1, false);
} }
} }
@@ -601,9 +705,9 @@ void PreloadFonts()
if (queuedSpecs < numFontSpecs) if (queuedSpecs < numFontSpecs)
{ {
slot.m_queued = true; slot.m_queued = true;
slot.m_singleJobCompleted.store(0);
slot.m_spec = specs + queuedSpecs; 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++; queuedSpecs++;
} }
@@ -613,6 +717,344 @@ void PreloadFonts()
Delay(1, nullptr); 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() void gpAppInit()
@@ -653,8 +1095,10 @@ int gpAppMain()
SpinCursor(2); // Tick once to let the display driver flush any resolution changes from prefs SpinCursor(2); // Tick once to let the display driver flush any resolution changes from prefs
FlushResolutionChange(); FlushResolutionChange();
InitLoadingWindow(); StepLoadScreen(2); InitLoadingWindow(); StepLoadScreen(2, true);
PreloadFonts(); StepLoadScreen(2); PreloadAATables();
assert(isPrefsLoaded || loadScreenWindowPhase == 0);
PreloadFonts(); StepLoadScreen(2, true);
#if defined COMPILEDEMO #if defined COMPILEDEMO
copyGood = true; copyGood = true;
@@ -673,12 +1117,12 @@ int gpAppMain()
// if ((thisMac.numScreens > 1) && (isUseSecondScreen)) // if ((thisMac.numScreens > 1) && (isUseSecondScreen))
// ReflectSecondMonitorEnvirons(false, true, true); // ReflectSecondMonitorEnvirons(false, true, true);
HandleDepthSwitching(); HandleDepthSwitching();
VariableInit(); StepLoadScreen(2); VariableInit(); StepLoadScreen(2, true);
GetExtraCursors(); StepLoadScreen(2); GetExtraCursors(); StepLoadScreen(2, true);
InitMarquee(); InitMarquee();
CreatePointers(); StepLoadScreen(2); CreatePointers(); StepLoadScreen(2, true);
InitSrcRects(); InitSrcRects();
CreateOffscreens(); StepLoadScreen(2); CreateOffscreens(); StepLoadScreen(2, true);
if (loadScreenWindow) if (loadScreenWindow)
{ {
@@ -693,12 +1137,28 @@ int gpAppMain()
loadScreenRingSurface = nullptr; loadScreenRingSurface = nullptr;
} }
bool resolutionChanged = false;
if (!isPrefsLoaded) if (!isPrefsLoaded)
{ {
WriteOutPrefs(); WriteOutPrefs();
if (thisMac.isResolutionDirty)
{
resolutionChanged = true;
FlushResolutionChange();
}
ShowInitialLaunchDisclaimer();
} }
OpenMainWindow(); if (thisMac.isResolutionDirty)
resolutionChanged = true;
if (resolutionChanged)
HandleSplashResolutionChange();
else
OpenMainWindow();
if (isDoColorFade) if (isDoColorFade)
PortabilityLayer::WindowManager::GetInstance()->SetWindowDesaturation(mainWindow, 1.0); PortabilityLayer::WindowManager::GetInstance()->SetWindowDesaturation(mainWindow, 1.0);
@@ -706,8 +1166,7 @@ int gpAppMain()
InitSound(); SpinCursor(2); InitSound(); SpinCursor(2);
InitMusic(); SpinCursor(2); InitMusic(); SpinCursor(2);
BuildHouseList(); BuildHouseList();
if (OpenHouse()) OpenHouse(true);
whoCares = ReadHouse();
PlayPrioritySound(kBirdSound, kBirdPriority); PlayPrioritySound(kBirdSound, kBirdPriority);
DelayTicks(6); DelayTicks(6);
@@ -740,7 +1199,8 @@ int gpAppMain()
if (!CloseHouse()) if (!CloseHouse())
{ {
CloseHouseResFork(); CloseHouseResFork();
houseStream->Close(); if (houseCFile)
houseCFile->Close();
houseOpen = false; houseOpen = false;
} }
} }

View File

@@ -2,14 +2,9 @@
#include "FontFamily.h" #include "FontFamily.h"
#include "GpApplicationName.h" #include "GpApplicationName.h"
#include "HostDisplayDriver.h"
#include "GliderProtos.h" #include "GliderProtos.h"
#include "Externs.h" #include "Externs.h"
#include "IGpDisplayDriver.h" #include "IGpDisplayDriver.h"
#include "PLCore.h"
#include "PLQDraw.h"
#include "PLStandardColors.h"
#include "PLSysCalls.h"
#include "RenderedFont.h" #include "RenderedFont.h"
#include "GpRenderedFontMetrics.h" #include "GpRenderedFontMetrics.h"
#include "MainMenuUI.h" #include "MainMenuUI.h"
@@ -19,6 +14,12 @@
#include "WindowManager.h" #include "WindowManager.h"
#include "Vec2i.h" #include "Vec2i.h"
#include "PLCore.h"
#include "PLDrivers.h"
#include "PLQDraw.h"
#include "PLStandardColors.h"
#include "PLSysCalls.h"
struct MainMenuControlState struct MainMenuControlState
{ {
Window *m_window; Window *m_window;
@@ -168,8 +169,7 @@ static void DrawMainMenuControl(DrawSurface *surface, MainMenuUIState::ControlID
void StartScrollForPage() void StartScrollForPage()
{ {
unsigned int displayHeight = 0; unsigned int displayHeight = PortabilityLayer::WindowManager::GetInstance()->GetDisplayResolution().m_y;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
DismissMainMenuUI(); DismissMainMenuUI();
@@ -262,8 +262,7 @@ void StartMainMenuUI()
static void DismissMainMenuUIPage() static void DismissMainMenuUIPage()
{ {
unsigned int displayHeight = 0; unsigned int displayHeight = PortabilityLayer::WindowManager::GetInstance()->GetDisplayResolution().m_y;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance(); PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
@@ -292,8 +291,7 @@ void TickMainMenuUI()
{ {
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance(); PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
unsigned int displayHeight = 0; unsigned int displayHeight = PortabilityLayer::WindowManager::GetInstance()->GetDisplayResolution().m_y;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
mainMenu.m_scrollInStep -= MainMenuUIState::kControlScrollInDecay; mainMenu.m_scrollInStep -= MainMenuUIState::kControlScrollInDecay;
mainMenu.m_scrollInOffset -= (mainMenu.m_scrollInStep >> MainMenuUIState::kControlScrollInDecayFalloffBits); mainMenu.m_scrollInOffset -= (mainMenu.m_scrollInStep >> MainMenuUIState::kControlScrollInDecayFalloffBits);
@@ -327,8 +325,7 @@ void HandleMainMenuUIResolutionChange()
{ {
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance(); PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
unsigned int displayHeight = 0; unsigned int displayHeight = PortabilityLayer::WindowManager::GetInstance()->GetDisplayResolution().m_y;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
for (int i = 0; i < MainMenuUIState::Control_Count; i++) for (int i = 0; i < MainMenuUIState::Control_Count; i++)
{ {

View File

@@ -5,12 +5,9 @@
//============================================================================ //============================================================================
#include "PLNumberFormatting.h"
#include "PLPasStr.h"
#include "Externs.h" #include "Externs.h"
#include "Environ.h" #include "Environ.h"
#include "FontFamily.h" #include "FontFamily.h"
#include "HostDisplayDriver.h"
#include "House.h" #include "House.h"
#include "IGpDisplayDriver.h" #include "IGpDisplayDriver.h"
#include "InputManager.h" #include "InputManager.h"
@@ -23,6 +20,9 @@
#include "WindowDef.h" #include "WindowDef.h"
#include "WindowManager.h" #include "WindowManager.h"
#include "PLDrivers.h"
#include "PLNumberFormatting.h"
#include "PLPasStr.h"
#define kMainWindowID 128 #define kMainWindowID 128
#define kEditWindowID 129 #define kEditWindowID 129

View File

@@ -53,7 +53,7 @@ short isMapH, isMapV, mapRoomsHigh, mapRoomsWide;
short mapLeftRoom, mapTopRoom; short mapLeftRoom, mapTopRoom;
Boolean isMapOpen, doPrettyMap; Boolean isMapOpen, doPrettyMap;
extern Boolean doBitchDialogs; extern Boolean doComplainDialogs;
//============================================================== Functions //============================================================== Functions
@@ -651,7 +651,7 @@ void HandleMapClick (const GpMouseInputEvent &theEvent)
} }
else else
{ {
if (doBitchDialogs) if (doComplainDialogs)
{ {
if (QueryNewRoom()) if (QueryNewRoom())
{ {

View File

@@ -6,7 +6,6 @@
#include "Externs.h" #include "Externs.h"
#include "HostDisplayDriver.h"
#include "IGpDisplayDriver.h" #include "IGpDisplayDriver.h"
#include "InputManager.h" #include "InputManager.h"
#include "Marquee.h" #include "Marquee.h"
@@ -14,6 +13,8 @@
#include "ObjectEdit.h" #include "ObjectEdit.h"
#include "RectUtils.h" #include "RectUtils.h"
#include "PLDrivers.h"
#include <assert.h> #include <assert.h>
#include <algorithm> #include <algorithm>
@@ -42,16 +43,23 @@ void DoMarquee (void)
{ {
if ((!theMarquee.active) || (theMarquee.paused)) if ((!theMarquee.active) || (theMarquee.paused))
return; 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]; theMarquee.step++;
DrawMarquee(surface, pattern);
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 //-------------------------------------------------------------- StartMarquee
@@ -222,7 +230,7 @@ void DragMarqueeRect (Window *window, DrawSurface *surface, Point start, Rect *t
Point wasPt, newPt; Point wasPt, newPt;
short deltaH, deltaV; short deltaH, deltaV;
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(handCursor); PLDrivers::GetDisplayDriver()->SetCursor(handCursor);
StopMarquee(); StopMarquee();
const uint8_t *pattern = theMarquee.pats[theMarquee.index]; const uint8_t *pattern = theMarquee.pats[theMarquee.index];
@@ -265,9 +273,9 @@ void DragMarqueeHandle (Window *window, DrawSurface *surface, Point start, short
short deltaH, deltaV; short deltaH, deltaV;
if ((theMarquee.direction == kAbove) || (theMarquee.direction == kBelow)) if ((theMarquee.direction == kAbove) || (theMarquee.direction == kBelow))
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(vertCursor); PLDrivers::GetDisplayDriver()->SetCursor(vertCursor);
else else
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(horiCursor); PLDrivers::GetDisplayDriver()->SetCursor(horiCursor);
StopMarquee(); StopMarquee();
const uint8_t *pattern = theMarquee.pats[theMarquee.index]; const uint8_t *pattern = theMarquee.pats[theMarquee.index];
@@ -349,7 +357,7 @@ void DragMarqueeCorner (Window *window, DrawSurface *surface, Point start, short
Point wasPt, newPt; Point wasPt, newPt;
short deltaH, deltaV; short deltaH, deltaV;
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(diagCursor); PLDrivers::GetDisplayDriver()->SetCursor(diagCursor);
StopMarquee(); StopMarquee();
const uint8_t *pattern = theMarquee.pats[theMarquee.index]; const uint8_t *pattern = theMarquee.pats[theMarquee.index];
@@ -514,6 +522,8 @@ void InitMarquee (void)
theMarquee.active = false; theMarquee.active = false;
theMarquee.paused = false; theMarquee.paused = false;
theMarquee.handled = false; theMarquee.handled = false;
theMarquee.step = 0;
theMarquee.interval = 2;
gliderMarqueeUp = false; gliderMarqueeUp = false;
} }

View File

@@ -15,7 +15,7 @@ typedef struct
{ {
Pattern pats[kNumMarqueePats]; Pattern pats[kNumMarqueePats];
Rect bounds, handle; Rect bounds, handle;
short index, direction, dist; short index, direction, dist, step, interval;
Boolean active, paused, handled; Boolean active, paused, handled;
} marquee; } marquee;

View File

@@ -426,6 +426,7 @@ void DoOptionsMenu (short theItem)
} }
OpenMainWindow(); OpenMainWindow();
RedrawSplashScreen();
incrementModeTime = TickCount() + kIdleSplashTicks; incrementModeTime = TickCount() + kIdleSplashTicks;
} }
else if (theMode == kSplashMode) // switching to edit mode else if (theMode == kSplashMode) // switching to edit mode

View File

@@ -4,18 +4,18 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
//============================================================================ //============================================================================
#include "PLResources.h"
#include "PLSound.h"
#include "DialogManager.h" #include "DialogManager.h"
#include "Environ.h" #include "Environ.h"
#include "Externs.h" #include "Externs.h"
#include "SoundSync.h" #include "SoundSync.h"
#include "HostMutex.h" #include "IGpMutex.h"
#include "HostSystemServices.h" #include "IGpSystemServices.h"
#include "MemoryManager.h" #include "MemoryManager.h"
#include "ResourceManager.h" #include "ResourceManager.h"
#include "PLDrivers.h"
#include "PLResources.h"
#include "PLSound.h"
#define kBaseBufferMusicID 2000 #define kBaseBufferMusicID 2000
#define kMaxMusic 7 #define kMaxMusic 7
@@ -47,7 +47,7 @@ struct MusicState
}; };
MusicState musicState; MusicState musicState;
PortabilityLayer::HostMutex *musicMutex; IGpMutex *musicMutex;
extern Boolean isSoundOn; extern Boolean isSoundOn;
@@ -337,7 +337,7 @@ void InitMusic (void)
musicState.musicSoundID = musicScore[musicState.musicCursor]; musicState.musicSoundID = musicScore[musicState.musicCursor];
musicState.musicMode = kPlayWholeScoreMode; musicState.musicMode = kPlayWholeScoreMode;
musicMutex = PortabilityLayer::HostSystemServices::GetInstance()->CreateMutex(); musicMutex = PLDrivers::GetSystemServices()->CreateMutex();
PL_NotYetImplemented_TODO("MusicSync"); PL_NotYetImplemented_TODO("MusicSync");

View File

@@ -1963,6 +1963,12 @@ void GetThisRoomsObjRects (void)
if ((noRoomAtAll) || (!houseUnlocked)) 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; return;
} }
else else

View File

@@ -278,12 +278,11 @@ void DoDemoGame (void)
whoCares = CloseHouse(); whoCares = CloseHouse();
thisHouseIndex = demoHouseIndex; thisHouseIndex = demoHouseIndex;
PasStringCopy(theHousesSpecs[thisHouseIndex].m_name, thisHouseName); PasStringCopy(theHousesSpecs[thisHouseIndex].m_name, thisHouseName);
if (OpenHouse()) if (OpenHouse(true))
{ {
if (thisMac.isTouchscreen) if (thisMac.isTouchscreen)
DismissMainMenuUI(); DismissMainMenuUI();
whoCares = ReadHouse();
demoGoing = true; demoGoing = true;
NewGame(kNewGameMode); NewGame(kNewGameMode);
@@ -293,9 +292,9 @@ void DoDemoGame (void)
whoCares = CloseHouse(); whoCares = CloseHouse();
thisHouseIndex = wasHouseIndex; thisHouseIndex = wasHouseIndex;
PasStringCopy(theHousesSpecs[thisHouseIndex].m_name, thisHouseName); PasStringCopy(theHousesSpecs[thisHouseIndex].m_name, thisHouseName);
if (OpenHouse()) OpenHouse(true);
whoCares = ReadHouse();
incrementModeTime = TickCount() + kIdleSplashTicks; incrementModeTime = TickCount() + kIdleSplashTicks;
RedrawSplashScreen();
} }
//-------------------------------------------------------------- InitGlider //-------------------------------------------------------------- InitGlider

View File

@@ -16,14 +16,13 @@
#include "IGpPrefsHandler.h" #include "IGpPrefsHandler.h"
#include "GpIOStream.h" #include "GpIOStream.h"
#include "MemoryManager.h" #include "MemoryManager.h"
#include "HostAudioDriver.h"
#include "HostDisplayDriver.h" #include "PLDrivers.h"
#include "HostInputDriver.h"
#define kPrefCreatorType 'ozm5' #define kPrefCreatorType 'ozm5'
#define kPrefFileType 'gliP' #define kPrefFileType 'gliP'
#define kPrefFileName PSTR("Glider Prefs v2") #define kPrefFileName PSTR("Glider Prefs")
#define kDefaultPrefFName PSTR("Preferences") #define kDefaultPrefFName PSTR("Preferences")
#define kPrefsStringsID 160 #define kPrefsStringsID 160
#define kNewPrefsAlertID 160 #define kNewPrefsAlertID 160
@@ -68,16 +67,8 @@ Boolean WritePrefs (const prefsInfo *thePrefs, short versionNow, THandle<moduleP
PasStringCopy(kPrefFileName, fileName); PasStringCopy(kPrefFileName, fileName);
VFileSpec theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kPrefs, fileName); VFileSpec theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kPrefs, fileName);
if (!fm->FileExists(PortabilityLayer::VirtualDirectories::kPrefs, fileName))
{ theErr = fm->OpenNonCompositeFile(theSpecs.m_dir, theSpecs.m_name, ".dat", PortabilityLayer::EFilePermission_Write, GpFileCreationDispositions::kCreateOrOverwrite, fileStream);
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);
if (theErr != PLErrors::kNone) if (theErr != PLErrors::kNone)
{ {
CheckFileError(theErr, PSTR("Preferences")); CheckFileError(theErr, PSTR("Preferences"));
@@ -202,10 +193,10 @@ PLError_t ReadPrefs (prefsInfo *thePrefs, short versionNeed, Boolean *isOldVersi
theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectory_t::kPrefs, fileName); theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectory_t::kPrefs, fileName);
if (!PortabilityLayer::FileManager::GetInstance()->FileExists(theSpecs.m_dir, theSpecs.m_name)) theErr = fm->OpenNonCompositeFile(theSpecs.m_dir, theSpecs.m_name, ".dat", PortabilityLayer::EFilePermission_Read, GpFileCreationDispositions::kOpenExisting, fileStream);
return PLErrors::kFileNotFound; if (theErr == PLErrors::kFileNotFound)
return theErr;
theErr = fm->OpenFileData(theSpecs.m_dir, theSpecs.m_name, PortabilityLayer::EFilePermission_Read, fileStream);
if (theErr != PLErrors::kNone) if (theErr != PLErrors::kNone)
{ {
CheckFileError(theErr, PSTR("Preferences")); CheckFileError(theErr, PSTR("Preferences"));
@@ -327,29 +318,29 @@ Boolean DeletePrefs ()
theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kPrefs, fileName); 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 //-------------------------------------------------------------- RunFunctionOnAllPrefsHandlers
bool RunFunctionOnAllPrefsHandlers (void *context, bool (*func) (void *context, IGpPrefsHandler *handler)) 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)) if (ddHandler && !func(context, ddHandler))
return false; return false;
if (IGpAudioDriver *audioDriver = PortabilityLayer::HostAudioDriver::GetInstance()) if (IGpAudioDriver *audioDriver = PLDrivers::GetAudioDriver())
{ {
IGpPrefsHandler *adHandler = audioDriver->GetPrefsHandler(); IGpPrefsHandler *adHandler = audioDriver->GetPrefsHandler();
if (adHandler && !func(context, adHandler)) if (adHandler && !func(context, adHandler))
return false; return false;
} }
size_t numInputDrivers = PortabilityLayer::HostInputDriver::NumInstances(); size_t numInputDrivers = PLDrivers::GetNumInputDrivers();
for (size_t i = 0; i < numInputDrivers; i++) 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)) if (idHandler && !func(context, idHandler))
return false; return false;
} }

View File

@@ -35,7 +35,7 @@ short numberRooms, thisRoomNumber, previousRoom;
short leftThresh, rightThresh, lastBackground; short leftThresh, rightThresh, lastBackground;
Boolean autoRoomEdit, newRoomNow, noRoomAtAll; Boolean autoRoomEdit, newRoomNow, noRoomAtAll;
Boolean leftOpen, rightOpen, topOpen, bottomOpen; Boolean leftOpen, rightOpen, topOpen, bottomOpen;
Boolean doBitchDialogs; Boolean doComplainDialogs;
extern short tempTiles[]; extern short tempTiles[];

View File

@@ -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 "DialogManager.h"
#include "DialogUtils.h" #include "DialogUtils.h"
#include "Externs.h" #include "Externs.h"
#include "HostDisplayDriver.h"
#include "IGpDisplayDriver.h" #include "IGpDisplayDriver.h"
#include "RectUtils.h" #include "RectUtils.h"
#include "PLPopupMenuWidget.h" #include "PLPopupMenuWidget.h"
@@ -25,6 +18,13 @@
#include "ResourceManager.h" #include "ResourceManager.h"
#include "Utilities.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 kRoomInfoDialogID 1003
#define kOriginalArtDialogID 1016 #define kOriginalArtDialogID 1016
@@ -54,7 +54,7 @@ void UpdateOriginalArt (Dialog *);
int16_t OriginalArtFilter (void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt); int16_t OriginalArtFilter (void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt);
Boolean PictIDExists (short); Boolean PictIDExists (short);
short GetFirstPICT (void); short GetFirstPICT (void);
void BitchAboutPICTNotFound (void); void ComplainAboutPICTNotFound (void);
Rect tileSrc, tileDest, tileSrcRect, editTETextBox; Rect tileSrc, tileDest, tileSrcRect, editTETextBox;
@@ -271,7 +271,7 @@ void HiliteTileOver (DrawSurface *surface, Point mouseIs)
{ {
if (cursorIs != kHandCursor) if (cursorIs != kHandCursor)
{ {
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(handCursor); PLDrivers::GetDisplayDriver()->SetCursor(handCursor);
cursorIs = kHandCursor; cursorIs = kHandCursor;
} }
@@ -325,7 +325,7 @@ void HiliteTileOver (DrawSurface *surface, Point mouseIs)
{ {
if (cursorIs != kBeamCursor) if (cursorIs != kBeamCursor)
{ {
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kIBeam); PLDrivers::GetDisplayDriver()->SetStandardCursor(EGpStandardCursors::kIBeam);
cursorIs = kBeamCursor; cursorIs = kBeamCursor;
} }
} }
@@ -441,7 +441,7 @@ void DoRoomInfo(void)
// SetPort((GrafPtr)tileSrcMap); // SetPort((GrafPtr)tileSrcMap);
if ((tempBack > kStars) && (!PictIDExists(tempBack))) if ((tempBack > kStars) && (!PictIDExists(tempBack)))
{ {
BitchAboutPICTNotFound(); ComplainAboutPICTNotFound();
tempBack = kSimpleRoom; tempBack = kSimpleRoom;
} }
if ((tempBack == 2002) || (tempBack == 2011) || if ((tempBack == 2002) || (tempBack == 2011) ||
@@ -869,10 +869,10 @@ short GetFirstPICT (void)
return resID; return resID;
} }
//-------------------------------------------------------------- BitchAboutPICTNotFound //-------------------------------------------------------------- ComplainAboutPICTNotFound
#ifndef COMPILEDEMO #ifndef COMPILEDEMO
void BitchAboutPICTNotFound (void) void ComplainAboutPICTNotFound (void)
{ {
short hitWhat; short hitWhat;

View File

@@ -9,16 +9,19 @@
#include "PLStringCompare.h" #include "PLStringCompare.h"
#include "DialogManager.h" #include "DialogManager.h"
#include "Externs.h" #include "Externs.h"
#include "FileBrowserUI.h"
#include "FileManager.h" #include "FileManager.h"
#include "FontFamily.h"
#include "House.h" #include "House.h"
#include "GpIOStream.h" #include "GpIOStream.h"
#include "InputManager.h" #include "InputManager.h"
#include "MacFileInfo.h" #include "MacFileInfo.h"
#include "MemoryManager.h" #include "MemoryManager.h"
#include "PLStandardColors.h"
#include "ResolveCachingColor.h"
#include <assert.h> #include <assert.h>
#define kSavedGameVersion 0x0200 #define kSavedGameVersion 0x0200
@@ -33,9 +36,93 @@ extern Boolean twoPlayerGame;
//============================================================== Functions //============================================================== 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 //-------------------------------------------------------------- SaveGame2
void SaveGame2 (void) Boolean SaveGame2 (void)
{ {
// Bringing up the save file UI can cause key/mouse events to be missed, resulting in state being stuck when this comes back. // Bringing up the save file UI can cause key/mouse events to be missed, resulting in state being stuck when this comes back.
// To avoid that, clear all state here. // To avoid that, clear all state here.
@@ -65,7 +152,7 @@ void SaveGame2 (void)
if (savedGame == nil) if (savedGame == nil)
{ {
YellowAlert(kYellowFailedSaveGame, PLErrors::kOutOfMemory); YellowAlert(kYellowFailedSaveGame, PLErrors::kOutOfMemory);
return; return false;
} }
memset(savedGame, 0, byteCount); memset(savedGame, 0, byteCount);
@@ -82,25 +169,16 @@ void SaveGame2 (void)
char savePath[sizeof(spec.m_name) + 1]; char savePath[sizeof(spec.m_name) + 1];
size_t savePathLength = 0; 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); mm->Release(savedGame);
return; return false;
} }
assert(savePathLength < sizeof(spec.m_name) - 1); assert(savePathLength < sizeof(spec.m_name) - 1);
spec.m_name[0] = static_cast<uint8_t>(savePathLength); spec.m_name[0] = static_cast<uint8_t>(savePathLength);
memcpy(spec.m_name + 1, savePath, 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; thisHousePtr = *thisHouse;
@@ -135,23 +213,20 @@ void SaveGame2 (void)
destRoom->objects[i] = srcRoom->objects[i]; 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"))) if (CheckFileError(theErr, PSTR("Saved Game")))
{ {
theErr = fm->OpenFileData(spec.m_dir, spec.m_name, PortabilityLayer::EFilePermission_Write, gameStream); if (gameStream->Write(savedGame, byteCount) != byteCount)
if (CheckFileError(theErr, PSTR("Saved Game")))
{ {
if (gameStream->Write(savedGame, byteCount) != byteCount) CheckFileError(PLErrors::kIOError, PSTR("Saved Game"));
{
CheckFileError(PLErrors::kIOError, PSTR("Saved Game"));
}
gameStream->Close();
} }
gameStream->Close();
} }
mm->Release(savedGame); mm->Release(savedGame);
return true;
} }
//-------------------------------------------------------------- SavedGameMismatchError //-------------------------------------------------------------- SavedGameMismatchError
@@ -191,7 +266,7 @@ Boolean OpenSavedGame (void)
char savePath[sizeof(spec.m_name) + 1]; char savePath[sizeof(spec.m_name) + 1];
size_t savePathLength = 0; 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; return false;
assert(savePathLength < sizeof(spec.m_name) - 1); assert(savePathLength < sizeof(spec.m_name) - 1);
@@ -199,15 +274,8 @@ Boolean OpenSavedGame (void)
spec.m_name[0] = static_cast<uint8_t>(savePathLength); spec.m_name[0] = static_cast<uint8_t>(savePathLength);
memcpy(spec.m_name + 1, savePath, 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; 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"))) if (!CheckFileError(theErr, PSTR("Saved Game")))
return(false); return(false);

View File

@@ -101,18 +101,26 @@ void UpdateLoadDialog (Dialog *theDialog)
if (SectRect(&dialogRect, &tempRect, &dummyRect)) if (SectRect(&dialogRect, &tempRect, &dummyRect))
{ {
PortabilityLayer::IResourceArchive *resFile = PortabilityLayer::ResourceManager::GetInstance()->LoadResFile(theHousesSpecs[i].m_dir, theHousesSpecs[i].m_name); PortabilityLayer::CompositeFile *cfile = PortabilityLayer::FileManager::GetInstance()->OpenCompositeFile(theHousesSpecs[i].m_dir, theHousesSpecs[i].m_name);
if (resFile != nullptr)
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, if (LargeIconPlot(surface, resFile, -16455, tempRect))
kDefaultHousePict8); haveHouseIcon = true;
resFile->Destroy();
} }
resFile->Destroy(); cfile->Close();
} }
else
if (!haveHouseIcon)
LoadDialogPICT(theDialog, kLoadIconFirstItem + i - housePage, LoadDialogPICT(theDialog, kLoadIconFirstItem + i - housePage,
kDefaultHousePict8); kDefaultHousePict8);
} }
@@ -411,11 +419,8 @@ void DoLoadHouse (void)
whoCares = CloseHouse(); whoCares = CloseHouse();
PasStringCopy(theHousesSpecs[thisHouseIndex].m_name, PasStringCopy(theHousesSpecs[thisHouseIndex].m_name,
thisHouseName); thisHouseName);
if (OpenHouse()) if (OpenHouse(true))
{
whoCares = ReadHouse();
houseNameDirty = true; houseNameDirty = true;
}
} }
leaving = true; leaving = true;
} }
@@ -452,11 +457,8 @@ void DoLoadHouse (void)
whoCares = CloseHouse(); whoCares = CloseHouse();
PasStringCopy(theHousesSpecs[thisHouseIndex].m_name, PasStringCopy(theHousesSpecs[thisHouseIndex].m_name,
thisHouseName); thisHouseName);
if (OpenHouse()) if (OpenHouse(true))
{
whoCares = ReadHouse();
houseNameDirty = true; houseNameDirty = true;
}
} }
leaving = true; leaving = true;
} }
@@ -489,11 +491,8 @@ void DoLoadHouse (void)
whoCares = CloseHouse(); whoCares = CloseHouse();
PasStringCopy(theHousesSpecs[thisHouseIndex].m_name, PasStringCopy(theHousesSpecs[thisHouseIndex].m_name,
thisHouseName); thisHouseName);
if (OpenHouse()) if (OpenHouse(true))
{
whoCares = ReadHouse();
houseNameDirty = true; houseNameDirty = true;
}
} }
leaving = true; leaving = true;
} }
@@ -596,7 +595,7 @@ void DoDirSearch (void)
{ {
theHousesSpecs[housesFound] = MakeVFileSpec(theDirs[currentDir], f->name); theHousesSpecs[housesFound] = MakeVFileSpec(theDirs[currentDir], f->name);
if (fm->FileExists(theDirs[currentDir], f->name)) if (fm->CompositeFileExists(theDirs[currentDir], f->name))
housesFound++; housesFound++;
} }
} }

View File

@@ -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 "ResolveCachingColor.h"
#include "DialogManager.h" #include "DialogManager.h"
#include "DialogUtils.h" #include "DialogUtils.h"
#include "Externs.h" #include "Externs.h"
#include "Environ.h" #include "Environ.h"
#include "HostDisplayDriver.h"
#include "House.h" #include "House.h"
#include "IGpDisplayDriver.h" #include "IGpDisplayDriver.h"
#include "WindowManager.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 kMainPrefsDialID 1012
#define kDisplayPrefsDialID 1017 #define kDisplayPrefsDialID 1017
@@ -72,7 +72,7 @@
#define kDoBackgroundCheck 11 #define kDoBackgroundCheck 11
#define kDoErrorCheck 12 #define kDoErrorCheck 12
#define kDoPrettyMapCheck 13 #define kDoPrettyMapCheck 13
#define kDoBitchDlgsCheck 14 #define kDoComplainDlgsCheck 14
void SetBrainsToDefaults (Dialog *); void SetBrainsToDefaults (Dialog *);
@@ -98,7 +98,7 @@ void SetAllDefaults (void);
void FlashSettingsButton (DrawSurface *, short); void FlashSettingsButton (DrawSurface *, short);
void UpdateSettingsMain (Dialog *); void UpdateSettingsMain (Dialog *);
int16_t PrefsFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt); int16_t PrefsFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt);
void BitchAboutChanges (void); void ComplainAboutChanges (void);
void WriteOutPrefs (void); void WriteOutPrefs (void);
@@ -109,11 +109,11 @@ long tempLeftMap, tempRightMap, tempBattMap, tempBandMap;
short whichCtrl, wasDepthPref; short whichCtrl, wasDepthPref;
Boolean wasFade, wasIdle, wasPlay, wasTransit, wasZooms, wasBackground; Boolean wasFade, wasIdle, wasPlay, wasTransit, wasZooms, wasBackground;
Boolean wasEscPauseKey, wasDemos, wasAutoScale, wasUseICCProfile, nextRestartChange, wasErrorCheck, wasFullscreenPref, needResolutionReset; Boolean wasEscPauseKey, wasDemos, wasAutoScale, wasUseICCProfile, nextRestartChange, wasErrorCheck, wasFullscreenPref, needResolutionReset;
Boolean wasPrettyMap, wasBitchDialogs; Boolean wasPrettyMap, wasComplainDialogs;
extern short numNeighbors, isDepthPref, maxFiles, willMaxFiles; extern short numNeighbors, isDepthPref, maxFiles, willMaxFiles;
extern Boolean isDoColorFade, isPlayMusicIdle, isAutoScale, isUseICCProfile; extern Boolean isDoColorFade, isPlayMusicIdle, isAutoScale, isUseICCProfile;
extern Boolean isHouseChecks, doBitchDialogs; extern Boolean isHouseChecks, doComplainDialogs;
extern Boolean isEscPauseKey, failedMusic, isSoundOn, doBackground; extern Boolean isEscPauseKey, failedMusic, isSoundOn, doBackground;
extern Boolean isMusicOn, quickerTransitions, doAutoDemo; extern Boolean isMusicOn, quickerTransitions, doAutoDemo;
extern Boolean changeLockStateOfHouse, saveHouseLocked, doPrettyMap; extern Boolean changeLockStateOfHouse, saveHouseLocked, doPrettyMap;
@@ -135,14 +135,14 @@ void SetBrainsToDefaults (Dialog *theDialog)
wasBackground = false; wasBackground = false;
wasErrorCheck = true; wasErrorCheck = true;
wasPrettyMap = true; wasPrettyMap = true;
wasBitchDialogs = true; wasComplainDialogs = true;
SetDialogItemValue(theDialog, kQuickTransitCheck, (short)wasTransit); SetDialogItemValue(theDialog, kQuickTransitCheck, (short)wasTransit);
SetDialogItemValue(theDialog, kDoZoomsCheck, (short)wasZooms); SetDialogItemValue(theDialog, kDoZoomsCheck, (short)wasZooms);
SetDialogItemValue(theDialog, kDoDemoCheck, (short)wasDemos); SetDialogItemValue(theDialog, kDoDemoCheck, (short)wasDemos);
SetDialogItemValue(theDialog, kDoBackgroundCheck, (short)wasBackground); SetDialogItemValue(theDialog, kDoBackgroundCheck, (short)wasBackground);
SetDialogItemValue(theDialog, kDoErrorCheck, (short)wasErrorCheck); SetDialogItemValue(theDialog, kDoErrorCheck, (short)wasErrorCheck);
SetDialogItemValue(theDialog, kDoPrettyMapCheck, (short)wasPrettyMap); SetDialogItemValue(theDialog, kDoPrettyMapCheck, (short)wasPrettyMap);
SetDialogItemValue(theDialog, kDoBitchDlgsCheck, (short)wasBitchDialogs); SetDialogItemValue(theDialog, kDoComplainDlgsCheck, (short)wasComplainDialogs);
} }
//-------------------------------------------------------------- UpdateSettingsBrains //-------------------------------------------------------------- UpdateSettingsBrains
@@ -238,7 +238,7 @@ void DoBrainsPrefs (void)
wasBackground = doBackground; wasBackground = doBackground;
wasErrorCheck = isHouseChecks; wasErrorCheck = isHouseChecks;
wasPrettyMap = doPrettyMap; wasPrettyMap = doPrettyMap;
wasBitchDialogs = doBitchDialogs; wasComplainDialogs = doComplainDialogs;
SetDialogItemValue(prefDlg, kQuickTransitCheck, (short)wasTransit); SetDialogItemValue(prefDlg, kQuickTransitCheck, (short)wasTransit);
SetDialogItemValue(prefDlg, kDoZoomsCheck, (short)wasZooms); SetDialogItemValue(prefDlg, kDoZoomsCheck, (short)wasZooms);
@@ -246,7 +246,7 @@ void DoBrainsPrefs (void)
SetDialogItemValue(prefDlg, kDoBackgroundCheck, (short)wasBackground); SetDialogItemValue(prefDlg, kDoBackgroundCheck, (short)wasBackground);
SetDialogItemValue(prefDlg, kDoErrorCheck, (short)wasErrorCheck); SetDialogItemValue(prefDlg, kDoErrorCheck, (short)wasErrorCheck);
SetDialogItemValue(prefDlg, kDoPrettyMapCheck, (short)wasPrettyMap); SetDialogItemValue(prefDlg, kDoPrettyMapCheck, (short)wasPrettyMap);
SetDialogItemValue(prefDlg, kDoBitchDlgsCheck, (short)wasBitchDialogs); SetDialogItemValue(prefDlg, kDoComplainDlgsCheck, (short)wasComplainDialogs);
UpdateSettingsBrains(prefDlg); UpdateSettingsBrains(prefDlg);
@@ -272,7 +272,7 @@ void DoBrainsPrefs (void)
doBackground = wasBackground; doBackground = wasBackground;
isHouseChecks = wasErrorCheck; isHouseChecks = wasErrorCheck;
doPrettyMap = wasPrettyMap; doPrettyMap = wasPrettyMap;
doBitchDialogs = wasBitchDialogs; doComplainDialogs = wasComplainDialogs;
leaving = true; leaving = true;
break; break;
@@ -315,9 +315,9 @@ void DoBrainsPrefs (void)
SetDialogItemValue(prefDlg, kDoPrettyMapCheck, (short)wasPrettyMap); SetDialogItemValue(prefDlg, kDoPrettyMapCheck, (short)wasPrettyMap);
break; break;
case kDoBitchDlgsCheck: case kDoComplainDlgsCheck:
wasBitchDialogs = !wasBitchDialogs; wasComplainDialogs = !wasComplainDialogs;
SetDialogItemValue(prefDlg, kDoBitchDlgsCheck, (short)wasBitchDialogs); SetDialogItemValue(prefDlg, kDoComplainDlgsCheck, (short)wasComplainDialogs);
break; break;
} }
} }
@@ -637,7 +637,7 @@ void HandleSoundMusicChange (short newVolume, Boolean sayIt)
isSoundOn = (newVolume != 0); isSoundOn = (newVolume != 0);
if (wasIdle) if (wasIdle && theMode != kEditMode)
{ {
if (newVolume == 0) if (newVolume == 0)
StopTheMusic(); StopTheMusic();
@@ -773,7 +773,7 @@ void DoSoundPrefs (void)
case kCancelButton: case kCancelButton:
UnivSetSoundVolume(wasLoudness, thisMac.hasSM3); UnivSetSoundVolume(wasLoudness, thisMac.hasSM3);
HandleSoundMusicChange(wasLoudness, false); HandleSoundMusicChange(wasLoudness, false);
if (isPlayMusicIdle != wasIdle) if (isPlayMusicIdle != wasIdle && theMode != kEditMode)
{ {
if (isPlayMusicIdle) if (isPlayMusicIdle)
{ {
@@ -831,7 +831,7 @@ void DoSoundPrefs (void)
case kIdleMusicItem: case kIdleMusicItem:
wasIdle = !wasIdle; wasIdle = !wasIdle;
SetDialogItemValue(prefDlg, kIdleMusicItem, (short)wasIdle); SetDialogItemValue(prefDlg, kIdleMusicItem, (short)wasIdle);
if (wasIdle) if (wasIdle && theMode != kEditMode)
{ {
UnivGetSoundVolume(&tempVolume, thisMac.hasSM3); UnivGetSoundVolume(&tempVolume, thisMac.hasSM3);
if (tempVolume != 0) if (tempVolume != 0)
@@ -1121,7 +1121,7 @@ void SetAllDefaults (void)
doBackground = false; doBackground = false;
isHouseChecks = true; isHouseChecks = true;
doPrettyMap = true; doPrettyMap = true;
doBitchDialogs = true; doComplainDialogs = true;
// Default control settings // Default control settings
PasStringCopy(PSTR("lf arrow"), leftName); PasStringCopy(PSTR("lf arrow"), leftName);
PasStringCopy(PSTR("rt arrow"), rightName); PasStringCopy(PSTR("rt arrow"), rightName);
@@ -1285,7 +1285,7 @@ void DoSettingsMain (void)
leaving = false; leaving = false;
nextRestartChange = false; nextRestartChange = false;
wasFullscreenPref = PortabilityLayer::HostDisplayDriver::GetInstance()->IsFullScreen(); wasFullscreenPref = PLDrivers::GetDisplayDriver()->IsFullScreen();
Window* exclWindow = prefDlg->GetWindow(); Window* exclWindow = prefDlg->GetWindow();
@@ -1340,11 +1340,11 @@ void DoSettingsMain (void)
if (nextRestartChange) if (nextRestartChange)
{ {
BitchAboutChanges(); ComplainAboutChanges();
nextRestartChange = false; nextRestartChange = false;
} }
IGpDisplayDriver *displayDriver = PortabilityLayer::HostDisplayDriver::GetInstance(); IGpDisplayDriver *displayDriver = PLDrivers::GetDisplayDriver();
if (displayDriver->IsFullScreen() != (wasFullscreenPref != 0)) if (displayDriver->IsFullScreen() != (wasFullscreenPref != 0))
{ {
@@ -1354,18 +1354,18 @@ void DoSettingsMain (void)
if (needResolutionReset) if (needResolutionReset)
{ {
PortabilityLayer::HostDisplayDriver::GetInstance()->RequestResetVirtualResolution(); displayDriver->RequestResetVirtualResolution();
needResolutionReset = false; needResolutionReset = false;
} }
PortabilityLayer::HostDisplayDriver::GetInstance()->SetUseICCProfile(isUseICCProfile); displayDriver->SetUseICCProfile(isUseICCProfile);
WriteOutPrefs(); WriteOutPrefs();
} }
//-------------------------------------------------------------- BitchAboutChanges //-------------------------------------------------------------- ComplainAboutChanges
void BitchAboutChanges (void) void ComplainAboutChanges (void)
{ {
#define kChangesEffectAlert 1040 #define kChangesEffectAlert 1040
short hitWhat; short hitWhat;

View File

@@ -378,17 +378,6 @@ void TellHerNoSounds (void)
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMemForSoundsAlert, nullptr); 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 //-------------------------------------------------------------- ParseAndConvertSound

View File

@@ -1,24 +1,27 @@
#include "CombinedTimestamp.h" #include "CombinedTimestamp.h"
#include "DeflateCodec.h" #include "DeflateCodec.h"
#include "Environ.h" #include "Environ.h"
#include "FontFamily.h"
#include "GpBuildVersion.h" #include "GpBuildVersion.h"
#include "GpIOStream.h" #include "GpIOStream.h"
#include "HostDirectoryCursor.h" #include "GpFileCreationDisposition.h"
#include "HostDisplayDriver.h" #include "IGpDirectoryCursor.h"
#include "HostFileSystem.h"
#include "IGpDisplayDriver.h" #include "IGpDisplayDriver.h"
#include "IGpFileSystem.h"
#include "MemoryManager.h" #include "MemoryManager.h"
#include "PLCore.h"
#include "PLStandardColors.h"
#include "PLSysCalls.h"
#include "RenderedFont.h" #include "RenderedFont.h"
#include "GpApplicationName.h" #include "GpApplicationName.h"
#include "GpRenderedFontMetrics.h" #include "GpRenderedFontMetrics.h"
#include "ResolveCachingColor.h" #include "ResolveCachingColor.h"
#include "ZipFile.h" #include "Vec2i.h"
#include "WindowDef.h" #include "WindowDef.h"
#include "WindowManager.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 <vector>
#include <string> #include <string>
@@ -93,41 +96,6 @@ SortableEntry SortableEntry::Create(const char *zipLocation, PortabilityLayer::V
return entry; 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 void InitSourceExportWindow(SourceExportState *state)
{ {
static const int kLoadScreenHeight = 32; 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 // 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. // the status bar dismissal causes a major change in the virtual resolution.
unsigned int displayWidth = 0; PortabilityLayer::Vec2i displaySize = PortabilityLayer::WindowManager::GetInstance()->GetDisplayResolution();
unsigned int displayHeight = 0; unsigned int displayWidth = displaySize.m_x;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&displayWidth, &displayHeight); unsigned int displayHeight = displaySize.m_y;
int32_t lsX = (static_cast<int32_t>(displayWidth) - kLoadScreenWidth) / 2; int32_t lsX = (static_cast<int32_t>(displayWidth) - kLoadScreenWidth) / 2;
int32_t lsY = (static_cast<int32_t>(displayHeight) - kLoadScreenHeight) / 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) 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) if (!stream)
return false; return false;
@@ -199,7 +167,7 @@ static bool RetrieveCompositeDirSize(PortabilityLayer::VirtualDirectory_t virtua
size_t totalSize = 0; size_t totalSize = 0;
totalSizeOut = 0; totalSizeOut = 0;
PortabilityLayer::HostDirectoryCursor *dirCursor = PortabilityLayer::HostFileSystem::GetInstance()->ScanDirectory(virtualDir); IGpDirectoryCursor *dirCursor = PLDrivers::GetFileSystem()->ScanDirectory(virtualDir);
if (!dirCursor) if (!dirCursor)
return false; return false;
@@ -400,9 +368,9 @@ static bool RepackDirectory(SourceExportState &state, GpIOStream *outStream, std
uint16_t dosDate = 0; uint16_t dosDate = 0;
uint16_t dosTime = 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) if (!dirCursor)
return false; return false;
@@ -425,7 +393,7 @@ static bool RepackDirectory(SourceExportState &state, GpIOStream *outStream, std
const bool shouldStore = (extension[3] == 'a'); 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) if (!state.m_fStream)
return false; return false;
@@ -607,7 +575,7 @@ static bool AddZipDirectory(GpIOStream *stream, std::vector<PortabilityLayer::Zi
uint16_t dosDate = 0; uint16_t dosDate = 0;
uint16_t dosTime = 0; uint16_t dosTime = 0;
ConvertToMSDOSTimestamp(ts, dosDate, dosTime); ts.GetAsMSDOSTimestamp(dosDate, dosTime);
GpUFilePos_t localHeaderPos = stream->Tell(); GpUFilePos_t localHeaderPos = stream->Tell();
@@ -664,7 +632,7 @@ bool ExportSourceToStream (GpIOStream *stream)
SourceExportState state; SourceExportState state;
InitSourceExportWindow(&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) if (!state.m_tsStream)
return false; return false;
@@ -673,7 +641,7 @@ bool ExportSourceToStream (GpIOStream *stream)
state.m_tsStream->Close(); state.m_tsStream->Close();
state.m_tsStream = nullptr; 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) if (!state.m_sourcePkgStream)
return false; return false;
@@ -730,7 +698,7 @@ bool ExportSourceToStream (GpIOStream *stream)
void DoExportSourceCode (void) 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) if (!stream)
return; return;

View File

@@ -70,9 +70,9 @@ short WhichStringFirst (StringPtr p1, StringPtr p2)
{ {
if (!foundIt) if (!foundIt)
{ {
if (p1[0] < p2[0]) // shortest string wins if (p1[0] > p2[0]) // shortest string wins
greater = 1; greater = 1;
else if (p1[0] > p2[0]) else if (p1[0] < p2[0])
greater = 2; greater = 2;
} }
foundIt = true; foundIt = true;

View File

@@ -11,13 +11,13 @@
#include "PLPasStr.h" #include "PLPasStr.h"
#include "PLResources.h" #include "PLResources.h"
#include "PLSound.h" #include "PLSound.h"
#include "PLSysCalls.h"
#include "PLTimeTaggedVOSEvent.h" #include "PLTimeTaggedVOSEvent.h"
#include "QDPixMap.h" #include "QDPixMap.h"
#include "BitmapImage.h" #include "BitmapImage.h"
#include "DialogManager.h" #include "DialogManager.h"
#include "DisplayDeviceManager.h" #include "DisplayDeviceManager.h"
#include "Externs.h" #include "Externs.h"
#include "HostSystemServices.h"
#include "IconLoader.h" #include "IconLoader.h"
#include "InputManager.h" #include "InputManager.h"
#include "ResourceManager.h" #include "ResourceManager.h"
@@ -115,9 +115,7 @@ void RedAlert (short errorNumber)
// CenterAlert(rDeathAlertID); // CenterAlert(rDeathAlertID);
dummyInt = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(rDeathAlertID, &substitutions); dummyInt = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(rDeathAlertID, &substitutions);
//ExitToShell(); PLSysCalls::Exit(-1);
PL_NotYetImplemented_TODO("Exit");
} }
//-------------------------------------------------------------- CreateOffScreenBitMap //-------------------------------------------------------------- CreateOffScreenBitMap

View File

@@ -3,6 +3,7 @@
enum EGpInputDriverType enum EGpInputDriverType
{ {
EGpInputDriverType_XInput, EGpInputDriverType_XInput,
EGpInputDriverType_SDL2_Gamepad,
EGpInputDriverType_Count, EGpInputDriverType_Count,
}; };

View File

@@ -2,11 +2,7 @@
#include "EGpAudioDriverType.h" #include "EGpAudioDriverType.h"
namespace PortabilityLayer struct IGpSystemServices;
{
class HostSystemServices;
}
struct IGpAudioDriver; struct IGpAudioDriver;
struct IGpLogDriver; struct IGpLogDriver;
@@ -18,5 +14,5 @@ struct GpAudioDriverProperties
bool m_debug; bool m_debug;
IGpLogDriver *m_logger; IGpLogDriver *m_logger;
PortabilityLayer::HostSystemServices *m_systemServices; IGpSystemServices *m_systemServices;
}; };

View File

@@ -2,8 +2,8 @@
#define GP_BUILD_VERSION_MAJOR 1 #define GP_BUILD_VERSION_MAJOR 1
#define GP_BUILD_VERSION_MINOR 0 #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_VERSION_STRING "1.0.15"
#define GP_APPLICATION_COPYRIGHT_STRING "2019-2020 Eric Lasota" #define GP_APPLICATION_COPYRIGHT_STRING "2019-2021 Eric Lasota"
#define GP_APPLICATION_WEBSITE_STRING "https://github.com/elasota/Aerofoil" #define GP_APPLICATION_WEBSITE_STRING "https://github.com/elasota/Aerofoil"

View File

@@ -0,0 +1,11 @@
#pragma once
namespace GpClipboardContentsTypes
{
enum GpClipboardContentsType
{
kText,
};
}
typedef GpClipboardContentsTypes::GpClipboardContentsType GpClipboardContentsType_t;

View File

@@ -9,11 +9,7 @@ struct IGpDisplayDriver;
struct IGpFiber; struct IGpFiber;
struct IGpVOSEventQueue; struct IGpVOSEventQueue;
struct IGpLogDriver; struct IGpLogDriver;
struct IGpSystemServices;
namespace PortabilityLayer
{
class HostSystemServices;
}
struct GpDisplayDriverProperties struct GpDisplayDriverProperties
{ {
@@ -46,5 +42,5 @@ struct GpDisplayDriverProperties
IGpVOSEventQueue *m_eventQueue; IGpVOSEventQueue *m_eventQueue;
IGpLogDriver *m_logger; IGpLogDriver *m_logger;
PortabilityLayer::HostSystemServices *m_systemServices; IGpSystemServices *m_systemServices;
}; };

132
GpCommon/GpDriverIndex.h Normal file
View 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;
}

View File

@@ -13,9 +13,23 @@ public:
virtual bool SeekStart(GpUFilePos_t loc) = 0; virtual bool SeekStart(GpUFilePos_t loc) = 0;
virtual bool SeekCurrent(GpFilePos_t loc) = 0; virtual bool SeekCurrent(GpFilePos_t loc) = 0;
virtual bool SeekEnd(GpUFilePos_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 Size() const = 0;
virtual GpUFilePos_t Tell() const = 0; virtual GpUFilePos_t Tell() const = 0;
virtual void Close() = 0; virtual void Close() = 0;
virtual void Flush() = 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;
}

View 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
};

View File

@@ -0,0 +1,8 @@
#pragma once
struct IGpDirectoryCursor
{
public:
virtual bool GetNext(const char *&outFileName) = 0;
virtual void Destroy() = 0;
};

View File

@@ -31,7 +31,8 @@ struct IGpDisplayDriver
virtual void Run() = 0; virtual void Run() = 0;
virtual void Shutdown() = 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 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; 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
View 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