Skip to content

Commit

Permalink
Flashing Objects on selecting (Phobos-developers#1201)
Browse files Browse the repository at this point in the history
* initial commit

[AudioVisual]
SelectFlashTimer= ;int frames

* Update Hooks.cpp

* Update Body.h

* Documentation update

* Fix styling and account for negative values

* Renamed parameter

---------

Co-authored-by: Kerbiter <[email protected]>
  • Loading branch information
Fryone and Metadorius authored Feb 11, 2024
1 parent 193223e commit 73a64e7
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ This page lists all the individual contributions to the project by their author.
- Customizable ElectricBolt Arcs
- Sound entry on unit's creation
- Auto-deploy/Deploy block on ammo change
- Flashing Technos on selecting
- **ZivDero**
- Allow giving ownership of buildings to players in Skirmish and MP using <Player @ A-H>
- **Ares developers**
Expand Down
10 changes: 10 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1000,3 +1000,13 @@ In `rulesmd.ini`:
[CrateRules]
CrateOnlyOnLand=no ; boolean
```

## 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.

In `rulesmd.ini`:
```ini
[AudioVisual]
SelectionFlashDuration=0 ; integer, number of frames
```
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ New:
- Allow setting default singleplayer map loading screen and briefing offsets (by Starkku)
- Allow toggling whether or not fire particle systems adjust target coordinates when firer rotates (by Starkku)
- `AmbientDamage` warhead & main target ignore customization (by Starkku)
- Flashing Technos on selecting (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
2 changes: 2 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,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->SelectionFlashDuration.Read(exINI, GameStrings::AudioVisual, "SelectionFlashDuration");

this->Buildings_DefaultDigitalDisplayTypes.Read(exINI, GameStrings::AudioVisual, "Buildings.DefaultDigitalDisplayTypes");
this->Infantry_DefaultDigitalDisplayTypes.Read(exINI, GameStrings::AudioVisual, "Infantry.DefaultDigitalDisplayTypes");
Expand Down Expand Up @@ -262,6 +263,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->RadialIndicatorVisibility)
.Process(this->DrawTurretShadow)
.Process(this->IsVoiceCreatedGlobal)
.Process(this->SelectionFlashDuration)
.Process(this->AnimRemapDefaultColorScheme)
.Process(this->TimerBlinkColorScheme)
.Process(this->Buildings_DefaultDigitalDisplayTypes)
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 @@ -104,6 +104,7 @@ class RulesExt

Valueable<bool> ShowDesignatorRange;
Valueable<bool> IsVoiceCreatedGlobal;
Valueable<int> SelectionFlashDuration;

ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
, Storage_TiberiumIndex { -1 }
Expand Down Expand Up @@ -163,6 +164,7 @@ class RulesExt
, RadialIndicatorVisibility { AffectedHouse::Allies }
, DrawTurretShadow { false }
, IsVoiceCreatedGlobal { false }
, SelectionFlashDuration { 0 }
, AnimRemapDefaultColorScheme { 0 }
, TimerBlinkColorScheme { 5 }
, Buildings_DefaultDigitalDisplayTypes {}
Expand Down
13 changes: 13 additions & 0 deletions src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,16 @@ DEFINE_HOOK(0x51BAFB, InfantryClass_ChronoSparkleDelay, 0x5)
R->ECX(RulesExt::Global()->ChronoSparkleDisplayDelay);
return 0x51BB00;
}

DEFINE_HOOK_AGAIN(0x5F4718, ObjectClass_Select, 0x7)
DEFINE_HOOK(0x5F46AE, ObjectClass_Select, 0x7)
{
GET(ObjectClass*, pThis, ESI);

pThis->IsSelected = true;

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

return 0;
}

0 comments on commit 73a64e7

Please sign in to comment.