2012-03-27 21:20:36 +00:00
|
|
|
#include "StdAfx.h"
|
|
|
|
#include "PageAdvanced.h"
|
|
|
|
#include "PropertySheetHelper.h"
|
|
|
|
#include "..\resource\resource.h"
|
|
|
|
|
|
|
|
CPageAdvanced* CPageAdvanced::ms_this = 0; // reinit'd in ctor
|
|
|
|
|
|
|
|
enum CLONECHOICE {MENUITEM_CLONEMIN, MENUITEM_PRAVETS82=MENUITEM_CLONEMIN, MENUITEM_PRAVETS8M, MENUITEM_PRAVETS8A, MENUITEM_CLONEMAX};
|
|
|
|
const TCHAR CPageAdvanced::m_CloneChoices[] =
|
|
|
|
TEXT("Pravets 82\0") // Bulgarian
|
|
|
|
TEXT("Pravets 8M\0") // Bulgarian
|
|
|
|
TEXT("Pravets 8A\0"); // Bulgarian
|
|
|
|
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
BOOL CALLBACK CPageAdvanced::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 CPageAdvanced::ms_this->DlgProcInternal(hWnd, message, wparam, lparam);
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
BOOL CPageAdvanced::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)
|
|
|
|
{
|
|
|
|
case PSN_SETACTIVE:
|
|
|
|
// About to become the active page
|
2012-03-31 21:34:02 +00:00
|
|
|
m_PropertySheetHelper.SetLastPage(m_Page);
|
2012-05-06 22:14:03 +00:00
|
|
|
InitOptions(hWnd);
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
case IDC_SAVESTATE_FILENAME:
|
|
|
|
break;
|
|
|
|
case IDC_SAVESTATE_BROWSE:
|
2013-12-29 22:09:41 +00:00
|
|
|
if(m_PropertySheetHelper.SaveStateSelectImage(hWnd, TEXT("Select Save State file"), false))
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_SAVESTATE_FILENAME, WM_SETTEXT, 0, (LPARAM)m_PropertySheetHelper.GetSSNewFilename());
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
case IDC_PRINTER_DUMP_FILENAME_BROWSE:
|
|
|
|
{
|
2012-05-06 22:14:03 +00:00
|
|
|
string strPrinterDumpLoc = m_PropertySheetHelper.BrowseToFile(hWnd, TEXT("Select printer dump file"), REGVALUE_PRINTER_FILENAME, TEXT("Text files (*.txt)\0*.txt\0") TEXT("All Files\0*.*\0"));
|
|
|
|
SendDlgItemMessage(hWnd, IDC_PRINTER_DUMP_FILENAME, WM_SETTEXT, 0, (LPARAM)strPrinterDumpLoc.c_str());
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDC_SAVESTATE_ON_EXIT:
|
|
|
|
break;
|
|
|
|
case IDC_SAVESTATE:
|
2012-05-06 22:14:03 +00:00
|
|
|
m_PropertySheetHelper.GetConfigNew().m_uSaveLoadStateMsg = WM_USER_SAVESTATE;
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
case IDC_LOADSTATE:
|
2012-05-06 22:14:03 +00:00
|
|
|
m_PropertySheetHelper.GetConfigNew().m_uSaveLoadStateMsg = WM_USER_LOADSTATE;
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
//
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
case IDC_THE_FREEZES_F8_ROM_FW:
|
|
|
|
{
|
2012-05-06 22:14:03 +00:00
|
|
|
const UINT uNewState = IsDlgButtonChecked(hWnd, IDC_THE_FREEZES_F8_ROM_FW) ? 1 : 0;
|
|
|
|
m_PropertySheetHelper.GetConfigNew().m_bEnableTheFreezesF8Rom = uNewState;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_CLONETYPE:
|
|
|
|
if(HIWORD(wparam) == CBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
const DWORD NewCloneMenuItem = (DWORD) SendDlgItemMessage(hWnd, IDC_CLONETYPE, CB_GETCURSEL, 0, 0);
|
|
|
|
const eApple2Type NewCloneType = GetCloneType(NewCloneMenuItem);
|
|
|
|
m_PropertySheetHelper.GetConfigNew().m_Apple2Type = NewCloneType;
|
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
|
|
|
{
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd,IDC_SAVESTATE_FILENAME,WM_SETTEXT,0,(LPARAM)Snapshot_GetFilename());
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
CheckDlgButton(hWnd, IDC_SAVESTATE_ON_EXIT, g_bSaveStateOnExit ? BST_CHECKED : BST_UNCHECKED);
|
|
|
|
CheckDlgButton(hWnd, IDC_DUMPTOPRINTER, g_bDumpToPrinter ? BST_CHECKED : BST_UNCHECKED);
|
|
|
|
CheckDlgButton(hWnd, IDC_PRINTER_CONVERT_ENCODING, g_bConvertEncoding ? BST_CHECKED : BST_UNCHECKED);
|
|
|
|
CheckDlgButton(hWnd, IDC_PRINTER_FILTER_UNPRINTABLE, g_bFilterUnprintable ? BST_CHECKED : BST_UNCHECKED);
|
|
|
|
CheckDlgButton(hWnd, IDC_PRINTER_APPEND, g_bPrinterAppend ? BST_CHECKED : BST_UNCHECKED);
|
|
|
|
SendDlgItemMessage(hWnd, IDC_SPIN_PRINTER_IDLE, UDM_SETRANGE, 0, MAKELONG(999,0));
|
|
|
|
SendDlgItemMessage(hWnd, IDC_SPIN_PRINTER_IDLE, UDM_SETPOS, 0, MAKELONG(Printer_GetIdleLimit (),0));
|
|
|
|
SendDlgItemMessage(hWnd, IDC_PRINTER_DUMP_FILENAME, WM_SETTEXT, 0, (LPARAM)Printer_GetFilename());
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
InitOptions(hWnd);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
m_PropertySheetHelper.ClearSSNewDirectory();
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
// Need to specify cmd-line switch: -printer-real to enable this control
|
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_DUMPTOPRINTER), g_bEnableDumpToRealPrinter ? TRUE : FALSE);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
void CPageAdvanced::DlgOK(HWND hWnd)
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
|
|
|
// Update save-state filename
|
|
|
|
{
|
|
|
|
char szFilename[MAX_PATH];
|
|
|
|
memset(szFilename, 0, sizeof(szFilename));
|
|
|
|
* (USHORT*) szFilename = sizeof(szFilename);
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
UINT nLineLength = SendDlgItemMessage(hWnd, IDC_SAVESTATE_FILENAME, EM_LINELENGTH, 0, 0);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_SAVESTATE_FILENAME, EM_GETLINE, 0, (LPARAM)szFilename);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
nLineLength = nLineLength > sizeof(szFilename)-1 ? sizeof(szFilename)-1 : nLineLength;
|
|
|
|
szFilename[nLineLength] = 0x00;
|
|
|
|
|
|
|
|
m_PropertySheetHelper.SaveStateUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update printer dump filename
|
|
|
|
{
|
|
|
|
char szFilename[MAX_PATH];
|
|
|
|
memset(szFilename, 0, sizeof(szFilename));
|
|
|
|
* (USHORT*) szFilename = sizeof(szFilename);
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
UINT nLineLength = SendDlgItemMessage(hWnd, IDC_PRINTER_DUMP_FILENAME, EM_LINELENGTH, 0, 0);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_PRINTER_DUMP_FILENAME, EM_GETLINE, 0, (LPARAM)szFilename);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
nLineLength = nLineLength > sizeof(szFilename)-1 ? sizeof(szFilename)-1 : nLineLength;
|
|
|
|
szFilename[nLineLength] = 0x00;
|
|
|
|
|
|
|
|
Printer_SetFilename(szFilename);
|
|
|
|
RegSaveString(TEXT(REG_CONFIG), REGVALUE_PRINTER_FILENAME, 1, Printer_GetFilename());
|
|
|
|
}
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
g_bSaveStateOnExit = IsDlgButtonChecked(hWnd, IDC_SAVESTATE_ON_EXIT) ? true : false;
|
2012-03-27 21:20:36 +00:00
|
|
|
REGSAVE(TEXT(REGVALUE_SAVE_STATE_ON_EXIT), g_bSaveStateOnExit ? 1 : 0);
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
g_bDumpToPrinter = IsDlgButtonChecked(hWnd, IDC_DUMPTOPRINTER ) ? true : false;
|
2012-03-27 21:20:36 +00:00
|
|
|
REGSAVE(TEXT(REGVALUE_DUMP_TO_PRINTER), g_bDumpToPrinter ? 1 : 0);
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
g_bConvertEncoding = IsDlgButtonChecked(hWnd, IDC_PRINTER_CONVERT_ENCODING ) ? true : false;
|
2012-03-27 21:20:36 +00:00
|
|
|
REGSAVE(TEXT(REGVALUE_CONVERT_ENCODING), g_bConvertEncoding ? 1 : 0);
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
g_bFilterUnprintable = IsDlgButtonChecked(hWnd, IDC_PRINTER_FILTER_UNPRINTABLE ) ? true : false;
|
2012-03-27 21:20:36 +00:00
|
|
|
REGSAVE(TEXT(REGVALUE_FILTER_UNPRINTABLE), g_bFilterUnprintable ? 1 : 0);
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
g_bPrinterAppend = IsDlgButtonChecked(hWnd, IDC_PRINTER_APPEND) ? true : false;
|
2012-03-27 21:20:36 +00:00
|
|
|
REGSAVE(TEXT(REGVALUE_PRINTER_APPEND), g_bPrinterAppend ? 1 : 0);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
Printer_SetIdleLimit((short)SendDlgItemMessage(hWnd, IDC_SPIN_PRINTER_IDLE , UDM_GETPOS, 0, 0));
|
2012-03-27 21:20:36 +00:00
|
|
|
REGSAVE(TEXT(REGVALUE_PRINTER_IDLE_LIMIT),Printer_GetIdleLimit());
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
m_PropertySheetHelper.PostMsgAfterClose(hWnd, m_Page);
|
|
|
|
}
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
void CPageAdvanced::InitOptions(HWND hWnd)
|
|
|
|
{
|
|
|
|
InitFreezeDlgButton(hWnd);
|
|
|
|
InitCloneDropdownMenu(hWnd);
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Advanced->Clone: Menu item to eApple2Type
|
|
|
|
eApple2Type CPageAdvanced::GetCloneType(DWORD NewMenuItem)
|
|
|
|
{
|
|
|
|
switch (NewMenuItem)
|
|
|
|
{
|
|
|
|
case MENUITEM_PRAVETS82: return A2TYPE_PRAVETS82;
|
|
|
|
case MENUITEM_PRAVETS8M: return A2TYPE_PRAVETS8M;
|
|
|
|
case MENUITEM_PRAVETS8A: return A2TYPE_PRAVETS8A;
|
|
|
|
default: return A2TYPE_PRAVETS82;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int CPageAdvanced::GetCloneMenuItem(void)
|
|
|
|
{
|
2012-05-06 22:14:03 +00:00
|
|
|
const eApple2Type type = m_PropertySheetHelper.GetConfigNew().m_Apple2Type;
|
|
|
|
const bool bIsClone = IsClone(type);
|
|
|
|
if (!bIsClone)
|
2012-03-27 21:20:36 +00:00
|
|
|
return MENUITEM_CLONEMIN;
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
int nMenuItem = type - A2TYPE_PRAVETS;
|
2012-03-27 21:20:36 +00:00
|
|
|
if (nMenuItem < 0 || nMenuItem >= MENUITEM_CLONEMAX)
|
|
|
|
return MENUITEM_CLONEMIN;
|
|
|
|
|
|
|
|
return nMenuItem;
|
|
|
|
}
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
void CPageAdvanced::InitFreezeDlgButton(HWND hWnd)
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
2012-05-06 22:14:03 +00:00
|
|
|
const bool bIsApple2 = IsApple2( m_PropertySheetHelper.GetConfigNew().m_Apple2Type );
|
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_THE_FREEZES_F8_ROM_FW), bIsApple2 ? TRUE : FALSE);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
const UINT CheckTheFreezesRom = m_PropertySheetHelper.GetConfigNew().m_bEnableTheFreezesF8Rom ? BST_CHECKED : BST_UNCHECKED;
|
|
|
|
CheckDlgButton(hWnd, IDC_THE_FREEZES_F8_ROM_FW, CheckTheFreezesRom);
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
void CPageAdvanced::InitCloneDropdownMenu(HWND hWnd)
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
|
|
|
// Set clone menu choice (ok even if it's not a clone)
|
2012-05-06 22:14:03 +00:00
|
|
|
const int nCurrentChoice = GetCloneMenuItem();
|
|
|
|
m_PropertySheetHelper.FillComboBox(hWnd, IDC_CLONETYPE, m_CloneChoices, nCurrentChoice);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
const bool bIsClone = IsClone( m_PropertySheetHelper.GetConfigNew().m_Apple2Type );
|
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_CLONETYPE), bIsClone ? TRUE : FALSE);
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|