diff --git a/changelog.md b/changelog.md index 8f01bc3..0e7e3ad 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,6 @@ # The Modding Tree changelog: -- Added a text-input component. +- Added 2 new input components, text-input and slider. - The red layer highlight will not appear before a layer is unlocked. # v2.π.1 - 4/7/21 diff --git a/docs/custom-tab-layouts.md b/docs/custom-tab-layouts.md index 539e2fb..cb19537 100644 --- a/docs/custom-tab-layouts.md +++ b/docs/custom-tab-layouts.md @@ -61,7 +61,10 @@ These are the existing components, but you can create more in [components.js](/j - 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) + The rest of the components are sub-components. They can be used just like other components, but are typically part of another component. diff --git a/js/Demo/demoLayers.js b/js/Demo/demoLayers.js index 91a4bff..36a2140 100644 --- a/js/Demo/demoLayers.js +++ b/js/Demo/demoLayers.js @@ -14,6 +14,7 @@ addLayer("c", { buyables: {}, // You don't actually have to initialize this one beep: false, thingy: "pointy", + otherThingy: 10, }}, color: "#4BDC13", requires: new Decimal(10), // Can be a function that takes requirement increases into account @@ -341,7 +342,9 @@ addLayer("c", { unlocked() {return (hasUpgrade("c", 13))}, content:[ ["raw-html", function() {return "

C O N F I R M E D

"}], "blank", - ["microtabs", "stuff", {'width': '600px', 'height': '350px', 'background-color': 'brown', 'border-style': 'solid'}] + ["microtabs", "stuff", {'width': '600px', 'height': '350px', 'background-color': 'brown', 'border-style': 'solid'}], + ["display-text", "Adjust how many points H gives you!"], + ["slider", ["otherThingy", 1, 30]], ] } diff --git a/js/Demo/demoTree.js b/js/Demo/demoTree.js index c344a5c..a19421e 100644 --- a/js/Demo/demoTree.js +++ b/js/Demo/demoTree.js @@ -36,11 +36,11 @@ addNode("g", { addNode("h", { branches: ["g"], layerShown: true, - tooltip: "Restore your points to 10", - tooltipLocked: "Restore your points to 10", + tooltip() {return "Restore your points to " + player.c.otherThingy}, + tooltipLocked() {return "Restore your points to " + player.c.otherThingy}, row: "side", - canClick() {return player.points.lt(10)}, - onClick() {player.points = new Decimal(10)} + canClick() {return player.points.lt(player.c.otherThingy)}, + onClick() {player.points = new Decimal(player.c.otherThingy)} }, ) diff --git a/js/components.js b/js/components.js index 1baa49f..0157c5d 100644 --- a/js/components.js +++ b/js/components.js @@ -407,6 +407,13 @@ function loadVue() { ` }) +// Updates the value in player[layer][data] + Vue.component('slider', { + props: ['layer', 'data'], + template: ` +
+ ` + }) // These are for buyables, data is the id of the corresponding buyable Vue.component('sell-one', {