FyroxEngine / Fyrox

3D and 2D game engine written in Rust
https://fyrox.rs
MIT License
7.64k stars 343 forks source link

Various TextBox / UI issues #361

Closed martin-t closed 4 months ago

martin-t commented 2 years ago

This is a summary of the issues i can into when implementing an in-game console. Most have already been mentioned on discord.

TextBox:

Text:

The whole UI:

Nice to have:

The Fyrox book:

mrDIMAS commented 2 years ago

@martin-t Could you please re-check issues with text box (and maybe other stuff) and mark them with Fixed (or similar) tag? I think I fixed most (if not all) of them.

As for StackPanel: stacking from the bottom up - it is already possible: set vertical alignment of the panel to Bottom and stack panel's orientation to Vertical.

martin-t commented 2 years ago

I updated the issue. All major issues are fixed, the rest is mostly papercuts, my console is fully usable (and i'll soon separate it into a reusable crate).

Thanks for the info about stack panel, that works too.

mrDIMAS commented 2 years ago

It only works if i click on the last letter but if i increase the TextBox's width and click to the right of the text, it doesn't move the cursor. should be fixed now.

CTRL+arrow to skip words is added too.

mrDIMAS commented 2 years ago

@martin-t what is meant by A way to set which chars are considered non-word chars.?

martin-t commented 2 years ago

@martin-t what is meant by A way to set which chars are considered non-word chars.?

I'd like to be able to set chars like - and _ to be treated like whitespace. It could be hardcoded but some people might not like that so i figured it would be best to make it configurable. Motivation is so that when i have cvars named such as g_balance_machine_gun_explosion_damage, it would be nice to skip words with ctrl+arrow.

BTW noticed a tiny annoyance with ctrl+arrow - it doesn't reset the cursor's blinking state to visible - if you press ctrl+arrow several times when the cursor is not visible, it feels like it disappeared completely because each press seems to reset the timer.

mrDIMAS commented 2 years ago

It turned out that you found not all issues 😄 . There were tons of them, text box was bugged as hell.

martin-t commented 2 years ago

If it makes you feel any better, just recently i ran across this quote:

There’s so much work involved in making a fully functional text input box that it is something of a litmus test for how far along a UI toolkit has gotten.

Anyway, one of your commit messages mentioned wrap which reminded me that word wrap is also broken (i tested text widget but likely also for textbox). :P

mrDIMAS commented 2 years ago

CTRL+SHIFT+arrow to select words done in https://github.com/FyroxEngine/Fyrox/commit/a6038b2c2bb38a4536f17013b1b926bad8c06b84

Explicitly state that there's no way to subscribe to events when creating widgets is done in https://fyrox-book.github.io/fyrox/ui/basic_concepts/basic_concepts.html#message-passing

mrDIMAS commented 2 years ago

@martin-t What do you mean by Shadows in one of your requests?

martin-t commented 2 years ago

@martin-t What do you mean by Shadows in one of your requests?

Drawing the text one more time with an offset like this image

It's useful to make text stand out because no matter what color there are always gonna be environments where it's hard to see. Some games even draw an outline around the whole text: image

I am not sure which would be better or easier to implement.

mrDIMAS commented 2 years ago

Wouldn't it be enough to just use a font with built-in outline? You can check one from here for example.

mrDIMAS commented 2 years ago

@martin-t I added shadows, please check if that's what you need.

mrDIMAS commented 2 years ago

Skip chars list is added too.

mrDIMAS commented 2 years ago

Alright, major issues are fixed, the rest of improvements will be done later. I'm already a bit tired of fixing these issues, wanna focus on something else.

martin-t commented 2 years ago

@martin-t I added shadows, please check if that's what you need.

Yup. I am using dilation 0 and offset [1,1] because that seems to give the most legible results for me.

I don't think dilation can be used to achieve the effect in my second example if that's what you intended. Dilation just makes the shadow bigger, the outline effect would require some kind of filter to make neighboring pixels dark. It could be hacked together by applying 4 shadows with the 4 possible diagonal offsets, maybe... But it's not important, the single 1 pixel shadow is what i wanted originally anyway, i only gave this as an example how it makes the text easier to read.

I'm already a bit tired of fixing these issues, wanna focus on something else.

That's understandable. I didn't expect you to fix so many of them at such a speed. :)

My console works pretty well now, so when i publish the crate hopefully it'll bring some more attention to fyrox.

mrDIMAS commented 4 months ago

The rest of the issues (most of them) should be fixed by now.