Skip to content

Commit

Permalink
Fix custom difficulty settings
Browse files Browse the repository at this point in the history
  • Loading branch information
CloneWith committed Jul 13, 2024
1 parent 4f4b9d5 commit cef2049
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/itdelatrisu/opsu/options/OptionGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public class OptionGroup {
}),
new OptionGroup(t("Custom"), GameImage.MENU_NAV_CUSTOM),
new OptionGroup(t("DIFFICULTY"), new GameOption[] {
GameOption.CUSTOM_DIFFICULTY,
GameOption.FIXED_CS,
GameOption.FIXED_HP,
GameOption.FIXED_AR,
Expand Down
8 changes: 8 additions & 0 deletions src/itdelatrisu/opsu/options/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ public void read(String s) {
String.format(t("Loads HD (%s) images when available.\nIncreases memory usage and loading times."),
GameImage.HD_SUFFIX),
true),
CUSTOM_DIFFICULTY(t("Use custom difficulty"), "CustomDiff", t("Use your own difficulty settings for beatmaps!"), false),
FIXED_CS(t("Fixed CS"), "FixedCS", t("Determines the size of circles and sliders."), 0, 0, 100) {
@Override
public String getValueString() {
Expand Down Expand Up @@ -1600,6 +1601,13 @@ public static boolean isExperimentalSliderMerging() {
return GameOption.EXPERIMENTAL_SLIDERS_MERGE.getBooleanValue();
}

/**
* Returns whether to use user-defined difficulty settings.
*
* @return true if use custom difficulty settings
*/
public static boolean isDifficultyCustom() { return GameOption.CUSTOM_DIFFICULTY.getBooleanValue(); }

/**
* Returns the fixed circle size override, if any.
*
Expand Down
18 changes: 10 additions & 8 deletions src/itdelatrisu/opsu/states/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -1627,8 +1627,7 @@ else if (hitObject.isSpinner())
UI.getNotificationManager().sendBarNotification(String.format(t("Using local beatmap offset (%dms)"), beatmap.localMusicOffset));

// using custom difficulty settings?
if (Options.getFixedCS() > 0f || Options.getFixedAR() > 0f || Options.getFixedOD() > 0f ||
Options.getFixedHP() > 0f || Options.getFixedSpeed() > 0f)
if (Options.isDifficultyCustom())
UI.getNotificationManager().sendNotification(t("Playing with custom difficulty settings."));

// load video
Expand Down Expand Up @@ -1972,13 +1971,14 @@ private void loadVideo(int offset) {
* Set map modifiers.
*/
private void setMapModifiers() {
boolean isCustom = Options.isDifficultyCustom();
boolean isAllowBeyond = Options.isInsaneSettingAllowed();
// map-based properties, re-initialized each game
float multiplier = GameMod.getDifficultyMultiplier();
float circleSize = Options.getFixedCS() > 0f ? Options.getFixedCS() * multiplier : beatmap.circleSize * multiplier;
float approachRate = Options.getFixedAR() > 0f ? Options.getFixedAR() * multiplier : beatmap.approachRate * multiplier;
float overallDifficulty = Options.getFixedOD() > 0f ? Options.getFixedOD() * multiplier : beatmap.overallDifficulty * multiplier;
float HPDrainRate = Options.getFixedHP() > 0f ? Options.getFixedHP() * multiplier : beatmap.HPDrainRate * multiplier;
float circleSize = (isCustom && Options.getFixedCS() > 0f) ? Options.getFixedCS() * multiplier : beatmap.circleSize * multiplier;
float approachRate = (isCustom && Options.getFixedAR() > 0f) ? Options.getFixedAR() * multiplier : beatmap.approachRate * multiplier;
float overallDifficulty = (isCustom && Options.getFixedOD() > 0f) ? Options.getFixedOD() * multiplier : beatmap.overallDifficulty * multiplier;
float HPDrainRate = (isCustom && Options.getFixedHP() > 0f) ? Options.getFixedHP() * multiplier : beatmap.HPDrainRate * multiplier;
circleSize = isAllowBeyond ? circleSize : Math.min(circleSize, 10f);
approachRate = isAllowBeyond ? approachRate : Math.min(approachRate, 10f);
overallDifficulty = isAllowBeyond ? overallDifficulty : Math.min(overallDifficulty, 10f);
Expand All @@ -1998,7 +1998,7 @@ private void setMapModifiers() {
Options.getSkin().getSliderBorderColor() : beatmap.getSliderBorderColor());

// approachRate (hit object approach time)
approachTime = (int) Utils.mapDifficultyRange(approachRate, 1800, 1200, 450, 50);
approachTime = (int) Utils.mapDifficultyRange(approachRate, 1800, 1200, 450);

// overallDifficulty (hit result time offsets)
hitResultOffset = new int[GameData.HIT_MAX];
Expand All @@ -2017,7 +2017,9 @@ private void setMapModifiers() {
// difficulty multiplier (scoring)
data.calculateDifficultyMultiplier(beatmap.HPDrainRate, beatmap.circleSize, beatmap.overallDifficulty);

int minFadeTime = isAllowBeyond ? OBJ_FADE_IN_TIME : 375;
// FIXME
// int minFadeTime = isAllowBeyond ? OBJ_FADE_IN_TIME : 375;
int minFadeTime = 375;

// hit object fade-in time (TODO: formula)
fadeInTime = Math.min(minFadeTime, (int) (approachTime / 2.5f));
Expand Down

0 comments on commit cef2049

Please sign in to comment.