Skip to content

Commit 722eb64

Browse files
NetsuNegiZivDeroCrimRecyaAephiexMetadorius
authored
Exclusive SuperWeapon Sidebar (#1384)
- It is possible to put sw cameos on the left of screen like C&C3 when `SuperWeaponSidebar` is true. Cameos arranged in a pyramid shape. In theory, it should be compatible with Ares. - 当 `SuperWeaponSidebar` 为true时,可以把超级武器的图标排列在屏幕左侧了,就像命令与征服3中那样。图标按照金字塔形状排列。理论上它应该是兼容Ares的。 - `SuperWeaponSidebar.Interval` controls the distance between two column cameos (excluding the background). When you need to make a background, the width of the background should be (`SuperWeaponSidebar.Interval` + cameo fixed width 60). - `SuperWeaponSidebar.Interval` 控制两列图标之间的横向间距(图标背景不包含在内)。如果你需要制作图标的背景,那么背景的宽度应该是 `SuperWeaponSidebar.Interval` + 图标的宽度(60像素)。 - `SuperWeaponSidebar.LeftOffset` controls the distance between the left side of cameo and the left side of its column (background). This will not be greater than `SuperWeaponSidebar.Interval`. - `SuperWeaponSidebar.LeftOffset` 控制图标距离背景左边缘的距离,这将不会超过 `SuperWeaponSidebar.Interval` 的值。 - `SuperWeaponSidebar.CameoHeight` controls the distance from the top of the previous cameo to the top of the next cameo. That is, the space between the upper and lower cameos is (`SuperWeaponSidebar.CameoHeight` - cameo fixed height 48). This will not be less than 48. When you need to make a background, this is the height of the background. - `SuperWeaponSidebar.CameoHeight` 控制图标顶部到下一个图标顶部的距离(也就是每两个背景之间的纵向间距),图标的顶部到其背景的上边缘的距离即为 `SuperWeaponSidebar.CameoHeight` - 图标高度(48)像素。如果你需要制作图标的背景,那么背景的高度应该是 `SuperWeaponSidebar.CameoHeight` 的值。 - `SuperWeaponSidebar.Max` controls the maximum number of cameos on the leftmost column, which also depends on the current game resolution. - `SuperWeaponSidebar.Max` 控制最左侧一列最多能有多少个图标,这也会受到当前游戏分辨率的影响。 - `SuperWeaponSidebar.MaxColumns` controls that maximum count of columns. - `SuperWeaponSidebar.MaxColumns` 控制最多能显示多少列。 - Only sw with `SuperWeaponSidebar.Significance` not lower than `SuperWeaponSidebar.RequiredSignificance` are allowed to be added to the sw sidebar. - 只有 `SuperWeaponSidebar.Significance` 值不低于 `SuperWeaponSidebar.RequiredSignificance` 的超级武器才允许被加入超级武器侧边栏。 - `SuperWeaponSidebarKeysEnabled` should be true that you can use hotkeys about superweapon sidebar. - `SuperWeaponSidebarKeysEnabled` 设为true时你才可以使用超级武器侧边栏的热键。 - You can also launch first 10 SW by hotkey in INTERFACE category. - 你还可以设置10个快捷键来释放对应图标的超级武器。 - For localization of hotkey, add `TXT_FIRE_TACTICAL_SW_XX`, `TXT_FIRE_TACTICAL_SW_XX_DESC`, `TXT_TOGGLE_SW_SIDEBAR` and `TXT_TOGGLE_SW_SIDEBAR_DESC` into your `.csf` file. - 如果需要本地化快捷键,只需要在你的 `csf` 文件中添加对应的 `TXT_FIRE_TACTICAL_SW_XX`, `TXT_FIRE_TACTICAL_SW_XX_DESC`, `TXT_TOGGLE_SW_SIDEBAR` and `TXT_TOGGLE_SW_SIDEBAR_DESC` 条目。 In `uimd.ini`: ```ini [Sidebar] SuperWeaponSidebar=false ; boolean SuperWeaponSidebar.Interval=0 ; integer, pixels SuperWeaponSidebar.LeftOffset=0 ; integer, pixels SuperWeaponSidebar.CameoHeight=48 ; integer, pixels SuperWeaponSidebar.Max=0 ; integer SuperWeaponSidebar.MaxColumns= ; integer ``` In `rulesmd.ini` ```ini [GlobalControls] SuperWeaponSidebarKeysEnabled=false ; boolean [AudioVisual] SuperWeaponSidebar.AllowByDefault=false ; boolean [SOMESIDE] SuperWeaponSidebar.OnPCX= ; filename - including the .pcx extension SuperWeaponSidebar.OffPCX= ; filename - including the .pcx extension SuperWeaponSidebar.TopPCX= ; filename - including the .pcx extension SuperWeaponSidebar.CenterPCX= ; filename - including the .pcx extension SuperWeaponSidebar.BottomPCX= ; filename - including the .pcx extension [SOMESW] SuperWeaponSidebar.Allow= ; boolean SuperWeaponSidebar.PriorityHouses= ; list of house types SuperWeaponSidebar.RequiredHouses= ; list of house types SuperWeaponSidebar.Significance=0 ; integer ``` In `ra2md.ini` ```ini [Phobos] SuperWeaponSidebar.RequiredSignificance=0 ; integer ``` ![sw_sidebar-01-on](https://github.com/user-attachments/assets/0d5178d4-9562-4df3-84d1-00bb04ed3039) ![sw_sidebar-02-on](https://github.com/user-attachments/assets/153a0db0-618f-4682-ad85-e44d287e8af7) --------- Co-authored-by: ZivDero <[email protected]> Co-authored-by: 绯红热茶 <[email protected]> Co-authored-by: Aephiex <[email protected]> Co-authored-by: Kerbiter <[email protected]>
1 parent deecb4c commit 722eb64

35 files changed

+1550
-26
lines changed

CREDITS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ This page lists all the individual contributions to the project by their author.
399399
- Fix the bug that ships can travel on elevated bridges
400400
- Original `Arcing` elevation inaccuracy fix
401401
- Fix the bug that uncontrolled scatter when elite techno attacked by aircraft or some unit try crush it
402+
- Exclusive SuperWeapon Sidebar
402403
- **Apollo** - Translucent SHP drawing patches
403404
- **ststl**:
404405
- Customizable `ShowTimer` priority of superweapons
@@ -473,6 +474,7 @@ This page lists all the individual contributions to the project by their author.
473474
- Aggressive attack move mission
474475
- Amphibious access vehicle
475476
- Fix an issue that spawned `Strafe` aircraft on aircraft carriers may not be able to return normally if aircraft carriers moved a short distance when the aircraft is landing
477+
- Exclusive SuperWeapon Sidebar
476478
- **Ollerus**:
477479
- Build limit group enhancement
478480
- Customizable rocker amplitude

Phobos.vcxproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
<ClCompile Include="src\Blowfish\Hooks.Blowfish.cpp" />
2424
<ClCompile Include="src\Ext\Cell\Body.cpp" />
2525
<ClCompile Include="src\Ext\House\Hooks.ForceEnemy.cpp" />
26+
<ClCompile Include="src\Commands\ToggleSWSidebar.cpp" />
27+
<ClCompile Include="src\Ext\Sidebar\SWSidebar\SWColumnClass.cpp" />
28+
<ClCompile Include="src\Ext\Sidebar\SWSidebar\SWSidebarClass.cpp" />
29+
<ClCompile Include="src\Ext\Sidebar\SWSidebar\SWButtonClass.cpp" />
30+
<ClCompile Include="src\Ext\Sidebar\SWSidebar\ToggleSWButtonClass.cpp" />
2631
<ClCompile Include="src\Ext\TechnoType\Hooks.MatrixOp.cpp" />
2732
<ClCompile Include="src\Ext\Techno\Hooks.Airstrike.cpp" />
2833
<ClCompile Include="src\Ext\Unit\Hooks.Harvester.cpp" />
@@ -200,6 +205,12 @@
200205
<ClInclude Include="src\New\Type\Affiliated\CreateUnitTypeClass.h" />
201206
<ClInclude Include="src\Blowfish\blowfish.h" />
202207
<ClInclude Include="src\Ext\Cell\Body.h" />
208+
<ClInclude Include="src\Commands\FireTacticalSW.h" />
209+
<ClInclude Include="src\Commands\ToggleSWSidebar.h" />
210+
<ClInclude Include="src\Ext\Sidebar\SWSidebar\SWColumnClass.h" />
211+
<ClInclude Include="src\Ext\Sidebar\SWSidebar\SWSidebarClass.h" />
212+
<ClInclude Include="src\Ext\Sidebar\SWSidebar\SWButtonClass.h" />
213+
<ClInclude Include="src\Ext\Sidebar\SWSidebar\ToggleSWButtonClass.h" />
203214
<ClInclude Include="src\New\Entity\AttachEffectClass.h" />
204215
<ClInclude Include="src\New\Type\Affiliated\TiberiumEaterTypeClass.h" />
205216
<ClInclude Include="src\New\Type\AttachEffectTypeClass.h" />

docs/User-Interface.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,3 +678,58 @@ In `RA2MD.INI`:
678678
[Phobos]
679679
ToolTipBlur=false ; boolean, whether the blur effect of tooltips will be enabled.
680680
```
681+
682+
### Exclusive SuperWeapon Sidebar
683+
684+
![image](_static/images/sw_sidebar-01-on.png)
685+
![image](_static/images/sw_sidebar-02-on.png)
686+
687+
- It is possible to put sw cameos on the left of screen like C&C3 when `SuperWeaponSidebar` is true. Cameos arranged in a pyramid shape. In theory, it should be compatible with Ares.
688+
- `SuperWeaponSidebar.Interval` controls the distance between two column cameos (excluding the background). When you need to make a background, the width of the background should be (`SuperWeaponSidebar.Interval` + cameo fixed width 60).
689+
- `SuperWeaponSidebar.LeftOffset` controls the distance between the left side of cameo and the left side of its column (background). This will not be greater than `SuperWeaponSidebar.Interval`.
690+
- `SuperWeaponSidebar.CameoHeight` controls the distance from the top of the previous cameo to the top of the next cameo. That is, the space between the upper and lower cameos is (`SuperWeaponSidebar.CameoHeight` - cameo fixed height 48). This will not be less than 48. When you need to make a background, this is the height of the background.
691+
- `SuperWeaponSidebar.Max` controls the maximum number of cameos on the leftmost column, which also depends on the current game resolution.
692+
- `SuperWeaponSidebar.MaxColumns` controls that maximum count of columns.
693+
- Only sw with `SuperWeaponSidebar.Significance` not lower than `SuperWeaponSidebar.RequiredSignificance` are allowed to be added to the sw sidebar.
694+
- `SuperWeaponSidebarKeysEnabled` should be true that you can use hotkeys about superweapon sidebar.
695+
- You can also launch first 10 SW by hotkey in INTERFACE category.
696+
- For localization of hotkey, add `TXT_FIRE_TACTICAL_SW_XX`, `TXT_FIRE_TACTICAL_SW_XX_DESC`, `TXT_TOGGLE_SW_SIDEBAR` and `TXT_TOGGLE_SW_SIDEBAR_DESC` into your `.csf` file.
697+
698+
In `uimd.ini`:
699+
```ini
700+
[Sidebar]
701+
SuperWeaponSidebar=false ; boolean
702+
SuperWeaponSidebar.Interval=0 ; integer, pixels
703+
SuperWeaponSidebar.LeftOffset=0 ; integer, pixels
704+
SuperWeaponSidebar.CameoHeight=48 ; integer, pixels
705+
SuperWeaponSidebar.Max=0 ; integer
706+
SuperWeaponSidebar.MaxColumns= ; integer
707+
```
708+
709+
In `rulesmd.ini`
710+
```ini
711+
[GlobalControls]
712+
SuperWeaponSidebarKeysEnabled=false ; boolean
713+
714+
[AudioVisual]
715+
SuperWeaponSidebar.AllowByDefault=false ; boolean
716+
717+
[SOMESIDE]
718+
SuperWeaponSidebar.OnPCX= ; filename - including the .pcx extension
719+
SuperWeaponSidebar.OffPCX= ; filename - including the .pcx extension
720+
SuperWeaponSidebar.TopPCX= ; filename - including the .pcx extension
721+
SuperWeaponSidebar.CenterPCX= ; filename - including the .pcx extension
722+
SuperWeaponSidebar.BottomPCX= ; filename - including the .pcx extension
723+
724+
[SOMESW]
725+
SuperWeaponSidebar.Allow= ; boolean
726+
SuperWeaponSidebar.PriorityHouses= ; list of house types
727+
SuperWeaponSidebar.RequiredHouses= ; list of house types
728+
SuperWeaponSidebar.Significance=0 ; integer
729+
```
730+
731+
In `ra2md.ini`
732+
```ini
733+
[Phobos]
734+
SuperWeaponSidebar.RequiredSignificance=0 ; integer
735+
```

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ New:
381381
- Dehardcoded 255 limit of `OverlayType` (by secsome)
382382
- [Customizable airstrike flare colors](Fixed-or-Improved-Logics.md#airstrike-flare-customizations) (by Starkku)
383383
- Allowed player's self-healing effects to be benefited by allied or `PlayerControl=true` houses (by Ollerus)
384+
- Exclusive SuperWeapon Sidebar (by NetsuNegi & CrimRecya)
384385
385386
Vanilla fixes:
386387
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
209 KB
Loading
155 KB
Loading

src/Commands/Commands.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include "ToggleDigitalDisplay.h"
1111
#include "ToggleDesignatorRange.h"
1212
#include "SaveVariablesToFile.h"
13+
#include "ToggleSWSidebar.h"
14+
#include "FireTacticalSW.h"
15+
#include <Ext/Sidebar/SWSidebar/SWSidebarClass.h>
1316

1417
DEFINE_HOOK(0x533066, CommandClassCallback_Register, 0x6)
1518
{
@@ -19,6 +22,21 @@ DEFINE_HOOK(0x533066, CommandClassCallback_Register, 0x6)
1922
MakeCommand<QuickSaveCommandClass>();
2023
MakeCommand<ToggleDigitalDisplayCommandClass>();
2124
MakeCommand<ToggleDesignatorRangeCommandClass>();
25+
MakeCommand<ToggleSWSidebar>();
26+
27+
if (Phobos::Config::SuperWeaponSidebarCommands)
28+
{
29+
SWSidebarClass::Commands[0] = MakeCommand<FireTacticalSWCommandClass<0>>();
30+
SWSidebarClass::Commands[1] = MakeCommand<FireTacticalSWCommandClass<1>>();
31+
SWSidebarClass::Commands[2] = MakeCommand<FireTacticalSWCommandClass<2>>();
32+
SWSidebarClass::Commands[3] = MakeCommand<FireTacticalSWCommandClass<3>>();
33+
SWSidebarClass::Commands[4] = MakeCommand<FireTacticalSWCommandClass<4>>();
34+
SWSidebarClass::Commands[5] = MakeCommand<FireTacticalSWCommandClass<5>>();
35+
SWSidebarClass::Commands[6] = MakeCommand<FireTacticalSWCommandClass<6>>();
36+
SWSidebarClass::Commands[7] = MakeCommand<FireTacticalSWCommandClass<7>>();
37+
SWSidebarClass::Commands[8] = MakeCommand<FireTacticalSWCommandClass<8>>();
38+
SWSidebarClass::Commands[9] = MakeCommand<FireTacticalSWCommandClass<9>>();
39+
}
2240

2341
if (Phobos::Config::DevelopmentCommands)
2442
{

src/Commands/Commands.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
#include <Utilities/Debug.h>
88

99
template <typename T>
10-
void MakeCommand()
10+
T* MakeCommand()
1111
{
1212
T* command = GameCreate<T>();
1313
CommandClass::Array.AddItem(command);
14+
return command;
1415
};
1516

1617
#define CATEGORY_TEAM StringTable::LoadString(GameStrings::TXT_TEAM)

src/Commands/FireTacticalSW.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#pragma once
2+
#include "Commands.h"
3+
4+
#include <Ext/Sidebar/Body.h>
5+
#include <Ext/Sidebar/SWSidebar/SWSidebarClass.h>
6+
7+
template<size_t Index>
8+
class FireTacticalSWCommandClass : public CommandClass
9+
{
10+
virtual const char* GetName() const override;
11+
virtual const wchar_t* GetUIName() const override;
12+
virtual const wchar_t* GetUICategory() const override;
13+
virtual const wchar_t* GetUIDescription() const override;
14+
virtual void Execute(WWKey eInput) const override;
15+
};
16+
17+
template<size_t Index>
18+
inline const char* FireTacticalSWCommandClass<Index>::GetName() const
19+
{
20+
_snprintf_s(Phobos::readBuffer, Phobos::readLength, "FireTacticalSW%d", Index + 1);
21+
return Phobos::readBuffer;
22+
}
23+
24+
template<size_t Index>
25+
inline const wchar_t* FireTacticalSWCommandClass<Index>::GetUIName() const
26+
{
27+
const wchar_t* csfString = StringTable::TryFetchString("TXT_FIRE_TACTICAL_SW_XX", L"Fire Super Weapon %d");
28+
_snwprintf_s(Phobos::wideBuffer, std::size(Phobos::wideBuffer), csfString, Index + 1);
29+
return Phobos::wideBuffer;
30+
}
31+
32+
template<size_t Index>
33+
inline const wchar_t* FireTacticalSWCommandClass<Index>::GetUICategory() const
34+
{
35+
return CATEGORY_INTERFACE;
36+
}
37+
38+
template<size_t Index>
39+
inline const wchar_t* FireTacticalSWCommandClass<Index>::GetUIDescription() const
40+
{
41+
const wchar_t* csfString = StringTable::TryFetchString("TXT_FIRE_TACTICAL_SW_XX_DESC", L"Fires the Super Weapon at position %d in the Super Weapon sidebar.");
42+
_snwprintf_s(Phobos::wideBuffer, std::size(Phobos::wideBuffer), csfString, Index + 1);
43+
return Phobos::wideBuffer;
44+
}
45+
46+
template<size_t Index>
47+
inline void FireTacticalSWCommandClass<Index>::Execute(WWKey eInput) const
48+
{
49+
if (!SWSidebarClass::IsEnabled())
50+
return;
51+
52+
const auto& columns = SWSidebarClass::Instance.Columns;
53+
54+
if (columns.empty())
55+
return;
56+
57+
const auto& buttons = columns.front()->Buttons;
58+
59+
if (Index < buttons.size())
60+
buttons[Index]->LaunchSuper();
61+
}

src/Commands/ToggleSWSidebar.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "ToggleSWSidebar.h"
2+
#include <HouseClass.h>
3+
4+
#include <Utilities/GeneralUtils.h>
5+
#include <Ext/Sidebar/SWSidebar/SWSidebarClass.h>
6+
7+
const char* ToggleSWSidebar::GetName() const
8+
{
9+
return "Toggle Super Weapon Sidebar";
10+
}
11+
12+
const wchar_t* ToggleSWSidebar::GetUIName() const
13+
{
14+
return GeneralUtils::LoadStringUnlessMissing("TXT_TOGGLE_SW_SIDEBAR", L"Toggle Super Weapon Sidebar");
15+
}
16+
17+
const wchar_t* ToggleSWSidebar::GetUICategory() const
18+
{
19+
return CATEGORY_INTERFACE;
20+
}
21+
22+
const wchar_t* ToggleSWSidebar::GetUIDescription() const
23+
{
24+
return GeneralUtils::LoadStringUnlessMissing("TXT_TOGGLE_SW_SIDEBAR_DESC", L"Toggle the Super Weapon Sidebar.");
25+
}
26+
27+
void ToggleSWSidebar::Execute(WWKey eInput) const
28+
{
29+
ToggleSWButtonClass::SwitchSidebar();
30+
31+
if (SWSidebarClass::Instance.CurrentColumn)
32+
MouseClass::Instance.UpdateCursor(MouseCursorType::Default, false);
33+
}

0 commit comments

Comments
 (0)