Can I make a request to have the generation of the d-mod and s-mod bars on ship icon (see below) abstracted and made accessible to the modding API?
I mean these:
In Fleet screen: (here the bars even have tooltips)
In Refit screen:
The bars are also visible on ships icons in the encounter dialogs, and in fleet tooltips in campaign, no idea if elsewhere.
What I request is some way for a mod to decide how many and what color of bars it wants display on a ship icon, to possibly add extra types for some special hullmods in addition to the default green and red ones.
Right now they are hardcoded in the obfuscated part of the code (sorry to dig there, I wanted to check how hardcoded or moddable it is).
The hardcoded logic gets the number of d-mods and displays correct number of red bars with corresponsing tooltips, and then gets the number of built-in mods and displays green bars with corresponding tooltip, which is exactly what we see. What I request is to have this logic to be abstracted and fully or partially overridable by custom implementation.
Simple way - allow full replacement of default bars:
- overridable method
getShipIconHullModBars() -> returns list of objects, each object representing one group of colored bars, with fields like this:
class HullModBarsGroup {
Color barColor;
int numberOfBars;
String tooltipText;
}
More advanced way (not exclusive with simple way) - allow adding of new bars at specified place, without removing exisitng ones (would provide better compatibility between mods that all want to add their own special groups):
- overridable method
getShipIconExtraHullModBars() -> returns list of objects, each object representing one group of colored bars, and its ordering, with fields like this:
class HullModBarsGroup {
float order;
Color barColor;
int numberOfBars;
String tooltipText;
}
The default implementation of
getShipIconHullModBars() to match the current logic would look like this:
public List<HullModBarsGroup> getShipIconHullModBars(ShipVariantAPI shipVariantAPI) {
HullModBarsGroup dmodBars = new HullModBarsGroup(
Color.red,
DModManager.getNumDMods(shipVariantAPI),
"Number of d-mods this ship has."
);
HullModBarsGroup storyModBars = new HullModBarsGroup(
Misc.getStoryOptionColor(),
Misc.getCurrSpecialMods(shipVariantAPI),
"Number of built in mods this ship has. Only counts mods custom built in after the ship was produced."
);
return Arrays.asList(dmodBars, storyModBars); // assuming they are added right-to-left, which seems to be the case
}