diff --git a/Aerofoil/GpSystemServices_Win32.cpp b/Aerofoil/GpSystemServices_Win32.cpp index 7c56fa0..88d8e29 100644 --- a/Aerofoil/GpSystemServices_Win32.cpp +++ b/Aerofoil/GpSystemServices_Win32.cpp @@ -232,9 +232,10 @@ uint64_t GpSystemServices_Win32::GetFreeMemoryCosmetic() const return memStatus.ullAvailPhys; } -void GpSystemServices_Win32::Beep() const +bool GpSystemServices_Win32::Beep() const { MessageBeep(MB_OK); + return true; } bool GpSystemServices_Win32::IsTouchscreen() const @@ -264,7 +265,7 @@ bool GpSystemServices_Win32::IsFullscreenOnStartup() const bool GpSystemServices_Win32::HasNativeFileManager() const { - return false; + return true; } unsigned int GpSystemServices_Win32::GetCPUCount() const diff --git a/Aerofoil/GpSystemServices_Win32.h b/Aerofoil/GpSystemServices_Win32.h index 8830ed2..cb0f274 100644 --- a/Aerofoil/GpSystemServices_Win32.h +++ b/Aerofoil/GpSystemServices_Win32.h @@ -28,7 +28,7 @@ public: void *CreateThread(ThreadFunc_t threadFunc, void *context) override; IGpThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override; uint64_t GetFreeMemoryCosmetic() const override; - void Beep() const override; + bool Beep() const override; bool IsTouchscreen() const override; bool IsUsingMouseAsTouch() const override; bool IsTextInputObstructive() const override; diff --git a/AerofoilAndroid/app/jni/main/GpSystemServices_Android.cpp b/AerofoilAndroid/app/jni/main/GpSystemServices_Android.cpp index 1cefa7e..468abba 100644 --- a/AerofoilAndroid/app/jni/main/GpSystemServices_Android.cpp +++ b/AerofoilAndroid/app/jni/main/GpSystemServices_Android.cpp @@ -55,8 +55,9 @@ void *GpSystemServices_Android::CreateThread(ThreadFunc_t threadFunc, void *cont return thread; } -void GpSystemServices_Android::Beep() const +bool GpSystemServices_Android::Beep() const { + return false; } bool GpSystemServices_Android::IsTouchscreen() const @@ -84,6 +85,11 @@ bool GpSystemServices_Android::IsFullscreenOnStartup() const return true; } +bool GpSystemServices_Android::HasNativeFileManager() const +{ + return false; +} + unsigned int GpSystemServices_Android::GetCPUCount() const { return SDL_GetCPUCount(); diff --git a/AerofoilAndroid/app/jni/main/GpSystemServices_Android.h b/AerofoilAndroid/app/jni/main/GpSystemServices_Android.h index 81c9985..881cbbf 100644 --- a/AerofoilAndroid/app/jni/main/GpSystemServices_Android.h +++ b/AerofoilAndroid/app/jni/main/GpSystemServices_Android.h @@ -9,12 +9,13 @@ public: GpSystemServices_Android(); void *CreateThread(ThreadFunc_t threadFunc, void *context) override; - void Beep() const override; + bool Beep() const override; bool IsTouchscreen() const override; bool IsUsingMouseAsTouch() const override; bool IsTextInputObstructive() const override; bool IsFullscreenPreferred() const override; bool IsFullscreenOnStartup() const override; + bool HasNativeFileManager() const override; unsigned int GetCPUCount() const override; void SetTextInputEnabled(bool isEnabled) override; bool IsTextInputEnabled() const override; diff --git a/AerofoilWeb/GpSystemServices_Web.cpp b/AerofoilWeb/GpSystemServices_Web.cpp index 25f3147..545fe63 100644 --- a/AerofoilWeb/GpSystemServices_Web.cpp +++ b/AerofoilWeb/GpSystemServices_Web.cpp @@ -136,8 +136,9 @@ void *GpSystemServices_Web::CreateThread(ThreadFunc_t threadFunc, void *context) return nullptr; } -void GpSystemServices_Web::Beep() const +bool GpSystemServices_Web::Beep() const { + return false; } bool GpSystemServices_Web::IsTouchscreen() const @@ -165,6 +166,11 @@ bool GpSystemServices_Web::IsFullscreenOnStartup() const return false; } +bool GpSystemServices_Web::HasNativeFileManager() const +{ + return false; +} + unsigned int GpSystemServices_Web::GetCPUCount() const { return SDL_GetCPUCount(); diff --git a/AerofoilWeb/GpSystemServices_Web.h b/AerofoilWeb/GpSystemServices_Web.h index ebc7e5d..4aafd63 100644 --- a/AerofoilWeb/GpSystemServices_Web.h +++ b/AerofoilWeb/GpSystemServices_Web.h @@ -12,12 +12,13 @@ public: ~GpSystemServices_Web(); void *CreateThread(ThreadFunc_t threadFunc, void *context) override; - void Beep() const override; + bool Beep() const override; bool IsTouchscreen() const override; bool IsUsingMouseAsTouch() const override; bool IsTextInputObstructive() const override; bool IsFullscreenPreferred() const override; bool IsFullscreenOnStartup() const override; + bool HasNativeFileManager() const override; unsigned int GetCPUCount() const override; void SetTextInputEnabled(bool isEnabled) override; bool IsTextInputEnabled() const override; diff --git a/AerofoilX/GpSystemServices_X.cpp b/AerofoilX/GpSystemServices_X.cpp index ed1401a..80f5247 100644 --- a/AerofoilX/GpSystemServices_X.cpp +++ b/AerofoilX/GpSystemServices_X.cpp @@ -64,8 +64,9 @@ void *GpSystemServices_X::CreateThread(ThreadFunc_t threadFunc, void *context) return thread; } -void GpSystemServices_X::Beep() const +bool GpSystemServices_X::Beep() const { + return false; } bool GpSystemServices_X::IsTouchscreen() const @@ -93,6 +94,11 @@ bool GpSystemServices_X::IsFullscreenOnStartup() const return false; } +bool GpSystemServices_X::HasNativeFileManager() const +{ + return true; +} + unsigned int GpSystemServices_X::GetCPUCount() const { return SDL_GetCPUCount(); diff --git a/AerofoilX/GpSystemServices_X.h b/AerofoilX/GpSystemServices_X.h index f9e9998..704eeab 100644 --- a/AerofoilX/GpSystemServices_X.h +++ b/AerofoilX/GpSystemServices_X.h @@ -12,12 +12,13 @@ public: ~GpSystemServices_X(); void *CreateThread(ThreadFunc_t threadFunc, void *context) override; - void Beep() const override; + bool Beep() const override; bool IsTouchscreen() const override; bool IsUsingMouseAsTouch() const override; bool IsTextInputObstructive() const override; bool IsFullscreenPreferred() const override; bool IsFullscreenOnStartup() const override; + bool HasNativeFileManager() const override; unsigned int GetCPUCount() const override; void SetTextInputEnabled(bool isEnabled) override; bool IsTextInputEnabled() const override; diff --git a/ApplicationResourcePatches/DITL/2005.json b/ApplicationResourcePatches/DITL/2005.json index 381f6df..351b1d4 100644 --- a/ApplicationResourcePatches/DITL/2005.json +++ b/ApplicationResourcePatches/DITL/2005.json @@ -4,7 +4,7 @@ { "name" : "Okay", "itemType" : "Button", - "pos" : [ 438, 292 ], + "pos" : [ 438, 316 ], "size" : [ 58, 20 ], "id" : 1, "enabled" : true @@ -12,7 +12,7 @@ { "name" : "Export Source Code to ZIP Archive...", "itemType" : "Button", - "pos" : [ 205, 292 ], + "pos" : [ 205, 316 ], "size" : [ 226, 20 ], "id" : 1, "enabled" : false @@ -176,6 +176,14 @@ "size" : [ 66, 20 ], "id" : 1, "enabled" : true + }, + { + "name" : "Ping sound original: Darrelle Jed Montojo (\"LittleRainySeasons\")", + "itemType" : "Label", + "pos" : [ 16, 277 ], + "size" : [ 406, 20 ], + "id" : 1, + "enabled" : true } ] } \ No newline at end of file diff --git a/ApplicationResourcePatches/SND/1063.wav b/ApplicationResourcePatches/SND/1063.wav new file mode 100644 index 0000000..757322b Binary files /dev/null and b/ApplicationResourcePatches/SND/1063.wav differ diff --git a/ApplicationResourcePatches/manifest.json b/ApplicationResourcePatches/manifest.json index b05a6ab..2f74d3f 100644 --- a/ApplicationResourcePatches/manifest.json +++ b/ApplicationResourcePatches/manifest.json @@ -39,7 +39,8 @@ "LICS/1004.txt" : "ApplicationResourcePatches/LICS/1004.txt", "LICS/1005.txt" : "ApplicationResourcePatches/LICS/1005.txt", "LICS/1006.txt" : "ApplicationResourcePatches/LICS/1006.txt", - "STR$23/1006.txt" : "ApplicationResourcePatches/STR/1006.txt" + "STR$23/1006.txt" : "ApplicationResourcePatches/STR/1006.txt", + "snd$20/1063.wav" : "ApplicationResourcePatches/SND/1063.wav" }, "delete" : [ diff --git a/CMakeLists.txt b/CMakeLists.txt index a3480d5..093e836 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,6 @@ add_library(PortabilityLayer STATIC PortabilityLayer/MemoryManager.cpp PortabilityLayer/MemReaderStream.cpp PortabilityLayer/MenuManager.cpp - PortabilityLayer/MMBlock.cpp PortabilityLayer/MMHandleBlock.cpp PortabilityLayer/PLApplication.cpp PortabilityLayer/PLButtonWidget.cpp diff --git a/GpApp/About.cpp b/GpApp/About.cpp index 42e8194..336b9b5 100644 --- a/GpApp/About.cpp +++ b/GpApp/About.cpp @@ -249,7 +249,7 @@ void DoAboutOpenSource(void) static const int kAboutOpenSourceDialogTemplateID = 2005; - const Rect windowRect = Rect::Create(0, 0, 324, 512); + const Rect windowRect = Rect::Create(0, 0, 348, 512); PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(windowRect, PortabilityLayer::WindowStyleFlags::kAlert, true, 0, 0, PSTR("")); diff --git a/GpApp/GliderDefines.h b/GpApp/GliderDefines.h index 55944ff..7b9db0d 100644 --- a/GpApp/GliderDefines.h +++ b/GpApp/GliderDefines.h @@ -115,7 +115,8 @@ #define kTransInSound 60 // ее ее #define kBonusSound 61 // еееееее #define kHissSound 62 // -#define kTriggerSound 63 +#define kPingSound 63 // +#define kTriggerSound 64 // This must be the last one #define kHitWallPriority 100 // ееееее #define kScoreTikPriority 101 // ее @@ -177,6 +178,7 @@ #define kFollowPriority 904 #define kTransInPriority 905 #define kTransOutPriority 906 +#define kPingPriority 907 #define kTriggerPriority 999 #define kArrowCursor 0 diff --git a/GpApp/Sound.cpp b/GpApp/Sound.cpp index 5ac7e74..5a56b4e 100644 --- a/GpApp/Sound.cpp +++ b/GpApp/Sound.cpp @@ -23,7 +23,7 @@ #define kBaseBufferSoundID 1000 -#define kMaxSounds 64 +#define kMaxSounds 65 void CallBack0 (PortabilityLayer::AudioChannel *); @@ -38,7 +38,7 @@ IGpAudioBuffer *ParseAndConvertSound(const THandle &handle); PortabilityLayer::AudioChannel *channel0, *channel1, *channel2; IGpAudioBuffer *theSoundData[kMaxSounds]; short numSoundsLoaded; -Boolean soundLoaded[kMaxSounds], dontLoadSounds; +Boolean dontLoadSounds; Boolean channelOpen, isSoundOn, failedSound; //============================================================== Functions @@ -341,6 +341,14 @@ void CloseSoundChannels (void) channelOpen = false; } +//-------------------------------------------------------------- PingBeep + +void PingBeep (int duration) +{ + PlayPrioritySound(kPingSound, kPingPriority); +} + + //-------------------------------------------------------------- InitSound void InitSound (void) @@ -376,6 +384,8 @@ void InitSound (void) failedSound = true; } } + + SetBeepFunction (PingBeep); } //-------------------------------------------------------------- KillSound diff --git a/GpCommon/IGpSystemServices.h b/GpCommon/IGpSystemServices.h index e774e8d..76f64ac 100644 --- a/GpCommon/IGpSystemServices.h +++ b/GpCommon/IGpSystemServices.h @@ -26,7 +26,7 @@ public: virtual void *CreateThread(ThreadFunc_t threadFunc, void *context) = 0; virtual IGpThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) = 0; virtual uint64_t GetFreeMemoryCosmetic() const = 0; // Returns free memory in bytes, does not have to be accurate - virtual void Beep() const = 0; + virtual bool Beep() const = 0; virtual bool IsTouchscreen() const = 0; virtual bool IsUsingMouseAsTouch() const = 0; virtual bool IsFullscreenPreferred() const = 0; diff --git a/PortabilityLayer/DialogManager.cpp b/PortabilityLayer/DialogManager.cpp index 18f0803..ad70cf2 100644 --- a/PortabilityLayer/DialogManager.cpp +++ b/PortabilityLayer/DialogManager.cpp @@ -13,6 +13,7 @@ #include "WindowDef.h" #include "WindowManager.h" +#include "PLApplication.h" #include "PLArrayView.h" #include "PLBigEndian.h" #include "PLButtonWidget.h" @@ -471,7 +472,7 @@ namespace PortabilityLayer Rect2i windowFullRect = WindowManager::GetInstance()->GetWindowFullRect(window); if (!windowFullRect.Contains(Vec2i(mouseEvent.m_x, mouseEvent.m_y))) { - PLDrivers::GetSystemServices()->Beep(); + SysBeep(1); continue; } } @@ -834,7 +835,7 @@ namespace PortabilityLayer // If sound index is 0, play no sound if (soundIndexes[0] != 0) - PLDrivers::GetSystemServices()->Beep(); + SysBeep(1); const Rect dialogRect = alertResData.m_rect.ToRect(); diff --git a/PortabilityLayer/FileBrowserUI.cpp b/PortabilityLayer/FileBrowserUI.cpp index d6cddea..e2a0004 100644 --- a/PortabilityLayer/FileBrowserUI.cpp +++ b/PortabilityLayer/FileBrowserUI.cpp @@ -21,6 +21,7 @@ #include "WindowDef.h" #include "MacRomanConversion.h" +#include "PLApplication.h" #include "PLArrayView.h" #include "PLControlDefinitions.h" #include "PLCore.h" @@ -756,7 +757,7 @@ namespace PortabilityLayer PLPasStr nameStr = editBox->GetString(); if (nameStr.Length() == 0 || !fs->ValidateFilePath(nameStr.Chars(), nameStr.Length())) { - PLDrivers::GetSystemServices()->Beep(); + SysBeep(1); FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIBadNameDialogTemplateID, nullptr); hit = -1; } @@ -772,7 +773,7 @@ namespace PortabilityLayer { DialogTextSubstitutions substitutions(nameStr); - PLDrivers::GetSystemServices()->Beep(); + SysBeep(1); int16_t subHit = FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIOverwriteDialogTemplateID, &substitutions); if (subHit == kOverwriteNoButton) @@ -783,7 +784,7 @@ namespace PortabilityLayer if ((mode == Mode_Open && hit == kOpenDeleteButton) || (mode == Mode_SaveWithDelete && hit == kSaveDeleteButton)) { - PLDrivers::GetSystemServices()->Beep(); + SysBeep(1); int16_t subHit = FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIDeleteDialogTemplateID, &substitutions); if (subHit == kOverwriteYesButton) diff --git a/PortabilityLayer/PLApplication.cpp b/PortabilityLayer/PLApplication.cpp index e743618..b82216e 100644 --- a/PortabilityLayer/PLApplication.cpp +++ b/PortabilityLayer/PLApplication.cpp @@ -18,9 +18,18 @@ namespace PortabilityLayer memcpy(dest + 1, src, sz); } } + + static BeepFunction_t gs_beepFunction = nullptr; } void SysBeep(int duration) { - PLDrivers::GetSystemServices()->Beep(); + if (!PLDrivers::GetSystemServices()->Beep()) + if (PortabilityLayer::gs_beepFunction != nullptr) + PortabilityLayer::gs_beepFunction(duration); +} + +void SetBeepFunction(BeepFunction_t beepFunction) +{ + PortabilityLayer::gs_beepFunction = beepFunction; } diff --git a/PortabilityLayer/PLApplication.h b/PortabilityLayer/PLApplication.h index 8f6e3bf..6e1351c 100644 --- a/PortabilityLayer/PLApplication.h +++ b/PortabilityLayer/PLApplication.h @@ -23,7 +23,11 @@ void PasStringCopy(const unsigned char *src, unsigned char *dest); template void PasStringCopy(const PortabilityLayer::PascalStrLiteral &src, unsigned char *dest); -void SysBeep(int duration); +void SysBeep(int duration); + +typedef void (*BeepFunction_t)(int duration); +void SetBeepFunction(BeepFunction_t beepFunction); + /////////////////////////////////////////////////////////////////////////////// #include "PascalStrLiteral.h" diff --git a/PortabilityLayer/PLSound.cpp b/PortabilityLayer/PLSound.cpp index 9b9b0fa..809f02f 100644 --- a/PortabilityLayer/PLSound.cpp +++ b/PortabilityLayer/PLSound.cpp @@ -180,6 +180,9 @@ namespace PortabilityLayer bool AudioChannelImpl::AddBuffer(IGpAudioBuffer *buffer, bool blocking) { + if (!buffer) + return false; + buffer->AddRef(); AudioCommand cmd;