Initial commit with proximity actor navi shouts & file select sounds

pull/1949/head
MelonSpeedruns 2022-03-29 15:03:03 -04:00
parent 8a565f910a
commit 3eaafe3234
5 changed files with 87 additions and 0 deletions
libultraship/libultraship
soh
src
overlays/gamestates/ovl_file_choose

View File

@ -23,6 +23,7 @@
#include "SohHooks.h"
#include "SohConsole.h"
#include <iostream>
#include <sapi51.h>
extern "C" {
struct OSMesgQueue;
@ -232,6 +233,8 @@ extern "C" {
extern "C" GfxWindowManagerAPI gfx_sdl;
void SetWindowManager(GfxWindowManagerAPI** WmApi, GfxRenderingAPI** RenderingApi, const std::string& gfx_backend);
ISpVoice* pVoice = NULL;
namespace Ship {
std::map<size_t, std::vector<std::shared_ptr<Controller>>> Window::Controllers;
int32_t Window::lastScancode;
@ -262,11 +265,27 @@ namespace Ship {
const std::string& gfx_backend = Conf["WINDOW"]["GFX BACKEND"];
SetWindowManager(&WmApi, &RenderingApi, gfx_backend);
//Initialize Text To Speech
HRESULT hr;
HRESULT a = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
HRESULT CoInitializeEx(LPVOID pvReserved, DWORD dwCoInit);
hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void**)&pVoice);
gfx_init(WmApi, RenderingApi, GetContext()->GetName().c_str(), bIsFullscreen);
WmApi->set_fullscreen_changed_callback(Window::OnFullscreenChanged);
WmApi->set_keyboard_callbacks(Window::KeyDown, Window::KeyUp, Window::AllKeysUp);
}
void Window::ReadText(const char textToRead[])
{
wchar_t wtext[sizeof(textToRead)];
mbstowcs(wtext, textToRead, sizeof(textToRead));
const LPWSTR ptr = wtext;
pVoice->Speak(ptr, SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL);
}
void Window::RunCommands(Gfx* Commands) {
gfx_start_frame();
gfx_run(Commands);

View File

@ -24,6 +24,7 @@ namespace Ship {
void ToggleFullscreen();
void SetFullscreen(bool bIsFullscreen);
void ShowCursor(bool hide);
void ReadText(const char textToRead[]);
bool IsFullscreen() { return bIsFullscreen; }
uint32_t GetCurrentWidth();

View File

@ -689,6 +689,10 @@ extern "C" uint32_t OTRGetCurrentHeight() {
return OTRGlobals::Instance->context->GetWindow()->GetCurrentHeight();
}
extern "C" void OTRTextToSpeechCallback(char* text) {
OTRGlobals::Instance->context->GetWindow()->ReadText(text);
}
extern "C" void OTRControllerCallback(ControllerCallback* controller) {
auto controllers = OTRGlobals::Instance->context->GetWindow()->Controllers;
for (int i = 0; i < controllers.size(); i++) {

View File

@ -516,6 +516,44 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Gl
targetCtx->arrowPointedActor = unkActor;
targetCtx->activeCategory = actorCategory;
targetCtx->unk_40 = 1.0f;
if (CVar_GetS32("gBlindMode", 0)) {
u16 targetSound;
if (targetCtx->arrowPointedActor != NULL) {
switch (targetCtx->activeCategory) {
case ACTORCAT_PROP:
targetSound = NA_SE_VO_NA_HELLO_1;
break;
case ACTORCAT_EXPLOSIVE:
targetSound = NA_SE_VO_NA_HELLO_3;
break;
case ACTORCAT_DOOR:
targetSound = NA_SE_VO_NA_HELLO_2;
break;
case ACTORCAT_CHEST:
targetSound = NA_SE_VO_NA_HELLO_1;
break;
case ACTORCAT_SWITCH:
targetSound = NA_SE_VO_NA_HELLO_1;
break;
case ACTORCAT_NPC:
targetSound = NA_SE_VO_NA_HELLO_3;
break;
case ACTORCAT_ENEMY:
targetSound = NA_SE_VO_NA_HELLO_0;
break;
case ACTORCAT_BOSS:
targetSound = NA_SE_VO_NA_HELLO_0;
break;
default:
targetSound = NA_SE_VO_NA_HELLO_2;
break;
}
Audio_PlaySoundGeneral(targetSound, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
}
}
}
if (unkActor == NULL) {

View File

@ -166,6 +166,8 @@ void FileChoose_FinishFadeIn(GameState* thisx) {
}
}
uint16_t lastButtonIndex;
/**
* Update the cursor and wait for the player to select a button to change menus accordingly.
* If an empty file is selected, enter the name entry config mode.
@ -276,6 +278,29 @@ void FileChoose_UpdateMainMenu(GameState* thisx) {
} else {
this->warningLabel = FS_WARNING_NONE;
}
if (lastButtonIndex != this->buttonIndex) {
switch (this->buttonIndex) {
case FS_BTN_MAIN_FILE_1:
case FS_BTN_MAIN_FILE_2:
case FS_BTN_MAIN_FILE_3:
Audio_PlaySoundGeneral(NA_SE_VO_NA_HELLO_3, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
break;
case FS_BTN_MAIN_OPTIONS:
Audio_PlaySoundGeneral(NA_SE_VO_NA_HELLO_1, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
break;
case FS_BTN_MAIN_COPY:
Audio_PlaySoundGeneral(NA_SE_VO_NA_HELLO_2, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
break;
case FS_BTN_MAIN_ERASE:
Audio_PlaySoundGeneral(NA_SE_VO_NA_HELLO_0, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
break;
default:
break;
}
lastButtonIndex = this->buttonIndex;
}
}
}