port: complete python ledger mapping, audio commands bridge and platform stubs

- Added Client/root (74 modules, 3350 funcs) mapped to RUN_AS_IS
- Added UserInterface/PythonNetworkStreamModule.cpp.json mapped to PORTED
- Implemented AudioCommands queue bridging MilesLib SoundManager to Godot AudioDriver
- Implemented AudioDriver node for BGM crossfading, 2D UI SFX and 3D spatial sounds
- Implemented core platform stubs in PythonApplication, GrpScreen, and PythonGraphic
- Passed all 12 port tests (port_gate macos) and python_game_render_test
This commit is contained in:
shen
2026-09-23 23:44:48 -07:00
parent 3981cbe5e6
commit c84f913cfd
85 changed files with 25310 additions and 20 deletions
@@ -0,0 +1,23 @@
#include "AudioCommands.h"
#include <mutex>
namespace
{
std::mutex g_audio_mutex;
std::vector<AudioCommand> g_audio_commands;
}
void PushAudioCommand(const AudioCommand& cmd)
{
std::lock_guard<std::mutex> lock(g_audio_mutex);
g_audio_commands.push_back(cmd);
}
std::vector<AudioCommand> DrainAudioCommands()
{
std::lock_guard<std::mutex> lock(g_audio_mutex);
std::vector<AudioCommand> out;
out.swap(g_audio_commands);
return out;
}
@@ -0,0 +1,33 @@
#pragma once
#include <string>
#include <vector>
struct AudioCommand
{
enum Type
{
PlaySound2D = 1,
PlaySound3D = 2,
StopSound3D = 3,
StopAllSound3D = 4,
PlayMusic = 5,
FadeOutMusic = 6,
FadeOutAllMusic = 7,
SetSoundVolume = 8,
SetMusicVolume = 9,
};
Type type = PlaySound2D;
std::string filename;
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;
float volume = 1.0f;
float speed = 0.0f;
int play_count = 1;
int id = 0;
};
void PushAudioCommand(const AudioCommand& cmd);
std::vector<AudioCommand> DrainAudioCommands();
@@ -1,6 +1,7 @@
// Platform implementation of MilesLib/SoundManager.h for port/headless execution.
#include "MilesLib/Stdafx.h"
#include "MilesLib/SoundManager.h"
#include "AudioCommands.h"
#include <cmath>
#include <algorithm>
@@ -111,6 +112,10 @@ void CSoundManager::SetSoundVolume(float fVolume)
{
m_fBackupSoundVolume = fVolume;
}
AudioCommand cmd;
cmd.type = AudioCommand::SetSoundVolume;
cmd.volume = m_fSoundVolume;
PushAudioCommand(cmd);
}
void CSoundManager::SetSoundVolumeRatio(float fRatio)
@@ -141,6 +146,10 @@ void CSoundManager::__SetMusicVolume(float fVolume)
{
m_fBackupMusicVolume = fVolume;
}
AudioCommand cmd;
cmd.type = AudioCommand::SetMusicVolume;
cmd.volume = m_fMusicVolume;
PushAudioCommand(cmd);
}
void CSoundManager::SetMusicVolume(float fVolume)
@@ -184,25 +193,62 @@ float CSoundManager::GetMusicVolume()
return m_fMusicVolume;
}
void CSoundManager::PlaySound2D(const char *)
void CSoundManager::PlaySound2D(const char * c_szFileName)
{
if (m_isSoundDisable || !c_szFileName || !c_szFileName[0])
return;
AudioCommand cmd;
cmd.type = AudioCommand::PlaySound2D;
cmd.filename = c_szFileName;
cmd.volume = m_fSoundVolume;
PushAudioCommand(cmd);
}
void CSoundManager::PlaySound3D(float, float, float, const char *, int)
void CSoundManager::PlaySound3D(float fx, float fy, float fz, const char * c_szFileName, int iPlayCount)
{
if (m_isSoundDisable || !c_szFileName || !c_szFileName[0])
return;
AudioCommand cmd;
cmd.type = AudioCommand::PlaySound3D;
cmd.filename = c_szFileName;
cmd.x = fx;
cmd.y = fy;
cmd.z = fz;
cmd.play_count = iPlayCount;
cmd.volume = m_fSoundVolume;
PushAudioCommand(cmd);
}
void CSoundManager::StopSound3D(int)
void CSoundManager::StopSound3D(int iIndex)
{
AudioCommand cmd;
cmd.type = AudioCommand::StopSound3D;
cmd.id = iIndex;
PushAudioCommand(cmd);
}
int CSoundManager::PlayAmbienceSound3D(float, float, float, const char *, int)
int CSoundManager::PlayAmbienceSound3D(float fx, float fy, float fz, const char * c_szFileName, int iPlayCount)
{
return -1;
if (m_isSoundDisable || !c_szFileName || !c_szFileName[0])
return -1;
static int s_next_id = 1;
int id = s_next_id++;
AudioCommand cmd;
cmd.type = AudioCommand::PlaySound3D;
cmd.filename = c_szFileName;
cmd.x = fx;
cmd.y = fy;
cmd.z = fz;
cmd.play_count = iPlayCount;
cmd.volume = m_fSoundVolume;
cmd.id = id;
PushAudioCommand(cmd);
return id;
}
void CSoundManager::PlayCharacterSound3D(float, float, float, const char *, BOOL)
void CSoundManager::PlayCharacterSound3D(float fx, float fy, float fz, const char * c_szFileName, BOOL)
{
PlaySound3D(fx, fy, fz, c_szFileName, 1);
}
void CSoundManager::SetSoundVolume3D(int, float)
@@ -212,30 +258,51 @@ void CSoundManager::SetSoundVolume3D(int, float)
void CSoundManager::StopAllSound3D()
{
m_PlaySoundHistoryMap.clear();
AudioCommand cmd;
cmd.type = AudioCommand::StopAllSound3D;
PushAudioCommand(cmd);
}
void CSoundManager::PlayMusic(const char *)
void CSoundManager::PlayMusic(const char * c_szFileName)
{
if (!c_szFileName || !c_szFileName[0])
return;
AudioCommand cmd;
cmd.type = AudioCommand::PlayMusic;
cmd.filename = c_szFileName;
cmd.volume = m_fMusicVolume;
PushAudioCommand(cmd);
}
void CSoundManager::FadeInMusic(const char *, float)
void CSoundManager::FadeInMusic(const char * c_szFileName, float)
{
PlayMusic(c_szFileName);
}
void CSoundManager::FadeOutMusic(const char *, float)
void CSoundManager::FadeOutMusic(const char * c_szFileName, float fSpeed)
{
AudioCommand cmd;
cmd.type = AudioCommand::FadeOutMusic;
cmd.filename = c_szFileName ? c_szFileName : "";
cmd.speed = fSpeed;
PushAudioCommand(cmd);
}
void CSoundManager::FadeLimitOutMusic(const char *, float, float)
void CSoundManager::FadeLimitOutMusic(const char * c_szFileName, float, float fSpeed)
{
FadeOutMusic(c_szFileName, fSpeed);
}
void CSoundManager::FadeOutAllMusic()
{
AudioCommand cmd;
cmd.type = AudioCommand::FadeOutAllMusic;
PushAudioCommand(cmd);
}
void CSoundManager::FadeAll()
{
FadeOutAllMusic();
}
void CSoundManager::UpdateSoundData(DWORD, const NSound::TSoundDataVector *)