Skip to content

Commit

Permalink
Add skin.ini's CursorTrailRotate setting to skin.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Rian8337 committed Nov 23, 2024
1 parent 62b2414 commit d223f85
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/com/reco1l/osu/skinning/SkinConversion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ fun convertToJson(ini: IniReader) = JSONObject().apply {

putObject("Cursor") {

put("rotateCursor", ini["General", "CursorRotate"] ?: true)
put("rotateCursor", ini.get<Boolean>("General", "CursorRotate") != false)
put("rotateCursorTrail", ini.get<Boolean>("General", "CursorTrailRotate") != false)
}

putObject("ComboColor") {
Expand Down
23 changes: 13 additions & 10 deletions src/ru/nsu/ccfit/zuev/osu/game/cursor/main/CursorEntity.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -45,25 +44,29 @@ 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() {
cursorSprite.handleClick();
}

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);
}
Expand Down
22 changes: 19 additions & 3 deletions src/ru/nsu/ccfit/zuev/osu/game/cursor/trail/CursorTrail.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
5 changes: 5 additions & 0 deletions src/ru/nsu/ccfit/zuev/skins/OsuSkin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -67,6 +68,10 @@ public boolean isRotateCursor() {
return rotateCursor.getCurrentValue();
}

public boolean isRotateCursorTrail() {
return rotateCursorTrail.getCurrentValue();
}

public float getComboTextScale() {
return comboTextScale.getCurrentValue();
}
Expand Down
1 change: 1 addition & 0 deletions src/ru/nsu/ccfit/zuev/skins/SkinJsonReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<JSONObject> consumer) {
Expand Down

0 comments on commit d223f85

Please sign in to comment.