XCOM 2
33 ratings
Add custom prop icons like the DLC
By Katoffel
Shows you how to add icons to your added props like the official DLC.
   
Award
Favorite
Favorited
Unfavorite
Intro
Since i got almost as much props in my mod as Fireaxis in there nice first DLC i also wanted a custom icon before my props.
Thats pretty much how this came together.
Adding a UIScreenListener
First you need to create the UIScreenListener that edits the lines in the prop list to show the icon.
Create a new UnrealScript (like in the image shown).


And fill the code from below in.
This is straight up copied (including there copyright. dont know if thats allowed, let me know if i break some rules by doing this) from the class Freaxis maid in there DLC with some edits ofc.

Edits:
  • I commented out the OnRemoved funtion. I know this isnt optimal but if u let it in the icons only show the first time u go into an menu, but dont on the following times (if someone knows something about that pls let me know).
  • Change
    if( BodyPart.DLCName == 'KatoffelTooFancy' )
    to a unique name. You can probably use this across mods (havent tested this tho).
  • Change
    "img:///UILibrary_Katoffel.Katoffel_icon"
    to ur name (ill show that in the next step)

// ********* FIRAXIS SOURCE CODE ****************** // FILE: UIScreenListener_UICustomize // AUTHOR: Brit Steiner // // PURPOSE: Adding DLC icons to the item lists. // //--------------------------------------------------------------------------------------- // Copyright (c) 2009-2016 Firaxis Games, Inc. All rights reserved. //--------------------------------------------------------------------------------------- class UIScreenListener_UICustomize extends UIScreenListener; // This event is triggered after a screen is initialized event OnInit(UIScreen Screen) { local UICustomize CustomizeScreen; CustomizeScreen = UICustomize(Screen); if( CustomizeScreen != none ) { if( CustomizeScreen.CustomizeManager != None ) { CustomizeScreen.CustomizeManager.SubscribeToGetIconsForBodyPart(GetIconsForBodyPart); } } } // This event is triggered when a screen is removed event OnRemoved(UIScreen Screen) { local UICustomize CustomizeScreen; CustomizeScreen = UICustomize(Screen); if( CustomizeScreen != none ) { if( CustomizeScreen.CustomizeManager != None ) { CustomizeScreen.CustomizeManager.UnsubscribeToGetIconsForBodyPart(GetIconsForBodyPart); } } } function string GetIconsForBodyPart(X2BodyPartTemplate BodyPart) { if( BodyPart.DLCName == 'KatoffelTooFancy' ) { return class'UIUtilities_Text'.static.InjectImage("img:///UILibrary_Katoffel.Katoffel_icon", 26, 26, -4) $ " "; } return ""; }
Thanks to robojumper for updating the code and posting it here, so it doesn't spam the logs.
Create the UPK
Nextup you need to pack your icon image in a UPK.
Mine is 32*32 pixel big, dont now if thats optimal or not.
Cause this guide is only helpful if you made a prop mod you probably know how to do that.
The name used in the first step is "img:///<yourpackage>.<youriconname>" as you would think.
Mine is called "UILibrary_Katoffel". I read something in a nexus post about "UILibrary_" is a needed prefix, but that could be a missunderstanding. I didnt try another name for that reason but it doesn't hurt to name it that way anyway i think.
Change the XComContent.ini entries
Ur XComContent.ini probaby looks something like this :

[XComGame.X2BodyPartTemplateManager] ;FancyTopHat +BodyPartTemplateConfig=(PartType="Helmets", TemplateName="Hat_FancyTopHat_M", ArchetypeName="Hat_FancyTopHat.ARC_Hat_FancyTopHat_M", Gender=eGender_Male, bCanUseOnCivilian=true, bVeteran=false) +BodyPartTemplateConfig=(PartType="Helmets",TemplateName="Hat_FancyTopHat_F", ArchetypeName="Hat_FancyTopHat.ARC_Hat_FancyTopHat_F", Gender=eGender_Female, bCanUseOnCivilian=true, bVeteran=false); ...

just add
DLCName="<the name u defined in the UISL in the first step>"
to every "+BodyPartTemplateConfig="

This is how it should look afterwards :
+BodyPartTemplateConfig=(PartType="Helmets", DLCName="KatoffelTooFancy", TemplateName="Hat_FancyTopHat_M", ArchetypeName="Hat_FancyTopHat.ARC_Hat_FancyTopHat_M", Gender=eGender_Male, bCanUseOnCivilian=true, bVeteran=false) +BodyPartTemplateConfig=(PartType="Helmets", DLCName="KatoffelTooFancy", TemplateName="Hat_FancyTopHat_F", ArchetypeName="Hat_FancyTopHat.ARC_Hat_FancyTopHat_F", Gender=eGender_Female, bCanUseOnCivilian=true, bVeteran=false);

Done :)
If you find typos, bug or fixes pls let me know so i can change this guide. I just found out how to do this so it works, but i cant guarantee its the best way to do this :)

Kat.
27 Comments
Katoffel  [author] Jul 1, 2016 @ 4:31am 
Yea was pretty busy that last few months. Thanks for posting, will update the guide...
krj12 (Ken) Jun 26, 2016 @ 4:21am 
@robojumper
Maybe you can highlite the parts that have changed? I dont see it.
I'm assuming the log file issue only happens in debug mode - I thought logging was turned
off in regular play mode.
robojumper Jun 26, 2016 @ 2:48am 
PSA: This code has a problem: It spams the log file! Katoffel has gone dark for a month now, and I hope people see this! http://pastebin.com/jqaarxvi is the fixed one. You still need to replace the img:/// thing of course.
Katoffel  [author] Mar 25, 2016 @ 11:58pm 
Good to know it's working now :)
krj12 (Ken) Mar 25, 2016 @ 8:02pm 
Finally got it to work after much trial and error.
A few notes:
1. It is not necessary to place the icon in a separate upk, it works fine in your main upk.
2. In addition to the above setup, you need XcomEditor.ini and XcomEngine.ini, which you may
not have if you didnt use the default project selection when creating your project.
3. Do not put spaces in any of your directory names, that's one thing that was throwing me for a loop.
∑3245 Mar 25, 2016 @ 4:15pm 
@krj12
Huh, I though it was my Modbuddy installation that was acting up whenever I use any *.uc scripts. This script might need a rewrite.
Katoffel  [author] Mar 25, 2016 @ 2:05pm 
create a new mod with "default mod" as a base and copy all the inis to ur new mod (change the names inside the inis to the name of ur old mod ofc)
the folder structure (were the uc is in) u can see on one image in the guide
krj12 (Ken) Mar 25, 2016 @ 1:47pm 
Getting a build failed as soon as I add the .uc file, is there some convention to the directory structure?
krj12 (Ken) Mar 25, 2016 @ 1:26pm 
I dont have those INIs in my project, only XcomContent.ini.
Katoffel  [author] Mar 25, 2016 @ 1:21pm 
have you deleted the standart inis that get created (XComEngine.ini + XComGame + XComEditor) ? dont know what they do but that could be it...
the "extends UIScreenListener;" makes it so the script gets executed, u dont have to "register" it anywere, the engine just runs it.