Code reverted to prior to spacy's relative directories.

Maybe we can do this properly in the future, but for now it was causing issues for people who like to keep saves with the roms, as well as breaking the rom open dialogues.

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@870 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
squall-leonhart 2009-03-24 05:15:25 +00:00
parent 4379051553
commit ad404dd582
6 changed files with 180 additions and 41 deletions

View File

@ -75,15 +75,15 @@ BOOL Directories::OnInitDialog()
if(!p.IsEmpty())
GetDlgItem(IDC_GBROM_PATH)->SetWindowText(p);
p = regQueryStringValue("batteryDir", DEFAULT_BATTERY_DIR);
p = regQueryStringValue("batteryDir", NULL);
if(!p.IsEmpty())
GetDlgItem(IDC_BATTERY_PATH)->SetWindowText( p);
p = regQueryStringValue("saveDir", DEFAULT_SAVESTATES_DIR);
p = regQueryStringValue("saveDir", NULL);
if(!p.IsEmpty())
GetDlgItem(IDC_SAVE_PATH)->SetWindowText(p);
p = regQueryStringValue("captureDir", DEFAULT_SCREENSHOTS_DIR);
p = regQueryStringValue("captureDir", NULL);
if(!p.IsEmpty())
GetDlgItem(IDC_CAPTURE_PATH)->SetWindowText(p);

View File

@ -800,8 +800,17 @@ void MainWnd::winSaveCheatListDefault()
name = theApp.filename.Right(theApp.filename.GetLength()-index-1);
else
name = theApp.filename;
CString dir = regQueryStringValue("saveDir", DEFAULT_SAVESTATES_DIR);
treatRelativePath( dir );
CString dir = regQueryStringValue("saveDir", NULL);
if( dir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, dir );
dir = baseDir;
}
if(!dir.GetLength())
dir = getDirFromFile(filename);
@ -833,8 +842,17 @@ void MainWnd::winLoadCheatListDefault()
name = theApp.filename.Right(theApp.filename.GetLength()-index-1);
else
name = theApp.filename;
CString dir = regQueryStringValue("saveDir", DEFAULT_SAVESTATES_DIR);
treatRelativePath( dir );
CString dir = regQueryStringValue("saveDir", NULL);
if( dir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, dir );
dir = baseDir;
}
if(!dir.GetLength())
dir = getDirFromFile(filename);
@ -896,8 +914,17 @@ void MainWnd::writeBatteryFile()
else
buffer = theApp.filename;
CString saveDir = regQueryStringValue("batteryDir", DEFAULT_BATTERY_DIR);
treatRelativePath( saveDir );
CString saveDir = regQueryStringValue("batteryDir", NULL);
if( saveDir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, saveDir );
saveDir = baseDir;
}
if(saveDir.IsEmpty())
saveDir = getDirFromFile(theApp.filename);
@ -924,8 +951,17 @@ void MainWnd::readBatteryFile()
else
buffer = theApp.filename;
CString saveDir = regQueryStringValue("batteryDir", DEFAULT_BATTERY_DIR);
treatRelativePath( saveDir );
CString saveDir = regQueryStringValue("batteryDir", NULL);
if( saveDir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, saveDir );
saveDir = baseDir;
}
if(saveDir.IsEmpty())
saveDir = getDirFromFile(theApp.filename);
@ -1078,8 +1114,17 @@ void MainWnd::screenCapture(int captureNumber)
{
CString buffer;
CString captureDir = regQueryStringValue("captureDir", DEFAULT_SCREENSHOTS_DIR);
treatRelativePath( captureDir );
CString captureDir = regQueryStringValue("captureDir", "");
if( captureDir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, captureDir );
captureDir = baseDir;
}
int index = theApp.filename.ReverseFind('\\');

View File

@ -67,7 +67,7 @@ void MainWnd::OnCheatsLoadcheatlist()
else
buffer = theApp.filename;
CString saveDir = regQueryStringValue("saveDir", DEFAULT_SAVESTATES_DIR);
CString saveDir = regQueryStringValue("saveDir", NULL);
if(saveDir.IsEmpty())
saveDir = getDirFromFile(theApp.filename);
@ -105,7 +105,7 @@ void MainWnd::OnCheatsSavecheatlist()
else
buffer = theApp.filename;
CString saveDir = regQueryStringValue("saveDir", DEFAULT_SAVESTATES_DIR);
CString saveDir = regQueryStringValue("saveDir", NULL);
if(saveDir.IsEmpty())
saveDir = getDirFromFile(theApp.filename);

View File

@ -166,8 +166,17 @@ void MainWnd::OnFileLoad()
else
buffer = theApp.filename;
CString saveDir = regQueryStringValue("saveDir", DEFAULT_SAVESTATES_DIR);
treatRelativePath( saveDir );
CString saveDir = regQueryStringValue("saveDir", NULL);
if( saveDir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, saveDir );
saveDir = baseDir;
}
if(saveDir.IsEmpty())
saveDir = getDirFromFile(theApp.filename);
@ -214,8 +223,17 @@ BOOL MainWnd::OnFileLoadSlot(UINT nID)
else
buffer = theApp.filename;
CString saveDir = regQueryStringValue("saveDir", DEFAULT_SAVESTATES_DIR);
treatRelativePath( saveDir );
CString saveDir = regQueryStringValue("saveDir", NULL);
if( saveDir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, saveDir );
saveDir = baseDir;
}
if(saveDir.IsEmpty())
saveDir = getDirFromFile(theApp.filename);
@ -256,8 +274,17 @@ void MainWnd::OnFileSave()
else
buffer = theApp.filename;
CString saveDir = regQueryStringValue("saveDir", DEFAULT_SAVESTATES_DIR);
treatRelativePath( saveDir );
CString saveDir = regQueryStringValue("saveDir", NULL);
if( saveDir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, saveDir );
saveDir = baseDir;
}
if(saveDir.IsEmpty())
saveDir = getDirFromFile(theApp.filename);
@ -299,8 +326,17 @@ BOOL MainWnd::OnFileSaveSlot(UINT nID)
else
buffer = theApp.filename;
CString saveDir = regQueryStringValue("saveDir", DEFAULT_SAVESTATES_DIR);
treatRelativePath( saveDir );
CString saveDir = regQueryStringValue("saveDir", NULL);
if( saveDir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, saveDir );
saveDir = baseDir;
}
if(saveDir.IsEmpty())
saveDir = getDirFromFile(theApp.filename);
@ -328,8 +364,17 @@ void MainWnd::OnFileImportBatteryfile()
CString filter = winLoadFilter(IDS_FILTER_SAV);
CString title = winResLoadString(IDS_SELECT_BATTERY_FILE);
CString saveDir = regQueryStringValue("batteryDir", DEFAULT_BATTERY_DIR);
treatRelativePath( saveDir );
CString saveDir = regQueryStringValue("batteryDir", NULL);
if( saveDir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, saveDir );
saveDir = baseDir;
}
if(saveDir.IsEmpty())
saveDir = getDirFromFile(theApp.filename);
@ -444,7 +489,16 @@ void MainWnd::OnFileExportBatteryfile()
CString title = winResLoadString(IDS_SELECT_BATTERY_FILE);
CString saveDir = regQueryStringValue("batteryDir", DEFAULT_BATTERY_DIR);
treatRelativePath( saveDir );
if( saveDir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, saveDir );
saveDir = baseDir;
}
if(saveDir.IsEmpty())
saveDir = getDirFromFile(theApp.filename);
@ -539,8 +593,17 @@ void MainWnd::OnFileScreencapture()
else
name = theApp.filename;
CString capdir = regQueryStringValue("captureDir", DEFAULT_SCREENSHOTS_DIR);
treatRelativePath( capdir );
CString capdir = regQueryStringValue("captureDir", "");
if( capdir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, capdir );
capdir = baseDir;
}
if(capdir.IsEmpty())
capdir = getDirFromFile(theApp.filename);
@ -686,8 +749,17 @@ void MainWnd::OnFileSavegameOldestslot()
else
filename = theApp.filename;
CString saveDir = regQueryStringValue("saveDir", DEFAULT_SAVESTATES_DIR);
treatRelativePath( saveDir );
CString saveDir = regQueryStringValue("saveDir", NULL);
if( saveDir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, saveDir );
saveDir = baseDir;
}
if(saveDir.IsEmpty())
saveDir = getDirFromFile(theApp.filename);
@ -731,8 +803,17 @@ void MainWnd::OnUpdateFileSavegameOldestslot(CCmdUI* pCmdUI)
else
filename = theApp.filename;
CString saveDir = regQueryStringValue("saveDir", DEFAULT_SAVESTATES_DIR);
treatRelativePath( saveDir );
CString saveDir = regQueryStringValue("saveDir", NULL);
if( saveDir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, saveDir );
saveDir = baseDir;
}
if(saveDir.IsEmpty())
saveDir = getDirFromFile(theApp.filename);
@ -774,8 +855,17 @@ void MainWnd::OnFileLoadgameMostrecent()
else
filename = theApp.filename;
CString saveDir = regQueryStringValue("saveDir", DEFAULT_SAVESTATES_DIR);
treatRelativePath( saveDir );
CString saveDir = regQueryStringValue("saveDir", NULL);
if( saveDir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, saveDir );
saveDir = baseDir;
}
if(saveDir.IsEmpty())
saveDir = getDirFromFile(theApp.filename);
@ -819,8 +909,17 @@ void MainWnd::OnUpdateFileLoadgameMostrecent(CCmdUI* pCmdUI)
else
filename = theApp.filename;
CString saveDir = regQueryStringValue("saveDir", DEFAULT_SAVESTATES_DIR);
treatRelativePath( saveDir );
CString saveDir = regQueryStringValue("saveDir", NULL);
if( saveDir[0] == '.' ) {
// handle as relative path
char baseDir[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
strcat( baseDir, "\\" );
strcat( baseDir, saveDir );
saveDir = baseDir;
}
if(saveDir.IsEmpty())
saveDir = getDirFromFile(theApp.filename);

View File

@ -6,7 +6,6 @@
#include "stdafx.h"
#include <intrin.h>
#include <shlobj.h> // for SHCreateDirectoryEx
#include "AVIWrite.h"
#include "LangSelect.h"

View File

@ -51,10 +51,6 @@ enum AUDIO_API {
#define REWIND_SIZE 400000
#define DEFAULT_BATTERY_DIR ".\\battery"
#define DEFAULT_SAVESTATES_DIR ".\\savestates"
#define DEFAULT_SCREENSHOTS_DIR ".\\screenshots"
class AVIWrite;
class WavWriter;