Adding in game Help menu for your mod through JSON - JBurlison/Pandaros.API GitHub Wiki

Step 1

Adding a wiki menu starts at creating a item to open it.

{
    "name": "Pandaros.Settlers.HelpMenu",
    "icon": "./icons/Help.png",
    "isPlaceable": false,
    "maxStackSize": 1,
    "categories": [
        "essential",
        "aaa"
    ],
    "StaticItemSettings": {
        "Name": "Pandaros.Settlers.HelpMenu"
    },
    "OpensMenuSettings": {
        "UIUrl": "Wiki.MainMenu",
        "ActivateClickType": 1,
        "ItemName": "Pandaros.Settlers.HelpMenu"
    }
}

Static item settings will keep the item in the inventory no matter what so its always there to use it.

For the OpensMenuSettings:

UIUrl. This URL is the json path to your wiki. examples of this in step 2

Activation Type:

  1. Left Click
  2. Right Click

ItemName: name of the item.

Step 2

Create a wiki menu json. This menu has to be registered in the modinfo json

modinfo

"Pandaros.API.jsonFiles": [
    {
      "fileType": "Pandaros.API.MenuFile",
      "relativePath": "Help/Menus/help.json"
    }
]

HelpJson

{
    "Wiki": {
        "MainMenu": {
            "header": "Pandaros.Settlers.Wiki.MainMenu.Title",
            "Items": [
                {
                    "type": "label",
                    "text": "Pandaros.Settlers.Wiki.MainMenu.Credits",
                    "alignement": "MiddleCenter"
                }
            ]
        }
    }
}

The items array, are displayed in the order you place them. There are a lot of different elements that can be placed in the items array. Here is the name and parameters of each item:

label

Parameters Optional Default Description
text No N/A Text to display on the label. Can be the localization key or text.
color Yes Black Applicable values: cyan, green, red, black, yellow, blue, magenta, gray, white, clear, grey, Black
alignement Yes MiddleLeft Applicable values: UpperLeft, UpperCenter, UpperRight, MiddleLeft, MiddleCenter, MiddleRight, LowerLeft, LowerCenter, LowerRight
fontsize Yes 18 Size of the font
localizationType Yes Sentence Applicable Values: None, Sentence, Type, TypeUse
position Yes 0 Margin left

space

Parameters Optional Default Description
height Yes 10 Height of the space
position Yes 0 Margin left

line

Parameters Optional Default Description
height Yes 10 Height of the line
color Yes Black Applicable values: cyan, green, red, black, yellow, blue, magenta, gray, white, clear, grey, Black
width Yes -1 Width of the l
position Yes 0 Margin left

icon

Parameters Optional Default Description
name No N/A Item name of the icon
position Yes 0 Margin left

jobrecipies

Lists out all a jobs recipes. Researched or not.

Parameters Optional Default Description
job No N/A Name of the job to list recipes for
position Yes 0 Margin left

item

Displays an items name and description.

Parameters Optional Default Description
name No N/A name of the item
position Yes 0 Margin left

itemrecipe

Displays an items recipe.

Parameters Optional Default Description
name No N/A name of the item
position Yes 0 Margin left

patchnotes

Displays the patchnotes for a mod if its configured in its mod info like this:

    "patchnotes": [
      {
        "version": "0.8.2.0",
        "notes": [
          "Fixed stone slab name",
          "Fixed bug where colonists would be hurt after researching colonist health"
         ]
       }
     ]
Parameters Optional Default Description
mod No N/A name of the mod to display the patchnotes for. Must match name in the modinfo

link

links form buttons that link to other json menus

Parameters Optional Default Description
url No N/A Similar to the URL described in step 1, its the json path to the new menu
width Yes -1 Width of the button, -1 spans whole UI
height Yes 25 Height of the button
label No N/A See Label

Example

{
  "type": "link",
  "url": "Wiki.Machinists",
  "width": 700,
  "position": 150,
  "label": {
    "text": "Pandaros.Settlers.Wiki.MainMenu.Machinists",
    "alignement": "MiddleCenter"
  }

table

Parameters Optional Default Description
row_height Yes 30 Height of each row
rows No N/A an array of arrays in each array item is the array is a column.

Example this example shows a 2 column 2 row table.

{
  "type": "table",
  "position": 50,
  "rows": [
    [
      {
        "type": "label",
        "fontsize": 20,
        "text": "Pandaros.Settlers.Wiki.Type"
      },
      {
        "type": "label",
        "fontsize": 20,
        "text": "Pandaros.Settlers.Wiki.Description"
      }
    ],
    [
      {
        "type": "icon",
        "name": "Pandaros.Settlers.Miner"
      },
      {
        "type": "item",
        "name": "Pandaros.Settlers.Miner"
      }
    ]
  ]
}

Settlers Examples

Menu Configurations: Menu Configurations

Mod Info: Mod Info

Localization: Localization