2014-08-13 20:30:35 +00:00
|
|
|
/*
|
|
|
|
AppleWin : An Apple //e emulator for Windows
|
|
|
|
|
|
|
|
Copyright (C) 1994-1996, Michael O'Brien
|
|
|
|
Copyright (C) 1999-2001, Oliver Schmidt
|
|
|
|
Copyright (C) 2002-2005, Tom Charlesworth
|
|
|
|
Copyright (C) 2006-2014, Tom Charlesworth, Michael Pohoreski, Nick Westgate
|
|
|
|
|
|
|
|
AppleWin is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
AppleWin is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with AppleWin; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2012-03-27 21:20:36 +00:00
|
|
|
#include "StdAfx.h"
|
2014-08-13 20:30:35 +00:00
|
|
|
|
2018-02-24 15:12:40 +00:00
|
|
|
#include "../Applewin.h"
|
2019-12-19 19:42:30 +00:00
|
|
|
#include "../CardManager.h"
|
2018-02-25 15:09:25 +00:00
|
|
|
#include "../Disk.h" // Drive_e, Disk_Status_e
|
2018-02-24 15:12:40 +00:00
|
|
|
#include "../Frame.h"
|
|
|
|
#include "../Registry.h"
|
|
|
|
#include "../resource/resource.h"
|
2014-08-13 20:30:35 +00:00
|
|
|
#include "PageDisk.h"
|
|
|
|
#include "PropertySheetHelper.h"
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
CPageDisk* CPageDisk::ms_this = 0; // reinit'd in ctor
|
|
|
|
|
|
|
|
const TCHAR CPageDisk::m_discchoices[] =
|
|
|
|
TEXT("Authentic Speed\0")
|
|
|
|
TEXT("Enhanced Speed\0");
|
|
|
|
|
2014-10-01 23:18:46 +00:00
|
|
|
const TCHAR CPageDisk::m_defaultDiskOptions[] =
|
|
|
|
TEXT("Select Disk...\0")
|
|
|
|
TEXT("Eject Disk\0");
|
|
|
|
|
|
|
|
const TCHAR CPageDisk::m_defaultHDDOptions[] =
|
|
|
|
TEXT("Select Hard Disk Image...\0")
|
|
|
|
TEXT("Unplug Hard Disk Image\0");
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
BOOL CALLBACK CPageDisk::DlgProc(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam)
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
|
|
|
// Switch from static func to our instance
|
2012-05-06 22:14:03 +00:00
|
|
|
return CPageDisk::ms_this->DlgProcInternal(hWnd, message, wparam, lparam);
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam)
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
// Property Sheet notifications
|
|
|
|
|
|
|
|
switch (((LPPSHNOTIFY)lparam)->hdr.code)
|
|
|
|
{
|
2012-03-31 21:34:02 +00:00
|
|
|
case PSN_SETACTIVE:
|
|
|
|
// About to become the active page
|
|
|
|
m_PropertySheetHelper.SetLastPage(m_Page);
|
2012-05-06 22:14:03 +00:00
|
|
|
InitOptions(hWnd);
|
2012-03-31 21:34:02 +00:00
|
|
|
break;
|
2012-03-27 21:20:36 +00:00
|
|
|
case PSN_KILLACTIVE:
|
2012-05-06 22:14:03 +00:00
|
|
|
SetWindowLong(hWnd, DWL_MSGRESULT, FALSE); // Changes are valid
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
case PSN_APPLY:
|
2012-05-06 22:14:03 +00:00
|
|
|
DlgOK(hWnd);
|
|
|
|
SetWindowLong(hWnd, DWL_MSGRESULT, PSNRET_NOERROR); // Changes are valid
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
case PSN_QUERYCANCEL:
|
|
|
|
// Can use this to ask user to confirm cancel
|
|
|
|
break;
|
|
|
|
case PSN_RESET:
|
2012-05-06 22:14:03 +00:00
|
|
|
DlgCANCEL(hWnd);
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wparam))
|
|
|
|
{
|
2014-10-01 23:18:46 +00:00
|
|
|
case IDC_COMBO_DISK1:
|
2014-10-10 20:24:50 +00:00
|
|
|
if (HIWORD(wparam) == CBN_SELCHANGE)
|
|
|
|
{
|
2019-12-19 19:42:30 +00:00
|
|
|
HandleFloppyDriveCombo(hWnd, DRIVE_1, LOWORD(wparam));
|
2014-10-01 23:18:46 +00:00
|
|
|
FrameRefreshStatus(DRAW_BUTTON_DRIVES);
|
|
|
|
}
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
2014-10-01 23:18:46 +00:00
|
|
|
case IDC_COMBO_DISK2:
|
2014-10-10 20:24:50 +00:00
|
|
|
if (HIWORD(wparam) == CBN_SELCHANGE)
|
|
|
|
{
|
2019-12-19 19:42:30 +00:00
|
|
|
HandleFloppyDriveCombo(hWnd, DRIVE_2, LOWORD(wparam));
|
2014-10-01 23:18:46 +00:00
|
|
|
FrameRefreshStatus(DRAW_BUTTON_DRIVES);
|
|
|
|
}
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
2014-10-01 23:18:46 +00:00
|
|
|
case IDC_COMBO_HDD1:
|
2014-10-10 20:24:50 +00:00
|
|
|
if (HIWORD(wparam) == CBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
HandleHDDCombo(hWnd, HARDDISK_1, LOWORD(wparam));
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
break;
|
2014-10-01 23:18:46 +00:00
|
|
|
case IDC_COMBO_HDD2:
|
2014-10-10 20:24:50 +00:00
|
|
|
if (HIWORD(wparam) == CBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
HandleHDDCombo(hWnd, HARDDISK_2, LOWORD(wparam));
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDC_HDD_ENABLE:
|
2012-05-06 22:14:03 +00:00
|
|
|
EnableHDD(hWnd, IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE));
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
2018-12-09 11:48:22 +00:00
|
|
|
case IDC_HDD_SWAP:
|
|
|
|
HandleHDDSwap(hWnd);
|
|
|
|
break;
|
2012-03-27 21:20:36 +00:00
|
|
|
case IDC_CIDERPRESS_BROWSE:
|
|
|
|
{
|
2014-08-13 20:30:35 +00:00
|
|
|
std::string CiderPressLoc = m_PropertySheetHelper.BrowseToFile(hWnd, TEXT("Select path to CiderPress"), REGVALUE_CIDERPRESSLOC, TEXT("Applications (*.exe)\0*.exe\0") TEXT("All Files\0*.*\0") );
|
2019-09-07 18:37:19 +00:00
|
|
|
RegSaveString(TEXT(REG_CONFIG), REGVALUE_CIDERPRESSLOC, 1, CiderPressLoc);
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_CIDERPRESS_FILENAME, WM_SETTEXT, 0, (LPARAM) CiderPressLoc.c_str());
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
case WM_INITDIALOG:
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
2019-12-19 19:42:30 +00:00
|
|
|
m_PropertySheetHelper.FillComboBox(hWnd, IDC_DISKTYPE, m_discchoices, g_CardMgr.GetDisk2CardMgr().GetEnhanceDisk() ? 1 : 0);
|
2014-10-01 23:18:46 +00:00
|
|
|
|
2019-12-19 19:42:30 +00:00
|
|
|
if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2)
|
|
|
|
InitComboFloppyDrive(hWnd, SLOT6);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2019-12-19 19:42:30 +00:00
|
|
|
InitComboHDD(hWnd, SLOT7);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2019-08-09 03:50:29 +00:00
|
|
|
TCHAR PathToCiderPress[MAX_PATH];
|
|
|
|
RegLoadString(TEXT(REG_CONFIG), REGVALUE_CIDERPRESSLOC, 1, PathToCiderPress, MAX_PATH, TEXT(""));
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_CIDERPRESS_FILENAME ,WM_SETTEXT, 0, (LPARAM)PathToCiderPress);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
CheckDlgButton(hWnd, IDC_HDD_ENABLE, HD_CardIsEnabled() ? BST_CHECKED : BST_UNCHECKED);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
EnableHDD(hWnd, IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE));
|
|
|
|
|
|
|
|
InitOptions(hWnd);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-12-19 19:42:30 +00:00
|
|
|
void CPageDisk::InitComboFloppyDrive(HWND hWnd, UINT slot)
|
|
|
|
{
|
|
|
|
Disk2InterfaceCard* pDisk2Card = dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(slot));
|
|
|
|
|
|
|
|
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK1, m_defaultDiskOptions, -1);
|
|
|
|
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK2, m_defaultDiskOptions, -1);
|
|
|
|
|
|
|
|
if (!pDisk2Card->GetFullName(DRIVE_1).empty())
|
|
|
|
{
|
|
|
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_INSERTSTRING, 0, (LPARAM)pDisk2Card->GetFullName(DRIVE_1).c_str());
|
|
|
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_SETCURSEL, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDisk2Card->GetFullName(DRIVE_2).empty())
|
|
|
|
{
|
|
|
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_INSERTSTRING, 0, (LPARAM)pDisk2Card->GetFullName(DRIVE_2).c_str());
|
|
|
|
SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_SETCURSEL, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPageDisk::InitComboHDD(HWND hWnd, UINT /*slot*/)
|
2018-12-09 11:48:22 +00:00
|
|
|
{
|
|
|
|
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_HDD1, m_defaultHDDOptions, -1);
|
|
|
|
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_HDD2, m_defaultHDDOptions, -1);
|
|
|
|
|
2019-09-07 08:02:39 +00:00
|
|
|
if (!HD_GetFullName(HARDDISK_1).empty())
|
2018-12-09 11:48:22 +00:00
|
|
|
{
|
2019-09-07 08:02:39 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_COMBO_HDD1, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(HARDDISK_1).c_str());
|
2018-12-09 11:48:22 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_COMBO_HDD1, CB_SETCURSEL, 0, 0);
|
|
|
|
}
|
|
|
|
|
2019-09-07 08:02:39 +00:00
|
|
|
if (!HD_GetFullName(HARDDISK_2).empty())
|
2018-12-09 11:48:22 +00:00
|
|
|
{
|
2019-09-07 08:02:39 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_COMBO_HDD2, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(HARDDISK_2).c_str());
|
2018-12-09 11:48:22 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_COMBO_HDD2, CB_SETCURSEL, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
void CPageDisk::DlgOK(HWND hWnd)
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
2018-02-25 15:09:25 +00:00
|
|
|
const bool bNewEnhanceDisk = SendDlgItemMessage(hWnd, IDC_DISKTYPE,CB_GETCURSEL, 0, 0) ? true : false;
|
2019-12-19 19:42:30 +00:00
|
|
|
if (bNewEnhanceDisk != g_CardMgr.GetDisk2CardMgr().GetEnhanceDisk())
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
2019-12-19 19:42:30 +00:00
|
|
|
g_CardMgr.GetDisk2CardMgr().SetEnhanceDisk(bNewEnhanceDisk);
|
2018-02-25 15:09:25 +00:00
|
|
|
REGSAVE(TEXT(REGVALUE_ENHANCE_DISK_SPEED), (DWORD)bNewEnhanceDisk);
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
const bool bNewHDDIsEnabled = IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE) ? true : false;
|
|
|
|
if (bNewHDDIsEnabled != HD_CardIsEnabled())
|
|
|
|
{
|
|
|
|
m_PropertySheetHelper.GetConfigNew().m_bEnableHDD = bNewHDDIsEnabled;
|
|
|
|
}
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2019-09-07 18:37:19 +00:00
|
|
|
RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_LAST_HARDDISK_1), 1, HD_GetFullPathName(HARDDISK_1));
|
|
|
|
RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_LAST_HARDDISK_2), 1, HD_GetFullPathName(HARDDISK_2));
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
m_PropertySheetHelper.PostMsgAfterClose(hWnd, m_Page);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPageDisk::InitOptions(HWND hWnd)
|
|
|
|
{
|
|
|
|
// Nothing to do:
|
|
|
|
// - no changes made on any other pages affect this page
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
void CPageDisk::EnableHDD(HWND hWnd, BOOL bEnable)
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
2014-10-01 23:18:46 +00:00
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_COMBO_HDD1), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_COMBO_HDD2), bEnable);
|
2018-12-09 11:48:22 +00:00
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_HDD_SWAP), bEnable);
|
2014-10-01 23:18:46 +00:00
|
|
|
}
|
|
|
|
|
2017-06-03 17:12:40 +00:00
|
|
|
void CPageDisk::EnableDisk(HWND hWnd, BOOL bEnable)
|
|
|
|
{
|
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_COMBO_DISK1), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_COMBO_DISK2), bEnable);
|
|
|
|
}
|
|
|
|
|
2014-10-10 20:24:50 +00:00
|
|
|
void CPageDisk::HandleHDDCombo(HWND hWnd, UINT driveSelected, UINT comboSelected)
|
2014-10-01 23:18:46 +00:00
|
|
|
{
|
2017-06-03 17:21:27 +00:00
|
|
|
if (!IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE))
|
|
|
|
return;
|
|
|
|
|
2014-10-01 23:18:46 +00:00
|
|
|
// Search from "select hard drive"
|
|
|
|
DWORD dwOpenDialogIndex = (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_FINDSTRINGEXACT, -1, (LPARAM)&m_defaultHDDOptions[0]);
|
|
|
|
DWORD dwComboSelection = (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_GETCURSEL, 0, 0);
|
2017-06-03 17:21:27 +00:00
|
|
|
|
|
|
|
SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, -1, 0); // Set to "empty" item
|
|
|
|
|
|
|
|
if (dwComboSelection == dwOpenDialogIndex)
|
2014-10-10 20:24:50 +00:00
|
|
|
{
|
2017-06-03 17:21:27 +00:00
|
|
|
EnableHDD(hWnd, FALSE); // Prevent multiple Selection dialogs to be triggered
|
|
|
|
bool bRes = HD_Select(driveSelected);
|
|
|
|
EnableHDD(hWnd, TRUE);
|
2017-06-03 17:12:40 +00:00
|
|
|
|
2017-06-03 17:21:27 +00:00
|
|
|
if (!bRes)
|
2014-10-10 20:24:50 +00:00
|
|
|
{
|
2017-06-03 17:21:27 +00:00
|
|
|
if (SendDlgItemMessage(hWnd, comboSelected, CB_GETCOUNT, 0, 0) == 3) // If there's already a HDD...
|
|
|
|
SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0); // then reselect it in the ComboBox
|
|
|
|
return;
|
|
|
|
}
|
2017-06-03 17:12:40 +00:00
|
|
|
|
2017-06-03 17:21:27 +00:00
|
|
|
// Add hard drive name as item 0 and select it
|
|
|
|
if (dwOpenDialogIndex > 0)
|
|
|
|
{
|
|
|
|
// Remove old item first
|
|
|
|
SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0);
|
|
|
|
}
|
2017-06-03 17:12:40 +00:00
|
|
|
|
2019-09-07 08:02:39 +00:00
|
|
|
SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(driveSelected).c_str());
|
2017-06-03 17:21:27 +00:00
|
|
|
SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0);
|
2014-10-01 23:18:46 +00:00
|
|
|
|
2017-06-03 17:21:27 +00:00
|
|
|
// If the HD was in the other combo, remove now
|
|
|
|
DWORD comboOther = (comboSelected == IDC_COMBO_HDD1) ? IDC_COMBO_HDD2 : IDC_COMBO_HDD1;
|
2014-10-01 23:18:46 +00:00
|
|
|
|
2019-09-07 08:02:39 +00:00
|
|
|
DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)HD_GetFullName(driveSelected).c_str());
|
2017-06-03 17:21:27 +00:00
|
|
|
if (duplicated != CB_ERR)
|
|
|
|
{
|
|
|
|
SendDlgItemMessage(hWnd, comboOther, CB_DELETESTRING, duplicated, 0);
|
|
|
|
SendDlgItemMessage(hWnd, comboOther, CB_SETCURSEL, -1, 0);
|
2014-10-01 23:18:46 +00:00
|
|
|
}
|
2017-06-03 17:21:27 +00:00
|
|
|
}
|
|
|
|
else if (dwComboSelection == (dwOpenDialogIndex+1))
|
|
|
|
{
|
|
|
|
if (dwComboSelection > 1)
|
2014-10-10 20:24:50 +00:00
|
|
|
{
|
2017-06-03 17:21:27 +00:00
|
|
|
UINT uCommand = (driveSelected == 0) ? IDC_COMBO_HDD1 : IDC_COMBO_HDD2;
|
|
|
|
if (RemovalConfirmation(uCommand))
|
|
|
|
{
|
|
|
|
// Unplug selected disk
|
|
|
|
HD_Unplug(driveSelected);
|
|
|
|
// Remove drive from list
|
|
|
|
SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0);
|
|
|
|
}
|
|
|
|
else
|
2014-10-10 20:24:50 +00:00
|
|
|
{
|
2017-06-03 17:21:27 +00:00
|
|
|
SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0);
|
2014-10-01 23:18:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-19 19:42:30 +00:00
|
|
|
void CPageDisk::HandleFloppyDriveCombo(HWND hWnd, UINT driveSelected, UINT comboSelected)
|
2014-10-01 23:18:46 +00:00
|
|
|
{
|
2019-12-19 19:42:30 +00:00
|
|
|
Disk2InterfaceCard* pDisk2Card = (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2)
|
|
|
|
? dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6))
|
|
|
|
: NULL;
|
|
|
|
|
2014-10-10 20:24:50 +00:00
|
|
|
// Search from "select floppy drive"
|
2014-10-01 23:18:46 +00:00
|
|
|
DWORD dwOpenDialogIndex = (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_FINDSTRINGEXACT, -1, (LPARAM)&m_defaultDiskOptions[0]);
|
|
|
|
DWORD dwComboSelection = (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_GETCURSEL, 0, 0);
|
2017-06-03 17:12:40 +00:00
|
|
|
|
|
|
|
SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, -1, 0); // Set to "empty" item
|
|
|
|
|
2014-10-10 20:24:50 +00:00
|
|
|
if (dwComboSelection == dwOpenDialogIndex)
|
|
|
|
{
|
2017-06-03 17:12:40 +00:00
|
|
|
EnableDisk(hWnd, FALSE); // Prevent multiple Selection dialogs to be triggered
|
2019-12-19 19:42:30 +00:00
|
|
|
bool bRes = false;
|
|
|
|
if (pDisk2Card) bRes = pDisk2Card->UserSelectNewDiskImage(driveSelected);
|
2017-06-03 17:12:40 +00:00
|
|
|
EnableDisk(hWnd, TRUE);
|
|
|
|
|
|
|
|
if (!bRes)
|
|
|
|
{
|
|
|
|
if (SendDlgItemMessage(hWnd, comboSelected, CB_GETCOUNT, 0, 0) == 3) // If there's already a disk...
|
|
|
|
SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0); // then reselect it in the ComboBox
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-10 20:24:50 +00:00
|
|
|
// Add floppy drive name as item 0 and select it
|
|
|
|
if (dwOpenDialogIndex > 0)
|
|
|
|
{
|
2014-10-01 23:18:46 +00:00
|
|
|
//Remove old item first
|
|
|
|
SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0);
|
|
|
|
}
|
2017-06-03 17:12:40 +00:00
|
|
|
|
2019-12-19 19:42:30 +00:00
|
|
|
std::string fullname;
|
|
|
|
if (pDisk2Card) fullname = pDisk2Card->GetFullName(driveSelected);
|
|
|
|
SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)fullname.c_str());
|
2014-10-01 23:18:46 +00:00
|
|
|
SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2014-10-10 20:24:50 +00:00
|
|
|
// If the FD was in the other combo, remove now
|
2014-10-01 23:18:46 +00:00
|
|
|
DWORD comboOther = (comboSelected == IDC_COMBO_DISK1) ? IDC_COMBO_DISK2 : IDC_COMBO_DISK1;
|
|
|
|
|
2019-12-19 19:42:30 +00:00
|
|
|
DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)fullname.c_str());
|
2014-10-10 20:24:50 +00:00
|
|
|
if (duplicated != CB_ERR)
|
|
|
|
{
|
2014-10-01 23:18:46 +00:00
|
|
|
SendDlgItemMessage(hWnd, comboOther, CB_DELETESTRING, duplicated, 0);
|
|
|
|
SendDlgItemMessage(hWnd, comboOther, CB_SETCURSEL, -1, 0);
|
|
|
|
}
|
|
|
|
}
|
2014-10-10 20:24:50 +00:00
|
|
|
else if (dwComboSelection == (dwOpenDialogIndex + 1))
|
|
|
|
{
|
|
|
|
if (dwComboSelection > 1)
|
|
|
|
{
|
|
|
|
UINT uCommand = (driveSelected == 0) ? IDC_COMBO_DISK1 : IDC_COMBO_DISK2;
|
|
|
|
if (RemovalConfirmation(uCommand))
|
|
|
|
{
|
2017-06-03 17:12:40 +00:00
|
|
|
// Eject selected disk
|
2019-12-19 19:42:30 +00:00
|
|
|
if (pDisk2Card) pDisk2Card->EjectDisk(driveSelected);
|
2017-06-03 17:12:40 +00:00
|
|
|
// Remove drive from list
|
2014-10-01 23:18:46 +00:00
|
|
|
SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0);
|
|
|
|
}
|
2014-10-10 20:24:50 +00:00
|
|
|
else
|
|
|
|
{
|
2014-10-01 23:18:46 +00:00
|
|
|
SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
2014-10-01 23:18:46 +00:00
|
|
|
|
2018-12-09 11:48:22 +00:00
|
|
|
void CPageDisk::HandleHDDSwap(HWND hWnd)
|
|
|
|
{
|
|
|
|
if (!RemovalConfirmation(IDC_HDD_SWAP))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!HD_ImageSwap())
|
|
|
|
return;
|
|
|
|
|
2019-12-19 19:42:30 +00:00
|
|
|
InitComboHDD(hWnd, SLOT7);
|
2018-12-09 11:48:22 +00:00
|
|
|
}
|
2014-10-01 23:18:46 +00:00
|
|
|
|
2014-10-10 20:24:50 +00:00
|
|
|
UINT CPageDisk::RemovalConfirmation(UINT uCommand)
|
2014-10-01 23:18:46 +00:00
|
|
|
{
|
|
|
|
TCHAR szText[100];
|
|
|
|
bool bMsgBox = true;
|
2014-10-10 20:24:50 +00:00
|
|
|
|
|
|
|
if (uCommand == IDC_COMBO_DISK1 || uCommand == IDC_COMBO_DISK2)
|
2019-08-25 18:21:33 +00:00
|
|
|
StringCbPrintf(szText, sizeof(szText), "Do you really want to eject the disk in drive-%c ?", '1' + uCommand - IDC_COMBO_DISK1);
|
2014-10-10 20:24:50 +00:00
|
|
|
else if (uCommand == IDC_COMBO_HDD1 || uCommand == IDC_COMBO_HDD2)
|
2019-08-25 18:21:33 +00:00
|
|
|
StringCbPrintf(szText, sizeof(szText), "Do you really want to unplug harddisk-%c ?", '1' + uCommand - IDC_COMBO_HDD1);
|
2018-12-09 11:48:22 +00:00
|
|
|
else if (uCommand == IDC_HDD_SWAP)
|
2019-08-25 18:21:33 +00:00
|
|
|
StringCbPrintf(szText, sizeof(szText), "Do you really want to swap the harddisk images?");
|
2014-10-01 23:18:46 +00:00
|
|
|
else
|
|
|
|
bMsgBox = false;
|
|
|
|
|
|
|
|
if (bMsgBox)
|
|
|
|
{
|
|
|
|
int nRes = MessageBox(g_hFrameWindow, szText, TEXT("Eject/Unplug Warning"), MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND);
|
|
|
|
if (nRes == IDNO)
|
2014-10-10 20:24:50 +00:00
|
|
|
uCommand = 0;
|
2014-10-01 23:18:46 +00:00
|
|
|
}
|
2014-10-10 20:24:50 +00:00
|
|
|
|
|
|
|
return uCommand;
|
|
|
|
}
|