Add cut/plant tree hotkeys (c/p)

This commit is contained in:
Jacorb90 2022-12-03 18:54:59 -05:00
parent 5121215a37
commit a19a63984a

View file

@ -10,6 +10,7 @@ import { createBar } from "features/bars/bar";
import { createBuyable } from "features/buyable"; import { createBuyable } from "features/buyable";
import { createClickable } from "features/clickables/clickable"; import { createClickable } from "features/clickables/clickable";
import { jsx, showIf } from "features/feature"; import { jsx, showIf } from "features/feature";
import { createHotkey } from "features/hotkey";
import MainDisplay from "features/resources/MainDisplay.vue"; import MainDisplay from "features/resources/MainDisplay.vue";
import { createResource, trackTotal } from "features/resources/resource"; import { createResource, trackTotal } from "features/resources/resource";
import { createUpgrade } from "features/upgrades/upgrade"; import { createUpgrade } from "features/upgrades/upgrade";
@ -412,6 +413,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
fillStyle: "margin-top: 0; transition-duration: 0s", fillStyle: "margin-top: 0; transition-duration: 0s",
progress: () => Decimal.div(manualCutProgress.value, computedManualCuttingCooldown.value) progress: () => Decimal.div(manualCutProgress.value, computedManualCuttingCooldown.value)
})); }));
const cutTree = createClickable(() => ({ const cutTree = createClickable(() => ({
display: { display: {
title: "Cut trees", title: "Cut trees",
@ -625,6 +627,21 @@ const layer = createLayer(id, function (this: BaseLayer) {
Decimal.sub(computedAutoPlantingAmount.value, computedAutoCuttingAmount.value) Decimal.sub(computedAutoPlantingAmount.value, computedAutoCuttingAmount.value)
); );
const cutTreeHK = createHotkey(() => ({
key: "c",
description: "Press the \"Cut trees\" button.",
onPress: () => {
if (cutTree.canClick.value) cutTree.onClick();
}
}));
const plantTreeHK = createHotkey(() => ({
key: "p",
description: "Press the \"Plant trees\" button.",
onPress: () => {
if (plantTree.canClick.value) plantTree.onClick();
}
}));
return { return {
name, name,
color: colorBright, color: colorBright,
@ -634,6 +651,8 @@ const layer = createLayer(id, function (this: BaseLayer) {
saplings, saplings,
cutTree, cutTree,
plantTree, plantTree,
cutTreeHK,
plantTreeHK,
row1Upgrades, row1Upgrades,
row2Upgrades, row2Upgrades,
row1Buyables, row1Buyables,