2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
2015-11-10 05:21:49 +00:00
|
|
|
* Project64 - A Nintendo 64 emulator. *
|
2012-12-19 09:30:18 +00:00
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
2010-06-07 02:23:58 +00:00
|
|
|
#include "stdafx.h"
|
2015-09-07 19:47:44 +00:00
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
#include "Settings Page.h"
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
COptionsGameBrowserPage::COptionsGameBrowserPage(HWND hParent, const RECT & rcDispay) :
|
|
|
|
m_OrderChanged(false),
|
|
|
|
m_OrderReset(false)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
if (!Create(hParent, rcDispay))
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-11-07 01:11:25 +00:00
|
|
|
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT2, GS(RB_ROMS));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT4, GS(RB_DIRS));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_USE_ROMBROWSER, GS(RB_USE));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_RECURSION, GS(RB_DIR_RECURSION));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT5, GS(RB_AVALIABLE_FIELDS));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT6, GS(RB_SHOW_FIELDS));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_ADD, GS(RB_ADD));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_REMOVE, GS(RB_REMOVE));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_UP, GS(RB_UP));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_DOWN, GS(RB_DOWN));
|
|
|
|
|
|
|
|
AddModCheckBox(GetDlgItem(IDC_USE_ROMBROWSER), RomBrowser_Enabled);
|
|
|
|
AddModCheckBox(GetDlgItem(IDC_RECURSION), RomBrowser_Recursive);
|
2008-11-14 20:51:06 +00:00
|
|
|
|
|
|
|
m_Avaliable.Attach(GetDlgItem(IDC_AVALIABLE));
|
|
|
|
m_Using.Attach(GetDlgItem(IDC_USING));
|
|
|
|
|
|
|
|
CRomBrowser::GetFieldInfo(m_Fields);
|
|
|
|
|
|
|
|
UpdatePageSettings();
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void COptionsGameBrowserPage::UpdateFieldList(const ROMBROWSER_FIELDS_LIST & Fields)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
m_Avaliable.ResetContent();
|
|
|
|
m_Using.ResetContent();
|
|
|
|
|
|
|
|
m_OrderChanged = false;
|
2015-11-07 01:11:25 +00:00
|
|
|
for (int i = 0, n = Fields.size(); i < n; i++)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
if (Fields[i].PosChanged())
|
|
|
|
{
|
|
|
|
m_OrderChanged = true;
|
|
|
|
}
|
|
|
|
int Pos = Fields[i].Pos();
|
2015-11-07 01:11:25 +00:00
|
|
|
if (Pos < 0)
|
|
|
|
{
|
|
|
|
m_Avaliable.SetItemData(m_Avaliable.AddStringW(GS(Fields[i].LangID())), i);
|
2008-11-14 20:51:06 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
int listCount = m_Using.GetCount();
|
|
|
|
if (Pos > listCount) { Pos = listCount; }
|
2015-11-07 01:11:25 +00:00
|
|
|
m_Using.SetItemData(m_Using.InsertStringW(Pos, GS(Fields[i].LangID())), i);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void COptionsGameBrowserPage::UpdatePageSettings(void)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
UpdateFieldList(m_Fields);
|
|
|
|
CSettingsPageImpl<COptionsGameBrowserPage>::UpdatePageSettings();
|
|
|
|
FixCtrlState();
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void COptionsGameBrowserPage::UseRomBrowserChanged(UINT Code, int id, HWND ctl)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
CheckBoxChanged(Code, id, ctl);
|
2008-11-14 20:51:06 +00:00
|
|
|
FixCtrlState();
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void COptionsGameBrowserPage::FixCtrlState(void)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
bool bEnabled = (SendDlgItemMessage(IDC_USE_ROMBROWSER, BM_GETCHECK, 0, 0) == BST_CHECKED);
|
|
|
|
::EnableWindow(GetDlgItem(IDC_ROMSEL_TEXT5), bEnabled);
|
|
|
|
::EnableWindow(GetDlgItem(IDC_ROMSEL_TEXT6), bEnabled);
|
|
|
|
::EnableWindow(GetDlgItem(IDC_AVALIABLE), bEnabled);
|
|
|
|
::EnableWindow(GetDlgItem(IDC_ADD), bEnabled);
|
|
|
|
::EnableWindow(GetDlgItem(IDC_REMOVE), bEnabled);
|
|
|
|
::EnableWindow(GetDlgItem(IDC_USING), bEnabled);
|
|
|
|
::EnableWindow(GetDlgItem(IDC_UP), bEnabled);
|
|
|
|
::EnableWindow(GetDlgItem(IDC_DOWN), bEnabled);
|
|
|
|
::EnableWindow(GetDlgItem(IDC_RECURSION), bEnabled);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void COptionsGameBrowserPage::AddFieldClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
int index = m_Avaliable.GetCurSel();
|
2015-11-07 01:11:25 +00:00
|
|
|
if (index < 0)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
return;
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
//remove from list
|
|
|
|
int i = m_Avaliable.GetItemData(index);
|
|
|
|
m_Avaliable.DeleteString(index);
|
|
|
|
|
|
|
|
//select next in list
|
|
|
|
int listCount = m_Avaliable.GetCount();
|
2015-11-07 01:11:25 +00:00
|
|
|
if (index >= listCount) { index -= 1; }
|
2008-11-14 20:51:06 +00:00
|
|
|
m_Avaliable.SetCurSel(index);
|
|
|
|
|
|
|
|
//Add to list
|
2015-03-04 09:36:08 +00:00
|
|
|
index = m_Using.AddStringW(GS(m_Fields[i].LangID()));
|
2015-11-07 01:11:25 +00:00
|
|
|
m_Using.SetItemData(index, i);
|
2008-11-14 20:51:06 +00:00
|
|
|
m_Using.SetCurSel(index);
|
|
|
|
|
|
|
|
m_OrderChanged = true;
|
|
|
|
m_OrderReset = false;
|
2015-11-07 01:11:25 +00:00
|
|
|
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void COptionsGameBrowserPage::RemoveFieldClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-05 16:21:50 +00:00
|
|
|
int index = m_Using.GetCurSel();
|
|
|
|
if (index < 0)
|
|
|
|
{
|
|
|
|
return;
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
//remove from list
|
2015-11-05 16:21:50 +00:00
|
|
|
int i = m_Using.GetItemData(index);
|
|
|
|
m_Using.DeleteString(index);
|
2008-11-14 20:51:06 +00:00
|
|
|
|
|
|
|
//select next in list
|
2015-11-05 16:21:50 +00:00
|
|
|
int listCount = m_Using.GetCount();
|
|
|
|
if (index >= listCount) { index -= 1; }
|
|
|
|
m_Using.SetCurSel(index);
|
2008-11-14 20:51:06 +00:00
|
|
|
|
|
|
|
//Add to list
|
2015-11-05 16:21:50 +00:00
|
|
|
index = m_Avaliable.AddStringW(GS(m_Fields[i].LangID()));
|
|
|
|
m_Avaliable.SetItemData(index, i);
|
|
|
|
m_Avaliable.SetCurSel(index);
|
2008-11-14 20:51:06 +00:00
|
|
|
|
|
|
|
m_OrderChanged = true;
|
|
|
|
m_OrderReset = false;
|
2015-11-05 16:21:50 +00:00
|
|
|
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void COptionsGameBrowserPage::MoveFieldUpClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
int index = m_Using.GetCurSel();
|
2015-11-07 01:11:25 +00:00
|
|
|
if (index <= 0)
|
|
|
|
{
|
|
|
|
return;
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
int i = m_Using.GetItemData(index);
|
|
|
|
m_Using.DeleteString(index);
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
index = m_Using.InsertStringW(index - 1, GS(m_Fields[i].LangID()));
|
|
|
|
m_Using.SetItemData(index, i);
|
2008-11-14 20:51:06 +00:00
|
|
|
m_Using.SetCurSel(index);
|
|
|
|
|
|
|
|
m_OrderChanged = true;
|
|
|
|
m_OrderReset = false;
|
2015-11-07 01:11:25 +00:00
|
|
|
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void COptionsGameBrowserPage::MoveFieldDownClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
int index = m_Using.GetCurSel();
|
|
|
|
if (index < 0 || index >= (m_Using.GetCount() - 1))
|
2015-11-07 01:11:25 +00:00
|
|
|
{
|
|
|
|
return;
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
int i = m_Using.GetItemData(index);
|
|
|
|
m_Using.DeleteString(index);
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
index = m_Using.InsertStringW(index + 1, GS(m_Fields[i].LangID()));
|
|
|
|
m_Using.SetItemData(index, i);
|
2008-11-14 20:51:06 +00:00
|
|
|
m_Using.SetCurSel(index);
|
|
|
|
|
|
|
|
m_OrderChanged = true;
|
|
|
|
m_OrderReset = false;
|
2015-11-07 01:11:25 +00:00
|
|
|
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void COptionsGameBrowserPage::HidePage()
|
|
|
|
{
|
|
|
|
ShowWindow(SW_HIDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void COptionsGameBrowserPage::ShowPage()
|
|
|
|
{
|
|
|
|
ShowWindow(SW_SHOW);
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void COptionsGameBrowserPage::ApplySettings(bool UpdateScreen)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
bool bColChanged = false;
|
|
|
|
if (m_OrderReset)
|
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
for (size_t i = 0; i < m_Fields.size(); i++)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
m_Fields[i].ResetPos();
|
|
|
|
}
|
|
|
|
bColChanged = true;
|
2015-11-07 01:11:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-05 09:14:32 +00:00
|
|
|
size_t Item, listCount = m_Using.GetCount();
|
2015-11-07 01:11:25 +00:00
|
|
|
for (Item = 0; Item < listCount; Item++)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
int Pos = m_Using.GetItemData(Item);
|
|
|
|
if (m_OrderReset || m_Fields[Pos].Pos() != Item)
|
|
|
|
{
|
|
|
|
m_Fields[Pos].SetColPos(Item);
|
|
|
|
bColChanged = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
listCount = m_Avaliable.GetCount();
|
2015-11-07 01:11:25 +00:00
|
|
|
for (Item = 0; Item < listCount; Item++)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
int Pos = m_Avaliable.GetItemData(Item);
|
|
|
|
if (m_OrderReset || m_Fields[Pos].Pos() != -1)
|
|
|
|
{
|
|
|
|
m_Fields[Pos].SetColPos(-1);
|
|
|
|
bColChanged = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bColChanged)
|
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
g_Settings->SaveBool(RomBrowser_ColoumnsChanged, !g_Settings->LoadBool(RomBrowser_ColoumnsChanged));
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CSettingsPageImpl<COptionsGameBrowserPage>::ApplySettings(UpdateScreen);
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
bool COptionsGameBrowserPage::EnableReset(void)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
if (m_OrderChanged) { return true; }
|
|
|
|
return CSettingsPageImpl<COptionsGameBrowserPage>::EnableReset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void COptionsGameBrowserPage::ResetPage()
|
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
if (m_OrderChanged)
|
|
|
|
{
|
2008-11-14 20:51:06 +00:00
|
|
|
ROMBROWSER_FIELDS_LIST Fields;
|
2015-11-07 01:11:25 +00:00
|
|
|
CRomBrowser::GetFieldInfo(Fields, true);
|
2008-11-14 20:51:06 +00:00
|
|
|
UpdateFieldList(Fields);
|
|
|
|
m_OrderReset = true;
|
2015-11-07 01:11:25 +00:00
|
|
|
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
CSettingsPageImpl<COptionsGameBrowserPage>::ResetPage();
|
|
|
|
}
|