Skip to content
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

Setting Sidebar tabs by selecting corresponded factory building #1435

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -364,6 +364,7 @@ This page lists all the individual contributions to the project by their author.
- Auto-deploy/Deploy block on ammo change
- Flashing Technos on selecting
- Promotion animation
- Set sidebar tab by selecting factory
- **ZivDero**
- Re-enable the Veinhole Monster and Weeds from TS
- Recreate the weed-charging of SWs like the TS Chemical Missile
Expand Down
2 changes: 1 addition & 1 deletion YRpp
Submodule YRpp updated 1 files
+3 −0 MouseClass.h
17 changes: 16 additions & 1 deletion docs/User-Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,29 @@ ShowTimer.Priority=0 ; integer

### Flashing Technos on selecting

Selecting technos, controlled by player, now may show a flash effect by setting `SelectionFlashDuration` parameter. Set `SelectionFlashDuration=0` to disable it.
- Selecting technos, controlled by player, now may show a flash effect by setting `SelectionFlashDuration` parameter. Set `SelectionFlashDuration=0` to disable it.

In `rulesmd.ini`:
```ini
[AudioVisual]
SelectionFlashDuration=0 ; integer, number of frames
```

### Set sidebar tab by selecting factory

- Factory buildings, owned by player, now may switch corresponded sidebar tabs, when selected, by enabling `SetTabBySelectingFactory` parameter.
- You may overwrite it to be able to switch to any sidebar tab by any building type selected, by setting `SetTabBySelecting` between 1 and 4.
- You may also disable it for factory building type by setting `SetTabBySelecting = 0`.

In `rulesmd.ini`:
```ini
[AudioVisual]
SetTabBySelectingFactory=false ; boolean

[SOMEBUILDING]
SetTabBySelecting=-1 ; integer, index of tab
```

## Hotkey Commands

### `[ ]` Display Damage Numbers
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ New:
- `<Player @ X>` can now be used as owner for pre-placed objects on skirmish and multiplayer maps (by Starkku)
- Allow customizing charge turret delays per burst on a weapon (by Starkku)
- Unit `Speed` setting now accepts floating point values (by Starkku)
- Set sidebar tab by selecting factory (by Fryone)

Vanilla fixes:
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)
Expand Down
3 changes: 3 additions & 0 deletions src/Ext/BuildingType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ void BuildingTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->Adjacent_Allowed.Read(exINI, pSection, "Adjacent.Allowed");
this->Adjacent_Disallowed.Read(exINI, pSection, "Adjacent.Disallowed");

this->SetTabBySelecting.Read(exINI, pSection, "SetTabBySelecting");

if (pThis->NumberOfDocks > 0)
{
this->AircraftDockingDirs.clear();
Expand Down Expand Up @@ -283,6 +285,7 @@ void BuildingTypeExt::ExtData::Serialize(T& Stm)
.Process(this->NoBuildAreaOnBuildup)
.Process(this->Adjacent_Allowed)
.Process(this->Adjacent_Disallowed)
.Process(this->SetTabBySelecting)
;
}

Expand Down
3 changes: 3 additions & 0 deletions src/Ext/BuildingType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class BuildingTypeExt
ValueableVector<BuildingTypeClass*> Adjacent_Allowed;
ValueableVector<BuildingTypeClass*> Adjacent_Disallowed;

Valueable<int> SetTabBySelecting;

ExtData(BuildingTypeClass* OwnerObject) : Extension<BuildingTypeClass>(OwnerObject)
, PowersUp_Owner { AffectedHouse::Owner }
, PowersUp_Buildings {}
Expand Down Expand Up @@ -126,6 +128,7 @@ class BuildingTypeExt
, NoBuildAreaOnBuildup { false }
, Adjacent_Allowed {}
, Adjacent_Disallowed {}
, SetTabBySelecting { -1 }
{ }

// Ares 0.A functions
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->DisplayIncome_AllowAI.Read(exINI, GameStrings::AudioVisual, "DisplayIncome.AllowAI");

this->IsVoiceCreatedGlobal.Read(exINI, GameStrings::AudioVisual, "IsVoiceCreatedGlobal");
this->SetTabBySelectingFactory.Read(exINI, GameStrings::AudioVisual, "SetTabBySelectingFactory");
this->SelectionFlashDuration.Read(exINI, GameStrings::AudioVisual, "SelectionFlashDuration");
this->DrawInsignia_OnlyOnSelected.Read(exINI, GameStrings::AudioVisual, "DrawInsignia.OnlyOnSelected");
this->DrawInsignia_AdjustPos_Infantry.Read(exINI, GameStrings::AudioVisual, "DrawInsignia.AdjustPos.Infantry");
Expand Down Expand Up @@ -359,6 +360,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->RadialIndicatorVisibility)
.Process(this->DrawTurretShadow)
.Process(this->IsVoiceCreatedGlobal)
.Process(this->SetTabBySelectingFactory)
.Process(this->SelectionFlashDuration)
.Process(this->DrawInsignia_OnlyOnSelected)
.Process(this->DrawInsignia_AdjustPos_Infantry)
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class RulesExt

Valueable<bool> ShowDesignatorRange;
Valueable<bool> IsVoiceCreatedGlobal;
Valueable<bool> SetTabBySelectingFactory;
Valueable<int> SelectionFlashDuration;
AnimTypeClass* DropPodTrailer;
SHPStruct* PodImage;
Expand Down Expand Up @@ -254,6 +255,7 @@ class RulesExt
, RadialIndicatorVisibility { AffectedHouse::Allies }
, DrawTurretShadow { false }
, IsVoiceCreatedGlobal { false }
, SetTabBySelectingFactory { false }
, SelectionFlashDuration { 0 }
, DrawInsignia_OnlyOnSelected { false }
, DrawInsignia_AdjustPos_Infantry { { 5, 2 } }
Expand Down
32 changes: 31 additions & 1 deletion src/Ext/Techno/Hooks.Misc.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Body.h"

#include <Ext/BuildingType/Body.h>
#include <SpawnManagerClass.h>
#include <TunnelLocomotionClass.h>

Expand Down Expand Up @@ -367,11 +368,40 @@ DEFINE_HOOK(0x5F46AE, ObjectClass_Select, 0x7)
{
GET(ObjectClass*, pThis, ESI);

const bool isControlledbyCurrentPlayer = pThis->GetOwningHouse()->IsControlledByCurrentPlayer();
const bool IsCurrentPlayer = pThis->GetOwningHouse()->IsCurrentPlayer();
pThis->IsSelected = true;

if (RulesExt::Global()->SelectionFlashDuration > 0 && pThis->GetOwningHouse()->IsControlledByCurrentPlayer())
if (RulesExt::Global()->SelectionFlashDuration > 0 && isControlledbyCurrentPlayer)
pThis->Flash(RulesExt::Global()->SelectionFlashDuration);

if (RulesExt::Global()->SetTabBySelectingFactory && pThis->WhatAmI() == AbstractType::Building && IsCurrentPlayer)
{
auto const pBldTypeExt = BuildingTypeExt::ExtMap.Find(specific_cast<BuildingClass*>(pThis)->Type);
const int tabIndex = pBldTypeExt->SetTabBySelecting;

if (5 > tabIndex && tabIndex > 0)
TabClass::Instance->SetTab(tabIndex - 1);
else if (tabIndex == -1)
switch (specific_cast<BuildingClass*>(pThis)->Type->Factory)
{
case AbstractType::BuildingType:
TabClass::Instance->SetTab(SidebarClass::Instance->ActiveTabIndex == 0 ? 1 : 0);
break;
case AbstractType::InfantryType:
TabClass::Instance->SetTab(2);
break;
case AbstractType::AircraftType:
TabClass::Instance->SetTab(3);
break;
case AbstractType::UnitType:
TabClass::Instance->SetTab(3);
break;
default:
break;
}
}

return 0;
}

Expand Down
Loading