[Project64] Code cleanup of Main Menu Class.cpp

This commit is contained in:
zilmar 2015-11-12 22:52:06 +11:00
parent 3b74fef76c
commit 24709944f3
3 changed files with 1239 additions and 1241 deletions

View File

@ -868,7 +868,6 @@ void CN64System::ExecuteCPU()
g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED); g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED);
m_EndEmulation = false; m_EndEmulation = false;
Notify().RefreshMenu();
m_Plugins->RomOpened(); m_Plugins->RomOpened();
if (m_SyncCPU) if (m_SyncCPU)

View File

@ -47,7 +47,6 @@ CMainMenu::~CMainMenu()
} }
} }
void CMainMenu::SettingsChanged(CMainMenu * _this) void CMainMenu::SettingsChanged(CMainMenu * _this)
{ {
_this->ResetMenu(); _this->ResetMenu();
@ -117,7 +116,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
if (g_Settings->LoadBool(GameRunning_CPU_Paused)) if (g_Settings->LoadBool(GameRunning_CPU_Paused))
{ {
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_FromMenu); g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_FromMenu);
} else { }
else
{
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_FromMenu); g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_FromMenu);
} }
WriteTrace(TraceDebug, __FUNCTION__ ": ID_SYSTEM_PAUSE 1"); WriteTrace(TraceDebug, __FUNCTION__ ": ID_SYSTEM_PAUSE 1");
@ -161,7 +162,6 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SaveGame); g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SaveGame);
if (GetSaveFileName(&openfilename)) if (GetSaveFileName(&openfilename))
{ {
_splitpath(SaveFile, drive, dir, fname, ext); _splitpath(SaveFile, drive, dir, fname, ext);
if (_stricmp(ext, ".pj") == 0 || _stricmp(ext, ".zip") == 0) if (_stricmp(ext, ".pj") == 0 || _stricmp(ext, ".zip") == 0)
{ {
@ -202,7 +202,8 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
openfilename.Flags = OFN_HIDEREADONLY; openfilename.Flags = OFN_HIDEREADONLY;
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_LoadGame); g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_LoadGame);
if (GetOpenFileName (&openfilename)) { if (GetOpenFileName(&openfilename))
{
g_Settings->SaveString(GameRunning_InstantSaveFile, SaveFile); g_Settings->SaveString(GameRunning_InstantSaveFile, SaveFile);
char SaveDir[MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; char SaveDir[MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
_splitpath(SaveFile, drive, dir, fname, ext); _splitpath(SaveFile, drive, dir, fname, ext);
@ -261,13 +262,16 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
_Gui->ShowStatusBar(true); _Gui->ShowStatusBar(true);
_Gui->MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop)); _Gui->MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop));
g_Settings->SaveBool(UserInterface_InFullScreen, (DWORD)false); g_Settings->SaveBool(UserInterface_InFullScreen, (DWORD)false);
} else { }
else
{
WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b"); WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b");
ShowCursor(false); ShowCursor(false);
WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 1"); WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 1");
_Gui->ShowStatusBar(false); _Gui->ShowStatusBar(false);
WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 2"); WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 2");
try { try
{
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": ChangeWindow: Starting"); WriteTrace(TraceGfxPlugin, __FUNCTION__ ": ChangeWindow: Starting");
g_Plugins->Gfx()->ChangeWindow(); g_Plugins->Gfx()->ChangeWindow();
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": ChangeWindow: Done"); WriteTrace(TraceGfxPlugin, __FUNCTION__ ": ChangeWindow: Done");
@ -290,10 +294,13 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN 1"); WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN 1");
break; break;
case ID_OPTIONS_ALWAYSONTOP: case ID_OPTIONS_ALWAYSONTOP:
if (g_Settings->LoadDword(UserInterface_AlwaysOnTop)) { if (g_Settings->LoadDword(UserInterface_AlwaysOnTop))
{
g_Settings->SaveBool(UserInterface_AlwaysOnTop, false); g_Settings->SaveBool(UserInterface_AlwaysOnTop, false);
_Gui->MakeWindowOnTop(false); _Gui->MakeWindowOnTop(false);
} else { }
else
{
g_Settings->SaveBool(UserInterface_AlwaysOnTop, true); g_Settings->SaveBool(UserInterface_AlwaysOnTop, true);
_Gui->MakeWindowOnTop(g_Settings->LoadBool(GameRunning_CPU_Running)); _Gui->MakeWindowOnTop(g_Settings->LoadBool(GameRunning_CPU_Running));
} }
@ -308,7 +315,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
{ {
g_Settings->SaveBool(UserInterface_ShowCPUPer, false); g_Settings->SaveBool(UserInterface_ShowCPUPer, false);
g_Notify->DisplayMessage(0, L""); g_Notify->DisplayMessage(0, L"");
} else { }
else
{
g_Settings->SaveBool(UserInterface_ShowCPUPer, true); g_Settings->SaveBool(UserInterface_ShowCPUPer, true);
} }
break; break;
@ -356,7 +365,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
if ((LogLevel & TraceError) != 0) if ((LogLevel & TraceError) != 0)
{ {
LogLevel &= ~TraceError; LogLevel &= ~TraceError;
} else { }
else
{
LogLevel |= TraceError; LogLevel |= TraceError;
} }
g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel);
@ -368,8 +379,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
if ((LogLevel & TraceSettings) != 0) if ((LogLevel & TraceSettings) != 0)
{ {
LogLevel &= ~TraceSettings; LogLevel &= ~TraceSettings;
} else { }
else
{
LogLevel |= TraceSettings; LogLevel |= TraceSettings;
} }
g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel);
@ -381,8 +393,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
if ((LogLevel & TraceRecompiler) != 0) if ((LogLevel & TraceRecompiler) != 0)
{ {
LogLevel &= ~TraceRecompiler; LogLevel &= ~TraceRecompiler;
} else { }
else
{
LogLevel |= TraceRecompiler; LogLevel |= TraceRecompiler;
} }
g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel);
@ -394,8 +407,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
if ((LogLevel & TraceRSP) != 0) if ((LogLevel & TraceRSP) != 0)
{ {
LogLevel &= ~TraceRSP; LogLevel &= ~TraceRSP;
} else { }
else
{
LogLevel |= TraceRSP; LogLevel |= TraceRSP;
} }
g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel);
@ -407,8 +421,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
if ((LogLevel & TraceTLB) != 0) if ((LogLevel & TraceTLB) != 0)
{ {
LogLevel &= ~TraceTLB; LogLevel &= ~TraceTLB;
} else { }
else
{
LogLevel |= TraceTLB; LogLevel |= TraceTLB;
} }
g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel);
@ -420,8 +435,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
if ((LogLevel & TraceGfxPlugin) != 0) if ((LogLevel & TraceGfxPlugin) != 0)
{ {
LogLevel &= ~TraceGfxPlugin; LogLevel &= ~TraceGfxPlugin;
} else { }
else
{
LogLevel |= TraceGfxPlugin; LogLevel |= TraceGfxPlugin;
} }
g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel);
@ -433,8 +449,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
if ((LogLevel & TraceDebug) != 0) if ((LogLevel & TraceDebug) != 0)
{ {
LogLevel &= ~TraceDebug; LogLevel &= ~TraceDebug;
} else { }
else
{
LogLevel |= TraceDebug; LogLevel |= TraceDebug;
} }
g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel);
@ -446,8 +463,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
if ((LogLevel & TraceAudio) != 0) if ((LogLevel & TraceAudio) != 0)
{ {
LogLevel &= ~TraceAudio; LogLevel &= ~TraceAudio;
} else { }
else
{
LogLevel |= TraceAudio; LogLevel |= TraceAudio;
} }
g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel);
@ -492,7 +510,8 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
case ID_HELP_ABOUT: _Gui->AboutBox(); break; case ID_HELP_ABOUT: _Gui->AboutBox(); break;
case ID_HELP_ABOUTSETTINGFILES: _Gui->AboutIniBox(); break; case ID_HELP_ABOUTSETTINGFILES: _Gui->AboutIniBox(); break;
default: default:
if (MenuID >= ID_RECENT_ROM_START && MenuID < ID_RECENT_ROM_END) { if (MenuID >= ID_RECENT_ROM_START && MenuID < ID_RECENT_ROM_END)
{
stdstr FileName; stdstr FileName;
if (g_Settings->LoadStringIndex(File_RecentGameFileIndex, MenuID - ID_RECENT_ROM_START, FileName) && if (g_Settings->LoadStringIndex(File_RecentGameFileIndex, MenuID - ID_RECENT_ROM_START, FileName) &&
FileName.length() > 0) FileName.length() > 0)
@ -500,19 +519,23 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
g_BaseSystem->RunFileImage(FileName.c_str()); g_BaseSystem->RunFileImage(FileName.c_str());
} }
} }
if (MenuID >= ID_RECENT_DIR_START && MenuID < ID_RECENT_DIR_END) { if (MenuID >= ID_RECENT_DIR_START && MenuID < ID_RECENT_DIR_END)
{
int Offset = MenuID - ID_RECENT_DIR_START; int Offset = MenuID - ID_RECENT_DIR_START;
stdstr Dir = g_Settings->LoadStringIndex(Directory_RecentGameDirIndex, Offset); stdstr Dir = g_Settings->LoadStringIndex(Directory_RecentGameDirIndex, Offset);
if (Dir.length() > 0) { if (Dir.length() > 0)
{
g_Settings->SaveString(Directory_Game, Dir.c_str()); g_Settings->SaveString(Directory_Game, Dir.c_str());
Notify().AddRecentDir(Dir.c_str()); Notify().AddRecentDir(Dir.c_str());
_Gui->RefreshMenu(); _Gui->RefreshMenu();
if (_Gui->RomBrowserVisible()) { if (_Gui->RomBrowserVisible())
{
_Gui->RefreshRomBrowser(); _Gui->RefreshRomBrowser();
} }
} }
} }
if (MenuID >= ID_LANG_START && MenuID < ID_LANG_END) { if (MenuID >= ID_LANG_START && MenuID < ID_LANG_END)
{
MENUITEMINFOW menuinfo; MENUITEMINFOW menuinfo;
wchar_t String[300]; wchar_t String[300];
@ -534,24 +557,6 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
return true; return true;
} }
/*stdstr CMainMenu::ShortCutString(MSC_MAP & ShortCuts, int MenuID, CMenuShortCutKey::ACCESS_MODE AccessLevel) {
Notify().BreakPoint(__FILEW__,__LINE__);
MSC_MAP::iterator MenuItem = ShortCuts.find(MenuID);
if (MenuItem == ShortCuts.end()) { return ""; }
const SHORTCUT_KEY_LIST & ShortCutList = MenuItem->second.GetAccelItems();
for (SHORTCUT_KEY_LIST::const_iterator item = ShortCutList.begin(); item != ShortCutList.end(); item++)
{
CMenuShortCutKey::ACCESS_MODE ItemMode = item->AccessMode();
if ((ItemMode & AccessLevel) != AccessLevel )
{
continue;
}
return item->Name();
}
return "";
}*/
stdstr CMainMenu::GetFileLastMod(stdstr FileName) stdstr CMainMenu::GetFileLastMod(stdstr FileName)
{ {
HANDLE hFile = CreateFile(FileName.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, HANDLE hFile = CreateFile(FileName.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL,
@ -570,8 +575,7 @@ stdstr CMainMenu::GetFileLastMod (stdstr FileName)
FileTimeToSystemTime(&LastWriteTime, &stUTC); FileTimeToSystemTime(&LastWriteTime, &stUTC);
SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal); SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
LastMod.Format(" [%d/%02d/%02d %02d:%02d]", LastMod.Format(" [%d/%02d/%02d %02d:%02d]", stLocal.wYear, stLocal.wMonth, stLocal.wDay, stLocal.wHour, stLocal.wMinute);
stLocal.wYear, stLocal.wMonth, stLocal.wDay,stLocal.wHour, stLocal.wMinute);
} }
CloseHandle(hFile); CloseHandle(hFile);
@ -667,9 +671,7 @@ void CMainMenu::FillOutMenu ( HMENU hMenu )
CMenuShortCutKey::ACCESS_MODE AccessLevel = CMenuShortCutKey::GAME_NOT_RUNNING; CMenuShortCutKey::ACCESS_MODE AccessLevel = CMenuShortCutKey::GAME_NOT_RUNNING;
if (g_Settings->LoadBool(GameRunning_CPU_Running)) if (g_Settings->LoadBool(GameRunning_CPU_Running))
{ {
AccessLevel = g_Settings->LoadBool(UserInterface_InFullScreen) ? AccessLevel = g_Settings->LoadBool(UserInterface_InFullScreen) ? CMenuShortCutKey::GAME_RUNNING_FULLSCREEN : CMenuShortCutKey::GAME_RUNNING_WINDOW;
CMenuShortCutKey::GAME_RUNNING_FULLSCREEN :
CMenuShortCutKey::GAME_RUNNING_WINDOW;
} }
//Get the system information to make the menu //Get the system information to make the menu
@ -706,7 +708,6 @@ void CMainMenu::FillOutMenu ( HMENU hMenu )
delete[] w_LastRom; delete[] w_LastRom;
} }
/* Recent Dir /* Recent Dir
****************/ ****************/
MenuItemList RecentDirMenu; MenuItemList RecentDirMenu;
@ -1052,13 +1053,11 @@ void CMainMenu::FillOutMenu ( HMENU hMenu )
DebugAppLoggingMenu.push_back(Item); DebugAppLoggingMenu.push_back(Item);
} }
/* Debug - Logging /* Debug - Logging
*******************/ *******************/
Item.Reset(ID_DEBUGGER_LOGOPTIONS, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Log Options..."); Item.Reset(ID_DEBUGGER_LOGOPTIONS, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Log Options...");
DebugLoggingMenu.push_back(Item); DebugLoggingMenu.push_back(Item);
Item.Reset(ID_DEBUGGER_GENERATELOG, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Generate Log"); Item.Reset(ID_DEBUGGER_GENERATELOG, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Generate Log");
if (g_Settings->LoadBool(Debugger_GenerateDebugLog)) { Item.SetItemTicked(true); } if (g_Settings->LoadBool(Debugger_GenerateDebugLog)) { Item.SetItemTicked(true); }
DebugLoggingMenu.push_back(Item); DebugLoggingMenu.push_back(Item);