ModifyDisplayText class for inserting/replacing terminalnode displaytext#63
ModifyDisplayText class for inserting/replacing terminalnode displaytext#63darmuh wants to merge 2 commits intoTeamXiaolan:mainfrom
Conversation
Also added and tested some additional public methods for manual add/removal of text at runtime using the class
|
Does this include custom terminal nodes? A question before I read the code (i.e. simulate by LLL) |
No anything that modifies the terminal display at runtime this cannot touch. This includes LLL's terminalevent based commands as well as DawnTerminalCommands that use a Func to update the text output at runtime For something like that it'd have to be refreshing each time the terminal loads (which would be more appropriate via a hook in Terminal.TextPostProcess) Totally possible, but I think should be separated from this sort of thing which only really needs to be run once (or manually an extra couple times during runtime if the api user wants to) |
|
hmm okay, another quick thing, i should really read this PR but this is easier, does this allow me to dynamically change text based on conditions i set or whatever? |
You can manually do this by saving a reference to the instance of the ModifyDisplayText class and running I avoided adding custom events to this one because it seemed to add a niche layer of complexity I didn't think was worth it. If you have a different opinion though, I don't mind rewriting some of this or changing some things |
|
I also tried to explain that sort of niche use case in the xml comments (they're a lot more detailed than my past PRs, something I plan to double back on maybe later this week) |
|
I think I have some ideas of how I'd want to implement this for a more DawnLib way, the impl will be what you wrote but I'll include it as a submodule of DawnTerminalCommands and add a method to refreshing into that submodule, that sound good? It'll give me a reason to also make it editor friendly |
sounds good, i'll leave it to you since you've got a specific vision in mind Will be here to assist as needed 🫡 |
|
just remember the main purpose behind this class was to modify result text for static vanilla style nodes once or twice per run time (ie. help, other, the start screen, etc.) So if you're using it to modify the output of dawnterminalcommands, it's not really necessary since we're already doing that with the Func And if you're changing the text frequently it'd be better done via an addition to |
|
dw its not to modify the output of dawnterminalcommands, it'll be a part of it so that it can be referenced super easily |
| return; | ||
|
|
||
| DawnPlugin.Logger.LogMessage($"Removing inserted text [{_textActuallyAdded}] from node - {ResultNode.name}"); | ||
| ResultNode.displayText = ResultNode.displayText.Replace(_textActuallyAdded, string.Empty); |
There was a problem hiding this comment.
wouldn't this just not work if it's a Replace style? it'll run but it won't properly bring the result node back to how it original was
There was a problem hiding this comment.
yeah you're right. Replace style was added after I realized there'd be a use case for completely replacing text and this is def an oversight of mine.
Probably need to cache any text that's removed as well as the style that was used at modification and change this to a switch based on the cached style.
There was a problem hiding this comment.
if that sounds like a headache to you I can go about fixing it before you get deep into this stuff
There was a problem hiding this comment.
go for it, im going to head to class soon anyway so take your time
There was a problem hiding this comment.
prob won't get to it any time soon but yeah I don't think this PR needs to be rushed at all. Marking the PR as draft to not confuse ourselves
|
Yeah I do think there could be a lot of changes to this that'd be nicer honestly, being able to edit the display text at any time would be pretty helpful, basically running a Function on it everytime it's accessed |
|
Overall, and this is a lot harder to setup and I'll try to, every terminalnode should be put into the DawnTerminalCommand registry, vanilla or modded, and replacing a command in any way would be as simple as referencing it's |
|
I think I'll just scrap the actual modification of the displaytext for a method that utilizes TextPostProcess then. It feels like a safer way to modify the result without making damaging/permanent changes to the terminal node |
This new class safely handles replacing/inserting additional text to a resulting terminalnode's displaytext at terminal start.
Can also be refreshed/removed manually any time at runtime.
The added text is then removed on terminal disable (and subsequently readded at next terminal start)
This class does NOT constantly modify/update the text at runtime, that would best be handled by adding to the vanilla Terminal.TextPostProcess method via a different class (in my opinion).
There is further detailed xml comments for more information on what each thing does.