diff --git a/js/Demo/demoLayers.js b/js/Demo/demoLayers.js
index 2e93fd3..46fea88 100644
--- a/js/Demo/demoLayers.js
+++ b/js/Demo/demoLayers.js
@@ -524,5 +524,32 @@ 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) {
+ player[this.layer].grid[id]++
+ },
+ getTitle(data, id) {
+ return "#" + id
+ },
+ getDisplay(data, id) {
+ return data
+ },
+ } ,
+ midsection: ["grid", "blank"]
+ }
+)
\ No newline at end of file
diff --git a/js/components.js b/js/components.js
index bd27909..f65224d 100644
--- a/js/components.js
+++ b/js/components.js
@@ -354,6 +354,57 @@ function loadVue() {
`
})
+
+ // data = button size, in px
+ Vue.component('grid', {
+ props: ['layer', 'data'],
+ template: `
+
+ `
+ })
+
+ Vue.component('gridable', {
+ props: ['layer', 'data'],
+ template: `
+
+ `,
+ data() { return { interval: false, time: 0,}},
+ computed: {
+ canClick() {
+ return gridRun(this.layer, 'getCanClick', player[this.layer].grid[this.data], this.data)}
+ },
+ methods: {
+ start() {
+ if (!this.interval && layers[this.layer].grid.onHold) {
+ this.interval = setInterval((function() {
+ if(this.time >= 5 && gridRun(this.layer, 'getCanClick', player[this.layer].grid[this.data], this.data)) {
+ gridRun(this.layer, 'onHold', player[this.layer].grid[this.data], this.data) }
+ this.time = this.time+1
+ }).bind(this), 50)}
+ },
+ stop() {
+ clearInterval(this.interval)
+ this.interval = false
+ this.time = 0
+ }
+ },
+ })
+
// data = button size, in px
Vue.component('microtabs', {
props: ['layer', 'data'],
diff --git a/js/technical/layerSupport.js b/js/technical/layerSupport.js
index 8ce18e2..165a4ac 100644
--- a/js/technical/layerSupport.js
+++ b/js/technical/layerSupport.js
@@ -156,6 +156,15 @@ function setupLayer(layer){
}
}
+ if (layers[layer].grid) {
+ layers[layer].grid.layer = layer
+ if (layers[layer].grid.getUnlocked === undefined)
+ layers[layer].grid.getUnlocked = true
+ if (layers[layer].grid.getCanClick === undefined)
+ layers[layer].grid.getCanClick = true
+
+ }
+
if (layers[layer].startData) {
data = layers[layer].startData()
if (data.best !== undefined && data.showBest === undefined) layers[layer].showBest = true
diff --git a/js/technical/temp.js b/js/technical/temp.js
index 8ee851b..2e22dea 100644
--- a/js/technical/temp.js
+++ b/js/technical/temp.js
@@ -11,6 +11,7 @@ var activeFunctions = [
"effectDescription", "display", "fullDisplay", "effectDisplay", "rewardDisplay",
"tabFormat", "content",
"onComplete", "onPurchase", "onEnter", "onExit",
+ "getUnlocked", "getStyle", "getCanClick",
]
var noCall = doNotCallTheseFunctionsEveryTick
diff --git a/js/utils.js b/js/utils.js
index ad57e97..253c42b 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -166,12 +166,20 @@ function buyBuyable(layer, id) {
function clickClickable(layer, id) {
if (!player[layer].unlocked) return
if (!tmp[layer].clickables[id].unlocked) return
- if (!tmp[layer].clickables[id].canClick) return
+ if (!tmp[layer].clickables[id].getCanClick) return
run(layers[layer].clickables[id].onClick, layers[layer].clickables[id])
updateClickableTemp(layer)
}
+function clickGrid(layer, id) {
+ if (!player[layer].unlocked) return
+ if (!run(layers[layer].grid.getUnlocked, layers[layer].grid, id)) return
+ if (!gridRun(layer, 'getCanClick', player[layer].grid[id], id)) return
+
+ gridRun(layer, 'onClick', player[layer].grid[id], id)
+}
+
// Function to determine if the player is in a challenge
function inChallenge(layer, id) {
let challenge = player[layer].activeChallenge
@@ -434,4 +442,13 @@ function run(func, target, args = null) {
}
else
return func;
+}
+
+function gridRun(layer, func, data, id) {
+ if (isFunction(layers[layer].grid[func])) {
+ let bound = layers[layer].grid[func].bind(layers[layer].grid)
+ return bound(data, id)
+ }
+ else
+ return layers[layer].grid[func];
}
\ No newline at end of file
diff --git a/js/utils/save.js b/js/utils/save.js
index e89866f..ce860b9 100644
--- a/js/utils/save.js
+++ b/js/utils/save.js
@@ -84,6 +84,8 @@ function getStartLayerData(layer) {
layerdata.lastMilestone = null;
layerdata.achievements = [];
layerdata.challenges = getStartChallenges(layer);
+ layerdata.grid = getStartGrid(layer);
+
return layerdata;
}
function getStartBuyables(layer) {
@@ -113,6 +115,20 @@ function getStartChallenges(layer) {
}
return data;
}
+function getStartGrid(layer) {
+ let data = {};
+ if (! layers[layer].grid) return data
+ if (layers[layer].grid.maxRows === undefined) layers[layer].grid.maxRows=layers[layer].grid.rows
+ if (layers[layer].grid.maxCols === undefined) layers[layer].grid.maxCols=layers[layer].grid.cols
+
+ for (let y = 1; y <= layers[layer].grid.maxRows; y++) {
+ for (let x = 1; x <= layers[layer].grid.maxCols; x++) {
+ data[100*y + x] = layers[layer].grid.getStartData(100*y + x)
+ }
+ }
+ return data;
+}
+
function fixSave() {
defaultData = getStartPlayer();
fixData(defaultData, player);
diff --git a/style.css b/style.css
index eab1e08..1942c4e 100644
--- a/style.css
+++ b/style.css
@@ -267,6 +267,22 @@ h1, h2, h3, b, input {
font-size: 10px;
}
+.tile {
+ height: 80px;
+ width: 80px;
+ border-radius: 12%;
+ border: 2px solid;
+ border-color: rgba(0, 0, 0, 0.125);
+ font-size: 10px;
+ overflow: visible;
+}
+
+.tile:hover {
+ box-shadow: 0 0 10px var(--points);
+ transform: scale(1.1, 1.1);
+ z-index: 7;
+}
+
.upgBig {
height: 200px;
width: 200px;