Getting back to retexturing... already hitting problems

Started by jabbamonkey, December 14, 2018, 07:28:46 PM

Previous topic - Next topic

jabbamonkey

Since 1.0 is released, I'm looking to put all of my retextures together into an updated mod (see my old stuff here: https://ludeon.com/forums/index.php?topic=35198.0;topicseen).
Note: I'm a designer, and not a strong programmer - so please use small words when talking "programming".   ;)

I tried to get started with simple texture replacement, but I'm already hitting issues. I started by checking the def file for the texture path, then putting the new image in the correct folder (of my mod), then loading the mod in game. Some images work, and some don't.  See an example issue below... 

For example, I wanted to replace the HEART organ image (the simple box with a cross on it). I went into the def file Items_BodyParts.xml and found the path to be Things/Item/Health/HealthItemNatural

So, I created the image HealthItemNatural.png and placed it below...
JabbamonkeysGraphics\Textures\Things\Item\Health\HealthItemNatural.png
(note: JabbamonkeysGraphics is the mod folder).
The image does not show up in-game (however, I have other images that I've retextured and show up fine).

So, some questions.
1. If I am retexturing, like above, will other mods affect my new image replacement?  So, if I create a HEART box image (mentioned above), and I have another medical mod installed ... will the conflict cause my image replacement to fail?
2. Related to the first question, if I am looking to replace the textures of someone else's mod, do I just need to load my mod before theirs (or after ... not sure about order)? I'm curious if my texture can OVERRIDE theirs.  Or is more involved (i.e. changing Def info)?  I want to know, so I can handle mod conflicts.
3. Any other idea why the example above fails?  I don't think I have any other mods installed related to medicine ... and the images don't show.
4. I replaced the image for Plasteel, using a 64x64 image. The image is skewed when the image shows up in-game (it looks SQUISHED).  Do I need to use another size?  How do I find this out (where do I look)? 


I also have a ton more questions, but will have to get to them later (i.e. replacing the METAL textures with multiple images, masking production benches, etc.)

Thanks for the help.



kwang4

1. If other mods are aimed at retexturing existing rimworld things, yes. There could be conflict as in one mod textures over the other one.

2. Depends on whether the other mod is retexturing objects or creating new ones. (Like if they just overrid the textures for "AssaultRifle" that would simply require you to load your mod after theirs. If they made a new object that RW doesn't have, like "Lightsaber" you'd have to go into that mod's Defs folder and manually change the texture path and add your texture to their "Textures Folder".

3. I looked at your previous A17 mod, and I noticed that you didn't have a Defs folder in your mod. This is where I'm a bit shaky, as everytime I override a texture, I copy the whole def file and put it in my mod folder. So basically create a folder called "Defs" right inside your mod folder like:

JabbamonkeysGraphics\Defs

Copy the core file Items_BodyParts.xml into the Defs folder you made. Technically because your texture has the exact same path as the Core, it should be fine now. I didn't even know one could retexture without a Defs folder or without patching, but it's always worked for me to copy the whole file in just to be safe.

4. Plasteel normally is 64x64, so I don't know why its not working. Here's a link to someone who got most of the Core textures for rimworld:https://github.com/RimworldModders/rimworld-assets If you right click on an image, select properties, go to details, it'll list the png size. Could you link the plasteel texture you're adding? Perhaps it might just be the game being weird.

jabbamonkey

Quote from: kwang4 on December 15, 2018, 05:03:49 PM
I didn't even know one could retexture without a Defs folder or without patching, but it's always worked for me to copy the whole file in just to be safe.

My concern is conflicting with other mods ... if I copy over the def file, and another mod has the same def file, then it could cause problems (especially if they are doing MORE than retexturing). So, quick question.... When I "copy the def" file, can I just include the information that I want to change, or do I need to include ALL of the def info for that object? For example, If I just want to replace the texture for the Survival Pack, can I call the object defname and the graphicData...

<ThingDef ParentName="MealBase">
    <defName>MealSurvivalPack</defName>
    <graphicData>
      <texPath>Things/Item/Meal/SurvivalPack</texPath>
      <graphicClass>Graphic_StackCount</graphicClass>
    </graphicData>
</ThingDef>


... and will it pull the rest of the ThingDef info from the core or other mod Def file? ...Or would I need to call ALL of the ThingDef info? 

I'll take a look at the Plasteel thing...

kwang4

Alright, at this point you can do one of two things.

First, if you know exactly which mods you might have conflicts with, copy the def from that mod and replace the texPath there.

The better way to do this is xpathing, which is slightly more complicated. At this point, move your mod so that it's below all other ones. In your mod, make a folder called Patches. Make a new xml file, and use this base code to replace just the texPath:
<?xml version="1.0" encoding="utf-8" ?>
<Patch>

<Operation Class="PatchOperationSequence">

<operations>
<li Class="PatchOperationReplace">
<xpath>Defs/ThingDef[defName = "YourItem"]/graphicData/texPath</xpath>
<value>
<texPath>Things/YourPath/YourPath</texPath>
</value>
</li>
</operations>
</Operation>


</Patch>


As for an explanation of the code...
<Patch>
  <Operation Class="PatchOperationSequence">

  </Operation>
</Patch>

Covers the whole operation, like setting up a ThingDef or any RW xml file. Just sorta necessary.

<li Class="PatchOperationReplace">
<xpath>Defs/ThingDef[defName = "YourItem"]/graphicData/texPath</xpath>

"PatchOperationReplace" is just you replacing an existing attribute. There's also other ones that add attributes as well if you wanna get fancy. the <Xpath> part tells you where you want to change. Most things are ThingDefs, that explains "Defs/ThingDef" and defName tells what your def is called. "graphicData" and "texPath" determine what attribute you're modifying. in the Def, all texPaths are encased in the category known as "graphicData".
<value>
<texPath>Things/YourPath/YourPath</texPath>
</value>

Finally, the actual change. the value thing is always necessary, and I thought that the "texPath" part was redundant, but that's the way it was structured.


This ended up being a bit long, but I hope it clarified things for you.


jabbamonkey

Ok, most of the MOD replacement textures are working using the xpathing. There are a few that don't work, but maybe I mistyped something. I'll need to double-check.  Thanks for the help.

Still having problems replacing CORE graphic textures. For example, my new MEDICINE texture isn't showing up when I load the game. So, I tried to use the xpath PatchOperationReplace to replace some of the core textures, but that gave me a TON of errors when I loaded the game. I assume the xpath wont work on CORE textures?

Also, regarding the Plasteel ... should there be a plasteel_a, plasteel_b and plasteel_c image?  (for small, medium and large stacks) Could that be why the image is getting skewed?

Also, any idea how to replace the METAL graphic?  I tried replacing the texture with ONE image, and it shows up as a RED X BOX when metal is placed in LARGE piles.  Small and medium metal piles still show the old graphics. 
     I assume this requires multiple metal images for different stack sizes as well.  Ideally, I'd like to have a single/small image (metal_a) ... then have multiple images selected for medium stacks (metal_b, metal_c, metal_d) ... and then a final image for the large stack (metal_e). Any idea how to do that?

jabbamonkey

In addition to the above ... which is better optimized code ... option 1 ...

<?xml version="1.0" encoding="utf-8" ?>
<Patch>

<Operation Class="PatchOperationSequence">
<operations>
<li Class="PatchOperationReplace">
<xpath>Defs/ThingDef[defName = "YourItemABC"]/graphicData/texPath</xpath>
<value>
<texPath>Things/YourPath/YourPathABC</texPath>
</value>
</li>
</operations>
</Operation>

<Operation Class="PatchOperationSequence">
<operations>
<li Class="PatchOperationReplace">
<xpath>Defs/ThingDef[defName = "YourItemXYZ"]/graphicData/texPath</xpath>
<value>
<texPath>Things/YourPath/YourPathXYZ</texPath>
</value>
</li>
</operations>
</Operation>


</Patch>


... or option 2 ...

<?xml version="1.0" encoding="utf-8" ?>
<Patch>

<Operation Class="PatchOperationSequence">
<operations>
<li Class="PatchOperationReplace">
<xpath>Defs/ThingDef[defName = "YourItemABC"]/graphicData/texPath</xpath>
<value>
<texPath>Things/YourPath/YourPathABC</texPath>
</value>
</li>

<li Class="PatchOperationReplace">
<xpath>Defs/ThingDef[defName = "YourItemXYZ"]/graphicData/texPath</xpath>
<value>
<texPath>Things/YourPath/YourPathXYZ</texPath>
</value>
</li>
</operations>
</Operation>


</Patch>

kwang4

Option one would be better, less code for the game to read.

Here's a little patch mod I made, attached below. outlines the three kinds of Graphics and issues you might encounter. Look through the different way I called the new texture locations in the patch, because there are really weird differences.
Main Points:

  • Graphic_Single only needs you to specify till the containing folder.
  • Graphic_Multi requires you to path inside of your containing folder. Ex: If folder is "Things/Buildings/Stuff", inside of it you'll have: Stuff_north, Stuff_east, Stuff_south. Your xpath for texturepath: "Things/Buildings/Stuff/Stuff
  • Graphic_StackCount is like Graphic_Single but you need: "ItemName_a" and "ItemName_b" in there.
The important thing is to make sure your path is right, because otherwise you'll keep getting errors.


As for metal textures, I really don't have much experience in stuff that detailed, I just know the basic structure of this stuff.

Also really sorry about the long response time, got caught up in life for a bit.

[attachment deleted due to age]

jabbamonkey

Quote from: kwang4 on December 19, 2018, 08:42:58 PM
Here's a little patch mod I made, attached below.

Thanks. I checked out your files...  Based on your example, I tried replacing a texture... Below is the xpathing for the SimpleProstheticArm that I am using. 

<Operation Class="PatchOperationInsert">
<xpath>Defs/ThingDefs[DefName = "SimpleProstheticArm"]/graphicData/texPath</xpath>
<value><texPath>Things/Item/BodyPart/SimpleProstheticArm</texPath>
</value>
</Operation>


Note: All of the simple prosthetics use a SINGLE image. I am trying to use a custom image for EACH prosthetic (i.e. Arm, Leg, Eye). Will I need to add something to the xpathing to fix this?

Below is the exact PATH for the SimpleProstheticArm...
JabbamonkeysGraphics\Textures\Things\Item\BodyPart\SimpleProstheticArm.png

kwang4

 SimpleProstheticArm doesn't actually write out its own graphic information. Rather, like you stated, all prosthetic body parts inherit their texture from a parent thing. That means you have to add the whole chunk of graphicdata into the Def, which means you need PatchOperationAdd, like below

<li Class="PatchOperationAdd">

  <xpath>Defs/ThingDef[defName = "SimpleProstheticArm"]</xpath>
   <value>
     <graphicData>
        <texPath>Things\Item\BodyPart\SimpleProstheticArm</texPath>
        <graphicClass>Graphic_Single</graphicClass>
        <drawSize>0.80</drawSize>
     </graphicData>
   </value>

</li>


I basically copied the bit from BodyPartProstheticBase and changed the path. Do this for all the different body parts and you're all set.

jabbamonkey

#9
Hmmm... that didn't work. I tried the following...

   <Operation Class="PatchOperationAdd">
<xpath>Defs/ThingDef[DefName = "SimpleProstheticArm"]</xpath>
<value>
<graphicData>
<texPath>Things\Item\BodyPart\SimpleProstheticArm</texPath>
<graphicClass>Graphic_Single</graphicClass>
<drawSize>0.80</drawSize>
</graphicData>
</value>
</Operation>

And the path to the image is...
JabbamonkeysGraphics\Textures\Things\Item\BodyPart\SimpleProstheticArm.png

I uploaded the files here...
http://classicgaming.cc/temp/JGraphicsv3.zip

You'll see a few files in the Patches folder. I am trying to have an xml file for EACH mod that I am using. You'll notice a Patches.xml file (which has the games default graphics edits) and MedPatches.xml (which has a mod's medical texture modifications).

kwang4

I went through the files and changed a few things. Most of it was good, you just had a few small errors hiding throughout your files that caused the failures.

1. The character "*" should be used by itself, like */ThingDefs. It doesn't work as "*Defs/ThingDefs".

2. In <texpath> the slashes are going the wrong way. It should be "/" not "\". That was a big error.

3. I'm not sure on this one, but I don't capitalize the d in defName. I just changed it to be safe, as  I know that lowercase works.

4. For the EPOE compatibility patch, I added the line <success>Always</success> to suppress errors from other people not having the mod.

I didn't do anything for the Vegetable mod cause I don't know what to do there.

File: https://www.dropbox.com/s/6jm7er31e4cimqo/JabbamonkeysGraphics.rar?dl=0

jabbamonkey

#11
AWESOME! Just took a look, and the textures are starting to look great.  Your changes fixed most of the issues I was having. 

I was still getting errors for the "leathers" ... and couldn't seem to see what was wrong there. I only placed new leather textures in the correct texture folder (and didn't do ANY xpathing patching for leathers).  The small and medium leather stacks would show up fine in the game (leather_a and leather_b), but the large stack leather texture got a red X (leather_c).  So, in the leather folder, I placed...

Things\Item\Resource\Leather\Leather_a.png   <-- This showed fine.
Things\Item\Resource\Leather\Leather_b.png   <-- This showed fine.
Things\Item\Resource\Leather\Leather_c.png   <-- This wasn't showing
Things\Item\Resource\Leather\Leathers.png    <-- I copied Leather_c, and renamed it.

Now the leathers all show up fine. Odd.

Quote from: kwang4 on December 24, 2018, 10:39:41 AM
I didn't do anything for the Vegetable mod cause I don't know what to do there.

Those were for another mod that I was updating. However, I learned that I don't need those patches at all... as long as the textures for those new graphics are in the correct folders, and my mod is loaded last, then the images are automatically replaced.

I am still getting some other errors, but should be able to fix them on my own... If I have trouble, I'll reach out again.

THANKS!!!

jabbamonkey

Back to the medical mod replacement texture...

Getting the following error....

QuoteXML error: Duplicate XML node name graphicData in this XML block: <ThingDef ParentName="Basic"><defName>EyePatch</defName><label>eye patch</label><description>Covers the eye socket. Intimidating.</description><graphicData><texPath>Things/Item/BodyPart/BasicProsthesis</texPath><graphicClass>Graphic_Single</graphicClass></graphicData><statBases><MarketValue>65</MarketValue><Mass>0.3</Mass></statBases><graphicData><texPath>Things/Item/BodyPart/EyePatch</texPath><graphicClass>Graphic_Single</graphicClass><drawSize>0.80</drawSize></graphicData></ThingDef>

In the mod, the mod creates this item...

   <ThingDef ParentName="Basic">
<defName>EyePatch</defName>
<label>eye patch</label>
<description>Covers the eye socket. Intimidating.</description>
<graphicData>
<texPath>Things/Item/BodyPart/BasicProsthesis</texPath>
<graphicClass>Graphic_Single</graphicClass>
</graphicData>
<statBases>
<MarketValue>65</MarketValue>
<Mass>0.3</Mass>
</statBases>
</ThingDef>


So, like the other medical items, I PATCH with this...

      <li Class="patchOperationAdd">
<success>Always</success>
<xpath>Defs/ThingDef[defName = "EyePatch"]</xpath>
<value>
<graphicData>
<texPath>Things/Item/BodyPart/EyePatch</texPath>
<graphicClass>Graphic_Single</graphicClass>
<drawSize>0.80</drawSize>
</graphicData>
</value>
</li>


The texture shows up fine in the game, but the error message is irritating (and people don't like those messages).  Any help?

Also, it is important to note, that other items are treated differently in the mod (which is why the other patching worked, and this isn't working) ...

<ThingDef Name="Bionic" ParentName="BodyPartBase" Abstract="True">
<techLevel>Spacer</techLevel>
<tradeTags>
<li>BionicProstheses</li>
</tradeTags>
<thingCategories>
<li>BionicProstheses</li>
</thingCategories>
<graphicData>
<texPath>Things/Item/BodyPart/BionicPart</texPath>
<graphicClass>Graphic_Single</graphicClass>
</graphicData>
</ThingDef>

<!-- Added body parts -->

<ThingDef ParentName="Bionic">
<defName>PowerArm</defName>
<label>power arm</label>
<description>Unparalleled strength and dexterity, and with retractable claws. This is the ultimate arm upgrade!</description>
<statBases>
<MarketValue>7500</MarketValue>
<Mass>6</Mass>
</statBases>
<techHediffsTags>
<li>AdvancedWeapon</li>
</techHediffsTags>
</ThingDef>

<!-- etc...  -->

kwang4

Basically, this item in the mod writes its own texture path, and doesn't inherit from a parent.

It defines its own texture here:
<graphicData>
<texPath>Things/Item/BodyPart/BasicProsthesis</texPath>
<graphicClass>Graphic_Single</graphicClass>
</graphicData>


So you need PatchOperationReplace just to replace the texPath. What you're doing now creates this:

<ThingDef ParentName="Basic">
<defName>EyePatch</defName>
<label>eye patch</label>
<description>Covers the eye socket. Intimidating.</description>
<graphicData>
<texPath>Things/Item/BodyPart/BasicProsthesis</texPath>
<graphicClass>Graphic_Single</graphicClass>
</graphicData>
                 <graphicData>
<texPath>Things/Item/BodyPart/BasicProsthesis</texPath>
<graphicClass>Graphic_Single</graphicClass>
</graphicData>
<statBases>
<MarketValue>65</MarketValue>
<Mass>0.3</Mass>
</statBases>
</ThingDef>


with 2 graphicData parts.

jabbamonkey

Yeah, I assumed that, so I had tried...

      <li Class="patchOperationReplace">
<xpath>*/ThingDef[defName = "EyePatch"]/graphicData</xpath>
<value>
<texturePath>Things/Item/BodyPart/EyePatch</texturePath>
</value>
</li>


But that gave another error ...