v2.3.1: shifted music tracks are now considered equivalent

This commit is contained in:
Evan Debenham
2024-01-25 13:38:59 -05:00
parent 5f735ffe6e
commit d8aa84ae46
3 changed files with 19 additions and 11 deletions

View File

@@ -94,13 +94,20 @@ public enum Music {
if (isPlaying() && this.trackList != null && tracks.length == trackList.length){ if (isPlaying() && this.trackList != null && tracks.length == trackList.length){
boolean sameList = true; //lists are considered the same if they are identical or merely shifted
for (int i = 0; i < tracks.length; i ++){ // e.g. the regular title theme and the victory theme are considered equivalent
if (!tracks[i].equals(trackList[i]) || chances[i] != trackChances[i]){ boolean sameList = false;
for (int ofs = 0; ofs < tracks.length; ofs++){
sameList = true;
for (int j = 0; j < tracks.length; j++){
int i = (j+ofs)%tracks.length;
if (!tracks[i].equals(trackList[j]) || chances[i] != trackChances[j]){
sameList = false; sameList = false;
break; break;
} }
} }
if (sameList) break;
}
if (sameList) { if (sameList) {
player.setVolume(volumeWithFade()); player.setVolume(volumeWithFade());

View File

@@ -21,6 +21,7 @@
package com.shatteredpixel.shatteredpixeldungeon.scenes; package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Rankings; import com.shatteredpixel.shatteredpixeldungeon.Rankings;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
@@ -41,6 +42,7 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndRanking;
import com.watabou.noosa.BitmapText; import com.watabou.noosa.BitmapText;
import com.watabou.noosa.Camera; import com.watabou.noosa.Camera;
import com.watabou.noosa.Image; import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Music;
import com.watabou.utils.GameMath; import com.watabou.utils.GameMath;
public class RankingsScene extends PixelScene { public class RankingsScene extends PixelScene {
@@ -59,6 +61,11 @@ public class RankingsScene extends PixelScene {
super.create(); super.create();
Music.INSTANCE.playTracks(
new String[]{Assets.Music.THEME_1, Assets.Music.THEME_2},
new float[]{1, 1},
false);
uiCamera.visible = false; uiCamera.visible = false;
int w = Camera.main.width; int w = Camera.main.width;

View File

@@ -21,7 +21,6 @@
package com.shatteredpixel.shatteredpixeldungeon.windows; package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress; import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
@@ -36,7 +35,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.watabou.noosa.Game; import com.watabou.noosa.Game;
import com.watabou.noosa.audio.Music;
import java.io.IOException; import java.io.IOException;
@@ -93,10 +91,6 @@ public class WndGame extends Window {
@Override @Override
protected void onClick() { protected void onClick() {
InterlevelScene.mode = InterlevelScene.Mode.DESCEND; InterlevelScene.mode = InterlevelScene.Mode.DESCEND;
Music.INSTANCE.playTracks(
new String[]{Assets.Music.THEME_1, Assets.Music.THEME_2},
new float[]{1, 1},
false);
Game.switchScene( RankingsScene.class ); Game.switchScene( RankingsScene.class );
} }
} ); } );