mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-07 03:13:49 +00:00
Add PluginAPI functions: GetUserDataPath() and GetUserCachePath().
New functions are used for texture library initialization. GetUserDataPath() returns default folder to search for hi-res texture packs. GetUserCachePath() returns folder to store texture cache. Mupen64Plus implementation: use system ConfigGetUserDataPath() and ConfigGetUserCachePath(). Windows implementation: just return FindPluginPath() for both functions. Note: behaviour of Mupen64Plus changed. Previously the emulator's folder was default path for hires textures and texture cache. Now default path is system dependent. For Windows it will be %HOME%\AppData\Roaming\Mupen64Plus
This commit is contained in:
parent
0c416070c7
commit
2c7184cab6
|
@ -52,11 +52,11 @@ void Config::resetToDefaults()
|
||||||
textureFilter.txForce16bpp = 0;
|
textureFilter.txForce16bpp = 0;
|
||||||
textureFilter.txSaveCache = 1;
|
textureFilter.txSaveCache = 1;
|
||||||
|
|
||||||
api().FindPluginPath(textureFilter.txPath);
|
api().GetUserDataPath(textureFilter.txPath);
|
||||||
wcscat(textureFilter.txPath, L"/hires_texture");
|
wcscat(textureFilter.txPath, L"/hires_texture");
|
||||||
|
|
||||||
#ifdef OS_WINDOWS
|
#ifdef OS_WINDOWS
|
||||||
font.name = "arial.ttf";
|
font.name.assign("arial.ttf");
|
||||||
#else
|
#else
|
||||||
font.name = "FreeSans.ttf";
|
font.name = "FreeSans.ttf";
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "TextDrawer.h"
|
#include "TextDrawer.h"
|
||||||
|
#include "PluginAPI.h"
|
||||||
#include "PostProcessor.h"
|
#include "PostProcessor.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -1350,17 +1351,19 @@ void TextureFilterHandler::init()
|
||||||
wchar_t txPath[PLUGIN_PATH_SIZE+16];
|
wchar_t txPath[PLUGIN_PATH_SIZE+16];
|
||||||
wchar_t * pTexPackPath = config.textureFilter.txPath;
|
wchar_t * pTexPackPath = config.textureFilter.txPath;
|
||||||
if (::wcslen(config.textureFilter.txPath) == 0) {
|
if (::wcslen(config.textureFilter.txPath) == 0) {
|
||||||
wcscpy(txPath, RSP.pluginpath);
|
api().GetUserDataPath(txPath);
|
||||||
wcscat(txPath, L"/hires_texture");
|
wcscat(txPath, L"/hires_texture");
|
||||||
pTexPackPath = txPath;
|
pTexPackPath = txPath;
|
||||||
}
|
}
|
||||||
|
wchar_t txCachePath[PLUGIN_PATH_SIZE];
|
||||||
|
api().GetUserCachePath(txCachePath);
|
||||||
|
|
||||||
m_inited = txfilter_init(maxTextureSize, // max texture width supported by hardware
|
m_inited = txfilter_init(maxTextureSize, // max texture width supported by hardware
|
||||||
maxTextureSize, // max texture height supported by hardware
|
maxTextureSize, // max texture height supported by hardware
|
||||||
32, // max texture bpp supported by hardware
|
32, // max texture bpp supported by hardware
|
||||||
options,
|
options,
|
||||||
config.textureFilter.txCacheSize, // cache texture to system memory
|
config.textureFilter.txCacheSize, // cache texture to system memory
|
||||||
RSP.pluginpath, // plugin path
|
txCachePath, // path to store cache files
|
||||||
pTexPackPath, // path to texture packs folder
|
pTexPackPath, // path to texture packs folder
|
||||||
wRomName, // name of ROM. must be no longer than 256 characters
|
wRomName, // name of ROM. must be no longer than 256 characters
|
||||||
displayLoadProgress);
|
displayLoadProgress);
|
||||||
|
|
|
@ -45,6 +45,8 @@ public:
|
||||||
void ChangeWindow();
|
void ChangeWindow();
|
||||||
|
|
||||||
void FindPluginPath(wchar_t * _strPath);
|
void FindPluginPath(wchar_t * _strPath);
|
||||||
|
void GetUserDataPath(wchar_t * _strPath);
|
||||||
|
void GetUserCachePath(wchar_t * _strPath);
|
||||||
|
|
||||||
#ifndef MUPENPLUSAPI
|
#ifndef MUPENPLUSAPI
|
||||||
// Zilmar
|
// Zilmar
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include "GLideN64_mupenplus.h"
|
||||||
#include "../PluginAPI.h"
|
#include "../PluginAPI.h"
|
||||||
#include "../OpenGL.h"
|
#include "../OpenGL.h"
|
||||||
#include "../RSP.h"
|
#include "../RSP.h"
|
||||||
|
@ -9,30 +10,52 @@ int PluginAPI::InitiateGFX(const GFX_INFO & _gfxInfo)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void _cutLastPathSeparator(wchar_t * _strPath)
|
||||||
|
{
|
||||||
|
std::wstring pluginPath(_strPath);
|
||||||
|
std::wstring::size_type pos = pluginPath.find_last_of(L"\\/");
|
||||||
|
wcscpy(_strPath, pluginPath.substr(0, pos).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void _getWSPath(const char * _path, wchar_t * _strPath)
|
||||||
|
{
|
||||||
|
::mbstowcs(_strPath, _path, PLUGIN_PATH_SIZE);
|
||||||
|
_cutLastPathSeparator(_strPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PluginAPI::GetUserDataPath(wchar_t * _strPath)
|
||||||
|
{
|
||||||
|
_getWSPath(ConfigGetUserDataPath(), _strPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PluginAPI::GetUserCachePath(wchar_t * _strPath)
|
||||||
|
{
|
||||||
|
_getWSPath(ConfigGetUserCachePath(), _strPath);
|
||||||
|
}
|
||||||
|
|
||||||
void PluginAPI::FindPluginPath(wchar_t * _strPath)
|
void PluginAPI::FindPluginPath(wchar_t * _strPath)
|
||||||
{
|
{
|
||||||
if (_strPath == NULL)
|
if (_strPath == NULL)
|
||||||
return;
|
return;
|
||||||
#ifdef OS_WINDOWS
|
#ifdef OS_WINDOWS
|
||||||
GetModuleFileNameW(NULL, _strPath, PLUGIN_PATH_SIZE);
|
GetModuleFileNameW(NULL, _strPath, PLUGIN_PATH_SIZE);
|
||||||
#elif OS_LINUX
|
_cutLastPathSeparator(_strPath);
|
||||||
|
#elif defined(OS_LINUX)
|
||||||
char path[512];
|
char path[512];
|
||||||
int res = readlink("/proc/self/exe", path, 510);
|
int res = readlink("/proc/self/exe", path, 510);
|
||||||
if (res != -1) {
|
if (res != -1) {
|
||||||
path[res] = 0;
|
path[res] = 0;
|
||||||
::mbstowcs(_strPath, path, PLUGIN_PATH_SIZE);
|
_getWSPath(path, _strPath);
|
||||||
}
|
}
|
||||||
#elif OS_MAC_OS_X
|
#elif defined(OS_MAC_OS_X)
|
||||||
char path[MAXPATHLEN];
|
char path[MAXPATHLEN];
|
||||||
uint32_t pathLen = MAXPATHLEN * 2;
|
uint32_t pathLen = MAXPATHLEN * 2;
|
||||||
if (_NSGetExecutablePath(path, pathLen) == 0) {
|
if (_NSGetExecutablePath(path, pathLen) == 0) {
|
||||||
::mbstowcs(_strPath, path, PLUGIN_PATH_SIZE);
|
_getWSPath(path, _strPath);
|
||||||
}
|
}
|
||||||
#else
|
#elif defined(ANDROID)
|
||||||
// TODO: Android implementation
|
GetUserCachePath(_strPath);
|
||||||
::mbstowcs(_strPath, "Plugin", PLUGIN_PATH_SIZE);
|
|
||||||
#endif
|
#endif
|
||||||
std::wstring pluginPath(_strPath);
|
|
||||||
std::wstring::size_type pos = pluginPath.find_last_of(L"\\/");
|
|
||||||
wcscpy(_strPath, pluginPath.substr(0, pos).c_str());
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,11 @@ bool Config_SetDefault()
|
||||||
assert(res == M64ERR_SUCCESS);
|
assert(res == M64ERR_SUCCESS);
|
||||||
res = ConfigSetDefaultBool(g_configVideoGliden64, "txSaveCache", config.textureFilter.txSaveCache, "Save texture cache to hard disk.");
|
res = ConfigSetDefaultBool(g_configVideoGliden64, "txSaveCache", config.textureFilter.txSaveCache, "Save texture cache to hard disk.");
|
||||||
assert(res == M64ERR_SUCCESS);
|
assert(res == M64ERR_SUCCESS);
|
||||||
|
// Convert to multibyte
|
||||||
|
char txPath[PLUGIN_PATH_SIZE * 2];
|
||||||
|
wcstombs(txPath, config.textureFilter.txPath, PLUGIN_PATH_SIZE * 2);
|
||||||
|
res = ConfigSetDefaultString(g_configVideoGliden64, "txPath", txPath, "Path to folder with hi-res texture packs.");
|
||||||
|
assert(res == M64ERR_SUCCESS);
|
||||||
|
|
||||||
res = ConfigSetDefaultString(g_configVideoGliden64, "fontName", config.font.name.c_str(), "File name of True Type Font for text messages.");
|
res = ConfigSetDefaultString(g_configVideoGliden64, "fontName", config.font.name.c_str(), "File name of True Type Font for text messages.");
|
||||||
assert(res == M64ERR_SUCCESS);
|
assert(res == M64ERR_SUCCESS);
|
||||||
|
@ -183,6 +188,8 @@ void Config_LoadConfig()
|
||||||
config.textureFilter.txForce16bpp = ConfigGetParamBool(g_configVideoGliden64, "txForce16bpp");
|
config.textureFilter.txForce16bpp = ConfigGetParamBool(g_configVideoGliden64, "txForce16bpp");
|
||||||
config.textureFilter.txCacheCompression = ConfigGetParamBool(g_configVideoGliden64, "txCacheCompression");
|
config.textureFilter.txCacheCompression = ConfigGetParamBool(g_configVideoGliden64, "txCacheCompression");
|
||||||
config.textureFilter.txSaveCache = ConfigGetParamBool(g_configVideoGliden64, "txSaveCache");
|
config.textureFilter.txSaveCache = ConfigGetParamBool(g_configVideoGliden64, "txSaveCache");
|
||||||
|
::mbstowcs(config.textureFilter.txPath, ConfigGetParamString(g_configVideoGliden64, "txPath"), PLUGIN_PATH_SIZE);
|
||||||
|
|
||||||
//#Font settings
|
//#Font settings
|
||||||
config.font.name = ConfigGetParamString(g_configVideoGliden64, "fontName");
|
config.font.name = ConfigGetParamString(g_configVideoGliden64, "fontName");
|
||||||
if (config.font.name.empty())
|
if (config.font.name.empty())
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath = NULL;
|
ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath = NULL;
|
||||||
ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath = NULL;
|
ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath = NULL;
|
||||||
|
ptr_ConfigGetUserDataPath ConfigGetUserDataPath = NULL;
|
||||||
|
ptr_ConfigGetUserCachePath ConfigGetUserCachePath = NULL;
|
||||||
ptr_ConfigOpenSection ConfigOpenSection = NULL;
|
ptr_ConfigOpenSection ConfigOpenSection = NULL;
|
||||||
ptr_ConfigDeleteSection ConfigDeleteSection = NULL;
|
ptr_ConfigDeleteSection ConfigDeleteSection = NULL;
|
||||||
ptr_ConfigSaveSection ConfigSaveSection = NULL;
|
ptr_ConfigSaveSection ConfigSaveSection = NULL;
|
||||||
|
@ -41,6 +43,9 @@ m64p_error PluginAPI::PluginStartup(m64p_dynlib_handle _CoreLibHandle)
|
||||||
{
|
{
|
||||||
ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath) DLSYM(_CoreLibHandle, "ConfigGetSharedDataFilepath");
|
ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath) DLSYM(_CoreLibHandle, "ConfigGetSharedDataFilepath");
|
||||||
ConfigGetUserConfigPath = (ptr_ConfigGetUserConfigPath) DLSYM(_CoreLibHandle, "ConfigGetUserConfigPath");
|
ConfigGetUserConfigPath = (ptr_ConfigGetUserConfigPath) DLSYM(_CoreLibHandle, "ConfigGetUserConfigPath");
|
||||||
|
ConfigGetUserCachePath = (ptr_ConfigGetUserCachePath)DLSYM(_CoreLibHandle, "ConfigGetUserCachePath");
|
||||||
|
ConfigGetUserDataPath = (ptr_ConfigGetUserDataPath)DLSYM(_CoreLibHandle, "ConfigGetUserDataPath");
|
||||||
|
|
||||||
ConfigOpenSection = (ptr_ConfigOpenSection)DLSYM(_CoreLibHandle, "ConfigOpenSection");
|
ConfigOpenSection = (ptr_ConfigOpenSection)DLSYM(_CoreLibHandle, "ConfigOpenSection");
|
||||||
ConfigDeleteSection = (ptr_ConfigDeleteSection)DLSYM(_CoreLibHandle, "ConfigDeleteSection");
|
ConfigDeleteSection = (ptr_ConfigDeleteSection)DLSYM(_CoreLibHandle, "ConfigDeleteSection");
|
||||||
ConfigSaveSection = (ptr_ConfigSaveSection)DLSYM(_CoreLibHandle, "ConfigSaveSection");
|
ConfigSaveSection = (ptr_ConfigSaveSection)DLSYM(_CoreLibHandle, "ConfigSaveSection");
|
||||||
|
|
|
@ -34,14 +34,19 @@ void PluginAPI::FindPluginPath(wchar_t * _strPath)
|
||||||
{
|
{
|
||||||
if (_strPath == NULL)
|
if (_strPath == NULL)
|
||||||
return;
|
return;
|
||||||
#ifdef OS_WINDOWS
|
|
||||||
::GetModuleFileName((HINSTANCE)&__ImageBase, _strPath, PLUGIN_PATH_SIZE);
|
::GetModuleFileName((HINSTANCE)&__ImageBase, _strPath, PLUGIN_PATH_SIZE);
|
||||||
#else
|
|
||||||
// TODO: for other OS
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
std::wstring pluginPath(_strPath);
|
std::wstring pluginPath(_strPath);
|
||||||
std::replace(pluginPath.begin(), pluginPath.end(), L'\\', L'/');
|
std::replace(pluginPath.begin(), pluginPath.end(), L'\\', L'/');
|
||||||
std::wstring::size_type pos = pluginPath.find_last_of(L"/");
|
std::wstring::size_type pos = pluginPath.find_last_of(L"/");
|
||||||
wcscpy(_strPath, pluginPath.substr(0, pos).c_str());
|
wcscpy(_strPath, pluginPath.substr(0, pos).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PluginAPI::GetUserDataPath(wchar_t * _strPath)
|
||||||
|
{
|
||||||
|
FindPluginPath(_strPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PluginAPI::GetUserCachePath(wchar_t * _strPath)
|
||||||
|
{
|
||||||
|
FindPluginPath(_strPath);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user