RimWorld

RimWorld

Xml Patch Helper
78 Comments
Proxyer 19 Jun @ 3:35am 
YES! YES! Ty update!! Making patches just got easier!
Aria Victoria 18 Jun @ 11:18pm 
TY <3
Aria Victoria 18 Jun @ 7:39pm 
Oh, I guess the github link is old? Last update on the repo is showing as last year.
Smash Phil  [author] 18 Jun @ 7:33pm 
Oh yea sorry, this is already updated to 1.6 I just haven't pushed it to steam.
Aria Victoria 18 Jun @ 7:15pm 
No rush (As I know you're already super busy as it is), but, is there any chance of a 1.6 version? I've only been without it for a few days and am already looking at the mod page longingly.
cyanobot 21 Feb @ 9:04am 
Thank you for many diagnosed typos, invaluable tool.
Smash Phil  [author] 28 Sep, 2024 @ 5:38pm 
This isn't really set up to test those, but the concept would be the same as just trying to add that single <li/> node. The point is being able to quickly validate that your xpath is correct and that you're inserting the value exactly where you want it. Nested nodes or not, it would be the same.
123nick 28 Sep, 2024 @ 6:40am 
How do you test a patch that adds multiple layers of nodes to a node?

For example, when theres a weapon that has a "costList" field, and each node below it is <ResourceName>x</ResourceName>, where X is the count of resources, then its easy to just add one using the node and value fields this mod has

But if im trying to add an ingredient to a recipedef, to the <ingredient> node, each ingredient is layed out as such:
<li>
___<filter>
________<thingDefs>
__________________<li>ComponentSpacer</li>
________</thingDefs>
___</filter>
___<count>6</count>
</li>

How do i test a patch that adds the li node AND its child nodes to the ingredients node?
aikixd 10 Sep, 2024 @ 10:31pm 
Here's a larger samples with coloration removed:
<li></color>
<def></color>Spine</color><<i></i>/def></color>
<coverage></color>0.05</color><<i></i>/coverage></color>
<depth></color>Inside</color><<i></i>/depth></color>
<<i></i>/li></color>
aikixd 10 Sep, 2024 @ 10:30pm 
Yeah, it's a malformed tag. I'm no modder, but a sw dev. If you can point me, I can try to find the source. It seems that `<i></i>` it pushed after the tag opener on an ending tag. If you remove that, then the ending tag becomes correct: `</def>`. When I find-replace `<i></i>` -> ``, the document becomes well formed.
Smash Phil  [author] 10 Sep, 2024 @ 12:06pm 
As an FYI you have
<li>
< (this is the invalid character)
</li>
in your results. Which is no good
Smash Phil  [author] 10 Sep, 2024 @ 12:05pm 
That’s usually when the result has some symbol I didn’t account for. The coloration of the text is just rich text, so if some symbol closes the rich text brackets prematurely then you’ll see those brackets instead of their color effect.

In this case, < is one such symbol. Not sure what def has that as input, it’s already a reserved character in xml.
aikixd 10 Sep, 2024 @ 11:26am 
Yeah, there's something weird going on here: `<color=#3CBEF0FF><<i></i>/def></color>`
aikixd 10 Sep, 2024 @ 11:14am 
Same issue as @Jesse - color tags are shown as literals. Path: `Defs/BodyDef[defName="Bird"]`
Smash Phil  [author] 12 Aug, 2024 @ 1:32am 
doesn't matter
Carxofing 11 Aug, 2024 @ 5:45pm 
What is the best position of Xml Patch Helper in the mod list? At the beginning or at the end?
Mana 19 Jul, 2024 @ 12:43pm 
I'm late to the modding game and want to thank you PROFUSELY for sharing this. Lifesaver.
Carxofing 30 May, 2024 @ 3:10am 
@smash Phil Thanks:steamthumbsup::steamdance:
Smash Phil  [author] 19 May, 2024 @ 6:49am 
You don’t have to compile anything. Harmony is a dependency, so you’ll need to download that mod on the workshop which will come with a pre compiled dll.
Carxofing 19 May, 2024 @ 6:46am 
@Smash Phil I downloaded the mod from github and now I was reading the readme file. I just can't figure out how to compile the Harmony file or what program to do it with. I would appreciate it if you could tell me how to do it.
The Dutchman 4 May, 2024 @ 1:03pm 
@Rokuni Try paying attention to the pictures....
Rokuni 30 Apr, 2024 @ 4:03pm 
is there a guide or something? once i click on it there's no xml whatsoever
Jesse 21 Apr, 2024 @ 12:35am 
I was looking at the BodyDef for snakes.
Smash Phil  [author] 20 Apr, 2024 @ 12:55am 
I'll look into it. Which body def?
Jesse 20 Apr, 2024 @ 12:02am 
There seems to be some kind of glitch when looking at BodyDefs with the patch helper in 1.4. Everything inside the codeblock turns grey with the color tags showing.
Smash Phil  [author] 11 Apr, 2024 @ 6:31pm 
Updated to 1.5
The Blind One 10 Mar, 2024 @ 7:28pm 
Roger that, thanks for the clarification.
Smash Phil  [author] 10 Mar, 2024 @ 5:53pm 
That’s intentional, since it would be arbitrary which patches do or don’t apply to the xml shown in the window. It would end up being confusing without additional UI
The Blind One 10 Mar, 2024 @ 12:37am 
So I was using this tool but it doesn't seem to recognize when a patch has patched another mod.

For example;

I have a mod that adds a building to the game
I then have a mod that patches that building's defs to some degree.

Now if I use this tool to check the def of that building, it shows the original def values of the building but not the actual in-game defs as when the patch is applied.

It's a minor thing but it got me confused for well over two hours thinking my patch didn't apply :lunar2019crylaughingpig:
Monkey Magic 9 Mar, 2024 @ 6:46pm 
Is there a video on this? Would be nice to see this running as an example
Ixcatl 4 Mar, 2024 @ 12:46pm 
really helpful little piece of kit to remind me how to work with this shit. thank you!
CTH2004 19 Nov, 2023 @ 11:56am 
Just to double check, this is soeley for debuging, so it won't be necessary as a requirment if used to assist in creation?

I'm pretty sure that's accurate, just double checking! Thanks!
Smash Phil  [author] 26 Sep, 2023 @ 2:03pm 
well it wouldn't be a one liner fix, but knowing that it's just not picking up the type certainly helps. The xpath field would need to be fetched via reflection. The mod is open source btw, github link is in the description if you'd like to submit a PR, but it might be a good idea to chat with me on discord before you do that so you don't take an approach that wouldn't be acceptable.

Just ping me if you decide to work on it yourself, I'm open to PRs on all my mods as long as the code is solid and there aren't any potentially performance ruining changes.
Malnormalulo 26 Sep, 2023 @ 1:46pm 
I totally understand. I took a quick look, and it seems the problem is that you're retrieving subclasses of PatchOperationPathed, while XML Extensions directly extends PatchOperation to add some extended functionality. Its pathed operations still have a String field named xpath, though, and it looks like that's all you're really relying on, so this might be a one-line fix (or nearly – might need to handle operations without an xpath field differently).

Hopefully that bit of digging helps. If implementing it and testing it is still a ways off with that figured out, I could try to submit a PR. Probably about time I get around to setting up an environment for C# development anyway.
Smash Phil  [author] 26 Sep, 2023 @ 12:41pm 
I can look into it when I have time, but it likely won't be any time soon. I'm incredibly busy. If their patches aren't working by default, then they might require some special handling.
Malnormalulo 26 Sep, 2023 @ 10:15am 
The dropdown of different patch operations includes various ones added by other mods, but the patches added by XML Extensions aren't listed. Any chance of enabling support for these? I'm currently debugging an issue using one of those operations where this tool would be super helpful.
Auld 10 Sep, 2023 @ 10:05am 
Extremely helpful mod, thanks!
Smash Phil  [author] 8 Aug, 2023 @ 7:05pm 
You're gonna have to elaborate, I'm not sure what you mean
Codingale 8 Aug, 2023 @ 6:38pm 
Hey is it possible to have it cache the playmode fetch? Or would that result in a large amount of memory used in the runtime? Thanks for this mod, so much easier now
Marcy 21 May, 2023 @ 3:29pm 
this finally helped me actually figure out how xpaths worked and saved me hours of frustration, i owe this mod my life
Harbinger 4 Apr, 2023 @ 1:51am 
What a useful mod for creating patches!
sel 29 Jan, 2023 @ 3:03pm 
thank you for this mod! this helped immensely in understanding how to make patches.
klvlt 12 Jan, 2023 @ 4:45am 
This mod has been (and still is) immensely helpful to me while learning the mysteries of the xpath. Thank you so much for creating and sharing it!
Smash Phil  [author] 8 Jan, 2023 @ 12:09pm 
@Kaedys Yea, this is intentional otherwise I would have to determine the execution order of the mod list's patches based on where Xml Patch Helper is in the list. In the future I may add some menu to toggle which mods to execute their patches but this is a bigger task than you think and I'm very pressed on personal time already.

So to answer your question, no. This is strictly the combined xml doc before inheritance and before any xml patches. Maybe in the future when I have more time
Kaedys 8 Jan, 2023 @ 11:39am 
Seems like the XML is sees is *before* patches are applies. For example, I have a patch that modifies the leatherdef of a bunch of animals (my own local frankenstein of the various Optimized Leather mods), including one that patches out every usage of, say, Leather_Rhinoceros. I know this is working, because the game does not complain about a missing def for a Race wanter, and the animals in question drop the altered leather def. Yet when I search for "Defs/ThingDef[race/leatherDef="Leather_Rhinoceros"]", it shows me all of the original defs that had it. Is there a way for the mod to show me the XML as it exists *after* all of the existing patches are applied?

It makes it annoyingly difficult to use the mod to test a new patch, since I cannot build off of any existing patches. With Unified XML Export defunct, this appears to be the best window into the XML available, but if it only shows me the XML before patches are applied, that usefulness is rather more limited than I'd like.
The Blind One 29 Nov, 2022 @ 11:45am 
Ayo thanks for this mod, figured out how to do a few xpath patches thanks to the tool saving me a lot of time and work <3
Smash Phil  [author] 13 Nov, 2022 @ 3:34pm 
Ask in the RW discord server, not here.
Sayori 13 Nov, 2022 @ 1:00pm 
Help, I tried looking for a fix but cant find one. Debug log says:

Unexpected element in patch XML; got mods, expected 'Operation'

[Lunarframework v1.0.3] Failed to load 'Geological Landforms' because component is in state 'initailized'

[Lunarframework v1.0.3] Failed to load 'Map Preview' because component is in state 'initialized'
Smash Phil  [author] 3 Nov, 2022 @ 10:41am 
@Victor This is true, although I would need to use my own text box UI element since RimWorld's just extends the text inside the predefined box instead of going down to a new line. I do need to add ctrl + z support though, you're right. Although this will require me looking into how to access the user's clipboard. Should be fine though
Victor 3 Nov, 2022 @ 10:19am 
My only suggestion would be increasing the text box, as it can get pretty messy with big operations. Oh, and if possible, support for Ctrl+Z.