From f22af37320d71a4f78b3f5a7138bc00be57fc1a8 Mon Sep 17 00:00:00 2001 From: nakeee Date: Fri, 20 Mar 2009 11:51:22 +0000 Subject: [PATCH] Trying to make gameini support some gl options git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2687 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/IniFile.cpp | 21 +++++++++++++++++ Source/Core/Common/Src/IniFile.h | 3 +++ Source/Core/Core/Src/ConfigManager.h | 6 ++--- Source/Core/Core/Src/CoreParameter.cpp | 2 ++ Source/Core/Core/Src/CoreParameter.h | 4 ++++ Source/Core/DolphinWX/Src/BootManager.cpp | 21 ++++++++++------- Source/Plugins/Plugin_DSP_HLE/Src/Config.h | 6 ++--- Source/Plugins/Plugin_VideoOGL/Src/Config.cpp | 23 +++++++++++++++++++ Source/Plugins/Plugin_VideoOGL/Src/Config.h | 7 +++--- Source/Plugins/Plugin_VideoOGL/Src/Globals.h | 4 +--- Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 2 ++ Source/Plugins/Plugin_Wiimote/Src/Config.h | 6 ++--- Source/Plugins/Plugin_nJoy_SDL/Src/Config.h | 6 ++--- 13 files changed, 85 insertions(+), 26 deletions(-) diff --git a/Source/Core/Common/Src/IniFile.cpp b/Source/Core/Common/Src/IniFile.cpp index 121736fe1a..7c39cb2200 100644 --- a/Source/Core/Common/Src/IniFile.cpp +++ b/Source/Core/Common/Src/IniFile.cpp @@ -171,6 +171,27 @@ std::string* IniFile::GetLine(Section* section, const char* key, std::string* va return 0; } +bool IniFile::Exists(const char* sectionName, const char* key) +{ + + const Section* section = GetSection(sectionName); + if (!section) + return false; + + for (std::vector::const_iterator iter = section->lines.begin(); iter != section->lines.end(); ++iter) + { + std::string lineKey; + ParseLine(*iter, &lineKey, NULL, NULL); + + if (!strcasecmp(lineKey.c_str(), key)) + { + return true; + } + } + + return false; +} + void IniFile::SetLines(const char* sectionName, const std::vector &lines) { Section* section = GetOrCreateSection(sectionName); diff --git a/Source/Core/Common/Src/IniFile.h b/Source/Core/Common/Src/IniFile.h index 767f554c3b..04f6aab246 100644 --- a/Source/Core/Common/Src/IniFile.h +++ b/Source/Core/Common/Src/IniFile.h @@ -57,6 +57,9 @@ public: void SetLines(const char* sectionName, const std::vector &lines); + // Returns true if exists key in section + bool Exists(const char* sectionName, const char* key); + // getter should be const bool Get(const char* sectionName, const char* key, std::string* value, const char* defaultValue = ""); bool Get(const char* sectionName, const char* key, int* value, int defaultValue = 0); diff --git a/Source/Core/Core/Src/ConfigManager.h b/Source/Core/Core/Src/ConfigManager.h index ba5c66fcf4..e4f098fb3a 100644 --- a/Source/Core/Core/Src/ConfigManager.h +++ b/Source/Core/Core/Src/ConfigManager.h @@ -15,8 +15,8 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#ifndef _CONFIG_H -#define _CONFIG_H +#ifndef _CONFIGMANAGER_H +#define _CONFIGMANAGER_H #include #include @@ -88,4 +88,4 @@ struct SConfig static SConfig m_Instance; }; -#endif +#endif // endif config manager diff --git a/Source/Core/Core/Src/CoreParameter.cpp b/Source/Core/Core/Src/CoreParameter.cpp index 192d972740..db1e3ed141 100644 --- a/Source/Core/Core/Src/CoreParameter.cpp +++ b/Source/Core/Core/Src/CoreParameter.cpp @@ -45,6 +45,8 @@ void SCoreStartupParameter::LoadDefaults() bWii = false; SelectedLanguage = 0; iTLBHack = 0; + delete gameIni; + gameIni = NULL; bJITOff = false; // debugger only settings bJITLoadStoreOff = false; diff --git a/Source/Core/Core/Src/CoreParameter.h b/Source/Core/Core/Src/CoreParameter.h index 12e84776aa..76902d4b2b 100644 --- a/Source/Core/Core/Src/CoreParameter.h +++ b/Source/Core/Core/Src/CoreParameter.h @@ -22,6 +22,7 @@ #include #endif +#include "IniFile.h" #include #define MAXPADS 4 @@ -36,6 +37,9 @@ struct SCoreStartupParameter // Windows/GUI related void* hMainWindow; + // game ini + IniFile *gameIni; + // Settings bool bEnableDebugging; bool bAutomaticStart; bool bBootToPause; bool bUseJIT; diff --git a/Source/Core/DolphinWX/Src/BootManager.cpp b/Source/Core/DolphinWX/Src/BootManager.cpp index 5b8c2bc9c3..3ea75aae0d 100644 --- a/Source/Core/DolphinWX/Src/BootManager.cpp +++ b/Source/Core/DolphinWX/Src/BootManager.cpp @@ -122,17 +122,19 @@ bool BootCore(const std::string& _rFilename) // ==================================================== // Load game specific settings // ---------------- - IniFile ini; + // Released when you LoadDefaults + IniFile *ini = new IniFile(); std::string unique_id = StartUp.GetUniqueID(); - if (unique_id.size() == 6 && ini.Load((FULL_GAMECONFIG_DIR + unique_id + ".ini").c_str())) + if (unique_id.size() == 6 && ini->Load((FULL_GAMECONFIG_DIR + unique_id + ".ini").c_str())) { + StartUp.gameIni = ini; // ------------------------------------------------ // General settings // ---------------- - ini.Get("Core", "UseDualCore", &StartUp.bUseDualCore, StartUp.bUseDualCore); - ini.Get("Core", "SkipIdle", &StartUp.bSkipIdle, StartUp.bSkipIdle); - ini.Get("Core", "OptimizeQuantizers", &StartUp.bOptimizeQuantizers, StartUp.bOptimizeQuantizers); - ini.Get("Core", "TLBHack", &StartUp.iTLBHack, StartUp.iTLBHack); + ini->Get("Core", "UseDualCore", &StartUp.bUseDualCore, StartUp.bUseDualCore); + ini->Get("Core", "SkipIdle", &StartUp.bSkipIdle, StartUp.bSkipIdle); + ini->Get("Core", "OptimizeQuantizers", &StartUp.bOptimizeQuantizers, StartUp.bOptimizeQuantizers); + ini->Get("Core", "TLBHack", &StartUp.iTLBHack, StartUp.iTLBHack); // ------------------------------------------------ // Wii settings @@ -144,8 +146,8 @@ bool BootCore(const std::string& _rFilename) u16 IPL_PGS = 0x17CC; // progressive scan u16 IPL_AR = 0x04D9; // widescreen - ini.Get("Wii", "ProgressiveScan", &StartUp.bProgressiveScan, StartUp.bProgressiveScan); - ini.Get("Wii", "Widescreen", &StartUp.bWidescreen, StartUp.bWidescreen); + ini->Get("Wii", "ProgressiveScan", &StartUp.bProgressiveScan, StartUp.bProgressiveScan); + ini->Get("Wii", "Widescreen", &StartUp.bWidescreen, StartUp.bWidescreen); // Save the update Wii SYSCONF settings pStream = NULL; @@ -164,6 +166,9 @@ bool BootCore(const std::string& _rFilename) } } // --------------- + } else { + delete ini; + ini = NULL; } // ===================== diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/Config.h b/Source/Plugins/Plugin_DSP_HLE/Src/Config.h index 5ddaa6fc33..a255b52c7d 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/Config.h +++ b/Source/Plugins/Plugin_DSP_HLE/Src/Config.h @@ -15,8 +15,8 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#ifndef _CONFIG_H -#define _CONFIG_H +#ifndef _PLUGIN_DSP_HLE_CONFIG_H +#define _PLUGIN_DSP_HLE_CONFIG_H #include @@ -36,5 +36,5 @@ struct CConfig extern CConfig g_Config; -#endif +#endif // _PLUGIN_DSP_HLE_CONFIG_H diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp index 602e7e59cf..55443a6d51 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp @@ -19,6 +19,7 @@ #include "Common.h" #include "IniFile.h" #include "Config.h" +#include "ConfigManager.h" Config g_Config; @@ -79,6 +80,27 @@ void Config::Load() iniFile.Get("Hacks", "EFBToTextureEnable", &bCopyEFBToRAM, 0); } +void Config::GameIniLoad() { + IniFile *iniFile = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.gameIni; + if (iniFile->Exists("Video", "ForceFiltering")) + iniFile->Get("Video", "ForceFiltering", &bForceFiltering, 0); + + if (iniFile->Exists("Video", "MaxAnisotropy")) + iniFile->Get("Video", "MaxAnisotropy", &iMaxAnisotropy, 3); // NOTE - this is x in (1 << x) + + if (iniFile->Exists("Video", "EFBCopyDisable")) + iniFile->Get("Video", "EFBCopyDisable", &bEFBCopyDisable, 0); + + if (iniFile->Exists("Video", "EFBCopyDisableHotKey")) + iniFile->Get("Video", "EFBCopyDisableHotKey", &bEFBCopyDisableHotKey, 0); + + if (iniFile->Exists("Video", "ProjectionHax1")) + iniFile->Get("Video", "ProjectionHax1", &bProjectionHax1, 0); + + if (iniFile->Exists("Video", "EFBToTextureEnable")) + iniFile->Get("Video", "EFBToTextureEnable", &bCopyEFBToRAM, 0); +} + void Config::Save() { IniFile iniFile; @@ -125,3 +147,4 @@ void Config::Save() iniFile.Save(FULL_CONFIG_DIR "gfx_opengl.ini"); } + diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Config.h b/Source/Plugins/Plugin_VideoOGL/Src/Config.h index 1196fed812..93e0c8ca3a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Config.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Config.h @@ -15,8 +15,8 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#ifndef _CONFIG_H -#define _CONFIG_H +#ifndef _PLUGIN_VIDEOOGL_CONFIG_H +#define _PLUGIN_VIDEOOGL_CONFIG_H #include "Common.h" @@ -43,6 +43,7 @@ struct Config { Config(); void Load(); + void GameIniLoad(); void Save(); // General @@ -104,4 +105,4 @@ private: extern Config g_Config; -#endif // _CONFIG_H +#endif // _PLUGIN_VIDEOOGL_CONFIG_H diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h index d229998bc5..9e23d02fe7 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h @@ -23,11 +23,9 @@ #include "VideoCommon.h" #include "pluginspecs_video.h" +#include "ConfigManager.h" // A global plugin specification extern PLUGIN_GLOBALS* globals; -//void OpenConsole(); -//void CloseConsole(); - #endif // _GLOBALS_H diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index d9cc9ea40d..46a3ee6f6e 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -228,6 +228,8 @@ void Initialize(void *init) InitXFBConvTables(); g_Config.Load(); + g_Config.GameIniLoad(); + if (!OpenGL_Create(g_VideoInitialize, 640, 480)) // 640x480 will be the default if all else fails { g_VideoInitialize.pLog("Renderer::Create failed\n", TRUE); diff --git a/Source/Plugins/Plugin_Wiimote/Src/Config.h b/Source/Plugins/Plugin_Wiimote/Src/Config.h index 2366c69e84..03018c384f 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Config.h +++ b/Source/Plugins/Plugin_Wiimote/Src/Config.h @@ -15,8 +15,8 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#ifndef _CONFIG_H -#define _CONFIG_H +#ifndef _PLUGIN_WIIMOTE_CONFIG_H +#define _PLUGIN_WIIMOTE_CONFIG_H struct Config @@ -91,4 +91,4 @@ struct Config extern Config g_Config; -#endif // _CONFIG_H +#endif // _PLUGIN_WIIMOTE_CONFIG_H diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/Config.h b/Source/Plugins/Plugin_nJoy_SDL/Src/Config.h index bf14deeb39..a423eb6d12 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/Config.h +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/Config.h @@ -15,8 +15,8 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#ifndef _CONFIG_H -#define _CONFIG_H +#ifndef _PLUGIN_NJOY_SDL_CONFIG_H +#define _PLUGIN_NJOY_SDL_CONFIG_H struct Config { @@ -38,4 +38,4 @@ struct Config extern Config g_Config; -#endif // _CONFIG_H +#endif // _PLUGIN_NJOY_SDL_CONFIG_H