-
-
Notifications
You must be signed in to change notification settings - Fork 128
Add Rebuild X Keyboard Commands #2129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
CnCRAZER
wants to merge
7
commits into
Phobos-developers:develop
Choose a base branch
from
CnCRAZER:Rebuild-last-structure
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+416
−0
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
52ec449
Add 'Build Last' commands and tracking
CnCRAZER 4c8c18a
Update BuildLastOfTab.cpp
CnCRAZER 659478b
Update BuildLastOfTab.cpp
CnCRAZER ce2ddf9
Add docs for Rebuild keyboard commands
CnCRAZER b80444a
Update CREDITS.md
CnCRAZER 73edb17
Add rebuild commands for tab 3 subtypes
CnCRAZER cb9ffcd
Add Rebuild Aircraft/Naval; adjust BuildLast tabs
CnCRAZER File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| #include "BuildLastOfTab.h" | ||
|
|
||
| #include <Utilities/GeneralUtils.h> | ||
| #include <Ext/House/Body.h> | ||
| #include <HouseClass.h> | ||
| #include <EventClass.h> | ||
| #include <SidebarClass.h> | ||
|
|
||
| static constexpr const char* BuildLastTabNames[3] = | ||
| { | ||
| "RebuildStructure", | ||
| "RebuildDefense", | ||
| "RebuildInfantry", | ||
| }; | ||
|
|
||
| static constexpr const char* BuildLastTabDescKeys[3] = | ||
| { | ||
| "RebuildStructure_Desc", | ||
| "RebuildDefense_Desc", | ||
| "RebuildInfantry_Desc", | ||
| }; | ||
|
|
||
| static constexpr const wchar_t* BuildLastTabUINames[3] = | ||
| { | ||
| L"Rebuild Structure", | ||
| L"Rebuild Defense", | ||
| L"Rebuild Infantry", | ||
| }; | ||
|
|
||
| static constexpr const wchar_t* BuildLastTabUIDescs[3] = | ||
| { | ||
| L"Re-queue the last produced Power/Resources building.", | ||
| L"Re-queue the last produced Defense/Combat building.", | ||
| L"Re-queue the last produced Infantry unit.", | ||
| }; | ||
|
|
||
| template<int TabIndex> | ||
| const char* BuildLastOfTabCommandClass<TabIndex>::GetName() const | ||
| { | ||
| return BuildLastTabNames[TabIndex]; | ||
| } | ||
|
|
||
| template<int TabIndex> | ||
| const wchar_t* BuildLastOfTabCommandClass<TabIndex>::GetUIName() const | ||
| { | ||
| return GeneralUtils::LoadStringUnlessMissing(BuildLastTabNames[TabIndex], BuildLastTabUINames[TabIndex]); | ||
| } | ||
|
|
||
| template<int TabIndex> | ||
| const wchar_t* BuildLastOfTabCommandClass<TabIndex>::GetUICategory() const | ||
| { | ||
| return CATEGORY_INTERFACE; | ||
| } | ||
|
|
||
| template<int TabIndex> | ||
| const wchar_t* BuildLastOfTabCommandClass<TabIndex>::GetUIDescription() const | ||
| { | ||
| static_assert(TabIndex >= 0 && TabIndex < 3, "TabIndex out of range"); | ||
| return GeneralUtils::LoadStringUnlessMissing(BuildLastTabDescKeys[TabIndex], BuildLastTabUIDescs[TabIndex]); | ||
| } | ||
|
|
||
| template<int TabIndex> | ||
| void BuildLastOfTabCommandClass<TabIndex>::Execute(WWKey eInput) const | ||
| { | ||
| auto const pPlayer = HouseClass::CurrentPlayer; | ||
| if (!pPlayer) | ||
| return; | ||
|
|
||
| auto const pExt = HouseExt::ExtMap.Find(pPlayer); | ||
| if (!pExt) | ||
| return; | ||
|
|
||
| auto const typeIndex = pExt->LastBuiltPerTab[TabIndex]; | ||
| if (typeIndex < 0) | ||
| return; | ||
|
|
||
| // Focus the sidebar to the corresponding tab. | ||
| if (SidebarClass::Instance.IsSidebarActive) | ||
| { | ||
| SidebarClass::Instance.ActiveTabIndex = TabIndex; | ||
| SidebarClass::Instance.SidebarNeedsRepaint(); | ||
| } | ||
|
|
||
| auto const rtti = pExt->LastBuiltRTTIPerTab[TabIndex]; | ||
| auto const isNaval = pExt->LastBuiltIsNavalPerTab[TabIndex]; | ||
|
|
||
| EventClass::OutList.Add(EventClass( | ||
| pPlayer->ArrayIndex, | ||
| EventType::Produce, | ||
| static_cast<int>(rtti), | ||
| typeIndex, | ||
| isNaval ? TRUE : FALSE | ||
| )); | ||
| } | ||
|
|
||
| // Explicit instantiations | ||
| template class BuildLastOfTabCommandClass<0>; | ||
| template class BuildLastOfTabCommandClass<1>; | ||
| template class BuildLastOfTabCommandClass<2>; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #pragma once | ||
|
|
||
| #include "Commands.h" | ||
|
|
||
| // Re-queue the last produced item from a specific production tab. | ||
| // TabIndex: 0 = Power/Infrastructure, 1 = Defense/Combat, 2 = Infantry, 3 = Vehicles/Aircraft | ||
| template<int TabIndex> | ||
| class BuildLastOfTabCommandClass : public CommandClass | ||
| { | ||
| public: | ||
| virtual const char* GetName() const override; | ||
| virtual const wchar_t* GetUIName() const override; | ||
| virtual const wchar_t* GetUICategory() const override; | ||
| virtual const wchar_t* GetUIDescription() const override; | ||
| virtual void Execute(WWKey eInput) const override; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| #include "RebuildTab3Subtypes.h" | ||
|
|
||
| #include <Utilities/GeneralUtils.h> | ||
| #include <Ext/House/Body.h> | ||
| #include <HouseClass.h> | ||
| #include <EventClass.h> | ||
| #include <SidebarClass.h> | ||
|
|
||
| // Helper: issue a Produce event for a tracked subtype and focus sidebar to tab 3. | ||
| static void ExecuteRebuildSubtype(int typeIndex, AbstractType rtti, bool isNaval) | ||
| { | ||
| auto const pPlayer = HouseClass::CurrentPlayer; | ||
| if (!pPlayer) | ||
| return; | ||
|
|
||
| if (typeIndex < 0) | ||
| return; | ||
|
|
||
| if (SidebarClass::Instance.IsSidebarActive) | ||
| { | ||
| SidebarClass::Instance.ActiveTabIndex = 3; | ||
| SidebarClass::Instance.SidebarNeedsRepaint(); | ||
| } | ||
|
|
||
| EventClass::OutList.Add(EventClass( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| pPlayer->ArrayIndex, | ||
| EventType::Produce, | ||
| static_cast<int>(rtti), | ||
| typeIndex, | ||
| isNaval ? TRUE : FALSE | ||
| )); | ||
| } | ||
|
|
||
| // --- RebuildVehicle (non-naval UnitType) --- | ||
|
|
||
| const char* RebuildVehicleCommandClass::GetName() const | ||
| { | ||
| return "RebuildVehicleOnly"; | ||
| } | ||
|
|
||
| const wchar_t* RebuildVehicleCommandClass::GetUIName() const | ||
| { | ||
| return GeneralUtils::LoadStringUnlessMissing("RebuildVehicleOnly", L"Rebuild Vehicle"); | ||
| } | ||
|
|
||
| const wchar_t* RebuildVehicleCommandClass::GetUICategory() const | ||
| { | ||
| return CATEGORY_INTERFACE; | ||
| } | ||
|
|
||
| const wchar_t* RebuildVehicleCommandClass::GetUIDescription() const | ||
| { | ||
| return GeneralUtils::LoadStringUnlessMissing("RebuildVehicleOnly_Desc", L"Re-queue the last produced ground vehicle (non-naval)."); | ||
| } | ||
|
|
||
| void RebuildVehicleCommandClass::Execute(WWKey eInput) const | ||
| { | ||
| auto const pPlayer = HouseClass::CurrentPlayer; | ||
| if (!pPlayer) | ||
| return; | ||
|
|
||
| auto const pExt = HouseExt::ExtMap.Find(pPlayer); | ||
| if (!pExt) | ||
| return; | ||
|
|
||
| ExecuteRebuildSubtype(pExt->LastBuiltVehicleTypeIndex, pExt->LastBuiltVehicleRTTI, false); | ||
| } | ||
|
|
||
| // --- RebuildAircraft (AircraftType) --- | ||
|
|
||
| const char* RebuildAircraftCommandClass::GetName() const | ||
| { | ||
| return "RebuildAircraft"; | ||
| } | ||
|
|
||
| const wchar_t* RebuildAircraftCommandClass::GetUIName() const | ||
| { | ||
| return GeneralUtils::LoadStringUnlessMissing("RebuildAircraft", L"Rebuild Aircraft"); | ||
| } | ||
|
|
||
| const wchar_t* RebuildAircraftCommandClass::GetUICategory() const | ||
| { | ||
| return CATEGORY_INTERFACE; | ||
| } | ||
|
|
||
| const wchar_t* RebuildAircraftCommandClass::GetUIDescription() const | ||
| { | ||
| return GeneralUtils::LoadStringUnlessMissing("RebuildAircraft_Desc", L"Re-queue the last produced aircraft."); | ||
| } | ||
|
|
||
| void RebuildAircraftCommandClass::Execute(WWKey eInput) const | ||
| { | ||
| auto const pPlayer = HouseClass::CurrentPlayer; | ||
| if (!pPlayer) | ||
| return; | ||
|
|
||
| auto const pExt = HouseExt::ExtMap.Find(pPlayer); | ||
| if (!pExt) | ||
| return; | ||
|
|
||
| ExecuteRebuildSubtype(pExt->LastBuiltAircraftTypeIndex, pExt->LastBuiltAircraftRTTI, false); | ||
| } | ||
|
|
||
| // --- RebuildNaval (naval UnitType) --- | ||
|
|
||
| const char* RebuildNavalCommandClass::GetName() const | ||
| { | ||
| return "RebuildNaval"; | ||
| } | ||
|
|
||
| const wchar_t* RebuildNavalCommandClass::GetUIName() const | ||
| { | ||
| return GeneralUtils::LoadStringUnlessMissing("RebuildNaval", L"Rebuild Naval"); | ||
| } | ||
|
|
||
| const wchar_t* RebuildNavalCommandClass::GetUICategory() const | ||
| { | ||
| return CATEGORY_INTERFACE; | ||
| } | ||
|
|
||
| const wchar_t* RebuildNavalCommandClass::GetUIDescription() const | ||
| { | ||
| return GeneralUtils::LoadStringUnlessMissing("RebuildNaval_Desc", L"Re-queue the last produced naval unit."); | ||
| } | ||
|
|
||
| void RebuildNavalCommandClass::Execute(WWKey eInput) const | ||
| { | ||
| auto const pPlayer = HouseClass::CurrentPlayer; | ||
| if (!pPlayer) | ||
| return; | ||
|
|
||
| auto const pExt = HouseExt::ExtMap.Find(pPlayer); | ||
| if (!pExt) | ||
| return; | ||
|
|
||
| ExecuteRebuildSubtype(pExt->LastBuiltNavalTypeIndex, pExt->LastBuiltNavalRTTI, true); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #pragma once | ||
|
|
||
| #include "Commands.h" | ||
|
|
||
| // Dedicated rebuild commands for tab 3 subtypes. | ||
| // RebuildVehicle: re-queues the last non-naval UnitType. | ||
| // RebuildAircraft: re-queues the last AircraftType. | ||
| // RebuildNaval: re-queues the last naval UnitType. | ||
|
|
||
| class RebuildVehicleCommandClass : public CommandClass | ||
| { | ||
| public: | ||
| virtual const char* GetName() const override; | ||
| virtual const wchar_t* GetUIName() const override; | ||
| virtual const wchar_t* GetUICategory() const override; | ||
| virtual const wchar_t* GetUIDescription() const override; | ||
| virtual void Execute(WWKey eInput) const override; | ||
| }; | ||
|
|
||
| class RebuildAircraftCommandClass : public CommandClass | ||
| { | ||
| public: | ||
| virtual const char* GetName() const override; | ||
| virtual const wchar_t* GetUIName() const override; | ||
| virtual const wchar_t* GetUICategory() const override; | ||
| virtual const wchar_t* GetUIDescription() const override; | ||
| virtual void Execute(WWKey eInput) const override; | ||
| }; | ||
|
|
||
| class RebuildNavalCommandClass : public CommandClass | ||
| { | ||
| public: | ||
| virtual const char* GetName() const override; | ||
| virtual const wchar_t* GetUIName() const override; | ||
| virtual const wchar_t* GetUICategory() const override; | ||
| virtual const wchar_t* GetUIDescription() const override; | ||
| virtual void Execute(WWKey eInput) const override; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.