Merge pull request #217 from SuuperW/paths

Paths
This commit is contained in:
zeromus 2018-11-29 15:04:31 -06:00 committed by GitHub
commit f6938dc80a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 78 additions and 37 deletions

View File

@ -179,7 +179,7 @@ bool importSave(HWND hwnd, HINSTANCE hAppInst)
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = "sav";
ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
std::string dir = path.getpath(path.BATTERY);
std::string dir = path.getpath(path.SRAM_IMPORT_EXPORT);
ofn.lpstrInitialDir = dir.c_str();
if(!GetOpenFileName(&ofn))
@ -189,8 +189,8 @@ bool importSave(HWND hwnd, HINSTANCE hAppInst)
if (res < MAX_SAVE_TYPES)
{
std::string dir = Path::GetFileDirectoryPath(SavFName);
path.setpath(path.BATTERY, dir);
WritePrivateProfileString(SECTION, BATTERYKEY, dir.c_str(), IniName);
path.setpath(path.SRAM_IMPORT_EXPORT, dir);
WritePrivateProfileString(SECTION, SRAMIMPORTKEY, dir.c_str(), IniName);
res = MMU_new.backupDevice.importData(SavFName, save_types[res+1].size);
if (res)
@ -219,15 +219,15 @@ bool exportSave(HWND hwnd, HINSTANCE hAppInst)
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = "sav";
ofn.Flags = OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
std::string dir = path.getpath(path.BATTERY);
std::string dir = path.getpath(path.SRAM_IMPORT_EXPORT);
ofn.lpstrInitialDir = dir.c_str();
if (!GetSaveFileName(&ofn))
return true;
dir = Path::GetFileDirectoryPath(SavFName);
path.setpath(path.BATTERY, dir);
WritePrivateProfileString(SECTION, BATTERYKEY, dir.c_str(), IniName);
path.setpath(path.SRAM_IMPORT_EXPORT, dir);
WritePrivateProfileString(SECTION, SRAMIMPORTKEY, dir.c_str(), IniName);
if (ofn.nFilterIndex == 2) strcat(SavFName, "*");

View File

@ -107,6 +107,7 @@ void WritePathSettings()
{
WritePrivateProfileString(SECTION, ROMKEY, path.pathToRoms, IniName);
WritePrivateProfileString(SECTION, BATTERYKEY, path.pathToBattery, IniName);
WritePrivateProfileString(SECTION, SRAMIMPORTKEY, path.pathToSramImportExport, IniName);
WritePrivateProfileString(SECTION, STATEKEY, path.pathToStates, IniName);
WritePrivateProfileString(SECTION, STATESLOTKEY, path.pathToStateSlots, IniName);
WritePrivateProfileString(SECTION, SCREENSHOTKEY, path.pathToScreenshots, IniName);
@ -172,7 +173,9 @@ BOOL PathSettings_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
SetDlgItemText(hDlg, IDC_ROMPATHEDIT, path.pathToRoms);
SetDlgItemText(hDlg, IDC_SAVERAMPATHEDIT, path.pathToBattery);
SetDlgItemText(hDlg, IDC_SRAMIMPORTPATHEDIT, path.pathToSramImportExport);
SetDlgItemText(hDlg, IDC_STATEPATHEDIT, path.pathToStates);
SetDlgItemText(hDlg, IDC_STATESLOTPATHEDIT, path.pathToStateSlots);
SetDlgItemText(hDlg, IDC_SCREENSHOTPATHEDIT, path.pathToScreenshots);
SetDlgItemText(hDlg, IDC_AVIPATHEDIT, path.pathToAviFiles);
SetDlgItemText(hDlg, IDC_CHEATPATHEDIT, path.pathToCheats);
@ -258,12 +261,24 @@ void PathSettings_OnCommand(HWND hDlg, int id, HWND hwndCtl, UINT codeNotify)
SetDlgItemText(hDlg, IDC_SAVERAMPATHEDIT, path.pathToBattery);
}
break;
case IDC_BROWSESRAMIMPORT:
{
if(BrowseForPath(path.pathToSramImportExport))
SetDlgItemText(hDlg, IDC_SRAMIMPORTPATHEDIT, path.pathToSramImportExport);
}
break;
case IDC_BROWSESTATES:
{
if(BrowseForPath(path.pathToStates))
SetDlgItemText(hDlg, IDC_STATEPATHEDIT, path.pathToStates);
}
break;
case IDC_BROWSESTATESLOTS:
{
if(BrowseForPath(path.pathToStateSlots))
SetDlgItemText(hDlg, IDC_STATESLOTPATHEDIT, path.pathToStateSlots);
}
break;
case IDC_BROWSESCREENSHOTS:
{
if(BrowseForPath(path.pathToScreenshots))
@ -343,7 +358,9 @@ void PathSettings_OnCommand(HWND hDlg, int id, HWND hwndCtl, UINT codeNotify)
GetDlgItemText(hDlg, IDC_ROMPATHEDIT, path.pathToRoms, MAX_PATH);
GetDlgItemText(hDlg, IDC_SAVERAMPATHEDIT, path.pathToBattery, MAX_PATH);
GetDlgItemText(hDlg, IDC_SRAMIMPORTPATHEDIT, path.pathToSramImportExport, MAX_PATH);
GetDlgItemText(hDlg, IDC_STATEPATHEDIT, path.pathToStates, MAX_PATH);
GetDlgItemText(hDlg, IDC_STATESLOTPATHEDIT, path.pathToStateSlots, MAX_PATH);
GetDlgItemText(hDlg, IDC_SCREENSHOTPATHEDIT, path.pathToScreenshots, MAX_PATH);
GetDlgItemText(hDlg, IDC_AVIPATHEDIT, path.pathToAviFiles, MAX_PATH);
GetDlgItemText(hDlg, IDC_CHEATPATHEDIT, path.pathToCheats, MAX_PATH);

View File

@ -153,6 +153,10 @@
#define IDD_PATHSETTINGS 366
#define IDC_ASSOCIATE 367
#define IDC_CLOSE_LUA_SCRIPTS 368
#define IDC_SRAMIMPORTPATHEDIT 369
#define IDC_BROWSESRAMIMPORT 370
#define IDC_STATESLOTPATHEDIT 371
#define IDC_BROWSESTATESLOTS 372
#define IDC_DES_BOX 402
#define IDC_R0 403
#define IDC_R1 404

View File

@ -57,47 +57,60 @@ BEGIN
LTEXT "Static",IDC_MROM,67,103,100,8
END
IDD_PATHSETTINGS DIALOGEX 0, 0, 252, 294
IDD_PATHSETTINGS DIALOGEX 0, 0, 252, 325
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Path Settings"
FONT 8, "Ms Shell Dlg 2", 0, 0, 0x0
BEGIN
GROUPBOX "Roms",IDC_STATIC,0,0,247,39
EDITTEXT IDC_ROMPATHEDIT,6,11,221,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BROWSEROMS,230,11,13,14
CONTROL "Automatically use last visited folder",IDC_USELASTVISIT,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,27,129,10
CONTROL "Associate nds Files",IDC_ASSOCIATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,132,27,80,10
EDITTEXT IDC_SAVERAMPATHEDIT,5,51,221,14,ES_AUTOHSCROLL
GROUPBOX "SaveRam",IDC_STATIC,0,42,248,44
LTEXT "Auto save",IDC_STATIC,5,54,35,14
EDITTEXT IDC_SAVERAMPATHEDIT,42,51,184,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BROWSESRAM,229,51,13,14
EDITTEXT IDC_STATEPATHEDIT,5,81,221,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BROWSESTATES,229,81,13,14
EDITTEXT IDC_SCREENSHOTPATHEDIT,5,112,221,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BROWSESCREENSHOTS,229,112,13,14
RADIOBUTTON "PNG",IDC_PNG,36,131,29,10
RADIOBUTTON "BMP",IDC_BMP,65,131,29,10
EDITTEXT IDC_FORMATEDIT,124,128,118,14,ES_AUTOHSCROLL
EDITTEXT IDC_AVIPATHEDIT,5,158,221,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BROWSEAVI,229,158,13,14
EDITTEXT IDC_CHEATPATHEDIT,5,189,221,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BROWSECHEATS,229,189,13,14
CONTROL "CHEAT.DAT",IDC_R4TYPE1,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,160,206,54,10
CONTROL "USRCHEAT.DAT",IDC_R4TYPE2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,160,218,67,10
EDITTEXT IDC_LUAPATHEDIT,5,243,221,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BROWSELUA,229,243,13,14
CONTROL "Auto-load Lua scripts with ROM",IDC_AUTOLOADLUA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,259,219,8
PUSHBUTTON "Defaults",IDC_PATHDEFAULTS,3,274,50,14
DEFPUSHBUTTON "OK",IDOK,148,274,50,14
PUSHBUTTON "Cancel",IDCANCEL,198,274,50,14
LTEXT "Format:",IDC_FORMATSTATIC,95,131,26,8
LTEXT "Save As:",IDC_SAVEAS,6,131,30,8
GROUPBOX "Screenshots",IDC_STATIC,0,103,248,44
GROUPBOX "States",IDC_STATIC,0,71,248,30
GROUPBOX "Roms",IDC_STATIC,1,0,247,39
GROUPBOX "SaveRam",IDC_STATIC,0,42,248,27
GROUPBOX "AviFiles",IDC_STATIC,0,149,247,27
GROUPBOX "Cheats",IDC_STATIC,0,180,247,50
GROUPBOX "Lua",IDC_STATIC,0,233,247,38
LTEXT "R4 cheats database file name",IDC_STATIC,56,206,100,17
LTEXT "Im/export",IDC_STATIC,5,70,35,14
EDITTEXT IDC_SRAMIMPORTPATHEDIT,42,67,184,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BROWSESRAMIMPORT,229,67,13,14
GROUPBOX "States",IDC_STATIC,0,87,248,46
EDITTEXT IDC_STATEPATHEDIT,5,97,221,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BROWSESTATES,229,97,13,14
LTEXT "Slots",IDC_STATIC,5,116,15,14
EDITTEXT IDC_STATESLOTPATHEDIT,24,113,202,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BROWSESTATESLOTS,229,113,13,14
GROUPBOX "Screenshots",IDC_STATIC,0,135,248,44
EDITTEXT IDC_SCREENSHOTPATHEDIT,5,144,221,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BROWSESCREENSHOTS,229,144,13,14
LTEXT "Save As:",IDC_SAVEAS,6,163,30,8
RADIOBUTTON "PNG",IDC_PNG,36,163,29,10
RADIOBUTTON "BMP",IDC_BMP,65,163,29,10
LTEXT "Format:",IDC_FORMATSTATIC,95,163,26,8
EDITTEXT IDC_FORMATEDIT,124,160,118,14,ES_AUTOHSCROLL
GROUPBOX "AviFiles",IDC_STATIC,0,181,247,28
EDITTEXT IDC_AVIPATHEDIT,5,189,221,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BROWSEAVI,229,189,13,14
GROUPBOX "Cheats",IDC_STATIC,0,212,247,50
EDITTEXT IDC_CHEATPATHEDIT,5,221,221,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BROWSECHEATS,229,221,13,14
LTEXT "R4 cheats database file name",IDC_STATIC,56,238,100,17
CONTROL "CHEAT.DAT",IDC_R4TYPE1,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,160,238,54,10
CONTROL "USRCHEAT.DAT",IDC_R4TYPE2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,160,250,67,10
GROUPBOX "Lua",IDC_STATIC,0,265,247,38
EDITTEXT IDC_LUAPATHEDIT,5,275,221,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BROWSELUA,229,275,13,14
CONTROL "Auto-load Lua scripts with ROM",IDC_AUTOLOADLUA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,291,219,8
PUSHBUTTON "Defaults",IDC_PATHDEFAULTS,3,306,50,14
DEFPUSHBUTTON "OK",IDOK,148,306,50,14
PUSHBUTTON "Cancel",IDCANCEL,198,306,50,14
END
IDD_ARCHIVEFILECHOOSER DIALOGEX 0, 0, 182, 113

View File

@ -253,6 +253,7 @@ void PathInfo::ReadPathSettings()
ReadKey(pathToRoms, ROMKEY);
ReadKey(pathToBattery, BATTERYKEY);
ReadKey(pathToSramImportExport, SRAMIMPORTKEY);
ReadKey(pathToStates, STATEKEY);
ReadKey(pathToStateSlots, STATESLOTKEY);
ReadKey(pathToScreenshots, SCREENSHOTKEY);
@ -293,6 +294,9 @@ void PathInfo::SwitchPath(Action action, KnownPath path, char *buffer)
case BATTERY:
pathToCopy = pathToBattery;
break;
case SRAM_IMPORT_EXPORT:
pathToCopy = pathToSramImportExport;
break;
case STATES:
pathToCopy = pathToStates;
break;

View File

@ -72,6 +72,7 @@ public:
#define ROMKEY "Roms"
#define BATTERYKEY "Battery"
#define SRAMIMPORTKEY "SramImportExport"
#define STATEKEY "States"
#define STATESLOTKEY "StateSlots"
#define SCREENSHOTKEY "Screenshots"
@ -94,6 +95,7 @@ public:
FIRSTKNOWNPATH = 0,
ROMS = 0,
BATTERY,
SRAM_IMPORT_EXPORT,
STATES,
STATE_SLOTS,
SCREENSHOTS,
@ -108,6 +110,7 @@ public:
char pathToRoms[MAX_PATH];
char pathToBattery[MAX_PATH];
char pathToSramImportExport[MAX_PATH];
char pathToStates[MAX_PATH];
char pathToStateSlots[MAX_PATH];
char pathToScreenshots[MAX_PATH];