XCOM 2
Long War Toolbox
"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.

Thanks,

Alex

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));
MissionState.GetShadowChamberStrings();

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

EnemiesList = Screen.Spawn(class'UIText', Screen);
EnemiesList.InitText('EnemiesList');
EnemiesList.AnchorTopLeft();
EnemiesList.SetText(class'UIUtilities_Text'.static.GetColoredText(MissionState.m_strShadowCrew, eUIState_Normal));
EnemiesList.SetY(330);
EnemiesList.SetX(35);
EnemiesList.SetWidth(320);

EnemiesDetectedTitle.Show();
EnemiesList.Show();

}
}

event OnReceiveFocus(UIScreen Screen)
{
EnemiesList.Show();
EnemiesDetectedTitle.Show();
}

event OnLoseFocus(UIScreen Screen)
{
EnemiesList.Hide();
EnemiesDetectedTitle.Hide();
}

event OnRemoved(UIScreen Screen)
{
EnemiesList.Remove();
EnemiesDetectedTitle.Remove();
}

defaultproperties
{
ScreenClass=class'UISquadSelect'
}
Editat ultima dată de Quvano; 3 mai 2016 la 18:41
< >
Se afișează 1-10 din 10 comentarii
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 30 apr. 2016 la 15:44 
@Celestus of Borg

Thanks, I'll take a look.
@AlexF - No problem. Hope you work this out!
@AlexF -- That's fine -- people are free to use any parts of our mods in their own that they wish.
Quvano 30 apr. 2016 la 18:21 
@Johnnylump

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.

Thanks.

Alex
Editat ultima dată de Quvano; 30 apr. 2016 la 19:21
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.
@amineri

Excellent. That is exactly what I needed.

Thanks,

Alex
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.
Absolutely wonderful. Love the collaboration haha
Dasta 2 iul. 2016 la 0:01 
I'm reading this and it just makes me happy. I love seeing people work together.
< >
Se afișează 1-10 din 10 comentarii
Per pagină: 1530 50