Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to auto jump to end of replay #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ function PlaybarSettingsSection() {
}
label={"Show difficulty graph"}
/>
<FormControlLabel
control={
<Switch
checked={settings.jumpToEndOnLoad}
onChange={(event) =>
playbarSettingsStore.changeSettings((s) => (s.jumpToEndOnLoad = event.target.checked))
}
/>
}
label={"Jump to end of replay"}
/>
</FormGroup>
</Stack>
</Paper>
Expand Down
3 changes: 3 additions & 0 deletions apps/desktop/frontend/src/app/services/common/playbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ import { JSONSchemaType } from "ajv";

export interface PlaybarSettings {
difficultyGraphEnabled: boolean;
jumpToEndOnLoad: boolean;
}

export const DEFAULT_PLAY_BAR_SETTINGS: PlaybarSettings = Object.freeze({
difficultyGraphEnabled: true,
jumpToEndOnLoad: false,
});

export const PlaybarSettingsSchema: JSONSchemaType<PlaybarSettings> = {
type: "object",
properties: {
difficultyGraphEnabled: { type: "boolean", default: DEFAULT_PLAY_BAR_SETTINGS.difficultyGraphEnabled },
jumpToEndOnLoad: { type: "boolean", default: DEFAULT_PLAY_BAR_SETTINGS.jumpToEndOnLoad },
},
required: [],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { readFile } from "fs/promises";
import { BlueprintLocatorService } from "../common/local/BlueprintLocatorService";
import { OsuFolderService } from "../common/local/OsuFolderService";
import { BeatmapBackgroundSettingsStore } from "../common/beatmap-background";
import { PlaybarSettingsStore } from "../common/playbar";
import { TextureManager } from "../textures/TextureManager";
import { ReplayFileWatcher } from "../common/local/ReplayFileWatcher";
import { ModSettingsService } from "../analysis/mod-settings";
Expand Down Expand Up @@ -44,6 +45,7 @@ export class ScenarioManager {
private readonly textureManager: TextureManager,
private readonly replayService: ReplayService,
private readonly beatmapBackgroundSettingsStore: BeatmapBackgroundSettingsStore,
private readonly playbarSettingsStore: PlaybarSettingsStore,
private readonly beatmapManager: BeatmapManager,
private readonly replayManager: ReplayManager,
private readonly sceneManager: AnalysisSceneManager,
Expand Down Expand Up @@ -103,6 +105,9 @@ export class ScenarioManager {
const duration = (this.audioEngine.song?.mediaElement.duration ?? 0) * 1000;
this.gameClock.setDuration(duration);
this.gameSimulator.calculateDifficulties(rawBlueprint, duration, modsToBitmask(replay.mods));
if (this.playbarSettingsStore.getSettings().jumpToEndOnLoad) {
this.gameClock.seekTo(duration);
}
});

// If the building is too slow or unbearable, we should push the building to a WebWorker, but right now it's ok
Expand Down