Skip to content

Commit

Permalink
Assign Super Weapon cameo to any sidebar tab (#1387)
Browse files Browse the repository at this point in the history
- Now you can specific sw will insert to which tab of sidebar.

In `rulesmd.ini`
```ini
[SOMESW]                    ; Super Weapon
TabIndex=1                  ; integer
```

---------

Co-authored-by: MortonPL <[email protected]>
Co-authored-by: Kerbiter <[email protected]>
  • Loading branch information
3 people authored Sep 23, 2024
1 parent 9d0f94e commit fca5e1f
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 0 deletions.
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ This page lists all the individual contributions to the project by their author.
- Jumpjet crash speed fix when crashing onto building
- Disguised units not using the correct palette if target has custom palette bugfix
- Tunnel/Walk/Mech locomotor being stuck when moving too fast bugfix
- Assign Super Weapon cameo to any sidebar tab
- **Apollo** - Translucent SHP drawing patches
- **ststl**
- Customizable ShowTimer priority of superweapons
Expand Down
11 changes: 11 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,17 @@ Detonate.Damage= ; integer
Detonate.AtFirer=false ; boolean
```

### Customize SuperWeapon TabIndex

- You can now assign a Super Weapon's cameo to any sidebar tab using `TabIndex`.
- Valid values are: 0 (buildings tab), 1 (arsenal tab), 2 (infantry tab), 3 (vehicle tab).

In `rulesmd.ini`:
```ini
[SOMESW] ; Super Weapon
TabIndex=1 ; integer
```

## Technos

### Aircraft spawner customizations
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ New:
- Nonprovocative Warheads (by Starkku)
- Option to restore `PowerSurplus` setting for AI (by Starkku)
- `FireOnce` infantry sequence reset toggle (by Starkku)
- Assign Super Weapon cameo to any sidebar tab (by NetsuNegi)
Vanilla fixes:
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/SWType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void SWTypeExt::ExtData::Serialize(T& Stm)
.Process(this->ShowTimer_Priority)
.Process(this->Convert_Pairs)
.Process(this->ShowDesignatorRange)
.Process(this->TabIndex)
.Process(this->UseWeeds)
.Process(this->UseWeeds_Amount)
.Process(this->UseWeeds_StorageTimer)
Expand Down Expand Up @@ -160,6 +161,9 @@ void SWTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)

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

this->TabIndex.Read(exINI, pSection, "TabIndex");
GeneralUtils::IntValidCheck(&this->TabIndex, pSection, "TabIndex", 1, 0, 3);

this->UseWeeds.Read(exINI, pSection, "UseWeeds");
this->UseWeeds_Amount.Read(exINI, pSection, "UseWeeds.Amount");
this->UseWeeds_StorageTimer.Read(exINI, pSection, "UseWeeds.StorageTimer");
Expand Down
3 changes: 3 additions & 0 deletions src/Ext/SWType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class SWTypeExt
Valueable<bool> Detonate_AtFirer;
Valueable<bool> ShowDesignatorRange;

Valueable<int> TabIndex;

std::vector<ValueableVector<int>> LimboDelivery_RandomWeightsData;
std::vector<ValueableVector<int>> SW_Next_RandomWeightsData;

Expand Down Expand Up @@ -107,6 +109,7 @@ class SWTypeExt
, ShowTimer_Priority { 0 }
, Convert_Pairs {}
, ShowDesignatorRange { true }
, TabIndex { 1 }
, UseWeeds { false }
, UseWeeds_Amount { RulesClass::Instance->WeedCapacity }
, UseWeeds_StorageTimer { false }
Expand Down
64 changes: 64 additions & 0 deletions src/Ext/SWType/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,67 @@ DEFINE_HOOK(0x6CC1E6, SuperClass_SetSWCharge_UseWeeds, 0x5)

return 0;
}

#pragma region SW TabIndex
DEFINE_HOOK(0x6A5F6E, SidebarClass_6A5F20_TabIndex, 0x8)
{
enum { ApplyTabIndex = 0x6A5FD3 };

GET(AbstractType const, absType, ESI);
GET(int const, typeIdx, EAX);

R->EAX(SidebarClass::GetObjectTabIdx(absType, typeIdx, 0));
return ApplyTabIndex;
}

DEFINE_HOOK(0x6A614D, SidebarClass_6A6140_TabIndex, 0x5)
{
enum { ApplyTabIndex = 0x6A61B1 };

GET(AbstractType const, absType, EDI);
GET(int const, typeIdx, EBP);

R->EAX(SidebarClass::GetObjectTabIdx(absType, typeIdx, 0));
return ApplyTabIndex;
}

DEFINE_HOOK(0x6A633D, SidebarClass_AddCameo_TabIndex, 0x5)
{
enum { ApplyTabIndex = 0x6A63B7 };

GET(AbstractType const, absType, ESI);
GET(int const, typeIdx, EBP);

R->Stack(STACK_OFFSET(0x14, 0x4), SidebarClass::GetObjectTabIdx(absType, typeIdx, 0));
return ApplyTabIndex;
}

DEFINE_HOOK(0x6ABC9D, SidebarClass_GetObjectTabIndex_Super, 0x5)
{
enum { ApplyTabIndex = 0x6ABCA2 };

GET(int const, typeIdx, EDX);

if (typeIdx < 0 || typeIdx >= SuperWeaponTypeClass::Array->Count)
return 0;

const auto pSWType = SuperWeaponTypeClass::Array->Items[typeIdx];
const auto pSWTypExt = SWTypeExt::ExtMap.Find(pSWType);

R->EAX(pSWTypExt->TabIndex);
return ApplyTabIndex;
}

DEFINE_HOOK(0x6AC67A, SidebarClass_6AC5F0_TabIndex, 0x5)
{
enum { ApplyTabIndex = 0x6AC6D9 };

GET(AbstractType const, absType, EAX);
GET(int const, typeIdx, ESI);

R->EAX(SidebarClass::GetObjectTabIdx(absType, typeIdx, 0));
return ApplyTabIndex;
}

DEFINE_JUMP(LJMP, 0x6A8D07, 0x6A8D17) // Skip tabIndex check
#pragma endregion

0 comments on commit fca5e1f

Please sign in to comment.