Fix reached macOS UI primitives and audio fade behavior

This commit is contained in:
shen
2026-09-24 00:31:51 -07:00
parent 330ec9745b
commit 400973da11
14 changed files with 439 additions and 66 deletions
+12 -4
View File
@@ -71,9 +71,13 @@ auto CScreen::RenderLine2d(float sx, float sy, float ex, float ey, float) -> voi
UIRenderAdd({UIRenderCommand::Line, sx, sy, ex, ey, ms_diffuseColor});
}
auto CScreen::RenderBox2d(float, float, float, float, float) -> void
auto CScreen::RenderBox2d(float sx, float sy, float ex, float ey, float) -> void
{
MT_PLATFORM_STUB();
// 40250's four line pairs, including its one-pixel extension of the bottom edge.
UIRenderAdd({UIRenderCommand::Line, sx, sy, ex, sy, ms_diffuseColor});
UIRenderAdd({UIRenderCommand::Line, sx, sy, sx, ey, ms_diffuseColor});
UIRenderAdd({UIRenderCommand::Line, ex, sy, ex, ey, ms_diffuseColor});
UIRenderAdd({UIRenderCommand::Line, sx, ey, ex + 1.0f, ey, ms_diffuseColor});
}
auto CScreen::RenderBar2d(float sx, float sy, float ex, float ey, float) -> void
@@ -81,9 +85,13 @@ auto CScreen::RenderBar2d(float sx, float sy, float ex, float ey, float) -> void
UIRenderAdd({UIRenderCommand::Bar, sx, sy, ex, ey, ms_diffuseColor});
}
auto CScreen::RenderGradationBar2d(float, float, float, float, DWORD, DWORD, float) -> void
auto CScreen::RenderGradationBar2d(float sx, float sy, float ex, float ey, DWORD start, DWORD end, float) -> void
{
MT_PLATFORM_STUB();
if (sx == ex || sy == ey)
return;
UIRenderCommand command{UIRenderCommand::GradientBar, sx, sy, ex, ey, start};
command.end_argb = end;
UIRenderAdd(std::move(command));
}
auto CScreen::RenderCircle2d(float, float, float, float, int) -> void
@@ -7,9 +7,10 @@
// Commands emitted by the 40250 UI drawing calls, consumed by Godot's CanvasItem.
// The port layer stays independent of godot-cpp.
struct UIRenderCommand {
enum Kind { Bar, Line, Text, Image } kind;
enum Kind { Bar, Line, Text, Image, GradientBar } kind;
float x1, y1, x2, y2;
std::uint32_t argb;
std::uint32_t end_argb = 0; // GradientBar only: colour on the bottom edge.
float clip_x1 = 0, clip_y1 = 0, clip_x2 = 0, clip_y2 = 0;
std::string text;
// Image only: text is the texture's file, drawn as the quad (vertices 0..3 = TL, TR, BL, BR)
@@ -16,6 +16,9 @@ struct AudioCommand
FadeOutAllMusic = 7,
SetSoundVolume = 8,
SetMusicVolume = 9,
FadeInMusic = 10,
FadeLimitOutMusic = 11,
SetSoundVolume3D = 12,
};
Type type = PlaySound2D;
@@ -171,14 +171,20 @@ void CSoundManager::SetMusicVolumeGrade(int iGrade)
void CSoundManager::SaveVolume()
{
m_fBackupMusicVolume = m_fMusicVolume;
m_fBackupSoundVolume = m_fSoundVolume;
if (m_isSoundDisable)
return;
const float musicVolume = m_fMusicVolume;
const float soundVolume = m_fSoundVolume;
SetMusicVolume(0.0f);
SetSoundVolume(0.0f);
m_fBackupMusicVolume = musicVolume;
m_fBackupSoundVolume = soundVolume;
m_isSoundDisable = TRUE;
}
void CSoundManager::RestoreVolume()
{
m_isSoundDisable = FALSE;
SetMusicVolume(m_fBackupMusicVolume);
SetSoundVolume(m_fBackupSoundVolume);
}
@@ -251,8 +257,13 @@ void CSoundManager::PlayCharacterSound3D(float fx, float fy, float fz, const cha
PlaySound3D(fx, fy, fz, c_szFileName, 1);
}
void CSoundManager::SetSoundVolume3D(int, float)
void CSoundManager::SetSoundVolume3D(int index, float volume)
{
AudioCommand cmd;
cmd.type = AudioCommand::SetSoundVolume3D;
cmd.id = index;
cmd.volume = volume;
PushAudioCommand(cmd);
}
void CSoundManager::StopAllSound3D()
@@ -274,9 +285,16 @@ void CSoundManager::PlayMusic(const char * c_szFileName)
PushAudioCommand(cmd);
}
void CSoundManager::FadeInMusic(const char * c_szFileName, float)
void CSoundManager::FadeInMusic(const char * c_szFileName, float speed)
{
PlayMusic(c_szFileName);
if (!c_szFileName || !c_szFileName[0])
return;
AudioCommand cmd;
cmd.type = AudioCommand::FadeInMusic;
cmd.filename = c_szFileName;
cmd.volume = m_fMusicVolume;
cmd.speed = speed;
PushAudioCommand(cmd);
}
void CSoundManager::FadeOutMusic(const char * c_szFileName, float fSpeed)
@@ -288,9 +306,14 @@ void CSoundManager::FadeOutMusic(const char * c_szFileName, float fSpeed)
PushAudioCommand(cmd);
}
void CSoundManager::FadeLimitOutMusic(const char * c_szFileName, float, float fSpeed)
void CSoundManager::FadeLimitOutMusic(const char * c_szFileName, float limit, float speed)
{
FadeOutMusic(c_szFileName, fSpeed);
AudioCommand cmd;
cmd.type = AudioCommand::FadeLimitOutMusic;
cmd.filename = c_szFileName ? c_szFileName : "";
cmd.volume = __ConvertRatioVolumeToApplyVolume(limit);
cmd.speed = speed;
PushAudioCommand(cmd);
}
void CSoundManager::FadeOutAllMusic()