Skip to content

Commit

Permalink
Initial implementation of difficulty custom adjustment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reco1I committed Nov 23, 2023
1 parent 3dde6e0 commit 4b27492
Show file tree
Hide file tree
Showing 11 changed files with 760 additions and 382 deletions.
488 changes: 272 additions & 216 deletions res/layout/fragment_in_game_option.xml

Large diffs are not rendered by default.

264 changes: 183 additions & 81 deletions src/com/edlplan/ui/fragment/InGameSettingMenu.java

Large diffs are not rendered by default.

30 changes: 26 additions & 4 deletions src/com/reco1l/api/ibancho/RoomAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,25 @@ object RoomAPI
* Change room mods.
*/
@JvmStatic
fun setRoomMods(mods: String?, speedMultiplier: Float, flFollowDelay: Float, forceAR: Float? = null)
fun setRoomMods(
mods: String?,
speedMultiplier: Float,
flFollowDelay: Float,
customAR: Float? = null,
customOD: Float? = null,
customCS: Float? = null,
customHP: Float? = null
)
{
val json = JSONObject().apply {

put("mods", mods)
put("speedMultiplier", speedMultiplier)
put("flFollowDelay", flFollowDelay)
put("forceAR", forceAR)
put("customAR", customAR)
put("customOD", customOD)
put("customCS", customCS)
put("customHP", customHP)

}
socket!!.emit("roomModsChanged", json)
Expand Down Expand Up @@ -508,15 +519,26 @@ object RoomAPI
*/
@JvmStatic
@JvmOverloads
fun setPlayerMods(mods: String?, speedMultiplier: Float, flFollowDelay: Float, forceAR: Float? = null)
fun setPlayerMods(
mods: String?,
speedMultiplier: Float,
flFollowDelay: Float,
customAR: Float? = null,
customOD: Float? = null,
customCS: Float? = null,
customHP: Float? = null
)
{
val json = JSONObject().apply {

put("mods", mods)
put("speedMultiplier", speedMultiplier)
put("flFollowDelay", flFollowDelay)
put("forceAR", forceAR)

put("customAR", customAR)
put("customOD", customOD)
put("customCS", customCS)
put("customHP", customHP)
}
socket!!.emit("playerModsChanged", json)

Expand Down
22 changes: 17 additions & 5 deletions src/com/reco1l/legacy/ui/multiplayer/RoomScene.kt
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,10 @@ object RoomScene : Scene(), IRoomEventListener, IPlayerEventListener
modsToString(getModMenu().mod),
getModMenu().changeSpeed,
getModMenu().fLfollowDelay,
if (getModMenu().isEnableForceAR) getModMenu().forceAR else null
getModMenu().customAR,
getModMenu().customOD,
getModMenu().customCS,
getModMenu().customHP
)

// Updating UI
Expand Down Expand Up @@ -822,7 +825,10 @@ object RoomScene : Scene(), IRoomEventListener, IPlayerEventListener
modsToString(getModMenu().mod),
getModMenu().changeSpeed,
getModMenu().fLfollowDelay,
if (getModMenu().isEnableForceAR) getModMenu().forceAR else null
getModMenu().customAR,
getModMenu().customOD,
getModMenu().customCS,
getModMenu().customHP
)

// Update room info text
Expand Down Expand Up @@ -911,7 +917,10 @@ object RoomScene : Scene(), IRoomEventListener, IPlayerEventListener
modsToString(roomMods),
getModMenu().changeSpeed,
getModMenu().fLfollowDelay,
if (getModMenu().isEnableForceAR) getModMenu().forceAR else null
getModMenu().customAR,
getModMenu().customOD,
getModMenu().customCS,
getModMenu().customHP
)
}

Expand Down Expand Up @@ -939,10 +948,13 @@ object RoomScene : Scene(), IRoomEventListener, IPlayerEventListener

Replay.oldMod = getModMenu().mod
Replay.oldChangeSpeed = getModMenu().changeSpeed
Replay.oldForceAR = getModMenu().forceAR
Replay.oldEnableForceAR = getModMenu().isEnableForceAR
Replay.oldFLFollowDelay = getModMenu().fLfollowDelay

Replay.oldCustomAR = getModMenu().customAR
Replay.oldCustomOD = getModMenu().customOD
Replay.oldCustomCS = getModMenu().customCS
Replay.oldCustomHP = getModMenu().customHP

getGlobal().gameScene.startGame(getGlobal().selectedTrack, null)

// Hiding any player menu if its shown
Expand Down
54 changes: 39 additions & 15 deletions src/ru/nsu/ccfit/zuev/osu/game/GameScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ private boolean loadGame(final TrackInfo track, final String rFile) {


scale = (float) ((Config.getRES_HEIGHT() / 480.0f)
* (54.42 - beatmapData.difficulty.cs * 4.48)
* (54.42 - (ModMenu.getInstance().isCustomCS() ? ModMenu.getInstance().getCustomCS() : beatmapData.difficulty.cs) * 4.48)
* 2 / GameObjectSize.BASE_OBJECT_SIZE)
+ 0.5f * Config.getScaleMultiplier();

Expand Down Expand Up @@ -474,9 +474,15 @@ private boolean loadGame(final TrackInfo track, final String rFile) {
scale -= (float) ((Config.getRES_HEIGHT() / 480.0f) * (4 * 4.48)
* 2 / GameObjectSize.BASE_OBJECT_SIZE);
}
//Force AR
if (ModMenu.getInstance().isEnableForceAR()){
approachRate = (float) GameHelper.ar2ms(ModMenu.getInstance().getForceAR()) / 1000f * timeMultiplier;

if (ModMenu.getInstance().isCustomAR()){
approachRate = (float) GameHelper.ar2ms(ModMenu.getInstance().getCustomAR()) / 1000f * timeMultiplier;
}
if (ModMenu.getInstance().isCustomOD()) {
overallDifficulty = ModMenu.getInstance().getCustomOD();
}
if (ModMenu.getInstance().isCustomHP()) {
drain = ModMenu.getInstance().getCustomHP();
}

GameHelper.setRelaxMod(ModMenu.getInstance().getMod().contains(GameMod.MOD_RELAX));
Expand Down Expand Up @@ -629,8 +635,9 @@ private boolean loadGame(final TrackInfo track, final String rFile) {
parameters.mods = ModMenu.getInstance().getMod().clone();
parameters.customSpeedMultiplier = ModMenu.getInstance().getChangeSpeed();

if (ModMenu.getInstance().isEnableForceAR()) {
parameters.forcedAR = ModMenu.getInstance().getForceAR();
// TODO PP calculation doesn't account for custom CS, OD and HP attributes currently.
if (ModMenu.getInstance().isCustomAR()) {
parameters.forcedAR = ModMenu.getInstance().getCustomAR();
}

timedDifficultyAttributes = BeatmapDifficultyCalculator.calculateTimedDifficulty(
Expand Down Expand Up @@ -710,9 +717,13 @@ public void onComplete() {
} else {
ModMenu.getInstance().setMod(Replay.oldMod);
ModMenu.getInstance().setChangeSpeed(Replay.oldChangeSpeed);
ModMenu.getInstance().setForceAR(Replay.oldForceAR);
ModMenu.getInstance().setEnableForceAR(Replay.oldEnableForceAR);
ModMenu.getInstance().setFLfollowDelay(Replay.oldFLFollowDelay);

ModMenu.getInstance().setCustomAR(Replay.oldCustomAR);
ModMenu.getInstance().setCustomOD(Replay.oldCustomOD);
ModMenu.getInstance().setCustomCS(Replay.oldCustomCS);
ModMenu.getInstance().setCustomHP(Replay.oldCustomHP);

quit();
}
}
Expand Down Expand Up @@ -816,8 +827,12 @@ public void onUpdate(final float pSecondsElapsed) {
stat.setDiffModifier(multiplier);
stat.setMaxObjectsCount(lastTrack.getTotalHitObjectCount());
stat.setMaxHighestCombo(lastTrack.getMaxCombo());
stat.setEnableForceAR(ModMenu.getInstance().isEnableForceAR());
stat.setForceAR(ModMenu.getInstance().getForceAR());

stat.setCustomAR(ModMenu.getInstance().getCustomAR());
stat.setCustomOD(ModMenu.getInstance().getCustomOD());
stat.setCustomCS(ModMenu.getInstance().getCustomCS());
stat.setCustomHP(ModMenu.getInstance().getCustomHP());

stat.setChangeSpeed(ModMenu.getInstance().getChangeSpeed());
stat.setFLFollowDelay(ModMenu.getInstance().getFLfollowDelay());

Expand Down Expand Up @@ -1250,7 +1265,10 @@ else if (stat.getMod().contains(GameMod.MOD_PERFECT)) {
.applyFilter(m -> m.unranked).hasNext();
if (hasUnrankedMod
|| Config.isRemoveSliderLock()
|| ModMenu.getInstance().isEnableForceAR()
|| ModMenu.getInstance().isCustomAR()
|| ModMenu.getInstance().isCustomOD()
|| ModMenu.getInstance().isCustomCS()
|| ModMenu.getInstance().isCustomHP()
|| !ModMenu.getInstance().isDefaultFLFollowDelay()) {
unranked.setVisible(true);
}
Expand Down Expand Up @@ -1933,9 +1951,12 @@ public void onModifierFinished(IModifier<IEntity> iModifier, IEntity iEntity) {
if (replaying) {
ModMenu.getInstance().setMod(Replay.oldMod);
ModMenu.getInstance().setChangeSpeed(Replay.oldChangeSpeed);
ModMenu.getInstance().setForceAR(Replay.oldForceAR);
ModMenu.getInstance().setEnableForceAR(Replay.oldEnableForceAR);
ModMenu.getInstance().setFLfollowDelay(Replay.oldFLFollowDelay);

ModMenu.getInstance().setCustomAR(Replay.oldCustomAR);
ModMenu.getInstance().setCustomOD(Replay.oldCustomOD);
ModMenu.getInstance().setCustomCS(Replay.oldCustomCS);
ModMenu.getInstance().setCustomHP(Replay.oldCustomHP);
}

if (replaying)
Expand Down Expand Up @@ -2088,9 +2109,12 @@ private void onExit() {
replayFile = null;
ModMenu.getInstance().setMod(Replay.oldMod);
ModMenu.getInstance().setChangeSpeed(Replay.oldChangeSpeed);
ModMenu.getInstance().setForceAR(Replay.oldForceAR);
ModMenu.getInstance().setEnableForceAR(Replay.oldEnableForceAR);
ModMenu.getInstance().setFLfollowDelay(Replay.oldFLFollowDelay);

Replay.oldCustomAR = ModMenu.getInstance().getCustomAR();
Replay.oldCustomOD = ModMenu.getInstance().getCustomOD();
Replay.oldCustomCS = ModMenu.getInstance().getCustomCS();
Replay.oldCustomHP = ModMenu.getInstance().getCustomHP();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public static DifficultyCalculationParameters constructDifficultyParameters(fina
parameters.mods = stat.getMod().clone();
parameters.customSpeedMultiplier = stat.getChangeSpeed();

if (stat.isEnableForceAR()) {
parameters.forcedAR = stat.getForceAR();
if (stat.isCustomAR()) {
// TODO Here too Rian.
parameters.forcedAR = stat.getCustomAR();
}

return parameters;
Expand Down
102 changes: 81 additions & 21 deletions src/ru/nsu/ccfit/zuev/osu/menu/ModMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Map;
import java.util.TreeMap;

import org.jetbrains.annotations.Nullable;
import ru.nsu.ccfit.zuev.osu.Config;
import ru.nsu.ccfit.zuev.osu.GlobalManager;
import ru.nsu.ccfit.zuev.osu.ResourceManager;
Expand Down Expand Up @@ -55,6 +56,12 @@ public class ModMenu implements IModSwitcher {
private boolean modsRemoved = false;
private float FLfollowDelay = DEFAULT_FL_FOLLOW_DELAY;


private Float customAR = null;
private Float customOD = null;
private Float customHP = null;
private Float customCS = null;

private ModMenu() {
mod = EnumSet.noneOf(GameMod.class);
}
Expand Down Expand Up @@ -161,12 +168,29 @@ public void hide(boolean updatePlayerMods) {
var string = MultiplayerConverter.modsToString(mod);

// The room mods are the same as the host mods
if (Multiplayer.isRoomHost)
RoomAPI.setRoomMods(string, changeSpeed, FLfollowDelay, enableForceAR ? forceAR : null);
else if (updatePlayerMods)
RoomAPI.setPlayerMods(string, changeSpeed, FLfollowDelay, enableForceAR ? forceAR : null);
else
if (Multiplayer.isRoomHost) {
RoomAPI.setRoomMods(
string,
changeSpeed,
FLfollowDelay,
customAR,
customOD,
customCS,
customHP
);
} else if (updatePlayerMods) {
RoomAPI.setPlayerMods(
string,
changeSpeed,
FLfollowDelay,
customAR,
customOD,
customCS,
customHP
);
} else {
RoomScene.awaitModsChange = false;
}
}
}

Expand Down Expand Up @@ -456,18 +480,6 @@ public void setChangeSpeed(float speed){
changeSpeed = speed;
}

public float getForceAR(){
return forceAR;
}

public void setForceAR(float ar){
forceAR = ar;
}

public boolean isEnableForceAR(){
return enableForceAR;
}

public boolean isDefaultFLFollowDelay() {
return FLfollowDelay == DEFAULT_FL_FOLLOW_DELAY;
}
Expand All @@ -476,10 +488,6 @@ public void resetFLFollowDelay() {
FLfollowDelay = DEFAULT_FL_FOLLOW_DELAY;
}

public void setEnableForceAR(boolean t){
enableForceAR = t;
}

public boolean isEnableNCWhenSpeedChange(){
return enableNCWhenSpeedChange;
}
Expand All @@ -492,4 +500,56 @@ public void updateMultiplierText(){
changeMultiplierText();
}



public boolean isCustomAR() {
return customAR != null;
}

public Float getCustomAR() {
return customAR;
}

public void setCustomAR(@Nullable Float customAR) {
this.customAR = customAR;
}


public boolean isCustomOD() {
return customOD != null;
}

public Float getCustomOD() {
return customOD;
}

public void setCustomOD(@Nullable Float customOD) {
this.customOD = customOD;
}


public boolean isCustomHP() {
return customHP != null;
}

public Float getCustomHP() {
return customHP;
}

public void setCustomHP(@Nullable Float customHP) {
this.customHP = customHP;
}


public boolean isCustomCS() {
return customCS != null;
}

public Float getCustomCS() {
return customCS;
}

public void setCustomCS(@Nullable Float customCS) {
this.customCS = customCS;
}
}
Loading

0 comments on commit 4b27492

Please sign in to comment.