DynamicSoldierRankDisplay

Tracking Issue: #408

Tags: ui, events

Mods may want to manipulate the way a soldier's rank is displayed (in terms of icon/name/description) in more dynamic ways. For example, LWOTC shows officer ranks for units with special officer abilities. There are three events with mostly self-explanatory names:

SoldierRankName event

Param Value
EventID SoldierRankName
EventData XComLWTuple
EventSource XComGameState_Unit
NewGameState none

Tuple contents

Index Name Type Direction
0 Rank int in
1 DisplayRankName string inout

Listener template

static function EventListenerReturn OnSoldierRankName(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
{
    local XComGameState_Unit UnitState;
    local XComLWTuple Tuple;
    local int Rank;
    local string DisplayRankName;

    UnitState = XComGameState_Unit(EventSource);
    Tuple = XComLWTuple(EventData);

    Rank = Tuple.Data[0].i;
    DisplayRankName = Tuple.Data[1].s;

    // Your code here

    Tuple.Data[1].s = DisplayRankName;

    return ELR_NoInterrupt;
}

SoldierShortRankName event

Param Value
EventID SoldierShortRankName
EventData XComLWTuple
EventSource XComGameState_Unit
NewGameState none

Tuple contents

Index Name Type Direction
0 Rank int in
1 DisplayShortRankName string inout

Listener template

static function EventListenerReturn OnSoldierShortRankName(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
{
    local XComGameState_Unit UnitState;
    local XComLWTuple Tuple;
    local int Rank;
    local string DisplayShortRankName;

    UnitState = XComGameState_Unit(EventSource);
    Tuple = XComLWTuple(EventData);

    Rank = Tuple.Data[0].i;
    DisplayShortRankName = Tuple.Data[1].s;

    // Your code here

    Tuple.Data[1].s = DisplayShortRankName;

    return ELR_NoInterrupt;
}

SoldierRankIcon event

Param Value
EventID SoldierRankIcon
EventData XComLWTuple
EventSource XComGameState_Unit
NewGameState none

Tuple contents

Index Name Type Direction
0 Rank int in
1 IconImagePath string inout

Listener template

static function EventListenerReturn OnSoldierRankIcon(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
{
    local XComGameState_Unit UnitState;
    local XComLWTuple Tuple;
    local int Rank;
    local string IconImagePath;

    UnitState = XComGameState_Unit(EventSource);
    Tuple = XComLWTuple(EventData);

    Rank = Tuple.Data[0].i;
    IconImagePath = Tuple.Data[1].s;

    // Your code here

    Tuple.Data[1].s = IconImagePath;

    return ELR_NoInterrupt;
}

There is a sister feature DynamicSoldierClassDisplay that extends this to class icon/name.

Source code references