Unit Icons Added By Conditions
Ever wish you could add a small indicator on units that are improved when you research a tech? Or when some condition is met? Well I think this would be a cool addition especially for maps that use tech/conditions to alter unit options.
The idea would be to allow map makers to specify a properties file that references a condition, unit type, and image. If the condition is true then the specified image is layered onto the unit images for that type (similar to how unit flags work). You could have multiple images added to the same unit type and they would be layered in the order specified in the properties file.
Total_World_War__December_1941.Germany.germanBunker=german_flag.png (always true)
- Created property file (unit_icons.properties):
- Create unit icon image (map/unitIcons/air.png):
- TEST: Unit icon is applied to german naval fighters on game started
- TEST: Unit icon is applied to german fighters when Germany researches and activates Improved Fighters
Here's a conceptualization.
alkexr last edited by
Similar system could potentially be used for stack numbers. By layering premade images over the unit.
@redrum Not a clear user case myself, as I'm not sure how much I like tech, but I'm thinking it would be good having an additional reference for the unit owner. The basic concept of tech itself is to differentiate the same unit for different players (unlike TWW, that has mostly player specific units).
Also having the possibility of always having it (tho you could have it by having a condition that is always true), so you can simply use it for multi-layered images; like having flags (270BC...) or red dots (NWO...) not as part of the basic picture, even tho they would be always there, anyways.
alkexr last edited by
@redrum Oh wow, now that I think of it, this feature would solve what would have been a huge challenge implementing a feature for Fallen Empire. No need to hurry though, It's not going to be in the alpha version.
@redrum Also maybe being able to change the unit image totally, instead of just adding another on top of it. This is how the hardcoded techs work, like when you get JetFighter.
I definitely think the term "decoration" is not good here, as this is probably something you want to use not for mainly decorative aims.
How about icons instead of decorations? I don't really care that much about the name so whatever the consensus is.
Yeah, having an option for always TRUE for things like flags/dots/etc that you want to always have on certain unit images is probably useful to avoid needing filler conditions and that would probably be easy by having the option to specifying 'TRUE' or 'ALWAYS' instead of a condition name.
I guess having the player name as well would help for cases where you don't have player specific units and say want different icons on the same unit type for different players.
I did think a little about completely replacing unit images as well and kind of arguments for both sides. It adds another parameter and a bit of complexity. Are there good use cases or if you are completely replacing the image then should it really be a different unit? Starts to get to what really is a 'unit' as I find the JetFighter example feels strange on most maps as all my units suddenly look like an entirely different image (though might be because of the drastic difference in the unit image that most maps use instead of just adding some stripes or something which could be achieved with icons then).
- Created property file (map/unit_icons.properties)
- Create unit icon image (map/unitIcons/air.png)
- TEST: Unit icon is applied to german naval fighters on game started
- TEST: Unit icon is applied to german fighters when Germany researches Improved Fighters
@redrum So where do these go?
Is there a complete example of this somewhere?
@hepps In the bolded paths above. Essentially just need to do 2 things:
- Add unit_icons.properties file to your map directory with at least 1 valid line
- Add unitIcons folder and an image inside to your map directory
I'll add an example to POS2 repo once the PR merges.
Is there a changelog for pos2 xml?
Essentially those should mostly line up with either things that were identified as missing from POS2 XML or things completed from the features list: https://forums.triplea-game.org/topic/182/guidelines-and-feature-request-list
@redrum I like the idea in general. But I wonder if it can be, even more constructive with abilities similar to those of the hard coded techs, which swap images completely.
@general_zod Overriding (or swapping) the unit images would be possible to add into this feature as well (@Cernel mentioned that too). I couldn't think of a lot of good use cases though. The hard coded techs is one use case though IMO not really a good one as seeing bombers magically change into like stealth bombers with bomber range is researched seems weird and they should probably just have some icon added to them. Can you think of some good examples?
Very excited about this! For TWW this will immediately solve the problem of great games ending horribly due to a player not remembering an enemy has a technology that can dramatically affect battles. And all without having to make 400 extra units and unit images!
Here is some light TWW porn....
I couldn't be happier with this development! GREAT WORK (as always) Red! You are truly a God amongst men.
@hepps Looks cool. Out of curiosity, any reason for not putting them all in the bottom right or top left?
You also might want to tone down the lime green just a tad.
@redrum I'll give it some more thought and get back to ya.
@redrum What you got against lime green anyway? That's like the third time you've dissed the lime green!
I was trying to avoid covering distinguishing parts of certain unit images. Very preliminary work done within 1/2 an hour of seeing this new feature come to fruition. Just take a pill... or a Bourbon... or both. Revisions will come when I sit down with my partner to finalize the designs.
@hepps Lol. It hurts my eyes! Definitely could use a pill and a Bourbon right now but have a few more hours of work to survive first. TGIF!
So you are going for adding a folder for these images. This makes me think it'd rule out the switch alternative to support, as it would be weird to have the new image outside the "units" folder, and it would not make sense to be defined as an icon for the starting image, anyway.
I'm unconvinced about this, especially on the account that of the few hard-coded techs, changing unit images, we have, few of them work in the way of adding any icons (I think the only case are heavy bombers, AA radar and rockets), but in the way of changing the image itself, either totally (improved factories etc.) or by adding a couple white stripes or such (super submarines etc.).
Of course, one could hack an image changing by just having the basic image totally transparent, and adding the icons on top of it as the actual images, making sure you start with an icon and the condition of the first one becomes false when the new one is true.
I don't have any particular examples in mind, as, as I said, I'm not huge on tech (both as a maker and as a user) and I'm not sure how can you get examples, in the moment, so far, anything like this has been limited only to a part of the few hard-coded techs available. I don't even know if and how I would be using this feature. But, in general, having the possibility of changing the image completely should feel of superior quality. All your fighters becoming jets, when you get the tech, is obviously silly, but you can have more sensible examples, like warriors turning into werewolves, Gandalf turning from grey to white, cavemen turning into spearmen, a battleship getting a radiotelemetre, or a factory looking more modern, rather than having an icon beside that tells you now it is more modern (kinda cheap). Beside, if this is not supported, I can see mapmakers hacking it by just assuring that the new image completely covers the old one (or by even more devious means...). The long range fighters, on the other hand, receiving a couple of white stripes is not making a lot more sense: just paint some stripes on the wings, they'll fly better. Not like that having the image not changing completely helps making more sense, I tend to think.
Anyway, probably the strongest argument is that icons telling what is what are likely suboptimal with respect to an integrated approach, as you, then, need to watch several images to know about one unit. From my point of view, even only adding two stripes to a fighter is more user friendly than adding an icon beside to tell that is an advanced version of the former. Like, I would not advice to substitute all Adv.Fighter in WAW with regular fighters images with an "A" symbol or something beside, no matter how much the current stripes solution is cheap, anyway.
It is basically the same reason why (as long as you have 12 or less players) it is better having units ownership depending on colours, than adding a flag or any symbol beside, to tell the ownership.
On the name, it depends on what this is going to be.
If it is going to be just an overlay thing, like decoration would imply, i don't think "Icon" is good, either, as it makes me rather think of something stand-alone (like it would be fitting if you want to add a small side-image highlighting some stuff regarding the unit, but here we could also use this thing to add white stripes for long range or whatever, and that would definitely be not an icon). In such a case, I'd call it "Unit Indicators", if that would sound fine to the average English speaker (or signage or such).
However, icon would be good enough as a title of this thread if you go for an integrated approach using the current basic "units" folder, without adding another folder specifically for this feature (and, in this case, the only name we need to add is only how to call the properties file, that would be the only addition).
So, my suggestion is not adding any "unitIcons", or whatever, new folder, but doing everything inside the current "units" folder. For the iconic part of it, the icons of general use would stay directly inside the "units" folder (where currently nothing is referenced, anyways), while player specific icons would go inside the players subfolders, with the unit images they are for.
So, instead of making some overlay thing on top of the current units stuff, I would rather go for expanding what is supported via the "units" folder itself only, by allowing defining multiple layers for images, that would also cover all what at this feature request (and more).
First of all, before getting to the conditions part, expanding the functionality of the current "units" folder system, by allowing having images directly in it, instead of in the players subfolders.
When a unit image is called, the engine will search for it in the player subfolders (just like now) and, if not finding it in it, it will, then, search for it directly in the general "units" folder (and, then, go searching in the program assets, of course, the same way).
All images for this feature would stay in the current "units" folder, as well (so not adding another folder for these things), and the property sheet being called "unit_display.properties".
Inside such file, you would have entries like:
The "info_name" being the info name for the game, that defines what xml we are using (that is what game we are referring to).
The "unit_name" being the name of the unit inside that xml.
The "player_name" being the name of a player inside that xml.
The "conditionAttachment" being a condition defined inside that xml.
The "image_name" being the name of the image file.
Assuming everything else is self explanatory, the way "conditionAttachment" works is that it is a check that is true if the condition is true.
The first two entries are mandatory.
The third and fourth entries are optional, and both (the "player_name" and the "conditionAttachment") are always true, if absent.
So, you can also have:
And this would always apply, to that player only.
And you can also have:
And this would apply to all players, if the condition is true.
Or you can just have:
This always applying to all players.
I guess all the above would be feasible by the engine checking how many entries and, in case of three, if the third one starts exactly as "conditionAttachment" or not.
For using this feature as a simple overlay (merely as an alternative to having it directly in the image itself, as per the only current practice), in a map like Napoleonic Empires, in which the ships are the same for everyone, but with different flags, you can have the ships images directly in the "units" folder, plus a single "flag" image per each player subfolder.
Then, in the "unit_display.properties" you would have:
So, everyone will get the same "Cutter" image, while the players will get different "flag" image, but this is not to be specified in the properties, as it just depend on the positions in the units folder, as said.
Of course, switched over, if, instead, you want the Cutter to be superimposed to the flag.
If and only if the unit_display.properties is absent or no entries are present or no entries are valid (for that player or at all), then the default image is used.
If any entries in unit_display.properties are valid, then the default is not used at all (so, nothing is superimposed to the default: to superimpose you need to specify what would be the default in the properties, as an always true entry).
If you want entries in properties to not superimpose, you just need to assure that the condition of the first entry becomes always false when the condition of the second entry is true, in the xml (you need to code the condition accordingly). I believe this would mean that TWW would superimpose after the first, if I'm assuming correctly that when you get a new level of the same kind of tech, the preceding one remains true.
For example, inside the property sheet, you can have only an entry like this, if you want the unit to be completely changed:
In this case, normally, the unit displayed is the default one (like not having an entry, when the entry is not valid). When the condition is true, instead, the "fighter_improved" is displayed, in substitution.
On the other hand, if you want to just have a overlay, you would have an entry like this:
In this case, the "gold_star" image would be just superimpose to the always true "fighter" image.
In both the above cases the "player_name" is absent, thus this will apply to any "germanFighter" units in the map, regardless of ownership.
On the other hand, I tend to think that one should not code the xml thinking about skin elements, so it would be rather better having:
When conditionType can be AND, OR, etc. (what's supported for triggers).
So, to be clear, what I'm saying is that you don't really need to make a way to define if stuff superimpose or replace, but you can have that it just always superimposes, and assure the lower levers to disappear (not being drawn anymore), when wanted, by conditions.
Moreover, it would be good also the "player_name" allowing for multiple (but you can just repeat the entry as many times as you need to; so I'm not sure about this).
p.s.: A remaining matter to define, then, would be if this feature should be switchable by the user and which way. This really needs to be sorted out, as well, since, for example, you should never be able to switch off the flags of the ships of Napoleonic Empires, as that is the only way to differentiate them by ownership. So, if I would make something like that, and this feature would be optional, I would still have the flags in the image themselves, to avoid them being ever not displayed. Probably, to keep it simple, just having a single entry in properties that define if everything or nothing can be turned off, by the user (when turned off, it would be like the map having no unit_display.properties).