mirror of
https://github.com/hedge-dev/UnleashedRecomp
synced 2026-09-03 18:43:35 -04:00
Redirected Install button to custom implementation
This currently fades out and closes the game upon accepting the message, it does not yet reboot into the installer menu using --install-dlc.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
#include "fader.h"
|
||||
#include "imgui_utils.h"
|
||||
#include <user/config.h>
|
||||
|
||||
static bool g_isFadeIn;
|
||||
|
||||
static float g_startTime;
|
||||
|
||||
static float g_duration;
|
||||
static ImU32 g_colour = IM_COL32(0, 0, 0, 255);
|
||||
static std::function<void()> g_endCallback;
|
||||
static float g_endCallbackDelay;
|
||||
|
||||
void Fader::Draw()
|
||||
{
|
||||
if (!s_isVisible)
|
||||
return;
|
||||
|
||||
auto time = (ImGui::GetTime() - g_startTime) / g_duration;
|
||||
auto alpha = 1.0f;
|
||||
|
||||
if (time >= g_duration)
|
||||
{
|
||||
if (g_endCallback && time >= g_duration + g_endCallbackDelay)
|
||||
g_endCallback();
|
||||
}
|
||||
else
|
||||
{
|
||||
alpha = g_isFadeIn
|
||||
? Lerp(1, 0, time)
|
||||
: Lerp(0, 1, time);
|
||||
}
|
||||
|
||||
auto colour = IM_COL32(g_colour & 0xFF, (g_colour >> 8) & 0xFF, (g_colour >> 16) & 0xFF, 255 * alpha);
|
||||
|
||||
ImGui::GetForegroundDrawList()->AddRectFilled({ 0, 0 }, ImGui::GetIO().DisplaySize, colour);
|
||||
}
|
||||
|
||||
static void DoFade(float duration, std::function<void()> endCallback, float endCallbackDelay)
|
||||
{
|
||||
Fader::s_isVisible = true;
|
||||
g_startTime = ImGui::GetTime();
|
||||
g_duration = duration;
|
||||
g_endCallback = endCallback;
|
||||
g_endCallbackDelay = endCallbackDelay;
|
||||
}
|
||||
|
||||
void Fader::SetFadeColour(ImU32 colour)
|
||||
{
|
||||
g_colour = colour;
|
||||
}
|
||||
|
||||
void Fader::FadeIn(float duration, std::function<void()> endCallback, float endCallbackDelay)
|
||||
{
|
||||
g_isFadeIn = true;
|
||||
DoFade(duration, endCallback, endCallbackDelay);
|
||||
}
|
||||
|
||||
void Fader::FadeOut(float duration, std::function<void()> endCallback, float endCallbackDelay)
|
||||
{
|
||||
g_isFadeIn = false;
|
||||
DoFade(duration, endCallback, endCallbackDelay);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
class Fader
|
||||
{
|
||||
public:
|
||||
inline static bool s_isVisible = false;
|
||||
|
||||
static void Draw();
|
||||
static void SetFadeColour(ImU32 colour);
|
||||
static void FadeIn(float duration = 1, std::function<void()> endCallback = nullptr, float endCallbackDelay = 0.75f);
|
||||
static void FadeOut(float duration = 1, std::function<void()> endCallback = nullptr, float endCallbackDelay = 0.75f);
|
||||
};
|
||||
@@ -1315,7 +1315,7 @@ static void DrawMessagePrompt()
|
||||
bool messageWindowReturned = false;
|
||||
if (g_currentMessagePromptConfirmation)
|
||||
{
|
||||
std::array<std::string, 2> YesNoButtons = { "Yes", "No" };
|
||||
std::array<std::string, 2> YesNoButtons = { Localise("Common_Yes"), Localise("Common_No") };
|
||||
messageWindowReturned = MessageWindow::Open(g_currentMessagePrompt, &g_currentMessageResult, YesNoButtons, 1);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -65,6 +65,9 @@ public:
|
||||
{
|
||||
case SDL_KEYDOWN:
|
||||
{
|
||||
if (g_isAppInit)
|
||||
break;
|
||||
|
||||
switch (event->key.keysym.scancode)
|
||||
{
|
||||
case SDL_SCANCODE_UP:
|
||||
@@ -89,8 +92,14 @@ public:
|
||||
}
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
{
|
||||
if (g_isAppInit)
|
||||
break;
|
||||
|
||||
g_isAccepted = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_CONTROLLERBUTTONDOWN:
|
||||
{
|
||||
@@ -177,7 +186,7 @@ bool DrawContainer(float appearTime, ImVec2 centre, ImVec2 max, bool isForegroun
|
||||
g_foregroundCount++;
|
||||
|
||||
if (isForeground)
|
||||
drawList->AddRectFilled({ 0.0f, 0.0f }, ImGui::GetIO().DisplaySize, IM_COL32(0, 0, 0, 223 * (g_foregroundCount ? 1 : alpha)));
|
||||
drawList->AddRectFilled({ 0.0f, 0.0f }, ImGui::GetIO().DisplaySize, IM_COL32(0, 0, 0, 190 * (g_foregroundCount ? 1 : alpha)));
|
||||
|
||||
DrawPauseContainer(g_upWindow.get(), _min, _max, alpha);
|
||||
|
||||
@@ -264,8 +273,8 @@ void MessageWindow::Draw()
|
||||
auto textMarginX = Scale(37);
|
||||
auto textMarginY = Scale(45);
|
||||
|
||||
bool isController = hid::detail::g_inputDevice == hid::detail::EInputDevice::Controller;
|
||||
bool isKeyboard = hid::detail::g_inputDevice == hid::detail::EInputDevice::Keyboard;
|
||||
bool isController = g_isAppInit ? true : hid::detail::g_inputDevice == hid::detail::EInputDevice::Controller;
|
||||
bool isKeyboard = g_isAppInit ? false : hid::detail::g_inputDevice == hid::detail::EInputDevice::Keyboard;
|
||||
|
||||
if (DrawContainer(g_appearTime, centre, { textSize.x / 2 + textMarginX, textSize.y / 2 + textMarginY }, !g_isControlsVisible))
|
||||
{
|
||||
@@ -328,14 +337,6 @@ void MessageWindow::Draw()
|
||||
g_upWasHeld = upIsHeld;
|
||||
g_downWasHeld = downIsHeld;
|
||||
|
||||
if (g_isDeclined)
|
||||
{
|
||||
g_result = g_cancelButtonIndex;
|
||||
|
||||
Game_PlaySound("sys_actstg_pausecansel");
|
||||
MessageWindow::Close();
|
||||
}
|
||||
|
||||
if (isController)
|
||||
{
|
||||
std::array<Button, 2> buttons =
|
||||
@@ -350,6 +351,14 @@ void MessageWindow::Draw()
|
||||
{
|
||||
ButtonGuide::Open(Button(Localise("Common_Select"), EButtonIcon::Enter));
|
||||
}
|
||||
|
||||
if (g_isDeclined)
|
||||
{
|
||||
g_result = g_cancelButtonIndex;
|
||||
|
||||
Game_PlaySound("sys_actstg_pausecansel");
|
||||
MessageWindow::Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -441,6 +450,7 @@ bool MessageWindow::Open(std::string text, int* result, std::span<std::string> b
|
||||
|
||||
*result = g_result;
|
||||
|
||||
// Returns true when the message window is closed.
|
||||
return !g_isAwaitingResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#define MSG_OPEN (false)
|
||||
#define MSG_CLOSED (true)
|
||||
|
||||
class MessageWindow
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user