News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

A Simutrans Prettification Project + Open GL dev

Started by _Hajo_, January 31, 2023, 08:20:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

_Hajo_

Since a while I work on making Simutrans prettier. So far I've tried to make two pleasant UI themes, a light one, called Silver and a dark one, called Purple night. I've renovated the old pak48.Excentrique to higher res graphics, now 144 pixels.

And since my mind is restless and the pak64 seemed to deserve some love as well, I've started a pak64 makeover, by the name of pak72.Elegance.

But there still was the core, the game itself. I had not been doing any C++ coding for years, but I decided to give it a try. Along with my work on themes, not only station, town and factory labels became part of a theme, but also window title bars.

Today I finally found a way to work on something that I wanted since a long time. Better text display in Simutrans. Right now it's an ugly hack, has performance issues, eats memory and only works with the vector type fonts, but here it is - and with it, the official announcement of my Simutrans Prettification Project.

smooth_ttf_fonts.png

Step by step I want to go over all the dialogs, see if I can change them to make them more pleasant to look at, easier to use, and if possible, work better together (at least not get in the way so often). Code and demo releases will appear here:

https://github.com/Varkalandar/simutrans_ts

The TS is not particularly meaningful. I had a Simutrans repository already, forked from aburch/simutrans, so I needed to chose another name for this one, now forked from simutrans/simutrans. If you want, think of tomato and salad, a Simutrans fork with some goodies added. Or traffic starter, if you want something more transport related.

Yona-TYT

Wow, this is really magnificent!.  8)  8)  8)

I wonder if something can be done to improve the load bar?.

Captura desde 2023-01-31 19-39-36.png

_Hajo_

Quote from: Yona-TYT on January 31, 2023, 11:39:55 PMWow, this is really magnificent!.  8)  8)  8)

I wonder if something can be done to improve the load bar?.

Thanks! And certainly. What exactly do you have in mind?

It's been tough to create a demo release, and convince the build pipeline to use the new TTF font and my updated translations in the archive. I have tested this with Linux and Windows, and it seems both packages work as expected.

https://github.com/Varkalandar/simutrans_ts/releases/tag/v0.03-alpha

There are still a lot of problems. In particular, the code does not handle font baselines properly, so some fonts (if you chose other than the Liberation Sans, with which I have tested) show too high or too low in the dialogs.

There is also a problem with the kerning (some characters are too far apart), but Simutrans font display routines don't know about kerning yet, and I have to implement that. Same for ascend and descend values (the reasons why some fonts are aligned too high or low). Also something for me to look into.

Compared to the screenshot yesterday I had to change the "weight" of the font slightly. The lines are now thicker, stronger. I have tested some settings and some fonts and think this is a good compromise which works with many fonts.

Furthermore I had to disable some checks in the language choice. At the moment all languages are enabled, even if the font does not support the characters. This is a workaround so you can at least try and see if some translation works with the chosen font.

So, what else is in there? If you chose the "Silver (large)" or "Purple Night (large)" themes, you will get theme defined window title bars, station, town, factory and marker labels. They all are not final, just to show that the code actually works.

Furthermore there is a slightly changed pak selector, with a (I think) better layout.

pak_selector.png

And I've started to change the depot windows slightly. Instead of having an empty space at the bottom to show vehicle details, the details are now shown in an overlay over some of the controls. It only appears if the mouse is over a vehicle, so will disappear if you move the mouse elsewhere, so you can use the controls.

Also, I tried to get the values into a more tabular order. There are some problems there still, sometimes texts are cut off with ellipses "..." even if there is enough space. I must look into that, apparently the calculation of the text length got broken in some cases due to my changes on the font routines.

Yona-TYT

Quote from: _Hajo_ on February 01, 2023, 08:02:19 PMThanks! And certainly. What exactly do you have in mind?

Mainly the shape of the bar, for example making the edges rounded, as seen in the new styles of the station labels.
And customizable background would also be nice.

Currently only two colors can be changed on this bar.

_Hajo_

I think the theme is already loaded at the point, also the preview/title image from the pak. Should be doable to use either source to define the loading bar looks. But maybe we should discuss the details in another thread.

Isaac Eiland-Hall

I will say this once and only once: If anyone uses this for Comic Sans, I WILL reach through the internet and slap you AND ban your account from this forum. ;-)

edit: Same goes for Papyrus...

Yona-TYT

Quote from: Isaac Eiland-Hall on February 01, 2023, 10:06:52 PMI will say this once and only once: If anyone uses this for Comic Sans, I WILL reach through the internet and slap you AND ban your account from this forum. ;-)

edit: Same goes for Papyrus...
Just a moment ! And why so much hate towards those fonts in particular?. :police: ^-^

Dwachs

Nice that you are working on the fonts code (to move away from fixed size bitmaps).

Quote from: _Hajo_ on February 01, 2023, 08:02:19 PMThere are some problems there still, sometimes texts are cut off with ellipses "..." even if there is enough space. I must look into that, apparently the calculation of the text length got broken in some cases due to my changes on the font routines.

This happens if the string changes after the assignment of the element sizes is done. Not sure what a proper fix would look like. I solved this by calling ``resize(scr_size(0,0));'' whenever some string label changed. see eg at the end of depot_frame_t::update_data() or within some of these draw(...) methods, another example is in convoi_info_t::update_labels()
Parsley, sage, rosemary, and maggikraut.

_Hajo_

Quote from: Dwachs on February 02, 2023, 12:41:45 PMNice that you are working on the fonts code (to move away from fixed size bitmaps).

Thank you. The real thanks must go to the person though, who implemented the FreeType support. Without that previous work, it wouldn't have been possible.

Also thanks for the hint with the ellipses and the label sizes. I had been looking into it, but couldn't figure out the real problem :o

_Hajo_

I made the spaces of the new fonts a little smaller, and tidied up the display of data in the depot dialogs some more.

simscr41.png

Demo versions for testing can be found here:
https://github.com/Varkalandar/simutrans_ts/releases/tag/v0.04-alpha

Flemmbrav

Quote from: Isaac Eiland-Hall on February 01, 2023, 10:06:52 PMI will say this once and only once: If anyone uses this for Comic Sans, I WILL reach through the internet and slap you AND ban your account from this forum. ;-)

edit: Same goes for Papyrus...

you do realize that that'll be the font pak192.comic will ship with? That's a lot of traveling you should be looking forward for here!


----

@Hajo finally proper fonts! Do you intend to make them part of the theme? Or be changed separately?

Yona-TYT

Quote from: Flemmbrav on February 02, 2023, 07:40:53 PMyou do realize that that'll be the font pak192.comic will ship with? That's a lot of traveling you should be looking forward for here!
----
@Hajo finally proper fonts! Do you intend to make them part of the theme? Or be changed separately?

Your questions and statements reawaken a concern I have.

As for whether we will have default themes in the paksets, I even did a little experiment last year -> https://forum.simutrans.com/index.php/topic,22162.0.html


Leartin

Quote from: Flemmbrav on February 02, 2023, 07:40:53 PMyou do realize that that'll be the font pak192.comic will ship with? That's a lot of traveling you should be looking forward for here!
He doesn't need to, I'll personally slap you with a stinky fish if you attempt that! P192C already has a font - Komika Axis of the Komika-Bundle by Larry Yerkes. (Though that doesn't support lower case, so probably one of the Komika Text variants... [Idea for Hajo: Allow for "Title" and "Body" fonts to be chosen])


Quote from: _Hajo_ on January 31, 2023, 08:20:59 PMStep by step I want to go over all the dialogs, see if I can change them to make them more pleasant to look at, easier to use, and if possible, work better together (at least not get in the way so often).
Very nice!

Here is a general idea for you that might impact all kinds of dialogs: Expanding tooltip functionality.
A) Allow tooltips to be more than one line of text, but rather, a formatted, multi-line block of text that may include icons.
B) Allow tooltips to be "pinned" - a way to make them stay open even if the mouse moves away, and to choose where it's positioned. (But also be closed if the dialog it belongs to is closed)

With A, existing tooltips can be prettier (eg. Name, cost, capacity of a station icon in separate lines) and more information might be possible due to better structure. But also, each vehicle could have it's stats as the tooltip instead of the current 'special' treatment in the depot to show it's stats. That same tooltip could also be shown in the convoi list and convoi details - wherever the vehicle appears in a dialog.

With B, it becomes much easier to compare things with each other. This is true for tracks and stations but even more so for vehicles. I also believe that one could incorporate most help texts in tooltips. Eg. in the finance dialog, the help describes each button individually. This could be done as tooltip for those buttons instead, but only if they can display more information and can be pinned to allow them to be studied.

_Hajo_

Quote from: Flemmbrav on February 02, 2023, 07:40:53 PM@Hajo finally proper fonts! Do you intend to make them part of the theme? Or be changed separately?

Thank you. I had not thought about this yet, but I agree with the idea that a pak set should be able to define a preferred theme and also a font to offer a consistent user experience.

In the UI we can offer an option so users can override the pak defaults, so everyone should be happy.

Quote from: Leartin on February 03, 2023, 11:06:41 AM[Idea for Hajo: Allow for "Title" and "Body" fonts to be chosen])

Very nice!

Here is a general idea for you that might impact all kinds of dialogs: Expanding tooltip functionality.
A) Allow tooltips to be more than one line of text, but rather, a formatted, multi-line block of text that may include icons.
B) Allow tooltips to be "pinned" - a way to make them stay open even if the mouse moves away, and to choose where it's positioned. (But also be closed if the dialog it belongs to is closed)

Thanks to you as well. And yes, I am already looking into options to have more than one font size. Technically it's easy, the question is how to implement it properly, I mean the interface to chose different sizes. I think I have an idea, but I need more time to weigh the pros and cons.

In regard to A) - Multi line tool tips should be easy, there are already routines to display multi-line text, fitted into a box. I need to think about the icons some, how to address an icon from a piece of text. Maybe with some html-like syntax like <img src="identifier"> and have the name of the icon there as identifier (the name from a pak file). Again, I need more time to think about this and come up with a good idea. Also, a point that puzzled me, buttons can have tool tips, combo boxes apparently can not ... something to investigate as well.

For B) - I'll say this is beyond my current skills. Maybe once I know the code better.

Thanks for all the feedback!

Yona-TYT


Quote from: _Hajo_ on February 03, 2023, 12:56:09 PMMaybe with some html-like syntax like <img src="identifier">

If you use html syntax (an image tag), that would benefit me a lot with scripting scenarios!.  ;D

Years ago I tried here: https://forum.simutrans.com/index.php/topic,15049.0.html

_Hajo_

So, next steps ... I want to make a graphical pak selector. I found a way to load "symbol.BigLogo.pak" from all installed pak sets and display them. Due to size reasons I only display the upper half right now. I think I could also show a middle band without too much hassle. (and sorry for the placeholders ... I just noticed pak72.Elegance and pak144.Excentrique had no big logos yet, so I had to quickly make up something). Using theme-defined background will also come soon.

It's not very pretty at the moment and the code is quiet some hack. But it actually works ;D

preview_1.png

Needs checkboxes or stuff to load with and without addons ... and maybe some hint about the installation folder, like the old pak selector showed? Pak sets might show just twice right now, without hint why.

Code: https://github.com/Varkalandar/simutrans_ts/tree/feature/graphical_pak_selector
Demo (with luck, if the scripts work): https://github.com/Varkalandar/simutrans_ts/releases/tag/Nightly

But first. Weekend!

_Hajo_

Been working on it some more. It's now a proper dialog, but that came at the price of leaving a margin for the toolbar, because dialogs are not allowed to overlap the toolbar space (even that there are no icons in it at this time).

To keep it symmetric, I apply the same margin on all 4 sides.

There are scrollbars now, so if you have many sets installed, you can scroll through them. There still is an omission. I need to calculate the actual height of the scrolled panel. So right now there is a fixed limit, but it will be dynamic soon.

The pak installer button works, but refresh of the icons does not. So after installing a new pak, one of the icons will be used twice. I'll look into that, how to refresh the icons list.

preview_2.png

Flemmbrav

IMHO only showing half of the big logo doesn't make that much sense.
I'd much more prefer to either show the whole big logo (and maybe make Simutrans start as a screen wide window to gain some space here),
or to have an extra image to be shown in the pakset chooser.

_Hajo_

I agree. It's mostly been for testing if it works at all. Until there are special logos/icons made for the pak selector, I'll display the whole "big logo".

I think I have fixed everything meanwhile, but I've removed the option to chose with/without addons. Pak sets are always loaded with addons in this version.

I've attached two previews with the "Modern (Large)" theme and the "Silver (Large)" theme.

Quote from: Flemmbrav on February 06, 2023, 07:55:39 PM(and maybe make Simutrans start as a screen wide window to gain some space here)

I can't do that (I think). The staring window size is given in one of the simuconf.tabs

For those interested to try, demo versions should appear here in the next minutes (Android build is out of order though):

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

Code needs more cleanup. I will do that once there is an agreement on the final pak selector.

https://github.com/Varkalandar/simutrans_ts/tree/feature/graphical_pak_selector


prissi

Working on presentation is nice. Especially in the depot which is too large and cluttered.

However, does this work with a touchscreen? I mean there are no mouseover with a touchscreen. We had made quite an effort to use simutrans with a touchscreen ... so it would be great if the depot can work with touchscreen as well. For this the info probably need to stay after the first click.

And all the logos had assumed a black background. Can the background of the logo display be black as well?

_Hajo_

My bad, I didn't think about touchscreen. So no, the new depot dialog doesn't work well with a touchscreen.

Meanwhile I had changed the background of the logos to theme_gui_t::gui_shadow_color
I'll change this to black.

Thank you for the info, Prissi!

Andarix

Quote from: prissi on February 08, 2023, 07:46:43 AM...
However, does this work with a touchscreen? I mean there are no mouseover with a touchscreen. We had made quite an effort to use simutrans with a touchscreen ... so it would be great if the depot can work with touchscreen as well. F...

A completely different UI is needed for a touchscreen.

For the depot it would make more sense to use a vehicle list (picture on the left, data on the right) that can be scrolled.

Currently, vehicle data cannot be displayed with touch without buying the vehicle. At least that's how it has been in my testing so far.

_Hajo_

During pak development I am using the factory list often, so see if Simutrans sets up the chains like I'd like it to.

So, I've started to work on the factory list as well. I've aligned the data in columns, gave the scrolled area a border and introduced background colors for odd and even rows. Also the rows are bigger now, because I don't think this is a space critical dialog.

prissi

I think if you start with one list, maybe it would be good to base it on this patch here:
https://forum.simutrans.com/index.php/topic,22171.msg202753.html#msg202753

That would also add extra functionality.

Also, since the list code has been recently unified, I think a more uniform display would be then better for all single line lists.

_Hajo_

Quote from: prissi on February 09, 2023, 11:59:57 PMAlso, since the list code has been recently unified, I think a more uniform display would be then better for all single line lists.

I'm working on that. Sadly the appearance of lines is defined in the "draw" method of the *stats types and not the list, so one has to change each *stat type for the stripes. But the goal is just that, make all the lists appear with the same looks. It just takes time.

_Hajo_

A second list is done in the new style, the city list.

Likely I'll not have time to work on more lists before next week.

_Hajo_

Work in progress, just a preview.

- There are two font sizes now. "Normal" and "large", which is 120% of the normal size.
- Both can be drawn in bold style.
- I've aligned and unified sizes of input fields in the new world dialog.

Also, it showcases the larger font in the "Settings for a New Game" label, and the bold normal size font in the title bar.

I have no demo of this out yet.


_Hajo_

More striped lists. I've also changed the station list to have indicator boxes like the factory list had, instead of shadow-colored vehicle names.

Demo versions are available here (including the updated new world and pak selector dialogs):
https://github.com/Varkalandar/simutrans_ts/releases/tag/v0.07

The Windows GDI build is broken. That is my fault, I had forgotten to test it during development, so I didn't notice till the release. There is also a problem with the android build, it also failed to build. Still, Windows, Linux and Mac builds are available.

Also, only the Silver and Purple Night themes are properly configured for the striped lists. Other themes will have striped lists, but likely in badly matching colors. I need to update them all.

Yona-TYT

Great, no doubt now it will be easier to look at those lists :D 8)

ceeac

The new lists look nice. Definitely an improvement compared to now imo. :)
If it is possible, maybe the convoys on the right hand side in the vehicle list should be vertically aligned? Not sure if this has performance implications when there are 30k+ convoys on the map, however.

prissi

I think the striped list should go into the main code as soon as the themes can support his.
Same for the additional labels.

The depot needs more thought on how to handle touch. The current state is also not too good, but at least on can see stats.

_Hajo_

Thanks for the feedback. I've not been feeling well recently but I hope to continue the work once I feel better again.

_Hajo_

Long break, but that is my life. First, feeling down, burned out, then interested in other stuff, working on other game projects.

But eventually an idea itched me. I tried to resist, knowing how unlikely it is to actually complete it. And others tried it before.

Then, 4 days ago, I actually started. Started to work on an OpenGl backend for Simutrans. It was done before, I know, but I could not find anything related, so I started from scratch. Now 4 days later and countless mistakes that ate my time and sleep, I hate C++ again and also know why, but well, it works ... somewhat. It can load legacy pak files, draw lines and boxes. There is a mistake though in decoding partial transparent pixels from legacy pak files. I'll fix that some day, once I understand how they are actually encoded.

So why another OpenGL backend if the old one failed? In other game projects of mine I grew rather fond of blending textures, for simulated light effects, or just to make things pretty. This is very hard with the traditional backend of Simutrans, even if that one is very performant.

Pros:

- Full 32 bit graphics from pak files to screen (needs a new Makepak and recompiled paks)
- All OpenGL blending fancy, colors, full and partial transparency (at like no extra cost)
- I might bite the sour apple and actually replace terrain rendering with real polygon texture mapping instead of that abomination of synthesizing myriads of tiles in memory that currently is in Simutrans. Downside is just the size and integration of this abomination. Very hard to understand and replace with something equivalent, but off loaded to the graphics hardware.

Cons:

- OpenGL does not allow multithreaded rendering. So likely the turbo charged multithreaded backend will be more performant.
- The day/night cycle trickery is hard. I'll not support it.
- Player colors are also hard with OpenGL. I'll likely not support it. Maybe I'll try something with shaders ... maybe.

What do I have now? An OpenGL backend in its infancy. Problem is now psychology ... actually I have achieved most of what I wanted, even if looks very incomplete to other people. I can load old paks, convert them and display them, and all the basic drawing functions are there. Usually this is the point where I lean back and say to myself, "I have proven that it can be made. I'm done here. Lets look for a new challenge"

It is hard for me to go further, and complete it. I'll try though, cause there is one thing not achieved yet - actual 32 bit graphics, a new Makepak and showcasing the transparency and light effects with some pak set.

Missing is 98% of the event handling. This is why I can only show the pak selector screen with a clipping bug and not even click a button to actually load a pak. Plus there are myriads of lurking bugs to erase and shortcuts which I put into this proof of concept.

PS: Why no Vulcan instead of OpenGL? Simple answer, my PC is so old, the graphics driver does not know about Vulcan and I cannot use it.

isidoro

Question is: if going OpenGL, why don't just render 3D and forget all the tile mess.  All front-back ordering, artifacts, etc. would be handled by OpenGL itself.

There can be a default train, bus, plane 3D model that would appear if no 3D model exists in the pakset.

_Hajo_

I think Ters tried that in his approach.

https://forum.simutrans.com/index.php/topic,11796.0.html

I am a 2d guy. I'll not try to lift Simutrans to full 3D. But see. If I could do it ion 4 days, anyone can, right? So anyone can to the 3D thing in only a little time.

I have no good answer. All my experience is with isometric games and using OpenGL with that. I am also not good for really big projects anymore, I have lost all endurance. So I'll keep the Simutrans rendering with 2D tiles and expand the quality of the rendering with colors, lights and transparency.

Also I am old now. You do not teach an old horse new tricks. Sorry.

PS: I think that most artifacts can be solved in 2D. No need to go full 3d for that unless you also want to make 3D models for all buildings and vehicles.