From 3bdf33a4b65a5cad8488b983d4bf392a05420010 Mon Sep 17 00:00:00 2001 From: ducdat0507 <62660527+ducdat0507@users.noreply.github.com> Date: Tue, 13 Dec 2022 19:53:15 +0700 Subject: [PATCH] Settings update --- .vscode/settings.json | 2 +- src/components/Options.vue | 119 ++++++++++++++++++++++---- src/components/common/modifiers.css | 5 +- src/components/fields/Select.vue | 4 + src/components/fields/Toggle.vue | 8 +- src/data/common.tsx | 5 +- src/data/layers/management.tsx | 2 +- src/data/projEntry.tsx | 4 +- src/features/challenges/challenge.tsx | 7 +- src/features/milestones/milestone.tsx | 7 +- src/game/modifiers.tsx | 4 +- src/game/player.ts | 8 +- src/game/settings.ts | 17 +++- 13 files changed, 155 insertions(+), 37 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ddcd19b..25708ee 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,7 +6,7 @@ "editor.defaultFormatter": "esbenp.prettier-vscode", "git.ignoreLimitWarning": true, "[typescriptreact]": { - "editor.defaultFormatter": "vscode.typescript-language-features" + "editor.defaultFormatter": "esbenp.prettier-vscode" }, "typescript.tsdk": "node_modules/typescript/lib" } \ No newline at end of file diff --git a/src/components/Options.vue b/src/components/Options.vue index 4ac105a..bc7ed8e 100644 --- a/src/components/Options.vue +++ b/src/components/Options.vue @@ -1,17 +1,26 @@ @@ -25,19 +34,36 @@ import Tooltip from "features/tooltips/Tooltip.vue"; import player from "game/player"; import settings, { settingFields } from "game/settings"; import { camelToTitle } from "util/common"; +import { save } from "util/save"; import { coerceComponent, render } from "util/vue"; import { computed, ref, toRefs } from "vue"; import Select from "./fields/Select.vue"; import Toggle from "./fields/Toggle.vue"; +import FeedbackButton from "./fields/FeedbackButton.vue"; const isOpen = ref(false); +const currentTab = ref("behaviour"); + defineExpose({ + isTab, + setTab, + save() { + save(); + }, open() { isOpen.value = true; } }); +function isTab (tab: string): boolean { + return tab == currentTab.value; +} + +function setTab (tab: string) { + currentTab.value = tab; +} + const themes = Object.keys(rawThemes).map(theme => ({ label: camelToTitle(theme), value: theme @@ -47,8 +73,10 @@ const settingFieldsComponent = computed(() => { return coerceComponent(jsx(() => <>{settingFields.map(render)})); }); -const { showTPS, theme } = toRefs(settings); -const { autosave, usingLog, alignUnits } = toRefs(player); +const { showTPS, theme, usingLog, alignUnits } = toRefs(settings); + +const { autosave, autoPause } = toRefs(player); + const isPaused = computed({ get() { return player.devSpeed === 0; @@ -58,32 +86,85 @@ const isPaused = computed({ } }); + const autosaveTitle = jsx(() => ( - + Autosave* + Automatically save the game every second or when the game is closed. )); const isPausedTitle = jsx(() => ( - + Pause game* + Stop everything from moving. + +)); +const autoPauseTitle = jsx(() => ( + + Auto-pause* + Automatically pause the game when a day is completed. It is best to keep this on to avoid over-grinding. + +)); + +const themeTitle = jsx(() => ( + + Theme + How the game looks. + +)); +const showTPSTitle = jsx(() => ( + + Show TPS + Show TPS meter at the bottom-left corner of the page. )); const progressMethodTitle = jsx(() => ( - - Logarithmic progress bars* + + Logarithmic progress bars + Whether progress bars should be normalized for exponential growth. )); const alignModifierUnitsTitle = jsx(() => ( - - Align modifier units* + + Align modifier units + Align numbers to the beginning of the unit in modifier view. )); - diff --git a/src/components/common/modifiers.css b/src/components/common/modifiers.css index 6842e0c..dc9e66d 100644 --- a/src/components/common/modifiers.css +++ b/src/components/common/modifiers.css @@ -8,10 +8,13 @@ } .modifier-amount { - flex-basis: 100px; flex-shrink: 0; text-align: right; } +:not(:first-of-type, :last-of-type) > .modifier-amount::after { + content: var(--unit); + opacity: 0; +} .modifier-description { flex-grow: 1; diff --git a/src/components/fields/Select.vue b/src/components/fields/Select.vue index f08c40f..72a31b2 100644 --- a/src/components/fields/Select.vue +++ b/src/components/fields/Select.vue @@ -87,6 +87,10 @@ function onUpdate(value: SelectOption) { background-color: var(--bought); } +.vue-input input { + font-size: inherit; +} + .vue-input input::placeholder { color: var(--link); } diff --git a/src/components/fields/Toggle.vue b/src/components/fields/Toggle.vue index 0db8bd1..a1eeff3 100644 --- a/src/components/fields/Toggle.vue +++ b/src/components/fields/Toggle.vue @@ -44,14 +44,16 @@ input { span { width: 100%; + padding-right: 41px; position: relative; } /* track */ input + span::before { content: ""; - float: right; - margin: 5px 0 5px 10px; + position: absolute; + top: calc(50% - 7px); + right: 0px; border-radius: 7px; width: 36px; height: 14px; @@ -66,7 +68,7 @@ input + span::before { input + span::after { content: ""; position: absolute; - top: 2px; + top: calc(50% - 10px); right: 16px; border-radius: 50%; width: 20px; diff --git a/src/data/common.tsx b/src/data/common.tsx index 5c1db03..be75f9b 100644 --- a/src/data/common.tsx +++ b/src/data/common.tsx @@ -20,6 +20,7 @@ import type { Modifier } from "game/modifiers"; import type { Persistent } from "game/persistence"; import { DefaultValue, persistent } from "game/persistence"; import player from "game/player"; +import settings from "game/settings"; import type { DecimalSource } from "util/bignum"; import Decimal, { format } from "util/bignum"; import { formatWhole } from "util/break_eternity"; @@ -333,7 +334,7 @@ export function createCollapsibleModifierSections( return ( <> {hasPreviousSection ?
: null} -
+
{header}
{modifiers} @@ -424,7 +425,7 @@ export function setUpDailyProgressTracker(options: { if (main.day.value !== options.day) return 1; let progress = Decimal.add(total.value, 1); let requirement = options.goal; - if (options.usingLog?.value ?? player.usingLog) { + if (options.usingLog?.value ?? settings.usingLog) { progress = progress.log10(); requirement = Decimal.log10(requirement); } diff --git a/src/data/layers/management.tsx b/src/data/layers/management.tsx index 994d1ad..2987ab2 100644 --- a/src/data/layers/management.tsx +++ b/src/data/layers/management.tsx @@ -1164,7 +1164,7 @@ const layer = createLayer(id, () => {

Build a Classroom

Hopefully it makes the school a bit less boring. Multiplies elves' XP gain by{" "} - Classrooms + 1. + (Classrooms + 1)0.9.
You have {formatWhole(classrooms.amount.value)} classrooms, which are currently diff --git a/src/data/projEntry.tsx b/src/data/projEntry.tsx index 3d77eae..0004f0e 100644 --- a/src/data/projEntry.tsx +++ b/src/data/projEntry.tsx @@ -146,7 +146,7 @@ export const main = createLayer("main", function (this: BaseLayer) { loreScene.value = -1; loreTitle.value = unref(layers[layer ?? "trees"]?.name ?? ""); loreBody.value = story; - player.devSpeed = null; + if (player.autoPause) player.devSpeed = null; showLoreModal.value = true; }, 1000); } @@ -370,7 +370,7 @@ export const main = createLayer("main", function (this: BaseLayer) { showLoreModal.value = true; day.value++; main.minimized.value = false; - player.devSpeed = 0; + if (player.autoPause) player.devSpeed = 0; } return { diff --git a/src/features/challenges/challenge.tsx b/src/features/challenges/challenge.tsx index 469d34a..8128ab2 100644 --- a/src/features/challenges/challenge.tsx +++ b/src/features/challenges/challenge.tsx @@ -299,7 +299,12 @@ globalBus.on("loadSettings", settings => { registerSettingField( jsx(() => ( ( + + Hide maxed challenges + Hide challenges that have been fully completed. + + ))} onUpdate:modelValue={value => (settings.hideChallenges = value)} modelValue={settings.hideChallenges} /> diff --git a/src/features/milestones/milestone.tsx b/src/features/milestones/milestone.tsx index 2671e21..d70d6ec 100644 --- a/src/features/milestones/milestone.tsx +++ b/src/features/milestones/milestone.tsx @@ -204,7 +204,12 @@ const msDisplayOptions = Object.values(MilestoneDisplay).map(option => ({ registerSettingField( jsx(() => (