From cc93d4ab92afa0ce61fccd57464f1e6cc5d7a4c4 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Tue, 13 Jan 2015 22:08:58 -0800 Subject: [PATCH] File open tweaks - Remove *.* from AppleSingle filter spec, since "all files" now works just fine. - Make "all files" the default if nothing is configured. --- app/Main.cpp | 11 ++++++++--- app/Main.h | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Main.cpp b/app/Main.cpp index 3c55e15..ef49894 100644 --- a/app/Main.cpp +++ b/app/Main.cpp @@ -67,7 +67,7 @@ const WCHAR MainWindow::kOpenBinaryII[] = const WCHAR MainWindow::kOpenACU[] = L"ACU Archives" /* (.acu)*/ L"|*.acu|"; const WCHAR MainWindow::kOpenAppleSingle[] = - L"AppleSingle files" /* (.as *.*)*/ L"|*.as;*.*|"; + L"AppleSingle files" /* (.as)*/ L"|*.as|"; const WCHAR MainWindow::kOpenDiskImage[] = L"Disk Images" /* (.shk .sdk .dsk .po .do .d13 .2mg .img .nib .nb2 .raw .hdv .dc .dc6 .ddd .app .fdi .iso .gz .zip)*/ L"|" L"*.shk;*.sdk;*.dsk;*.po;*.do;*.d13;*.2mg;*.img;*.nib;*.nb2;*.raw;*.hdv;*.dc;*.dc6;*.ddd;*.app;*.fdi;*.iso;*.gz;*.zip|"; @@ -1200,7 +1200,12 @@ void MainWindow::OnFileOpen(void) CFileDialog dlg(TRUE, L"shk", NULL, OFN_FILEMUSTEXIST, openFilters, this); - dlg.m_ofn.nFilterIndex = fPreferences.GetPrefLong(kPrLastOpenFilterIndex); + DWORD savedIndex = fPreferences.GetPrefLong(kPrLastOpenFilterIndex); + if (savedIndex < kFilterIndexFIRST || savedIndex > kFilterIndexMAX) { + // default to *.* if not set (zero) or out of range + savedIndex = kFilterIndexGeneric; + } + dlg.m_ofn.nFilterIndex = savedIndex; dlg.m_ofn.lpstrInitialDir = fPreferences.GetPrefString(kPrOpenArchiveFolder); if (dlg.DoModal() != IDOK) @@ -1974,7 +1979,7 @@ int MainWindow::LoadArchive(const WCHAR* fileName, const WCHAR* extension, /* * That didn't work. Try the others. */ - for (int i = kFilterIndexFIRST; i <= kFilterIndexLAST; i++) { + for (int i = kFilterIndexFIRST; i <= kFilterIndexLASTNG; i++) { if (i == filterIndex) continue; pOpenArchive = CreateArchiveInstance((FilterIndex) i); diff --git a/app/Main.h b/app/Main.h index fa53b7d..ac43139 100644 --- a/app/Main.h +++ b/app/Main.h @@ -25,6 +25,8 @@ #define WMU_LATE_INIT (WM_USER+0) #define WMU_START (WM_USER+1) // used by ActionProgressDialog +// The filter index is saved in the registry, so if you reorder this list +// you will briefly annoy existing users. enum FilterIndex { kFilterIndexFIRST = 1, // first index, must be non-Generic kFilterIndexNuFX = 1, @@ -32,7 +34,7 @@ enum FilterIndex { kFilterIndexACU = 3, kFilterIndexAppleSingle = 4, kFilterIndexDiskImage = 5, - kFilterIndexLAST = 5, // last non-Generic index + kFilterIndexLASTNG = 5, // last non-Generic index kFilterIndexGeneric = 6, // *.* filter used kFilterIndexMAX = 6 // highest valid number