Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
325989f
Core
CrimRecya Dec 15, 2024
4875c49
Merge branch 'develop' into develop-Distribution
CrimRecya Jan 26, 2025
6edc48e
Update Whats-New.md
CrimRecya Jan 26, 2025
73a6c0b
Draw at mouse
CrimRecya Jan 26, 2025
97c070d
Show range ring
CrimRecya Jan 26, 2025
e242669
Fix a typo
CrimRecya Jan 26, 2025
ab9c046
Fix target cloaked units
CrimRecya Feb 2, 2025
97f0e11
Merge branch 'develop' into develop-Distribution
CrimRecya Feb 2, 2025
32c90bd
")"
DeathFishAtEase Feb 2, 2025
82ea77c
Add a hold down key to enable
CrimRecya Feb 3, 2025
957b2ef
Merge branch 'develop' into develop-Distribution
CrimRecya Feb 3, 2025
d279944
Doc
CrimRecya Feb 3, 2025
4444222
Fix target shrouded units
CrimRecya Feb 3, 2025
40051d9
Fix target disguised units
CrimRecya Feb 3, 2025
2e38594
Fix target outside units
CrimRecya Feb 3, 2025
55723f3
Global toggle
CrimRecya Feb 13, 2025
dab3385
Merge branch 'develop' into develop-Distribution
CrimRecya Feb 13, 2025
1c47634
Message, sound and scroll action
CrimRecya Mar 6, 2025
90556bd
Merge remote-tracking branch 'upstream/develop' into develop-Distribu…
CrimRecya Mar 6, 2025
f4ae01b
Merge remote-tracking branch 'upstream/develop' into develop-Distribu…
CrimRecya Mar 25, 2025
6ce7407
Fix merge
CrimRecya Mar 25, 2025
685d456
Low distance first
CrimRecya Mar 25, 2025
1bb257d
...
CrimRecya Mar 25, 2025
ce16654
Merge remote-tracking branch 'upstream/develop' into develop-Distribu…
Coronia Jul 5, 2025
96c6a06
Merge branch 'develop' into develop-Distribution
Coronia Jul 5, 2025
25574cc
Code style
CrimRecya Jul 5, 2025
cd1b12f
Merge remote-tracking branch 'upstream/develop' into develop-Distribu…
Coronia Jul 15, 2025
3191dab
remove unnecessary Grinder process
Coronia Jul 16, 2025
55b7208
Merge branch 'develop' into develop-Distribution
Coronia Jul 16, 2025
4d1c883
Merge remote-tracking branch 'upstream/develop' into develop-Distribu…
CrimRecya Aug 6, 2025
b55908a
Refactor
CrimRecya Aug 6, 2025
6525feb
Remove useless
CrimRecya Aug 6, 2025
09bae51
Fix default value
CrimRecya Aug 6, 2025
aa509d0
Separate functions
CrimRecya Aug 6, 2025
e0bbe02
Fix include
CrimRecya Aug 6, 2025
573d8f8
Fit with FakeOf
CrimRecya Aug 26, 2025
fdd82ac
Merge branch 'develop' into develop-Distribution
CrimRecya Aug 26, 2025
4ab9876
TODO
CrimRecya Aug 28, 2025
2892caf
Merge branch 'develop' into develop-Distribution
CrimRecya Sep 13, 2025
e49a75f
Update YRpp
CrimRecya Sep 13, 2025
eb552f1
Button on bottom
CrimRecya Sep 13, 2025
27ca512
update doc
Coronia Oct 18, 2025
88c6cbe
Merge branch 'develop' into develop-Distribution
Coronia Oct 18, 2025
9dcbd2c
revert YRpp
Coronia Oct 18, 2025
744bf42
Merge branch 'develop' into develop-Distribution
Coronia Oct 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ This page lists all the individual contributions to the project by their author.
- Fix an issue that units' `LaserTrails` will always lags behind by one frame
- Fix an issue that the currently hovered planning node not update up-to-date, such as using hotkeys to select technos
- Allow the aircraft to enter area guard mission and not crash immediately without any airport
- Distribution click action mode
- **Ollerus**:
- Build limit group enhancement
- Customizable rocker amplitude
Expand Down
2 changes: 2 additions & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<ClCompile Include="src\Commands\ToggleDesignatorRange.cpp" />
<ClCompile Include="src\Commands\ToggleDigitalDisplay.cpp" />
<ClCompile Include="src\Commands\SaveVariablesToFile.cpp" />
<ClCompile Include="src\Commands\DistributionMode.cpp" />
<ClCompile Include="src\Ext\Anim\Body.cpp" />
<ClCompile Include="src\Ext\Anim\Hooks.cpp" />
<ClCompile Include="src\Ext\Anim\Hooks.AnimCreateUnit.cpp" />
Expand Down Expand Up @@ -242,6 +243,7 @@
<ClInclude Include="src\Commands\ToggleDesignatorRange.h" />
<ClInclude Include="src\Commands\ToggleDigitalDisplay.h" />
<ClInclude Include="src\Commands\SaveVariablesToFile.h" />
<ClInclude Include="src\Commands\DistributionMode.h" />
<ClInclude Include="src\Ext\Bullet\Trajectories\BombardTrajectory.h" />
<ClInclude Include="src\Ext\Bullet\Trajectories\PhobosTrajectory.h" />
<ClInclude Include="src\Ext\Bullet\Trajectories\StraightTrajectory.h" />
Expand Down
2 changes: 1 addition & 1 deletion YRpp
51 changes: 51 additions & 0 deletions docs/User-Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,57 @@ For this command to work in multiplayer - you need to use a version of [YRpp spa
- These vanilla CSF entries will be used: `TXT_SAVING_GAME`, `TXT_GAME_WAS_SAVED` and `TXT_ERROR_SAVING_GAME`.
- The save should be looks like `Allied Mission 25: Esther's Money - QuickSaved`.

### `[ ]` Distribution Mode Spread / Filter / Enable

- Now you can change the click action by using `AllowSwitchNoMoveCommand` hotkey. If the behavior to be executed by the current techno is different from the behavior displayed by the mouse, and the behavior to be executed will make the techno move near the target, the behavior will be replaced with area guard. Regardless of whether or not switch hotkey is used, default behavior can be changed through `DefaultApplyNoMoveCommand`.
- Now you can also change the click action when hold down the specific hotkey if enabled `AllowDistributionCommand`. The new behavior is like using the selected objects one by one to click on each target within the range.
- `AllowDistributionCommand.SpreadMode` & `AllowDistributionCommand.FilterMode` allow you to set spread range and target filter by hotkeys, which default to `DefaultDistributionSpreadMode` and `DefaultDistributionFilterMode`.
- When the range is 0, it is the original default behavior of the game. The range can be adjusted to 4, 8 or 16 cells by another shortcut key. You can also adjust this by using the mouse wheel while holding down the specific hotkey if `AllowDistributionCommand.SpreadModeScroll` set to true;
- The targets within the range will be allocated equally to the selected technos. Only when the behavior to be performed by the current techno is the same as that displayed by the mouse will it be allocated. Otherwise, it will return to the original default behavior of the game (it will not be effective for technos in the air). This will display a range ring.
- When the filter is `None`, it is the default behavior of the game. If the range is not zero at this time, a green ring will be displayed. You can adjust the filter mode to:
- `Like` - only targets with the same armor type (Completely identical `Armor`) will be selected among the targets allocated in the range. At this time, a blue ring will be displayed.
- `Type` - only targets of the same type (like infantries, vehicles or buildings) will be selected among the targets allocated in the range. At this time, a yellow ring will be displayed.
- `Name` - only targets of the same name (or with the same `GroupAs`) will be selected among the targets allocated in the range. At this time, a red ring will be displayed.
- `AllowDistributionCommand.AffectsAllies` & `AllowDistributionCommand.AffectsEnemies` allow the distribution command to work on allies (including owner) or enemies target. If picking a target that's not eligible, it'll fallback to vanilla command.
- It's possible to add a button for distribution mode in the bottom bar by adding `DistributionMode` in the `ButtonList` of `AdvancedCommandBar` and `MultiplayerAdvancedCommandBar`.
- The positions of each button are hardcoded, so it'll only decide whether enable this button or not. Distribute Mode button is now always listed after all the vanilla ones.
- The asset of these buttons should be added in `sidec0x.mix` files which correspond to different sides, with the name `button12.shp`.
- For localization add `TXT_SWITCH_NOMOVE`, `TXT_DISTR_SPREAD`, `TXT_DISTR_FILTER`, `TXT_DISTR_HOLDDOWN`, `TXT_SWITCH_NOMOVE_DESC`, `TXT_DISTR_SPREAD_DESC`, `TXT_DISTR_FILTER_DESC`, `TXT_DISTR_HOLDDOWN_DESC`, `MSG:DistributionModeOn`, `MSG:DistributionModeOff`, `TIP:DistributionMode` into your `.csf` file.

In `rulesmd.ini`:
```ini
[GlobalControls]
AllowSwitchNoMoveCommand=false ; boolean
AllowDistributionCommand=false ; boolean
AllowDistributionCommand.SpreadMode=true ; boolean
AllowDistributionCommand.SpreadModeScroll=true ; boolean
AllowDistributionCommand.FilterMode=true ; boolean
AllowDistributionCommand.AffectsAllies=true ; boolean
AllowDistributionCommand.AffectsEnemies=true ; boolean

[AudioVisual]
StartDistributionModeSound= ; sound entry
EndDistributionModeSound= ; sound entry
AddDistributionModeCommandSound= ; sound entry
```

In `ra2md.ini`:
```ini
[Phobos]
DefaultApplyNoMoveCommand=true ; boolean
DefaultDistributionSpreadMode=2 ; integer, 0 - r=0 , 1 - r=4 , 2 - r=8 , 3 - r=16
DefaultDistributionFilterMode=2 ; integer, 0 - None , 1 - Like , 2 - Type , 3 - Name
```

In `uimd.ini`:
```ini
[AdvancedCommandBar]
ButtonList=[Button1],DistributionMode,[ButtonX] ; List of button entry

[MultiplayerAdvancedCommandBar]
ButtonList=[Button1],DistributionMode,[ButtonX] ; List of button entry
```

### `[ ]` Toggle Message Label

- Switches on/off [Task subtitles' label in the middle of the screen](#task-subtitles-display-in-the-middle-of-the-screen).
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ New:
- Fast access structure (by FlyStar)
- Toggle off laser trail and shake effects (by Ollerus)
- [Dehardcode the `ZAdjust` of warhead anim](Fixed-or-Improved-Logics.md#dehardcode-the-zadjust-of-warhead-anim) (by TaranDahl)
- Distribution click action mode (by CrimRecya)

Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
111 changes: 110 additions & 1 deletion src/Commands/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@
#include "ToggleDigitalDisplay.h"
#include "ToggleDesignatorRange.h"
#include "SaveVariablesToFile.h"
#include "DistributionMode.h"
#include "ToggleSWSidebar.h"
#include "FireTacticalSW.h"
#include "ToggleMessageList.h"

#include <CCINIClass.h>
#include <ShapeButtonClass.h>

#include <Utilities/Macro.h>
#include <Ext/Sidebar/SWSidebar/SWSidebarClass.h>
#include <Misc/MessageColumn.h>

#pragma region HotkeyCommand

DEFINE_HOOK(0x533066, CommandClassCallback_Register, 0x6)
{
// Load it after Ares'
Expand All @@ -44,6 +48,20 @@ DEFINE_HOOK(0x533066, CommandClassCallback_Register, 0x6)
SWSidebarClass::Commands[9] = MakeCommand<FireTacticalSWCommandClass<9>>();
}

if (Phobos::Config::AllowSwitchNoMoveCommand)
MakeCommand<SwitchNoMoveCommandClass>();

if (Phobos::Config::AllowDistributionCommand)
{
if (Phobos::Config::AllowDistributionCommand_SpreadMode)
MakeCommand<DistributionModeSpreadCommandClass>();

if (Phobos::Config::AllowDistributionCommand_FilterMode)
MakeCommand<DistributionModeFilterCommandClass>();

MakeCommand<DistributionModeHoldDownCommandClass>();
}

if (Phobos::Config::DevelopmentCommands)
{
MakeCommand<DamageDisplayCommandClass>();
Expand All @@ -61,14 +79,24 @@ DEFINE_HOOK(0x533066, CommandClassCallback_Register, 0x6)
return 0;
}

#pragma endregion

#pragma region MouseScroll

static void MouseWheelDownCommand()
{
if (DistributionModeHoldDownCommandClass::Enabled && Phobos::Config::AllowDistributionCommand_SpreadModeScroll)
DistributionModeHoldDownCommandClass::DistributionSpreadModeReduce();

if (MessageColumnClass::Instance.IsHovering())
MessageColumnClass::Instance.ScrollDown();
}

static void MouseWheelUpCommand()
{
if (DistributionModeHoldDownCommandClass::Enabled && Phobos::Config::AllowDistributionCommand_SpreadModeScroll)
DistributionModeHoldDownCommandClass::DistributionSpreadModeExpand();

if (MessageColumnClass::Instance.IsHovering())
MessageColumnClass::Instance.ScrollUp();
}
Expand All @@ -87,11 +115,92 @@ DEFINE_HOOK(0x777998, Game_WndProc_ScrollMouseWheel, 0x6)

static inline bool CheckSkipScrollSidebar()
{
return MessageColumnClass::Instance.IsHovering();
return DistributionModeHoldDownCommandClass::Enabled
|| MessageColumnClass::Instance.IsHovering();
}

DEFINE_HOOK(0x533F50, Game_ScrollSidebar_Skip, 0x5)
{
enum { SkipScrollSidebar = 0x533FC3 };
return CheckSkipScrollSidebar() ? SkipScrollSidebar : 0;
}

#pragma endregion

#pragma region ShapeButton

int ShapeButtonHelper::NewButtonIndexes[ShapeButtonHelper::NewButtonCount] =
{
-1 // DistributionMode
// New button initialize here
};

DEFINE_HOOK(0x6CFD08, ShapeButtonClass_FindIndex_FindNewButton, 0x5)
{
enum { SetButtonIndex = 0x6CFD0D };

GET(const char*, name, ECX);

for (int i = 0; i < ShapeButtonHelper::NewButtonCount; ++i)
{
if (_strcmpi(name, ShapeButtonHelper::NewButtonNames[i]) == 0)
{
R->EAX(i + ShapeButtonHelper::OldButtonCount);
return SetButtonIndex;
}
}

return 0;
}

DEFINE_HOOK(0x6D0233, TabClass_Init_InitNewButtonIndex, 0x6)
{
for (int i = 0; i < ShapeButtonHelper::NewButtonCount; ++i)
ShapeButtonHelper::NewButtonIndexes[i] = ShapeButtonClass::FindIndex(ShapeButtonHelper::NewButtonNames[i]);

return 0;
}

DEFINE_HOOK(0x6D0827, TabClass_Update_UpdateNewButton, 0x6)
{
GET(const int, index, EAX);

if (ShapeButtonHelper::NewButtonIndexes[0] == index)
{
if (ShapeButtonClass::GetButton(index)->IsOn)
DistributionModeHoldDownCommandClass::DistributionModeOn();
else
DistributionModeHoldDownCommandClass::DistributionModeOff();
}

// New button trigger here

return 0;
}

DEFINE_HOOK(0x6D10DF, TabClass_InitButtonIO_InitNewHoldDownButton, 0x6)
{
const int distributionModeButtonIndex = ShapeButtonHelper::NewButtonIndexes[0];

if (distributionModeButtonIndex != -1)
{
if (const auto pButton = ShapeButtonClass::GetButton(distributionModeButtonIndex))
{
// Clicking the button is different from holding down the hotkey
pButton->ToggleType = 1;
pButton->UseFlash = true;
}
}

return 0;
}

DEFINE_HOOK(0x6D14DD, TabClass_InitToolTip_InitNewButtonToolTip, 0x5)
{
for (int i = 0; i < ShapeButtonHelper::NewButtonCount; ++i)
ShapeButtonClass::SetToolTip(ShapeButtonClass::GetButton(ShapeButtonHelper::NewButtonIndexes[i]), ShapeButtonHelper::NewButtonTipNames[i]);

return 0;
}

#pragma endregion
33 changes: 33 additions & 0 deletions src/Commands/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,39 @@ T* MakeCommand()
return command;
};

class ShapeButtonHelper
{
public:
static constexpr int MaxButtonCount = 25;
static constexpr int InUseButtonCount = 11;
static constexpr int UnusedButtonCount = 1;
static constexpr int OldButtonCount = InUseButtonCount + UnusedButtonCount;
static constexpr int NewButtonCount = std::min(1, (MaxButtonCount - OldButtonCount));
// 1. Team01
// 2. Team02
// 3. Team03
// 4. TypeSelect
// 5. Deploy
// 6. AttackMove
// 7. Guard
// 8. Beacon
// 9. Stop
// 10. PlanningMode
// 11. Cheer
// 12. MoveToDeploy
static constexpr const char* NewButtonNames[NewButtonCount] =
{
/* 13. */ "DistributionMode"
/* New button name here */
};
static constexpr const char* NewButtonTipNames[NewButtonCount] =
{
"Tip:DistributionMode"
// New button tip here
};
static int NewButtonIndexes[NewButtonCount];
};
Comment on lines +17 to +48
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to be refactored, and it is important as it's a framework code and it is going to be used for other buttons as well.

Per @tomsons26 who is well into the engine(s), the bottom bar is called Advanced Command Bar. I propose to transform those static array fields into fields of AdvancedCommandBarButtonClass and use a similar approach with registering as with CommandClass.

Maybe it would also be beneficial to place commands and command buttons separately.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Courtesy of @tomsons26

TabClass_CommandBar_from_name	006CFCC0	
TabClass_CommandBar_set_index	006CFD20	
TabClass_CommandBar_get_index	006CFD30	
TabClass_CommandBar_get_button	006CFD40	
TabClass_CommandBar_get_dimensions	006CFD60	
TabClass_CommandBar_set_count	006CFDB0	
TabClass_CommandBar_inrange	006CFDF0	
TabClass_CommandBar_getoffset	006CFE10	
TabClass_CommandBar_unload_shapes	006D0270	
TabClass_CommandBar_add_buttons	006D04A0	
TabClass_CommandBar_remove_buttons	006D04D0	
TabClass_CommandBar_Link_Tooptip	006D09C0	
TabClass_CommandBar_load_buttons_shapes	006D0F10	
TabClass_CommandBar_unload_buttons_shapes	006D0F70	
TabClass_CommandBar_set_id	006D0FB0	
TabClass_CommandBar_init_io	006D0FD0	
TabClass_CommandBar_init_thumb	006D1130	
TabClass_CommandBar_activate	006D1200	
TabClass_CommandBar_deinit	006D14F0	
TabClass_CommandBar_add_thumb	006D1570	
TabClass_CommandBar_remove_thumb	006D15F0	
TabClass_CommandBar_activate_thumb	006D1610	
TabClass_CommandBar_deactivate_thumb	006D1660	
char * const RulesClass::int AdvancedCommandBar(CCINIClass &)::.0::AdvancedCommandBar	007F0CE8	
char * const RulesClass::int MultiplayerAdvancedCommandBar(CCINIClass &)::.0::MultiplayerAdvancedCommandBar	007F0CEC	
CommandBar_invalid_id	008427CC	
CommandBar_button_names	008427D0	
CommandBar_do_subtract_in_do_blit	00884D2E	
CommandBar_shapes	00B0C148	
CommandBar_chear_id	00B0C1B8	
CommandBar_button_shapes	00B0C1C0	
CommandBar_deploy_id	00B0CB20	
CommandBar_type_select_id	00B0CB38	
CommandBar_beacon_id	00B0CB3C	
CommandBar_first_button_h	00B0CB50	
CommandBar_count	00B0CB54	
CommandBar_guard_id	00B0CB68	
CommandBar_stop_id	00B0CB6C	
CommandBar_index_lookup	00B0CB78	
CommandBar_shapes_is_allocated	00B0CBDC	
CommandBar_planning_id	00B0CC1C	
CommandBar_team_1_id	00B0CC20	
CommandBar_yoff	00B0CC24	
CommandBar_team_2_id	00B0CC28	
CommandBar_max_xpos	00B0CC2C	
CommandBar_xoff	00B0CC38	
CommandBar_thumb_shape_deactivated	00B0CC40	
CommandBar_thumb_shape_activated	00B0CCB0	
CommandBar_some_width	00B0CD10	
CommandBar_attackmove_id	00B0CD24	
CommandBar_team_3_id	00B0CD28	
CommandBar_first_button_w	00B0CD38	
CommandBar_cap_shape	00B0FA90	
CommandBar_main_rect	00B0FC58	
CommandBar_rect2	00B0FC60	
CommandBar_BTTNBKGD_SHP_rect	00B0FC68	
CommandBar_RENDCAP_SHP_rect	00B0FC6C


#define CATEGORY_TEAM StringTable::LoadString(GameStrings::TXT_TEAM)
#define CATEGORY_INTERFACE StringTable::LoadString(GameStrings::TXT_INTERFACE)
#define CATEGORY_TAUNT StringTable::LoadString(GameStrings::TXT_TAUNT)
Expand Down
Loading