Skip to content

Add Rebuild X Keyboard Commands#2129

Open
CnCRAZER wants to merge 7 commits intoPhobos-developers:developfrom
CnCRAZER:Rebuild-last-structure
Open

Add Rebuild X Keyboard Commands#2129
CnCRAZER wants to merge 7 commits intoPhobos-developers:developfrom
CnCRAZER:Rebuild-last-structure

Conversation

@CnCRAZER
Copy link
Contributor

@CnCRAZER CnCRAZER commented Mar 5, 2026

This pull request introduces a set of new keyboard commands that allow players to quickly re-queue the last produced unit or building of various types directly from the sidebar. These "Rebuild" commands are implemented with supporting infrastructure for tracking the last built item per sidebar tab and per subtype (vehicle, aircraft, naval), and are fully integrated into the command registration and serialization systems. Documentation and credits have also been updated accordingly.

New "Rebuild" Commands Functionality:

  • Added new keyboard commands under the "Interface" category: Rebuild Structure, Rebuild Defense, Rebuild Infantry, Rebuild Vehicle, Rebuild Aircraft, and Rebuild Naval. These commands allow the player to quickly re-queue the last produced item of the corresponding type. [1] [2] [3] [4] [5] [6] [7]

Sidebar Tab and Subtype Tracking:

  • Implemented tracking of the last built item per sidebar tab and per subtype (vehicle, aircraft, naval) within the HouseExt extension. This enables the new commands to function reliably and recall the correct unit/building type. [1] [2] [3] [4]

Project and Build Integration:

  • Registered new command source files and headers in the project file (Phobos.vcxproj) and ensured all new commands are registered at runtime. [1] [2] [3] [4] [5]

Documentation and Credits:

  • Updated user documentation to describe the new "Rebuild" commands and their effects.
  • Added a changelog entry and credited the author for the new feature. [1] [2]

These changes collectively enhance the user interface by providing convenient hotkeys for quickly rebuilding recently produced units and structures, improving gameplay efficiency and quality of life.

CnCRAZER added 4 commits March 5, 2026 12:50
Introduce BuildLastOfTab commands to re-queue the last produced item from each sidebar tab (Power/Infrastructure, Defense/Combat, Infantry, Vehicles/Aircraft). Adds BuildLastOfTab.cpp/.h with a templated CommandClass (explicit instantiations for tabs 0..3) and UI strings. Register the new commands in Commands.cpp and add sources to the Visual Studio project file. Add per-tab last-built tracking to HouseExt (LastBuiltPerTab, LastBuiltRTTIPerTab, LastBuiltIsNavalPerTab), initialize defaults, and include them in serialization. Add a hook (Hooks.BuildLastTab.cpp) into HouseClass object delivery to update the per-tab last-built info when the current player's factory delivers an object.
Document four new keyboard commands (Rebuild Structure, Rebuild Defense, Rebuild Infantry, Rebuild Vehicle) in docs/User-Interface.md, add a What's New entry in docs/Whats-New.md, and credit RAZER in CREDITS.md. Adds brief descriptions and localization note for the new commands.
@CnCRAZER CnCRAZER changed the title Rebuild last structure Add Rebuild X Keyboard Commands Mar 5, 2026
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

Copy link
Contributor

@TaranDahl TaranDahl left a comment

Choose a reason for hiding this comment

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

Code looks good.
But there are design problems that need to be addressed.

- Re-queue the last produced Infantry you built.

### `[ ]` Rebuild Vehicle
- Re-queue the last produced Vehicle you built.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be best to handle Aircraft and Ship separately as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So 3 potential keybinds for last tab? Vehicle / navy / aircraft?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented this change. Let me know what you think

Copy link
Contributor

Choose a reason for hiding this comment

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

So 3 potential keybinds for last tab? Vehicle / navy / aircraft?

Yeah. In short, the key should bind to the production line instead of the tab.
In addition, the old code should be modified to ensure consistency (i.e., set the shortcut keys according to the production line instead of the tab).

CnCRAZER added 3 commits March 6, 2026 10:34
Introduce dedicated rebuild commands for tab 3: RebuildVehicle, RebuildAircraft and RebuildNaval. Adds new header/source (src/Commands/RebuildTab3Subtypes.*), registers the commands in Commands.cpp and includes them in the VCXPROJ and project includes. Track per-subtype last-built data in HouseExt (Body.h/Body.cpp) including type indices and RTTI, persist them in serialization, and update the existing BuildLastTab hook to maintain these per-subtype fields. Commands enqueue Produce events and focus the sidebar to tab 3 when executed, with UI strings loaded via GeneralUtils.
Introduce dedicated Rebuild Aircraft and Rebuild Naval commands and remove the Vehicle entry from the generic BuildLast tab set. Update BuildLastOfTab to use 3 tabs (Structure, Defense, Infantry) by shrinking the name/description/UI arrays and the static_assert, and remove the template instantiation/registration for the 4th tab. Register the new RebuildVehicle, RebuildAircraft and RebuildNaval commands in Commands.cpp instead of using a mixed Vehicle/Aircraft entry. Update docs: User-Interface.md wording ("Unit") and add UI entries for Rebuild Aircraft and Rebuild Naval, and Whats-New.md to list the new commands.
@TaranDahl
Copy link
Contributor

You need to set up a flag to control whether these shortcuts are enabled.

@secsome
Copy link
Member

secsome commented Mar 22, 2026

You need to set up a flag to control whether these shortcuts are enabled.

Why does these shortcuts need a flag? Are they balance related?

@CnCRAZER
Copy link
Contributor Author

You need to set up a flag to control whether these shortcuts are enabled.

IMO it's not the same as showing designator ranges and such. Just a QOL feature that can be used in Vanilla and/or any mod out there.

@TaranDahl
Copy link
Contributor

@Metadorius You have the final say.

Copy link
Member

@Metadorius Metadorius left a comment

Choose a reason for hiding this comment

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

I don't think a key to toggle is needed, why?

auto const rtti = pExt->LastBuiltRTTIPerTab[TabIndex];
auto const isNaval = pExt->LastBuiltIsNavalPerTab[TabIndex];

EventClass::OutList.Add(EventClass(
Copy link
Member

Choose a reason for hiding this comment

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

I am pretty sure this bypasses all the legality checks?

Copy link
Contributor

Choose a reason for hiding this comment

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

It will get rejected by the house if the house can't build it. That said, what we did in Vinifera is check if it's present on th sidebar as an icon as a shortcut.

SidebarClass::Instance.SidebarNeedsRepaint();
}

EventClass::OutList.Add(EventClass(
Copy link
Member

Choose a reason for hiding this comment

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

same

@TaranDahl
Copy link
Contributor

I don't think a key to toggle is needed, why?

Because you said that under the PR of aggressive stance.

@Metadorius
Copy link
Member

Because you said that under the PR of aggressive stance.

aggressive stance changes the gameplay mechanic; this does not

@CnCRAZER
Copy link
Contributor Author

CnCRAZER commented Mar 22, 2026

Been sharing this feature ontop 4.0.2 build with some friends in cncnet yr.

Only negative feedback or potential criticism with it is when using the hotkeys to rebuild last buildingtypes from tab 0 or 1, the rest of the cameo's do not get grey'd out as it would if you normally left clicked them. But with phobos having the ability to queu structures for production I'm not sure if this is needed.

@TaranDahl
Copy link
Contributor

this does not

Strictly speaking, no.
The fewer operations, the stronger it is. Any QoL improvements will affect gameplay.

@TaranDahl
Copy link
Contributor

Only negative feedback or potential criticism

I don't intend to give negative feedback.
I just think that if this is to be categorized as QoL without needing a switch, then it seems ridiculous that we had to enforce a switch for the Aggressive stance back then, especially since we drove away a developer because of this issue. It seems we don't have a clear standard for whether a feature should be categorized as QoL; it's all decided arbitrarily.

the rest of the cameo's do not get grey'd out as it would if you normally left clicked them.

Try marking that SidebarClass needs to be redrawn.

@TaranDahl
Copy link
Contributor

TaranDahl commented Mar 22, 2026

To be honest, I have absolutely no interest in whether there is a switch or not. I enable everything that I think can reduce operational requirements.
But I think we should not slap our past selves in the face, unless we are going to admit that it was a mistake and make corrections.

@CnCRAZER
Copy link
Contributor Author

I have absolutely no issues making it toggled by the way. Was only voicing my opinion on it. If all other shortcuts/keybinds are toggled then perhaps this should be as well for consistency

@Metadorius
Copy link
Member

Strictly speaking, no. The fewer operations, the stronger it is. Any QoL improvements will affect gameplay.

there is a line to be drawn, no need to have toggles for QoL stuff that's marginally changing the gameplay

@Metadorius
Copy link
Member

then it seems ridiculous that we had to enforce a switch for the Aggressive stance back then, especially since we drove away a developer because of this issue

the difference is that the gameplay impact was much bigger there than it is here. I don't have an objective measure, and I am not sure if we will ever have one because it's not possible to objectively measure everything, so I am going just by feeling. the line to be drawn lies somewhere between aggressive stance and this

@TaranDahl
Copy link
Contributor

Actually, I think you might as well say "My word is the line."
This standard is clear and unquestionable.

@Metadorius
Copy link
Member

Actually, I think you might as well say "My word is the line."
This standard is clear and unquestionable.

while simpler, I don't think that's how things should be done. I only exercise the "I said so" when I see some fatal-ish consequence, and whoever else doesn't understand. Otherwise I try to explain/figure out what's better with everyone else, of course, steering towards what is thought to be optimal solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants