CGeneralOptionsPage::CGeneralOptionsPage(CSettingConfig * SettingsConfig, HWND hParent, const RECT & rcDispay) :
m_SettingsConfig(SettingsConfig)
{
    if (!Create(hParent, rcDispay))
    {
        return;
    }

    //Set the text for all gui Items
    SetDlgItemTextW(m_hWnd, IDC_AUTOSLEEP, wGS(OPTION_AUTO_SLEEP).c_str());
    SetDlgItemTextW(m_hWnd, IDC_LOAD_FULLSCREEN, wGS(OPTION_AUTO_FULLSCREEN).c_str());
    SetDlgItemTextW(m_hWnd, IDC_SCREEN_SAVER, wGS(OPTION_DISABLE_SS).c_str());
    SetDlgItemTextW(m_hWnd, IDC_BASIC_MODE, wGS(OPTION_BASIC_MODE).c_str());
    SetDlgItemTextW(m_hWnd, IDC_MAXROMS_TXT, wGS(RB_MAX_ROMS).c_str());
    SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT2, wGS(RB_ROMS).c_str());
    SetDlgItemTextW(m_hWnd, IDC_MAXROMDIR_TXT, wGS(RB_MAX_DIRS).c_str());
    SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT4, wGS(RB_DIRS).c_str());
    SetDlgItemTextW(m_hWnd, IDC_IPLDIR_TXT, wGS(OPTION_IPL_ROM_PATH).c_str());

    AddModCheckBox(GetDlgItem(IDC_AUTOSLEEP), Setting_AutoSleep);
    AddModCheckBox(GetDlgItem(IDC_LOAD_FULLSCREEN), Setting_AutoFullscreen);
    AddModCheckBox(GetDlgItem(IDC_SCREEN_SAVER), Setting_DisableScrSaver);
    AddModCheckBox(GetDlgItem(IDC_BASIC_MODE), UserInterface_BasicMode);

    CModifiedEditBox * TxtBox = AddModTextBox(GetDlgItem(IDC_REMEMBER), File_RecentGameFileCount, false);
    TxtBox->SetTextField(GetDlgItem(IDC_MAXROMS_TXT));

    TxtBox = AddModTextBox(GetDlgItem(IDC_REMEMBERDIR), Directory_RecentGameDirCount, false);
    TxtBox->SetTextField(GetDlgItem(IDC_MAXROMDIR_TXT));

    UpdatePageSettings();
}
void COptionsDirectoriesPage::SelectDirectory(LanguageStringID Title, CModifiedEditBox & EditBox, CModifiedButton & Default, CModifiedButton & selected)
{
	wchar_t Buffer[MAX_PATH], Directory[MAX_PATH];
	LPITEMIDLIST pidl;
	BROWSEINFOW bi;

	stdstr InitialDir = EditBox.GetWindowText();

	bi.hwndOwner = m_hWnd;
	bi.pidlRoot = NULL;
	bi.pszDisplayName = Buffer;
	bi.lpszTitle = GS(Title);
	bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
	bi.lpfn = (BFFCALLBACK)SelectDirCallBack;
	bi.lParam = (DWORD)InitialDir.c_str();
	if ((pidl = SHBrowseForFolderW(&bi)) != NULL)
	{
		if (SHGetPathFromIDListW(pidl, Directory))
		{
			stdstr path;
			CPath SelectedDir(path.FromUTF16(Directory), "");
			EditBox.SetChanged(true);
			EditBox.SetWindowText(SelectedDir);
			Default.SetChanged(true);
			Default.SetCheck(BST_UNCHECKED);
			selected.SetCheck(BM_SETCHECK);
			SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
		}
	}
}
CGameStatusPage::CGameStatusPage (HWND hParent, const RECT & rcDispay )
{
	if (!Create(hParent,rcDispay))
	{
		return;
	}

	CIniFile RomIniFile  (g_Settings->LoadString(SupportFile_RomDatabase).c_str());
	strlist Keys;
	RomIniFile.GetKeyList("Rom Status",Keys);
	stdstr Status = g_Settings->LoadString(Rdb_Status);

	CModifiedComboBoxTxt * ComboBox;
	ComboBox = AddModComboBoxTxt(GetDlgItem(IDC_STATUS_TYPE),Rdb_Status);
	if (ComboBox)
	{
		for (strlist::iterator item = Keys.begin(); item != Keys.end(); item++ ) 
		{
			if (strstr(item->c_str(),".Sel") != NULL) { continue; }
			if (strstr(item->c_str(),".Auto") != NULL) { continue; }
			ComboBox->AddItem(item->c_str(), item->c_str());
		}
		ComboBox->SetTextField(GetDlgItem(IDC_STATUS_TEXT));
	}
	CModifiedEditBox * TxtBox;
	TxtBox = AddModTextBox(GetDlgItem(IDC_NOTES_CORE),Rdb_NotesCore,true);
	TxtBox->SetTextField(GetDlgItem(IDC_NOTES_CORE_TEXT));
	TxtBox = AddModTextBox(GetDlgItem(IDC_NOTES_PLUGIN),Rdb_NotesPlugin,true);
	TxtBox->SetTextField(GetDlgItem(IDC_NOTES_PLUGIN_TEXT));

	UpdatePageSettings();
}
void COptionsDirectoriesPage::ResetDirectory(CModifiedEditBox & EditBox, SettingID Type)
{
	if (!EditBox.IsChanged())
	{
		return;
	}
	stdstr dir;
	g_Settings->LoadDefaultString(Type, dir);
	EditBox.SetWindowText(dir.c_str());
	EditBox.SetReset(true);
}
void COptionsDirectoriesPage::UpdateDirectory(CModifiedEditBox & EditBox, SettingID Type)
{
	if (EditBox.IsChanged())
	{
		stdstr dir = EditBox.GetWindowText();
		g_Settings->SaveString(Type, dir.c_str());
	}
	if (EditBox.IsReset())
	{
		g_Settings->DeleteSetting(Type);
	}
}
CGeneralOptionsPage::CGeneralOptionsPage(CSettingConfig * SettingsConfig, HWND hParent, const RECT & rcDispay ) :
	m_SettingsConfig(SettingsConfig)
{
	if (!Create(hParent,rcDispay))
	{
		return;
	}

	AddModCheckBox(GetDlgItem(IDC_AUTOSLEEP),Setting_AutoSleep);
	AddModCheckBox(GetDlgItem(IDC_LOAD_FULLSCREEN),Setting_AutoFullscreen);
	AddModCheckBox(GetDlgItem(IDC_SCREEN_SAVER),Setting_DisableScrSaver);
	AddModCheckBox(GetDlgItem(IDC_BASIC_MODE),UserInterface_BasicMode);

	CModifiedEditBox * TxtBox = AddModTextBox(GetDlgItem(IDC_REMEMBER),File_RecentGameFileCount, false);
	TxtBox->SetTextField(GetDlgItem(IDC_MAXROMS_TXT));

	TxtBox = AddModTextBox(GetDlgItem(IDC_REMEMBERDIR),Directory_RecentGameDirCount, false);
	TxtBox->SetTextField(GetDlgItem(IDC_MAXROMDIR_TXT));

	UpdatePageSettings();
}
void CAdvancedOptionsPage::SelectFile(LanguageStringID Title, CModifiedEditBox & EditBox)
{
    // Open DDROM
    OPENFILENAME openfilename;
    char FileName[_MAX_PATH], Directory[_MAX_PATH];
    memset(&FileName, 0, sizeof(FileName));
    memset(&openfilename, 0, sizeof(openfilename));

    strcpy(Directory, g_Settings->LoadStringVal(RomList_GameDir).c_str());
    openfilename.lStructSize = sizeof(openfilename);
    openfilename.hwndOwner = m_hWnd;
    openfilename.lpstrFilter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
    openfilename.lpstrFile = FileName;
    openfilename.lpstrInitialDir = Directory;
    openfilename.nMaxFile = MAX_PATH;
    openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;

    if (GetOpenFileName(&openfilename))
    {
        EditBox.SetChanged(true);
        EditBox.SetWindowText(FileName);
        SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
    }
}