TheRealSFlo Posted February 28, 2016 Share Posted February 28, 2016 I'm working on a LW-styled fatigue system and I'd like to add UI elements to the soldier roster and loadout screens. However, I'm having some trouble understanding how to add said elements to the existing UI properly and how reference the soldier objects being listed in the interface without overriding any of the game's existing classes. Any help is highly appreciated! Link to comment Share on other sites More sharing options...
davidlallen Posted February 28, 2016 Share Posted February 28, 2016 It isn't always possible to avoid extending game classes. You can override only certain functions within the class, and it does open the possibility of other mods (or game updates) breaking your mod. It is also painful that sometimes classes have private variables, which means you cannot partially extend the class. Have you picked apart some of the other mods which add, or replace elements in nearby screens? For example, Expanded Perk Tree replaces the perk tree in the armory soldier view. Uniform Manager adds some buttons in related screens. There are probably others. Link to comment Share on other sites More sharing options...
Amineri Posted February 28, 2016 Share Posted February 28, 2016 Unfortunately, adding elements to each element in a list isn't always possible without actually replacing the class. Just look at some of the ugly hacks I had to use in order to get the Leaderpack stuff working ... :( ScreenListeners can only listen to UIScreen classes, not to UIPanel classes (which makes sense, I suppose, so a UIPanel could be a single button or a BGPanel...). In general you can access the UIList from the UIScreen that owns it, then loop over the UIList elements and add new UI elements to them. The problem typically comes in when things are refreshed. Firaxis has a habit of re-organizing/refreshing a list by deleting the list and then recreating it, and oft-times this can occur without an OnReceiveFocus call to the UIScreen, which means there's no signal to the UIScreenListener to be able to update your per-listitem elements. I ran into this problem with the UISquadSelect_ListItem for the Leaderpack (officer) mod, and basically had to replace those classes -- although my solution was less elegant because I wrote that code before class replacement was a "thing". I had to use a ScreenListener on the UISquadSelect and then remove and replace all of the ListItems with my own extension class. I think this was in part what contributed to the development of the class replacement concept, which isn't perfect, but is generally an improvement over some alternatives. The ideal case, of course, would be to have TriggerEvent calls in the UI code at appropriate places in the code that mods could hook into in order to add elements. Link to comment Share on other sites More sharing options...
Zyxpsilon Posted February 28, 2016 Share Posted February 28, 2016 ...The ideal case, of course, would be to have TriggerEvent calls in the UI code at appropriate places in the code that mods could hook into in order to add elements.Sure, yet another drop into the ocean of an already stormy weather system that could generate a wild Tsunami of smiles by Modders looking for slightly better & versatile SDK tools.Willing to do the leg work, since you already have proper "Connections" with insider freakish (as a joke, guys -- as a bad joke) devs? Link to comment Share on other sites More sharing options...
Recommended Posts