From 08c46a446480139f9edd9dbce60bd49db91ea6df Mon Sep 17 00:00:00 2001 From: tomch Date: Sat, 21 Jun 2008 11:48:15 +0000 Subject: [PATCH] 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 --- resource/Applewin.rc | 4 +-- source/Applewin.cpp | 9 +++++- source/Applewin.h | 6 ++-- source/PropertySheetPage.cpp | 53 +++++++++++++++++++----------------- 4 files changed, 42 insertions(+), 30 deletions(-) diff --git a/resource/Applewin.rc b/resource/Applewin.rc index 8afb60a3..0d4ea366 100644 --- a/resource/Applewin.rc +++ b/resource/Applewin.rc @@ -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 diff --git a/source/Applewin.cpp b/source/Applewin.cpp index c0338e02..5e0e9d21 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -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 () { diff --git a/source/Applewin.h b/source/Applewin.h index 973b4182..df288b9b 100644 --- a/source/Applewin.h +++ b/source/Applewin.h @@ -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(); diff --git a/source/PropertySheetPage.cpp b/source/PropertySheetPage.cpp index ab3e8e24..b1b01f05 100644 --- a/source/PropertySheetPage.cpp +++ b/source/PropertySheetPage.cpp @@ -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()); + 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 " @@ -1097,7 +1103,9 @@ static void AdvancedDlg_OK(HWND window, UINT afterclose) "you shall set the emulated computer type " "to Clone from the Configuration tab.\n\n"), TEXT("Clone type changed"), - MB_ICONQUESTION | MB_OK | MB_SETFOREGROUND) ; + 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,18 +1537,18 @@ 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; OPENFILENAME ofn; ZeroMemory(&ofn,sizeof(OPENFILENAME)); - + ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hWindow; ofn.hInstance = g_hInstance; @@ -1551,24 +1559,19 @@ string BrowseToCiderPress (HWND hWindow, TCHAR* pszTitle) ofn.lpstrInitialDir = szDirectory; ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrTitle = 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; }