Long War Toolbox
Quvano Apr 30, 2016 @ 3:02pm
"Show Enemies on Mission Planning" compatibility with Toolbox
Hey guys

I am the author of "Show Enemies on Mission Planning". I've had requests to make it compatible but unfortunately my mod uses a screenlistner extension on UISquadSelect so that is really not possible. I think the best thing to do, if you are willing, is for you guys to just incorporate my mod into Toolbox's custom UISquadSelect extension class. The code is quite short. Here it is in its entirety (minus the cheat option which allows the info to be displayed without the Shadow Chamber being built):

If there is a way that I could make it compatibile that I am not aware of, please let me know and I'll take care of it on my end.



UPDATE: Mod is now compatible with Toolbox


class UIShowEnemies extends UIScreenListener config(UIShowEnemies);

//Currently, the title text supported only for English/INT = ENEMIES DETECTED
//The text for the enemies list is from function so it should be localized by existing XCOM code.
var public localized String m_strEnemiesDetected;

var UIText EnemiesList;
var UIText EnemiesDetectedTitle;

event OnInit(UIScreen Screen)
local XComGameState_MissionSite MissionState;
local XComGameState_HeadquartersXCom XComHQ;

XComHQ = class'UIUtilities_Strategy'.static.GetXComHQ();

if (XCOMHQ.GetFacilityByName('ShadowChamber') != none)

MissionState = XComGameState_MissionSite(`XCOMHISTORY.GetGameStateForObjectID(XComHQ.MissionRef.ObjectID));

EnemiesDetectedTitle = Screen.Spawn(class'UIText', Screen);
EnemiesDetectedTitle.SetText(class'UIUtilities_Text'.static.GetSizedText(class'UIUtilities_Text'.static.GetColoredText(m_strEnemiesDetected $ " " $ MissionState.m_strShadowCount, eUIState_Bad),25));

EnemiesList = Screen.Spawn(class'UIText', Screen);
EnemiesList.SetText(class'UIUtilities_Text'.static.GetColoredText(MissionState.m_strShadowCrew, eUIState_Normal));



event OnReceiveFocus(UIScreen Screen)

event OnLoseFocus(UIScreen Screen)

event OnRemoved(UIScreen Screen)

Last edited by Quvano; May 3, 2016 @ 6:41pm
< >
Showing 1-10 of 10 comments
BTernaryTau Apr 30, 2016 @ 3:43pm 
In the readme, it's mentioned that there are several hooks added into UISquadSelect, including one that triggers after squad select initialization. I haven't looked into this, but I think that should be enough for you to make Show Enemies on Mission Planning compatible.
Quvano Apr 30, 2016 @ 3:44pm 
@Celestus of Borg

Thanks, I'll take a look.
BTernaryTau Apr 30, 2016 @ 3:52pm 
@AlexF - No problem. Hope you work this out!
johnnylump Apr 30, 2016 @ 4:29pm 
@AlexF -- That's fine -- people are free to use any parts of our mods in their own that they wish.
Quvano Apr 30, 2016 @ 6:21pm 

I was actually talking about you guys incorporating my code, not the other way around.

However, I am attempting to make mine compatible with Toolbox by hooking into PostSquadSelectInit. How do I go about doing that? I'm trying to use XEVENTMGR.RegisterForEvent. Hopefully that is the correct way

Also, can I register for the event in the OnInit handler of the ScreenListner extension whose defualt properites sets ScreenClass=class'UISquadSelect'? Can I even use that technique given that Toolbox overrides the built in UISquadSelect class?

Aleternately, is the correct way to create a second class that extends UIScreenListerner without a ScreenClass assignment? And then it's in that class where the event listener is registered?

I just need help understanding how to hook into your event triggered in a class that overwrites a built in screen class.


Last edited by Quvano; Apr 30, 2016 @ 7:21pm
amineri May 1, 2016 @ 5:06am 
I've had to deal with this sort of mod interoperability myself, since we have several mods in the pipe that have to be compatible, yet also function independently.

One method is to set up your screen listener with a ScreenClass == none and then do filtering within OnInit, etc. The filter looks like if(UISquadSelect(Screen) != none). I've used this, and it will automatically detect UISquadSelect or any extension of it.

Another method is to use one of the new X2EventManager TriggerEvent methods that I've added in various places in Toolbox to improve interoperability. This method was used with the (updated) LeaderPack mod to make that compatible. LeaderPack had its own UIScreenListener on UISquadSelect for the leader-related UI bits, and I used the Triggered Events to implement the same functionality.

If you look through the LeaderPack code, inside the class UIStrategyScreenListener_LWOfficerPack is an example where I've set up 8 different RegisterForEvent methods to listen for events generated by Toolbox.

Note that LeaderPack was updated with these changes over a month ago, so a little while before Toolbox release! :). So that design functions fine with or without Toolbox. If Toolbox isn't present, the UISquadSelect listener kicks in and LeaderPack does its thing, and the RegisteredEvents never activate because they aren't triggered. If Toolbox IS present, then the UISquadSelect listener doesn't activate, but the functionality is handled through the Events.
Quvano May 1, 2016 @ 2:40pm 

Excellent. That is exactly what I needed.


Quvano May 1, 2016 @ 4:07pm 
Thank you, Show Enemies on Mission Planning is now compatible with Toolbox. I wound up using the first method as it was easiest and quickest but I am going to examine the RegisterForEvent method as I think that may be a better design in the long run.
Merchant2006 May 8, 2016 @ 4:07am 
Absolutely wonderful. Love the collaboration haha
Dasta Jul 2, 2016 @ 12:01am 
I'm reading this and it just makes me happy. I love seeing people work together.
< >
Showing 1-10 of 10 comments
Per page: 15 30 50