Open axvemi opened 1 year ago
I thought of this too today! It would be very useful. Kind of CSS (well, at least, a style sheet) for BBcode. It could add a new custom tags, or reuse one tag like [style=emphasize]...[/style]
[style=title]...[/style]
to avoid collision with future BBcode commands.
The reason it'd be good to have is that I have a consistent palette in my project and would like to use it in text everywhere, without copy/pasting the markup every time. I'd also like to be able to change it programmatically when the 'mood' changes.
I thought "maybe it can be integrated with the Theme system and type variations" but this wouldn't allow for using custom tags in the styles. So regarding it as "a collection of tags" as you do makes more sense.
I wonder if this could be part of the Theme for bbtext rather than its own resource.
Describe the project you are working on
I'm not currently on a project but playing with the RichTextLabel and Bbcode to know what I can do with it, but I can see it being used on every project that wants to use these two things.
Describe the problem or limitation you are having in your project
As you probably know, in a RichTextLabel you can have multiple tags. For example [b], [i], or your own custom tags, and apply some variables to them.
The problem comes when I want to use multiple of these in other places, I have to each time have the same setup with the same variables. For example, if in one place I use
[b][i][myOwn variable=40] Hello World [/b][/i][/myOwn]
I do have to use the same setup in every place, and update it if I change a variable, add or remove a tag etc...Describe the feature / enhancement and how it helps to overcome the problem or limitation
Instead of having to write all the tags that you want to use, with those variables, you could define in a resource or something a collection of Bbcode tags, in order, and with it's variables.
That would generate a new tag that would apply all of those effects to the tex that you place inside it.
If you want to add a new effect, or edit a variable of one of those tags in the collection, you would edit it inside the collection, so it takes that value in every place that you use that collection tag.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Let's say that you use this example :
[b][i][myOwn variable=40] Hello World [/b][/i][/myOwn]
You would define in the resource, or whatever, the list of tags that you want to use and it's values. Ie: collection1: [b] [i] [custom speed = 10]
And then you would use it like this:
[collection1] Hello World [/collection1]
If this enhancement will not be used often, can it be worked around with a few lines of script?
You can copy paste the same setup in every place, but it's tedious and if you change something, you have to change it everywhere. An alternative is creating a custom tag that implements all of those effects.
Is there a reason why this should be core and not an add-on in the asset library?
I don't think it's possible, but correct me if I'm wrong.