Skip to content

Commit

Permalink
Use original OD value when using PR mod in beatmap info
Browse files Browse the repository at this point in the history
  • Loading branch information
Rian8337 committed Jan 4, 2025
1 parent b159594 commit c0309ab
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/ts/drawables/DrawableBeatmapInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { BeatmapDifficulty, Modes, ModUtil } from "@rian8337/osu-base";
import {
BeatmapDifficulty,
DroidHitWindow,
Modes,
ModPrecise,
ModUtil,
PreciseDroidHitWindow,
} from "@rian8337/osu-base";
import {
droidStarRating,
mostCommonBPM,
Expand Down Expand Up @@ -103,6 +110,15 @@ export class DrawableBeatmapInfo {
true,
);

if (mods.some((m) => m instanceof ModPrecise)) {
// Special case for OD. The Precise mod changes the hit window and not the OD itself, but we must
// map the hit window back to the original hit window for the user to understand the difficulty
// increase of the mod.
const { greatWindow } = new PreciseDroidHitWindow(difficulty.od);

difficulty.od = DroidHitWindow.greatWindowToOD(greatWindow);
}

// CS, AR, OD
this.write("CS", difficulty.cs.toFixed(2).replace(/\.?0+$/, ""), " / ");
this.write("AR", difficulty.ar.toFixed(2).replace(/\.?0+$/, ""), " / ");
Expand Down Expand Up @@ -157,11 +173,19 @@ export class DrawableBeatmapInfo {
this.setFont(true);

if (trimIfTooLong) {
let wasTrimmed = false;

while (
value.length > 3 &&
this.ctx.measureText(value).width >
this.screen.width / 4 - this.widthMargin
this.screen.width / 4 - this.widthMargin * 2
) {
value = value.slice(0, -3) + "...";
wasTrimmed = true;
value = value.slice(0, -3);
}

if (wasTrimmed) {
value += "...";
}
}

Expand All @@ -176,9 +200,7 @@ export class DrawableBeatmapInfo {
}

private formatNullableDecimal(value: number | null) {
return value === null
? "Unknown"
: value.toFixed(2).replace(/\.?0+$/, "");
return value?.toFixed(2).replace(/\.?0+$/, "") ?? "Unknown";
}

private translateTo(x: number, y: number) {
Expand Down

0 comments on commit c0309ab

Please sign in to comment.