Skip to content

Commit 7de29c0

Browse files
StyriumBlackDog86
authored andcommitted
Issue #1509 - Add OverrideEffectIconColor event
1 parent 69617b4 commit 7de29c0

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

X2WOTCCommunityHighlander/Src/XComGame/Classes/UITacticalHUD_Perk.uc

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,75 @@ simulated function UpdateData(const out UISummary_UnitEffect Summary)
4949

5050
case 'eAbilitySource_Item':
5151
case 'eAbilitySource_Standard':
52+
// Start Issue #1509
53+
//
54+
// Adds an event that allows listeners to override the icon color
55+
// To achieve this, the default case has been decoupled from the 'eAbilitySource_Item' and 'eAbilitySource_Standard' cases.
56+
Icon.SetBGColorState(eUIState_Normal);
57+
5258
default:
59+
TriggerOverrideEffectIconColor(Summary);
60+
// End Issue #1509
61+
}
62+
}
63+
64+
// Start Issue #1509
65+
/// HL-Docs: feature:OverrideEffectIconColor; issue:1509; tags:tactical
66+
/// The `OverrideEffectIconColor` event allows mods to override the background and foreground
67+
/// colors of icons from `X2Effect_Persistent` set as `ePerkBuff_Passive`.
68+
/// The "background" color is the color of the icon itself, and normally varies depending on
69+
/// the `AbilitySourceName` property set on the `X2Effect_Persistent`
70+
/// The "foreground" color is normally always black.
71+
/// Default colors used by the game can be found in the `UIUtilities_Colors` class.
72+
///
73+
/// Listeners should use the Effect's `AbilitySourceName` provided in the `EventData` as a filter
74+
/// to ensure maximum compatibility.
75+
///
76+
/// Performance note: this event gets triggered *a lot*,
77+
/// so try to avoid complex computations in listeners to reduce the performance hit.
78+
///
79+
/// ```event
80+
/// EventID: OverrideEffectIconColor,
81+
/// EventData: [in name AbilitySourceName, out string BackgroundColor, out string ForegroundColor],
82+
/// EventSource: none,
83+
/// NewGameState: none
84+
/// ```
85+
simulated function TriggerOverrideEffectIconColor(UISummary_UnitEffect Summary)
86+
{
87+
local XComLWTuple Tuple;
88+
local X2EventManager EventMGR;
89+
90+
Tuple = new class'XComLWTuple';
91+
Tuple.Data.Add(3);
92+
93+
Tuple.Id = 'OverrideEffectIconColorTest';
94+
Tuple.Data[0].kind = XComLWTVName;
95+
Tuple.Data[0].n = Summary.AbilitySourceName;
96+
Tuple.Data[1].kind = XComLWTVString;
97+
Tuple.Data[1].s = "";
98+
Tuple.Data[2].kind = XComLWTVString;
99+
Tuple.Data[2].s = "";
100+
101+
EventMGR = `XEVENTMGR;
102+
EventMGR.TriggerEvent('OverrideEffectIconColor', Tuple);
103+
104+
if (Tuple.Data[1].s != "")
105+
{
106+
Icon.SetBGColor(Tuple.Data[1].s);
107+
}
108+
else
109+
{
110+
// no color code was provided, set the original "default" eUIState
53111
Icon.SetBGColorState(eUIState_Normal);
54112
}
113+
114+
// only set the ForegroundColor if a custom one was provided by the event
115+
if (Tuple.Data[2].s != "")
116+
{
117+
Icon.SetForegroundColor(Tuple.Data[2].s);
118+
}
55119
}
120+
// End Issue #1509
56121

57122
simulated function OnMouseEvent(int cmd, array<string> args)
58123
{

0 commit comments

Comments
 (0)