Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RichTextLabel: highlighting and redacting #367

Closed
CawawaC opened this issue Jan 8, 2020 · 3 comments
Closed

RichTextLabel: highlighting and redacting #367

CawawaC opened this issue Jan 8, 2020 · 3 comments
Milestone

Comments

@CawawaC
Copy link

CawawaC commented Jan 8, 2020

Describe the project you are working on

I'm currently working on a text-driven game. Part horror investigation, par turn-based RPG. Text formatting is absolutely essential because there are almost no images, all interactions happen with the text, and all the information is held in the text while being highlighted in proper ways in order to guide the player. Also, all the events that take place during play happen, you guessed it, to the text.

Describe the problem or limitation you are having in your project

I need a way to bring forward certain words in the text. I need them as eye-popping as possible.
Also, and this is a related addition, I need to be able to dynamically obscure text. Some displayed texts need to be obscured when the player is missing information.
All this without using an image of a text, since text is generated, and I need it to be dynamic (be able to change the content in real time and modify the style of individual words, and be able to have parts of it hoverable and clickable).

Describe how this feature / enhancement will help you overcome this problem or limitation

Highlighting text is arguably the most eye-popping text styling option. It is a great way to bring forward crucial information, like enemy names in my game.
Redacted text is part of investigation visual tropes, that's why I'm looking to reproduce it, and am choosing it as the way my game will obscure parts of a text.

Show a mock up screenshots/video or a flow diagram explaining how your proposal will work

Highlighted text:
Capture
Redacted text :
redacted

Describe implementation detail for your proposal (in code), if possible

Unfortunately, I'm not familiar enough with the inner working of text styling in the Godot source. But hightlighting could be a BBCode tag. Or perhaps RichTextEffect could take care of this. Since highlighting is actually painting the background of a character, BBCode tags for highlighting could look like this:

[background=yellow]highlighted text[/background]
or
[bgcolor=yellow]highlighted text[/background] which seems more common.

As for redacted text:
[redacted]redactedtext[/redacted]
Which would paint a black color over the text. And would probably need to remove the actual characters, so they can't in any way be selected. It is basically the same as highlighting, but color is painted over the text, and not under it. So we could also make it more generic:
[overlay=black]redacted text[/overlay]
I tried using a RichTextEffect to replace tagged letters with the full block character █ but no luck: there's space displayed instead of the characters. And replacing the letters this way does not remove them (selecting, copying and pasting reveals they are still there).

If this enhancement will not be used often, can it be worked around with a few lines of script?

Probably not. At least, I don't see how you could alter the background color of certain characters within a text node using only scripts.

Is there a reason why this should be core and not an add-on in the asset library?

If there's a way to make this into an addon, I don't see why not. But it's not a heavy addition, and only expands upon common text styling options to make RichTextLabel more versatile.

@CawawaC CawawaC changed the title RichTextLabel missing features RichTextLabel additional features Jan 8, 2020
@Calinou

This comment has been minimized.

@Calinou Calinou closed this as completed Jan 8, 2020
@CawawaC CawawaC changed the title RichTextLabel additional features RichTextLabel: highlighting and redacting Jan 8, 2020
@Calinou Calinou reopened this Jan 8, 2020
@KoBeWi
Copy link
Member

KoBeWi commented Jun 20, 2021

@CawawaC godotengine/godot#35608 added foreground and background text for RichTextLabel, however the "redacted" text needs some workarounds to be unselectable. Does that satisfy the proposal though?

@CawawaC
Copy link
Author

CawawaC commented Jun 25, 2021

Oh perfect! Thanks for pointing this PR out to me :)

@CawawaC CawawaC closed this as completed Jun 25, 2021
@KoBeWi KoBeWi added this to the 4.0 milestone Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants