1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-24 09:21:46 +00:00

Added "this" to tabFormat

This commit is contained in:
Harley White 2021-06-01 14:56:33 -04:00
parent b5a850bbee
commit 6273181bf8
6 changed files with 14 additions and 11 deletions

View file

@ -1,6 +1,7 @@
# The Modding Tree changelog: # The Modding Tree changelog:
- Fixed demo.html - Fixed demo.html
- You can now use "this" in tabFormat!
- Fixed certain things skipping negative rows (now they are treated like non-numeric rows, and don't appear in the tree still). - Fixed certain things skipping negative rows (now they are treated like non-numeric rows, and don't appear in the tree still).
### v2.5.11.1 - 5/27/21 ### v2.5.11.1 - 5/27/21

View file

@ -52,7 +52,7 @@ While reading this documentation, the following key will be used when describing
- [Bars](bars.md): Display some information as a progress bar, gauge, or similar. They are highly customizable, and can be horizontal and vertical as well. - [Bars](bars.md): Display some information as a progress bar, gauge, or similar. They are highly customizable, and can be horizontal and vertical as well.
- [Subtabs and Microtabs](subtabs-and-microtabs.md): Create subtabs for your tabs, as well as "microtab" components that you can put inside the tabs. - [Subtabs and Microtabs](subtabs-and-microtabs.md): Create subtabs for your tabs, as well as "microtab" components that you can put inside the tabs.
You can even use them to embed a layer inside another layer! You can even use them to embed a layer inside another layer!
- [Grids][grids.md]: Create a group buttons that behave the same, but have their own data. Good for map tiles, an inventory grid, and more! - [Grids](grids.md): Create a group buttons that behave the same, but have their own data. Good for map tiles, an inventory grid, and more!
- [Infoboxes](infoboxes.md): Boxes containing text that can be shown or hidden. - [Infoboxes](infoboxes.md): Boxes containing text that can be shown or hidden.
- [Trees](trees-and-tree-customization.md): Make your own trees. You can make non-layer button nodes too! - [Trees](trees-and-tree-customization.md): Make your own trees. You can make non-layer button nodes too!
- [Particle system](particles.md): Can be used to create particles for visual effects, but also interactable things like golden cookies or collectables. - [Particle system](particles.md): Can be used to create particles for visual effects, but also interactable things like golden cookies or collectables.

View file

@ -304,7 +304,7 @@ addLayer("c", {
["display-text", "Name your points!"], ["display-text", "Name your points!"],
["text-input", "thingy"], ["text-input", "thingy"],
["display-text", ["display-text",
function() {return 'I have ' + format(player.points) + ' ' + player.c.thingy + ' points!'}, function() {return 'I have ' + format(player.points) + ' ' + player[this.layer].thingy + ' points!'},
{"color": "red", "font-size": "32px", "font-family": "Comic Sans MS"}], {"color": "red", "font-size": "32px", "font-family": "Comic Sans MS"}],
"h-line", "milestones", "blank", "upgrades", "challenges"], "h-line", "milestones", "blank", "upgrades", "challenges"],
glowColor: "blue", glowColor: "blue",

View file

@ -306,9 +306,9 @@ function loadVue() {
Vue.component('respec-button', { Vue.component('respec-button', {
props: ['layer', 'data'], props: ['layer', 'data'],
template: ` template: `
<div> <div v-if="tmp[layer].buyables && tmp[layer].buyables.respec && !(tmp[layer].buyables.showRespec !== undefined && tmp[layer].buyables.showRespec == false)">
<div class="tooltipBox"><input type="checkbox" v-model="player[layer].noRespecConfirm" ><tooltip v-bind:text="'Disable respec confirmation'"></tooltip></div> <div class="tooltipBox"><input type="checkbox" v-model="player[layer].noRespecConfirm" ><tooltip v-bind:text="'Disable respec confirmation'"></tooltip></div>
<button v-if="tmp[layer].buyables && tmp[layer].buyables.respec && !(tmp[layer].buyables.showRespec !== undefined && tmp[layer].buyables.showRespec == false)" v-on:click="respecBuyables(layer)" v-bind:class="{ longUpg: true, can: player[layer].unlocked, locked: !player[layer].unlocked }" style="margin-right: 18px">{{tmp[layer].buyables.respecText ? tmp[layer].buyables.respecText : "Respec"}}</button> <button v-on:click="respecBuyables(layer)" v-bind:class="{ longUpg: true, can: player[layer].unlocked, locked: !player[layer].unlocked }" style="margin-right: 18px">{{tmp[layer].buyables.respecText ? tmp[layer].buyables.respecText : "Respec"}}</button>
</div> </div>
` `
}) })

View file

@ -147,9 +147,9 @@ function constructTabFormat(layer, id, family){
} }
if (isFunction(tabLayer)) { if (isFunction(tabLayer)) {
return tabLayer() return tabLayer.bind(location)()
} }
updateTempData(tabLayer, tabTemp, tabFunc) updateTempData(tabLayer, tabTemp, tabFunc, {layer, id, family})
return tabTemp return tabTemp
} }

View file

@ -109,18 +109,20 @@ function updateTemp() {
} }
} }
function updateTempData(layerData, tmpData, funcsData) { function updateTempData(layerData, tmpData, funcsData, useThis) {
for (item in funcsData){ for (item in funcsData){
if (Array.isArray(layerData[item])) { if (Array.isArray(layerData[item])) {
if (item !== "tabFormat" && item !== "content") // These are only updated when needed if (item !== "tabFormat" && item !== "content") // These are only updated when needed
updateTempData(layerData[item], tmpData[item], funcsData[item]) updateTempData(layerData[item], tmpData[item], funcsData[item], useThis)
} }
else if ((!!layerData[item]) && (layerData[item].constructor === Object) || (typeof layerData[item] === "object") && traversableClasses.includes(layerData[item].constructor.name)){ else if ((!!layerData[item]) && (layerData[item].constructor === Object) || (typeof layerData[item] === "object") && traversableClasses.includes(layerData[item].constructor.name)){
updateTempData(layerData[item], tmpData[item], funcsData[item]) updateTempData(layerData[item], tmpData[item], funcsData[item], useThis)
} }
else if (isFunction(layerData[item]) && !isFunction(tmpData[item])){ else if (isFunction(layerData[item]) && !isFunction(tmpData[item])){
let value = layerData[item]() let value
if (useThis !== undefined) value = layerData[item].bind(useThis)()
else value = layerData[item]()
if (value !== value || value === decimalNaN){ if (value !== value || value === decimalNaN){
if (NaNalert === true || confirm ("Invalid value found in tmp, named '" + item + "'. Please let the creator of this mod know! Would you like to try to auto-fix the save and keep going?")){ if (NaNalert === true || confirm ("Invalid value found in tmp, named '" + item + "'. Please let the creator of this mod know! Would you like to try to auto-fix the save and keep going?")){
NaNalert = true NaNalert = true