Add Plugin list to enhancment

This commit is contained in:
zilmar 2021-02-11 21:56:09 +10:30
parent 3553c87121
commit 3e02ff31d7
6 changed files with 222 additions and 13 deletions

View File

@ -166,7 +166,15 @@ CEnhancement::CEnhancement(const char * Ident, const char * Entry) :
}
Key.resize(Seperator);
if (stricmp(Key.c_str(), "Note") == 0)
if (stricmp(Key.c_str(), "PluginList") == 0)
{
strvector Plugins = stdstr(&Pos[1]).Tokenize(",");
for (size_t i = 0, n = Plugins.size(); i < n; i++)
{
m_PluginList.push_back(Plugins[i]);
}
}
else if (stricmp(Key.c_str(), "Note") == 0)
{
m_Note = &Pos[1];
}
@ -259,6 +267,11 @@ void CEnhancement::SetEntries(const CodeEntries & Entries)
CheckValid();
}
void CEnhancement::SetPluginList(const PluginList & List)
{
m_PluginList = List;
}
void CEnhancement::SetOptions(const CodeOptions & Options)
{
m_Options = Options;

View File

@ -28,6 +28,7 @@ public:
};
typedef std::vector<CodeEntry> CodeEntries;
typedef std::vector<CodeOption> CodeOptions;
typedef std::vector<std::string> PluginList;
CEnhancement(const char * Ident);
CEnhancement(const char * Ident, const char * Entry);
@ -35,6 +36,7 @@ public:
void SetNote(const char * Note);
void SetEntries(const CodeEntries & Entries);
void SetOptions(const CodeOptions & Options);
void SetPluginList(const PluginList & List);
void SetSelectedOption(uint16_t Value);
void SetActive(bool Active);
void SetOnByDefault(bool OnByDefault);
@ -44,6 +46,7 @@ public:
inline const std::string & GetNote(void) const { return m_Note; }
inline const CodeEntries & GetEntries(void) const { return m_Entries; }
inline const CodeOptions & GetOptions(void) const { return m_Options; }
inline const PluginList & GetPluginList(void) const { return m_PluginList; }
inline uint32_t CodeOptionSize(void) const { return m_CodeOptionSize; }
inline bool Valid(void) const { return m_Valid; }
inline bool Active(void) const { return m_Active; }
@ -61,6 +64,7 @@ private:
std::string m_Name;
std::string m_NameAndExtension;
std::string m_Note;
PluginList m_PluginList;
CodeEntries m_Entries;
CodeOptions m_Options;
std::string m_OptionValue;

View File

@ -325,6 +325,20 @@ void CEnhancmentFile::SaveCurrentSection(void)
continue;
}
Section += stdstr_f("$%s%s", Enhancement.GetName().c_str(), m_LineFeed);
if (!Enhancement.GetPluginList().empty())
{
const CEnhancement::PluginList & List = Enhancement.GetPluginList();
std::string PluginList;
for (size_t i = 0, n = List.size(); i < n; i++)
{
if (i > 0)
{
PluginList += ",";
}
PluginList += List[i].c_str();
}
Section += stdstr_f("PluginList=%s%s", PluginList.c_str() , m_LineFeed);
}
if (Enhancement.GetOnByDefault())
{
Section += stdstr_f("OnByDefault=1%s", m_LineFeed);

View File

@ -41,23 +41,26 @@ private:
CEnhancementUI & m_EnhancementUI;
CEnhancement::CodeEntries m_Entries;
CEnhancement::PluginList m_PluginList;
CEnhancement * m_EditEnhancement;
};
class CEditGS :
public CDialogImpl < CEditGS >
public CDialogImpl<CEditGS>
{
public:
BEGIN_MSG_MAP_EX(CEditGS)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_HANDLER(IDC_CHEAT_CODES, EN_CHANGE, OnCheatChanged)
COMMAND_HANDLER_EX(IDC_CHK_LIMIT_PLUGINS, BN_CLICKED, OnPluginBtn)
COMMAND_ID_HANDLER(IDC_BTN_PLUGIN, OnEditPlugins)
COMMAND_ID_HANDLER(IDOK, OnOkCmd)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
END_MSG_MAP()
enum { IDD = IDD_Enhancement_GS };
CEditGS(CEnhancement::CodeEntries & Entries);
CEditGS(CEnhancement::CodeEntries & Entries, CEnhancement::PluginList & PluginList);
private:
CEditGS();
@ -65,6 +68,8 @@ private:
CEditGS& operator=(const CEditGS&);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnPluginBtn(UINT Code, int id, HWND ctl);
LRESULT OnEditPlugins(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnOkCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnCheatChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
@ -72,6 +77,38 @@ private:
bool CheatCode(CEnhancement::CodeEntries & Entries);
CEnhancement::CodeEntries & m_Entries;
CEnhancement::PluginList & m_PluginList;
};
class CEditPluginList :
public CDialogImpl<CEditPluginList>
{
public:
BEGIN_MSG_MAP_EX(CEditPluginList)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_ID_HANDLER(ID_ADD, OnAddBtn)
COMMAND_ID_HANDLER(ID_REMOVE, OnRemoveBtn)
COMMAND_ID_HANDLER(IDOK, OnOkCmd)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
END_MSG_MAP()
enum { IDD = IDD_Enhancement_Plugins };
CEditPluginList(CEnhancement::PluginList & List);
private:
CEditPluginList();
CEditPluginList(const CEditPluginList&);
CEditPluginList& operator=(const CEditPluginList&);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnAddBtn(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnRemoveBtn(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnOkCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
CListBox m_PluginListBox;
CEnhancement::PluginList & m_PluginList;
};
CEnhancementUI::CEnhancementUI(void) :
@ -443,6 +480,7 @@ CEditEnhancement::CEditEnhancement(CEnhancementUI & EnhancementUI, CEnhancement
LRESULT CEditEnhancement::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
m_Entries = m_EditEnhancement != nullptr ? m_EditEnhancement->GetEntries() : CEnhancement::CodeEntries();
m_PluginList = m_EditEnhancement != nullptr ? m_EditEnhancement->GetPluginList() : CEnhancement::PluginList();
GetDlgItem(IDC_OVERCLOCK).EnableWindow(false);
GetDlgItem(IDC_OVER_CLOCK_MODIFIER).EnableWindow(false);
GetDlgItem(IDC_CODE_NAME).SetWindowText(m_EditEnhancement != nullptr ? stdstr(m_EditEnhancement->GetName()).ToUTF16().c_str() : L"");
@ -455,7 +493,7 @@ LRESULT CEditEnhancement::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM
LRESULT CEditEnhancement::OnGamesharkBtn(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
{
CButton(GetDlgItem(IDC_GAMESHARK)).SetCheck(m_Entries.size() > 0 ? BST_CHECKED : BST_UNCHECKED);
CEditGS(m_Entries).DoModal(m_hWnd);
CEditGS(m_Entries, m_PluginList).DoModal(m_hWnd);
CButton(GetDlgItem(IDC_GAMESHARK)).SetCheck(m_Entries.size() > 0 ? BST_CHECKED : BST_UNCHECKED);
return 0;
}
@ -480,6 +518,7 @@ LRESULT CEditEnhancement::OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl
m_EditEnhancement->SetName(GetCWindowText(GetDlgItem(IDC_CODE_NAME)).c_str());
m_EditEnhancement->SetOnByDefault(CButton(GetDlgItem(IDC_AUTOON)).GetCheck() == BST_CHECKED);
m_EditEnhancement->SetEntries(m_Entries);
m_EditEnhancement->SetPluginList(m_PluginList);
m_EditEnhancement->SetNote(GetCWindowText(GetDlgItem(IDC_NOTES)).c_str());
}
else
@ -488,6 +527,7 @@ LRESULT CEditEnhancement::OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl
Enhancement.SetName(GetCWindowText(GetDlgItem(IDC_CODE_NAME)).c_str());
Enhancement.SetOnByDefault(CButton(GetDlgItem(IDC_AUTOON)).GetCheck() == BST_CHECKED);
Enhancement.SetEntries(m_Entries);
Enhancement.SetPluginList(m_PluginList);
Enhancement.SetNote(GetCWindowText(GetDlgItem(IDC_NOTES)).c_str());
Enhancements.AddItem(Enhancement);
}
@ -498,8 +538,9 @@ LRESULT CEditEnhancement::OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl
}
CEditGS::CEditGS(CEnhancement::CodeEntries & Entries) :
m_Entries(Entries)
CEditGS::CEditGS(CEnhancement::CodeEntries & Entries, CEnhancement::PluginList & PluginList) :
m_Entries(Entries),
m_PluginList(PluginList)
{
}
@ -517,9 +558,24 @@ LRESULT CEditGS::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*
}
CEdit CheatCodes(GetDlgItem(IDC_CHEAT_CODES));
CheatCodes.SetWindowText(Buffer.ToUTF16().c_str());
CButton(GetDlgItem(IDC_CHK_LIMIT_PLUGINS)).SetCheck(m_PluginList.size() > 0 ? BST_CHECKED : BST_UNCHECKED);
return TRUE;
}
LRESULT CEditGS::OnPluginBtn(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
{
CButton(GetDlgItem(IDC_CHK_LIMIT_PLUGINS)).SetCheck(m_PluginList.size() > 0 ? BST_CHECKED : BST_UNCHECKED);
CEditPluginList(m_PluginList).DoModal(m_hWnd);
CButton(GetDlgItem(IDC_CHK_LIMIT_PLUGINS)).SetCheck(m_PluginList.size() > 0 ? BST_CHECKED : BST_UNCHECKED);
return 0;
}
LRESULT CEditGS::OnEditPlugins(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
OnPluginBtn(0, 0, 0);
return 0;
}
LRESULT CEditGS::OnCheatChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
CEnhancement::CodeEntries Entries;
@ -613,3 +669,84 @@ bool CEditGS::CheatCode(CEnhancement::CodeEntries & Entries)
}
return ValidCode;
}
CEditPluginList::CEditPluginList(CEnhancement::PluginList & List) :
m_PluginList(List)
{
}
LRESULT CEditPluginList::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/)
{
m_PluginListBox.Attach(GetDlgItem(IDC_PLUGIN_LIST));
for (size_t i = 0, n = m_PluginList.size(); i < n; i++)
{
m_PluginListBox.AddString(stdstr(m_PluginList[i]).ToUTF16().c_str());
}
return TRUE;
}
LRESULT CEditPluginList::OnAddBtn(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
CWindow hEdit = GetDlgItem(IDC_ADD_EDIT);
stdstr PluginName = stdstr(GetCWindowText(hEdit)).Trim();
std::wstring wPluginName = PluginName.ToUTF16();
if (PluginName.empty())
{
return 0;
}
for (int i = 0, n = m_PluginListBox.GetCount(); i < n; i++)
{
int nLen = m_PluginListBox.GetTextLen(i);
if (nLen == 0)
{
continue;
}
std::wstring WindowText;
WindowText.resize(nLen + 1);
m_PluginListBox.GetText(i, (wchar_t *)WindowText.c_str());
if (strcmp(stdstr().FromUTF16(WindowText.c_str()).c_str(), PluginName.c_str()) == 0)
{
return 0;
}
}
hEdit.SetWindowText(L"");
m_PluginListBox.AddString(wPluginName.c_str());
return 0;
}
LRESULT CEditPluginList::OnRemoveBtn(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
int index = m_PluginListBox.GetCurSel();
if (index >= 0)
{
m_PluginListBox.DeleteString(index);
}
return 0;
}
LRESULT CEditPluginList::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
EndDialog(wID);
return 0;
}
LRESULT CEditPluginList::OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
CEnhancement::PluginList PluginList;
for (int i = 0, n = m_PluginListBox.GetCount(); i < n; i++)
{
int nLen = m_PluginListBox.GetTextLen(i);
if (nLen == 0)
{
continue;
}
std::wstring WindowText;
WindowText.resize(nLen + 1);
m_PluginListBox.GetText(i, (wchar_t *)WindowText.c_str());
PluginList.push_back(stdstr().FromUTF16(WindowText.c_str()));
}
m_PluginList = PluginList;
EndDialog(wID);
return 0;
}

View File

@ -1291,15 +1291,17 @@ BEGIN
PUSHBUTTON "Export",IDC_BTN_EXPORT,360,7,56,13
END
IDD_Enhancement_GS DIALOGEX 0, 0, 123, 133
IDD_Enhancement_GS DIALOGEX 0, 0, 122, 144
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Edit Gameshark"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
LTEXT "Code:",IDC_CODE,7,7,25,8
EDITTEXT IDC_CHEAT_CODES,7,17,108,90,ES_MULTILINE | ES_UPPERCASE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
DEFPUSHBUTTON "OK",IDOK,7,114,50,14
PUSHBUTTON "Cancel",IDCANCEL,65,114,50,14
DEFPUSHBUTTON "OK",IDOK,7,125,50,14
PUSHBUTTON "Cancel",IDCANCEL,65,125,50,14
CONTROL "Limit on plugins",IDC_CHK_LIMIT_PLUGINS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,110,63,10
PUSHBUTTON "Edit",IDC_BTN_PLUGIN,75,110,41,10
END
IDD_Debugger_ExceptionBP DIALOGEX 0, 0, 269, 221
@ -1401,6 +1403,20 @@ BEGIN
LTEXT "Disk Seek Timing:",IDC_DISKSEEKTIMING_TEXT2,6,10,91,10
END
IDD_Enhancement_Plugins DIALOGEX 0, 0, 122, 184
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Edit Plugin List"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,7,165,50,14
PUSHBUTTON "Cancel",IDCANCEL,65,165,50,14
LISTBOX IDC_PLUGIN_LIST,7,43,109,97,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "Add",ID_ADD,66,23,50,14
DEFPUSHBUTTON "Remove",ID_REMOVE,66,143,50,14
EDITTEXT IDC_ADD_EDIT,7,7,109,12,ES_AUTOHSCROLL
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
@ -1826,7 +1842,7 @@ BEGIN
BEGIN
LEFTMARGIN, 7
TOPMARGIN, 7
BOTTOMMARGIN, 128
BOTTOMMARGIN, 139
END
IDD_Debugger_ExceptionBP, DIALOG
@ -1867,6 +1883,13 @@ BEGIN
TOPMARGIN, 4
BOTTOMMARGIN, 176
END
IDD_Enhancement_Plugins, DIALOG
BEGIN
LEFTMARGIN, 7
TOPMARGIN, 7
BOTTOMMARGIN, 179
END
END
#endif // APSTUDIO_INVOKED
@ -2249,6 +2272,11 @@ BEGIN
0
END
IDD_Enhancement_Plugins AFX_DIALOG_LAYOUT
BEGIN
0
END
/////////////////////////////////////////////////////////////////////////////
//

View File

@ -2,7 +2,13 @@
// Microsoft Visual C++ generated include file.
// Used by UIResources.rc
//
#define VERSION_REVISION 0
#define VER_VER_DEBUG 0
#define VERSION_MAJOR 2
#define IDAPPLY 3
#define VERSION_MINOR 4
#define ID_ADD 4
#define ID_REMOVE 5
#define IDI_PJ64_Icon 101
#define IDD_Rom_Information 104
#define IDD_Key_Prompt 108
@ -81,6 +87,7 @@
#define IDD_Settings_DiskDrive 215
#define IDD_Support_RequestCode 216
#define IDD_Settings_GameDiskDrive 217
#define IDD_Enhancement_Plugins 218
#define IDC_MENU_ITEM_TEXT 1000
#define IDC_CLOSE_BUTTON 1001
#define IDC_LIST2 1003
@ -110,7 +117,7 @@
#define IDC_CHK_VADDR 1011
#define IDC_CHK_HEX 1011
#define IDC_DISPLAY_FRAMERATE 1012
#define IDC_INFO_MEDIA 1012
#define IDC_INFO_MEDIA 1012
#define IDC_ALT 1012
#define IDC_LIST 1012
#define IDC_HLE_AUDIO 1012
@ -378,7 +385,7 @@
#define IDC_ROM_SIZE 1194
#define IDC_REG_TABS 1194
#define IDC_CART_ID 1195
#define IDC_MEDIA 1196
#define IDC_MEDIA 1196
#define IDC_COUNTRY 1197
#define IDC_CRC1 1198
#define IDC_CRC2 1199
@ -605,6 +612,7 @@
#define IDC_CHK_CPU 1473
#define IDC_CHK_OV 1474
#define IDC_CHK_TRAP 1475
#define VERSION_BUILD 1475
#define IDC_CHK_VCEI 1476
#define IDC_CHK_FPE 1477
#define IDC_CHK_WATCH 1478
@ -716,9 +724,14 @@
#define IDC_F6_LBL 1581
#define IDC_DISKSEEKTIMING2 1581
#define IDC_F7_LBL 1582
#define IDC_CHK_LIMIT_PLUGINS 1582
#define IDC_F8_LBL 1583
#define IDC_BTN_PLUGIN 1583
#define IDC_F9_LBL 1584
#define IDC_LIST1 1584
#define IDC_PLUGIN_LIST 1584
#define IDC_F10_LBL 1585
#define IDC_ADD_EDIT 1585
#define IDC_F11_LBL 1586
#define IDC_F12_LBL 1587
#define IDC_F13_LBL 1588
@ -929,7 +942,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 225
#define _APS_NEXT_COMMAND_VALUE 40121
#define _APS_NEXT_CONTROL_VALUE 1582
#define _APS_NEXT_CONTROL_VALUE 1586
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif