mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 21:01:37 +00:00
options_menu: allow providing reasons for greyed out options
This commit is contained in:
parent
1f7f093e22
commit
837914dfdc
4 changed files with 26 additions and 22 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
#include <kernel/memory.h>
|
#include <kernel/memory.h>
|
||||||
#include <ui/window.h>
|
#include <ui/window.h>
|
||||||
|
|
||||||
extern "C" void Game_PlaySound(const char* pName)
|
SWA_API void Game_PlaySound(const char* pName)
|
||||||
{
|
{
|
||||||
void* soundPlayerSharedPtr = g_userHeap.Alloc(8);
|
void* soundPlayerSharedPtr = g_userHeap.Alloc(8);
|
||||||
GuestToHostFunction<void>(0x82B4DF50, soundPlayerSharedPtr, ((be<uint32_t>*)g_memory.Translate(0x83367900))->get(), 7, 0, 0);
|
GuestToHostFunction<void>(0x82B4DF50, soundPlayerSharedPtr, ((be<uint32_t>*)g_memory.Translate(0x83367900))->get(), 7, 0, 0);
|
||||||
|
|
@ -22,7 +22,7 @@ extern "C" void Game_PlaySound(const char* pName)
|
||||||
g_userHeap.Free(soundPlayerSharedPtr);
|
g_userHeap.Free(soundPlayerSharedPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void Window_SetFullscreen(bool isEnabled)
|
SWA_API void Window_SetFullscreen(bool isEnabled)
|
||||||
{
|
{
|
||||||
Window::SetFullscreen(isEnabled);
|
Window::SetFullscreen(isEnabled);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
extern "C" void Game_PlaySound(const char* pName);
|
SWA_API void Game_PlaySound(const char* pName);
|
||||||
extern "C" void Window_SetFullscreen(bool isEnabled);
|
SWA_API void Window_SetFullscreen(bool isEnabled);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ bool InjectOptionsBehaviour(uint32_t pThis, uint32_t count)
|
||||||
auto pHudPause = (SWA::CHudPause*)g_memory.Translate(pThis);
|
auto pHudPause = (SWA::CHudPause*)g_memory.Translate(pThis);
|
||||||
auto cursorIndex = *(be<uint32_t>*)g_memory.Translate(4 * (*(be<uint32_t>*)g_memory.Translate(pThis + 0x19C) + 0x68) + pThis);
|
auto cursorIndex = *(be<uint32_t>*)g_memory.Translate(4 * (*(be<uint32_t>*)g_memory.Translate(pThis + 0x19C) + 0x68) + pThis);
|
||||||
|
|
||||||
auto exitType = SWA::eActionType_Undefined;
|
auto actionType = SWA::eActionType_Undefined;
|
||||||
auto transitionType = SWA::eTransitionType_Undefined;
|
auto transitionType = SWA::eTransitionType_Undefined;
|
||||||
|
|
||||||
switch (pHudPause->m_Menu)
|
switch (pHudPause->m_Menu)
|
||||||
|
|
@ -32,13 +32,13 @@ bool InjectOptionsBehaviour(uint32_t pThis, uint32_t count)
|
||||||
case SWA::eMenuType_WorldMap:
|
case SWA::eMenuType_WorldMap:
|
||||||
case SWA::eMenuType_Stage:
|
case SWA::eMenuType_Stage:
|
||||||
case SWA::eMenuType_Misc:
|
case SWA::eMenuType_Misc:
|
||||||
exitType = SWA::eActionType_Return;
|
actionType = SWA::eActionType_Return;
|
||||||
transitionType = SWA::eTransitionType_Quit;
|
transitionType = SWA::eTransitionType_Quit;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SWA::eMenuType_Village:
|
case SWA::eMenuType_Village:
|
||||||
case SWA::eMenuType_Hub:
|
case SWA::eMenuType_Hub:
|
||||||
exitType = SWA::eActionType_Return;
|
actionType = SWA::eActionType_Return;
|
||||||
transitionType = SWA::eTransitionType_Hide;
|
transitionType = SWA::eTransitionType_Hide;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +56,7 @@ bool InjectOptionsBehaviour(uint32_t pThis, uint32_t count)
|
||||||
}
|
}
|
||||||
else if (cursorIndex == count - 1)
|
else if (cursorIndex == count - 1)
|
||||||
{
|
{
|
||||||
pHudPause->m_Action = exitType;
|
pHudPause->m_Action = actionType;
|
||||||
pHudPause->m_Transition = transitionType;
|
pHudPause->m_Transition = transitionType;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ static ImFont* g_dfsogeistdFont;
|
||||||
static ImFont* g_newRodinFont;
|
static ImFont* g_newRodinFont;
|
||||||
|
|
||||||
static const IConfigDef* g_selectedItem;
|
static const IConfigDef* g_selectedItem;
|
||||||
static bool g_isSelectedItemAccessible;
|
|
||||||
|
static std::string* g_inaccessibleReason;
|
||||||
|
|
||||||
static bool g_isEnterKeyBuffered = false;
|
static bool g_isEnterKeyBuffered = false;
|
||||||
|
|
||||||
|
|
@ -496,7 +497,9 @@ static bool DrawCategories()
|
||||||
extern void VideoConfigValueChangedCallback(IConfigDef* config);
|
extern void VideoConfigValueChangedCallback(IConfigDef* config);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* config, bool isAccessible, T valueMin = T(0), T valueCenter = T(0.5), T valueMax = T(1))
|
static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* config,
|
||||||
|
bool isAccessible, std::string* inaccessibleReason = nullptr,
|
||||||
|
T valueMin = T(0), T valueCenter = T(0.5), T valueMax = T(1))
|
||||||
{
|
{
|
||||||
auto drawList = ImGui::GetForegroundDrawList();
|
auto drawList = ImGui::GetForegroundDrawList();
|
||||||
auto clipRectMin = drawList->GetClipRectMin();
|
auto clipRectMin = drawList->GetClipRectMin();
|
||||||
|
|
@ -527,7 +530,7 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
||||||
if (g_selectedRowIndex == rowIndex)
|
if (g_selectedRowIndex == rowIndex)
|
||||||
{
|
{
|
||||||
g_selectedItem = config;
|
g_selectedItem = config;
|
||||||
g_isSelectedItemAccessible = isAccessible;
|
g_inaccessibleReason = isAccessible ? nullptr : inaccessibleReason;
|
||||||
|
|
||||||
if (!g_isEnterKeyBuffered)
|
if (!g_isEnterKeyBuffered)
|
||||||
{
|
{
|
||||||
|
|
@ -834,14 +837,15 @@ static void DrawConfigOptions()
|
||||||
int32_t rowCount = 0;
|
int32_t rowCount = 0;
|
||||||
|
|
||||||
bool isStage = OptionsMenu::s_pauseMenuType == SWA::eMenuType_Stage || OptionsMenu::s_pauseMenuType == SWA::eMenuType_Hub;
|
bool isStage = OptionsMenu::s_pauseMenuType == SWA::eMenuType_Stage || OptionsMenu::s_pauseMenuType == SWA::eMenuType_Hub;
|
||||||
|
auto cmnReason = &Localise("Options_Desc_NotAvailable");
|
||||||
|
|
||||||
// TODO: Don't use raw numbers here!
|
// TODO: Don't use raw numbers here!
|
||||||
switch (g_categoryIndex)
|
switch (g_categoryIndex)
|
||||||
{
|
{
|
||||||
case 0: // SYSTEM
|
case 0: // SYSTEM
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::Language, !OptionsMenu::s_isPause);
|
DrawConfigOption(rowCount++, yOffset, &Config::Language, !OptionsMenu::s_isPause, cmnReason);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::Hints, !isStage);
|
DrawConfigOption(rowCount++, yOffset, &Config::Hints, !isStage, cmnReason);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::ControlTutorial, !isStage);
|
DrawConfigOption(rowCount++, yOffset, &Config::ControlTutorial, !isStage, cmnReason);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::SaveScoreAtCheckpoints, true);
|
DrawConfigOption(rowCount++, yOffset, &Config::SaveScoreAtCheckpoints, true);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::UnleashGaugeBehaviour, true);
|
DrawConfigOption(rowCount++, yOffset, &Config::UnleashGaugeBehaviour, true);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::WerehogHubTransformVideo, true);
|
DrawConfigOption(rowCount++, yOffset, &Config::WerehogHubTransformVideo, true);
|
||||||
|
|
@ -850,7 +854,7 @@ static void DrawConfigOptions()
|
||||||
case 1: // INPUT
|
case 1: // INPUT
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::CameraXInvert, true);
|
DrawConfigOption(rowCount++, yOffset, &Config::CameraXInvert, true);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::CameraYInvert, true);
|
DrawConfigOption(rowCount++, yOffset, &Config::CameraYInvert, true);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::XButtonHoming, !OptionsMenu::s_isPause); // TODO: make this editable in stages.
|
DrawConfigOption(rowCount++, yOffset, &Config::XButtonHoming, !OptionsMenu::s_isPause, cmnReason); // TODO: make this editable in stages.
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::UnleashCancel, true);
|
DrawConfigOption(rowCount++, yOffset, &Config::UnleashCancel, true);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::BackgroundInput, true);
|
DrawConfigOption(rowCount++, yOffset, &Config::BackgroundInput, true);
|
||||||
break;
|
break;
|
||||||
|
|
@ -863,11 +867,11 @@ static void DrawConfigOptions()
|
||||||
break;
|
break;
|
||||||
case 3: // VIDEO
|
case 3: // VIDEO
|
||||||
// TODO: expose WindowWidth/WindowHeight as WindowSize.
|
// TODO: expose WindowWidth/WindowHeight as WindowSize.
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::ResolutionScale, true, 0.25f, 1.0f, 2.0f);
|
DrawConfigOption(rowCount++, yOffset, &Config::ResolutionScale, true, nullptr, 0.25f, 1.0f, 2.0f);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::Fullscreen, true);
|
DrawConfigOption(rowCount++, yOffset, &Config::Fullscreen, true);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::VSync, true);
|
DrawConfigOption(rowCount++, yOffset, &Config::VSync, true);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::TripleBuffering, true);
|
DrawConfigOption(rowCount++, yOffset, &Config::TripleBuffering, true);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::FPS, true, 15, 120, 240);
|
DrawConfigOption(rowCount++, yOffset, &Config::FPS, true, nullptr, 15, 120, 240);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::Brightness, true);
|
DrawConfigOption(rowCount++, yOffset, &Config::Brightness, true);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::AntiAliasing, true);
|
DrawConfigOption(rowCount++, yOffset, &Config::AntiAliasing, true);
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::AlphaToCoverage, true);
|
DrawConfigOption(rowCount++, yOffset, &Config::AlphaToCoverage, true);
|
||||||
|
|
@ -993,7 +997,11 @@ static void DrawInfoPanel()
|
||||||
{
|
{
|
||||||
auto desc = g_selectedItem->GetDescription();
|
auto desc = g_selectedItem->GetDescription();
|
||||||
|
|
||||||
if (g_isSelectedItemAccessible)
|
if (g_inaccessibleReason)
|
||||||
|
{
|
||||||
|
desc = *g_inaccessibleReason;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// Specialised description for resolution scale
|
// Specialised description for resolution scale
|
||||||
if (g_selectedItem->GetName() == "ResolutionScale")
|
if (g_selectedItem->GetName() == "ResolutionScale")
|
||||||
|
|
@ -1010,10 +1018,6 @@ static void DrawInfoPanel()
|
||||||
|
|
||||||
desc += "\n\n" + g_selectedItem->GetValueDescription();
|
desc += "\n\n" + g_selectedItem->GetValueDescription();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
desc = Localise("Options_Desc_NotAvailable");
|
|
||||||
}
|
|
||||||
|
|
||||||
auto size = Scale(26.0f);
|
auto size = Scale(26.0f);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue