2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 14:37:41 +00:00

Initial pass at getting subtitle support in. Doesn't compile for unknown reasons

This commit is contained in:
ZarothYe
2022-02-23 21:35:03 -06:00
parent 84eedce685
commit 229883654e
22 changed files with 579 additions and 39 deletions

View File

@ -94,6 +94,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "../pfGameMgr/pfGameMgr.h"
#include "../plMessage/plAIMsg.h"
#include "../plAvatar/plAvBrainCritter.h"
#include "../plMessage/plSubtitleMsg.h"
#include "plProfile.h"
@ -189,6 +190,7 @@ char* plPythonFileMod::fFunctionNames[] =
{ "OnGameMgrMsg" }, // kfunc_OnGameMgrMsg
{ "OnGameCliMsg" }, // kfunc_OnGameCliMsg
{ "OnAIMsg" }, // kfunc_OnAIMsg
{ "OnSubtitleMsg" }, // kfunc_OnSubtitleMsg
{ nil }
};
@ -2780,6 +2782,36 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
}
}
if (fPyFunctionInstances[kfunc_OnSubtitleMsg])
{
plSubtitleMsg* pSubMsg = plSubtitleMsg::ConvertNoRef(msg);
if (pSubMsg)
{
plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_OnSubtitleMsg], fFunctionNames[kfunc_OnSubtitleMsg],
"ss", pSubMsg->GetText(), pSubMsg->GetSpeaker());
if (retVal == nil)
{
#ifndef PLASMA_EXTERNAL_RELEASE
// for some reason this function didn't, remember that and not call it again
fPyFunctionInstances[kfunc_OnSubtitleMsg] = nil;
#endif //PLASMA_EXTERNAL_RELEASE
// if there was an error make sure that the stderr gets flushed so it can be seen
ReportError();
}
Py_XDECREF(retVal);
plProfile_EndTiming(PythonUpdate);
// display any output (NOTE: this would be disabled in production)
DisplayPythonOutput();
// we handled this message (I think)
return true;
}
}
return plModifier::MsgReceive(msg);
}

View File

@ -202,6 +202,7 @@ public:
kfunc_OnGameMgrMsg,
kfunc_OnGameCliMsg,
kfunc_OnAIMsg,
kfunc_OnSubtitleMsg,
kfunc_lastone
};
// array of matching Python instance where the functions are, if defined

View File

@ -256,6 +256,22 @@ hsBool pyAudioControl::IsMuted()
return plgAudioSys::IsMuted();
}
// Enable or disable displaying speech subtitles
void pyAudioControl::EnableSubtitles()
{
plgAudioSys::SetEnableSubtitles(true);
}
void pyAudioControl::DisableSubtitles()
{
plgAudioSys::SetEnableSubtitles(false);
}
bool pyAudioControl::AreSubtitlesEnabled() const
{
return plgAudioSys::AreSubtitlesEnabled();
}
hsBool pyAudioControl::SupportEAX(const char *deviceName)
{
return plgAudioSys::SupportsEAX(deviceName);

View File

@ -109,6 +109,11 @@ public:
virtual void UnmuteAll();
virtual hsBool IsMuted();
// Enable or disable displaying speech subtitles
void EnableSubtitles();
void DisableSubtitles();
bool AreSubtitlesEnabled() const;
virtual void SetAudioSystemMode(int mode); // sets the current mode
virtual int GetAudioSystemMode(); // returns the current mode
virtual int GetHighestAudioMode(); // returns the highest mode the card is capable of handling

View File

@ -242,6 +242,14 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptAudioControl, isMuted)
PYTHON_RETURN_BOOL(self->fThis->IsMuted());
}
PYTHON_BASIC_METHOD_DEFINITION(ptAudioControl, enableSubtitles, EnableSubtitles)
PYTHON_BASIC_METHOD_DEFINITION(ptAudioControl, disableSubtitles, DisableSubtitles)
PYTHON_METHOD_DEFINITION_NOARGS(ptAudioControl, areSubtitlesEnabled)
{
PYTHON_RETURN_BOOL(self->fThis->AreSubtitlesEnabled());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAudioControl, canSetMicLevel)
{
PYTHON_RETURN_BOOL(self->fThis->CanSetMicLevel());
@ -484,6 +492,9 @@ PYTHON_START_METHODS_TABLE(ptAudioControl)
PYTHON_BASIC_METHOD(ptAudioControl, muteAll, "Mutes all sounds."),
PYTHON_BASIC_METHOD(ptAudioControl, unmuteAll, "Unmutes all sounds."),
PYTHON_METHOD_NOARGS(ptAudioControl, isMuted, "Are all sounds muted? Returns 1 if true otherwise returns 0."),
PYTHON_BASIC_METHOD(ptAudioControl, enableSubtitles, "Enables audio subtitles."),
PYTHON_BASIC_METHOD(ptAudioControl, disableSubtitles, "Disables audio subtitles."),
PYTHON_METHOD_NOARGS(ptAudioControl, areSubtitlesEnabled, "Are audio subtitles enabled? Returns 1 if true otherwise returns 0."),
PYTHON_METHOD_NOARGS(ptAudioControl, canSetMicLevel, "Can the microphone level be set? Returns 1 if true otherwise returns 0."),
PYTHON_METHOD(ptAudioControl, setMicLevel, "Params: level\nSets the microphone recording level (0.0 to 1.0)."),
PYTHON_METHOD_NOARGS(ptAudioControl, getMicLevel, "Returns the microphone recording level (0.0 to 1.0)."),