mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 04:41:39 +00:00
options_menu: fix naming convention
This commit is contained in:
parent
3015111379
commit
82f3c4ee1a
1 changed files with 141 additions and 141 deletions
|
|
@ -32,39 +32,39 @@ constexpr float COMMON_PADDING_POS_Y = 118.0f;
|
||||||
constexpr float COMMON_PADDING_POS_X = 30.0f;
|
constexpr float COMMON_PADDING_POS_X = 30.0f;
|
||||||
constexpr float INFO_CONTAINER_POS_X = 870.0f;
|
constexpr float INFO_CONTAINER_POS_X = 870.0f;
|
||||||
|
|
||||||
static constexpr int32_t m_categoryCount = 4;
|
static constexpr int32_t g_categoryCount = 4;
|
||||||
static int32_t m_categoryIndex;
|
static int32_t g_categoryIndex;
|
||||||
static ImVec2 m_categoryAnimMin;
|
static ImVec2 g_categoryAnimMin;
|
||||||
static ImVec2 m_categoryAnimMax;
|
static ImVec2 g_categoryAnimMax;
|
||||||
|
|
||||||
static int32_t m_firstVisibleRowIndex;
|
static int32_t g_firstVisibleRowIndex;
|
||||||
static int32_t m_prevSelectedRowIndex;
|
static int32_t g_prevSelectedRowIndex;
|
||||||
static int32_t m_selectedRowIndex;
|
static int32_t g_selectedRowIndex;
|
||||||
static double m_rowSelectionTime;
|
static double g_rowSelectionTime;
|
||||||
|
|
||||||
static bool m_leftWasHeld;
|
static bool g_leftWasHeld;
|
||||||
static bool m_upWasHeld;
|
static bool g_upWasHeld;
|
||||||
static bool m_rightWasHeld;
|
static bool g_rightWasHeld;
|
||||||
static bool m_downWasHeld;
|
static bool g_downWasHeld;
|
||||||
|
|
||||||
static bool m_lockedOnOption;
|
static bool g_lockedOnOption;
|
||||||
static double m_lastTappedTime;
|
static double g_lastTappedTime;
|
||||||
static double m_lastIncrementTime;
|
static double g_lastIncrementTime;
|
||||||
static double m_lastIncrementSoundTime;
|
static double g_lastIncrementSoundTime;
|
||||||
|
|
||||||
static constexpr size_t GRID_SIZE = 9;
|
static constexpr size_t GRID_SIZE = 9;
|
||||||
|
|
||||||
static ImFont* m_seuratFont;
|
static ImFont* g_seuratFont;
|
||||||
static ImFont* m_dfsogeistdFont;
|
static ImFont* g_dfsogeistdFont;
|
||||||
static ImFont* m_newRodinFont;
|
static ImFont* g_newRodinFont;
|
||||||
|
|
||||||
static const IConfigDef* m_selectedItem;
|
static const IConfigDef* g_selectedItem;
|
||||||
|
|
||||||
static std::string* m_inaccessibleReason;
|
static std::string* g_inaccessibleReason;
|
||||||
|
|
||||||
static bool m_isEnterKeyBuffered = false;
|
static bool g_isEnterKeyBuffered = false;
|
||||||
|
|
||||||
static double m_appearTime = 0.0;
|
static double g_appearTime = 0.0;
|
||||||
|
|
||||||
static void DrawScanlineBars()
|
static void DrawScanlineBars()
|
||||||
{
|
{
|
||||||
|
|
@ -132,7 +132,7 @@ static void DrawScanlineBars()
|
||||||
|
|
||||||
// Options text
|
// Options text
|
||||||
// TODO: localise this.
|
// TODO: localise this.
|
||||||
DrawTextWithOutline<int>(m_dfsogeistdFont, Scale(48.0f), { Scale(122.0f), Scale(56.0f) }, IM_COL32(255, 195, 0, 255), "OPTIONS", 4, IM_COL32_BLACK);
|
DrawTextWithOutline<int>(g_dfsogeistdFont, Scale(48.0f), { Scale(122.0f), Scale(56.0f) }, IM_COL32(255, 195, 0, 255), "OPTIONS", 4, IM_COL32_BLACK);
|
||||||
|
|
||||||
// Top bar line
|
// Top bar line
|
||||||
drawList->AddLine
|
drawList->AddLine
|
||||||
|
|
@ -160,7 +160,7 @@ static float AlignToNextGrid(float value)
|
||||||
|
|
||||||
static void DrawContainer(ImVec2 min, ImVec2 max)
|
static void DrawContainer(ImVec2 min, ImVec2 max)
|
||||||
{
|
{
|
||||||
double containerHeight = ComputeMotion(m_appearTime, 0.0, CONTAINER_LINE_ANIMATION_DURATION);
|
double containerHeight = ComputeMotion(g_appearTime, 0.0, CONTAINER_LINE_ANIMATION_DURATION);
|
||||||
|
|
||||||
float center = (min.y + max.y) / 2.0f;
|
float center = (min.y + max.y) / 2.0f;
|
||||||
min.y = Lerp(center, min.y, containerHeight);
|
min.y = Lerp(center, min.y, containerHeight);
|
||||||
|
|
@ -169,9 +169,9 @@ static void DrawContainer(ImVec2 min, ImVec2 max)
|
||||||
auto& res = ImGui::GetIO().DisplaySize;
|
auto& res = ImGui::GetIO().DisplaySize;
|
||||||
auto drawList = ImGui::GetForegroundDrawList();
|
auto drawList = ImGui::GetForegroundDrawList();
|
||||||
|
|
||||||
double outerAlpha = ComputeMotion(m_appearTime, CONTAINER_OUTER_TIME, CONTAINER_OUTER_DURATION);
|
double outerAlpha = ComputeMotion(g_appearTime, CONTAINER_OUTER_TIME, CONTAINER_OUTER_DURATION);
|
||||||
double innerAlpha = ComputeMotion(m_appearTime, CONTAINER_INNER_TIME, CONTAINER_INNER_DURATION);
|
double innerAlpha = ComputeMotion(g_appearTime, CONTAINER_INNER_TIME, CONTAINER_INNER_DURATION);
|
||||||
double backgroundAlpha = ComputeMotion(m_appearTime, CONTAINER_BACKGROUND_TIME, CONTAINER_BACKGROUND_DURATION);
|
double backgroundAlpha = ComputeMotion(g_appearTime, CONTAINER_BACKGROUND_TIME, CONTAINER_BACKGROUND_DURATION);
|
||||||
|
|
||||||
const uint32_t lineColor = IM_COL32(0, 89, 0, 255 * containerHeight);
|
const uint32_t lineColor = IM_COL32(0, 89, 0, 255 * containerHeight);
|
||||||
const uint32_t outerColor = IM_COL32(0, 49, 0, 255 * outerAlpha);
|
const uint32_t outerColor = IM_COL32(0, 49, 0, 255 * outerAlpha);
|
||||||
|
|
@ -225,42 +225,42 @@ static std::string& GetCategory(int index)
|
||||||
|
|
||||||
static void ResetSelection()
|
static void ResetSelection()
|
||||||
{
|
{
|
||||||
m_firstVisibleRowIndex = 0;
|
g_firstVisibleRowIndex = 0;
|
||||||
m_selectedRowIndex = 0;
|
g_selectedRowIndex = 0;
|
||||||
m_prevSelectedRowIndex = 0;
|
g_prevSelectedRowIndex = 0;
|
||||||
m_rowSelectionTime = ImGui::GetTime();
|
g_rowSelectionTime = ImGui::GetTime();
|
||||||
m_leftWasHeld = false;
|
g_leftWasHeld = false;
|
||||||
m_upWasHeld = false;
|
g_upWasHeld = false;
|
||||||
m_rightWasHeld = false;
|
g_rightWasHeld = false;
|
||||||
m_downWasHeld = false;
|
g_downWasHeld = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool DrawCategories()
|
static bool DrawCategories()
|
||||||
{
|
{
|
||||||
double motion = ComputeMotion(m_appearTime, CONTAINER_CATEGORY_TIME, CONTAINER_CATEGORY_DURATION);
|
double motion = ComputeMotion(g_appearTime, CONTAINER_CATEGORY_TIME, CONTAINER_CATEGORY_DURATION);
|
||||||
|
|
||||||
if (motion == 0.0)
|
if (motion == 0.0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto inputState = SWA::CInputState::GetInstance();
|
auto inputState = SWA::CInputState::GetInstance();
|
||||||
|
|
||||||
bool moveLeft = !m_lockedOnOption && (inputState->GetPadState().IsTapped(SWA::eKeyState_LeftBumper) ||
|
bool moveLeft = !g_lockedOnOption && (inputState->GetPadState().IsTapped(SWA::eKeyState_LeftBumper) ||
|
||||||
inputState->GetPadState().IsTapped(SWA::eKeyState_LeftTrigger));
|
inputState->GetPadState().IsTapped(SWA::eKeyState_LeftTrigger));
|
||||||
|
|
||||||
bool moveRight = !m_lockedOnOption && (inputState->GetPadState().IsTapped(SWA::eKeyState_RightBumper) ||
|
bool moveRight = !g_lockedOnOption && (inputState->GetPadState().IsTapped(SWA::eKeyState_RightBumper) ||
|
||||||
inputState->GetPadState().IsTapped(SWA::eKeyState_RightTrigger));
|
inputState->GetPadState().IsTapped(SWA::eKeyState_RightTrigger));
|
||||||
|
|
||||||
if (moveLeft)
|
if (moveLeft)
|
||||||
{
|
{
|
||||||
--m_categoryIndex;
|
--g_categoryIndex;
|
||||||
if (m_categoryIndex < 0)
|
if (g_categoryIndex < 0)
|
||||||
m_categoryIndex = m_categoryCount - 1;
|
g_categoryIndex = g_categoryCount - 1;
|
||||||
}
|
}
|
||||||
else if (moveRight)
|
else if (moveRight)
|
||||||
{
|
{
|
||||||
++m_categoryIndex;
|
++g_categoryIndex;
|
||||||
if (m_categoryIndex >= m_categoryCount)
|
if (g_categoryIndex >= g_categoryCount)
|
||||||
m_categoryIndex = 0;
|
g_categoryIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moveLeft || moveRight)
|
if (moveLeft || moveRight)
|
||||||
|
|
@ -278,22 +278,22 @@ static bool DrawCategories()
|
||||||
float tabPadding = gridSize;
|
float tabPadding = gridSize;
|
||||||
|
|
||||||
float size = Scale(32.0f);
|
float size = Scale(32.0f);
|
||||||
ImVec2 textSizes[m_categoryCount];
|
ImVec2 textSizes[g_categoryCount];
|
||||||
float tabWidthSum = 0.0f;
|
float tabWidthSum = 0.0f;
|
||||||
for (size_t i = 0; i < m_categoryCount; i++)
|
for (size_t i = 0; i < g_categoryCount; i++)
|
||||||
{
|
{
|
||||||
textSizes[i] = m_dfsogeistdFont->CalcTextSizeA(size, FLT_MAX, 0.0f, GetCategory(i).c_str());
|
textSizes[i] = g_dfsogeistdFont->CalcTextSizeA(size, FLT_MAX, 0.0f, GetCategory(i).c_str());
|
||||||
tabWidthSum += textSizes[i].x + textPadding * 2.0f;
|
tabWidthSum += textSizes[i].x + textPadding * 2.0f;
|
||||||
}
|
}
|
||||||
tabWidthSum += (m_categoryCount - 1) * tabPadding;
|
tabWidthSum += (g_categoryCount - 1) * tabPadding;
|
||||||
|
|
||||||
float tabHeight = gridSize * 4.0f;
|
float tabHeight = gridSize * 4.0f;
|
||||||
float xOffset = ((clipRectMax.x - clipRectMin.x) - tabWidthSum) / 2.0f;
|
float xOffset = ((clipRectMax.x - clipRectMin.x) - tabWidthSum) / 2.0f;
|
||||||
xOffset -= (1.0 - motion) * gridSize * 4.0;
|
xOffset -= (1.0 - motion) * gridSize * 4.0;
|
||||||
|
|
||||||
ImVec2 minVec[m_categoryCount];
|
ImVec2 minVec[g_categoryCount];
|
||||||
|
|
||||||
for (size_t i = 0; i < m_categoryCount; i++)
|
for (size_t i = 0; i < g_categoryCount; i++)
|
||||||
{
|
{
|
||||||
ImVec2 min = { clipRectMin.x + xOffset, clipRectMin.y };
|
ImVec2 min = { clipRectMin.x + xOffset, clipRectMin.y };
|
||||||
|
|
||||||
|
|
@ -301,39 +301,39 @@ static bool DrawCategories()
|
||||||
ImVec2 max = { clipRectMin.x + xOffset, clipRectMin.y + tabHeight };
|
ImVec2 max = { clipRectMin.x + xOffset, clipRectMin.y + tabHeight };
|
||||||
xOffset += tabPadding;
|
xOffset += tabPadding;
|
||||||
|
|
||||||
if (m_categoryIndex == i)
|
if (g_categoryIndex == i)
|
||||||
{
|
{
|
||||||
// Animation interrupted by entering/exiting or resizing the options menu
|
// Animation interrupted by entering/exiting or resizing the options menu
|
||||||
if (motion < 1.0 || abs(m_categoryAnimMin.y - min.y) > 0.01f || abs(m_categoryAnimMax.y - max.y) > 0.01f)
|
if (motion < 1.0 || abs(g_categoryAnimMin.y - min.y) > 0.01f || abs(g_categoryAnimMax.y - max.y) > 0.01f)
|
||||||
{
|
{
|
||||||
m_categoryAnimMin = min;
|
g_categoryAnimMin = min;
|
||||||
m_categoryAnimMax = max;
|
g_categoryAnimMax = max;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float animWidth = m_categoryAnimMax.x - m_categoryAnimMin.x;
|
float animWidth = g_categoryAnimMax.x - g_categoryAnimMin.x;
|
||||||
float width = max.x - min.x;
|
float width = max.x - min.x;
|
||||||
float height = max.y - min.y;
|
float height = max.y - min.y;
|
||||||
|
|
||||||
animWidth = Lerp(animWidth, width, 1.0f - exp(-64.0f * ImGui::GetIO().DeltaTime));
|
animWidth = Lerp(animWidth, width, 1.0f - exp(-64.0f * ImGui::GetIO().DeltaTime));
|
||||||
|
|
||||||
auto center = Lerp(min, max, 0.5f);
|
auto center = Lerp(min, max, 0.5f);
|
||||||
auto animCenter = Lerp(m_categoryAnimMin, m_categoryAnimMax, 0.5f);
|
auto animCenter = Lerp(g_categoryAnimMin, g_categoryAnimMax, 0.5f);
|
||||||
auto animatedCenter = Lerp(animCenter, center, 1.0f - exp(-16.0f * ImGui::GetIO().DeltaTime));
|
auto animatedCenter = Lerp(animCenter, center, 1.0f - exp(-16.0f * ImGui::GetIO().DeltaTime));
|
||||||
|
|
||||||
float widthHalfExtent = width / 2.0f;
|
float widthHalfExtent = width / 2.0f;
|
||||||
float heightHalfExtent = height / 2.0f;
|
float heightHalfExtent = height / 2.0f;
|
||||||
|
|
||||||
m_categoryAnimMin = { animatedCenter.x - widthHalfExtent, animatedCenter.y - heightHalfExtent };
|
g_categoryAnimMin = { animatedCenter.x - widthHalfExtent, animatedCenter.y - heightHalfExtent };
|
||||||
m_categoryAnimMax = { animatedCenter.x + widthHalfExtent, animatedCenter.y + heightHalfExtent };
|
g_categoryAnimMax = { animatedCenter.x + widthHalfExtent, animatedCenter.y + heightHalfExtent };
|
||||||
}
|
}
|
||||||
|
|
||||||
SetShaderModifier(IMGUI_SHADER_MODIFIER_SCANLINE_BUTTON);
|
SetShaderModifier(IMGUI_SHADER_MODIFIER_SCANLINE_BUTTON);
|
||||||
|
|
||||||
drawList->AddRectFilledMultiColor
|
drawList->AddRectFilledMultiColor
|
||||||
(
|
(
|
||||||
m_categoryAnimMin,
|
g_categoryAnimMin,
|
||||||
m_categoryAnimMax,
|
g_categoryAnimMax,
|
||||||
IM_COL32(0, 130, 0, 223 * motion),
|
IM_COL32(0, 130, 0, 223 * motion),
|
||||||
IM_COL32(0, 130, 0, 178 * motion),
|
IM_COL32(0, 130, 0, 178 * motion),
|
||||||
IM_COL32(0, 130, 0, 223 * motion),
|
IM_COL32(0, 130, 0, 223 * motion),
|
||||||
|
|
@ -342,8 +342,8 @@ static bool DrawCategories()
|
||||||
|
|
||||||
drawList->AddRectFilledMultiColor
|
drawList->AddRectFilledMultiColor
|
||||||
(
|
(
|
||||||
m_categoryAnimMin,
|
g_categoryAnimMin,
|
||||||
m_categoryAnimMax,
|
g_categoryAnimMax,
|
||||||
IM_COL32(0, 0, 0, 13 * motion),
|
IM_COL32(0, 0, 0, 13 * motion),
|
||||||
IM_COL32(0, 0, 0, 0),
|
IM_COL32(0, 0, 0, 0),
|
||||||
IM_COL32(0, 0, 0, 55 * motion),
|
IM_COL32(0, 0, 0, 55 * motion),
|
||||||
|
|
@ -352,8 +352,8 @@ static bool DrawCategories()
|
||||||
|
|
||||||
drawList->AddRectFilledMultiColor
|
drawList->AddRectFilledMultiColor
|
||||||
(
|
(
|
||||||
m_categoryAnimMin,
|
g_categoryAnimMin,
|
||||||
m_categoryAnimMax,
|
g_categoryAnimMax,
|
||||||
IM_COL32(0, 130, 0, 13 * motion),
|
IM_COL32(0, 130, 0, 13 * motion),
|
||||||
IM_COL32(0, 130, 0, 111 * motion),
|
IM_COL32(0, 130, 0, 111 * motion),
|
||||||
IM_COL32(0, 130, 0, 0),
|
IM_COL32(0, 130, 0, 0),
|
||||||
|
|
@ -369,10 +369,10 @@ static bool DrawCategories()
|
||||||
minVec[i] = min;
|
minVec[i] = min;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < m_categoryCount; i++)
|
for (size_t i = 0; i < g_categoryCount; i++)
|
||||||
{
|
{
|
||||||
auto& min = minVec[i];
|
auto& min = minVec[i];
|
||||||
uint8_t alpha = (i == m_categoryIndex ? 235 : 128) * motion;
|
uint8_t alpha = (i == g_categoryIndex ? 235 : 128) * motion;
|
||||||
|
|
||||||
SetGradient
|
SetGradient
|
||||||
(
|
(
|
||||||
|
|
@ -384,7 +384,7 @@ static bool DrawCategories()
|
||||||
|
|
||||||
DrawTextWithOutline<int>
|
DrawTextWithOutline<int>
|
||||||
(
|
(
|
||||||
m_dfsogeistdFont,
|
g_dfsogeistdFont,
|
||||||
size,
|
size,
|
||||||
min,
|
min,
|
||||||
IM_COL32_WHITE,
|
IM_COL32_WHITE,
|
||||||
|
|
@ -396,7 +396,7 @@ static bool DrawCategories()
|
||||||
ResetGradient();
|
ResetGradient();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ImGui::GetTime() - m_appearTime) >= (CONTAINER_FULL_DURATION / 60.0))
|
if ((ImGui::GetTime() - g_appearTime) >= (CONTAINER_FULL_DURATION / 60.0))
|
||||||
{
|
{
|
||||||
drawList->PushClipRect({ clipRectMin.x, clipRectMin.y + gridSize * 6.0f }, { clipRectMax.x - gridSize, clipRectMax.y - gridSize });
|
drawList->PushClipRect({ clipRectMin.x, clipRectMin.y + gridSize * 6.0f }, { clipRectMax.x - gridSize, clipRectMax.y - gridSize });
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -430,18 +430,18 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
||||||
|
|
||||||
auto configName = config->GetNameLocalised();
|
auto configName = config->GetNameLocalised();
|
||||||
auto size = Scale(26.0f);
|
auto size = Scale(26.0f);
|
||||||
auto textSize = m_seuratFont->CalcTextSizeA(size, FLT_MAX, 0.0f, configName.c_str());
|
auto textSize = g_seuratFont->CalcTextSizeA(size, FLT_MAX, 0.0f, configName.c_str());
|
||||||
|
|
||||||
ImVec2 textPos = { min.x + gridSize, min.y + (optionHeight - textSize.y) / 2.0f };
|
ImVec2 textPos = { min.x + gridSize, min.y + (optionHeight - textSize.y) / 2.0f };
|
||||||
ImVec4 textClipRect = { min.x, min.y, max.x, max.y };
|
ImVec4 textClipRect = { min.x, min.y, max.x, max.y };
|
||||||
|
|
||||||
bool lockedOnOption = false;
|
bool lockedOnOption = false;
|
||||||
if (m_selectedRowIndex == rowIndex)
|
if (g_selectedRowIndex == rowIndex)
|
||||||
{
|
{
|
||||||
m_selectedItem = config;
|
g_selectedItem = config;
|
||||||
m_inaccessibleReason = isAccessible ? nullptr : inaccessibleReason;
|
g_inaccessibleReason = isAccessible ? nullptr : inaccessibleReason;
|
||||||
|
|
||||||
if (!m_isEnterKeyBuffered)
|
if (!g_isEnterKeyBuffered)
|
||||||
{
|
{
|
||||||
if (isAccessible)
|
if (isAccessible)
|
||||||
{
|
{
|
||||||
|
|
@ -465,12 +465,12 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
||||||
|
|
||||||
if (padState.IsTapped(SWA::eKeyState_A))
|
if (padState.IsTapped(SWA::eKeyState_A))
|
||||||
{
|
{
|
||||||
m_lockedOnOption ^= true;
|
g_lockedOnOption ^= true;
|
||||||
|
|
||||||
if (m_lockedOnOption)
|
if (g_lockedOnOption)
|
||||||
{
|
{
|
||||||
m_leftWasHeld = false;
|
g_leftWasHeld = false;
|
||||||
m_rightWasHeld = false;
|
g_rightWasHeld = false;
|
||||||
// remember value
|
// remember value
|
||||||
s_oldValue = config->Value;
|
s_oldValue = config->Value;
|
||||||
|
|
||||||
|
|
@ -489,12 +489,12 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
||||||
{
|
{
|
||||||
// released lock, restore old value
|
// released lock, restore old value
|
||||||
config->Value = s_oldValue;
|
config->Value = s_oldValue;
|
||||||
m_lockedOnOption = false;
|
g_lockedOnOption = false;
|
||||||
|
|
||||||
Game_PlaySound("sys_worldmap_cansel");
|
Game_PlaySound("sys_worldmap_cansel");
|
||||||
}
|
}
|
||||||
|
|
||||||
lockedOnOption = m_lockedOnOption;
|
lockedOnOption = g_lockedOnOption;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -505,14 +505,14 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fadedOut = (m_lockedOnOption && m_selectedItem != config) || !isAccessible;
|
auto fadedOut = (g_lockedOnOption && g_selectedItem != config) || !isAccessible;
|
||||||
auto alpha = fadedOut ? 0.5f : 1.0f;
|
auto alpha = fadedOut ? 0.5f : 1.0f;
|
||||||
auto textColour = IM_COL32(255, 255, 255, 255 * alpha);
|
auto textColour = IM_COL32(255, 255, 255, 255 * alpha);
|
||||||
|
|
||||||
if (m_selectedItem == config)
|
if (g_selectedItem == config)
|
||||||
{
|
{
|
||||||
float prevItemOffset = (m_prevSelectedRowIndex - m_selectedRowIndex) * (optionHeight + optionPadding);
|
float prevItemOffset = (g_prevSelectedRowIndex - g_selectedRowIndex) * (optionHeight + optionPadding);
|
||||||
double animRatio = std::clamp((ImGui::GetTime() - m_rowSelectionTime) * 60.0 / 8.0, 0.0, 1.0);
|
double animRatio = std::clamp((ImGui::GetTime() - g_rowSelectionTime) * 60.0 / 8.0, 0.0, 1.0);
|
||||||
prevItemOffset *= pow(1.0 - animRatio, 3.0);
|
prevItemOffset *= pow(1.0 - animRatio, 3.0);
|
||||||
|
|
||||||
auto c0 = IM_COL32(0xE2, 0x71, 0x22, isAccessible ? 0x80 : 0x30);
|
auto c0 = IM_COL32(0xE2, 0x71, 0x22, isAccessible ? 0x80 : 0x30);
|
||||||
|
|
@ -520,11 +520,11 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
||||||
|
|
||||||
drawList->AddRectFilledMultiColor({ min.x, min.y + prevItemOffset }, { max.x, max.y + prevItemOffset }, c0, c0, c1, c1);
|
drawList->AddRectFilledMultiColor({ min.x, min.y + prevItemOffset }, { max.x, max.y + prevItemOffset }, c0, c0, c1, c1);
|
||||||
|
|
||||||
DrawTextWithMarquee(m_seuratFont, size, textPos, min, max, textColour, configName.c_str(), m_rowSelectionTime, 0.9, 250.0);
|
DrawTextWithMarquee(g_seuratFont, size, textPos, min, max, textColour, configName.c_str(), g_rowSelectionTime, 0.9, 250.0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
drawList->AddText(m_seuratFont, size, textPos, textColour, configName.c_str(), 0, 0.0f, &textClipRect);
|
drawList->AddText(g_seuratFont, size, textPos, textColour, configName.c_str(), 0, 0.0f, &textClipRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right side
|
// Right side
|
||||||
|
|
@ -605,18 +605,18 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
||||||
bool leftIsHeld = padState.IsDown(SWA::eKeyState_DpadLeft) || padState.LeftStickHorizontal < -0.5f;
|
bool leftIsHeld = padState.IsDown(SWA::eKeyState_DpadLeft) || padState.LeftStickHorizontal < -0.5f;
|
||||||
bool rightIsHeld = padState.IsDown(SWA::eKeyState_DpadRight) || padState.LeftStickHorizontal > 0.5f;
|
bool rightIsHeld = padState.IsDown(SWA::eKeyState_DpadRight) || padState.LeftStickHorizontal > 0.5f;
|
||||||
|
|
||||||
bool leftTapped = !m_leftWasHeld && leftIsHeld;
|
bool leftTapped = !g_leftWasHeld && leftIsHeld;
|
||||||
bool rightTapped = !m_rightWasHeld && rightIsHeld;
|
bool rightTapped = !g_rightWasHeld && rightIsHeld;
|
||||||
|
|
||||||
double time = ImGui::GetTime();
|
double time = ImGui::GetTime();
|
||||||
|
|
||||||
if (leftTapped || rightTapped)
|
if (leftTapped || rightTapped)
|
||||||
m_lastTappedTime = time;
|
g_lastTappedTime = time;
|
||||||
|
|
||||||
bool decrement = leftTapped;
|
bool decrement = leftTapped;
|
||||||
bool increment = rightTapped;
|
bool increment = rightTapped;
|
||||||
|
|
||||||
bool fastIncrement = (time - m_lastTappedTime) > 0.5;
|
bool fastIncrement = (time - g_lastTappedTime) > 0.5;
|
||||||
constexpr double INCREMENT_TIME = 1.0 / 120.0;
|
constexpr double INCREMENT_TIME = 1.0 / 120.0;
|
||||||
|
|
||||||
constexpr double INCREMENT_SOUND_TIME = 1.0 / 7.5;
|
constexpr double INCREMENT_SOUND_TIME = 1.0 / 7.5;
|
||||||
|
|
@ -624,12 +624,12 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
||||||
|
|
||||||
if (fastIncrement)
|
if (fastIncrement)
|
||||||
{
|
{
|
||||||
isPlayIncrementSound = (time - m_lastIncrementSoundTime) > INCREMENT_SOUND_TIME;
|
isPlayIncrementSound = (time - g_lastIncrementSoundTime) > INCREMENT_SOUND_TIME;
|
||||||
|
|
||||||
if ((time - m_lastIncrementTime) < INCREMENT_TIME)
|
if ((time - g_lastIncrementTime) < INCREMENT_TIME)
|
||||||
fastIncrement = false;
|
fastIncrement = false;
|
||||||
else
|
else
|
||||||
m_lastIncrementTime = time;
|
g_lastIncrementTime = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fastIncrement)
|
if (fastIncrement)
|
||||||
|
|
@ -638,8 +638,8 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
||||||
increment = rightIsHeld;
|
increment = rightIsHeld;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_leftWasHeld = leftIsHeld;
|
g_leftWasHeld = leftIsHeld;
|
||||||
m_rightWasHeld = rightIsHeld;
|
g_rightWasHeld = rightIsHeld;
|
||||||
|
|
||||||
if constexpr (std::is_enum_v<T>)
|
if constexpr (std::is_enum_v<T>)
|
||||||
{
|
{
|
||||||
|
|
@ -694,7 +694,7 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
||||||
|
|
||||||
if ((increment || decrement) && isConfigValueInBounds && isPlayIncrementSound)
|
if ((increment || decrement) && isConfigValueInBounds && isPlayIncrementSound)
|
||||||
{
|
{
|
||||||
m_lastIncrementSoundTime = time;
|
g_lastIncrementSoundTime = time;
|
||||||
Game_PlaySound("sys_actstg_twn_speechbutton");
|
Game_PlaySound("sys_actstg_twn_speechbutton");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -720,7 +720,7 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
||||||
}
|
}
|
||||||
|
|
||||||
size = Scale(20.0f);
|
size = Scale(20.0f);
|
||||||
textSize = m_newRodinFont->CalcTextSizeA(size, FLT_MAX, 0.0f, valueText.data());
|
textSize = g_newRodinFont->CalcTextSizeA(size, FLT_MAX, 0.0f, valueText.data());
|
||||||
|
|
||||||
min.x += ((max.x - min.x) - textSize.x) / 2.0f;
|
min.x += ((max.x - min.x) - textSize.x) / 2.0f;
|
||||||
min.y += ((max.y - min.y) - textSize.y) / 2.0f;
|
min.y += ((max.y - min.y) - textSize.y) / 2.0f;
|
||||||
|
|
@ -735,7 +735,7 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
||||||
|
|
||||||
DrawTextWithOutline<int>
|
DrawTextWithOutline<int>
|
||||||
(
|
(
|
||||||
m_newRodinFont,
|
g_newRodinFont,
|
||||||
size,
|
size,
|
||||||
min,
|
min,
|
||||||
IM_COL32(255, 255, 255, 255 * alpha),
|
IM_COL32(255, 255, 255, 255 * alpha),
|
||||||
|
|
@ -753,11 +753,11 @@ static void DrawConfigOptions()
|
||||||
auto clipRectMin = drawList->GetClipRectMin();
|
auto clipRectMin = drawList->GetClipRectMin();
|
||||||
auto clipRectMax = drawList->GetClipRectMax();
|
auto clipRectMax = drawList->GetClipRectMax();
|
||||||
|
|
||||||
m_selectedItem = nullptr;
|
g_selectedItem = nullptr;
|
||||||
|
|
||||||
float gridSize = Scale(GRID_SIZE);
|
float gridSize = Scale(GRID_SIZE);
|
||||||
float optionHeightWithPadding = gridSize * 6.0f;
|
float optionHeightWithPadding = gridSize * 6.0f;
|
||||||
float yOffset = -m_firstVisibleRowIndex * optionHeightWithPadding;
|
float yOffset = -g_firstVisibleRowIndex * optionHeightWithPadding;
|
||||||
|
|
||||||
int32_t rowCount = 0;
|
int32_t rowCount = 0;
|
||||||
|
|
||||||
|
|
@ -765,7 +765,7 @@ static void DrawConfigOptions()
|
||||||
auto cmnReason = &Localise("Options_Desc_NotAvailable");
|
auto cmnReason = &Localise("Options_Desc_NotAvailable");
|
||||||
|
|
||||||
// TODO: Don't use raw numbers here!
|
// TODO: Don't use raw numbers here!
|
||||||
switch (m_categoryIndex)
|
switch (g_categoryIndex)
|
||||||
{
|
{
|
||||||
case 0: // SYSTEM
|
case 0: // SYSTEM
|
||||||
DrawConfigOption(rowCount++, yOffset, &Config::Language, !OptionsMenu::s_isPause, cmnReason);
|
DrawConfigOption(rowCount++, yOffset, &Config::Language, !OptionsMenu::s_isPause, cmnReason);
|
||||||
|
|
@ -813,58 +813,58 @@ static void DrawConfigOptions()
|
||||||
|
|
||||||
auto inputState = SWA::CInputState::GetInstance();
|
auto inputState = SWA::CInputState::GetInstance();
|
||||||
|
|
||||||
bool upIsHeld = !m_lockedOnOption && (inputState->GetPadState().IsDown(SWA::eKeyState_DpadUp) ||
|
bool upIsHeld = !g_lockedOnOption && (inputState->GetPadState().IsDown(SWA::eKeyState_DpadUp) ||
|
||||||
inputState->GetPadState().LeftStickVertical > 0.5f);
|
inputState->GetPadState().LeftStickVertical > 0.5f);
|
||||||
|
|
||||||
bool downIsHeld = !m_lockedOnOption && (inputState->GetPadState().IsDown(SWA::eKeyState_DpadDown) ||
|
bool downIsHeld = !g_lockedOnOption && (inputState->GetPadState().IsDown(SWA::eKeyState_DpadDown) ||
|
||||||
inputState->GetPadState().LeftStickVertical < -0.5f);
|
inputState->GetPadState().LeftStickVertical < -0.5f);
|
||||||
|
|
||||||
bool scrollUp = !m_upWasHeld && upIsHeld;
|
bool scrollUp = !g_upWasHeld && upIsHeld;
|
||||||
bool scrollDown = !m_downWasHeld && downIsHeld;
|
bool scrollDown = !g_downWasHeld && downIsHeld;
|
||||||
|
|
||||||
int32_t prevSelectedRowIndex = m_selectedRowIndex;
|
int32_t prevSelectedRowIndex = g_selectedRowIndex;
|
||||||
|
|
||||||
if (scrollUp)
|
if (scrollUp)
|
||||||
{
|
{
|
||||||
--m_selectedRowIndex;
|
--g_selectedRowIndex;
|
||||||
if (m_selectedRowIndex < 0)
|
if (g_selectedRowIndex < 0)
|
||||||
m_selectedRowIndex = rowCount - 1;
|
g_selectedRowIndex = rowCount - 1;
|
||||||
}
|
}
|
||||||
else if (scrollDown)
|
else if (scrollDown)
|
||||||
{
|
{
|
||||||
++m_selectedRowIndex;
|
++g_selectedRowIndex;
|
||||||
if (m_selectedRowIndex >= rowCount)
|
if (g_selectedRowIndex >= rowCount)
|
||||||
m_selectedRowIndex = 0;
|
g_selectedRowIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrollUp || scrollDown)
|
if (scrollUp || scrollDown)
|
||||||
{
|
{
|
||||||
m_rowSelectionTime = ImGui::GetTime();
|
g_rowSelectionTime = ImGui::GetTime();
|
||||||
m_prevSelectedRowIndex = prevSelectedRowIndex;
|
g_prevSelectedRowIndex = prevSelectedRowIndex;
|
||||||
Game_PlaySound("sys_worldmap_cursor");
|
Game_PlaySound("sys_worldmap_cursor");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_upWasHeld = upIsHeld;
|
g_upWasHeld = upIsHeld;
|
||||||
m_downWasHeld = downIsHeld;
|
g_downWasHeld = downIsHeld;
|
||||||
|
|
||||||
int32_t visibleRowCount = int32_t(floor((clipRectMax.y - clipRectMin.y) / optionHeightWithPadding));
|
int32_t visibleRowCount = int32_t(floor((clipRectMax.y - clipRectMin.y) / optionHeightWithPadding));
|
||||||
|
|
||||||
bool disableMoveAnimation = false;
|
bool disableMoveAnimation = false;
|
||||||
|
|
||||||
if (m_firstVisibleRowIndex > m_selectedRowIndex)
|
if (g_firstVisibleRowIndex > g_selectedRowIndex)
|
||||||
{
|
{
|
||||||
m_firstVisibleRowIndex = m_selectedRowIndex;
|
g_firstVisibleRowIndex = g_selectedRowIndex;
|
||||||
disableMoveAnimation = true;
|
disableMoveAnimation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_firstVisibleRowIndex + visibleRowCount - 1 < m_selectedRowIndex)
|
if (g_firstVisibleRowIndex + visibleRowCount - 1 < g_selectedRowIndex)
|
||||||
{
|
{
|
||||||
m_firstVisibleRowIndex = std::max(0, m_selectedRowIndex - visibleRowCount + 1);
|
g_firstVisibleRowIndex = std::max(0, g_selectedRowIndex - visibleRowCount + 1);
|
||||||
disableMoveAnimation = true;
|
disableMoveAnimation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disableMoveAnimation)
|
if (disableMoveAnimation)
|
||||||
m_prevSelectedRowIndex = m_selectedRowIndex;
|
g_prevSelectedRowIndex = g_selectedRowIndex;
|
||||||
|
|
||||||
// Pop clip rect from DrawCategories
|
// Pop clip rect from DrawCategories
|
||||||
drawList->PopClipRect();
|
drawList->PopClipRect();
|
||||||
|
|
@ -874,7 +874,7 @@ static void DrawConfigOptions()
|
||||||
{
|
{
|
||||||
float totalHeight = (clipRectMax.y - clipRectMin.y);
|
float totalHeight = (clipRectMax.y - clipRectMin.y);
|
||||||
float heightRatio = float(visibleRowCount) / float(rowCount);
|
float heightRatio = float(visibleRowCount) / float(rowCount);
|
||||||
float offsetRatio = float(m_firstVisibleRowIndex) / float(rowCount);
|
float offsetRatio = float(g_firstVisibleRowIndex) / float(rowCount);
|
||||||
float minY = offsetRatio * totalHeight + clipRectMin.y;
|
float minY = offsetRatio * totalHeight + clipRectMin.y;
|
||||||
|
|
||||||
drawList->AddRectFilled
|
drawList->AddRectFilled
|
||||||
|
|
@ -925,21 +925,21 @@ static void DrawInfoPanel()
|
||||||
// Thumbnail box
|
// Thumbnail box
|
||||||
drawList->AddRectFilled(clipRectMin, thumbnailMax, IM_COL32(0, 0, 0, 255));
|
drawList->AddRectFilled(clipRectMin, thumbnailMax, IM_COL32(0, 0, 0, 255));
|
||||||
|
|
||||||
if (m_selectedItem)
|
if (g_selectedItem)
|
||||||
{
|
{
|
||||||
auto desc = m_selectedItem->GetDescription();
|
auto desc = g_selectedItem->GetDescription();
|
||||||
|
|
||||||
if (m_inaccessibleReason)
|
if (g_inaccessibleReason)
|
||||||
{
|
{
|
||||||
desc = *m_inaccessibleReason;
|
desc = *g_inaccessibleReason;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Specialised description for resolution scale
|
// Specialised description for resolution scale
|
||||||
if (m_selectedItem->GetName() == "ResolutionScale")
|
if (g_selectedItem->GetName() == "ResolutionScale")
|
||||||
{
|
{
|
||||||
char buf[100];
|
char buf[100];
|
||||||
auto resScale = round(*(float*)m_selectedItem->GetValue() * 1000) / 1000;
|
auto resScale = round(*(float*)g_selectedItem->GetValue() * 1000) / 1000;
|
||||||
|
|
||||||
std::snprintf(buf, sizeof(buf), desc.c_str(),
|
std::snprintf(buf, sizeof(buf), desc.c_str(),
|
||||||
(int)((float)Window::s_width * resScale),
|
(int)((float)Window::s_width * resScale),
|
||||||
|
|
@ -948,14 +948,14 @@ static void DrawInfoPanel()
|
||||||
desc = buf;
|
desc = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
desc += "\n\n" + m_selectedItem->GetValueDescription();
|
desc += "\n\n" + g_selectedItem->GetValueDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto size = Scale(26.0f);
|
auto size = Scale(26.0f);
|
||||||
|
|
||||||
drawList->AddText
|
drawList->AddText
|
||||||
(
|
(
|
||||||
m_seuratFont,
|
g_seuratFont,
|
||||||
size,
|
size,
|
||||||
{ clipRectMin.x, thumbnailMax.y + size - 5.0f },
|
{ clipRectMin.x, thumbnailMax.y + size - 5.0f },
|
||||||
IM_COL32_WHITE,
|
IM_COL32_WHITE,
|
||||||
|
|
@ -975,9 +975,9 @@ void OptionsMenu::Init()
|
||||||
|
|
||||||
constexpr float FONT_SCALE = 2.0f;
|
constexpr float FONT_SCALE = 2.0f;
|
||||||
|
|
||||||
m_seuratFont = io.Fonts->AddFontFromFileTTF("FOT-SeuratPro-M.otf", 26.0f * FONT_SCALE);
|
g_seuratFont = io.Fonts->AddFontFromFileTTF("FOT-SeuratPro-M.otf", 26.0f * FONT_SCALE);
|
||||||
m_dfsogeistdFont = io.Fonts->AddFontFromFileTTF("DFSoGeiStd-W7.otf", 48.0f * FONT_SCALE);
|
g_dfsogeistdFont = io.Fonts->AddFontFromFileTTF("DFSoGeiStd-W7.otf", 48.0f * FONT_SCALE);
|
||||||
m_newRodinFont = io.Fonts->AddFontFromFileTTF("FOT-NewRodinPro-DB.otf", 20.0f * FONT_SCALE);
|
g_newRodinFont = io.Fonts->AddFontFromFileTTF("FOT-NewRodinPro-DB.otf", 20.0f * FONT_SCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsMenu::Draw()
|
void OptionsMenu::Draw()
|
||||||
|
|
@ -989,7 +989,7 @@ void OptionsMenu::Draw()
|
||||||
|
|
||||||
// We've entered the menu now, no need to check this.
|
// We've entered the menu now, no need to check this.
|
||||||
if (pInputState->GetPadState().IsReleased(SWA::eKeyState_A))
|
if (pInputState->GetPadState().IsReleased(SWA::eKeyState_A))
|
||||||
m_isEnterKeyBuffered = false;
|
g_isEnterKeyBuffered = false;
|
||||||
|
|
||||||
g_callbackDataIndex = 0;
|
g_callbackDataIndex = 0;
|
||||||
|
|
||||||
|
|
@ -1011,16 +1011,16 @@ void OptionsMenu::Open(bool isPause, SWA::EMenuType pauseMenuType)
|
||||||
|
|
||||||
s_pauseMenuType = pauseMenuType;
|
s_pauseMenuType = pauseMenuType;
|
||||||
|
|
||||||
m_appearTime = ImGui::GetTime();
|
g_appearTime = ImGui::GetTime();
|
||||||
m_categoryIndex = 0;
|
g_categoryIndex = 0;
|
||||||
m_categoryAnimMin = { 0.0f, 0.0f };
|
g_categoryAnimMin = { 0.0f, 0.0f };
|
||||||
m_categoryAnimMax = { 0.0f, 0.0f };
|
g_categoryAnimMax = { 0.0f, 0.0f };
|
||||||
m_selectedItem = nullptr;
|
g_selectedItem = nullptr;
|
||||||
|
|
||||||
/* Store button state so we can track it later
|
/* Store button state so we can track it later
|
||||||
and prevent the first item being selected. */
|
and prevent the first item being selected. */
|
||||||
if (SWA::CInputState::GetInstance()->GetPadState().IsDown(SWA::eKeyState_A))
|
if (SWA::CInputState::GetInstance()->GetPadState().IsDown(SWA::eKeyState_A))
|
||||||
m_isEnterKeyBuffered = true;
|
g_isEnterKeyBuffered = true;
|
||||||
|
|
||||||
ResetSelection();
|
ResetSelection();
|
||||||
|
|
||||||
|
|
@ -1042,5 +1042,5 @@ void OptionsMenu::Close()
|
||||||
|
|
||||||
bool OptionsMenu::CanClose()
|
bool OptionsMenu::CanClose()
|
||||||
{
|
{
|
||||||
return !m_lockedOnOption;
|
return !g_lockedOnOption;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue