1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-30 20:02:07 +00:00
The-Modding-Tree/docs/custom-tab-layouts.md

81 lines
5 KiB
Markdown
Raw Normal View History

2020-10-01 05:30:59 +00:00
# Custom tab layouts
2021-05-11 01:24:24 +00:00
Note: If you are using subtabs, `tabFormat` is used differently, but the same format is used for defining their layouts. [See here for more on subtabs](subtabs-and-microtabs.md).
2020-10-26 20:45:22 +00:00
Custom tab layouts can be used to do basically anything in a tab window, especially combined with the "style" layer feature. The `tabFormat` feature is an array of things, like this:
2020-10-01 05:30:59 +00:00
```js
2020-10-26 20:45:22 +00:00
tabFormat: [
"main-display",
["prestige-button", function() { return "Melt your points into " }],
"blank",
["display-text",
function() { return 'I have ' + format(player.points) + ' pointy points!' },
{ "color": "red", "font-size": "32px", "font-family": "Comic Sans MS" }],
"blank",
["toggle", ["c", "beep"]],
"milestones",
"blank",
"blank",
"upgrades"
]
```
2020-10-01 05:30:59 +00:00
2020-10-26 20:45:22 +00:00
It is a list of components, which can be either just a name, or an array with arguments. If it's an array, the first item is the name of the component, the second is the data passed into it, and the third (optional) applies a CSS style to it with a "CSS object", where the keys are CSS attributes.
2020-10-01 05:30:59 +00:00
These are the existing components, but you can create more in [components.js](/js/components.js):
2020-10-01 05:30:59 +00:00
- display-text: Displays some text (can use basic HTML). The argument is the text to display. It can also be a function that returns updating text.
2020-10-01 05:30:59 +00:00
- raw-html: Displays some basic HTML, can also be a function.
2020-10-26 20:45:22 +00:00
- blank: Adds empty space. The default dimensions are 8px x 17px. The argument changes the dimensions. If it's a single value (e.g. "20px"), that determines the height. If you have a pair of arguments, the first is width and the second is height.
2020-10-01 05:30:59 +00:00
2020-10-16 15:39:39 +00:00
- row: Display a list of components horizontally. The argument is an array of components in the tab layout format.
2020-10-26 20:45:22 +00:00
- column: Display a list of components vertically. The argument is an array of components in the tab layout format. This is useful to display columns within a row.
2020-10-16 15:39:39 +00:00
2021-05-12 02:29:05 +00:00
- main-display: The text that displays the main currency for the layer and its effects. The argument is the amount of precision to use, allowing it to display non-whole numbers.
2020-10-01 05:30:59 +00:00
2020-10-26 20:45:22 +00:00
- resource-display: The text that displays the currency that this layer is based on, as well as the best and/or total values for this layer's prestige currency (if they are put in `startData` for this layer).
2020-10-18 00:23:39 +00:00
2020-10-26 20:45:22 +00:00
- prestige-button: The argument is a string that the prestige button should say before the amount of currency you will gain. It can also be a function that returns updating text.
2020-10-01 05:30:59 +00:00
- text-input: A text input box. The argument is the name of the variable in player[layer] that the input is for, player[layer][argument]
(Works with strings, numbers, and Decimals!)
- slider: Lets the user input a value with a slider. The argument a 3-element array: [name, min, max].
The name is the name of the variable in player[layer] that the input that the input is for, and min and max are the limits of the slider.
(Does not work for Decimal values)
2020-12-05 19:52:29 +00:00
- upgrades: The layer's upgrades. The argument is optional, and is a the list of rows this component should include, if it doesn't have all of them.
- milestones, challenges, achievements: Display the upgrades, milestones, and challenges for a layer, as appropriate.
2020-10-01 05:30:59 +00:00
2020-10-26 20:45:22 +00:00
- buyables, clickables: Display all of the buyables/clickables for this layer, as appropriate. The argument is optional and is the size of the boxes in pixels.
2020-10-01 05:30:59 +00:00
- microtabs: Display a set of subtabs for an area. The argument is the name of the set of microtabs in the "microtabs" feature.
- bar: Display a bar. The argument is the id of the bar to display.
2020-10-26 03:00:32 +00:00
- infobox: Display an infobox. The argument is the id of the infobox to display.
- tree: Displays a tree. The argument is an array of arrays containing the names of the nodes in the tree (first by row, then by column)
[See here for more information on tree layouts and nodes!](trees-and-tree-customization.md)
- toggle: A toggle button that toggles a bool value. The argument is a pair that identifies the location in player of the bool to toggle, e.g. `[layer, id]`. 'layer' also affects the color of the toggle.
2021-04-27 02:43:36 +00:00
- grid: Displays the gridable grid for the layer. If you need more than one grid, use a layer proxy.
2021-04-27 02:43:36 +00:00
- layer-proxy: Lets you use components from another layer. The argument is a pair, `[layer, data]`, consisting of the id of the layer to proxy from, and the tabFormat for the components to show.
2021-05-13 03:21:39 +00:00
(Note: you cannot use a microtab within a layer proxy)
2020-10-17 19:50:30 +00:00
The rest of the components are sub-components. They can be used just like other components, but are typically part of another component.
- upgrade, milestone, challenge, buyable, clickable, achievement, gridable: An individual upgrade, challenge, etc. The argument is the id. This can be used if you want to have upgrades split up across multiple subtabs, for example.
2020-10-17 19:50:30 +00:00
- respec-button, master-button: The respec and master buttons for buyables and clickables, respectively.
2020-10-26 20:45:22 +00:00
- sell-one, sell-all: The "sell one" and "sell all" for buyables, respectively. The argument is the id of the buyable.