Add Unit Count and Damage Display Outline


  • Donators Moderators Admin

    0_1530795534385_Implemented.png

    This has come up many times over the years and is likely a pie in the sky idea. Not really sure whether something like this would even be possible... but it would certainly be a huge step forward from a UI standpoint.

    0_1530198736852_Dream a little dream.png

    Just putting it out here for posterity. 🙂


    After the changes:
    0_1530236800772_c0f59700-91ab-4c77-933d-c3318ce98f0b-image.png

    0_1530236811343_05c6ed96-7591-4789-88ce-11d8fe8372be-image.png

    PR: https://github.com/triplea-game/triplea/pull/3488


  • Donators Moderators Admin

    If I remember any of the conversations clearly, I don't think anything like this could be achieved with the resources available through Java... but I was wondering if it could be achieved in the same way we have done the "Flag Display Mode" or many of the other graphical processes for rendering images?

    If the game had a separate folder for "Stack Numbers"... and the Map Properties file had a line that defined whether the game used "Stack Numbers"... something like this...

    units.counter.offset.width=0
    units.counter.offset.height=52
    units.counter.stacknumbers=true

    Then we could build a folder for the game assets that had a set of numbers designed along the lines of the above example. Additionally this would then allow a map maker to build a custom set (if anyone other than me had the audacity to do so) and place that in their own map folder.

    If the map properties folder did not have the setting to true then it would default to the current method. Or if numbers were missing from the "UnitStack" folder then it would default to the current method.

    If this were a viable way to achieve this... I would be more than happy to volunteer to make numbers from 2- 1000 for the game engine assets. (Not that I think 1000 is really necessary... realistically I think more like 2-300 would suffice)


  • Donators Moderators Admin

    @hepps I just designed one number. Saved as a jpeg it is 1.35KB. So if I did separate images for 2-300 it would add 403.5 KB to the engine assets. I'm no techie... but that doesn't sound like a lot.



  • I would suggest considering separate images for digits instead of numbers. While that complicates calculating display coordinates, it has the great advantage of requiring 10 images instead of infinitely many. Though then you couldn't have Roman numerals for 270 BC, which would be a shame, really.


  • Donators Moderators Admin

    @alkexr I'm easy. I do not profess to know the best way to handle this from a technical standpoint. All I know is that after rendering a near infinite number of trees, hills, mountains and houses.... I can probably design as many numbers as we could possibly need. 🙂


  • Donators Moderators Admin

    @hepps we allllll know YOUR EASY! 🙂 nice ideas


  • Donators Moderators Admin

    @prastle You only know that because we've been on a date. If you hadn't been swept off your feet by my rugged good looks and charm... you'd have not idea. 🙂


  • Donators Moderators Admin

    @hepps ROFL!
    yes dear


  • Admin

    @Hepps So is the main point having a nice outline for the unit numbers? If so I'd probably want to consider doing it without images first before falling back to that option. But what you propose should be theoretically doable and I'd probably agree with @alkexr to draw each digit so less images are needed.

    Also the benefit of figuring out how to do it programmatically is we keep the font size options. Though I guess in theory you could do something with image sizing.


  • Donators Moderators Admin

    @redrum I am open to all kinds of options... fast and loose that's how I like to play it. 😉

    I guess just working on a couple different maps lately I started to really see how the monochrome pixilated numbers are a huge opportunity for maps. And while antialiasing alone would be an improvement, it by no means solve the issue of maps with a variety of unit and territory colours, shading, reliefs, unit colours.....

    So while pondering it I thought the best would be a outline. the reason I suggested an image is really a by-product of two things...

    First I thought an outlined number was not possible to render currently. (as a font)

    Second I thought if they were images then it allows the creative juices to just flow, since you could do all kinds of wonderful things both with numbers as well as backgrounds.



  • @redrum said in Inception: A dream within a dream (Unit stack numbers display):

    figuring out how to do it programmatically

    In C# what I would do is to draw the number (string) to a Bitmap first (don't know java equivalent). Then for each pixel P, you take the maximum of (alpha of pixel Q * strength - Euclidian distance(P, Q) * sharpness) over all pixels Q on the bitmap, this will be the alpha of the outline. Then you overlay the original bitmap over the outline. (Strength and sharpness are parameters.) If you only take the maximum over pixels Q within a radius of (255 * strength - sharpness), then you get the same result in O(n^2) relative to the height/width of the bitmap.


  • Admin

    Just outlining the current numbers would be a great improvement! The default white numbers can be hard to see and distinguish on bright territory backgrounds. (Yes, I know that I can change colors... But I don't want to 😊)


  • Admin

    So here a first go at it:
    0_1530226684526_6e1188b5-4c10-4686-8555-a1aa95f8e079-image.png

    And with a large number of units:
    0_1530226809487_3be9b57f-018a-4179-926f-ddecd0623437-image.png

    Before:
    0_1530227830920_ba3f141f-da39-496d-a6ea-6673fe6c15b3-image.png


  • Donators Moderators Admin

    @redrum How is that possible? How was this able to be done so quickly?


  • Admin

    @alkexr That's a bit more graphics kungfu then I'm doing at the moment. Initially, I'm just outlining the text by first drawing it at the 1 pixel over northwest, southwest, northeast, and southeast positions with the outline color and then drawing the text in the center with the text color. As well as enabling anti-aliasing.


  • Donators Moderators Admin

    @redrum All good. I just thought this would be a much bigger undertaking...

    "To the uninitiated everything appears to be made of magic"


  • Admin

    @hepps Well, my pretty simple approach took about 5 minutes. Ask and thou shall receive 🙂

    Open to trying some other ideas if folks want. Probably gonna at least add an option to set the outline color as well.


  • Donators Moderators Admin

    @redrum That was my very next question. 🙂

    I'm going to use inception more often. It appears to be highly effective as a title. 😉


  • Admin

    And did unit and bombing damage as well:
    0_1530234019701_47e2665f-4a3f-4f62-b59f-d829e58340c3-image.png


  • Admin

    And the update font preferences:
    0_1530235467266_d9569bb3-c8c1-4955-8dec-65f832f10c3d-image.png

    Any thoughts on defaults? Unit color/outline as white/black seems good. But black numbers with white outline are a bit jarring. Maybe do a gray for default outline for hit and bombing damage? Also should the default font size be a bit bigger? 12 seems really small on most screens/maps.

    0_1530237214893_2c7d5fb5-f111-4ade-b075-9b56499ffe26-image.png

    Current defaults:
    private static final int MAP_FONT_SIZE_DEFAULT = 12;
    private static final Color TERRITORY_NAME_AND_PU_AND_COMMENT_COLOR_DEFAULT = Color.BLACK;
    private static final Color UNIT_COUNT_COLOR_DEFAULT = Color.WHITE;
    private static final Color UNIT_COUNT_OUTLINE_DEFAULT = Color.BLACK;
    private static final Color UNIT_FACTORY_DAMAGE_COLOR_DEFAULT = Color.BLACK;
    private static final Color UNIT_FACTORY_DAMAGE_OUTLINE_DEFAULT = Color.LIGHT_GRAY;
    private static final Color UNIT_HIT_DAMAGE_COLOR_DEFAULT = Color.BLACK;
    private static final Color UNIT_HIT_DAMAGE_OUTLINE_DEFAULT = Color.LIGHT_GRAY;