forked from profectus/Profectus
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"
|
:value="hideChallenges"
|
||||||
@change="toggleSettingsOption('hideChallenges')"
|
@change="toggleSettingsOption('hideChallenges')"
|
||||||
/>
|
/>
|
||||||
|
<Toggle
|
||||||
|
title="Unthrottled"
|
||||||
|
:value="unthrottled"
|
||||||
|
@change="toggleSettingsOption('unthrottled')"
|
||||||
|
/>
|
||||||
<Toggle
|
<Toggle
|
||||||
title="Offline Production<tooltip display='Save-specific'>*</tooltip>"
|
title="Offline Production<tooltip display='Save-specific'>*</tooltip>"
|
||||||
:value="offlineProd"
|
:value="offlineProd"
|
||||||
|
@ -75,7 +80,7 @@ export default defineComponent({
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapSettings(["showTPS", "hideChallenges", "theme", "msDisplay"]),
|
...mapSettings(["showTPS", "hideChallenges", "theme", "msDisplay", "unthrottled"]),
|
||||||
...mapPlayer(["autosave", "offlineProd"]),
|
...mapPlayer(["autosave", "offlineProd"]),
|
||||||
paused() {
|
paused() {
|
||||||
return player.devSpeed === 0;
|
return player.devSpeed === 0;
|
||||||
|
|
|
@ -3,6 +3,7 @@ import modInfo from "@/data/modInfo.json";
|
||||||
import Decimal, { DecimalSource } from "@/util/bignum";
|
import Decimal, { DecimalSource } from "@/util/bignum";
|
||||||
import { layers } from "./layers";
|
import { layers } from "./layers";
|
||||||
import player from "./player";
|
import player from "./player";
|
||||||
|
import settings from "./settings";
|
||||||
import state from "./state";
|
import state from "./state";
|
||||||
|
|
||||||
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
||||||
|
@ -107,6 +108,8 @@ function updateLayers(diff: DecimalSource) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let intervalID: number | null = null;
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
let diff: DecimalSource = (now - player.time) / 1e3;
|
let diff: DecimalSource = (now - player.time) / 1e3;
|
||||||
|
@ -169,8 +172,22 @@ function update() {
|
||||||
updateLayers(diff);
|
updateLayers(diff);
|
||||||
|
|
||||||
player.justLoaded = false;
|
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 {
|
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,
|
showTPS: true,
|
||||||
msDisplay: MilestoneDisplay.All,
|
msDisplay: MilestoneDisplay.All,
|
||||||
hideChallenges: false,
|
hideChallenges: false,
|
||||||
theme: Themes.Nordic
|
theme: Themes.Nordic,
|
||||||
|
unthrottled: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const settingsHandler: ProxyHandler<Record<string, any>> = {
|
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;
|
msDisplay: MilestoneDisplay;
|
||||||
hideChallenges: boolean;
|
hideChallenges: boolean;
|
||||||
theme: Themes;
|
theme: Themes;
|
||||||
|
unthrottled: boolean;
|
||||||
[index: string]: unknown;
|
[index: string]: unknown;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue