[Project64] Add GameLoaded setting

This commit is contained in:
zilmar 2015-11-12 22:27:19 +11:00
parent 51c89388c7
commit 73d7263de0
5 changed files with 463 additions and 417 deletions

View File

@ -181,6 +181,7 @@ bool CN64System::RunFileImage(const char * FileLoc)
return false; return false;
} }
WriteTrace(TraceDebug, __FUNCTION__ ": Mark Rom as loading"); WriteTrace(TraceDebug, __FUNCTION__ ": Mark Rom as loading");
g_Settings->SaveString(Game_File, "");
//Mark the rom as loading //Mark the rom as loading
g_Settings->SaveBool(GameRunning_LoadingInProgress, true); g_Settings->SaveBool(GameRunning_LoadingInProgress, true);
@ -201,10 +202,7 @@ bool CN64System::RunFileImage(const char * FileLoc)
{ {
g_System->RefreshGameSettings(); g_System->RefreshGameSettings();
WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom"); g_Settings->SaveString(Game_File, FileLoc);
Notify().AddRecentRom(FileLoc);
Notify().SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str());
g_Settings->SaveBool(GameRunning_LoadingInProgress, false); g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
if (g_Settings->LoadDword(Setting_AutoStart) != 0) if (g_Settings->LoadDword(Setting_AutoStart) != 0)
@ -275,9 +273,6 @@ void CN64System::StartEmulation2(bool NewThread)
if (NewThread) if (NewThread)
{ {
WriteTrace(TraceDebug, __FUNCTION__ ": Starting"); WriteTrace(TraceDebug, __FUNCTION__ ": Starting");
Notify().HideRomBrowser();
if (bHaveDebugger()) if (bHaveDebugger())
{ {
g_LogOptions.GenerateLog = g_Settings->LoadBool(Debugger_GenerateDebugLog); g_LogOptions.GenerateLog = g_Settings->LoadBool(Debugger_GenerateDebugLog);

View File

@ -172,6 +172,7 @@ void CSettings::AddHowToHandleSetting ()
AddHandler(Rdb_CRC_Recalc, new CSettingTypeRDBYesNo("CRC-Recalc", false)); AddHandler(Rdb_CRC_Recalc, new CSettingTypeRDBYesNo("CRC-Recalc", false));
AddHandler(Game_IniKey, new CSettingTypeTempString("")); AddHandler(Game_IniKey, new CSettingTypeTempString(""));
AddHandler(Game_File, new CSettingTypeTempString(""));
AddHandler(Game_GameName, new CSettingTypeTempString("")); AddHandler(Game_GameName, new CSettingTypeTempString(""));
AddHandler(Game_GoodName, new CSettingTypeGame("Good Name", Rdb_GoodName)); AddHandler(Game_GoodName, new CSettingTypeGame("Good Name", Rdb_GoodName));
AddHandler(Game_TempLoaded, new CSettingTypeTempBool(false)); AddHandler(Game_TempLoaded, new CSettingTypeTempBool(false));
@ -431,7 +432,8 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
if (DefaultID == Default_None) if (DefaultID == Default_None)
{ {
_this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, Value)); _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, Value));
} else { }
else {
_this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, DefaultID)); _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, DefaultID));
} }
break; break;
@ -439,7 +441,8 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
if (DefaultID == Default_None) if (DefaultID == Default_None)
{ {
_this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, "")); _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, ""));
} else { }
else {
_this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, DefaultID)); _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, DefaultID));
} }
break; break;
@ -459,7 +462,8 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
_this->m_NextAutoSettingId += 1; _this->m_NextAutoSettingId += 1;
_this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), (int)Value)); _this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), (int)Value));
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting)); _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting));
} else { }
else {
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), DefaultID)); _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), DefaultID));
} }
break; break;
@ -467,7 +471,8 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
if (DefaultID == Default_None) if (DefaultID == Default_None)
{ {
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), "")); _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), ""));
} else { }
else {
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), DefaultID)); _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), DefaultID));
} }
break; break;
@ -483,7 +488,8 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
if (DefaultID == Default_None) if (DefaultID == Default_None)
{ {
_this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, (int)Value, true)); _this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, (int)Value, true));
} else { }
else {
_this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, (SettingID)Value, true)); _this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, (SettingID)Value, true));
} }
break; break;
@ -491,7 +497,8 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
if (DefaultID == Default_None) if (DefaultID == Default_None)
{ {
_this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, "", true)); _this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, "", true));
} else { }
else {
_this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, DefaultID, true)); _this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, DefaultID, true));
} }
break; break;
@ -506,7 +513,8 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
if (DefaultID == Default_None) if (DefaultID == Default_None)
{ {
_this->AddHandler(ID, new CSettingTypeRomDatabaseSetting(Category, DefaultStr, (int)Value, true)); _this->AddHandler(ID, new CSettingTypeRomDatabaseSetting(Category, DefaultStr, (int)Value, true));
} else { }
else {
SettingID RdbSetting = (SettingID)_this->m_NextAutoSettingId; SettingID RdbSetting = (SettingID)_this->m_NextAutoSettingId;
_this->m_NextAutoSettingId += 1; _this->m_NextAutoSettingId += 1;
_this->AddHandler(RdbSetting, new CSettingTypeRomDatabaseSetting(Category, DefaultStr, DefaultID, true)); _this->AddHandler(RdbSetting, new CSettingTypeRomDatabaseSetting(Category, DefaultStr, DefaultID, true));
@ -553,7 +561,8 @@ bool CSettings::LoadBool ( SettingID Type, bool & Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else {
return FindInfo->second->Load(0, Value); return FindInfo->second->Load(0, Value);
} }
return false; return false;
@ -578,7 +587,8 @@ bool CSettings::LoadBoolIndex( SettingID Type, int index , bool & Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
return FindInfo->second->Load(index, Value); return FindInfo->second->Load(index, Value);
} else { }
else {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
return false; return false;
@ -603,7 +613,8 @@ bool CSettings::LoadDword ( SettingID Type, uint32_t & Value)
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else {
return FindInfo->second->Load(0, Value); return FindInfo->second->Load(0, Value);
} }
return false; return false;
@ -628,7 +639,8 @@ bool CSettings::LoadDwordIndex( SettingID Type, int index, uint32_t & Value)
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
return FindInfo->second->Load(index, Value); return FindInfo->second->Load(index, Value);
} else { }
else {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
return false; return false;
@ -653,7 +665,8 @@ bool CSettings::LoadStringVal ( SettingID Type, stdstr & Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else {
return FindInfo->second->Load(0, Value); return FindInfo->second->Load(0, Value);
} }
return false; return false;
@ -672,7 +685,8 @@ bool CSettings::LoadStringVal ( SettingID Type, char * Buffer, int BufferSize )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else {
stdstr Value; stdstr Value;
bRes = FindInfo->second->Load(0, Value); bRes = FindInfo->second->Load(0, Value);
int len = BufferSize; int len = BufferSize;
@ -704,7 +718,8 @@ bool CSettings::LoadStringIndex ( SettingID Type, int index, stdstr & Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
return FindInfo->second->Load(index, Value); return FindInfo->second->Load(index, Value);
} else { }
else {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
return false; return false;
@ -731,11 +746,13 @@ void CSettings::LoadDefaultBool ( SettingID Type, bool & Value )
{ {
//if not found do nothing //if not found do nothing
UnknownSetting(Type); UnknownSetting(Type);
} else { }
else {
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else {
FindInfo->second->LoadDefault(0, Value); FindInfo->second->LoadDefault(0, Value);
} }
} }
@ -766,11 +783,13 @@ void CSettings::LoadDefaultDword ( SettingID Type, uint32_t & Value)
{ {
//if not found do nothing //if not found do nothing
UnknownSetting(Type); UnknownSetting(Type);
} else { }
else {
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else {
FindInfo->second->LoadDefault(0, Value); FindInfo->second->LoadDefault(0, Value);
} }
} }
@ -801,11 +820,13 @@ void CSettings::LoadDefaultString ( SettingID Type, stdstr & Value )
{ {
//if not found do nothing //if not found do nothing
UnknownSetting(Type); UnknownSetting(Type);
} else { }
else {
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else {
FindInfo->second->LoadDefault(0, Value); FindInfo->second->LoadDefault(0, Value);
} }
} }
@ -844,7 +865,8 @@ void CSettings::SaveBool ( SettingID Type, bool Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else {
FindInfo->second->Save(0, Value); FindInfo->second->Save(0, Value);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -862,7 +884,8 @@ void CSettings::SaveBoolIndex( SettingID Type, int index, bool Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
FindInfo->second->Save(index, Value); FindInfo->second->Save(index, Value);
} else { }
else {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -880,7 +903,8 @@ void CSettings::SaveDword ( SettingID Type, uint32_t Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else {
FindInfo->second->Save(0, Value); FindInfo->second->Save(0, Value);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -898,7 +922,8 @@ void CSettings::SaveDwordIndex ( SettingID Type, int index, uint32_t Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
FindInfo->second->Save(index, Value); FindInfo->second->Save(index, Value);
} else { }
else {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -916,7 +941,8 @@ void CSettings::SaveString ( SettingID Type, const stdstr & Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else {
FindInfo->second->Save(0, Value); FindInfo->second->Save(0, Value);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -933,7 +959,8 @@ void CSettings::SaveString ( SettingID Type, const char * Buffer )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else {
FindInfo->second->Save(0, Buffer); FindInfo->second->Save(0, Buffer);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -950,7 +977,8 @@ void CSettings::SaveStringIndex( SettingID Type, int index, const char * Buffer
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
FindInfo->second->Save(index, Buffer); FindInfo->second->Save(index, Buffer);
} else { }
else {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -972,7 +1000,8 @@ void CSettings::DeleteSetting( SettingID Type )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else {
FindInfo->second->Delete(0); FindInfo->second->Delete(0);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -989,7 +1018,8 @@ void CSettings::DeleteSettingIndex( SettingID Type, int index )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
FindInfo->second->Delete(index); FindInfo->second->Delete(index);
} else { }
else {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -1067,7 +1097,8 @@ void CSettings::RegisterChangeCB(SettingID Type,void * Data, SettingChangedFunc
item = item->Next; item = item->Next;
} }
item->Next = new_item; item->Next = new_item;
} else { }
else {
m_Callback.insert(SETTING_CALLBACK::value_type(Type, new_item)); m_Callback.insert(SETTING_CALLBACK::value_type(Type, new_item));
} }
} }
@ -1096,10 +1127,12 @@ void CSettings::UnregisterChangeCB(SettingID Type,void * Data, SettingChangedFun
SETTING_CHANGED_CB * Next = item->Next; SETTING_CHANGED_CB * Next = item->Next;
m_Callback.erase(Callback); m_Callback.erase(Callback);
m_Callback.insert(SETTING_CALLBACK::value_type(Type, Next)); m_Callback.insert(SETTING_CALLBACK::value_type(Type, Next));
} else { }
else {
m_Callback.erase(Callback); m_Callback.erase(Callback);
} }
} else { }
else {
PrevItem->Next = item->Next; PrevItem->Next = item->Next;
} }
delete item; delete item;
@ -1109,7 +1142,8 @@ void CSettings::UnregisterChangeCB(SettingID Type,void * Data, SettingChangedFun
PrevItem = item; PrevItem = item;
item = item->Next; item = item->Next;
} }
} else { }
else {
UnknownSetting(Type); UnknownSetting(Type);
return; return;
} }

View File

@ -105,6 +105,7 @@ enum SettingID
//Individual Game Settings //Individual Game Settings
Game_IniKey, Game_IniKey,
Game_File,
Game_GameName, Game_GameName,
Game_GoodName, Game_GoodName,
Game_TempLoaded, Game_TempLoaded,

View File

@ -50,6 +50,7 @@ m_ResetInfo(NULL)
g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged);
g_Settings->RegisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); g_Settings->RegisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged);
g_Settings->RegisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded);
} }
//if this fails then it has already been created //if this fails then it has already been created
@ -66,6 +67,7 @@ CMainGui::~CMainGui(void)
g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged);
g_Settings->UnregisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); g_Settings->UnregisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged);
g_Settings->UnregisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded);
} }
if (m_hMainWindow) if (m_hMainWindow)
{ {
@ -118,6 +120,19 @@ void CMainGui::LoadingInProgressChanged(CMainGui * Gui)
Gui->RefreshMenu(); Gui->RefreshMenu();
} }
void CMainGui::GameLoaded(CMainGui * Gui)
{
stdstr FileLoc = g_Settings->LoadStringVal(Game_File);
if (FileLoc.length() > 0)
{
WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom");
Notify().AddRecentRom(FileLoc.c_str());
Notify().SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str());
Gui->HideRomList();
}
}
void RomBowserColoumnsChanged(CMainGui * Gui) void RomBowserColoumnsChanged(CMainGui * Gui)
{ {
Gui->ResetRomBrowserColomuns(); Gui->ResetRomBrowserColomuns();

View File

@ -112,6 +112,7 @@ private:
friend void RomBowserColoumnsChanged(CMainGui * Gui); friend void RomBowserColoumnsChanged(CMainGui * Gui);
friend void RomBrowserRecursiveChanged(CMainGui * Gui); friend void RomBrowserRecursiveChanged(CMainGui * Gui);
static void LoadingInProgressChanged(CMainGui * Gui); static void LoadingInProgressChanged(CMainGui * Gui);
static void GameLoaded(CMainGui * Gui);
CBaseMenu * m_Menu; CBaseMenu * m_Menu;