OverridePromotionUIClass

Tracking Issue: #600

Tags: ui, events

Fires an event that allows mods to override the UI class used for a given promotion screen. Note that any class provided by a mod must be UIArmory_Promotion or a subclass of it.

OverridePromotionUIClass event

Param Value
EventID OverridePromotionUIClass
EventData XComLWTuple
EventSource XComHQPresentationLayer
NewGameState none

Tuple contents

Index Name Type Direction
0 PromotionScreenType enum (CHLPromotionScreenType) in
1 PromotionUIClass class (class<UIArmory_Promotion>) inout

Listener template

static function EventListenerReturn OnOverridePromotionUIClass(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
{
    local XComHQPresentationLayer Pres;
    local XComLWTuple Tuple;
    local CHLPromotionScreenType PromotionScreenType;
    local class<UIArmory_Promotion> PromotionUIClass;

    Pres = XComHQPresentationLayer(EventSource);
    Tuple = XComLWTuple(EventData);

    PromotionScreenType = CHLPromotionScreenType(Tuple.Data[0].i);
    PromotionUIClass = class<UIArmory_Promotion>(Tuple.Data[1].o);

    // Your code here

    Tuple.Data[1].o = PromotionUIClass;

    return ELR_NoInterrupt;
}

The following simplified example is taken from Community Promotion Screen:

local XComLWTuple Tuple;
local CHLPromotionScreenType ScreenType;

Tuple = XComLWTuple(EventData);

ScreenType = CHLPromotionScreenType(Tuple.Data[0].i);

if ((ScreenType == eCHLPST_PsiOp && ShouldOverridePsiPromotionScreen()) ||
        (ScreenType == eCHLPST_Hero && ShouldOverrideHeroPromotionScreen()) ||
        (ScreenType == eCHLPST_Standard && ShouldOverrideStandardPromotionScreen()))
{
    Tuple.Data[1].o = class'NPSBDP_UIArmory_PromotionHero';
}

return ELR_NoInterrupt;

The integer values of PromotionScreenType correspond to the CHLPromotionScreenType enum.

enum CHLPromotionScreenType
{
    eCHLPST_Standard,
    eCHLPST_Hero,
    eCHLPST_PsiOp
};

Source code references