Skip to content

ModifyDisplayText class for inserting/replacing terminalnode displaytext#63

Draft
darmuh wants to merge 2 commits intoTeamXiaolan:mainfrom
darmuh:ModifyDisplayText
Draft

ModifyDisplayText class for inserting/replacing terminalnode displaytext#63
darmuh wants to merge 2 commits intoTeamXiaolan:mainfrom
darmuh:ModifyDisplayText

Conversation

@darmuh
Copy link
Contributor

@darmuh darmuh commented Feb 3, 2026

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.

Also added and tested some additional public methods for manual add/removal of text at runtime using the class
@XuuXiaolan
Copy link
Collaborator

Does this include custom terminal nodes? A question before I read the code (i.e. simulate by LLL)

@darmuh
Copy link
Contributor Author

darmuh commented Feb 3, 2026

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)

@XuuXiaolan
Copy link
Collaborator

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?
i.e. edit the help command but i edit the text to something else every other quota day, is that possible or is it fixed onto one edit until i reload?

@darmuh
Copy link
Contributor Author

darmuh commented Feb 3, 2026

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? i.e. edit the help command but i edit the text to something else every other quota day, is that possible or is it fixed onto one edit until i reload?

You can manually do this by saving a reference to the instance of the ModifyDisplayText class and running RefreshAddedTextNow at every other quota day (or however often you want) so long as your IProvider has the logic to update to whatever you want your text to display at that time.

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

@darmuh
Copy link
Contributor Author

darmuh commented Feb 3, 2026

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)

@XuuXiaolan
Copy link
Collaborator

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

@darmuh
Copy link
Contributor Author

darmuh commented Feb 3, 2026

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 🫡

@darmuh
Copy link
Contributor Author

darmuh commented Feb 3, 2026

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 Terminal.TextPostProcess

@XuuXiaolan
Copy link
Collaborator

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that sounds like a headache to you I can go about fixing it before you get deep into this stuff

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go for it, im going to head to class soon anyway so take your time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@darmuh darmuh marked this pull request as draft February 3, 2026 11:05
@XuuXiaolan
Copy link
Collaborator

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
Cuz this type of thing is already super similar and it doesn't feel right to create something new just for that instead of incorporating it here
Modded terminalnode support would be nice too, i.e. being able to edit the simulate node.
Id also like to see if we can consolidate a lot of these last few PR's together into the DawnLib format (DawnLib.DefineTerminalCommand) but I can do that part myself

@XuuXiaolan
Copy link
Collaborator

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 NamespacedKey

@darmuh
Copy link
Contributor Author

darmuh commented Feb 3, 2026

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants