Reload Enhancements on edit dialog

This commit is contained in:
zilmar 2021-03-23 12:41:18 +10:30
parent 133170c1a2
commit 2ed2205db2
5 changed files with 14 additions and 5 deletions

View File

@ -51,7 +51,7 @@ void CEnhancements::ApplyActive(CMipsMemoryVM & MMU, CPlugins * Plugins, bool Up
if (m_UpdateCheats && UpdateChanges) if (m_UpdateCheats && UpdateChanges)
{ {
m_UpdateCheats = false; m_UpdateCheats = false;
Load(&MMU, Plugins); LoadActive(&MMU, Plugins);
} }
for (size_t i = 0, n = m_ActiveCodes.size(); i < n; i++) for (size_t i = 0, n = m_ActiveCodes.size(); i < n; i++)
{ {
@ -261,14 +261,20 @@ void CEnhancements::LoadEnhancements(const char * Ident, SectionFiles & Files, s
} }
} }
void CEnhancements::Load(CMipsMemoryVM * MMU, CPlugins * Plugins) void CEnhancements::Load(void)
{ {
WaitScanDone(); WaitScanDone();
CGuard Guard(m_CS); CGuard Guard(m_CS);
LoadEnhancements(CEnhancement::CheatIdent, m_CheatFiles, m_CheatFile, m_Cheats); LoadEnhancements(CEnhancement::CheatIdent, m_CheatFiles, m_CheatFile, m_Cheats);
LoadEnhancements(CEnhancement::EnhancementIdent, m_EnhancementFiles, m_EnhancementFile, m_Enhancements); LoadEnhancements(CEnhancement::EnhancementIdent, m_EnhancementFiles, m_EnhancementFile, m_Enhancements);
}
void CEnhancements::LoadActive(CMipsMemoryVM * MMU, CPlugins * Plugins)
{
Load();
CGuard Guard(m_CS);
m_OverClock = false; m_OverClock = false;
m_OverClockModifier = 1; m_OverClockModifier = 1;

View File

@ -26,7 +26,8 @@ public:
void UpdateCheats(void); void UpdateCheats(void);
void UpdateEnhancements(const CEnhancementList & Enhancements); void UpdateEnhancements(const CEnhancementList & Enhancements);
void ResetActive(CPlugins * Plugins); void ResetActive(CPlugins * Plugins);
void Load(CMipsMemoryVM * MMU, CPlugins * Plugins); void Load(void);
void LoadActive(CMipsMemoryVM * MMU, CPlugins * Plugins);
CEnhancementList Cheats(void); CEnhancementList Cheats(void);
CEnhancementList Enhancements(void); CEnhancementList Enhancements(void);

View File

@ -14,6 +14,7 @@ CCheatsUI::~CCheatsUI()
void CCheatsUI::Display(HWND hParent, bool BlockExecution) void CCheatsUI::Display(HWND hParent, bool BlockExecution)
{ {
g_Enhancements->Load();
m_Cheats = g_Enhancements->Cheats(); m_Cheats = g_Enhancements->Cheats();
if (g_BaseSystem) if (g_BaseSystem)
{ {

View File

@ -145,6 +145,7 @@ LRESULT CEnhancementUI::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*
DeleteObject(hBmp); DeleteObject(hBmp);
m_TreeList.SetImageList(hImageList, TVSIL_STATE); m_TreeList.SetImageList(hImageList, TVSIL_STATE);
g_Enhancements->Load();
m_Enhancements = g_Enhancements->Enhancements(); m_Enhancements = g_Enhancements->Enhancements();
CRect rcDlg, rcParent; CRect rcDlg, rcParent;

View File

@ -963,12 +963,12 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
else if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) else if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS)
{ {
g_Enhancements->ResetActive(nullptr); g_Enhancements->ResetActive(nullptr);
g_Enhancements->Load(nullptr, nullptr); g_Enhancements->LoadActive(nullptr, nullptr);
_this->m_CheatsUI.Display(hWnd, true); _this->m_CheatsUI.Display(hWnd, true);
} }
else if (LOWORD(wParam) == ID_POPUPMENU_CHOOSEENHANCEMENT) else if (LOWORD(wParam) == ID_POPUPMENU_CHOOSEENHANCEMENT)
{ {
g_Enhancements->Load(nullptr, nullptr); g_Enhancements->LoadActive(nullptr, nullptr);
_this->m_EnhancementUI.Display(hWnd, true); _this->m_EnhancementUI.Display(hWnd, true);
} }