Removed dynamic imports
This commit is contained in:
parent
673f7790c7
commit
6ba25f9abd
6 changed files with 64 additions and 62 deletions
|
@ -306,18 +306,20 @@ const msDisplayOptions = Object.values(AchievementDisplay).map(option => ({
|
|||
value: option
|
||||
}));
|
||||
|
||||
registerSettingField(
|
||||
jsx(() => (
|
||||
<Select
|
||||
title={jsx(() => (
|
||||
<span class="option-title">
|
||||
Show achievements
|
||||
<desc>Select which achievements to display based on criterias.</desc>
|
||||
</span>
|
||||
))}
|
||||
options={msDisplayOptions}
|
||||
onUpdate:modelValue={value => (settings.msDisplay = value as AchievementDisplay)}
|
||||
modelValue={settings.msDisplay}
|
||||
/>
|
||||
))
|
||||
globalBus.on("setupVue", () =>
|
||||
registerSettingField(
|
||||
jsx(() => (
|
||||
<Select
|
||||
title={jsx(() => (
|
||||
<span class="option-title">
|
||||
Show achievements
|
||||
<desc>Select which achievements to display based on criterias.</desc>
|
||||
</span>
|
||||
))}
|
||||
options={msDisplayOptions}
|
||||
onUpdate:modelValue={value => (settings.msDisplay = value as AchievementDisplay)}
|
||||
modelValue={settings.msDisplay}
|
||||
/>
|
||||
))
|
||||
)
|
||||
);
|
||||
|
|
|
@ -364,17 +364,19 @@ globalBus.on("loadSettings", settings => {
|
|||
setDefault(settings, "hideChallenges", false);
|
||||
});
|
||||
|
||||
registerSettingField(
|
||||
jsx(() => (
|
||||
<Toggle
|
||||
title={jsx(() => (
|
||||
<span class="option-title">
|
||||
Hide maxed challenges
|
||||
<desc>Hide challenges that have been fully completed.</desc>
|
||||
</span>
|
||||
))}
|
||||
onUpdate:modelValue={value => (settings.hideChallenges = value)}
|
||||
modelValue={settings.hideChallenges}
|
||||
/>
|
||||
))
|
||||
globalBus.on("setupVue", () =>
|
||||
registerSettingField(
|
||||
jsx(() => (
|
||||
<Toggle
|
||||
title={jsx(() => (
|
||||
<span class="option-title">
|
||||
Hide maxed challenges
|
||||
<desc>Hide challenges that have been fully completed.</desc>
|
||||
</span>
|
||||
))}
|
||||
onUpdate:modelValue={value => (settings.hideChallenges = value)}
|
||||
modelValue={settings.hideChallenges}
|
||||
/>
|
||||
))
|
||||
)
|
||||
);
|
||||
|
|
|
@ -129,24 +129,26 @@ document.onkeydown = function (e) {
|
|||
}
|
||||
};
|
||||
|
||||
registerInfoComponent(
|
||||
jsx(() => {
|
||||
const keys = Object.values(hotkeys).filter(hotkey => unref(hotkey?.enabled));
|
||||
if (keys.length === 0) {
|
||||
return "";
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<br />
|
||||
<h4>Hotkeys</h4>
|
||||
<div style="column-count: 2">
|
||||
{keys.map(hotkey => (
|
||||
<div>
|
||||
<Hotkey hotkey={hotkey as GenericHotkey} /> {unref(hotkey?.description)}
|
||||
</div>
|
||||
))}
|
||||
globalBus.on("setupVue", () =>
|
||||
registerInfoComponent(
|
||||
jsx(() => {
|
||||
const keys = Object.values(hotkeys).filter(hotkey => unref(hotkey?.enabled));
|
||||
if (keys.length === 0) {
|
||||
return "";
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<br />
|
||||
<h4>Hotkeys</h4>
|
||||
<div style="column-count: 2">
|
||||
{keys.map(hotkey => (
|
||||
<div>
|
||||
<Hotkey hotkey={hotkey as GenericHotkey} /> {unref(}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})
|
||||
);
|
||||
})
|
||||
)
|
||||
);
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
import { hasWon } from "data/projEntry";
|
||||
import projInfo from "data/projInfo.json";
|
||||
import { globalBus } from "game/events";
|
||||
import settings from "game/settings";
|
||||
import Decimal from "util/bignum";
|
||||
import { loadingSave } from "util/save";
|
||||
import type { Ref } from "vue";
|
||||
import { watch } from "vue";
|
||||
import player from "./player";
|
||||
import state from "./state";
|
||||
|
||||
let intervalID: NodeJS.Timer | null = null;
|
||||
|
||||
// Not imported immediately due to dependency cycles
|
||||
// This gets set during startGameLoop(), and will only be used in the update function
|
||||
let hasWon: null | Ref<boolean> = null;
|
||||
|
||||
function update() {
|
||||
const now = Date.now();
|
||||
let diff = (now - player.time) / 1e3;
|
||||
|
@ -95,12 +91,6 @@ function update() {
|
|||
|
||||
/** Starts the game loop for the project, which updates the game in ticks. */
|
||||
export async function startGameLoop() {
|
||||
hasWon = (await import("data/projEntry")).hasWon;
|
||||
watch(hasWon, hasWon => {
|
||||
if (hasWon) {
|
||||
globalBus.emit("gameWon");
|
||||
}
|
||||
});
|
||||
if (settings.unthrottled) {
|
||||
requestAnimationFrame(update);
|
||||
} else {
|
||||
|
@ -108,6 +98,12 @@ export async function startGameLoop() {
|
|||
}
|
||||
}
|
||||
|
||||
watch(hasWon, hasWon => {
|
||||
if (hasWon) {
|
||||
globalBus.emit("gameWon");
|
||||
}
|
||||
});
|
||||
|
||||
setInterval(() => {
|
||||
state.mouseActivity = [...state.mouseActivity.slice(-7), false];
|
||||
}, 1000 * 60 * 60);
|
||||
|
|
|
@ -3,12 +3,14 @@ import App from "App.vue";
|
|||
import projInfo from "data/projInfo.json";
|
||||
import "game/notifications";
|
||||
import state from "game/state";
|
||||
import "util/galaxy";
|
||||
import { load } from "util/save";
|
||||
import { useRegisterSW } from "virtual:pwa-register/vue";
|
||||
import type { App as VueApp } from "vue";
|
||||
import { createApp, nextTick } from "vue";
|
||||
import { useToast } from "vue-toastification";
|
||||
import "util/galaxy";
|
||||
import { globalBus } from "./game/events";
|
||||
import { startGameLoop } from "./game/gameLoop";
|
||||
|
||||
declare global {
|
||||
/**
|
||||
|
@ -56,8 +58,6 @@ requestAnimationFrame(async () => {
|
|||
"padding: 4px;"
|
||||
);
|
||||
await load();
|
||||
const { globalBus } = await import("./game/events");
|
||||
const { startGameLoop } = await import("./game/gameLoop");
|
||||
|
||||
// Create Vue
|
||||
const vue = (window.vue = createApp(App));
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { LoadablePlayerData } from "components/modals/SavesManager.vue";
|
||||
import { fixOldSave, getInitialLayers } from "data/projEntry";
|
||||
import projInfo from "data/projInfo.json";
|
||||
import { globalBus } from "game/events";
|
||||
import { addLayer, layers, removeLayer } from "game/layers";
|
||||
import type { Player } from "game/player";
|
||||
import player, { stringifySave } from "game/player";
|
||||
import settings, { loadSettings } from "game/settings";
|
||||
|
@ -101,8 +103,6 @@ export const loadingSave = ref(false);
|
|||
export async function loadSave(playerObj: Partial<Player>): Promise<void> {
|
||||
console.info("Loading save", playerObj);
|
||||
loadingSave.value = true;
|
||||
const { layers, removeLayer, addLayer } = await import("game/layers");
|
||||
const { fixOldSave, getInitialLayers } = await import("data/projEntry");
|
||||
|
||||
for (const layer in layers) {
|
||||
const l = layers[layer];
|
||||
|
|
Loading…
Reference in a new issue