Added unthrottled setting
This commit is contained in:
parent
c617737788
commit
2eeb96a66f
4 changed files with 27 additions and 3 deletions
|
@ -26,6 +26,11 @@
|
|||
:value="hideChallenges"
|
||||
@change="toggleSettingsOption('hideChallenges')"
|
||||
/>
|
||||
<Toggle
|
||||
title="Unthrottled"
|
||||
:value="unthrottled"
|
||||
@change="toggleSettingsOption('unthrottled')"
|
||||
/>
|
||||
<Toggle
|
||||
title="Offline Production<tooltip display='Save-specific'>*</tooltip>"
|
||||
:value="offlineProd"
|
||||
|
@ -75,7 +80,7 @@ export default defineComponent({
|
|||
};
|
||||
},
|
||||
computed: {
|
||||
...mapSettings(["showTPS", "hideChallenges", "theme", "msDisplay"]),
|
||||
...mapSettings(["showTPS", "hideChallenges", "theme", "msDisplay", "unthrottled"]),
|
||||
...mapPlayer(["autosave", "offlineProd"]),
|
||||
paused() {
|
||||
return player.devSpeed === 0;
|
||||
|
|
|
@ -3,6 +3,7 @@ import modInfo from "@/data/modInfo.json";
|
|||
import Decimal, { DecimalSource } from "@/util/bignum";
|
||||
import { layers } from "./layers";
|
||||
import player from "./player";
|
||||
import settings from "./settings";
|
||||
import state from "./state";
|
||||
|
||||
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
||||
|
@ -107,6 +108,8 @@ function updateLayers(diff: DecimalSource) {
|
|||
});
|
||||
}
|
||||
|
||||
let intervalID: number | null = null;
|
||||
|
||||
function update() {
|
||||
const now = Date.now();
|
||||
let diff: DecimalSource = (now - player.time) / 1e3;
|
||||
|
@ -169,8 +172,22 @@ function update() {
|
|||
updateLayers(diff);
|
||||
|
||||
player.justLoaded = false;
|
||||
|
||||
if (settings.unthrottled) {
|
||||
requestAnimationFrame(update);
|
||||
if (intervalID != null) {
|
||||
clearInterval(intervalID);
|
||||
intervalID = null;
|
||||
}
|
||||
} else if (intervalID == null) {
|
||||
intervalID = setInterval(update, 50);
|
||||
}
|
||||
}
|
||||
|
||||
export default function startGameLoop(): void {
|
||||
setInterval(update, 50);
|
||||
if (settings.unthrottled) {
|
||||
requestAnimationFrame(update);
|
||||
} else {
|
||||
intervalID = setInterval(update, 50);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@ const state = reactive<Settings>({
|
|||
showTPS: true,
|
||||
msDisplay: MilestoneDisplay.All,
|
||||
hideChallenges: false,
|
||||
theme: Themes.Nordic
|
||||
theme: Themes.Nordic,
|
||||
unthrottled: false
|
||||
});
|
||||
|
||||
const settingsHandler: ProxyHandler<Record<string, any>> = {
|
||||
|
|
1
src/typings/settings.d.ts
vendored
1
src/typings/settings.d.ts
vendored
|
@ -9,5 +9,6 @@ export interface Settings {
|
|||
msDisplay: MilestoneDisplay;
|
||||
hideChallenges: boolean;
|
||||
theme: Themes;
|
||||
unthrottled: boolean;
|
||||
[index: string]: unknown;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue