mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-21 22:03:36 -07:00
Audio Glossary TTS
This commit is contained in:
parent
4a0a2c9e88
commit
ac6c84f296
1 changed files with 66 additions and 5 deletions
|
@ -59,6 +59,8 @@ typedef struct {
|
||||||
|
|
||||||
}SfxRecord;
|
}SfxRecord;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ActorAccessibility {
|
class ActorAccessibility {
|
||||||
public:
|
public:
|
||||||
int isOn = 0;
|
int isOn = 0;
|
||||||
|
@ -81,6 +83,15 @@ class ActorAccessibility {
|
||||||
};
|
};
|
||||||
static ActorAccessibility* aa;
|
static ActorAccessibility* aa;
|
||||||
|
|
||||||
|
class AudioGlossaryData {
|
||||||
|
public:
|
||||||
|
AccessibleActorList_t::iterator current = aa->accessibleActorList.begin();
|
||||||
|
bool GlossaryStarted = false;
|
||||||
|
int cooldown = 0;
|
||||||
|
int frameCount = 0;
|
||||||
|
};
|
||||||
|
static AudioGlossaryData* glossary;
|
||||||
|
|
||||||
uint64_t ActorAccessibility_GetNextID() {
|
uint64_t ActorAccessibility_GetNextID() {
|
||||||
uint64_t result = aa->nextActorID;
|
uint64_t result = aa->nextActorID;
|
||||||
aa->nextActorID++;
|
aa->nextActorID++;
|
||||||
|
@ -115,6 +126,7 @@ void ActorAccessibility_OnGameStillFrozen()
|
||||||
void ActorAccessibility_Init() {
|
void ActorAccessibility_Init() {
|
||||||
|
|
||||||
aa = new ActorAccessibility();
|
aa = new ActorAccessibility();
|
||||||
|
glossary = new AudioGlossaryData();
|
||||||
aa->isOn = CVarGetInteger("gA11yAudioInteraction", 0);
|
aa->isOn = CVarGetInteger("gA11yAudioInteraction", 0);
|
||||||
if (!aa->isOn)
|
if (!aa->isOn)
|
||||||
return;
|
return;
|
||||||
|
@ -396,12 +408,13 @@ int ActorAccessibility_GetRandomStartingFrameCount(int min, int max) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actor->frameCount++;
|
actor->frameCount++;
|
||||||
|
glossary->frameCount++;
|
||||||
if (actor->frameCount != 1 && (actor->frameCount - 1) % actor->policy.n != 0)
|
if (actor->frameCount != 1 && (actor->frameCount - 1) % actor->policy.n != 0)
|
||||||
return;
|
return;
|
||||||
if (!actor->policy.runsAlways && actor->xyzDistToPlayer > actor->policy.distance) {
|
if (!actor->policy.runsAlways && actor->xyzDistToPlayer > actor->policy.distance) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (actor->isDrawn == 0 && actor->actor->id != 406 && actor->actor->id != 302)
|
if (actor->isDrawn == 0 && actor->actor->id != 406 && actor->actor->id != 302 && !glossary->GlossaryStarted)
|
||||||
return;
|
return;
|
||||||
if (actor->policy.aimAssist.isProvider) {
|
if (actor->policy.aimAssist.isProvider) {
|
||||||
if (player->stateFlags1 & PLAYER_STATE1_FIRST_PERSON &&
|
if (player->stateFlags1 & PLAYER_STATE1_FIRST_PERSON &&
|
||||||
|
@ -453,6 +466,11 @@ int ActorAccessibility_GetRandomStartingFrameCount(int min, int max) {
|
||||||
if (player->stateFlags1 & PLAYER_STATE1_IN_CUTSCENE) {
|
if (player->stateFlags1 & PLAYER_STATE1_IN_CUTSCENE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ActorAccessibility_AudioGlossary(play);
|
||||||
|
if (glossary->GlossaryStarted) {
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
//Real actors.
|
//Real actors.
|
||||||
for (AccessibleActorList_t::iterator i = aa->accessibleActorList.begin(); i != aa->accessibleActorList.end(); i++)
|
for (AccessibleActorList_t::iterator i = aa->accessibleActorList.begin(); i != aa->accessibleActorList.end(); i++)
|
||||||
ActorAccessibility_RunAccessibilityForActor(play, &i->second);
|
ActorAccessibility_RunAccessibilityForActor(play, &i->second);
|
||||||
|
@ -470,21 +488,64 @@ int ActorAccessibility_GetRandomStartingFrameCount(int min, int max) {
|
||||||
for (VAList_t::iterator i = list->begin(); i != list->end(); i++)
|
for (VAList_t::iterator i = list->begin(); i != list->end(); i++)
|
||||||
ActorAccessibility_RunAccessibilityForActor(play, &(*i));
|
ActorAccessibility_RunAccessibilityForActor(play, &(*i));
|
||||||
|
|
||||||
ActorAccessibility_AudioGlossary(play);
|
|
||||||
|
|
||||||
//Processes external audio engine.
|
//Processes external audio engine.
|
||||||
ActorAccessibility_PrepareNextAudioFrame();
|
ActorAccessibility_PrepareNextAudioFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActorAccessibility_AudioGlossary(PlayState* play) {
|
void ActorAccessibility_AudioGlossary(PlayState* play) {
|
||||||
AccessibleActorList_t::iterator i = aa->accessibleActorList.begin();
|
if (glossary->GlossaryStarted) {
|
||||||
|
AccessibleActor glossaryActor = (*glossary->current).second;
|
||||||
|
ActorAccessibility_CopyParamsFromRealActor(&glossaryActor);
|
||||||
|
glossaryActor.policy.distance = glossaryActor.xzDistToPlayer * 3;
|
||||||
|
glossaryActor.policy.ydist = 1000;
|
||||||
|
glossaryActor.frameCount = glossary->frameCount;
|
||||||
|
ActorAccessibility_RunAccessibilityForActor(play, &glossaryActor);
|
||||||
|
}
|
||||||
|
if (glossary->cooldown != 0) {
|
||||||
|
glossary->cooldown--;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
OSContPad* trackerButtonsPressed = LUS::Context::GetInstance()->GetControlDeck()->GetPads();
|
OSContPad* trackerButtonsPressed = LUS::Context::GetInstance()->GetControlDeck()->GetPads();
|
||||||
bool comboStartGlossary = trackerButtonsPressed != nullptr && trackerButtonsPressed[0].button & buttons[10] &&
|
bool comboStartGlossary = trackerButtonsPressed != nullptr && trackerButtonsPressed[0].button & buttons[10] &&
|
||||||
trackerButtonsPressed[0].button & buttons[6];
|
trackerButtonsPressed[0].button & buttons[6];
|
||||||
if (comboStartGlossary) {
|
if (comboStartGlossary) {
|
||||||
SpeechSynthesizer::Instance->Speak((*i).second.policy.englishName, GetLanguageCode());
|
glossary->GlossaryStarted = true;
|
||||||
|
glossary->current = aa->accessibleActorList.begin();
|
||||||
|
SpeechSynthesizer::Instance->Speak((*glossary->current).second.policy.englishName, GetLanguageCode());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
bool comboNextGlossary = trackerButtonsPressed != nullptr && trackerButtonsPressed[0].button & buttons[13] &&
|
||||||
|
trackerButtonsPressed[0].button & buttons[6];
|
||||||
|
if (comboNextGlossary && glossary->GlossaryStarted) {
|
||||||
|
if (glossary->current != aa->accessibleActorList.end()) {
|
||||||
|
glossary->current++;
|
||||||
|
|
||||||
|
};
|
||||||
|
glossary->cooldown = 20;
|
||||||
|
SpeechSynthesizer::Instance->Speak((*glossary->current).second.policy.englishName, GetLanguageCode());
|
||||||
|
}
|
||||||
|
bool comboPrevGlossary = trackerButtonsPressed != nullptr && trackerButtonsPressed[0].button & buttons[12] &&
|
||||||
|
trackerButtonsPressed[0].button & buttons[6];
|
||||||
|
if (comboPrevGlossary && glossary->GlossaryStarted) {
|
||||||
|
if (glossary->current != aa->accessibleActorList.begin()) {
|
||||||
|
glossary->current--;
|
||||||
|
|
||||||
|
};
|
||||||
|
glossary->cooldown = 20;
|
||||||
|
|
||||||
|
|
||||||
|
SpeechSynthesizer::Instance->Speak((*glossary->current).second.policy.englishName, GetLanguageCode());
|
||||||
|
|
||||||
|
}
|
||||||
|
bool comboDisableGlossary = trackerButtonsPressed != nullptr && trackerButtonsPressed[0].button & buttons[11] &&
|
||||||
|
trackerButtonsPressed[0].button & buttons[6];
|
||||||
|
if (comboDisableGlossary) {
|
||||||
|
glossary->cooldown = 0;
|
||||||
|
glossary->GlossaryStarted = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//Virtual actor config.
|
//Virtual actor config.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue