1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

Init mupen64plus config at PluginStartup

This commit is contained in:
Logan McNaughton 2017-09-12 19:58:52 -06:00 committed by Sergey Lipskiy
parent f567186e01
commit 528744de19
3 changed files with 18 additions and 20 deletions

View File

@ -18,18 +18,19 @@ Config config;
static
const u32 uMegabyte = 1024U*1024U;
static m64p_handle g_configVideoGeneral = nullptr;
static m64p_handle g_configVideoGliden64 = nullptr;
m64p_handle g_configVideoGeneral = nullptr;
m64p_handle g_configVideoGliden64 = nullptr;
static
bool Config_SetDefault()
{
if (ConfigOpenSection("Video-General", &g_configVideoGeneral) != M64ERR_SUCCESS) {
LOG(LOG_ERROR, "Unable to open Video-General configuration section");
g_configVideoGeneral = nullptr;
return false;
}
if (ConfigOpenSection("Video-GLideN64", &g_configVideoGliden64) != M64ERR_SUCCESS) {
LOG(LOG_ERROR, "Unable to open GLideN64 configuration section");
g_configVideoGliden64 = nullptr;
return false;
}
@ -309,23 +310,8 @@ void Config_LoadCustomConfig()
void Config_LoadConfig()
{
const u32 hacks = config.generalEmulation.hacks;
if (!Config_SetDefault()) {
config.generalEmulation.hacks = hacks;
if (g_configVideoGeneral == nullptr || g_configVideoGliden64 == nullptr)
return;
}
config.version = ConfigGetParamInt(g_configVideoGliden64, "configVersion");
if (config.version != CONFIG_VERSION_CURRENT) {
m64p_error res = ConfigDeleteSection("Video-GLideN64");
assert(res == M64ERR_SUCCESS);
ConfigSaveFile();
if (!Config_SetDefault()) {
config.generalEmulation.hacks = hacks;
return;
}
}
config.video.fullscreen = ConfigGetParamBool(g_configVideoGeneral, "Fullscreen");
config.video.windowedWidth = ConfigGetParamInt(g_configVideoGeneral, "ScreenWidth");
@ -429,5 +415,4 @@ void Config_LoadConfig()
if (config.generalEmulation.enableCustomSettings)
Config_LoadCustomConfig();
config.generalEmulation.hacks = hacks;
}

View File

@ -49,4 +49,8 @@ extern ptr_VidExt_GL_SwapBuffers CoreVideo_GL_SwapBuffers;
extern void(*renderCallback)(int);
extern m64p_handle g_configVideoGeneral;
extern m64p_handle g_configVideoGliden64;
bool Config_SetDefault();
#endif // GLIDEN64_MUPENPLUS_H

View File

@ -1,6 +1,7 @@
#include "GLideN64_mupenplus.h"
#include "../PluginAPI.h"
#include "../GLideN64.h"
#include "../Config.h"
#include <DisplayWindow.h>
#ifdef OS_WINDOWS
@ -81,6 +82,14 @@ m64p_error PluginAPI::PluginStartup(m64p_dynlib_handle _CoreLibHandle)
CoreVideo_GL_GetAttribute = (ptr_VidExt_GL_GetAttribute) DLSYM(_CoreLibHandle, "VidExt_GL_GetAttribute");
CoreVideo_GL_SwapBuffers = (ptr_VidExt_GL_SwapBuffers) DLSYM(_CoreLibHandle, "VidExt_GL_SwapBuffers");
if (Config_SetDefault()) {
config.version = ConfigGetParamInt(g_configVideoGliden64, "configVersion");
if (config.version != CONFIG_VERSION_CURRENT) {
ConfigDeleteSection("Video-GLideN64");
ConfigSaveFile();
Config_SetDefault();
}
}
return M64ERR_SUCCESS;
}