mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-12-18 22:12:18 +00:00
CTitleStateMenu_patches: reset achievements on New Game (#278)
This commit is contained in:
parent
900ba7c916
commit
553e011dad
8 changed files with 89 additions and 7 deletions
|
|
@ -102,6 +102,7 @@
|
|||
#include "SWA/System/GameMode/Title/TitleMenu.h"
|
||||
#include "SWA/System/GameMode/Title/TitleStateBase.h"
|
||||
#include "SWA/System/GameMode/Title/TitleStateIntro.h"
|
||||
#include "SWA/System/GameMode/Title/TitleStateMenu.h"
|
||||
#include "SWA/System/GameMode/Title/TitleStateWorldMap.h"
|
||||
#include "SWA/System/GameMode/WorldMap/WorldMapCamera.h"
|
||||
#include "SWA/System/GameMode/WorldMap/WorldMapCursor.h"
|
||||
|
|
|
|||
|
|
@ -4,6 +4,15 @@
|
|||
|
||||
namespace SWA
|
||||
{
|
||||
enum EWindowStatus : uint32_t
|
||||
{
|
||||
eWindowStatus_Closed,
|
||||
eWindowStatus_OpeningMessage = 2,
|
||||
eWindowStatus_DisplayingMessage,
|
||||
eWindowStatus_OpeningControls,
|
||||
eWindowStatus_DisplayingControls
|
||||
};
|
||||
|
||||
class CGeneralWindow
|
||||
{
|
||||
public:
|
||||
|
|
@ -14,5 +23,20 @@ namespace SWA
|
|||
Chao::CSD::RCPtr<Chao::CSD::CScene> m_rcWindow_2;
|
||||
Chao::CSD::RCPtr<Chao::CSD::CScene> m_rcWindowSelect;
|
||||
Chao::CSD::RCPtr<Chao::CSD::CScene> m_rcFooter;
|
||||
SWA_INSERT_PADDING(0x58);
|
||||
be<EWindowStatus> m_Status;
|
||||
be<uint32_t> m_CursorIndex;
|
||||
SWA_INSERT_PADDING(0x04);
|
||||
be<uint32_t> m_SelectedIndex;
|
||||
};
|
||||
|
||||
SWA_ASSERT_OFFSETOF(CGeneralWindow, m_rcGeneral, 0xD0);
|
||||
SWA_ASSERT_OFFSETOF(CGeneralWindow, m_rcBg, 0xD8);
|
||||
SWA_ASSERT_OFFSETOF(CGeneralWindow, m_rcWindow, 0xE0);
|
||||
SWA_ASSERT_OFFSETOF(CGeneralWindow, m_rcWindow_2, 0xE8);
|
||||
SWA_ASSERT_OFFSETOF(CGeneralWindow, m_rcWindowSelect, 0xF0);
|
||||
SWA_ASSERT_OFFSETOF(CGeneralWindow, m_rcFooter, 0xF8);
|
||||
SWA_ASSERT_OFFSETOF(CGeneralWindow, m_Status, 0x158);
|
||||
SWA_ASSERT_OFFSETOF(CGeneralWindow, m_CursorIndex, 0x15C);
|
||||
SWA_ASSERT_OFFSETOF(CGeneralWindow, m_SelectedIndex, 0x164);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@ namespace SWA
|
|||
SWA_INSERT_PADDING(0x88);
|
||||
Hedgehog::Base::CSharedString m_StageName;
|
||||
xpointer<CSoundAdministrator> m_pSoundAdministrator;
|
||||
SWA_INSERT_PADDING(0x124);
|
||||
SWA_INSERT_PADDING(0x48);
|
||||
xpointer<CGeneralWindow> m_pGeneralWindow;
|
||||
SWA_INSERT_PADDING(0xD8);
|
||||
SScoreInfo m_ScoreInfo;
|
||||
SWA_INSERT_PADDING(0x0C);
|
||||
};
|
||||
|
|
@ -60,6 +62,7 @@ namespace SWA
|
|||
SWA_ASSERT_OFFSETOF(CGameDocument::CMember, m_spDatabase, 0x1C);
|
||||
SWA_ASSERT_OFFSETOF(CGameDocument::CMember, m_StageName, 0xAC);
|
||||
SWA_ASSERT_OFFSETOF(CGameDocument::CMember, m_pSoundAdministrator, 0xB0);
|
||||
SWA_ASSERT_OFFSETOF(CGameDocument::CMember, m_pGeneralWindow, 0xFC);
|
||||
SWA_ASSERT_OFFSETOF(CGameDocument::CMember, m_ScoreInfo, 0x1D8);
|
||||
SWA_ASSERT_SIZEOF(CGameDocument::CMember, 0x230);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,36 @@
|
|||
|
||||
namespace SWA
|
||||
{
|
||||
class CTitleMenu
|
||||
class CTitleMenu : public CMenuWindowBase
|
||||
{
|
||||
public:
|
||||
SWA_INSERT_PADDING(0x44);
|
||||
SWA_INSERT_PADDING(0x28);
|
||||
be<uint32_t> m_Field38;
|
||||
bool m_Field3C; // Seems to be related to exit transition.
|
||||
SWA_INSERT_PADDING(0x04);
|
||||
be<uint32_t> m_CursorIndex;
|
||||
SWA_INSERT_PADDING(0x0C);
|
||||
bool m_Field54; // Seems to be related to exit transition.
|
||||
SWA_INSERT_PADDING(0x0B);
|
||||
be<float> m_Field60;
|
||||
SWA_INSERT_PADDING(0x34);
|
||||
bool m_Field98;
|
||||
bool m_IsDeleteCheckMessageOpen;
|
||||
bool m_Field9A; // Seems to be related to cursor selection.
|
||||
SWA_INSERT_PADDING(0x04);
|
||||
bool m_Field9F;
|
||||
SWA_INSERT_PADDING(0x02);
|
||||
bool m_IsDLCInfoMessageOpen;
|
||||
};
|
||||
|
||||
SWA_ASSERT_OFFSETOF(CTitleMenu, m_Field38, 0x38);
|
||||
SWA_ASSERT_OFFSETOF(CTitleMenu, m_Field3C, 0x3C);
|
||||
SWA_ASSERT_OFFSETOF(CTitleMenu, m_CursorIndex, 0x44);
|
||||
SWA_ASSERT_OFFSETOF(CTitleMenu, m_Field54, 0x54);
|
||||
SWA_ASSERT_OFFSETOF(CTitleMenu, m_Field60, 0x60);
|
||||
SWA_ASSERT_OFFSETOF(CTitleMenu, m_Field98, 0x98);
|
||||
SWA_ASSERT_OFFSETOF(CTitleMenu, m_IsDeleteCheckMessageOpen, 0x99);
|
||||
SWA_ASSERT_OFFSETOF(CTitleMenu, m_Field9A, 0x9A);
|
||||
SWA_ASSERT_OFFSETOF(CTitleMenu, m_Field9F, 0x9F);
|
||||
SWA_ASSERT_OFFSETOF(CTitleMenu, m_IsDLCInfoMessageOpen, 0xA2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <SWA.inl>
|
||||
|
||||
namespace SWA
|
||||
{
|
||||
class CTitleStateMenu : public CTitleStateBase {};
|
||||
}
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
#include <api/SWA.h>
|
||||
#include <cpu/guest_stack_var.h>
|
||||
#include <locale/locale.h>
|
||||
#include <os/logger.h>
|
||||
#include <ui/button_guide.h>
|
||||
#include <ui/fader.h>
|
||||
#include <ui/message_window.h>
|
||||
#include <ui/options_menu.h>
|
||||
#include <user/achievement_manager.h>
|
||||
#include <user/paths.h>
|
||||
#include <app.h>
|
||||
#include <exports.h>
|
||||
|
|
@ -50,12 +53,14 @@ PPC_FUNC_IMPL(__imp__sub_825882B8);
|
|||
PPC_FUNC(sub_825882B8)
|
||||
{
|
||||
auto pTitleState = (SWA::CTitleStateBase*)g_memory.Translate(ctx.r3.u32);
|
||||
auto pGameDocument = SWA::CGameDocument::GetInstance();
|
||||
|
||||
auto pInputState = SWA::CInputState::GetInstance();
|
||||
auto& pPadState = pInputState->GetPadState();
|
||||
auto isAccepted = pPadState.IsTapped(SWA::eKeyState_A) || pPadState.IsTapped(SWA::eKeyState_Start);
|
||||
|
||||
auto pContext = pTitleState->GetContextBase<SWA::CTitleStateBase::CTitleStateContext>();
|
||||
auto isNewGameIndex = pContext->m_pTitleMenu->m_CursorIndex == 0;
|
||||
auto isOptionsIndex = pContext->m_pTitleMenu->m_CursorIndex == 2;
|
||||
auto isInstallIndex = pContext->m_pTitleMenu->m_CursorIndex == 3;
|
||||
|
||||
|
|
@ -63,7 +68,17 @@ PPC_FUNC(sub_825882B8)
|
|||
if (App::s_isSaveDataCorrupt && pContext->m_pTitleMenu->m_CursorIndex == 1)
|
||||
pContext->m_pTitleMenu->m_CursorIndex = 0;
|
||||
|
||||
if (!OptionsMenu::s_isVisible && isOptionsIndex)
|
||||
if (isNewGameIndex && isAccepted)
|
||||
{
|
||||
if (pContext->m_pTitleMenu->m_IsDeleteCheckMessageOpen &&
|
||||
pGameDocument->m_pMember->m_pGeneralWindow->m_SelectedIndex == 1)
|
||||
{
|
||||
LOGN("Resetting achievements...");
|
||||
|
||||
AchievementManager::Reset();
|
||||
}
|
||||
}
|
||||
else if (!OptionsMenu::s_isVisible && isOptionsIndex)
|
||||
{
|
||||
if (OptionsMenu::s_isRestartRequired)
|
||||
{
|
||||
|
|
@ -76,7 +91,6 @@ PPC_FUNC(sub_825882B8)
|
|||
{
|
||||
Game_PlaySound("sys_worldmap_window");
|
||||
Game_PlaySound("sys_worldmap_decide");
|
||||
|
||||
OptionsMenu::Open();
|
||||
}
|
||||
}
|
||||
|
|
@ -93,7 +107,6 @@ PPC_FUNC(sub_825882B8)
|
|||
if (OptionsMenu::CanClose() && pPadState.IsTapped(SWA::eKeyState_B))
|
||||
{
|
||||
Game_PlaySound("sys_worldmap_cansel");
|
||||
|
||||
OptionsMenu::Close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,9 +67,15 @@ void AchievementManager::Unlock(uint16_t id)
|
|||
AchievementOverlay::Open(id);
|
||||
}
|
||||
|
||||
void AchievementManager::Load()
|
||||
void AchievementManager::Reset()
|
||||
{
|
||||
Data = {};
|
||||
}
|
||||
|
||||
void AchievementManager::Load()
|
||||
{
|
||||
AchievementManager::Reset();
|
||||
|
||||
Status = EAchStatus::Success;
|
||||
|
||||
auto dataPath = GetDataPath(true);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public:
|
|||
static size_t GetTotalRecords();
|
||||
static bool IsUnlocked(uint16_t id);
|
||||
static void Unlock(uint16_t id);
|
||||
static void Reset();
|
||||
static void Load();
|
||||
static void Save(bool ignoreStatus = false);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue