Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
Add Online Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
secsome committed Nov 22, 2023
1 parent cbf51ee commit ece147f
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 19 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
18 changes: 14 additions & 4 deletions DOCUMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions FA2sp/Ext/CFinalSunApp/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
#pragma warning(disable : 6262)

std::vector<std::string> CFinalSunAppExt::RecentFilesExt;
std::array<std::pair<std::string, std::string>, 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()
{
Expand Down
2 changes: 2 additions & 0 deletions FA2sp/Ext/CFinalSunApp/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <CFinalSunApp.h>

#include <array>
#include <vector>
#include <string>

Expand All @@ -15,4 +16,5 @@ class NOVTABLE CFinalSunAppExt : public CFinalSunApp
BOOL InitInstanceExt();

static std::vector<std::string> RecentFilesExt;
static std::array<std::pair<std::string, std::string>, 7> ExternalLinks;
};
19 changes: 19 additions & 0 deletions FA2sp/Ext/CFinalSunDlg/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
18 changes: 11 additions & 7 deletions FA2sp/Ext/CFinalSunDlg/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion FA2sp/FA2sp.Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
36 changes: 36 additions & 0 deletions FA2sp/FA2sp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <CINI.h>

#include <clocale>
Expand Down Expand Up @@ -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() };
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions FA2sp/FA2sp.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class ExtConfigs
static bool ModernObjectBrowser;
static bool ExtVariables;
static bool FileWatcher;
static bool CustomOnlineWebsites;
};

class Variables
Expand Down
13 changes: 7 additions & 6 deletions FA2sp/UI/CMenu.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ece147f

Please sign in to comment.