From ece147f87ab86ffae6d4dc0a85b80a5cd7c8d879 Mon Sep 17 00:00:00 2001 From: secsome <302702960@qq.com> Date: Wed, 22 Nov 2023 14:40:05 +0800 Subject: [PATCH] Add Online Menu --- CHANGELOG.md | 16 +++++++++++++- DOCUMENT.md | 18 ++++++++++++---- FA2sp/Ext/CFinalSunApp/Body.cpp | 10 +++++++++ FA2sp/Ext/CFinalSunApp/Body.h | 2 ++ FA2sp/Ext/CFinalSunDlg/Body.cpp | 19 +++++++++++++++++ FA2sp/Ext/CFinalSunDlg/Hooks.cpp | 18 +++++++++------- FA2sp/FA2sp.Constants.h | 2 +- FA2sp/FA2sp.cpp | 36 ++++++++++++++++++++++++++++++++ FA2sp/FA2sp.h | 1 + FA2sp/UI/CMenu.rc | 13 ++++++------ 10 files changed, 116 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be0a741e..cfda1a64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,22 @@ # FINALALERT2 - SP CHANGELOG -## RELEASE 1.6.3 (2023-09-26) +## RELEASE 1.6.3 (2023-11-22) - New ***ExtConfig*** : `ExtVariables` = **BOOLEAN**, defaults to false - New ***ExtConfig*** : `FileWatcher` = **BOOLEAN**, defaults to true +- Add shortcuts to some online websites + - [FA2sp Github Page](https://github.com/secsome/FA2sp), translation key: `Menu.Online.FA2sp` + - [Phobos Github Page](https://github.com/Phobos-developers/Phobos), translation key: `Menu.Online.Phobos` + - [PPM Forum MainPage](https://www.ppmforums.com/), translation key: `Menu.Online.PPM` + - [ModEnc MainPage](https://modenc.renegadeprojects.com/Main_Page), translation key: `Menu.Online.ModEnc` + - You can also add your own shortcuts (3 at max) by editing `FAData.ini` section `[Online]` + - This feature might be vulnerable in some cases, so it is disabled by default, you can enable it by setting ***ExtConfig*** : `CustomOnlineWebsites` = **BOOLEAN**, defaults to false + ```ini + ; In `FAData.ini` + [OnlineWebsites] + Custom1=My Website Name 1,https://website1.com + Custom2=My Website Name 2,https://website2.com + Custom3=My Website Name 3,https://website3.com + ``` ## RELEASE 1.6.2 (2023-07-18) - Renamed ***ExtConfig*** : `BrowserRedraw.GuessMode` to `ObjectBrowser.GuessMode` diff --git a/DOCUMENT.md b/DOCUMENT.md index 1a6d1ed2..b95e074d 100644 --- a/DOCUMENT.md +++ b/DOCUMENT.md @@ -75,7 +75,8 @@ Now this feature supports RaiseSingleTile/LowerSingleTile (though they are not " - `HideNoRubbleBuilding` = **BOOLEAN** ; If this value is true, then building whose HP = 0 with `LeaveRubble=no` won't be rendered, defaults to **false** - `ExtVariables` = **BOOLEAN** ; Determines if FA2sp supports unlimited count of local variables, defaults to **false** (Phobos required) - `FileWatcher` = **BOOLEAN** ; Determines if FA2sp will detect if map file is modified external, defaults to **true** - - **`[Sides]`** (**x** means this item is **essensial**, fa2sp need this section to work properly) + - `CustomOnlineWebsites` = **BOOLEAN** ; Determines if FA2sp will read custom online websites + - - **`[Sides]`** (**x** means this item is **essensial**, fa2sp need this section to work properly) - Contains a list of sides registered in rules ```ini [Sides] @@ -373,6 +374,14 @@ Now this feature supports RaiseSingleTile/LowerSingleTile (though they are not " Index = RegName ; Like 0=INORANLAMP, value must be a valid building regname ``` + + - `[OnlineWebsites]` + ```ini + [OnlineWebsites] + Custom1=My Website Name 1,https://website1.com + Custom2=My Website Name 2,https://website2.com + Custom3=My Website Name 3,ahttps://website3.com + ``` - `FALanguage.ini` ```ini [CURRENTLANGUAGE-StringsRA2] @@ -434,9 +443,10 @@ Now this feature supports RaiseSingleTile/LowerSingleTile (though they are not " Menu.MapTools.NavigateCoordinate = TEXT Menu.MapTools.ToolScripts = TEXT Menu.Online = TEXT - Menu.Online.Westwood = TEXT - Menu.Online.FA2Fansite = TEXT - Menu.Online.FA2Forum = TEXT + Menu.Online.FA2sp = TEXT + Menu.Online.Phobos = TEXT + Menu.Online.PPM = TEXT + Menu.Online.ModEnc = TEXT Menu.Options = TEXT Menu.Options.Settings = TEXT Menu.Options.ShowMinimap = TEXT diff --git a/FA2sp/Ext/CFinalSunApp/Body.cpp b/FA2sp/Ext/CFinalSunApp/Body.cpp index ee263b14..fed4529c 100644 --- a/FA2sp/Ext/CFinalSunApp/Body.cpp +++ b/FA2sp/Ext/CFinalSunApp/Body.cpp @@ -14,6 +14,16 @@ #pragma warning(disable : 6262) std::vector CFinalSunAppExt::RecentFilesExt; +std::array, 7> CFinalSunAppExt::ExternalLinks +{ + std::make_pair("https://github.com/secsome/FA2sp", ""), + std::make_pair("https://github.com/Phobos-developers/Phobos", ""), + std::make_pair("https://www.ppmforums.com/", ""), + std::make_pair("https://modenc.renegadeprojects.com/Main_Page", ""), + std::make_pair("", ""), + std::make_pair("", ""), + std::make_pair("", "") +}; CFinalSunAppExt* CFinalSunAppExt::GetInstance() { diff --git a/FA2sp/Ext/CFinalSunApp/Body.h b/FA2sp/Ext/CFinalSunApp/Body.h index 78fdbd72..37410105 100644 --- a/FA2sp/Ext/CFinalSunApp/Body.h +++ b/FA2sp/Ext/CFinalSunApp/Body.h @@ -2,6 +2,7 @@ #include +#include #include #include @@ -15,4 +16,5 @@ class NOVTABLE CFinalSunAppExt : public CFinalSunApp BOOL InitInstanceExt(); static std::vector RecentFilesExt; + static std::array, 7> ExternalLinks; }; \ No newline at end of file diff --git a/FA2sp/Ext/CFinalSunDlg/Body.cpp b/FA2sp/Ext/CFinalSunDlg/Body.cpp index f8a18eb8..e8391115 100644 --- a/FA2sp/Ext/CFinalSunDlg/Body.cpp +++ b/FA2sp/Ext/CFinalSunDlg/Body.cpp @@ -125,6 +125,25 @@ BOOL CFinalSunDlgExt::OnCommandExt(WPARAM wParam, LPARAM lParam) } break; } + case 33000: + case 33001: + case 33002: + case 33003: + case 33004: + case 33005: + case 33006: + { + const auto& url = CFinalSunAppExt::ExternalLinks[wmID - 33000].first; + if (url.empty()) + break; + if (!ShellExecute(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL)) + { + std::string buffer = "Failed to open url, try manually: "; + buffer += url; + MessageBox(buffer.c_str()); + } + break; + } default: break; } diff --git a/FA2sp/Ext/CFinalSunDlg/Hooks.cpp b/FA2sp/Ext/CFinalSunDlg/Hooks.cpp index e6cf7c65..a66895a8 100644 --- a/FA2sp/Ext/CFinalSunDlg/Hooks.cpp +++ b/FA2sp/Ext/CFinalSunDlg/Hooks.cpp @@ -77,6 +77,12 @@ DEFINE_HOOK(432380, CFinalSunDlg_Update_RecentFiles, A) pMenu->GetSubMenu(0)->InsertMenu(10 + i, MF_BYPOSITION, 40140 + i, CFinalSunAppExt::RecentFilesExt[i].c_str()); } + for (size_t i = 4; i < 7; ++i) + { + if (!CFinalSunAppExt::ExternalLinks[i].first.empty()) + pMenu->GetSubMenu(4)->InsertMenu(3 + i, MF_BYPOSITION, 33000 + i, CFinalSunAppExt::ExternalLinks[i].second.c_str()); + } + R->EDI(::CheckMenuItem); return 0x432442; @@ -162,13 +168,11 @@ DEFINE_HOOK(43209D, CFinalSunDlg_Update_TranslateMenuItems, A) translateMenuItem(40134, "Menu.MapTools.NavigateCoordinate"); translateMenuItem(40135, "Menu.MapTools.ToolScripts"); - if (0) - { - translateSubMenu(i++, "Menu.Online"); - translateMenuItem(40078, "Menu.Online.Westwood"); - translateMenuItem(40081, "Menu.Online.FA2Fansite"); - translateMenuItem(40119, "Menu.Online.FA2Forum"); - } + translateSubMenu(i++, "Menu.Online"); + translateMenuItem(33000, "Menu.Online.FA2sp"); + translateMenuItem(33001, "Menu.Online.Phobos"); + translateMenuItem(33002, "Menu.Online.PPM"); + translateMenuItem(33003, "Menu.Online.ModEnc"); translateSubMenu(i++, "Menu.Options"); translateMenuItem(40004, "Menu.Options.Settings"); diff --git a/FA2sp/FA2sp.Constants.h b/FA2sp/FA2sp.Constants.h index c3037935..a57753a5 100644 --- a/FA2sp/FA2sp.Constants.h +++ b/FA2sp/FA2sp.Constants.h @@ -5,7 +5,7 @@ #define PRODUCT_MAJOR 1 #define PRODUCT_MINOR 6 -#define PRODUCT_REVISION 2 +#define PRODUCT_REVISION 3 #ifdef NDEBUG #define PRODUCT_STR __str(PRODUCT_MAJOR) "." __str(PRODUCT_MINOR) "." __str(PRODUCT_REVISION) diff --git a/FA2sp/FA2sp.cpp b/FA2sp/FA2sp.cpp index 8ec32d14..c09f3c4b 100644 --- a/FA2sp/FA2sp.cpp +++ b/FA2sp/FA2sp.cpp @@ -3,10 +3,13 @@ #include "Helpers/MutexHelper.h" #include "Helpers/InstructionSet.h" +#include "Helpers/STDHelpers.h" #include "Miscs/Palettes.h" #include "Miscs/VoxelDrawer.h" #include "Miscs/Exception.h" +#include "Ext/CFinalSunApp/Body.h" + #include #include @@ -62,6 +65,7 @@ bool ExtConfigs::HideNoRubbleBuilding; bool ExtConfigs::ModernObjectBrowser; bool ExtConfigs::ExtVariables; bool ExtConfigs::FileWatcher; +bool ExtConfigs::CustomOnlineWebsites; MultimapHelper Variables::Rules = { &CINI::Rules(), &CINI::CurrentDocument() }; MultimapHelper Variables::FAData = { &CINI::FAData() }; @@ -156,6 +160,38 @@ void FA2sp::ExtConfigsInitialize() ExtConfigs::ExtVariables = CINI::FAData->GetBool("ExtConfigs", "ExtVariables"); ExtConfigs::FileWatcher = CINI::FAData->GetBool("ExtConfigs", "FileWatcher", true); + + ExtConfigs::CustomOnlineWebsites = CINI::FAData->GetBool("ExtConfigs", "CustomOnlineWebsites"); + if (ExtConfigs::CustomOnlineWebsites) + { + if (auto pStr = CINI::FAData->TryGetString("OnlineWebsites", "Custom1")) + { + auto res = STDHelpers::SplitString(*pStr); + if (res.size() == 2) + { + CFinalSunAppExt::ExternalLinks[4].first = res[1]; + CFinalSunAppExt::ExternalLinks[4].second = res[0]; + } + } + if (auto pStr = CINI::FAData->TryGetString("OnlineWebsites", "Custom2")) + { + auto res = STDHelpers::SplitString(*pStr); + if (res.size() == 2) + { + CFinalSunAppExt::ExternalLinks[5].first = res[1]; + CFinalSunAppExt::ExternalLinks[5].second = res[0]; + } + } + if (auto pStr = CINI::FAData->TryGetString("OnlineWebsites", "Custom3")) + { + auto res = STDHelpers::SplitString(*pStr); + if (res.size() == 2) + { + CFinalSunAppExt::ExternalLinks[6].first = res[1]; + CFinalSunAppExt::ExternalLinks[6].second = res[0]; + } + } + } } // DllMain diff --git a/FA2sp/FA2sp.h b/FA2sp/FA2sp.h index 6d4ffeaa..5cdff599 100644 --- a/FA2sp/FA2sp.h +++ b/FA2sp/FA2sp.h @@ -69,6 +69,7 @@ class ExtConfigs static bool ModernObjectBrowser; static bool ExtVariables; static bool FileWatcher; + static bool CustomOnlineWebsites; }; class Variables diff --git a/FA2sp/UI/CMenu.rc b/FA2sp/UI/CMenu.rc index 8bb635f8..62508c9f 100644 --- a/FA2sp/UI/CMenu.rc +++ b/FA2sp/UI/CMenu.rc @@ -81,12 +81,13 @@ POPUP "Map tools" MENUITEM SEPARATOR MENUITEM "Tool Scripts", 40135 } -//POPUP "Online" -//{ -// MENUITEM "Westwood.com", 40078 -// MENUITEM "FinalAlert 2(tm) Fansite link", 40081 -// MENUITEM "FinalAlert 2(tm) Forum", 40119 -//} +POPUP "Online" +{ + MENUITEM "FA2sp Github Page", 33000 + MENUITEM "Phobos Github Page", 33001 + MENUITEM "PPM Forum MainPage", 33002 + MENUITEM "ModEnc MainPage", 33003 +} POPUP "Options" { MENUITEM "Settings", 40004