mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-09-27 09:55:43 +00:00
Improve Config's "Do Benchmark" behaviour when HW config changes.
This commit is contained in:
parent
f5ec940189
commit
595b429796
@ -8,7 +8,6 @@ public:
|
|||||||
CConfigNeedingRestart(UINT bEnableTheFreezesF8Rom = false) :
|
CConfigNeedingRestart(UINT bEnableTheFreezesF8Rom = false) :
|
||||||
m_Apple2Type(g_Apple2Type),
|
m_Apple2Type(g_Apple2Type),
|
||||||
m_bEnhanceDisk(enhancedisk),
|
m_bEnhanceDisk(enhancedisk),
|
||||||
m_bDoBenchmark(false),
|
|
||||||
m_uSaveLoadStateMsg(0)
|
m_uSaveLoadStateMsg(0)
|
||||||
{
|
{
|
||||||
m_bEnableHDD = HD_CardIsEnabled();
|
m_bEnableHDD = HD_CardIsEnabled();
|
||||||
@ -25,7 +24,6 @@ public:
|
|||||||
m_bEnhanceDisk = other.m_bEnhanceDisk;
|
m_bEnhanceDisk = other.m_bEnhanceDisk;
|
||||||
m_bEnableHDD = other.m_bEnableHDD;
|
m_bEnableHDD = other.m_bEnableHDD;
|
||||||
m_bEnableTheFreezesF8Rom = other.m_bEnableTheFreezesF8Rom;
|
m_bEnableTheFreezesF8Rom = other.m_bEnableTheFreezesF8Rom;
|
||||||
m_bDoBenchmark = other.m_bDoBenchmark;
|
|
||||||
m_uSaveLoadStateMsg = other.m_uSaveLoadStateMsg;
|
m_uSaveLoadStateMsg = other.m_uSaveLoadStateMsg;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -37,7 +35,6 @@ public:
|
|||||||
m_bEnhanceDisk == other.m_bEnhanceDisk &&
|
m_bEnhanceDisk == other.m_bEnhanceDisk &&
|
||||||
m_bEnableHDD == other.m_bEnableHDD &&
|
m_bEnableHDD == other.m_bEnableHDD &&
|
||||||
m_bEnableTheFreezesF8Rom == other.m_bEnableTheFreezesF8Rom &&
|
m_bEnableTheFreezesF8Rom == other.m_bEnableTheFreezesF8Rom &&
|
||||||
m_bDoBenchmark == other.m_bDoBenchmark &&
|
|
||||||
m_uSaveLoadStateMsg == other.m_uSaveLoadStateMsg;
|
m_uSaveLoadStateMsg == other.m_uSaveLoadStateMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +48,5 @@ public:
|
|||||||
BOOL m_bEnhanceDisk;
|
BOOL m_bEnhanceDisk;
|
||||||
bool m_bEnableHDD;
|
bool m_bEnableHDD;
|
||||||
UINT m_bEnableTheFreezesF8Rom;
|
UINT m_bEnableTheFreezesF8Rom;
|
||||||
bool m_bDoBenchmark;
|
|
||||||
UINT m_uSaveLoadStateMsg;
|
UINT m_uSaveLoadStateMsg;
|
||||||
};
|
};
|
||||||
|
@ -74,7 +74,9 @@ BOOL CPageConfig::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_BENCHMARK:
|
case IDC_BENCHMARK:
|
||||||
m_PropertySheetHelper.GetConfigNew().m_bDoBenchmark = true;
|
if (!IsOkToBenchmark(hWnd, m_PropertySheetHelper.IsConfigChanged()))
|
||||||
|
break;
|
||||||
|
m_PropertySheetHelper.SetDoBenchmark();
|
||||||
PropSheet_PressButton(GetParent(hWnd), PSBTN_OK);
|
PropSheet_PressButton(GetParent(hWnd), PSBTN_OK);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -261,3 +263,30 @@ void CPageConfig::ui_tfe_settings_dialog(HWND hwnd)
|
|||||||
{
|
{
|
||||||
DialogBox(g_hInstance, (LPCTSTR)IDD_TFE_SETTINGS_DIALOG, hwnd, CPageConfigTfe::DlgProc);
|
DialogBox(g_hInstance, (LPCTSTR)IDD_TFE_SETTINGS_DIALOG, hwnd, CPageConfigTfe::DlgProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CPageConfig::IsOkToBenchmark(HWND hWnd, const bool bConfigChanged)
|
||||||
|
{
|
||||||
|
if (bConfigChanged)
|
||||||
|
{
|
||||||
|
if (MessageBox(hWnd,
|
||||||
|
TEXT("The hardware configuration has changed. Benchmarking will lose these changes.\n\n")
|
||||||
|
TEXT("Are you sure you want to do this?"),
|
||||||
|
TEXT("Benchmarks"),
|
||||||
|
MB_ICONQUESTION | MB_OKCANCEL | MB_SETFOREGROUND) == IDCANCEL)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_nAppMode == MODE_LOGO)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (MessageBox(hWnd,
|
||||||
|
TEXT("Running the benchmarks will reset the state of ")
|
||||||
|
TEXT("the emulated machine, causing you to lose any ")
|
||||||
|
TEXT("unsaved work.\n\n")
|
||||||
|
TEXT("Are you sure you want to do this?"),
|
||||||
|
TEXT("Benchmarks"),
|
||||||
|
MB_ICONQUESTION | MB_YESNO | MB_SETFOREGROUND) == IDNO)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -29,6 +29,7 @@ private:
|
|||||||
eApple2Type GetApple2Type(DWORD NewMenuItem);
|
eApple2Type GetApple2Type(DWORD NewMenuItem);
|
||||||
void EnableTrackbar(HWND hWnd, BOOL enable);
|
void EnableTrackbar(HWND hWnd, BOOL enable);
|
||||||
void ui_tfe_settings_dialog(HWND hwnd);
|
void ui_tfe_settings_dialog(HWND hwnd);
|
||||||
|
bool IsOkToBenchmark(HWND hWnd, const bool bConfigChanged);
|
||||||
|
|
||||||
static CPageConfig* ms_this;
|
static CPageConfig* ms_this;
|
||||||
static const TCHAR m_ComputerChoices[];
|
static const TCHAR m_ComputerChoices[];
|
||||||
|
@ -71,30 +71,11 @@ Design:
|
|||||||
- so this can just discard any config changes
|
- so this can just discard any config changes
|
||||||
- if any config change, then show msg box to say they won't be applied
|
- if any config change, then show msg box to say they won't be applied
|
||||||
. Benchmark button
|
. Benchmark button
|
||||||
- Action it immediately (yes).
|
- Action it immediately.
|
||||||
- But apply or discard config changes?
|
- If config has changed:
|
||||||
- Could discard & show msg box like Load/Save State (for consistency)
|
- Prompt to either do benchmark (and lose new config) or cancel benchmark (and drop back to Configuration dialog).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// NB. This used to be in FrameWndProc() for case WM_USER_RESTART:
|
|
||||||
// - but this is too late to cancel, since new configurations have already been changed.
|
|
||||||
bool CPropertySheetHelper::IsOkToRestart(HWND hWnd)
|
|
||||||
{
|
|
||||||
if (g_nAppMode == MODE_LOGO)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (MessageBox(hWnd,
|
|
||||||
TEXT("Restarting the emulator will reset the state ")
|
|
||||||
"of the emulated machine, causing you to lose any "
|
|
||||||
"unsaved work.\n\n"
|
|
||||||
"Are you sure you want to do this?",
|
|
||||||
TEXT(REG_CONFIG),
|
|
||||||
MB_ICONQUESTION | MB_OKCANCEL | MB_SETFOREGROUND) == IDCANCEL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CPropertySheetHelper::FillComboBox(HWND window, int controlid, LPCTSTR choices, int currentchoice)
|
void CPropertySheetHelper::FillComboBox(HWND window, int controlid, LPCTSTR choices, int currentchoice)
|
||||||
{
|
{
|
||||||
_ASSERT(choices);
|
_ASSERT(choices);
|
||||||
@ -283,16 +264,23 @@ void CPropertySheetHelper::PostMsgAfterClose(HWND hWnd, PAGETYPE page)
|
|||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
UINT uAfterClose = 0;
|
if (m_ConfigNew.m_uSaveLoadStateMsg && IsOkToSaveLoadState(hWnd, IsConfigChanged()))
|
||||||
|
|
||||||
if (m_ConfigNew.m_uSaveLoadStateMsg)
|
|
||||||
{
|
{
|
||||||
// Drop any state change, and do load/save state
|
// Drop any config change, and do load/save state
|
||||||
PostMessage(g_hFrameWindow, m_ConfigNew.m_uSaveLoadStateMsg, 0, 0);
|
PostMessage(g_hFrameWindow, m_ConfigNew.m_uSaveLoadStateMsg, 0, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_bDoBenchmark)
|
||||||
|
{
|
||||||
|
// Drop any config change, and do benchmark
|
||||||
|
PostMessage(g_hFrameWindow, WM_USER_BENCHMARK, 0, 0); // NB. doesn't do WM_USER_RESTART
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_ConfigNew != m_ConfigOld)
|
UINT uAfterClose = 0;
|
||||||
|
|
||||||
|
if (IsConfigChanged())
|
||||||
{
|
{
|
||||||
if (!CheckChangesForRestart(hWnd))
|
if (!CheckChangesForRestart(hWnd))
|
||||||
{
|
{
|
||||||
@ -306,11 +294,6 @@ void CPropertySheetHelper::PostMsgAfterClose(HWND hWnd, PAGETYPE page)
|
|||||||
uAfterClose = WM_USER_RESTART;
|
uAfterClose = WM_USER_RESTART;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_ConfigNew.m_bDoBenchmark)
|
|
||||||
{
|
|
||||||
uAfterClose = WM_USER_BENCHMARK; // which implies WM_USER_RESTART (actually it doesn't)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uAfterClose)
|
if (uAfterClose)
|
||||||
PostMessage(g_hFrameWindow, uAfterClose, 0, 0);
|
PostMessage(g_hFrameWindow, uAfterClose, 0, 0);
|
||||||
}
|
}
|
||||||
@ -335,7 +318,7 @@ void CPropertySheetHelper::ApplyNewConfig(void)
|
|||||||
if (CONFIG_CHANGED(m_Apple2Type))
|
if (CONFIG_CHANGED(m_Apple2Type))
|
||||||
{
|
{
|
||||||
SaveComputerType(m_ConfigNew.m_Apple2Type);
|
SaveComputerType(m_ConfigNew.m_Apple2Type);
|
||||||
g_Apple2Type = m_ConfigNew.m_Apple2Type; // Is this necessary?
|
//g_Apple2Type = m_ConfigNew.m_Apple2Type; // Is this necessary?
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CONFIG_CHANGED(m_Slot[4]))
|
if (CONFIG_CHANGED(m_Slot[4]))
|
||||||
@ -344,14 +327,14 @@ void CPropertySheetHelper::ApplyNewConfig(void)
|
|||||||
if (CONFIG_CHANGED(m_Slot[5]))
|
if (CONFIG_CHANGED(m_Slot[5]))
|
||||||
SetSlot5(m_ConfigNew.m_Slot[5]);
|
SetSlot5(m_ConfigNew.m_Slot[5]);
|
||||||
|
|
||||||
if (m_ConfigNew.m_Slot[4] == CT_MockingboardC || m_ConfigNew.m_Slot[4] == CT_Phasor)
|
//if (m_ConfigNew.m_Slot[4] == CT_MockingboardC || m_ConfigNew.m_Slot[4] == CT_Phasor)
|
||||||
{
|
//{
|
||||||
MB_SetSoundcardType(m_ConfigNew.m_Slot[4]); // Is this necessary?
|
// MB_SetSoundcardType(m_ConfigNew.m_Slot[4]); // Is this necessary?
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
MB_SetSoundcardType(CT_Empty); // Is this necessary?
|
// MB_SetSoundcardType(CT_Empty); // Is this necessary?
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (CONFIG_CHANGED(m_bEnhanceDisk))
|
if (CONFIG_CHANGED(m_bEnhanceDisk))
|
||||||
REGSAVE(TEXT(REGVALUE_ENHANCE_DISK_SPEED), m_ConfigNew.m_bEnhanceDisk);
|
REGSAVE(TEXT(REGVALUE_ENHANCE_DISK_SPEED), m_ConfigNew.m_bEnhanceDisk);
|
||||||
@ -359,13 +342,13 @@ void CPropertySheetHelper::ApplyNewConfig(void)
|
|||||||
if (CONFIG_CHANGED(m_bEnableHDD))
|
if (CONFIG_CHANGED(m_bEnableHDD))
|
||||||
{
|
{
|
||||||
REGSAVE(TEXT(REGVALUE_HDD_ENABLED), m_ConfigNew.m_bEnableHDD ? 1 : 0);
|
REGSAVE(TEXT(REGVALUE_HDD_ENABLED), m_ConfigNew.m_bEnableHDD ? 1 : 0);
|
||||||
HD_SetEnabled(m_ConfigNew.m_bEnableHDD); // Is this necessary?
|
//HD_SetEnabled(m_ConfigNew.m_bEnableHDD); // Is this necessary?
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CONFIG_CHANGED(m_bEnableTheFreezesF8Rom))
|
if (CONFIG_CHANGED(m_bEnableTheFreezesF8Rom))
|
||||||
{
|
{
|
||||||
REGSAVE(TEXT(REGVALUE_THE_FREEZES_F8_ROM), m_ConfigNew.m_bEnableTheFreezesF8Rom);
|
REGSAVE(TEXT(REGVALUE_THE_FREEZES_F8_ROM), m_ConfigNew.m_bEnableTheFreezesF8Rom);
|
||||||
sg_PropertySheet.SetTheFreezesF8Rom(m_ConfigNew.m_bEnableTheFreezesF8Rom); // Is this necessary?
|
//sg_PropertySheet.SetTheFreezesF8Rom(m_ConfigNew.m_bEnableTheFreezesF8Rom); // Is this necessary?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,8 +363,8 @@ void CPropertySheetHelper::SaveCurrentConfig(void)
|
|||||||
m_ConfigOld.m_bEnableTheFreezesF8Rom = sg_PropertySheet.GetTheFreezesF8Rom();
|
m_ConfigOld.m_bEnableTheFreezesF8Rom = sg_PropertySheet.GetTheFreezesF8Rom();
|
||||||
|
|
||||||
// Reset flags each time:
|
// Reset flags each time:
|
||||||
m_ConfigOld.m_bDoBenchmark = false;
|
|
||||||
m_ConfigOld.m_uSaveLoadStateMsg = 0;
|
m_ConfigOld.m_uSaveLoadStateMsg = 0;
|
||||||
|
m_bDoBenchmark = false;
|
||||||
|
|
||||||
// Setup ConfigNew
|
// Setup ConfigNew
|
||||||
m_ConfigNew = m_ConfigOld;
|
m_ConfigNew = m_ConfigOld;
|
||||||
@ -398,6 +381,38 @@ void CPropertySheetHelper::RestoreCurrentConfig(void)
|
|||||||
sg_PropertySheet.SetTheFreezesF8Rom(m_ConfigOld.m_bEnableTheFreezesF8Rom);
|
sg_PropertySheet.SetTheFreezesF8Rom(m_ConfigOld.m_bEnableTheFreezesF8Rom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CPropertySheetHelper::IsOkToSaveLoadState(HWND hWnd, const bool bConfigChanged)
|
||||||
|
{
|
||||||
|
if (bConfigChanged)
|
||||||
|
{
|
||||||
|
if (MessageBox(hWnd,
|
||||||
|
TEXT("The hardware configuration has changed. Save/Load state will lose these changes.\n\n")
|
||||||
|
TEXT("Are you sure you want to do this?"),
|
||||||
|
TEXT(REG_CONFIG),
|
||||||
|
MB_ICONQUESTION | MB_OKCANCEL | MB_SETFOREGROUND) == IDCANCEL)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CPropertySheetHelper::IsOkToRestart(HWND hWnd)
|
||||||
|
{
|
||||||
|
if (g_nAppMode == MODE_LOGO)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (MessageBox(hWnd,
|
||||||
|
TEXT("Restarting the emulator will reset the state ")
|
||||||
|
TEXT("of the emulated machine, causing you to lose any ")
|
||||||
|
TEXT("unsaved work.\n\n")
|
||||||
|
TEXT("Are you sure you want to do this?"),
|
||||||
|
TEXT(REG_CONFIG),
|
||||||
|
MB_ICONQUESTION | MB_OKCANCEL | MB_SETFOREGROUND) == IDCANCEL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool CPropertySheetHelper::HardwareConfigChanged(HWND hWnd)
|
bool CPropertySheetHelper::HardwareConfigChanged(HWND hWnd)
|
||||||
{
|
{
|
||||||
std::string strMsg("The emulator needs to restart as the hardware configuration has changed:\n");
|
std::string strMsg("The emulator needs to restart as the hardware configuration has changed:\n");
|
||||||
@ -424,19 +439,6 @@ bool CPropertySheetHelper::HardwareConfigChanged(HWND hWnd)
|
|||||||
strMsgMain += ". F8 ROM changed (The Freeze's F8 Rom)\n";
|
strMsgMain += ". F8 ROM changed (The Freeze's F8 Rom)\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strMsgMain.empty())
|
|
||||||
{
|
|
||||||
if (CONFIG_CHANGED(m_bDoBenchmark))
|
|
||||||
strMsg = "The emulator needs to restart to perform the benchmark.\n";
|
|
||||||
else
|
|
||||||
_ASSERT(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (CONFIG_CHANGED(m_bDoBenchmark))
|
|
||||||
strMsgMain += ". Benchmark\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string strMsgPost("\n");
|
std::string strMsgPost("\n");
|
||||||
strMsgPost += "This change will not take effect until the next time you restart the emulator.\n\n";
|
strMsgPost += "This change will not take effect until the next time you restart the emulator.\n\n";
|
||||||
strMsgPost += "Would you like to restart the emulator now?";
|
strMsgPost += "Would you like to restart the emulator now?";
|
||||||
|
@ -8,7 +8,8 @@ public:
|
|||||||
CPropertySheetHelper() :
|
CPropertySheetHelper() :
|
||||||
m_LastPage(PG_CONFIG),
|
m_LastPage(PG_CONFIG),
|
||||||
m_bmPages(0),
|
m_bmPages(0),
|
||||||
m_bSSNewFilename(false)
|
m_bSSNewFilename(false),
|
||||||
|
m_bDoBenchmark(false)
|
||||||
{}
|
{}
|
||||||
virtual ~CPropertySheetHelper(){}
|
virtual ~CPropertySheetHelper(){}
|
||||||
|
|
||||||
@ -34,8 +35,11 @@ public:
|
|||||||
void ClearSSNewDirectory(void) { m_szSSNewDirectory[0] = 0; }
|
void ClearSSNewDirectory(void) { m_szSSNewDirectory[0] = 0; }
|
||||||
// const CConfigNeedingRestart& GetConfigOld(void) { return m_ConfigOld; }
|
// const CConfigNeedingRestart& GetConfigOld(void) { return m_ConfigOld; }
|
||||||
CConfigNeedingRestart& GetConfigNew(void) { return m_ConfigNew; }
|
CConfigNeedingRestart& GetConfigNew(void) { return m_ConfigNew; }
|
||||||
|
bool IsConfigChanged(void) { return m_ConfigNew != m_ConfigOld; }
|
||||||
|
void SetDoBenchmark(void) { m_bDoBenchmark = true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool IsOkToSaveLoadState(HWND hWnd, const bool bConfigChanged);
|
||||||
bool IsOkToRestart(HWND hWnd);
|
bool IsOkToRestart(HWND hWnd);
|
||||||
void SaveComputerType(eApple2Type NewApple2Type);
|
void SaveComputerType(eApple2Type NewApple2Type);
|
||||||
bool HardwareConfigChanged(HWND hWnd);
|
bool HardwareConfigChanged(HWND hWnd);
|
||||||
@ -53,4 +57,5 @@ private:
|
|||||||
char m_szSSNewFilename[MAX_PATH];
|
char m_szSSNewFilename[MAX_PATH];
|
||||||
CConfigNeedingRestart m_ConfigOld;
|
CConfigNeedingRestart m_ConfigOld;
|
||||||
CConfigNeedingRestart m_ConfigNew;
|
CConfigNeedingRestart m_ConfigNew;
|
||||||
|
bool m_bDoBenchmark;
|
||||||
};
|
};
|
||||||
|
@ -1320,15 +1320,6 @@ LRESULT CALLBACK FrameWndProc (
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_USER_BENCHMARK: {
|
case WM_USER_BENCHMARK: {
|
||||||
if (g_nAppMode != MODE_LOGO)
|
|
||||||
if (MessageBox(g_hFrameWindow,
|
|
||||||
TEXT("Running the benchmarks will reset the state of ")
|
|
||||||
TEXT("the emulated machine, causing you to lose any ")
|
|
||||||
TEXT("unsaved work.\n\n")
|
|
||||||
TEXT("Are you sure you want to do this?"),
|
|
||||||
TEXT("Benchmarks"),
|
|
||||||
MB_ICONQUESTION | MB_YESNO | MB_SETFOREGROUND) == IDNO)
|
|
||||||
break;
|
|
||||||
UpdateWindow(window);
|
UpdateWindow(window);
|
||||||
ResetMachineState();
|
ResetMachineState();
|
||||||
g_nAppMode = MODE_LOGO;
|
g_nAppMode = MODE_LOGO;
|
||||||
|
Loading…
Reference in New Issue
Block a user