From 47b012bd4a6485be3eedf678aa0ab9575a98d9b0 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 4 Jun 2016 19:07:20 +1000 Subject: [PATCH] [Project64] Add Debug languages --- .../Multilanguage/LanguageClass.cpp | 27 ++++++++++++++----- Source/Project64-core/Settings/Settings.h | 1 + .../Project64-core/Settings/SettingsClass.cpp | 1 + .../Project64/UserInterface/MainMenuClass.cpp | 12 +++++++++ .../Project64/UserInterface/MainMenuClass.h | 2 +- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Source/Project64-core/Multilanguage/LanguageClass.cpp b/Source/Project64-core/Multilanguage/LanguageClass.cpp index 2a4bd46f9..fa1dc34d2 100644 --- a/Source/Project64-core/Multilanguage/LanguageClass.cpp +++ b/Source/Project64-core/Multilanguage/LanguageClass.cpp @@ -501,8 +501,8 @@ void CLanguage::LoadDefaultStrings(void) } CLanguage::CLanguage() : -m_emptyString(""), -m_LanguageLoaded(false) + m_emptyString(""), + m_LanguageLoaded(false) { LoadDefaultStrings(); if (g_Settings) @@ -513,12 +513,18 @@ m_LanguageLoaded(false) bool CLanguage::LoadCurrentStrings(void) { - LanguageList LangList = GetLangList(); - stdstr Filename; - //clear all the current strings loaded m_CurrentStrings.clear(); + if (g_Settings->LoadBool(Debugger_DebugLanguage)) + { + m_LanguageLoaded = true; + return true; + } + + LanguageList LangList = GetLangList(); + stdstr Filename; + //Find the file name of the current language for (LanguageList::iterator Language = LangList.begin(); Language != LangList.end(); Language++) { @@ -599,6 +605,15 @@ const std::string & CLanguage::GetString(LanguageStringID StringID) return CurrentString->second; } + if (g_Settings->LoadBool(Debugger_DebugLanguage)) + { + std::pair ret = m_CurrentStrings.insert(LANG_STRINGS::value_type(StringID, stdstr_f("#%d#", StringID))); + if (ret.second) + { + return ret.first->second; + } + } + LANG_STRINGS::iterator DefString = m_DefaultStrings.find(StringID); if (DefString != m_DefaultStrings.end()) { @@ -645,7 +660,7 @@ std::string CLanguage::GetLangString(const char * FileName, LanguageStringID ID) LANG_STR CLanguage::GetNextLangString(void * OpenFile) { - enum { MAX_STRING_LEN = 400 }; + enum { MAX_STRING_LEN = 800 }; int32_t StringID; char szString[MAX_STRING_LEN]; //temp store the string from the file diff --git a/Source/Project64-core/Settings/Settings.h b/Source/Project64-core/Settings/Settings.h index b22624403..d96093432 100644 --- a/Source/Project64-core/Settings/Settings.h +++ b/Source/Project64-core/Settings/Settings.h @@ -216,6 +216,7 @@ enum SettingID Debugger_AppLogFlush, Debugger_ShowDListAListCount, Debugger_ShowRecompMemSize, + Debugger_DebugLanguage, //Trace Debugger_TraceMD5, diff --git a/Source/Project64-core/Settings/SettingsClass.cpp b/Source/Project64-core/Settings/SettingsClass.cpp index 856f53453..be5090d37 100644 --- a/Source/Project64-core/Settings/SettingsClass.cpp +++ b/Source/Project64-core/Settings/SettingsClass.cpp @@ -292,6 +292,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(Debugger_DisableGameFixes, new CSettingTypeApplication("Debugger", "Disable Game Fixes", false)); AddHandler(Debugger_ShowDListAListCount, new CSettingTypeApplication("Debugger", "Show Dlist Alist Count", false)); AddHandler(Debugger_ShowRecompMemSize, new CSettingTypeApplication("Debugger", "Show Recompiler Memory size", false)); + AddHandler(Debugger_DebugLanguage, new CSettingTypeApplication("Debugger", "Debug Language", false)); AddHandler(Debugger_ShowDivByZero, new CSettingTypeApplication("Debugger", "Show Div by zero", false)); AddHandler(Debugger_ProfileCode, new CSettingTypeApplication("Debugger", "Profile Code", (uint32_t)false)); AddHandler(Debugger_AppLogFlush, new CSettingTypeApplication("Logging", "Log Auto Flush", (uint32_t)false)); diff --git a/Source/Project64/UserInterface/MainMenuClass.cpp b/Source/Project64/UserInterface/MainMenuClass.cpp index a33172fcf..15fb48272 100644 --- a/Source/Project64/UserInterface/MainMenuClass.cpp +++ b/Source/Project64/UserInterface/MainMenuClass.cpp @@ -25,6 +25,7 @@ CMainMenu::CMainMenu(CMainGui * hMainWindow) : m_ChangeSettingList.push_back(Debugger_ShowUnhandledMemory); m_ChangeSettingList.push_back(Debugger_ShowPifErrors); m_ChangeSettingList.push_back(Debugger_ShowDListAListCount); + m_ChangeSettingList.push_back(Debugger_DebugLanguage); m_ChangeSettingList.push_back(Debugger_ShowRecompMemSize); m_ChangeSettingList.push_back(Debugger_ShowDivByZero); m_ChangeSettingList.push_back(Debugger_GenerateLogFiles); @@ -486,6 +487,10 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI g_Notify->DisplayMessage(0, ""); g_Settings->SaveBool(Debugger_ShowDListAListCount, !g_Settings->LoadBool(Debugger_ShowDListAListCount)); break; + case ID_DEBUG_LANGUAGE: + g_Settings->SaveBool(Debugger_DebugLanguage, !g_Settings->LoadBool(Debugger_DebugLanguage)); + g_Lang->LoadCurrentStrings(); + break; case ID_DEBUG_SHOW_RECOMP_MEM_SIZE: g_Notify->DisplayMessage(0, ""); g_Settings->SaveBool(Debugger_ShowRecompMemSize, !g_Settings->LoadBool(Debugger_ShowRecompMemSize)); @@ -1205,12 +1210,19 @@ void CMainMenu::FillOutMenu(HMENU hMenu) { Item.SetItemTicked(true); } + DebugMenu.push_back(Item); Item.Reset(ID_DEBUG_SHOW_DLIST_COUNT, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Display Alist/Dlist Count"); if (g_Settings->LoadBool(Debugger_ShowDListAListCount)) { Item.SetItemTicked(true); } DebugMenu.push_back(Item); + Item.Reset(ID_DEBUG_LANGUAGE, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Debug Language"); + if (g_Settings->LoadBool(Debugger_DebugLanguage)) + { + Item.SetItemTicked(true); + } + DebugMenu.push_back(Item); Item.Reset(ID_DEBUG_SHOW_RECOMP_MEM_SIZE, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Display Recompiler Code Buffer Size"); if (g_Settings->LoadBool(Debugger_ShowRecompMemSize)) { diff --git a/Source/Project64/UserInterface/MainMenuClass.h b/Source/Project64/UserInterface/MainMenuClass.h index 6e187c9a7..71305ce03 100644 --- a/Source/Project64/UserInterface/MainMenuClass.h +++ b/Source/Project64/UserInterface/MainMenuClass.h @@ -35,7 +35,7 @@ enum MainMenuID //Debugger Menu ID_DEBUG_SHOW_TLB_MISSES, ID_DEBUG_SHOW_UNHANDLED_MEM, ID_DEBUG_SHOW_PIF_ERRORS, ID_DEBUG_SHOW_DLIST_COUNT, ID_DEBUG_SHOW_RECOMP_MEM_SIZE, ID_DEBUG_SHOW_DIV_BY_ZERO, - ID_DEBUG_GENERATE_LOG_FILES, ID_DEBUG_DISABLE_GAMEFIX, + ID_DEBUG_GENERATE_LOG_FILES, ID_DEBUG_DISABLE_GAMEFIX, ID_DEBUG_LANGUAGE, ID_DEBUGGER_LOGOPTIONS, ID_DEBUGGER_GENERATELOG, ID_DEBUGGER_DUMPMEMORY, ID_DEBUGGER_SEARCHMEMORY, ID_DEBUGGER_TLBENTRIES, ID_DEBUGGER_BREAKPOINTS, ID_DEBUGGER_MEMORY, ID_DEBUGGER_R4300REGISTERS, ID_DEBUGGER_INTERRUPT_SP, ID_DEBUGGER_INTERRUPT_SI, ID_DEBUGGER_INTERRUPT_AI, ID_DEBUGGER_INTERRUPT_VI,