mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-26 12:21:39 +00:00
CTitleStateMenu: implemented rebooting into installer
This commit is contained in:
parent
fc9c7ffb3a
commit
d69f0442a7
16 changed files with 123 additions and 25 deletions
|
|
@ -67,6 +67,11 @@ set(SWA_KERNEL_CXX_SOURCES
|
||||||
"kernel/io/file_system.cpp"
|
"kernel/io/file_system.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(SWA_OS_CXX_SOURCES
|
||||||
|
"os/win32/process_win32.cpp"
|
||||||
|
"os/process.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
set(SWA_CPU_CXX_SOURCES
|
set(SWA_CPU_CXX_SOURCES
|
||||||
"cpu/guest_thread.cpp"
|
"cpu/guest_thread.cpp"
|
||||||
"cpu/code_cache.cpp"
|
"cpu/code_cache.cpp"
|
||||||
|
|
@ -163,6 +168,7 @@ set(SWA_CXX_SOURCES
|
||||||
"stdafx.cpp"
|
"stdafx.cpp"
|
||||||
|
|
||||||
${SWA_KERNEL_CXX_SOURCES}
|
${SWA_KERNEL_CXX_SOURCES}
|
||||||
|
${SWA_OS_CXX_SOURCES}
|
||||||
${SWA_CPU_CXX_SOURCES}
|
${SWA_CPU_CXX_SOURCES}
|
||||||
${SWA_GPU_CXX_SOURCES}
|
${SWA_GPU_CXX_SOURCES}
|
||||||
${SWA_APU_CXX_SOURCES}
|
${SWA_APU_CXX_SOURCES}
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,24 @@
|
||||||
#include <kernel/function.h>
|
#include <kernel/function.h>
|
||||||
#include <ui/window.h>
|
#include <ui/window.h>
|
||||||
#include <patches/audio_patches.h>
|
#include <patches/audio_patches.h>
|
||||||
|
#include <os/process.h>
|
||||||
|
|
||||||
bool g_isAppInit = false;
|
void App::Exit(std::vector<std::string> restartArgs)
|
||||||
bool g_isMissingDLC = false;
|
{
|
||||||
|
if (restartArgs.size())
|
||||||
|
os::process::StartProcess(os::process::GetExecutablePath(), restartArgs, os::process::GetWorkingDirectory());
|
||||||
|
|
||||||
double g_deltaTime;
|
#if _WIN32
|
||||||
|
ExitProcess(0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// CApplication::Ctor
|
// CApplication::Ctor
|
||||||
PPC_FUNC_IMPL(__imp__sub_824EB490);
|
PPC_FUNC_IMPL(__imp__sub_824EB490);
|
||||||
PPC_FUNC(sub_824EB490)
|
PPC_FUNC(sub_824EB490)
|
||||||
{
|
{
|
||||||
g_isAppInit = true;
|
App::s_isInit = true;
|
||||||
g_isMissingDLC = !Installer::checkAllDLC(GetGamePath());
|
App::s_isMissingDLC = !Installer::checkAllDLC(GetGamePath());
|
||||||
|
|
||||||
__imp__sub_824EB490(ctx, base);
|
__imp__sub_824EB490(ctx, base);
|
||||||
}
|
}
|
||||||
|
|
@ -23,13 +29,13 @@ PPC_FUNC(sub_824EB490)
|
||||||
PPC_FUNC_IMPL(__imp__sub_822C1130);
|
PPC_FUNC_IMPL(__imp__sub_822C1130);
|
||||||
PPC_FUNC(sub_822C1130)
|
PPC_FUNC(sub_822C1130)
|
||||||
{
|
{
|
||||||
g_deltaTime = ctx.f1.f64;
|
App::s_deltaTime = ctx.f1.f64;
|
||||||
|
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
|
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
|
||||||
|
|
||||||
Window::Update();
|
Window::Update();
|
||||||
AudioPatches::Update(g_deltaTime);
|
AudioPatches::Update(App::s_deltaTime);
|
||||||
|
|
||||||
__imp__sub_822C1130(ctx, base);
|
__imp__sub_822C1130(ctx, base);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
extern bool g_isAppInit;
|
class App
|
||||||
extern bool g_isMissingDLC;
|
{
|
||||||
|
public:
|
||||||
|
inline static bool s_isInit;
|
||||||
|
inline static bool s_isMissingDLC;
|
||||||
|
|
||||||
extern double g_deltaTime;
|
inline static double s_deltaTime;
|
||||||
|
|
||||||
|
static void Exit(std::vector<std::string> restartArgs = {});
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ void ImFontAtlasSnapshot::GenerateGlyphRanges()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_isAppInit)
|
if (App::s_isInit)
|
||||||
{
|
{
|
||||||
for (size_t i = XDBF_LANGUAGE_ENGLISH; i <= XDBF_LANGUAGE_ITALIAN; i++)
|
for (size_t i = XDBF_LANGUAGE_ENGLISH; i <= XDBF_LANGUAGE_ITALIAN; i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
1
UnleashedRecomp/os/.gitignore
vendored
Normal file
1
UnleashedRecomp/os/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
![Ww][Ii][Nn]32/
|
||||||
17
UnleashedRecomp/os/process.cpp
Normal file
17
UnleashedRecomp/os/process.cpp
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include "process.h"
|
||||||
|
#include "process_detail.h"
|
||||||
|
|
||||||
|
std::filesystem::path os::process::GetExecutablePath()
|
||||||
|
{
|
||||||
|
return detail::GetExecutablePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::path os::process::GetWorkingDirectory()
|
||||||
|
{
|
||||||
|
return detail::GetWorkingDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool os::process::StartProcess(const std::filesystem::path path, const std::vector<std::string> args, std::filesystem::path work)
|
||||||
|
{
|
||||||
|
return detail::StartProcess(path, args, work);
|
||||||
|
}
|
||||||
8
UnleashedRecomp/os/process.h
Normal file
8
UnleashedRecomp/os/process.h
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace os::process
|
||||||
|
{
|
||||||
|
std::filesystem::path GetExecutablePath();
|
||||||
|
std::filesystem::path GetWorkingDirectory();
|
||||||
|
bool StartProcess(const std::filesystem::path path, const std::vector<std::string> args, std::filesystem::path work = {});
|
||||||
|
}
|
||||||
8
UnleashedRecomp/os/process_detail.h
Normal file
8
UnleashedRecomp/os/process_detail.h
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace os::process::detail
|
||||||
|
{
|
||||||
|
std::filesystem::path GetExecutablePath();
|
||||||
|
std::filesystem::path GetWorkingDirectory();
|
||||||
|
bool StartProcess(const std::filesystem::path path, const std::vector<std::string> args, std::filesystem::path work = {});
|
||||||
|
}
|
||||||
45
UnleashedRecomp/os/win32/process_win32.cpp
Normal file
45
UnleashedRecomp/os/win32/process_win32.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
#include <os/process_detail.h>
|
||||||
|
|
||||||
|
std::filesystem::path os::process::detail::GetExecutablePath()
|
||||||
|
{
|
||||||
|
char exePath[MAX_PATH];
|
||||||
|
|
||||||
|
if (!GetModuleFileNameA(nullptr, exePath, MAX_PATH))
|
||||||
|
return std::filesystem::path();
|
||||||
|
|
||||||
|
return std::filesystem::path(exePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::path os::process::detail::GetWorkingDirectory()
|
||||||
|
{
|
||||||
|
char workPath[MAX_PATH];
|
||||||
|
|
||||||
|
if (!GetCurrentDirectoryA(MAX_PATH, workPath))
|
||||||
|
return std::filesystem::path();
|
||||||
|
|
||||||
|
return std::filesystem::path(workPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool os::process::detail::StartProcess(const std::filesystem::path path, const std::vector<std::string> args, std::filesystem::path work)
|
||||||
|
{
|
||||||
|
if (path.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (work.empty())
|
||||||
|
work = path.parent_path();
|
||||||
|
|
||||||
|
auto cli = path.string();
|
||||||
|
for (auto& arg : args)
|
||||||
|
cli += " " + arg;
|
||||||
|
|
||||||
|
STARTUPINFOA startInfo{ sizeof(STARTUPINFOA) };
|
||||||
|
PROCESS_INFORMATION procInfo{};
|
||||||
|
|
||||||
|
if (!CreateProcessA(path.string().c_str(), cli.data(), nullptr, nullptr, false, 0, nullptr, work.string().c_str(), &startInfo, &procInfo))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CloseHandle(procInfo.hProcess);
|
||||||
|
CloseHandle(procInfo.hThread);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
@ -41,12 +41,12 @@ static double ComputeLerpFactor(double t, double deltaTime)
|
||||||
// delta time, as it might be time scaled and not match with 30 FPS behavior.
|
// delta time, as it might be time scaled and not match with 30 FPS behavior.
|
||||||
void CameraLerpFixMidAsmHook(PPCRegister& t)
|
void CameraLerpFixMidAsmHook(PPCRegister& t)
|
||||||
{
|
{
|
||||||
t.f64 = ComputeLerpFactor(t.f64, g_deltaTime);
|
t.f64 = ComputeLerpFactor(t.f64, App::s_deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraTargetSideOffsetLerpFixMidAsmHook(PPCVRegister& v13, PPCVRegister& v62)
|
void CameraTargetSideOffsetLerpFixMidAsmHook(PPCVRegister& v13, PPCVRegister& v62)
|
||||||
{
|
{
|
||||||
float factor = float(ComputeLerpFactor(double(v13.f32[0] * v62.f32[0]), g_deltaTime));
|
float factor = float(ComputeLerpFactor(double(v13.f32[0] * v62.f32[0]), App::s_deltaTime));
|
||||||
|
|
||||||
for (size_t i = 0; i < 4; i++)
|
for (size_t i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -117,11 +117,11 @@ PPC_FUNC(sub_824B0930)
|
||||||
auto pHudPause = (SWA::CHudPause*)g_memory.Translate(ctx.r3.u32);
|
auto pHudPause = (SWA::CHudPause*)g_memory.Translate(ctx.r3.u32);
|
||||||
auto pInputState = SWA::CInputState::GetInstance();
|
auto pInputState = SWA::CInputState::GetInstance();
|
||||||
|
|
||||||
g_achievementMenuIntroTime += g_deltaTime;
|
g_achievementMenuIntroTime += App::s_deltaTime;
|
||||||
|
|
||||||
if (g_isAchievementMenuOutro)
|
if (g_isAchievementMenuOutro)
|
||||||
{
|
{
|
||||||
g_achievementMenuOutroTime += g_deltaTime;
|
g_achievementMenuOutroTime += App::s_deltaTime;
|
||||||
|
|
||||||
// Re-open pause menu after achievement menu closes with delay.
|
// Re-open pause menu after achievement menu closes with delay.
|
||||||
if (g_achievementMenuOutroTime >= g_achievementMenuOutroThreshold)
|
if (g_achievementMenuOutroTime >= g_achievementMenuOutroThreshold)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include <locale/locale.h>
|
#include <locale/locale.h>
|
||||||
#include <ui/fader.h>
|
#include <ui/fader.h>
|
||||||
#include <ui/message_window.h>
|
#include <ui/message_window.h>
|
||||||
|
#include <app.h>
|
||||||
|
|
||||||
static bool g_quitMessageOpen = false;
|
static bool g_quitMessageOpen = false;
|
||||||
static bool g_quitMessageFaderBegun = false;
|
static bool g_quitMessageFaderBegun = false;
|
||||||
|
|
@ -23,7 +24,7 @@ static bool ProcessQuitMessage()
|
||||||
switch (g_quitMessageResult)
|
switch (g_quitMessageResult)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
Fader::FadeOut(1, []() { ExitProcess(0); });
|
Fader::FadeOut(1, []() { App::Exit(); });
|
||||||
g_quitMessageFaderBegun = true;
|
g_quitMessageFaderBegun = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ static bool ProcessInstallMessage()
|
||||||
if (g_installMessageFaderBegun)
|
if (g_installMessageFaderBegun)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
auto& str = g_isMissingDLC
|
auto& str = App::s_isMissingDLC
|
||||||
? Localise("Installer_Message_TitleMissingDLC")
|
? Localise("Installer_Message_TitleMissingDLC")
|
||||||
: Localise("Installer_Message_Title");
|
: Localise("Installer_Message_Title");
|
||||||
|
|
||||||
|
|
@ -31,8 +31,7 @@ static bool ProcessInstallMessage()
|
||||||
switch (g_installMessageResult)
|
switch (g_installMessageResult)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
// TODO: replace ExitProcess with restart method using --install-dlc argument.
|
Fader::FadeOut(1, []() { App::Exit({ "--install-dlc" }); });
|
||||||
Fader::FadeOut(1, []() { ExitProcess(0); });
|
|
||||||
g_installMessageFaderBegun = true;
|
g_installMessageFaderBegun = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ std::tuple<std::tuple<ImVec2, ImVec2>, GuestTexture*> GetButtonIcon(EButtonIcon
|
||||||
std::tuple<ImVec2, ImVec2> btn;
|
std::tuple<ImVec2, ImVec2> btn;
|
||||||
GuestTexture* texture;
|
GuestTexture* texture;
|
||||||
|
|
||||||
auto isPlayStation = g_isAppInit
|
auto isPlayStation = App::s_isInit
|
||||||
? Config::ControllerIcons == EControllerIcons::PlayStation
|
? Config::ControllerIcons == EControllerIcons::PlayStation
|
||||||
: hid::detail::g_inputDevice == hid::detail::EInputDevice::PlayStation;
|
: hid::detail::g_inputDevice == hid::detail::EInputDevice::PlayStation;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ public:
|
||||||
{
|
{
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
{
|
{
|
||||||
if (g_isAppInit)
|
if (App::s_isInit)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (event->key.keysym.scancode)
|
switch (event->key.keysym.scancode)
|
||||||
|
|
@ -93,7 +93,7 @@ public:
|
||||||
|
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
{
|
{
|
||||||
if (g_isAppInit)
|
if (App::s_isInit)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
g_isAccepted = true;
|
g_isAccepted = true;
|
||||||
|
|
@ -273,8 +273,8 @@ void MessageWindow::Draw()
|
||||||
auto textMarginX = Scale(37);
|
auto textMarginX = Scale(37);
|
||||||
auto textMarginY = Scale(45);
|
auto textMarginY = Scale(45);
|
||||||
|
|
||||||
bool isController = g_isAppInit ? true : hid::detail::IsInputDeviceController();
|
bool isController = App::s_isInit ? true : hid::detail::IsInputDeviceController();
|
||||||
bool isKeyboard = g_isAppInit ? false : hid::detail::g_inputDevice == hid::detail::EInputDevice::Keyboard;
|
bool isKeyboard = App::s_isInit ? false : hid::detail::g_inputDevice == hid::detail::EInputDevice::Keyboard;
|
||||||
|
|
||||||
if (DrawContainer(g_appearTime, centre, { textSize.x / 2 + textMarginX, textSize.y / 2 + textMarginY }, !g_isControlsVisible))
|
if (DrawContainer(g_appearTime, centre, { textSize.x / 2 + textMarginX, textSize.y / 2 + textMarginY }, !g_isControlsVisible))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include "sdl_listener.h"
|
#include "sdl_listener.h"
|
||||||
#include <user/config.h>
|
#include <user/config.h>
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
|
#include <app.h>
|
||||||
|
|
||||||
bool m_isFullscreenKeyReleased = true;
|
bool m_isFullscreenKeyReleased = true;
|
||||||
bool m_isResizing = false;
|
bool m_isResizing = false;
|
||||||
|
|
@ -18,7 +19,7 @@ int Window_OnSDLEvent(void*, SDL_Event* event)
|
||||||
{
|
{
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
Config::Save();
|
Config::Save();
|
||||||
ExitProcess(0);
|
App::Exit();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue