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

Add Android compatible wrapper for wcscat and wchar_t* constant strings.

This commit is contained in:
Sergey Lipskiy 2015-05-29 20:51:19 +06:00
parent 0a4bf95e2f
commit 2b0db06858
5 changed files with 48 additions and 2 deletions

View File

@ -388,6 +388,7 @@
<ClInclude Include="..\..\src\S2DEX2.h" />
<ClInclude Include="..\..\src\windows\GLFunctions.h" />
<ClInclude Include="..\..\src\windows\GLideN64_windows.h" />
<ClInclude Include="..\..\src\wst.h" />
<ClInclude Include="..\..\src\ZilmarGFX_1_3.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_mupenplus|Win32'">true</ExcludedFromBuild>

View File

@ -346,5 +346,8 @@
<ClInclude Include="..\..\src\GLSLCombiner.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\wst.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -6,6 +6,7 @@
#include "RSP.h"
#include "PluginAPI.h"
#include "Config.h"
#include "wst.h"
void Config::resetToDefaults()
{
@ -53,7 +54,7 @@ void Config::resetToDefaults()
textureFilter.txSaveCache = 1;
api().GetUserDataPath(textureFilter.txPath);
wcscat(textureFilter.txPath, L"/hires_texture");
gln_wcscat(textureFilter.txPath, wst("/hires_texture"));
#ifdef OS_WINDOWS
font.name.assign("arial.ttf");

View File

@ -25,6 +25,7 @@
#include "GLideNHQ/Ext_TxFilter.h"
#include "VI.h"
#include "Config.h"
#include "wst.h"
#include "Log.h"
#include "TextDrawer.h"
#include "PluginAPI.h"
@ -1352,7 +1353,7 @@ void TextureFilterHandler::init()
wchar_t * pTexPackPath = config.textureFilter.txPath;
if (::wcslen(config.textureFilter.txPath) == 0) {
api().GetUserDataPath(txPath);
wcscat(txPath, L"/hires_texture");
gln_wcscat(txPath, wst("/hires_texture"));
pTexPackPath = txPath;
}
wchar_t txCachePath[PLUGIN_PATH_SIZE];

40
src/wst.h Normal file
View File

@ -0,0 +1,40 @@
#ifndef WST_H
#define WST_H
#ifdef ANDROID
void gln_wcscat(wchar_t* destination, const wchar_t* source)
{
const u32 bufSize = 512;
char cbuf[bufSize];
wcstombs(cbuf, destination, bufSize);
std::string dest(cbuf);
wcstombs(cbuf, source, bufSize);
dest.append(cbuf);
mbstowcs(destination, dest.c_str(), PLUGIN_PATH_SIZE);
}
class dummyWString
{
public:
dummyWString(const char * _str)
{
wchar_t buf[512];
mbstowcs(buf, _str, 512);
_wstr.assign(buf);
}
const wchar_t * c_str() const {
return _wstr.c_str();
}
private:
std::wstring _wstr;
};
#define wst(A) dummyWString(A).c_str()
#else // ANDROID
#define gln_wcscat wcscat
#define wst(A) L##A
#endif // ANDROID
#endif // WST_H