-
Notifications
You must be signed in to change notification settings - Fork 5
Adding Categories
This page will show you how to add your own buttons to the overview of categories.
Each category button has one or multiple category names attached to it, allowing users to easily filter the item list.
If you're only trying to use the mod, please return to the repository overview.
If you want to add custom items to the interface, please see Adding Items.
All default categories use the same button templates. As such, it is highly recommended to use the same templates for any categories you're adding.
The interface assumes a button size of (36x24) pixels, so if you do wish to deviate from the templates, please use these dimensions.
Unselected Category | Selected Category |
---|---|
You can put your category buttons wherever you want. Note down the asset paths to both images.
Categories are added in groups. Each group has a label above the category buttons. The below example shows how to add a new group with one category button.
First, create the file categories.config.patch
in the sipMods
folder.
/Starbound/mods/SIP-CategoryAddOn/sipMods/categories.config.patch
As this is a patch, we'll start with an empty array of patch operations.
[]
Before adding categories, you must first create a group for them. The group is identified by it's label. Since another mod may already have created a group with the same label, it is highly recommended to test for the group before making it.
For a group named "Mod Category", This results in the following patch file:
[
[{
"op": "test",
"path": "/Mod Category",
"inverse": true
},{
"op": "add",
"path": "/Mod Category",
"value": []
}]
]
Now that we know the group exists, we can safely add a new category to it. The mod will take care of positioning the categories, so you only have to supply a few parameters.
Parameter | Description |
---|---|
image |
Asset path for the button image, used when the category is not selected. |
selectedImage |
Asset path for the button image, used when the category is selected. |
categories |
Array of category names, or a single category name (string). When the category is selected, only items matching one or more categories will be listed. |
caption |
Optional parameter that adds text on top of the category button. |
We add the category in a seperate patch operation, so that it will be added regardless of whether "Mod Category" already existed or not.
[{
"op": "add",
"path": "/Mod Category/-",
"value": {
"caption": "Add-On\nHats",
"image": "/interface/sip/categories/vanityhat.png",
"selectedImage": "/interface/sip/categories/vanityhatselected.png",
"categories": ["headwear"]
}
}]
Adding this operation to the patch file gives us the following complete patch file:
[
[{
"op": "test",
"path": "/Mod Category",
"inverse": true
}, {
"op": "add",
"path": "/Mod Category",
"value": []
}],
[{
"op": "add",
"path": "/Mod Category/-",
"value": {
"caption": "Add-On\nHats",
"image": "/interface/sip/categories/vanityhat.png",
"selectedImage": "/interface/sip/categories/vanityhatselected.png",
"categories": ["headwear"]
}
}]
]