From 1493a401d2230ec1a3c72096cea7bf25a6f68741 Mon Sep 17 00:00:00 2001 From: ducdat0507 <62660527+ducdat0507@users.noreply.github.com> Date: Mon, 19 Dec 2022 19:17:43 +0700 Subject: [PATCH] Hotkey display --- src/components/Hotkey.vue | 50 ++++++++++++++++++++++++++++++++++++ src/data/layers/cloth.tsx | 25 +++++++++++++----- src/data/layers/letters.tsx | 21 ++++++++++++--- src/data/layers/trees.tsx | 17 +++++++++--- src/data/layers/workshop.tsx | 6 +++-- src/features/hotkey.tsx | 5 ++-- 6 files changed, 107 insertions(+), 17 deletions(-) create mode 100644 src/components/Hotkey.vue diff --git a/src/components/Hotkey.vue b/src/components/Hotkey.vue new file mode 100644 index 0000000..d5e90ce --- /dev/null +++ b/src/components/Hotkey.vue @@ -0,0 +1,50 @@ + + + + + + + diff --git a/src/data/layers/cloth.tsx b/src/data/layers/cloth.tsx index 720dab9..61a78d7 100644 --- a/src/data/layers/cloth.tsx +++ b/src/data/layers/cloth.tsx @@ -2,6 +2,7 @@ * @module * @hidden */ +import HotkeyVue from "components/Hotkey.vue"; import Row from "components/layout/Row.vue"; import Spacer from "components/layout/Spacer.vue"; import Modal from "components/Modal.vue"; @@ -61,7 +62,11 @@ const layer = createLayer(id, function (this: BaseLayer) { })); const breeding = createClickable(() => ({ display: { - title: "Breed sheep", + title: jsx(() => ( +

+ Breed sheep +

+ )), description: jsx(() => ( <> Breed {formatWhole(Decimal.floor(computedSheepGain.value))} sheep @@ -99,7 +104,11 @@ const layer = createLayer(id, function (this: BaseLayer) { })); const shearing = createClickable(() => ({ display: { - title: "Shear sheep", + title: jsx(() => ( +

+ Shear sheep +

+ )), description: jsx(() => ( <> Shear up to {formatWhole(Decimal.floor(computedShearingAmount.value))} sheep @@ -137,7 +146,11 @@ const layer = createLayer(id, function (this: BaseLayer) { })); const spinning = createClickable(() => ({ display: { - title: "Spinning wool", + title: jsx(() => ( +

+ Spin wool +

+ )), description: jsx(() => ( <> Spin {formatWhole(Decimal.floor(computedSpinningAmount.value))} wool @@ -165,7 +178,7 @@ const layer = createLayer(id, function (this: BaseLayer) { const breedSheepHK = createHotkey(() => ({ key: "b", - description: 'Press the "Breed Sheep" button', + description: "Breed sheep", onPress: () => { if (breeding.canClick.value) breeding.onClick(); } @@ -173,7 +186,7 @@ const layer = createLayer(id, function (this: BaseLayer) { const shearSheepHK = createHotkey(() => ({ key: "h", // For some reason, "shift+s" doesn't work properly - description: 'Press the "Shear Sheep" button', + description: "Shear sheep", onPress: () => { if (shearing.canClick.value) shearing.onClick(); } @@ -181,7 +194,7 @@ const layer = createLayer(id, function (this: BaseLayer) { const spinWoolHK = createHotkey(() => ({ key: "s", - description: 'Press the "Spin Wool" button', + description: "Spin wool", onPress: () => { if (spinning.canClick.value) spinning.onClick(); } diff --git a/src/data/layers/letters.tsx b/src/data/layers/letters.tsx index 93aceb0..6ed2210 100644 --- a/src/data/layers/letters.tsx +++ b/src/data/layers/letters.tsx @@ -27,6 +27,8 @@ import paper from "./paper"; import SqrtVue from "components/math/Sqrt.vue"; import { globalBus } from "game/events"; import { main } from "data/projEntry"; +import { createHotkey } from "features/hotkey"; +import HotkeyVue from "components/Hotkey.vue"; const id = "letters"; const day = 14; @@ -43,13 +45,17 @@ const layer = createLayer(id, function (this: BaseLayer) { height: 10, style: "margin-top: 8px", borderStyle: "border-color: black", - baseStyle: "margin-top: 0", - fillStyle: "margin-top: 0; transition-duration: 0s; background: black", + baseStyle: "margin-top: -1px", + fillStyle: "margin-top: -1px; transition-duration: 0s; background: black", progress: () => Decimal.div(processingProgress.value, computedProcessingCooldown.value) })); const process = createClickable(() => ({ display: { - title: "Process Letters", + title: jsx(() => ( +

+ Process letters +

+ )), description: jsx(() => ( <> Process {format(computedLettersGain.value, 1)} letters @@ -77,6 +83,14 @@ const layer = createLayer(id, function (this: BaseLayer) { } })); + const processHK = createHotkey(() => ({ + key: "l", + description: "Process letters", + onPress: () => { + if (process.canClick.value) process.onClick(); + } + })); + const metalBuyable = createBuyable(() => ({ display: { title: "Sorting Machine", @@ -285,6 +299,7 @@ const layer = createLayer(id, function (this: BaseLayer) { letters, totalLetters, processingProgress, + processHK, buyables, milestones, minWidth: 700, diff --git a/src/data/layers/trees.tsx b/src/data/layers/trees.tsx index dbfe739..7766d08 100644 --- a/src/data/layers/trees.tsx +++ b/src/data/layers/trees.tsx @@ -2,6 +2,7 @@ * @module * @hidden */ +import HotkeyVue from "components/Hotkey.vue"; import Spacer from "components/layout/Spacer.vue"; import Modal from "components/Modal.vue"; import { createCollapsibleModifierSections, setUpDailyProgressTracker } from "data/common"; @@ -564,7 +565,11 @@ const layer = createLayer(id, function (this: BaseLayer) { const cutTree = createClickable(() => ({ display: { - title: "Cut trees", + title: jsx(() => ( +

+ Cut trees +

+ )), description: jsx(() => ( <> Cut down up to {formatWhole(Decimal.floor(computedManualCuttingAmount.value))}{" "} @@ -620,7 +625,11 @@ const layer = createLayer(id, function (this: BaseLayer) { })); const plantTree = createClickable(() => ({ display: { - title: "Plant trees", + title: jsx(() => ( +

+ Plant trees +

+ )), description: jsx(() => ( <> Plant up to {formatWhole(Decimal.floor(computedManualPlantingAmount.value))}{" "} @@ -792,14 +801,14 @@ const layer = createLayer(id, function (this: BaseLayer) { const cutTreeHK = createHotkey(() => ({ key: "c", - description: 'Press the "Cut trees" button.', + description: "Cut trees", onPress: () => { if (cutTree.canClick.value) cutTree.onClick(); } })); const plantTreeHK = createHotkey(() => ({ key: "p", - description: 'Press the "Plant trees" button.', + description: "Plant trees", onPress: () => { if (plantTree.canClick.value) plantTree.onClick(); } diff --git a/src/data/layers/workshop.tsx b/src/data/layers/workshop.tsx index 1252950..7df7ef6 100644 --- a/src/data/layers/workshop.tsx +++ b/src/data/layers/workshop.tsx @@ -2,6 +2,7 @@ * @module * @hidden */ +import HotkeyVue from "components/Hotkey.vue"; import Spacer from "components/layout/Spacer.vue"; import { createCollapsibleMilestones } from "data/common"; import { main } from "data/projEntry"; @@ -76,7 +77,8 @@ const layer = createLayer(id, function (this: BaseLayer) { display: jsx(() => ( <> - Build {formatWhole(foundationConversion.actualGain.value)}% of the foundation + Build {formatWhole(foundationConversion.actualGain.value)}% of the foundation{" "} +

@@ -131,7 +133,7 @@ const layer = createLayer(id, function (this: BaseLayer) { const buildFoundationHK = createHotkey(() => ({ key: "w", - description: "Build part of the foundation.", + description: "Build foundation", onPress: () => { if (buildFoundation.canClick.value) buildFoundation.onClick(); } diff --git a/src/features/hotkey.tsx b/src/features/hotkey.tsx index bfb958f..b716f9a 100644 --- a/src/features/hotkey.tsx +++ b/src/features/hotkey.tsx @@ -13,6 +13,7 @@ import type { import { processComputable } from "util/computed"; import { createLazyProxy } from "util/proxies"; import { shallowReactive, unref } from "vue"; +import HotkeyVue from "components/Hotkey.vue"; export const hotkeys: Record = shallowReactive({}); export const HotkeyType = Symbol("Hotkey"); @@ -102,8 +103,8 @@ registerInfoComponent(

Hotkeys

{keys.map(hotkey => ( -
- {hotkey?.key}: {hotkey?.description} +
+ {hotkey?.description}
))}