vmaurer
Topic Author
Posts: 17
Joined: 21 Jul 2022, 17:44

Adding new RichText features without having to modify the plugin code

09 Jan 2024, 15:46

Hi, in our project we make use of the RichText structure to embed buttons used by input actions into text. In order to do so, we have added custom code to the TryCreateInlineTag function, checking for a tag named "action". Then, an interface implemented by the data context of the TextBlock is used to "access" core project systems in order to determine the button currently used by that action.

The solution works quite well, but we still don't like it for several reasons:
- We had to modify the original plugin code -> It would be nice to keep the plugin clean in its original state, since it would also save a lot of trouble with merging when upgrading Noesis
- The header and source files of the interface mentioned before are also part of the plugin

Ideally, the functions declared in RichText.cpp should be exposed as overridable members to the RichText class, so it's possible to write a custom one based on that outside of the plugin.
But I'd be happy to hear other suggestions as well.

Best Regards
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: Adding new RichText features without having to modify the plugin code

10 Jan 2024, 12:06

If I understood correctly you are defining a new tag "action" to create an inline button in the text. I think no interface would be needed for this, it could be a simple action name that is used as the command binding of the button. For example:
[action='ClosePage']
Would generate something like:
<Button Command="{Binding ClosePage}"/>
Could that work in your case?

Anyway, could you please create a ticket (private if you need it) attaching what you are doing and what is your proposal to make it extensible? In the past we thought of having a callback that users can set to extend TryCreateInlineForTag and TryParseSpanForTag functions.

Thanks.
 
vmaurer
Topic Author
Posts: 17
Joined: 21 Jul 2022, 17:44

Re: Adding new RichText features without having to modify the plugin code

10 Jan 2024, 17:36

Sorry, I should have been more specific. By 'buttons' I meant the inputs on gamepad, mouse and keyboard.

To bring in a little bit more context: We have various text lines telling the player what input they need to press in order to perform a certain action. One such text line could look like this: Press <action id="Interact" /> to pull the lever. We added some custom code to
TryCreateInlineForTag(...)
to parse the action tag. The id-Parameter refers to an enhanced input action that needs to be resolved into an icon of the corresponding input, but the resolver is part of our core module, so we can't access it from within the Noesis plugin. As a workaround, we added an interface to "communicate with the resolver".
In the past we thought of having a callback that users can set to extend TryCreateInlineForTag and TryParseSpanForTag functions.
I think that would be good enough too.

I will create a ticket for this matter.
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: Adding new RichText features without having to modify the plugin code

11 Jan 2024, 12:10

Understood, it makes sense then how you implemented it.

Thanks for the ticket, we will solve it for the next release so it is easier to extend with custom tags.
 
vmaurer
Topic Author
Posts: 17
Joined: 21 Jul 2022, 17:44

Re: Adding new RichText features without having to modify the plugin code

11 Jan 2024, 12:57

Sounds great. Thanks!

Who is online

Users browsing this forum: Ahrefs [Bot] and 6 guests