win32-when being run from a subdirectory of %temp%, store user files in local appdata, in effort to shut up remaining pokemon gamers running desmume from zipfiles.
This commit is contained in:
parent
fa5d62b740
commit
2bd54afffb
|
@ -144,6 +144,12 @@ public:
|
|||
p = pathToModule + lstrlen(pathToModule);
|
||||
while (p >= pathToModule && *p != DIRECTORY_DELIMITER_CHAR) p--;
|
||||
if (++p >= pathToModule) *p = 0;
|
||||
|
||||
extern char* _hack_alternateModulePath;
|
||||
if(_hack_alternateModulePath)
|
||||
{
|
||||
strcpy(pathToModule,_hack_alternateModulePath);
|
||||
}
|
||||
#elif defined(DESMUME_COCOA)
|
||||
std::string pathStr = Path::GetFileDirectoryPath(path);
|
||||
|
||||
|
@ -383,25 +389,15 @@ public:
|
|||
|
||||
enum R4Format
|
||||
{
|
||||
#if defined(_WINDOWS) && !defined(WXPORT)
|
||||
R4_CHEAT_DAT = IDC_R4TYPE1,
|
||||
R4_USRCHEAT_DAT = IDC_R4TYPE2
|
||||
#else
|
||||
R4_CHEAT_DAT,
|
||||
R4_USRCHEAT_DAT
|
||||
#endif
|
||||
R4_CHEAT_DAT = 0,
|
||||
R4_USRCHEAT_DAT = 1
|
||||
};
|
||||
R4Format r4Format;
|
||||
|
||||
enum ImageFormat
|
||||
{
|
||||
#if defined(_WINDOWS) && !defined(WXPORT)
|
||||
PNG = IDC_PNG,
|
||||
BMP = IDC_BMP
|
||||
#else
|
||||
PNG,
|
||||
BMP
|
||||
#endif
|
||||
PNG = 0,
|
||||
BMP = 1
|
||||
};
|
||||
|
||||
ImageFormat currentimageformat;
|
||||
|
|
|
@ -147,8 +147,10 @@ BOOL PathSettings_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
|
|||
CheckDlgButton(hDlg, IDC_USELASTVISIT, (path.savelastromvisit) ? BST_CHECKED : BST_UNCHECKED);
|
||||
CheckDlgButton(hDlg, IDC_ASSOCIATE, (associate) ? BST_CHECKED : BST_UNCHECKED);
|
||||
CheckDlgButton(hDlg, IDC_AUTOLOADLUA, (autoLoadLua) ? BST_CHECKED : BST_UNCHECKED);
|
||||
CheckRadioButton(hDlg, IDC_PNG, IDC_BMP, (int)path.imageformat());
|
||||
CheckRadioButton(hDlg, IDC_R4TYPE1, IDC_R4TYPE2, (int)path.r4Format);
|
||||
static const int imageFormatMap[] = { IDC_PNG, IDC_BMP };
|
||||
static const int r4TypeMap[] = { IDC_R4TYPE1, IDC_R4TYPE2 };
|
||||
CheckRadioButton(hDlg, IDC_PNG, IDC_BMP, imageFormatMap[(int)path.imageformat()]);
|
||||
CheckRadioButton(hDlg, IDC_R4TYPE1, IDC_R4TYPE2, r4TypeMap[(int)path.r4Format]);
|
||||
|
||||
// IDC_FORMATEDIT setup
|
||||
SetDlgItemText(hDlg, IDC_FORMATEDIT, path.screenshotFormat);
|
||||
|
|
|
@ -15,21 +15,59 @@
|
|||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "path.h"
|
||||
#include "winutil.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include <windef.h>
|
||||
#include <ShlObj.h>
|
||||
|
||||
|
||||
char IniName[MAX_PATH];
|
||||
|
||||
char* _hack_alternateModulePath;
|
||||
|
||||
|
||||
static char vPath[MAX_PATH*2], *szPath;
|
||||
|
||||
void GetINIPath()
|
||||
{
|
||||
char vPath[MAX_PATH], *szPath;
|
||||
/*if (*vPath)
|
||||
|
||||
bool useModulePath = true;
|
||||
|
||||
//check if desmume is running from the temp directory.
|
||||
{
|
||||
//DebugBreak();
|
||||
wchar_t tempPath[MAX_PATH];
|
||||
GetTempPathW(MAX_PATH,tempPath);
|
||||
wchar_t modulePath[MAX_PATH];
|
||||
GetModuleFileNameW(NULL, modulePath, MAX_PATH);
|
||||
if(!_wcsnicmp(tempPath,modulePath,wcslen(tempPath)))
|
||||
{
|
||||
//running from temp dir
|
||||
|
||||
//decided not to warn user
|
||||
//GetPrivateProfileBool("General","Temp Directory Warning", false, IniName))
|
||||
//MessageBox(NULL,"You are running DeSmuME from your temp directory, probably by running straight from an archive instead of dearchiving to your disk manually......
|
||||
|
||||
//use an alternate path
|
||||
useModulePath = false;
|
||||
static char userpath[MAX_PATH];
|
||||
SHGetFolderPath(NULL,CSIDL_LOCAL_APPDATA,NULL,0,userpath);
|
||||
_snprintf(vPath,MAX_PATH,"%s\\%s",userpath,"DeSmuME");
|
||||
szPath = vPath;
|
||||
else
|
||||
{*/
|
||||
_hack_alternateModulePath = szPath;
|
||||
|
||||
//not so sure about this.. but lets go for it.
|
||||
SetCurrentDirectory(userpath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(useModulePath)
|
||||
{
|
||||
char *p;
|
||||
ZeroMemory(vPath, sizeof(vPath));
|
||||
GetModuleFileName(NULL, vPath, sizeof(vPath));
|
||||
|
@ -37,7 +75,7 @@ void GetINIPath()
|
|||
while (p >= vPath && *p != '\\') p--;
|
||||
if (++p >= vPath) *p = 0;
|
||||
szPath = vPath;
|
||||
//}
|
||||
}
|
||||
if (strlen(szPath) + strlen("\\desmume.ini") < MAX_PATH)
|
||||
{
|
||||
sprintf(IniName, "%s\\desmume.ini",szPath);
|
||||
|
@ -47,6 +85,8 @@ void GetINIPath()
|
|||
{
|
||||
memset(IniName,0,MAX_PATH) ;
|
||||
}
|
||||
|
||||
FCEUD_MakePathDirs(IniName);
|
||||
}
|
||||
|
||||
void PreventScreensaver()
|
||||
|
|
Loading…
Reference in New Issue