- attempt to get non ascii file paths working in megaglest (Japanese etc...)

This commit is contained in:
Mark Vejvoda
2011-05-18 21:49:11 +00:00
parent 727c7b33d9
commit 60b8093f5b
34 changed files with 519 additions and 110 deletions

View File

@@ -13,6 +13,7 @@
#include "config.h"
#include "game_constants.h"
#include <wx/stdpaths.h>
#include <platform_util.h>
//#include <wx/filename.h>
#ifndef WIN32
@@ -360,30 +361,30 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
// For windows register g3d file extension to launch this app
#if defined(WIN32) && !defined(__MINGW32__)
// example from: http://stackoverflow.com/questions/1387769/create-registry-entry-to-associate-file-extension-with-application-in-c
//[HKEY_CURRENT_USER\Software\Classes\blergcorp.blergapp.v1\shell\open\command]
//@="c:\path\to\app.exe \"%1\""
//[HKEY_CURRENT_USER\Software\Classes\.blerg]
//[HKEY_CURRENT_USER\Software\Classes\blergcorp.blergapp.v1\shell\open\command]
//@="c:\path\to\app.exe \"%1\""
//[HKEY_CURRENT_USER\Software\Classes\.blerg]
//@="blergcorp.blergapp.v1"
//Open the registry key.
string subKey = "Software\\Classes\\megaglest.g3d\\shell\\open\\command";
string subKey = "Software\\Classes\\megaglest.g3d\\shell\\open\\command";
HKEY keyHandle;
DWORD dwDisposition;
RegCreateKeyEx(HKEY_CURRENT_USER,subKey.c_str(),0, NULL, 0, KEY_ALL_ACCESS, NULL, &keyHandle, &dwDisposition);
//Set the value.
string launchApp = appPath + " \"%1\"";
DWORD len = launchApp.length() + 1;
RegSetValueEx(keyHandle, NULL, 0, REG_SZ, (PBYTE)launchApp.c_str(), len);
RegCloseKey(keyHandle);
subKey = "Software\\Classes\\.g3d";
RegCreateKeyEx(HKEY_CURRENT_USER,subKey.c_str(),0, NULL, 0, KEY_ALL_ACCESS, NULL, &keyHandle, &dwDisposition);
//Set the value.
launchApp = "megaglest.g3d";
len = launchApp.length() + 1;
RegSetValueEx(keyHandle, NULL, 0, REG_SZ, (PBYTE)launchApp.c_str(), len);
RegCloseKey(keyHandle);
DWORD dwDisposition;
RegCreateKeyEx(HKEY_CURRENT_USER,subKey.c_str(),0, NULL, 0, KEY_ALL_ACCESS, NULL, &keyHandle, &dwDisposition);
//Set the value.
string launchApp = appPath + " \"%1\"";
DWORD len = launchApp.length() + 1;
RegSetValueEx(keyHandle, NULL, 0, REG_SZ, (PBYTE)launchApp.c_str(), len);
RegCloseKey(keyHandle);
subKey = "Software\\Classes\\.g3d";
RegCreateKeyEx(HKEY_CURRENT_USER,subKey.c_str(),0, NULL, 0, KEY_ALL_ACCESS, NULL, &keyHandle, &dwDisposition);
//Set the value.
launchApp = "megaglest.g3d";
len = launchApp.length() + 1;
RegSetValueEx(keyHandle, NULL, 0, REG_SZ, (PBYTE)launchApp.c_str(), len);
RegCloseKey(keyHandle);
#endif
}
@@ -799,7 +800,11 @@ void MainWindow::saveScreenshot() {
if(autoSaveScreenshotIndex >= 0) {
string saveAsFilename = autoScreenShotParams[autoSaveScreenshotIndex];
saveAsFilename.erase(0,7);
#ifdef WIN32
FILE*f = _wfopen(utf8_decode(saveAsFilename).c_str(), L"rb");
#else
FILE *f= fopen(saveAsFilename.c_str(), "rb");
#endif
if(f == NULL) {
renderer->saveScreen(saveAsFilename.c_str());
}
@@ -829,7 +834,11 @@ void MainWindow::saveScreenshot() {
for(int i=0; i < 5000; ++i) {
path = screenShotsPath;
path += string("screen") + intToStr(i) + string(".") + fileFormat;
#ifdef WIN32
FILE*f= _wfopen(utf8_decode(path).c_str(), L"rb");
#else
FILE *f= fopen(path.c_str(), "rb");
#endif
if(f == NULL) {
renderer->saveScreen(path);
break;
@@ -2128,9 +2137,9 @@ bool App::OnInit() {
//#endif
// printf("appPath [%s]\n",argv[0]);
wxString exe_path = wxStandardPaths::Get().GetExecutablePath();
//wxString path_separator = wxFileName::GetPathSeparator();
//exe_path = exe_path.BeforeLast(path_separator[0]);
wxString exe_path = wxStandardPaths::Get().GetExecutablePath();
//wxString path_separator = wxFileName::GetPathSeparator();
//exe_path = exe_path.BeforeLast(path_separator[0]);
//exe_path += path_separator;
#if defined(__MINGW32__)