Adding new RichText features without having to modify the plugin code
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
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
-
sfernandez
Site Admin
- Posts: 3093
- Joined:
Re: Adding new RichText features without having to modify the plugin code
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:
Would generate something like:
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.
Code: Select all
[action='ClosePage']
Code: Select all
<Button Command="{Binding ClosePage}"/>
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.
Re: Adding new RichText features without having to modify the plugin code
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 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".
I will create a ticket for this matter.
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
Code: Select all
TryCreateInlineForTag(...)
I think that would be good enough too.In the past we thought of having a callback that users can set to extend TryCreateInlineForTag and TryParseSpanForTag functions.
I will create a ticket for this matter.
-
sfernandez
Site Admin
- Posts: 3093
- Joined:
Re: Adding new RichText features without having to modify the plugin code
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.
Thanks for the ticket, we will solve it for the next release so it is easier to extend with custom tags.
Re: Adding new RichText features without having to modify the plugin code
Sounds great. Thanks!
Who is online
Users browsing this forum: No registered users and 5 guests