News:

SimuTranslator
Make Simutrans speak your language.

Let themes define station label looks (optional)

Started by _Hajo_, January 02, 2023, 06:39:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

_Hajo_

This request came up in the pak144.Excentrique discussion. To let a theme define the looks of a station label.

I have some proof of concept work now.

A theme can now define two additional parameters

1) In the themes dat file, a brightness can be set for the player colored text in the label. E.g.

gui_player_color_label = 5

2) Similar to window background, a label background can be defined in the makeobj dat. E.g.

# text labels
Obj=menu
name=DisplayTextLabel
Image[0]=> display_text_label.0.0
Image[1]=> display_text_label.0.1
Image[2]=> display_text_label.0.2
Image[3]=> display_text_label.1.0
Image[4]=> display_text_label.1.1
Image[5]=> display_text_label.1.2
Image[6]=> display_text_label.2.0
Image[7]=> display_text_label.2.1
Image[8]=> display_text_label.2.2

I have attached two previews, one with a light and one with a dark theme. This is for discussion. E.g. there is no way yet to define a custom size for the labels, but this is on my list.

Addendum:

- If a scene does not define a DisplayTextLabel object, the traditional display code for labels will be used. So this is fully compatible with older themes.
- The ownership of the station is indicated by the color of the text, not the color of the background anymore. I know this is harder to see, but it seemed to be a quick solution for this proposal. Better ideas are welcome.

Leartin

Quote from: _Hajo_ on January 02, 2023, 06:39:29 PM- The ownership of the station is indicated by the color of the text, not the color of the background anymore. I know this is harder to see, but it seemed to be a quick solution for this proposal. Better ideas are welcome.
Is player color in the label working properly?
As in: Could a theme creator use player color in the label images to create a player color indicator box, or a border in player color, or underline the station in player color, or.... you get the idea. Should be fine to hand the burden of making sure station ownership is clear over to the UI designer.

Ranran(retired)

Currently, station labeling has three style options.
(1) Box with player color background
(2) Shadowed player-colored text with no background
(3) Player-colored squares and yellow text

Is the new station label a fourth option?
ひめしという日本人が開発者達の助言を無視して自分好みの機能をextendedに"強引に"実装し、
コードをぐちゃぐちゃにしてメンテナンスを困難にし(とりわけ道路と建物関連)、
挙句にバグを大量に埋め込み、それを知らんぷりして放置し(隠居するなどと言って)別のところに逃げ隠れて自分のフォーク(OTRP)は開発を続けている
その事実と彼の無責任さに日本人プレイヤーは目を向けるべき。らんらんはそれでやる気をなくした(´・ω・`)
他人の振り見て我が振り直せ。ひめしのようにならないために、らんらんが生み出したバグや問題は自分で修正しなくちゃね(´・ω・`)

_Hajo_

#3
Quote from: Leartin on January 02, 2023, 08:46:20 PMIs player color in the label working properly?

I think it is. Well, the text color.
Right now I don't know if the UI "display_stretch_xxx" routines handle player colors. I assumed they do not, so I didn't even try.

Edit: I have tested. These routines do not replace player colors. So one cannot use them in the graphics with the intention to have them replaced by the actual player colors in the display.

Quote from: (N)Ranran (Hibernating) on January 02, 2023, 08:58:18 PMCurrently, station labeling has three style options.
[...]
Is the new station label a fourth option?


Yes, but actually no. Right now a theme can define a label background, and if it does there is always this background used. Themes without will offer the old options.

It should not be hard though to make it switchable. I.e. if a theme has a label background, there will be 4 options to chose from, for other themes the former 3 options. I'll implement it this way, to give a 4th option if there is one.

_Hajo_

I now have a version that supports player colors in the station labels. Unfortunately for this I had to change the signature of "display_img_stretch", to take a player number. The lower level routines already supported player colors, but "display_img_stretch" passed a hardcoded zero to them. Now the caller can decide if player colors have to be used.

Code to review:
https://github.com/Varkalandar/simutrans/tree/feature/themed_station_labels

Still to do: Expand the display options dialog to make this a fourth option for the station label display. Right now, if a theme supplies a label background, it will be used regardless of player settings in the display options.

Yona-TYT

Quote from: _Hajo_ on January 03, 2023, 03:12:42 PMI now have a version that supports player colors in the station labels. Unfortunately for this I had to change the signature of "display_img_stretch", to take a player number. The lower level routines already supported player colors, but "display_img_stretch" passed a hardcoded zero to them. Now the caller can decide if player colors have to be used.

Code to review:
https://github.com/Varkalandar/simutrans/tree/feature/themed_station_labels

Still to do: Expand the display options dialog to make this a fourth option for the station label display. Right now, if a theme supplies a label background, it will be used regardless of player settings in the display options.
Wow, it looks unbelievably good!. 8)

isidoro

Certainly!  Even the shape of the label is changed.  :thumbsup:

Leartin

This is great!

Just some thinking... what about the station status indicator?
Currently, you got the label indicating station name and owner as one thing, and the station status indicated by a colored bar as a separate thing. If you want to make the UI of station labels nicer, perhaps it's better to think of them as a union?

station-label-mockup.png

These two mockups (based on your preview) just show ideas. The station status could be a part of the label 9-slice (if there was a mask like for colored buttons or 'special colors' to be replaced with the indicator), or a separate graphic that's anchored to one of the sides of the label. I have no suggestion of what to do with the ware bars even though I don't think they are particularly great or useful as they are (AFAIK you can't even set colors to make them reasonable, not that there are enough distinct colors for the amount of goods in most paksets...), but even if they exist as is, it could be nice to have their baseline as a 3-slice.

I don't want to push this too much, but if we get "just" the station labels and don't think about this until later, it might be we miss opportunities we have now by cementing a new status quo too early.

_Hajo_

Quote from: Yona-TYT on January 03, 2023, 04:07:54 PMWow, it looks unbelievably good!. 8)

Thanks. I have made another design for my "purple night" theme, using all 8 shades of player color as a second example.

Quote from: Leartin on January 03, 2023, 10:10:14 PMThis is great!

Just some thinking... what about the station status indicator?
Currently, you got the label indicating station name and owner as one thing, and the station status indicated by a colored bar as a separate thing. If you want to make the UI of station labels nicer, perhaps it's better to think of them as a union?

Thanks as well! From a players point of view they sure can be seen as a union, but in the code, the places which draw the name and the goods status bars are pretty far apart.

I'd like to do the goods and status bars in a separate patch, just cause the code responsible for drawing is so different. It can eventually still be in the same theme definition, so the designer won't see that it once came in two code patches.

Tomorrow I'll try to give the text in the labels a color config entry too. Not 100% sure how to do it, cause I'd like to offer both options, to draw a player color colored text or a fixed color.

_Hajo_

So, took a bit to get it working. And I've only tested the Linux version so far. But I got a "nightly" build with the new label handling included. You can download it here:

https://github.com/Varkalandar/simutrans/releases/tag/Nightly

If you select the "Silver (Large size)" or the "Purple Night (Large size)" theme you can test the labels with your favorite pak set. You can even make your own, if you fetch the sources of e.g. the "Silver" theme and replace the "display_text_label.png" with your own version, then rebuild the theme.

Theme sources,
https://github.com/Varkalandar/simutrans/tree/feature/themed_station_labels/themes.src

_Hajo_

#10
I think it's ready for being tested now. The display settings dialog allows to cycle through the old 3 station styles if the theme has no graphics defined, and it allows to cycle through 4 styles, 4th being the theme defined label. The setting is saved and can be set via simuconf.tab as usual.

The them config (tab file) now supports these settings:

#
# station labels
#

# height of the label
gui_display_text_label_height = 18

# text margins inside the labels (left, top, right)
gui_display_text_label_margins = 6, 5, 6

# The color of the label text. Can be a number 1-7, to indicate player color
# brightness or it cant be a RGB value like #000000.
gui_display_text_label_color = #000000

The supplied silver theme (large) has a fixed color for station labels, the purple night theme (large) uses the brightest player color (7). The margins allow to move the text off-center to allow labels with extra graphics to the left or right of the text.

Sources to review:
https://github.com/Varkalandar/simutrans/tree/feature/themed_station_labels

Downloads for testing:
https://github.com/Varkalandar/simutrans/releases/tag/Nightly

Edit: I missed to rebuild the themes into the distribution direction. If you have downloaded one of the test versions already, please download again. I still need to find out how to handle the automatic builds better.

Leartin

#11
Good thing I tested with my own experiment anyway :D

station-label-nomockup.png

- it seems RGB color does not work for text, but brightness does. (I tried #FFFFFF and #ffffff)
- the station display setting is not saved, and I'd expect it to switch to the new style automatically when a theme supporting it is selected.
- I think the centering does not work properly, I suppose it does not take margin into account.

EDIT:
station-label-nomockup2.png
- it appears the possibility of larger fonts is not taken into account.

- could we get separates label styles for different uses? Right now, the same label is used for cities and markers as well, while vehicle messages ("no route!") appear unaltered.

_Hajo_

#12
Thanks for testing!

- I'll look into the RGB values. Only tested #000000, probably missed a bug there.
- I had such an effect too, that the display mode didn't seem to be saved. But in fact, I had a simuconf.tab somewhere that set it to mode 3 and overrode the saved value each time Simutrans was started. Please check your simuconf.tab(s), I'm somewhat sure the value is saved and if you remove the setting from simuconf.tab(s) it will be used.
- My bad. Somewhere I had seen a message that all fonts have the same size, so I assumed bigger fonts are not an issue. Not sure what to do there, but the height setting in the theme config clearly has a problem in that case. I'll need some time to check different fonts and think about a solution.

Quote from: Leartin on January 04, 2023, 08:41:54 PM- could we get separates label styles for different uses? Right now, the same label is used for cities and markers as well, while vehicle messages ("no route!") appear unaltered.

This routine is a remnant of very old Simutrans times. Town names, markers, station and in some cases factory names are displayed with it, I think. Right now the only parameters it gets are the screen position, the text and a pointer to a player object (for the color).

I've checked the code and found 4 locations from where the routine is called. So it will be a fairly low impact change to expand it and receive some more data from the caller.

What do you have in mind? Town names, markers etc. each being displayed with their very own label background? This will enlarge a themes config and data quite a bit. I feel a bit shy about such big changes, but technically it should be doable. Just testing and debugging will get exponentially more difficult with each possible combination of attributes.

Edit: Bug for "#aabbcc" style color values confirmed. Instead of the real value, black was used. I'll fix this.
Edit 2: Should be fixed now. Was broken twice ... both in parsing and in display.
Edit 3: pak128.German comes with a simuconf.tab that sets label style to 3 too. So one really must check all simuconf.tabs, global, local and pak to avoid the saved value being overriden.

Ranran(retired)

#13
Quote from: _Hajo_ on January 04, 2023, 09:29:27 PMNot sure what to do there, but the height setting in the theme config clearly has a problem in that case. I'll need some time to check different fonts and think about a solution.
I would expect LINEASCENT to be the height of the font, but this doesn't seem right at times. When I use this to adjust the vertical alignment, some fonts are slightly over-positioned.
For example, the rectangular background of the station name.

The theme's method of structuring button images may be helpful. This correctly handles variable font sizes.
Button images are divided into 9 parts. A combination of a flat image in the center and each corner. However, this reduces design flexibility somewhat. With the 9 parts method, it is difficult to achieve something like Learnin's example with the existing button image method (circular parts on the left). So there has never been a theme with such a button design.
Other than that, it may take some effort to make simutrans support for variable fonts....
For example, shrinking a large image, but simutrans fonts can be very small and have a limited number of colors, so I'm wondering if this can provide a good look.
ひめしという日本人が開発者達の助言を無視して自分好みの機能をextendedに"強引に"実装し、
コードをぐちゃぐちゃにしてメンテナンスを困難にし(とりわけ道路と建物関連)、
挙句にバグを大量に埋め込み、それを知らんぷりして放置し(隠居するなどと言って)別のところに逃げ隠れて自分のフォーク(OTRP)は開発を続けている
その事実と彼の無責任さに日本人プレイヤーは目を向けるべき。らんらんはそれでやる気をなくした(´・ω・`)
他人の振り見て我が振り直せ。ひめしのようにならないために、らんらんが生み出したバグや問題は自分で修正しなくちゃね(´・ω・`)

Leartin

Quote from: _Hajo_ on January 04, 2023, 09:29:27 PM- I had such an effect too, that the display mode didn't seem to be saved. But in fact, I had a simuconf.tab somewhere that set it to mode 3 and overrode the saved value each time Simutrans was started. Please check your simuconf.tab(s), I'm somewhat sure the value is saved and if you remove the setting from simuconf.tab(s) it will be used.
That is correct. The value was set to 3 in the simuconf (I might add: In the simuconf you provide with your test version), removing that allows the display setting to be saved. HOWEVER, that's not good enough. Imagine player colors being reset because the default colors in the simuconf overwrite what the player chose :o

Though I understand it's essentially an old bug that only comes to live now since appearently nobody bothered changing the label display type before. And in that regard: According to simuconf there is one value that sets both whats displayed (label, statistics, or both) AND in which style (add 4 to switch) while the ingame setting only allow a number of 0 to 3 and "eat up" a change in style in the simuconf if you open the settings. Technically, this is a bug report, but I hesitate to open a new topic for it since you are already active in the area and might want to solve it yourself, while changes from someone else might interfere with your current work.

Quote from: _Hajo_ on January 04, 2023, 09:29:27 PMNot sure what to do there, but the height setting in the theme config clearly has a problem in that case. I'll need some time to check different fonts and think about a solution.
Remove the height setting, and add a bottom margin instead. The button height is top margin plus bottom margin plus the height of the text. To see how to get the height of the text, check other theme elements, eg. title bars, which already adjust to font size. After all, you already used 9slice for scalability.
Note: Use the max of margins+textheight and the combined heights of graphics 2 and 8 in the 9slice. Just in case, it only needs to be computed once anyway.

Quote from: _Hajo_ on January 04, 2023, 09:29:27 PMTown names, markers etc. each being displayed with their very own label background? This will enlarge a themes config and data quite a bit. I feel a bit shy about such big changes, but technically it should be doable. Just testing and debugging will get exponentially more difficult with each possible combination of attributes.
Yes, indeed. The label I made is reminiscent of Austrian ÖBB station signs. So it makes sense to me that cities are displayed as Austrian city signs in the same theme, and markers as Austrian (private) signposts. (Though it's just experimentation, I don't plan on creating an Austrian Theme. Although....)
I'm a pak192.comic guy, naturally I'm not at all concerned with size here. Even if each player gets there own label graphic, its still smaller than a single citybuilding that uses rotations and seasons. Plus, I'm not saying each type of label needs to be defined individually - "gui_display_text_label_" could still apply to all, while "gui_display_text_label_station_"; "gui_display_text_label_city_" and "gui_display_text_label_marker_" supersedes them.
Note that on your part, if labels work in general, you only need to test if it takes the new values (if that is even testworthy), since the method is the same anyway. Dumbed down: If your function DrawLabel(graphic, margin, color) works, it works no matter if it's fed label_graphic, label_margin, label_color or label_city_graphic, label_city_margin, label_city_color. Unless what it's fed is garbage, but that's on the theme designer.

Quote from: (N)Ranran (Hibernating) on January 04, 2023, 10:46:09 PMWith the 9 parts method, it is difficult to achieve something like Learnin's example with the existing button image method (circular parts on the left).
It already is a 9slice, so my example is one. And yes, if you stretch it, the circle becomes an egg. However, I'm not much concerned about this, since in a proper theme, I'd have a large variant anyway with larger icons etc, and can make the 9slice borders bigger with a bigger circle for that. The way I see it, there is no point in using really large text with a small theme, or small text with a large theme, and if you do that combination yourself, it only needs to look "correct", not "nice".
That being said, you can work around this by combining a nine-slice with non-scaling 'ornaments'. Those would be simple icons to be placed on the center of one of the edges. With that, larger text makes the box bigger, while the player indicator stays a vertically centered circle. While it won't look good anymore with text twice the size, it's a lot better if the text is only slightly bigger. It also enables a box like this (ASCII, since I'm lazy):

#-----O-----#
I           I
I           I
O           O
I           I
I           I
#-----O-----#

But that's wishful thinking and shouldn't be thought of in regards to the labels, but in regards to the whole Simutrans UI.

Flemmbrav

OMG i love the idea of multiple players having all their individual station sign!
That'd be sooo cool in network games!

_Hajo_

Only a few answers right now, cause I'm a bit in a hurry.

- Mixup of statistic, name display and name display style flags and values in one integer. Yes, old and ugly, and a source of errors. I'll see what I can do. It might break some compatibility though, and require a player to re-set the choices after switching from Simutrans to the patch version and back. I'll do it later, once the display related things are stabilized.

- Font sizes. I think I have a solution, like Leartin proposed. Using a bottom margin, and remove the label height setting. Might need some tuning, but the approach works.

Plans: I'll try to split station name display from towns and the rest. So stations can get their own label style. This seems to be the most important. Once this works, we can discuss more styles for more object types.

... more answers later.


_Hajo_

#17
Testing .. 1,2,3!

I have split station labels from other labels. Proof of concept screens attached. The code needs some cleanup, though.

Downloads for testing:
https://github.com/Varkalandar/simutrans/releases/tag/themed_labels.v01

Your station labels look cool, Leartin ;)

Edit: I have merged all changes from Standard, so this should work as well as the current nightly.

ceeac

Some comments regarding the code:
  • In the patch, tabs and spaces are mixed, while the surrounding code exclusively uses tabs for indentation - this should be changed to tabs for consistency.
  • Some (stub) function definitions are missing from simgraph0 - see https://github.com/Varkalandar/simutrans/actions/runs/3848068926/jobs/6555350693
  • regarding display_text_label(): It might be a good idea to use an enum for the flag parameter,  something like this:enum class label_style_t : uint8 {
      halt = 'H',
      factory = 'F',
      ...
    };

_Hajo_

Thank you for the review.

1) I had tried to set my IDE to use tabs. How can I find the places where tabs and spaces are mixed to clean them up?

2) This is helpful, thanks. I was wondering why the test fail, but ignored that cause my self built binary worked "good enough" for me. I'll fix that.

3) Yes, and there is also some duplicated code, which needs unification. For today I just wanted to get the demo with different label styles out. Once it is confirmed that this is the way to go I'll clean up the code. Open question, how many styles will be needed and if we actually need the enum or just a call to "is_halt()", if station labels are the only to distinguish.

_Hajo_

I've been experimenting with markers. There is a slight conflict here at times, if pak sets define their own marker graphics, and my idea to give a marker a pointer to the square.

Anyways, if it's wanted, I can give markers their own section in a theme config and their own display code. This version uses the known 9 part images for the labels and a 10th for the pointer/trunk part.

The marker label code is right now in a different branch where I test other UI stuff too ("ui_improvements"). It's not ready yet to be used in production.

Leartin

How does that 'trunk' work with zoom and various pakset sizes? Can't be static like the label, or it will point to the wrong tile if zoomed out too much. Could zoom, but then it needs to have the right size to go from tile to label, which is dependent on the pakset size, while themes should be independent of pakset size.

If you control both pakset and theme, you could get that effect anyway by making the pakset marker the trunk, which then has the correct size for the pakset and zooms to always end in the label. If anything, this kind of hybrid thing begs the question if labels should be part of a theme designed to be pakset-independent, like all the dialog stuff that does not interact too much with pakset graphics, or rather thought of as part of the landscape, part of the pakset graphics...

_Hajo_

#22
My code moves trunk and label so that it actually points to the right tile.

I've tested that with two pak sets (64 pixels and 144 pixels) and all zoom levels.

Well it's a proposal. And not part of the patch just cause of this reason it's not so cleanly integrated.

But you cannot get the same effect with a marker object and a traditional label. Even if you make the object not zoom, it will not fit to the label after zooming. There is too much trickery in the label position calculation.

Edit: but yes, the question if the pak set or the theme should define the looks,  I had brought that up very early in the part of the pak144.excentrique discussion that lead to this development. There was only one answer posted and that one said theme.

Edit 2: implementation wise the difference is very minimal. Both theme and pak set objects are registered the same way. The only difference is that themes override pak set objects. My code would work as well if all the stuff comes from the pak set.

What will be missing are the values from the theme tab, sizes, colors, etc

Edit 3: I can't test it right now, but if the automatic build worked, the marker code should be active in these versions:

https://github.com/Varkalandar/simutrans/releases/tag/Nightly

Should be fully compatible with all pak sets, but only the silver and purple night themes have marker graphics. So you can try and see. Neither the label itself nor the trunk part do zoom.

_Hajo_

Another option. Smaller down arrow. It will be easy to add an height offset to a theme config so it can be displayed higher or lower and the offset being scaled with the map zoom factor.

_Hajo_

So, I think I've got them all now. Town labels, station labels, markers and eventually also factory labels. I ran a bit dry in coming up with yet another label style, so these are just proof of concept that all these label types can be distinguished and drawn in their very own, theme-defined style.

prissi

I think the GUI addition is very nice. I like especially the trunk marker much more than the sign one with the floating text. It makes much more sense like this and is easier to find. I would rather abolish the marker on the tile in favour of the trunk.

I am not sure if more styles for the different floating text will be used much, but it certainly is nice to have a choice. Can you do a diff of it?

The height of the current font is in LINESPACE. But I think those labels should work similar to the round buttons with text, so you should be able to copy the code from there. Line 371 in gui/componenenhts/gui_button.cc

Otherwise it is very nice someone is caring again for the GUI appearance and modding in standard.

Also our official repo is now simutrans/simutrans where in principle we can handle pull requests etc. which is not possible with aburch.

_Hajo_

Thanks for the feedback Prissi. Makes me happy to see that you like the proposal :)

It's fairly easy to use one source image for all label definitions, but I can shrink the code a bit if only markers are separate from other labels. So, towns, stations and factories share one label style, and markers get the new 10-part style definition with the trunk part.

This will also make the theme tab files a bit smaller, easier to maintain, with only two sets of margins and text color definitions.

Let me know which version you prefer, the 4 styles or 2 styles options. I'll then prepare a patch. Actually I'd prefer a pull request, but I must see if that is possible since I forked from aburch/simutrans.

And yes, I used LINESPACE already for the font height. So that doesn't need to be changed.

prissi

I think the marker trunk would be better part of the existing marker graphic, just with a second "pillar" part so that the marker trunk can grow out of the map and shrinks in size with the zoom.

And I think having four possibilities would be nice; but I am not sure how many would be used. I mean even you had trouble to come up with more than two distinct but matching styles.

_Hajo_

I agree, having all the options is better than later missing some. It is easy to share one image with all the definitions. Leartin made very nice station labels with some logo to the left, that sure is worth to be separate from town and factory labels.

I'll clean up, merge all the needed code to the branch "feature/themed_station_labels" and ask for a review once it's done. Sadly real life is getting more and more busy, but I hope to have it done till mid of next week.

_Hajo_

Merging went faster than expected. The required code is now on the "feature/themed_station_labels" branch. The diff to Simutrans standard is quite large though: "Showing 75 changed files with 3,494 additions and 588 deletions."

https://github.com/aburch/simutrans/compare/master...Varkalandar:simutrans:feature/themed_station_labels

Previews from the branch attached. Purple Night theme has makers with trunks, I forgot to screenshot these. Uploaded files show all marker styles from the "Silver" theme with different player colors and fonts.