From f4b4ec20d07a6342e49a701f12498dd65d22261e Mon Sep 17 00:00:00 2001 From: Harley White Date: Wed, 12 May 2021 23:21:39 -0400 Subject: [PATCH] Fixed many tabFormat issues --- changelog.md | 5 +++++ docs/custom-tab-layouts.md | 2 ++ js/Demo/demoLayers.js | 35 +++-------------------------------- js/Demo/demoMod.js | 2 +- js/game.js | 2 +- js/technical/displays.js | 10 ++++------ js/technical/layerSupport.js | 8 +++++--- js/utils/NumberFormating.js | 8 ++++++-- 8 files changed, 27 insertions(+), 45 deletions(-) diff --git a/changelog.md b/changelog.md index 3d9ef6b..ddc7f8a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,10 @@ # The Modding Tree changelog: +# v2.5.5.2 - 5/12/21 +- Fixed a major issue with buyables. +- Fixed a variety of tabFormat-related issues. +- Fixed commas appearing in decimal places (thanks to pg132!) + # v2.5.5.1 - 5/12/21 - Fixed clickables. diff --git a/docs/custom-tab-layouts.md b/docs/custom-tab-layouts.md index 0c769c5..11a1ba4 100644 --- a/docs/custom-tab-layouts.md +++ b/docs/custom-tab-layouts.md @@ -68,6 +68,8 @@ These are the existing components, but you can create more in [components.js](/j - grid: Displays the gridable grid for the layer. If you need more than one grid, use a layer proxy. - 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. + (Note: you cannot use a microtab within a layer proxy) + 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 164f3c3..2e93fd3 100644 --- a/js/Demo/demoLayers.js +++ b/js/Demo/demoLayers.js @@ -6,7 +6,6 @@ addLayer("c", { name: "Candies", // This is optional, only used in a few places, If absent it just uses the layer id. symbol: "C", // This appears on the layer's node. Default is the id with the first letter capitalized position: 0, // Horizontal position within a row. By default it uses the layer id and sorts in alphabetical order - marked: "discord.png", startData() { return { unlocked: true, points: new Decimal(0), @@ -319,7 +318,7 @@ addLayer("c", { ["buyables", ""], "blank", ["row", [ ["toggle", ["c", "beep"]], ["blank", ["30px", "10px"]], // Width, height - ["layer-proxy", ["f", ["prestige-button"]]], "blank", ["v-line", "200px"], + ["display-text", function() {return "Beep"}], "blank", ["v-line", "200px"], ["column", [ ["prestige-button", "", {'width': '150px', 'height': '80px'}], ["prestige-button", "", {'width': '100px', 'height': '150px'}], @@ -427,7 +426,6 @@ addLayer("f", { canReset() { return tmp[this.layer].baseAmount.gte(tmp[this.layer].nextAt) }, - // This is also non minimal, a Clickable! clickables: { @@ -526,32 +524,5 @@ addLayer("a", { onComplete() {console.log("Bork bork bork!")} }, }, - grid: { - maxRows: 3, - rows: 2, - cols: 2, - getStartData(id) { - return id - }, - getUnlocked(id) { // Default - return true - }, - getCanClick(data, id) { - return true - }, - getStyle(data, id) { - return {'background-color': '#'+ (data*1234%999999)} - }, - onClick(data, id) { // Don't forget onHold - player[this.layer].grid[id]++ - }, - getTitle(data, id) { - return "Gridable #" + id - }, - getDisplay(data, id) { - return data - }, - } , - midsection: ["grid", "blank"] - } -) \ No newline at end of file + }, +) diff --git a/js/Demo/demoMod.js b/js/Demo/demoMod.js index 34ba2ad..26402d8 100644 --- a/js/Demo/demoMod.js +++ b/js/Demo/demoMod.js @@ -11,7 +11,7 @@ let modInfo = { // Set your version in num and name let VERSION = { - num: "2.5.5.1", + num: "2.5.5.2", name: "Dreams Really Do Come True", } diff --git a/js/game.js b/js/game.js index 1e16f6c..71d4894 100644 --- a/js/game.js +++ b/js/game.js @@ -5,7 +5,7 @@ var scrolled = false; // Don't change this const TMT_VERSION = { - tmtNum: "2.5.5.1", + tmtNum: "2.5.5.2", tmtName: "Dreams Really Do Come True" } diff --git a/js/technical/displays.js b/js/technical/displays.js index 1652d8e..ce228c0 100644 --- a/js/technical/displays.js +++ b/js/technical/displays.js @@ -143,9 +143,7 @@ function constructTabFormat(layer, id, family){ } if (isFunction(tabLayer)) { - - let bound = tabLayer.bind(layers[layer]) - Vue.set(tabTemp, key, bound()) + return tabLayer() } updateTempData(tabLayer, tabTemp, tabFunc) return tabTemp @@ -173,7 +171,7 @@ function updateTabFormat(layer) { // Check for embedded layer if (isPlainObject(tmp[layer].tabFormat) && tmp[layer].tabFormat[tab].embedLayer !== undefined) { - constructTabFormat(tmp[layer].tabFormat[tab].embedLayer) + updateTabFormat(tmp[layer].tabFormat[tab].embedLayer) } // Update microtabs @@ -183,9 +181,9 @@ function updateTabFormat(layer) { if (tmp[layer].microtabs[family][tab]) { if (tmp[layer].microtabs[family][tab].embedLayer) - constructTabFormat(tmp[layer].microtabs[family][tab].embedLayer) + updateTabFormat(tmp[layer].microtabs[family][tab].embedLayer) else - constructTabFormat(layer, tab, family) + Vue.set(temp[layer].microtabs[family][tab], 'content', constructTabFormat(layer, tab, family)) } } } \ No newline at end of file diff --git a/js/technical/layerSupport.js b/js/technical/layerSupport.js index 165a4ac..6e0e277 100644 --- a/js/technical/layerSupport.js +++ b/js/technical/layerSupport.js @@ -118,12 +118,14 @@ function setupLayer(layer){ layers[layer].buyables[thing].layer = layer if (layers[layer].buyables[thing].unlocked === undefined) layers[layer].buyables[thing].unlocked = true - } layers[layer].buyables[thing].canBuy = function() {return canBuyBuyable(this.layer, this.id)} if (layers[layer].buyables[thing].purchaseLimit === undefined) layers[layer].buyables[thing].purchaseLimit = new Decimal(Infinity) - } + + } + + } } - + if (layers[layer].clickables){ layers[layer].clickables.layer = layer setRowCol(layers[layer].clickables) diff --git a/js/utils/NumberFormating.js b/js/utils/NumberFormating.js index 4dd3704..ee97cce 100644 --- a/js/utils/NumberFormating.js +++ b/js/utils/NumberFormating.js @@ -15,14 +15,18 @@ function exponentialFormat(num, precision, mantissa = true) { function commaFormat(num, precision) { if (num === null || num === undefined) return "NaN" if (num.mag < 0.001) return (0).toFixed(precision) - return num.toStringWithDecimalPlaces(precision).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") + let init = num.toStringWithDecimalPlaces(precision) + let portions = init.split(".") + portions[0] = portions[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") + if (portions.length == 1) return portions[0] + return portions[0] + "." + portions[1] } function regularFormat(num, precision) { if (num === null || num === undefined) return "NaN" if (num.mag < 0.0001) return (0).toFixed(precision) - if (num.mag < 0.1 && precision !==0) precision = 4 + if (num.mag < 0.1 && precision !==0) precision = Math.max(precision, 4) return num.toStringWithDecimalPlaces(precision) }