RimWorld

RimWorld

Xml Patch Helper
73 Comments
cyanobot Feb 21 @ 9:04am 
Thank you for many diagnosed typos, invaluable tool.
Smash Phil  [author] Sep 28, 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 Sep 28, 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 Sep 10, 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 Sep 10, 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] Sep 10, 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] Sep 10, 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 Sep 10, 2024 @ 11:26am 
Yeah, there's something weird going on here: `<color=#3CBEF0FF><<i></i>/def></color>`
aikixd Sep 10, 2024 @ 11:14am 
Same issue as @Jesse - color tags are shown as literals. Path: `Defs/BodyDef[defName="Bird"]`
Smash Phil  [author] Aug 12, 2024 @ 1:32am 
doesn't matter
Carxofing Aug 11, 2024 @ 5:45pm 
What is the best position of Xml Patch Helper in the mod list? At the beginning or at the end?
Mana Jul 19, 2024 @ 12:43pm 
I'm late to the modding game and want to thank you PROFUSELY for sharing this. Lifesaver.
Carxofing May 30, 2024 @ 3:10am 
@smash Phil Thanks:steamthumbsup::steamdance:
Smash Phil  [author] May 19, 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 May 19, 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 May 4, 2024 @ 1:03pm 
@Rokuni Try paying attention to the pictures....
Rokuni Apr 30, 2024 @ 4:03pm 
is there a guide or something? once i click on it there's no xml whatsoever
Jesse Apr 21, 2024 @ 12:35am 
I was looking at the BodyDef for snakes.
Smash Phil  [author] Apr 20, 2024 @ 12:55am 
I'll look into it. Which body def?
Jesse Apr 20, 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] Apr 11, 2024 @ 6:31pm 
Updated to 1.5
The Blind One Mar 10, 2024 @ 7:28pm 
Roger that, thanks for the clarification.
Smash Phil  [author] Mar 10, 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 Mar 10, 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 Mar 9, 2024 @ 6:46pm 
Is there a video on this? Would be nice to see this running as an example
Ixcatl Mar 4, 2024 @ 12:46pm 
really helpful little piece of kit to remind me how to work with this shit. thank you!
CTH2004 Nov 19, 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] Sep 26, 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 Sep 26, 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] Sep 26, 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 Sep 26, 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 Sep 10, 2023 @ 10:05am 
Extremely helpful mod, thanks!
Smash Phil  [author] Aug 8, 2023 @ 7:05pm 
You're gonna have to elaborate, I'm not sure what you mean
Codingale Aug 8, 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 May 21, 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
Rhaza Apr 4, 2023 @ 1:51am 
What a useful mod for creating patches!
sel Jan 29, 2023 @ 3:03pm 
thank you for this mod! this helped immensely in understanding how to make patches.
klvlt Jan 12, 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] Jan 8, 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 Jan 8, 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 Nov 29, 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] Nov 13, 2022 @ 3:34pm 
Ask in the RW discord server, not here.
Sayori Nov 13, 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] Nov 3, 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 Nov 3, 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.
Nepenthe Oct 27, 2022 @ 5:23pm 
I think you just saved me approximately two days of banging my head against a wall before realizing my xml patch was one character off - big thanks!
[The] Force Aug 23, 2022 @ 5:42pm 
Oh. My. God. Thank you. I've been trying to make a super presumably simple patch for a week (realistically only bout 4-5 hours of work) and this will help me figure out so much way faster than just comparing code jesus
Smash Phil  [author] Aug 9, 2022 @ 1:25pm 
Yea, pretty good suggestions. I have a few things in mind I'd like to add whenever I have time to work some more on this. Right now I'm busy with the vehicle framework but I'd like to revisit and add some additional features in the future
quin Aug 9, 2022 @ 10:09am 
Pretty neat little tool, hopefully it'll make XML less "scary" for newcomers.

I'd love two things added to it:
- an option to paste in your patch xml as a way to check if everything is correct instead of loading the game time and time again to test your patch
- making it so that clicking on a node in code window would add it to xpath or maybe some other method of navigating with the GUI, but thats waaaay more work :)
Smash Phil  [author] Aug 8, 2022 @ 7:36pm 
@teika ...? no.