Jump to content

Squad Select UIScreenListener - Cannot find hook for when a unit is removed


TheRealSFlo

Recommended Posts

I'm using a UIScreenListener to draw additional data to the Squad Select screen from 'UISquadSelect.uc' and I can't seem to find an event that takes place whenever a unit is removed from the squad that I can hook into.

 

OnInit(), OnReceiveFocus(), & OnLoseFocus() all serve most of my needs, but when a unit is removed from the current squad the additional data I drew to the screen lingers since I cannot call the event that checks for and wipes the unneeded visuals until the screen loses focus again. I couldn't find a function in 'UISquadSelect.uc' to really hook into when I looked through it.

 

Anyone know what event I'm missing?

Link to comment
Share on other sites

Nope, this was a problem I ran into with OfficerPack as well, which is why I had to resort to the more extreme measures of class replacement. Note that I didn't use the built-in new/spawn driven class replacement as set up in Engine.ini (since that wasn't available when I wrote the code), but instead replaced the SquadSelect_ListItem from within a UISquadSelect ScreenListener. Overall it's a fairly hack-ey solution, and I can't recommend it, and I can't really recommend it. Especially since the mod would be incompatible with OfficerPack.

Link to comment
Share on other sites

Well, I think the easiest way would just be to show you an example. In my mod I needed a way to update data every time a new soldier was 'focused' during tactical play. So I used this in a UITacticalHUD ScreenListener:

`BATTLE.WorldInfo.MyWatchVariableMgr.RegisterWatchVariable( XComTacticalController(`PRES.Owner), 'm_kActiveUnit', self, updateStats);

This is (to my understanding) saying that whenever the m_kActiveUnit variable located in the `Pres.Owner instance of XComTacticalController is directly changed (like, assigned via an = operator), call the updateStats function located in the 'self' object.

 

You may be able to do something similar to achieve the same results if you can find a variable that can be watched and changes at the correct times. If you are curious, my Lifetime Stats mod does this in the LifetimeStats_ScreenListener.uc class (which is more updated on the Workshop than on the nexus).

Link to comment
Share on other sites

  • Recently Browsing   0 members

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