Jump to content

Flags during LoadOut


Zyxpsilon

Recommended Posts

Trying to insert them using this script...

// qUIck_FLO == Displays Nationality Flags on Squad-Loadout screen
// NOTE == Original code created by TrackTwo for "UIUpgradeReminder"
// Author == Zyxpsilon.. with some precious help from InfectedM

class qUIck_FLO_UIListener extends UIScreenListener config(FLOConfig);

// Config variables for placement, size and (#2) Transparency
//
var const config int FLAGS_XLoc;
var const config int FLAGS_YLoc;
var const config float FLAGS_SCALE;
// var const config float FLAGS_ALPHA;

// Data Collector Arrays
var array<UIPanel> FlagIcons;
var array<UISquadSelect_ListItem> CachedListItems;

// UI has started up: refresh our Flags list
event OnInit(UIScreen Screen)
{
    local UISquadSelect SquadSelect;

    SquadSelect = UISquadSelect(Screen);
    if (SquadSelect != none)
        RefreshFlags(SquadSelect);
}
// Regained focus: refresh our Flags list
event OnReceiveFocus(UIScreen Screen)
{
    local UISquadSelect SquadSelect;

    SquadSelect = UISquadSelect(Screen);
    if (SquadSelect != none)
        RefreshFlags(SquadSelect);
}

function UIImage CreateFlagIcon(UISquadSelect_ListItem ListItem)
{
    local XComGameState_Unit Unit;
    local string FlagIconImg;
    local UIImage FlagIcon;

    // Look up the unit associated with this slot.
    Unit = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(ListItem.GetUnitRef().ObjectID));
    FlagIconImg  = (Unit.IsSoldier()) ? Unit.GetCountryTemplate().FlagImage : "";
    FlagIcon = ListItem.DynamicContainer.Spawn(class 'UIImage', ListItem.DynamicContainer).InitImage(, FlagIconImg);
    FlagIcon.SetPosition(FLAGS_XLoc, FLAGS_YLoc);
    FlagIcon.SetScale(FLAGS_SCALE);
    FlagIcon.Hide();
    return FlagIcon;
}

// Refresh the Flag state
function RefreshFlags(UISquadSelect SquadSelect)
{
local UISquadSelect_ListItem ListItem;
local int i;
local UIPanel Panel;
local array<UIPanel> ListItemPanels;

// Iterate the children of the squad select looking for the list items.
    SquadSelect.GetChildrenOfType(class'UISquadSelect_ListItem', ListItemPanels);
    foreach ListItemPanels(Panel)
    {
    ListItem = UISquadSelect_ListItem(Panel);

    // Have we already handled this list item?
        i = CachedListItems.Find(ListItem);
        if (i == -1)
        {
            // This one is new. Create new Flags and cache this item.
            FlagIcons.AddItem(CreateFlagIcon(ListItem));
            CachedListItems.AddItem(ListItem);
            i = CachedListItems.Length - 1;
        }

    FlagIcons[i].Show();
    }
}

defaultproperties
{
    // UISquadSelect is the name of the class we want to pay attention to, but it may be overridden by
    // another mod so we can't rely on it being there.
}

Compiled correctly, but the ingame problems are;

 

http://s33.postimg.org/5njzhur4f/FLO_First_Try_Flaw.png

 

1) They don't re-locate and re-scale as defined by the XComFLOConfig.ini file below;

[FLOConfig.qUIck_FLO_UIListener]

; Configuration settings for Flag-Images within each soldier "Info-boxes"

; X--Position (Larger values are further right on-screen)
FLAGS_XLoc=210

; Y--Position (Larger values are further down on-screen)
FLAGS_YLoc=216

; Size of the image on-screen. Scales the original (128x64) by the given factor.
; Current default of (0.75) equals to (96x48) pixels.
FLAGS_SCALE=0.75

2) When switching troopers, the initial (via AutoFill) flag remains and the new isn't updated.

 

Anyone has any ideas what's wrong with that code?

Edited by Zyxpsilon
Link to comment
Share on other sites

Okay -- i found how to fix #1 ... it's the config file naming convention that must match with the Mod "title" as written up for the build asset -- src \\ MOD \\ Classes;

 

class qUIck_FLO_UIListener extends UIScreenListener config(qUIck_FLO);

 

The file itself then has to be renamed XComqUIck_FLO.ini while being dropped into the Config folder.

And receive this as its first instruction too...

 

[qUIck_FLO.qUIck_FLO_UIListener]

 

Duh! :wink:

 

Sooooo.. if anyone still has some suggestion how to proceed with the refresh for new "Select/Soldier" steps.. please share your thoughts!

Edited by Zyxpsilon
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...