mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +00:00
Add beep sound to platforms with no beep
This commit is contained in:
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
BIN
ApplicationResourcePatches/SND/1063.wav
Normal file
BIN
ApplicationResourcePatches/SND/1063.wav
Normal file
Binary file not shown.
@@ -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" :
|
||||
[
|
||||
|
@@ -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
|
||||
|
@@ -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(""));
|
||||
|
||||
|
@@ -115,7 +115,8 @@
|
||||
#define kTransInSound 60 // <20><> <20><>
|
||||
#define kBonusSound 61 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define kHissSound 62 //
|
||||
#define kTriggerSound 63
|
||||
#define kPingSound 63 //
|
||||
#define kTriggerSound 64 // This must be the last one
|
||||
|
||||
#define kHitWallPriority 100 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define kScoreTikPriority 101 // <20><>
|
||||
@@ -177,6 +178,7 @@
|
||||
#define kFollowPriority 904
|
||||
#define kTransInPriority 905
|
||||
#define kTransOutPriority 906
|
||||
#define kPingPriority 907
|
||||
#define kTriggerPriority 999
|
||||
|
||||
#define kArrowCursor 0
|
||||
|
@@ -23,7 +23,7 @@
|
||||
|
||||
|
||||
#define kBaseBufferSoundID 1000
|
||||
#define kMaxSounds 64
|
||||
#define kMaxSounds 65
|
||||
|
||||
|
||||
void CallBack0 (PortabilityLayer::AudioChannel *);
|
||||
@@ -38,7 +38,7 @@ IGpAudioBuffer *ParseAndConvertSound(const THandle<void> &handle);
|
||||
PortabilityLayer::AudioChannel *channel0, *channel1, *channel2;
|
||||
IGpAudioBuffer *theSoundData[kMaxSounds];
|
||||
short numSoundsLoaded;
|
||||
Boolean soundLoaded[kMaxSounds], dontLoadSounds;
|
||||
Boolean dontLoadSounds;
|
||||
Boolean channelOpen, isSoundOn, failedSound;
|
||||
|
||||
//============================================================== Functions
|
||||
@@ -341,6 +341,14 @@ void CloseSoundChannels (void)
|
||||
channelOpen = false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- PingBeep
|
||||
|
||||
void PingBeep (int duration)
|
||||
{
|
||||
PlayPrioritySound(kPingSound, kPingPriority);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------- InitSound
|
||||
|
||||
void InitSound (void)
|
||||
@@ -376,6 +384,8 @@ void InitSound (void)
|
||||
failedSound = true;
|
||||
}
|
||||
}
|
||||
|
||||
SetBeepFunction (PingBeep);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- KillSound
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -25,6 +25,10 @@ void PasStringCopy(const PortabilityLayer::PascalStrLiteral<TSize> &src, unsigne
|
||||
|
||||
void SysBeep(int duration);
|
||||
|
||||
typedef void (*BeepFunction_t)(int duration);
|
||||
void SetBeepFunction(BeepFunction_t beepFunction);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include "PascalStrLiteral.h"
|
||||
|
||||
|
@@ -180,6 +180,9 @@ namespace PortabilityLayer
|
||||
|
||||
bool AudioChannelImpl::AddBuffer(IGpAudioBuffer *buffer, bool blocking)
|
||||
{
|
||||
if (!buffer)
|
||||
return false;
|
||||
|
||||
buffer->AddRef();
|
||||
|
||||
AudioCommand cmd;
|
||||
|
Reference in New Issue
Block a user