From 73a64e78157a821fd4718afd641fdc4b86251bee Mon Sep 17 00:00:00 2001 From: Fryone Date: Mon, 12 Feb 2024 00:44:35 +0300 Subject: [PATCH] Flashing Objects on selecting (#1201) * 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 --- CREDITS.md | 1 + docs/Fixed-or-Improved-Logics.md | 10 ++++++++++ docs/Whats-New.md | 1 + src/Ext/Rules/Body.cpp | 2 ++ src/Ext/Rules/Body.h | 2 ++ src/Ext/Techno/Hooks.cpp | 13 +++++++++++++ 6 files changed, 29 insertions(+) diff --git a/CREDITS.md b/CREDITS.md index 254ab589b4..587decd9cc 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -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 - **Ares developers** diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index 4907a7ac2a..e233049186 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -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 +``` diff --git a/docs/Whats-New.md b/docs/Whats-New.md index d7691b8e29..9207f3c8d7 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -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) diff --git a/src/Ext/Rules/Body.cpp b/src/Ext/Rules/Body.cpp index 0bf98af124..ad0ab12bdb 100644 --- a/src/Ext/Rules/Body.cpp +++ b/src/Ext/Rules/Body.cpp @@ -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"); @@ -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) diff --git a/src/Ext/Rules/Body.h b/src/Ext/Rules/Body.h index abe45e44cc..836493e355 100644 --- a/src/Ext/Rules/Body.h +++ b/src/Ext/Rules/Body.h @@ -104,6 +104,7 @@ class RulesExt Valueable ShowDesignatorRange; Valueable IsVoiceCreatedGlobal; + Valueable SelectionFlashDuration; ExtData(RulesClass* OwnerObject) : Extension(OwnerObject) , Storage_TiberiumIndex { -1 } @@ -163,6 +164,7 @@ class RulesExt , RadialIndicatorVisibility { AffectedHouse::Allies } , DrawTurretShadow { false } , IsVoiceCreatedGlobal { false } + , SelectionFlashDuration { 0 } , AnimRemapDefaultColorScheme { 0 } , TimerBlinkColorScheme { 5 } , Buildings_DefaultDigitalDisplayTypes {} diff --git a/src/Ext/Techno/Hooks.cpp b/src/Ext/Techno/Hooks.cpp index 74b842ac3f..a3c77019e8 100644 --- a/src/Ext/Techno/Hooks.cpp +++ b/src/Ext/Techno/Hooks.cpp @@ -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; +}