2008-12-08 05:30:24 +00:00
|
|
|
// Copyright (C) 2003-2008 Dolphin Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
#include "Common.h"
|
|
|
|
#include "IniFile.h"
|
|
|
|
#include "Config.h"
|
2008-12-08 09:53:38 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <CoreFoundation/CFString.h>
|
|
|
|
#include <CoreFoundation/CFUrl.h>
|
|
|
|
#include <CoreFoundation/CFBundle.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
|
|
|
#endif
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
SConfig SConfig::m_Instance;
|
|
|
|
|
|
|
|
|
|
|
|
SConfig::SConfig()
|
|
|
|
{
|
|
|
|
LoadSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SConfig::~SConfig()
|
|
|
|
{
|
|
|
|
SaveSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SConfig::SaveSettings()
|
|
|
|
{
|
|
|
|
IniFile ini;
|
2008-12-10 02:41:55 +00:00
|
|
|
ini.Load(CONFIG_FILE); // yes we must load first to not kill unknown stuff
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
// misc
|
|
|
|
{
|
|
|
|
ini.Set("General", "LastFilename", m_LastFilename);
|
|
|
|
|
|
|
|
// ISO folders
|
|
|
|
ini.Set("General", "GCMPathes", (int)m_ISOFolder.size());
|
|
|
|
|
|
|
|
for (size_t i = 0; i < m_ISOFolder.size(); i++)
|
|
|
|
{
|
|
|
|
TCHAR tmp[16];
|
|
|
|
sprintf(tmp, "GCMPath%i", (int)i);
|
|
|
|
ini.Set("General", tmp, m_ISOFolder[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-23 11:24:11 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2009-01-04 21:53:41 +00:00
|
|
|
// General
|
|
|
|
ini.Set("Interface", "ConfirmStop", m_LocalCoreStartupParameter.bConfirmStop);
|
|
|
|
ini.Set("Interface", "HideCursor", m_LocalCoreStartupParameter.bHideCursor);
|
|
|
|
ini.Set("Interface", "AutoHideCursor", m_LocalCoreStartupParameter.bAutoHideCursor);
|
|
|
|
ini.Set("Interface", "Theme", m_LocalCoreStartupParameter.iTheme);
|
|
|
|
|
2008-12-23 11:24:11 +00:00
|
|
|
// Core
|
2008-12-08 05:30:24 +00:00
|
|
|
ini.Set("Core", "HLEBios", m_LocalCoreStartupParameter.bHLEBios);
|
|
|
|
ini.Set("Core", "UseDynarec", m_LocalCoreStartupParameter.bUseJIT);
|
|
|
|
ini.Set("Core", "UseDualCore", m_LocalCoreStartupParameter.bUseDualCore);
|
|
|
|
ini.Set("Core", "SkipIdle", m_LocalCoreStartupParameter.bSkipIdle);
|
|
|
|
ini.Set("Core", "LockThreads", m_LocalCoreStartupParameter.bLockThreads);
|
|
|
|
ini.Set("Core", "DefaultGCM", m_LocalCoreStartupParameter.m_strDefaultGCM);
|
|
|
|
ini.Set("Core", "DVDRoot", m_LocalCoreStartupParameter.m_strDVDRoot);
|
|
|
|
ini.Set("Core", "OptimizeQuantizers", m_LocalCoreStartupParameter.bOptimizeQuantizers);
|
|
|
|
ini.Set("Core", "EnableCheats", m_LocalCoreStartupParameter.bEnableCheats);
|
|
|
|
ini.Set("Core", "SelectedLanguage", m_LocalCoreStartupParameter.SelectedLanguage);
|
2008-12-23 11:24:11 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
ini.Set("Core", "RunCompareServer", m_LocalCoreStartupParameter.bRunCompareServer);
|
|
|
|
ini.Set("Core", "RunCompareClient", m_LocalCoreStartupParameter.bRunCompareClient);
|
2008-12-09 05:37:15 +00:00
|
|
|
|
2008-12-23 11:24:11 +00:00
|
|
|
// Wii
|
2008-12-09 05:37:15 +00:00
|
|
|
ini.Set("Wii", "ShowWiimoteLeds", m_LocalCoreStartupParameter.bWiiLeds);
|
|
|
|
ini.Set("Wii", "ShowWiimoteSpeakers", m_LocalCoreStartupParameter.bWiiSpeakers);
|
2008-12-23 11:24:11 +00:00
|
|
|
|
|
|
|
// Plugins
|
|
|
|
ini.Set("Core", "GFXPlugin", m_LocalCoreStartupParameter.m_strVideoPlugin);
|
|
|
|
ini.Set("Core", "DSPPlugin", m_LocalCoreStartupParameter.m_strDSPPlugin);
|
|
|
|
ini.Set("Core", "PadPlugin", m_LocalCoreStartupParameter.m_strPadPlugin);
|
|
|
|
ini.Set("Core", "WiiMotePlugin", m_LocalCoreStartupParameter.m_strWiimotePlugin);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ini.Save(CONFIG_FILE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SConfig::LoadSettings()
|
|
|
|
{
|
|
|
|
IniFile ini;
|
|
|
|
ini.Load(CONFIG_FILE);
|
2008-12-08 09:53:38 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
// Plugin path will be Dolphin.app/Contents/PlugIns
|
|
|
|
CFURLRef BundleRef, PluginDirRef;
|
|
|
|
// Get the main bundle for the app
|
|
|
|
BundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
|
|
|
PluginDirRef = CFBundleCopyBuiltInPlugInsURL(CFBundleGetMainBundle());
|
|
|
|
CFStringRef BundlePath = CFURLCopyFileSystemPath(BundleRef, kCFURLPOSIXPathStyle);
|
|
|
|
CFStringRef PluginDirPath = CFURLCopyFileSystemPath(PluginDirRef, kCFURLPOSIXPathStyle);
|
|
|
|
char AppBundlePath[MAXPATHLEN], PluginPath[MAXPATHLEN];
|
|
|
|
CFStringGetFileSystemRepresentation(BundlePath, AppBundlePath, sizeof(AppBundlePath));
|
|
|
|
CFStringGetFileSystemRepresentation(PluginDirPath, PluginPath, sizeof(PluginPath));
|
|
|
|
// printf("bundle path = %s %s\n", AppBundlePath, PluginPath);
|
|
|
|
CFRelease(BundleRef);
|
|
|
|
CFRelease(BundlePath);
|
|
|
|
CFRelease(PluginDirRef);
|
|
|
|
CFRelease(PluginDirPath);
|
|
|
|
std::string PluginsDir = AppBundlePath;
|
|
|
|
PluginsDir += DIR_SEP;
|
|
|
|
PluginsDir += PluginPath;
|
|
|
|
PluginsDir += DIR_SEP;
|
|
|
|
|
|
|
|
m_DefaultGFXPlugin = PluginsDir + DEFAULT_GFX_PLUGIN;
|
|
|
|
m_DefaultDSPPlugin = PluginsDir + DEFAULT_DSP_PLUGIN;
|
|
|
|
m_DefaultPADPlugin = PluginsDir + DEFAULT_PAD_PLUGIN;
|
|
|
|
m_DefaultWiiMotePlugin = PluginsDir + DEFAULT_WIIMOTE_PLUGIN;
|
|
|
|
|
|
|
|
#else
|
2008-12-23 11:24:11 +00:00
|
|
|
// Hard coded default plugin
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-23 11:24:11 +00:00
|
|
|
m_DefaultGFXPlugin = PLUGINS_DIR DIR_SEP DEFAULT_GFX_PLUGIN;
|
|
|
|
m_DefaultDSPPlugin = PLUGINS_DIR DIR_SEP DEFAULT_DSP_PLUGIN;
|
|
|
|
m_DefaultPADPlugin = PLUGINS_DIR DIR_SEP DEFAULT_PAD_PLUGIN;
|
|
|
|
m_DefaultWiiMotePlugin = PLUGINS_DIR DIR_SEP DEFAULT_WIIMOTE_PLUGIN;
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2008-12-08 09:53:38 +00:00
|
|
|
#endif
|
2008-12-23 11:24:11 +00:00
|
|
|
// Misc
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
|
|
|
ini.Get("General", "LastFilename", &m_LastFilename);
|
|
|
|
|
|
|
|
m_ISOFolder.clear();
|
|
|
|
int numGCMPaths;
|
|
|
|
|
|
|
|
if (ini.Get("General", "GCMPathes", &numGCMPaths, 0))
|
|
|
|
{
|
|
|
|
for (int i = 0; i < numGCMPaths; i++)
|
|
|
|
{
|
|
|
|
TCHAR tmp[16];
|
|
|
|
sprintf(tmp, "GCMPath%i", i);
|
|
|
|
std::string tmpPath;
|
|
|
|
ini.Get("General", tmp, &tmpPath, "");
|
|
|
|
m_ISOFolder.push_back(tmpPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2009-01-04 21:53:41 +00:00
|
|
|
// General interfance
|
|
|
|
ini.Get("Interface", "ConfirmStop", &m_LocalCoreStartupParameter.bConfirmStop, false);
|
|
|
|
ini.Get("Interface", "HideCursor", &m_LocalCoreStartupParameter.bHideCursor, false);
|
|
|
|
ini.Get("Interface", "AutoHideCursor", &m_LocalCoreStartupParameter.bAutoHideCursor, false);
|
|
|
|
ini.Get("Interface", "Theme", &m_LocalCoreStartupParameter.iTheme, 0);
|
|
|
|
|
2008-12-23 11:24:11 +00:00
|
|
|
// Core
|
2008-12-08 05:30:24 +00:00
|
|
|
ini.Get("Core", "HLEBios", &m_LocalCoreStartupParameter.bHLEBios, true);
|
|
|
|
ini.Get("Core", "UseDynarec", &m_LocalCoreStartupParameter.bUseJIT, true);
|
|
|
|
ini.Get("Core", "UseDualCore", &m_LocalCoreStartupParameter.bUseDualCore, false);
|
|
|
|
ini.Get("Core", "SkipIdle", &m_LocalCoreStartupParameter.bSkipIdle, true);
|
|
|
|
ini.Get("Core", "LockThreads", &m_LocalCoreStartupParameter.bLockThreads, true);
|
|
|
|
ini.Get("Core", "DefaultGCM", &m_LocalCoreStartupParameter.m_strDefaultGCM);
|
|
|
|
ini.Get("Core", "DVDRoot", &m_LocalCoreStartupParameter.m_strDVDRoot);
|
|
|
|
ini.Get("Core", "OptimizeQuantizers", &m_LocalCoreStartupParameter.bOptimizeQuantizers, true);
|
|
|
|
ini.Get("Core", "EnableCheats", &m_LocalCoreStartupParameter.bEnableCheats, false);
|
|
|
|
ini.Get("Core", "SelectedLanguage", &m_LocalCoreStartupParameter.SelectedLanguage, 0);
|
2008-12-23 11:24:11 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
ini.Get("Core", "RunCompareServer", &m_LocalCoreStartupParameter.bRunCompareServer, false);
|
|
|
|
ini.Get("Core", "RunCompareClient", &m_LocalCoreStartupParameter.bRunCompareClient, false);
|
2008-12-09 05:37:15 +00:00
|
|
|
|
2008-12-23 11:24:11 +00:00
|
|
|
// Wii
|
2008-12-09 05:37:15 +00:00
|
|
|
ini.Get("Wii", "ShowWiimoteLeds", &m_LocalCoreStartupParameter.bWiiLeds, false);
|
|
|
|
ini.Get("Wii", "ShowWiimoteSpeakers", &m_LocalCoreStartupParameter.bWiiSpeakers, false);
|
2008-12-23 11:24:11 +00:00
|
|
|
|
|
|
|
// Plugins
|
|
|
|
ini.Get("Core", "GFXPlugin", &m_LocalCoreStartupParameter.m_strVideoPlugin, m_DefaultGFXPlugin.c_str());
|
|
|
|
ini.Get("Core", "DSPPlugin", &m_LocalCoreStartupParameter.m_strDSPPlugin, m_DefaultDSPPlugin.c_str());
|
|
|
|
ini.Get("Core", "PadPlugin", &m_LocalCoreStartupParameter.m_strPadPlugin, m_DefaultPADPlugin.c_str());
|
|
|
|
ini.Get("Core", "WiiMotePlugin", &m_LocalCoreStartupParameter.m_strWiimotePlugin, m_DefaultWiiMotePlugin.c_str());
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|