[SOLVED] Hiding unused vanilla ThingCategories

Started by Wivex, April 09, 2016, 09:57:41 AM

Previous topic - Next topic

Wivex

Guys, a word of advice please. Suppose, i want to reassemble the whole ThingFilter tree with my own ThingCategories. How can i do that, without detouring the TreeNode_ThingCategory and so on? I want it to be xml based, not purely defined in od assembly.

Fluffy (l2032)

The way I do (did) it in my apparel sense mod is by 'unhooking' categories from their parents. The tree is displayed by starting from root, then going over all of the children. If the category isn't a child of any category, it'll never show up.

I'm not sure that's possible with XML only though, the game may complain, or default to the root category. Worth a shot, anyway.

Wivex

#2
Yeah, i've seen your method to do that, but i was hoping for an easier solution. Btw, if you unhook it from the root def, what would happen if i make separate tree, not connected to the root? Or hook categories to themselves, like it's used for hiding research defs?

UPDATE: ok, turned out i can unhook categories by removing <parent> tag without any harm. God, i feel so dumb now.

Deon

#3
Quote from: Wivex on April 09, 2016, 04:08:00 PM
Yeah, i've seen your method to do that, but i was hoping for an easier solution. Btw, if you unhook it from the root def, what would happen if i make separate tree, not connected to the root? Or hook categories to themselves, like it's used for hiding research defs?

UPDATE: ok, turned out i can unhook categories by removing <parent> tag without any harm. God, i feel so dumb now.
I feel even dumber because I am trying to figure out how XML modding works. I have learned how to add new stuff, but I am not getting this "removing parent" part.

For example, let's say I want to unlink Foods from Resources, so it does not appear in stockpile.

I just make a new mod, create a file ThingCategories.xml in a subfolder ThingCategoryDefs.

Then I fill that file with contents like these:

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

    <ThingCategoryDef>
      <defName>Foods</defName>
      <label>foods</label>
    </ThingCategoryDef>

</ThingCategoryDefs>


Basically I removed parent from the Foods, but it still loads it as a child of resources, I assume from the core file? In stockpile menu Foods are still under Resources. Am I being overly dumb or is there something you can offer me as advice?

Any help would be greatly appreciated. I am currently wondering what is a proper way to remove vanilla definitions to come up with your own without just "renaming" existing defs.

Wivex

i may be wrong, but i've done it exactly the way you did. I think you should check if your mod is loaded at all.

Deon

Here's what I have in console:

http://i.imgur.com/0XLImHn.png

It says "Initializing new game with mods Core and TestRemoval".

The mod itself looks like this:
/Mods
//TestRemoval
///About/About.xml
///ThingCategoryDefs/ThingCategories.xml

And the contents of ThingCategories.xml is above.

Do you have an example which works that you could share? It would help me a lot.

Wivex


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

<!-- those categories are hidden -->

<ThingCategoryDef>
<defName>Foods</defName>
<label>foods</label>
</ThingCategoryDef>

<ThingCategoryDef>
<defName>FoodMeals</defName>
<label>meals</label>
</ThingCategoryDef>

<ThingCategoryDef>
<defName>MeatRaw</defName>
<label>meat</label>
</ThingCategoryDef>

<ThingCategoryDef>
<defName>PlantFoodRaw</defName>
<label>vegetarian</label>
</ThingCategoryDef>

<ThingCategoryDef>
<defName>Manufactured</defName>
<label>manufactured</label>
</ThingCategoryDef>

<ThingCategoryDef>
<defName>Textiles</defName>
<label>textiles</label>
</ThingCategoryDef>

<ThingCategoryDef>
<defName>Medicine</defName>
<label>medicine</label>
</ThingCategoryDef>

<ThingCategoryDef>
<defName>Art</defName>
<label>art</label>
</ThingCategoryDef>

<ThingCategoryDef>
<defName>Grenades</defName>
<label>grenades</label>
</ThingCategoryDef>

</ThingCategoryDefs>

Deon

Is that supposed to work without other modifications?
I have copypasted it in my file and I still see all categories:


Alistaire

You want to set parents of categories to a newly added category without parent (or through C# remove childCategories from existing
ThingCategoryDef of their parent) as to hide them from the Root category.

Using C# it's possible to hide and show all empty ThingCategoryDef correctly through recursive methods.

Deon

QuoteYou want to set parents of categories to a newly added category without parent
That's a good idea. Thanks a lot.

Deon

Umm guys... Sorry for being annoying, but is it possible that I do something totally wrong and confuse everyone?

Because this is what I have:


<ThingCategoryDefs>

  <ThingCategoryDef>
    <defName>Disabled</defName>
    <label>Disabled</label>
  </ThingCategoryDef>

<ThingCategoryDef>
<defName>Foods</defName>
<label>foods</label>
<parent>Disabled</parent>
</ThingCategoryDef>

</ThingCategoryDefs>


It should make a new category def called "disabled" and assign food to it. The issue is, it does not. I load the game and the foods are still under resources. Any idea why this happens would be appreciated :D. I would love to learn modding thoroughly, I just need to start somewhere. And the fact that I fail at such simple things kinda frightens me :D. I never had anything like that with Dwarf Fortress modding, even dfhack scripts heh.

Alistaire

Make sure you have the mod loaded on startup, do not open the Mods menu because closing it causes all kinds of bugs due to the game only
partially reloading somehow and if you do open the mods menu close and restart the game.

Deon

That's kinda... dangerous to hear :D. Is it really that unstable? I am pretty sure I loaded all major mods and started playing the game with mod content without issues before.

Also nope, I did what you said. Started the game, opened mods menu. Enabled the mod (how else would I make it loaded :D). Quit the game. Started it and made a new world. Started a new colony. Foods category is still there.

Deon

Quote from: Deon on April 20, 2016, 04:26:45 PM
The mod itself looks like this:
/Mods
//TestRemoval
///About/About.xml
///ThingCategoryDefs/ThingCategories.xml
Herp derp. You probably didn't notice the issue because it would be too simple for those who are used to modding.
And I was just unobservant.

There should be "Defs" folder, which in turn contains ThingCategoryDefs. I only figured it out after I tried modifying a name of a category and noticed there's no effect, and decided to double check the file path :D.

I am sorry for wasting your time on replies and thank you for the goodwill. I really appreciate the community's eagerness to accept a new member :).