Amazing mod, I applaud your technical prowess. This is going to be a great example of how to extend vanilla functionality in a way Alex didn't expect.
The more orthodox way of it would probably be via a MapAwareDialog class extending RuleBasedInteractionDialogPluginImpl, and hooking it via rules.csv. Still, can't guarantee it would work as well as yours. This would avoid having to inject it mid-way, and having to deal with reflection (which I find your use of really educational, especially the trick with OptionDelegateProbe).
Either way, great stuff. Been feasting on your code for a while now
Thank you for your kind words! Yeah, now that I think about it, extending
RuleBasedInteractionDialogPluginImpl is definitely less hacky than my approach. Although it probably wouldn't save me much time, since constructing and configuring the map component is the much more difficult part. Without a proper API there's no way to completely avoid reflection, unfortunately.
Actually, my original attempt is even more extreme: I thought the only way to modify the UI is using javaagent + ASM to inject bytecode, like what Minecraft mods do… Fortunately I quickly found out there's a thing called
reportShownInteractionDialog() that can potentially make it work using "just" reflection, so that's good I guess. The half-written code for that approach can be found in the "javaagent" branch of the repo, if anyone's interested.