mirror of
https://github.com/blawar/GLideN64.git
synced 2024-06-25 22:09:35 +00:00
Switch to settings file.
This commit is contained in:
parent
2b55125978
commit
2f7ad0180a
|
@ -11,14 +11,15 @@
|
|||
|
||||
#include "Settings.h"
|
||||
|
||||
void loadSettings()
|
||||
void loadSettings(const QString & _strFileName)
|
||||
{
|
||||
QSettings settings("Emulation", "GLideN64");
|
||||
// QSettings settings("Emulation", "GLideN64");
|
||||
QSettings settings(_strFileName, QSettings::IniFormat);
|
||||
config.version = settings.value("version").toInt();
|
||||
if (config.version != CONFIG_VERSION_CURRENT) {
|
||||
config.resetToDefaults();
|
||||
settings.clear();
|
||||
writeSettings();
|
||||
writeSettings(_strFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -100,9 +101,10 @@ void loadSettings()
|
|||
settings.endGroup();
|
||||
}
|
||||
|
||||
void writeSettings()
|
||||
void writeSettings(const QString & _strFileName)
|
||||
{
|
||||
QSettings settings("Emulation", "GLideN64");
|
||||
// QSettings settings("Emulation", "GLideN64");
|
||||
QSettings settings(_strFileName, QSettings::IniFormat);
|
||||
settings.setValue("version", config.version);
|
||||
|
||||
settings.beginGroup("video");
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
void loadSettings();
|
||||
void writeSettings();
|
||||
void loadSettings(const QString & _strFileName);
|
||||
void writeSettings(const QString & _strFileName);
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@ void ConfigDialog::accept()
|
|||
config.bloomFilter.blurAmount = ui->blurAmountSlider->value();
|
||||
config.bloomFilter.blurStrength = ui->blurStrengthSlider->value();
|
||||
|
||||
writeSettings();
|
||||
writeSettings(m_strIniPath);
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@ public:
|
|||
explicit ConfigDialog(QWidget *parent = 0);
|
||||
~ConfigDialog();
|
||||
|
||||
bool isAccepted() const {return m_accepted;}
|
||||
void setIniPath(const QString & _strIniPath) { m_strIniPath = _strIniPath; }
|
||||
bool isAccepted() const { return m_accepted; }
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void accept();
|
||||
|
@ -39,6 +40,7 @@ private:
|
|||
QFont m_font;
|
||||
QColor m_color;
|
||||
bool m_accepted;
|
||||
QString m_strIniPath;
|
||||
};
|
||||
|
||||
#endif // CONFIGDIALOG_H
|
||||
|
|
|
@ -15,17 +15,20 @@ inline void initMyResource() { Q_INIT_RESOURCE(icon); }
|
|||
inline void cleanMyResource() { Q_CLEANUP_RESOURCE(icon); }
|
||||
|
||||
static
|
||||
int openConfigDialog(bool & _accepted)
|
||||
int openConfigDialog(const wchar_t * _strFileName, bool & _accepted)
|
||||
{
|
||||
cleanMyResource();
|
||||
initMyResource();
|
||||
loadSettings();
|
||||
QString strIniFileName = QString::fromWCharArray(_strFileName);
|
||||
loadSettings(strIniFileName);
|
||||
|
||||
int argc = 0;
|
||||
char * argv = 0;
|
||||
QApplication a(argc, &argv);
|
||||
|
||||
ConfigDialog w;
|
||||
|
||||
w.setIniPath(strIniFileName);
|
||||
w.show();
|
||||
const int res = a.exec();
|
||||
_accepted = w.isAccepted();
|
||||
|
@ -47,9 +50,9 @@ int openAboutDialog()
|
|||
return a.exec();
|
||||
}
|
||||
|
||||
bool runConfigThread() {
|
||||
bool runConfigThread(const wchar_t * _strFileName) {
|
||||
bool accepted = false;
|
||||
std::thread configThread(openConfigDialog, std::ref(accepted));
|
||||
std::thread configThread(openConfigDialog, _strFileName, std::ref(accepted));
|
||||
configThread.join();
|
||||
return accepted;
|
||||
}
|
||||
|
@ -60,9 +63,9 @@ int runAboutThread() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
EXPORT bool CALL RunConfig()
|
||||
EXPORT bool CALL RunConfig(const wchar_t * _strFileName)
|
||||
{
|
||||
return runConfigThread();
|
||||
return runConfigThread(_strFileName);
|
||||
}
|
||||
|
||||
EXPORT int CALL RunAbout()
|
||||
|
@ -70,7 +73,7 @@ EXPORT int CALL RunAbout()
|
|||
return runAboutThread();
|
||||
}
|
||||
|
||||
EXPORT void CALL LoadConfig()
|
||||
EXPORT void CALL LoadConfig(const wchar_t * _strFileName)
|
||||
{
|
||||
loadSettings();
|
||||
loadSettings(QString::fromWCharArray(_strFileName));
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@ extern "C" {
|
|||
#define CALL _cdecl
|
||||
#endif
|
||||
|
||||
EXPORT bool CALL RunConfig();
|
||||
EXPORT bool CALL RunConfig(const wchar_t * _strFileName);
|
||||
EXPORT int CALL RunAbout();
|
||||
EXPORT void CALL LoadConfig();
|
||||
EXPORT void CALL LoadConfig(const wchar_t * _strFileName);
|
||||
EXPORT void CALL SaveScreenshot(const char * _folder, const char * _name, int _width, int _height, const unsigned char * _data);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
<ExceptionHandling>Sync</ExceptionHandling>
|
||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<PreprocessorDefinitions>OS_WINDOWS;_WINDOWS;UNICODE;WIN32;QT_NO_DEBUG;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>OS_WINDOWS;_WINDOWS;UNICODE;WIN32;QT_NO_DEBUG;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;NDEBUG;QT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessToFile>false</PreprocessToFile>
|
||||
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
|
@ -98,7 +98,7 @@
|
|||
<ExceptionHandling>Sync</ExceptionHandling>
|
||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;OS_WINDOWS;_WINDOWS;UNICODE;WIN32;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_DEBUG;OS_WINDOWS;_WINDOWS;UNICODE;WIN32;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessToFile>false</PreprocessToFile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
|
@ -242,7 +242,7 @@ endlocal
|
|||
<ImportGroup Label="ExtensionTargets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties UicDir=".\GeneratedFiles" RccDir=".\GeneratedFiles" Qt5Version_x0020_Win32="qt-5_4_0-x86-msvc2013-static-release" />
|
||||
<UserProperties UicDir=".\GeneratedFiles" RccDir=".\GeneratedFiles" Qt5Version_x0020_Win32="5_4_msvc" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
|
@ -13,6 +13,7 @@
|
|||
#include "../RSP.h"
|
||||
#include "../RDP.h"
|
||||
#include "../VI.h"
|
||||
#include "../Config.h"
|
||||
#include "../Debug.h"
|
||||
#include "../Log.h"
|
||||
|
||||
|
@ -22,6 +23,7 @@ void RSP_ThreadProc(std::mutex * _pRspThreadMtx, std::mutex * _pPluginThreadMtx,
|
|||
_pRspThreadMtx->lock();
|
||||
RSP_Init();
|
||||
GBI.init();
|
||||
Config_LoadConfig();
|
||||
video().start();
|
||||
TFH.init();
|
||||
assert(!isGLError());
|
||||
|
@ -119,6 +121,7 @@ void PluginAPI::RomOpen()
|
|||
#else
|
||||
RSP_Init();
|
||||
GBI.init();
|
||||
Config_LoadConfig();
|
||||
video().start();
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
#include "../PluginAPI.h"
|
||||
#include "../OpenGL.h"
|
||||
#include "../Config.h"
|
||||
#include "../RSP.h"
|
||||
|
||||
int PluginAPI::InitiateGFX(const GFX_INFO & _gfxInfo)
|
||||
{
|
||||
_initiateGFX(_gfxInfo);
|
||||
|
||||
Config_LoadConfig();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "../GLideN64.h"
|
||||
#include "../Resource.h"
|
||||
#include "../RSP.h"
|
||||
#include "../PluginAPI.h"
|
||||
#include "../Textures.h"
|
||||
#include "../OpenGL.h"
|
||||
#include "../GLideNUI/GLideNUI.h"
|
||||
|
@ -396,14 +397,26 @@ void Config_DoConfig(HWND hParent)
|
|||
RunConfig(hInstance);
|
||||
}
|
||||
#else // LEGACY_UI
|
||||
static
|
||||
void _getIniFileName(wchar_t * _buf)
|
||||
{
|
||||
api().FindPluginPath(_buf);
|
||||
wcscat(_buf, L"/GLideN64.ini");
|
||||
}
|
||||
|
||||
void Config_DoConfig(HWND hParent)
|
||||
{
|
||||
if (RunConfig())
|
||||
wchar_t strIniFileName[PLUGIN_PATH_SIZE];
|
||||
_getIniFileName(strIniFileName);
|
||||
|
||||
if (RunConfig(strIniFileName))
|
||||
video().restart();
|
||||
}
|
||||
|
||||
void Config_LoadConfig()
|
||||
{
|
||||
LoadConfig();
|
||||
wchar_t strIniFileName[PLUGIN_PATH_SIZE];
|
||||
_getIniFileName(strIniFileName);
|
||||
LoadConfig(strIniFileName);
|
||||
}
|
||||
#endif // LEGACY_UI
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "GLideN64_Windows.h"
|
||||
#include "../OpenGL.h"
|
||||
#include "../Config.h"
|
||||
|
||||
HWND hWnd;
|
||||
HWND hStatusBar;
|
||||
|
@ -11,7 +10,5 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID /*lpvReserved*/)
|
|||
{
|
||||
hInstance = hinstDLL;
|
||||
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
Config_LoadConfig();
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user