From 9eb65c4b810e863edefc554d3da260aa1b242c28 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 13 Jul 2021 08:17:16 +0930 Subject: [PATCH] Add Author to enhancement file --- .../N64System/Enhancement/Enhancement.cpp | 9 ++++++ .../N64System/Enhancement/Enhancement.h | 3 ++ .../N64System/Enhancement/EnhancementFile.cpp | 4 +++ Source/Project64/UserInterface/CheatUI.cpp | 2 ++ .../Project64/UserInterface/EnhancementUI.cpp | 2 ++ Source/Project64/UserInterface/UIResources.rc | 32 +++++++++++-------- Source/Project64/UserInterface/resource.h | 2 ++ 7 files changed, 40 insertions(+), 14 deletions(-) diff --git a/Source/Project64-core/N64System/Enhancement/Enhancement.cpp b/Source/Project64-core/N64System/Enhancement/Enhancement.cpp index 67057553c..a5549b2b3 100644 --- a/Source/Project64-core/N64System/Enhancement/Enhancement.cpp +++ b/Source/Project64-core/N64System/Enhancement/Enhancement.cpp @@ -171,6 +171,10 @@ CEnhancement::CEnhancement(const char * Ident, const char * Entry) : m_PluginList.push_back(Plugins[i]); } } + else if (stricmp(Key.c_str(), "Author") == 0) + { + m_Author = &Pos[1]; + } else if (stricmp(Key.c_str(), "Note") == 0) { m_Note = &Pos[1]; @@ -282,6 +286,11 @@ void CEnhancement::SetName(const char * Name) CheckValid(); } +void CEnhancement::SetAuthor(const char * Author) +{ + m_Author = Author != nullptr ? Author : ""; +} + void CEnhancement::SetNote(const char * Note) { m_Note = Note != nullptr ? Note : ""; diff --git a/Source/Project64-core/N64System/Enhancement/Enhancement.h b/Source/Project64-core/N64System/Enhancement/Enhancement.h index ce88044c6..19a6d7de3 100644 --- a/Source/Project64-core/N64System/Enhancement/Enhancement.h +++ b/Source/Project64-core/N64System/Enhancement/Enhancement.h @@ -26,6 +26,7 @@ public: CEnhancement(const char * Ident); CEnhancement(const char * Ident, const char * Entry); void SetName(const char * Name); + void SetAuthor(const char * Author); void SetNote(const char * Note); void SetEntries(const CodeEntries & Entries); void SetOptions(const CodeOptions & Options); @@ -37,6 +38,7 @@ public: inline const std::string & GetName(void) const { return m_Name; } inline const std::string & GetNameAndExtension(void) const { return m_NameAndExtension; } + inline const std::string & GetAuthor(void) const { return m_Author; } 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; } @@ -58,6 +60,7 @@ private: std::string m_Ident; std::string m_Name; std::string m_NameAndExtension; + std::string m_Author; std::string m_Note; PluginList m_PluginList; CodeEntries m_Entries; diff --git a/Source/Project64-core/N64System/Enhancement/EnhancementFile.cpp b/Source/Project64-core/N64System/Enhancement/EnhancementFile.cpp index a628f1ee3..d412b8c7d 100644 --- a/Source/Project64-core/N64System/Enhancement/EnhancementFile.cpp +++ b/Source/Project64-core/N64System/Enhancement/EnhancementFile.cpp @@ -337,6 +337,10 @@ void CEnhancmentFile::SaveCurrentSection(void) { Section += stdstr_f("Note=%s%s", Enhancement.GetNote().c_str(), m_LineFeed); } + if (!Enhancement.GetAuthor().empty()) + { + Section += stdstr_f("Author=%s%s", Enhancement.GetAuthor().c_str(), m_LineFeed); + } const CEnhancement::CodeEntries & Entries = Enhancement.GetEntries(); for (size_t i = 0, n = Entries.size(); i < n; i++) { diff --git a/Source/Project64/UserInterface/CheatUI.cpp b/Source/Project64/UserInterface/CheatUI.cpp index 9a7f0055c..c7319bec8 100644 --- a/Source/Project64/UserInterface/CheatUI.cpp +++ b/Source/Project64/UserInterface/CheatUI.cpp @@ -645,6 +645,7 @@ LRESULT CEditCheat::OnEditCheat(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, return 0; } GetDlgItem(IDC_CODE_NAME).SetWindowText(stdstr(m_EditEnhancement->GetName()).ToUTF16().c_str()); + GetDlgItem(IDC_CODE_AUTHOR).SetWindowText(stdstr(m_EditEnhancement->GetAuthor()).ToUTF16().c_str()); stdstr Buffer; const CEnhancement::CodeEntries & Entries = m_EditEnhancement->GetEntries(); for (size_t i = 0, n = Entries.size(); i < n; i++) @@ -706,6 +707,7 @@ LRESULT CEditCheat::OnAddCheat(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCt if (m_EditEnhancement != nullptr) { m_EditEnhancement->SetName(NewCheatName.c_str()); + m_EditEnhancement->SetAuthor(GetCWindowText(GetDlgItem(IDC_CODE_AUTHOR)).c_str()); m_EditEnhancement->SetEntries(Enhancement.GetEntries()); m_EditEnhancement->SetOptions(Enhancement.GetOptions()); m_EditEnhancement->SetNote(GetCWindowText(GetDlgItem(IDC_NOTES)).c_str()); diff --git a/Source/Project64/UserInterface/EnhancementUI.cpp b/Source/Project64/UserInterface/EnhancementUI.cpp index 88beb2d0e..3429c6a22 100644 --- a/Source/Project64/UserInterface/EnhancementUI.cpp +++ b/Source/Project64/UserInterface/EnhancementUI.cpp @@ -502,6 +502,7 @@ LRESULT CEditEnhancement::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM m_Entries = m_EditEnhancement != nullptr ? m_EditEnhancement->GetEntries() : CEnhancement::CodeEntries(); m_PluginList = m_EditEnhancement != nullptr ? m_EditEnhancement->GetPluginList() : CEnhancement::PluginList(); GetDlgItem(IDC_CODE_NAME).SetWindowText(m_EditEnhancement != nullptr ? stdstr(m_EditEnhancement->GetName()).ToUTF16().c_str() : L""); + GetDlgItem(IDC_CODE_AUTHOR).SetWindowText(m_EditEnhancement != nullptr ? stdstr(m_EditEnhancement->GetAuthor()).ToUTF16().c_str() : L""); GetDlgItem(IDC_NOTES).SetWindowText(m_EditEnhancement != nullptr ? stdstr(m_EditEnhancement->GetNote()).ToUTF16().c_str() : L""); CButton(GetDlgItem(IDC_AUTOON)).SetCheck(m_EditEnhancement != nullptr ? (m_EditEnhancement->GetOnByDefault() ? BST_CHECKED : BST_UNCHECKED) : BST_UNCHECKED); CButton(GetDlgItem(IDC_GAMESHARK)).SetCheck(m_Entries.size() > 0 ? BST_CHECKED : BST_UNCHECKED); @@ -543,6 +544,7 @@ LRESULT CEditEnhancement::OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl CEnhancement TempEnhancement(CEnhancement::EnhancementIdent); CEnhancement & Enhancement = m_EditEnhancement != nullptr ? *m_EditEnhancement : TempEnhancement; Enhancement.SetName(GetCWindowText(GetDlgItem(IDC_CODE_NAME)).c_str()); + Enhancement.SetAuthor(GetCWindowText(GetDlgItem(IDC_CODE_AUTHOR)).c_str()); Enhancement.SetOnByDefault(CButton(GetDlgItem(IDC_AUTOON)).GetCheck() == BST_CHECKED); Enhancement.SetOverClock(CButton(GetDlgItem(IDC_OVERCLOCK)).GetCheck() == BST_CHECKED, atoi(GetCWindowText(GetDlgItem(IDC_OVER_CLOCK_MODIFIER)).c_str())); Enhancement.SetEntries(m_Entries); diff --git a/Source/Project64/UserInterface/UIResources.rc b/Source/Project64/UserInterface/UIResources.rc index 808a74c2a..ae86000f0 100644 --- a/Source/Project64/UserInterface/UIResources.rc +++ b/Source/Project64/UserInterface/UIResources.rc @@ -287,14 +287,16 @@ STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD | WS_VISIBLE EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - LTEXT "Name:",IDC_NAME,4,6,25,10 - EDITTEXT IDC_CODE_NAME,52,4,146,12,ES_AUTOHSCROLL - LTEXT "Code:",IDC_CODE,4,24,31,10 - LTEXT "
:",IDC_CODE_DES,4,34,92,10 - LTEXT "Options:",IDC_LABEL_OPTIONS,101,24,38,10,WS_DISABLED - LTEXT "