Skip to content

Commit fca5e1f

Browse files
NetsuNegiMortonPLMetadorius
authored
Assign Super Weapon cameo to any sidebar tab (#1387)
- 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]>
1 parent 9d0f94e commit fca5e1f

File tree

6 files changed

+84
-0
lines changed

6 files changed

+84
-0
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ This page lists all the individual contributions to the project by their author.
329329
- Jumpjet crash speed fix when crashing onto building
330330
- Disguised units not using the correct palette if target has custom palette bugfix
331331
- Tunnel/Walk/Mech locomotor being stuck when moving too fast bugfix
332+
- Assign Super Weapon cameo to any sidebar tab
332333
- **Apollo** - Translucent SHP drawing patches
333334
- **ststl**
334335
- Customizable ShowTimer priority of superweapons

docs/New-or-Enhanced-Logics.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,17 @@ Detonate.Damage= ; integer
874874
Detonate.AtFirer=false ; boolean
875875
```
876876

877+
### Customize SuperWeapon TabIndex
878+
879+
- You can now assign a Super Weapon's cameo to any sidebar tab using `TabIndex`.
880+
- Valid values are: 0 (buildings tab), 1 (arsenal tab), 2 (infantry tab), 3 (vehicle tab).
881+
882+
In `rulesmd.ini`:
883+
```ini
884+
[SOMESW] ; Super Weapon
885+
TabIndex=1 ; integer
886+
```
887+
877888
## Technos
878889

879890
### Aircraft spawner customizations

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ New:
452452
- Nonprovocative Warheads (by Starkku)
453453
- Option to restore `PowerSurplus` setting for AI (by Starkku)
454454
- `FireOnce` infantry sequence reset toggle (by Starkku)
455+
- Assign Super Weapon cameo to any sidebar tab (by NetsuNegi)
455456
456457
Vanilla fixes:
457458
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)

src/Ext/SWType/Body.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ void SWTypeExt::ExtData::Serialize(T& Stm)
4747
.Process(this->ShowTimer_Priority)
4848
.Process(this->Convert_Pairs)
4949
.Process(this->ShowDesignatorRange)
50+
.Process(this->TabIndex)
5051
.Process(this->UseWeeds)
5152
.Process(this->UseWeeds_Amount)
5253
.Process(this->UseWeeds_StorageTimer)
@@ -160,6 +161,9 @@ void SWTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
160161

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

164+
this->TabIndex.Read(exINI, pSection, "TabIndex");
165+
GeneralUtils::IntValidCheck(&this->TabIndex, pSection, "TabIndex", 1, 0, 3);
166+
163167
this->UseWeeds.Read(exINI, pSection, "UseWeeds");
164168
this->UseWeeds_Amount.Read(exINI, pSection, "UseWeeds.Amount");
165169
this->UseWeeds_StorageTimer.Read(exINI, pSection, "UseWeeds.StorageTimer");

src/Ext/SWType/Body.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class SWTypeExt
6060
Valueable<bool> Detonate_AtFirer;
6161
Valueable<bool> ShowDesignatorRange;
6262

63+
Valueable<int> TabIndex;
64+
6365
std::vector<ValueableVector<int>> LimboDelivery_RandomWeightsData;
6466
std::vector<ValueableVector<int>> SW_Next_RandomWeightsData;
6567

@@ -107,6 +109,7 @@ class SWTypeExt
107109
, ShowTimer_Priority { 0 }
108110
, Convert_Pairs {}
109111
, ShowDesignatorRange { true }
112+
, TabIndex { 1 }
110113
, UseWeeds { false }
111114
, UseWeeds_Amount { RulesClass::Instance->WeedCapacity }
112115
, UseWeeds_StorageTimer { false }

src/Ext/SWType/Hooks.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,67 @@ DEFINE_HOOK(0x6CC1E6, SuperClass_SetSWCharge_UseWeeds, 0x5)
182182

183183
return 0;
184184
}
185+
186+
#pragma region SW TabIndex
187+
DEFINE_HOOK(0x6A5F6E, SidebarClass_6A5F20_TabIndex, 0x8)
188+
{
189+
enum { ApplyTabIndex = 0x6A5FD3 };
190+
191+
GET(AbstractType const, absType, ESI);
192+
GET(int const, typeIdx, EAX);
193+
194+
R->EAX(SidebarClass::GetObjectTabIdx(absType, typeIdx, 0));
195+
return ApplyTabIndex;
196+
}
197+
198+
DEFINE_HOOK(0x6A614D, SidebarClass_6A6140_TabIndex, 0x5)
199+
{
200+
enum { ApplyTabIndex = 0x6A61B1 };
201+
202+
GET(AbstractType const, absType, EDI);
203+
GET(int const, typeIdx, EBP);
204+
205+
R->EAX(SidebarClass::GetObjectTabIdx(absType, typeIdx, 0));
206+
return ApplyTabIndex;
207+
}
208+
209+
DEFINE_HOOK(0x6A633D, SidebarClass_AddCameo_TabIndex, 0x5)
210+
{
211+
enum { ApplyTabIndex = 0x6A63B7 };
212+
213+
GET(AbstractType const, absType, ESI);
214+
GET(int const, typeIdx, EBP);
215+
216+
R->Stack(STACK_OFFSET(0x14, 0x4), SidebarClass::GetObjectTabIdx(absType, typeIdx, 0));
217+
return ApplyTabIndex;
218+
}
219+
220+
DEFINE_HOOK(0x6ABC9D, SidebarClass_GetObjectTabIndex_Super, 0x5)
221+
{
222+
enum { ApplyTabIndex = 0x6ABCA2 };
223+
224+
GET(int const, typeIdx, EDX);
225+
226+
if (typeIdx < 0 || typeIdx >= SuperWeaponTypeClass::Array->Count)
227+
return 0;
228+
229+
const auto pSWType = SuperWeaponTypeClass::Array->Items[typeIdx];
230+
const auto pSWTypExt = SWTypeExt::ExtMap.Find(pSWType);
231+
232+
R->EAX(pSWTypExt->TabIndex);
233+
return ApplyTabIndex;
234+
}
235+
236+
DEFINE_HOOK(0x6AC67A, SidebarClass_6AC5F0_TabIndex, 0x5)
237+
{
238+
enum { ApplyTabIndex = 0x6AC6D9 };
239+
240+
GET(AbstractType const, absType, EAX);
241+
GET(int const, typeIdx, ESI);
242+
243+
R->EAX(SidebarClass::GetObjectTabIdx(absType, typeIdx, 0));
244+
return ApplyTabIndex;
245+
}
246+
247+
DEFINE_JUMP(LJMP, 0x6A8D07, 0x6A8D17) // Skip tabIndex check
248+
#pragma endregion

0 commit comments

Comments
 (0)