diff --git a/src/com/reco1l/osu/skinning/SkinConversion.kt b/src/com/reco1l/osu/skinning/SkinConversion.kt index b734e2e85..0e6f43cc8 100644 --- a/src/com/reco1l/osu/skinning/SkinConversion.kt +++ b/src/com/reco1l/osu/skinning/SkinConversion.kt @@ -48,7 +48,8 @@ fun convertToJson(ini: IniReader) = JSONObject().apply { putObject("Cursor") { - put("rotateCursor", ini["General", "CursorRotate"] ?: true) + put("rotateCursor", ini.get("General", "CursorRotate") != false) + put("rotateCursorTrail", ini.get("General", "CursorTrailRotate") != false) } putObject("ComboColor") { diff --git a/src/ru/nsu/ccfit/zuev/osu/game/cursor/main/CursorEntity.java b/src/ru/nsu/ccfit/zuev/osu/game/cursor/main/CursorEntity.java index 948add326..55805cfef 100644 --- a/src/ru/nsu/ccfit/zuev/osu/game/cursor/main/CursorEntity.java +++ b/src/ru/nsu/ccfit/zuev/osu/game/cursor/main/CursorEntity.java @@ -1,7 +1,6 @@ package ru.nsu.ccfit.zuev.osu.game.cursor.main; import org.anddev.andengine.entity.Entity; -import org.anddev.andengine.entity.particle.ParticleSystem; import org.anddev.andengine.entity.particle.emitter.PointParticleEmitter; import org.anddev.andengine.entity.scene.Scene; import org.anddev.andengine.opengl.texture.region.TextureRegion; @@ -13,7 +12,7 @@ public class CursorEntity extends Entity { protected final CursorSprite cursorSprite; - private ParticleSystem particles = null; + private CursorTrail trail = null; private PointParticleEmitter emitter = null; private boolean isShowing = false; private float particleOffsetX, particleOffsetY; @@ -31,8 +30,8 @@ public CursorEntity() { var spawnRate = (int) GlobalManager.getInstance().getMainActivity().getRefreshRate() * 2; emitter = new PointParticleEmitter(particleOffsetX, particleOffsetY); - particles = new CursorTrail(emitter, spawnRate, cursorSprite.baseSize, trailTex); - particles.setParticlesSpawnEnabled(false); + trail = new CursorTrail(emitter, spawnRate, trailTex, cursorSprite); + trail.setParticlesSpawnEnabled(false); } attachChild(cursorSprite); @@ -45,8 +44,8 @@ public CursorEntity() { public void setShowing(boolean showing) { isShowing = showing; setVisible(showing); - if (particles != null) - particles.setParticlesSpawnEnabled(showing); + if (trail != null) + trail.setParticlesSpawnEnabled(showing); } public void click() { @@ -54,16 +53,20 @@ public void click() { } public void update(float pSecondsElapsed) { - // this.handleLongerTrail(); - if(isShowing) { + if (isShowing) { cursorSprite.update(pSecondsElapsed); + + if (trail != null) { + trail.update(); + } } + super.onManagedUpdate(pSecondsElapsed); } public void attachToScene(Scene fgScene) { - if (particles != null) { - fgScene.attachChild(particles); + if (trail != null) { + fgScene.attachChild(trail); } fgScene.attachChild(this); } diff --git a/src/ru/nsu/ccfit/zuev/osu/game/cursor/trail/CursorTrail.java b/src/ru/nsu/ccfit/zuev/osu/game/cursor/trail/CursorTrail.java index a9f331d4d..e9398e1dc 100644 --- a/src/ru/nsu/ccfit/zuev/osu/game/cursor/trail/CursorTrail.java +++ b/src/ru/nsu/ccfit/zuev/osu/game/cursor/trail/CursorTrail.java @@ -10,23 +10,39 @@ import javax.microedition.khronos.opengles.GL10; import ru.nsu.ccfit.zuev.osu.game.GameHelper; +import ru.nsu.ccfit.zuev.osu.game.cursor.main.CursorSprite; +import ru.nsu.ccfit.zuev.skins.OsuSkin; public class CursorTrail extends ParticleSystem { + private final CursorSprite cursor; + public CursorTrail( PointParticleEmitter emitter, int spawnRate, - float trailSize, - TextureRegion pTextureRegion + TextureRegion pTextureRegion, + CursorSprite cursor ) { super(emitter, spawnRate, spawnRate, spawnRate, pTextureRegion); + this.cursor = cursor; + // Cancelling the speed multiplier for the trail. addParticleModifier(new ExpireModifier(0.1f * GameHelper.getSpeedMultiplier())); addParticleModifier(new AlphaModifier(GameHelper.getSpeedMultiplier(), 0.0f, 0f, 0.10f)); setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); - addParticleInitializer(new ScaleInitializer(trailSize)); + addParticleInitializer(new ScaleInitializer(cursor.baseSize)); setParticlesSpawnEnabled(false); + updateRotation(); } + public void update() { + updateRotation(); + } + + private void updateRotation() { + if (OsuSkin.get().isRotateCursorTrail()) { + setRotation(cursor.getRotation()); + } + } } diff --git a/src/ru/nsu/ccfit/zuev/skins/OsuSkin.java b/src/ru/nsu/ccfit/zuev/skins/OsuSkin.java index 9ce848a31..789662209 100644 --- a/src/ru/nsu/ccfit/zuev/skins/OsuSkin.java +++ b/src/ru/nsu/ccfit/zuev/skins/OsuSkin.java @@ -31,6 +31,7 @@ public class OsuSkin { protected final BooleanSkinData useNewLayout = new BooleanSkinData("useNewLayout"); protected final BooleanSkinData forceOverrideComboColor = new BooleanSkinData("forceOverride"); protected final BooleanSkinData rotateCursor = new BooleanSkinData("rotateCursor", true); + protected final BooleanSkinData rotateCursorTrail = new BooleanSkinData("rotateCursorTrail", true); protected final BooleanSkinData layeredHitSounds = new BooleanSkinData("layeredHitSounds", true); protected final BooleanSkinData sliderBallFlip = new BooleanSkinData("sliderBallFlip", true); protected final BooleanSkinData spinnerFrequencyModulate = new BooleanSkinData("spinnerFrequencyModulate", true); @@ -67,6 +68,10 @@ public boolean isRotateCursor() { return rotateCursor.getCurrentValue(); } + public boolean isRotateCursorTrail() { + return rotateCursorTrail.getCurrentValue(); + } + public float getComboTextScale() { return comboTextScale.getCurrentValue(); } diff --git a/src/ru/nsu/ccfit/zuev/skins/SkinJsonReader.java b/src/ru/nsu/ccfit/zuev/skins/SkinJsonReader.java index 081652508..fd6d9b808 100644 --- a/src/ru/nsu/ccfit/zuev/skins/SkinJsonReader.java +++ b/src/ru/nsu/ccfit/zuev/skins/SkinJsonReader.java @@ -160,6 +160,7 @@ protected void loadCursor() { OsuSkin skin = OsuSkin.get(); JSONObject data = currentCursorData; skin.rotateCursor.setFromJson(data); + skin.rotateCursorTrail.setFromJson(data); } public void load(String tag, @NonNull JSONObject data, Consumer consumer) {