From 1a96d7d2264c41e247d150d5aa2ba59b7c86aa1e Mon Sep 17 00:00:00 2001 From: Harley White Date: Wed, 26 May 2021 01:44:12 -0400 Subject: [PATCH] Added leftTab and related features --- changelog.md | 1 + demo.html | 4 ++-- docs/layer-features.md | 6 +++++- docs/making-a-mod.md | 2 +- index.html | 5 +++-- js/Demo/demoLayers.js | 9 +++++++++ js/Demo/demoTree.js | 5 ++++- js/components.js | 2 +- js/game.js | 2 +- js/technical/displays.js | 1 + js/technical/systemComponents.js | 15 +++++++++++---- js/tree.js | 4 +++- js/utils.js | 33 ++++++++++++++++++++------------ js/utils/save.js | 1 + 14 files changed, 64 insertions(+), 26 deletions(-) diff --git a/changelog.md b/changelog.md index d0f8e2b..4091f12 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ - The challenge that you are currently in is highlighted, and will not be hidden if "hide completed challenges" is on and it is already completed. - Fixed the infobox not appearing in default tabFormat. - Fixed upgrade/buyable layering when they are hovered over. +- Added leftTab, which makes a layer use the left tab instead of the right one (good for trees-within-trees and such) ### v2.5.10.2 - 5/24/21 - Fixed some things in the tree tab not being clickable. diff --git a/demo.html b/demo.html index cea99d9..251e844 100644 --- a/demo.html +++ b/demo.html @@ -67,8 +67,8 @@
{{VERSION.withoutName}}
+ v-if="((player.navTab == 'none' && (tmp[player.tab].row == 'side' || tmp[player.tab].row == 'otherside' || player[player.tab].prevTab)) || player[player.navTab].prevTab)" + class="other-back overlayThing" onclick="goBack(player.navTab == 'none' ? player.tab : player.navTab)">←

i
diff --git a/docs/layer-features.md b/docs/layer-features.md index ee778fa..1ea624c 100644 --- a/docs/layer-features.md +++ b/docs/layer-features.md @@ -104,7 +104,7 @@ You can make almost any value dynamic by using a function in its place, includin - roundUpCost: **optional**. a bool, which is true if the resource cost needs to be rounded up. (use if the base resource is a "static" currency.) - gainMult(), gainExp(): **optional**. For normal layers, these functions calculate the multiplier and exponent on resource gain from upgrades and boosts and such. Plug in most bonuses here. - For static layers, they instead divide and root the cost of the resource. + For static layers, they instead multiply and roots the cost of the resource. (So to make a boost you want to make gainMult smaller and gainExp larger.) - directMult(): **optional**. Directly multiplies the resource gain, after exponents and softcaps. For static layers, actually multiplies resource gain instead of reducing the cost. @@ -173,6 +173,10 @@ componentStyles: { } ``` +- leftTab: **optional**, if true, this layer will use the left tab instead of the right tab. + +- previousTab: **optional**, a layer's id. If a layer has a previousTab, the layer will always have a back arrow and pressing the back arrow on this layer will take you to the layer with this id. + - deactivated: **optional**, if this is true, hasUpgrade, hasChallenge, hasAchievement, and hasMilestone will return false for things in the layer, and you will be unable to buy or click things on the layer. You will have to disable effects of buyables, the innate layer effect, and possibly other things yourself. ## Custom Prestige type diff --git a/docs/making-a-mod.md b/docs/making-a-mod.md index c17b850..1f1877f 100644 --- a/docs/making-a-mod.md +++ b/docs/making-a-mod.md @@ -62,4 +62,4 @@ Refresh the page again, and it should work! You are gaining 2 points per second! ## Upgraded upgrades -To be continued... \ No newline at end of file +Now that you know how to make an upgrade, let's \ No newline at end of file diff --git a/index.html b/index.html index c7bcb46..904d566 100644 --- a/index.html +++ b/index.html @@ -30,6 +30,7 @@ +
@@ -66,8 +67,8 @@
{{VERSION.withoutName}}
+ v-if="((player.navTab == 'none' && (tmp[player.tab].row == 'side' || tmp[player.tab].row == 'otherside' || player[player.tab].prevTab)) || player[player.navTab].prevTab)" + class="other-back overlayThing" onclick="goBack(player.navTab == 'none' ? player.tab : player.navTab)">←

i
diff --git a/js/Demo/demoLayers.js b/js/Demo/demoLayers.js index 0b36fd3..a5aafd1 100644 --- a/js/Demo/demoLayers.js +++ b/js/Demo/demoLayers.js @@ -384,6 +384,15 @@ addLayer("c", { // This layer is mostly minimal but it uses a custom prestige type and a clickable addLayer("f", { + infoboxes:{ + coolInfo: { + title: "Lore", + titleStyle: {'color': '#FE0000'}, + body: "DEEP LORE!", + bodyStyle: {'background-color': "#0000EE"} + } + }, + startData() { return { unlocked: false, points: new Decimal(0), diff --git a/js/Demo/demoTree.js b/js/Demo/demoTree.js index a19421e..ff7b91d 100644 --- a/js/Demo/demoTree.js +++ b/js/Demo/demoTree.js @@ -45,5 +45,8 @@ addNode("h", { ) addLayer("tree-tab", { - tabFormat: [["tree", function() {return (layoutInfo.treeLayout ? layoutInfo.treeLayout : TREE_LAYERS)}]] + tabFormat: [["tree", function() {return (layoutInfo.treeLayout ? layoutInfo.treeLayout : TREE_LAYERS)}]], + previousTab: "", + leftTab: true, + }) \ No newline at end of file diff --git a/js/components.js b/js/components.js index 48d7ee4..1652046 100644 --- a/js/components.js +++ b/js/components.js @@ -498,7 +498,7 @@ function loadVue() { template: `
- +
diff --git a/js/game.js b/js/game.js index b16ed42..9e35454 100644 --- a/js/game.js +++ b/js/game.js @@ -139,7 +139,7 @@ function rowReset(row, layer) { } function layerDataReset(layer, keep = []) { - let storedData = {unlocked: player[layer].unlocked, forceTooltip: player[layer].forceTooltip, noRespecConfirm: player[layer].noRespecConfirm} // Always keep these + let storedData = {unlocked: player[layer].unlocked, forceTooltip: player[layer].forceTooltip, noRespecConfirm: player[layer].noRespecConfirm, prevTab:player[layer].prevTab} // Always keep these for (thing in keep) { if (player[layer][keep[thing]] !== undefined) diff --git a/js/technical/displays.js b/js/technical/displays.js index d85ef72..9fefff8 100644 --- a/js/technical/displays.js +++ b/js/technical/displays.js @@ -55,6 +55,7 @@ function updateWidth() { var splitScreen = screenWidth >= 1024 if (player.forceOneTab) splitScreen = false + if (player.navTab == "none") splitScreen = true tmp.other.screenWidth = screenWidth tmp.other.screenHeight = window.innerHeight diff --git a/js/technical/systemComponents.js b/js/technical/systemComponents.js index c35b8b4..62ba9be 100644 --- a/js/technical/systemComponents.js +++ b/js/technical/systemComponents.js @@ -13,13 +13,20 @@ var systemComponents = { }, 'tree-node': { - props: ['layer', 'abb', 'size'], + props: ['layer', 'abb', 'size', 'prev'], template: `
+
diff --git a/js/tree.js b/js/tree.js index 998fc17..2aae72a 100644 --- a/js/tree.js +++ b/js/tree.js @@ -16,5 +16,7 @@ addNode("blank", { addLayer("tree-tab", { - tabFormat: [["tree", function() {return (layoutInfo.treeLayout ? layoutInfo.treeLayout : TREE_LAYERS)}]] + tabFormat: [["tree", function() {return (layoutInfo.treeLayout ? layoutInfo.treeLayout : TREE_LAYERS)}]], + previousTab: "", + leftTab: true, }) \ No newline at end of file diff --git a/js/utils.js b/js/utils.js index 8473b43..09d9446 100644 --- a/js/utils.js +++ b/js/utils.js @@ -137,37 +137,47 @@ function inChallenge(layer, id) { // ************ Misc ************ var onTreeTab = true -function showTab(name) { + +function showTab(name, prev) { if (LAYERS.includes(name) && !layerunlocked(name)) return if (player.tab !== name) clearParticles(function(p) {return p.layer === player.tab}) - if (player.tab === name && isPlainObject(tmp[name].tabFormat)) { + if (tmp[name] && player.tab === name && isPlainObject(tmp[name].tabFormat)) { player.subtabs[name].mainTabs = Object.keys(layers[name].tabFormat)[0] } var toTreeTab = name == "none" player.tab = name - if (player.navTab == "none" && (tmp[name].row !== "side") && (tmp[name].row !== "otherside")) player.lastSafeTab = name - delete player.notify[name] + if (tmp[name] && (tmp[name].row !== "side") && (tmp[name].row !== "otherside")) player.lastSafeTab = name updateTabFormats() needCanvasUpdate = true document.activeElement.blur() } -function showNavTab(name) { +function showNavTab(name, prev) { + console.log(prev) if (LAYERS.includes(name) && !layerunlocked(name)) return if (player.navTab !== name) clearParticles(function(p) {return p.layer === player.navTab}) - - var toTreeTab = name == "tree" + if (tmp[name] && tmp[name].previousTab !== undefined) prev = tmp[name].previousTab + var toTreeTab = name == "tree-tab" + console.log(name + prev) + if (!tmp[prev]?.leftTab == !tmp[name]?.leftTab) player[name].prevTab = prev + else if (player[name]) + player[name].prevTab = "" player.navTab = name - player.notify[name] = false updateTabFormats() needCanvasUpdate = true } -function goBack() { - if (player.navTab !== "none") showTab("none") - else showTab(player.lastSafeTab) +function goBack(layer) { + let nextTab = "none" + + if (player[layer].prevTab) nextTab = player[layer].prevTab + if (player.navTab !== "none" && (tmp[layer]?.row == "side" || tmp[layer].row == "side")) nextTab = player.lastSafeTab + + if (tmp[layer].leftTab) showNavTab(nextTab, layer) + else showTab(nextTab, layer) + } function layOver(obj1, obj2) { @@ -239,7 +249,6 @@ function layerunlocked(layer) { function keepGoing() { player.keepGoing = true; needCanvasUpdate = true; - goBack() } function toNumber(x) { diff --git a/js/utils/save.js b/js/utils/save.js index 139719e..7ec1daf 100644 --- a/js/utils/save.js +++ b/js/utils/save.js @@ -87,6 +87,7 @@ function getStartLayerData(layer) { layerdata.achievements = []; layerdata.challenges = getStartChallenges(layer); layerdata.grid = getStartGrid(layer); + layerdata.prevTab = "" return layerdata; }