Merged from cm630 branch

Fix for browsing for CiderPress changed curr dir
Fix for pressing "OK" on Advanced sheet resulted in resetting savestate file to default
This commit is contained in:
tomch 2008-06-21 11:48:15 +00:00
parent 1251cff260
commit 08c46a4464
4 changed files with 42 additions and 30 deletions

View File

@ -174,7 +174,7 @@ BEGIN
GROUPBOX "Floppy Controller",IDC_STATIC,2,21,206,73
GROUPBOX "Harddisk Controller",IDC_STATIC,2,113,205,71
LTEXT "Path to CiderPress:",IDC_STATIC,5,190,74,8
EDITTEXT IDC_CIDERPRESS_FILENAME,5,200,143,12,ES_AUTOHSCROLL
EDITTEXT IDC_CIDERPRESS_FILENAME,5,200,143,12,ES_AUTOHSCROLL | ES_READONLY
PUSHBUTTON "Browse...",IDC_CIDERPRESS_BROWSE,154,200,50,14
END
@ -207,7 +207,7 @@ BEGIN
CONTROL "Save State on exit",IDC_SAVESTATE_ON_EXIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,68,74,10
PUSHBUTTON "Save State",IDC_SAVESTATE,16,85,85,15
PUSHBUTTON "Load State",IDC_LOADSTATE,16,107,85,15
EDITTEXT IDC_SAVESTATE_FILENAME,5,23,143,12,ES_AUTOHSCROLL
EDITTEXT IDC_SAVESTATE_FILENAME,5,23,143,12,ES_AUTOHSCROLL | ES_READONLY
LTEXT "(F11 during emulation)",IDC_STATIC,110,88,74,8
LTEXT "(F12 during emulation)",IDC_STATIC,110,110,90,8
PUSHBUTTON "Browse...",IDC_SAVESTATE_BROWSE,154,22,50,14

View File

@ -482,7 +482,7 @@ void LoadConfiguration ()
// Current/Starting Dir is the "root" of where the user keeps his disk images
RegLoadString(TEXT("Preferences"),REGVALUE_PREF_START_DIR,1,g_sCurrentDir,MAX_PATH);
SetCurrentDirectory(g_sCurrentDir);
SetCurrentImageDir();
char szUthernetInt[MAX_PATH] = {0};
RegLoadString(TEXT("Configuration"),TEXT("Uthernet Interface"),1,szUthernetInt,MAX_PATH);
@ -490,6 +490,13 @@ void LoadConfiguration ()
}
//===========================================================================
void SetCurrentImageDir()
{
SetCurrentDirectory(g_sCurrentDir);
}
//===========================================================================
void RegisterExtensions ()
{

View File

@ -1,5 +1,9 @@
#pragma once
void SetCurrentCLK6502();
void SetCurrentImageDir();
extern char VERSIONSTRING[]; // Contructed in WinMain()
extern TCHAR *g_pAppTitle;
@ -41,5 +45,3 @@ extern bool g_bDisableDirectSound; // Cmd line switch: don't init DS (so n
extern UINT g_Slot4; // Mockingboard or Mouse in slot4
extern HANDLE g_hCustomRomF8; // NULL if no custom rom
void SetCurrentCLK6502();

View File

@ -964,17 +964,21 @@ static BOOL CALLBACK DiskDlgProc (HWND window,
//===========================================================================
static char g_szNewDirectory[MAX_PATH];
static char g_szNewFilename[MAX_PATH];
static bool g_bSSNewFilename = false;
static char g_szSSNewDirectory[MAX_PATH];
static char g_szSSNewFilename[MAX_PATH];
static void SaveStateUpdate()
{
Snapshot_SetFilename(g_szNewFilename);
if (g_bSSNewFilename)
{
Snapshot_SetFilename(g_szSSNewFilename);
RegSaveString(TEXT("Configuration"),REGVALUE_SAVESTATE_FILENAME,1,Snapshot_GetFilename());
if(g_szNewDirectory[0])
RegSaveString(TEXT("Preferences"),REGVALUE_PREF_START_DIR,1,g_szNewDirectory);
if(g_szSSNewDirectory[0])
RegSaveString(TEXT("Preferences"),REGVALUE_PREF_START_DIR,1,g_szSSNewDirectory);
}
}
static int SaveStateSelectImage(HWND hWindow, TCHAR* pszTitle, bool bSave)
@ -1018,13 +1022,14 @@ static int SaveStateSelectImage(HWND hWindow, TCHAR* pszTitle, bool bSave)
if(nRes)
{
strcpy(g_szNewFilename, &szFilename[ofn.nFileOffset]);
strcpy(g_szSSNewFilename, &szFilename[ofn.nFileOffset]);
szFilename[ofn.nFileOffset] = 0;
if (_tcsicmp(szDirectory, szFilename))
strcpy(g_szNewDirectory, szFilename);
strcpy(g_szSSNewDirectory, szFilename);
}
g_bSSNewFilename = nRes ? true : false;
return nRes;
}
@ -1090,6 +1095,7 @@ static void AdvancedDlg_OK(HWND window, UINT afterclose)
else
{
if (NewApple2Clone != (g_uCloneType + APPLECLONE_MASK|APPLE2E_MASK))
{
MessageBox(window,
TEXT(
"You have changed the emulated clone type "
@ -1098,6 +1104,8 @@ static void AdvancedDlg_OK(HWND window, UINT afterclose)
"to Clone from the Configuration tab.\n\n"),
TEXT("Clone type changed"),
MB_ICONQUESTION | MB_OK | MB_SETFOREGROUND) ;
g_uCloneType = NewApple2Clone - (APPLECLONE_MASK|APPLE2E_MASK);
}
}
if (NewApple2Type > A2TYPE_APPLE2PLUS)
@ -1158,7 +1166,7 @@ static BOOL CALLBACK AdvancedDlgProc (HWND window,
break;
case IDC_SAVESTATE_BROWSE:
if(SaveStateSelectImage(window, TEXT("Select Save State file"), true))
SendDlgItemMessage(window, IDC_SAVESTATE_FILENAME, WM_SETTEXT, 0, (LPARAM) g_szNewFilename);
SendDlgItemMessage(window, IDC_SAVESTATE_FILENAME, WM_SETTEXT, 0, (LPARAM) g_szSSNewFilename);
break;
case IDC_SAVESTATE_ON_EXIT:
break;
@ -1205,7 +1213,7 @@ static BOOL CALLBACK AdvancedDlgProc (HWND window,
FillComboBox(window, IDC_CLONETYPE, g_CloneChoices, g_uCloneType);
InitFreezeDlgButton(window);
g_szNewDirectory[0] = 0x00;
g_szSSNewDirectory[0] = 0x00;
afterclose = 0;
break;
@ -1515,7 +1523,7 @@ DWORD PSP_GetVolumeMax()
bool PSP_SaveStateSelectImage(HWND hWindow, bool bSave)
{
g_szNewDirectory[0] = 0x00;
g_szSSNewDirectory[0] = 0x00;
if(SaveStateSelectImage(hWindow, bSave ? TEXT("Select Save State file")
: TEXT("Select Load State file"), bSave))
@ -1529,12 +1537,12 @@ bool PSP_SaveStateSelectImage(HWND hWindow, bool bSave)
}
}
//===========================================================================
string BrowseToCiderPress (HWND hWindow, TCHAR* pszTitle)
static string BrowseToCiderPress (HWND hWindow, TCHAR* pszTitle)
{
TCHAR szDirectory[MAX_PATH] = TEXT("");
TCHAR szCPFilename[MAX_PATH];
strcpy(szCPFilename, "");
TCHAR szCPFilename[MAX_PATH] = TEXT("");
RegLoadString(TEXT("Configuration"), REGVALUE_CIDERPRESSLOC, 1, szCPFilename ,MAX_PATH);
string PathName = szCPFilename;
@ -1555,20 +1563,15 @@ string BrowseToCiderPress (HWND hWindow, TCHAR* pszTitle)
int nRes = GetOpenFileName(&ofn);
if(nRes) //Okay is pressed
{
strcpy(g_szNewFilename, &szCPFilename[ofn.nFileOffset]);
szCPFilename[ofn.nFileOffset] = 0;
if (_tcsicmp(szDirectory, szCPFilename))
strcpy(g_szNewDirectory, szCPFilename);
SetCurrentImageDir(); // Reset, since GetOpenFileName() will've changed curr dir
PathName = szCPFilename;
PathName.append (g_szNewFilename);
}
else //Cancel is pressed.
{
RegLoadString(TEXT("Configuration"), REGVALUE_CIDERPRESSLOC, 1, szCPFilename,MAX_PATH);
RegLoadString(TEXT("Configuration"), REGVALUE_CIDERPRESSLOC, 1, szCPFilename, MAX_PATH);
PathName = szCPFilename;
}
return PathName;
}