Skip to content

Commit

Permalink
Fix unfavouriting songs
Browse files Browse the repository at this point in the history
Option to use instrumental for results music
  • Loading branch information
superpowers04 committed Sep 11, 2024
1 parent 36e9a12 commit f6265a7
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 48 deletions.
29 changes: 15 additions & 14 deletions source/FinishSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -173,27 +173,28 @@ class FinishSubState extends MusicBeatSubstate
pauseGame = true;
autoEnd = true;
FlxG.sound.pause();

if(endingMusic == null){
music = new FlxSound().loadEmbedded(SELoader.cache.loadSound( win ? 'assets/shared/music/resultsNORMAL.ogg' : 'assets/shared/music/resultsSHIT.ogg' ), true, true);
if(win && SESave.data.resultsInst){
FlxG.sound.music.play();
}else{
music = new FlxSound().loadEmbedded(endingMusic , true, true);
music = new FlxSound().loadEmbedded(endingMusic ?? SELoader.cache.loadSound( win ? 'assets/shared/music/resultsNORMAL.ogg' : 'assets/shared/music/resultsSHIT.ogg' ), true, true);
music.play(false);

if(!win && endingMusic == null){
music.looped = false;
music.onComplete = function(){
music = new FlxSound().loadEmbedded(SELoader.cache.loadSound('assets/shared/music/breakfast.ogg'), true, true);
music.play(false);
FlxG.sound.list.add(music);
}
}
FlxG.sound.list.add(music);
}
music.play(false);

if(!win && endingMusic == null){
music.looped = false;
music.onComplete = function(){
music = new FlxSound().loadEmbedded(SELoader.cache.loadSound('assets/shared/music/breakfast.ogg'), true, true);
music.play(false);
FlxG.sound.list.add(music);
}


}
endingMusic = null;
shownResults = true;

FlxG.sound.list.add(music);
if(isError){
var finishedText:FlxText = new FlxText(20,-55,0, "Error caught!" );
finishedText.size = 32;
Expand Down
2 changes: 1 addition & 1 deletion source/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class MainMenuState extends SickMenuState {
32,(nightly==""?FlxColor.RED:FlxColor.WHITE),CENTER);
outdatedLMAO.screenCenter(FlxAxes.X);
add(outdatedLMAO);
}else
}
// Whole bunch of checks to prevent crashing
if (TitleState.retChar(SESave.data.playerChar) == "" && SESave.data.playerChar != "automatic"){
errorMessage += '\n${SESave.data.playerChar} is an invalid player! Reset back to BF!';
Expand Down
9 changes: 5 additions & 4 deletions source/MusicBeatState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -368,22 +368,23 @@ class MusicBeatState extends FlxUIState {
public static function switchState(nextState:FlxState){
return FlxG.switchState(nextState);
}
public var shouldTransitionIn:Bool = true;
public var shouldTransitionOut:Bool = true;

function tranIn(){ // Replace with empty functions to disable

LoadingScreen.hide();
if(!shouldTransitionIn) return;
var oldY = FlxG.camera.x;
FlxG.camera.x -= 300;
FlxTween.tween(FlxG.camera, {x:oldY},0.7,{ease: FlxEase.expoOut});
var oldZoom = FlxG.camera.zoom;
FlxG.camera.zoom += 1;
FlxTween.tween(FlxG.camera, {zoom:oldZoom},0.7,{ease: FlxEase.expoOut});

LoadingScreen.hide();

}
function tranOut(){
// active = false;

if(!shouldTransitionOut) return;
if(loading) LoadingScreen.show();


Expand Down
1 change: 1 addition & 0 deletions source/OptionsMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class OptionsMenu extends MusicBeatState
new VolumeOption("se.options.volume.other","other"),
new HCBoolOption("Animation debug Music","Whether to play music for animation debug or continue playing the current song","animDebugMusic"),
new HCBoolOption("Options Menu Music","Whether to play music for the options menu or continue playing the current song","optionsMusic"),
new HCBoolOption("Use current song for results","Loops the current playing song for results","resultsInst"),
new HCBoolOption("Miss Sounds","Play a sound when you miss",'playMisses'),
new HCBoolOption("Hit Sounds","Play a click when you hit a note. Uses osu!'s sounds or your mods/hitsound.ogg",'hitSound'),
new HCBoolOption("Play Character Voices","Plays the voices a character has when you press a note.","playVoices"),
Expand Down
3 changes: 1 addition & 2 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2746,8 +2746,7 @@ class PlayState extends ScriptMusicBeatState
}


private function keyShit():Void
{try{doKeyShit();}catch(e){handleError('Error during keyshit: ${e.message}\n ${e.stack}');}}
private function keyShit():Void {try{doKeyShit();}catch(e){handleError('Error during keyshit: ${e.message}\n ${e.stack}');}}
public var doKeyShit:()->Void = function():Void{throw("I can't handle key inputs? Please report this!");};
public var noteShit:()->Void = function():Void{throw("I can't handle input for some reason, Please report this!");};
public var goodNoteHit:(Note, ?Bool)->Void = function(note:Note, ?resetMashViolation:Bool = true):Void{throw("I cant register any note hits!");};
Expand Down
26 changes: 14 additions & 12 deletions source/SickMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -163,30 +163,32 @@ class SickMenuState extends ScriptMusicBeatState
trace('${e.stack}');
}
}

override function create() {
// if (ChartingState.charting) ChartingState.charting = false;
SearchMenuState.resetVars();
// if (SESave.data.songUnload && PlayState.SONG != null) {PlayState.SONG = null;}
// PlayState.songScript = "";PlayState.hsBrTools = null;
override function new(){
if(SearchMenuState.background == null){
try{

SearchMenuState.background = if(SELoader.exists("mods/bg.png")) SELoader.loadGraphic("mods/bg.png",true); else SELoader.loadGraphic("assets/images/menuDesat.png",true);
SearchMenuState.backgroundOver = if(SELoader.exists("mods/fg.png")) SELoader.loadGraphic("mods/fg.png",true); else FlxGraphic.fromRectangle(0,0,0x00000000);
SearchMenuState.background = SELoader.exists("mods/bg.png") ? SELoader.loadGraphic("mods/bg.png",true) : SELoader.loadGraphic("assets/images/menuDesat.png",true);
SearchMenuState.backgroundOver = SELoader.exists("mods/fg.png") ? SELoader.loadGraphic("mods/fg.png",true) : FlxGraphic.fromRectangle(0,0,0);
}catch(e){trace('Unable to load background! ${e.message}');}
if(SearchMenuState.background == null) SearchMenuState.background = FlxGraphic.fromRectangle(0,0,0xff110015);
SearchMenuState.background.persist = SearchMenuState.backgroundOver.persist = true;
SearchMenuState.background.destroyOnNoUse = SearchMenuState.backgroundOver.destroyOnNoUse = false;
}


if(bg == null){

bg = new FlxSprite().loadGraphic(SearchMenuState.background);
bg.color = 0xFFFF6E6E;
}
bg.scrollFactor.set(0.01,0.01);
super();
}
override function create() {
// if (ChartingState.charting) ChartingState.charting = false;
SearchMenuState.resetVars();
// if (SESave.data.songUnload && PlayState.SONG != null) {PlayState.SONG = null;}
// PlayState.songScript = "";PlayState.hsBrTools = null;





add(bg);
if(SearchMenuState.backgroundOver != null){
Expand Down
36 changes: 26 additions & 10 deletions source/TitleState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ class TitleState extends MusicBeatState
android.widget.Toast.makeText('Update check skipped due to lack of internet permissions',20);
}
#end
FlxG.switchState(if(FlxG.keys.pressed.SHIFT) new OptionsMenu() else new MainMenuState());
FlxG.switchState(FlxG.keys.pressed.SHIFT ? new OptionsMenu() : new MainMenuState());
}else{
new FlxTimer().start(0.5,function(_){try{updateCheck = true;}catch(e){}});

Expand Down Expand Up @@ -1201,9 +1201,21 @@ class TitleState extends MusicBeatState
// if(superLogo != null && superLogo is FlxSprite)(cast superLogo).graphic.destroy();
if(superLogo != null) superLogo.destroy();
// FlxTween.tween(FlxG.camera.scroll,{y:-300},4,{ease:FlxEase.cubeOut});
FlxTween.tween(logoBl,{y:-300},4,{ease:FlxEase.cubeOut});
FlxTween.tween(titleText,{y:740},4,{ease:FlxEase.cubeOut});
FlxG.switchState(if(FlxG.keys.pressed.SHIFT) new OptionsMenu() else new MainMenuState());
if(FlxG.keys.pressed.SHIFT){
FlxG.switchState(new OptionsMenu());
return;
}
var state = new MainMenuState();
state.shouldTransitionIn = false;
FlxTween.tween(logoBl,{y:-300,alpha:0},0.5,{ease:FlxEase.cubeOut});
FlxTween.tween(titleText,{y:740,alpha:0},0.5,{ease:FlxEase.cubeOut,onComplete:(_)->{

FlxG.camera.alpha = 0;
FlxG.switchState(state);

}});


}

function createCoolText(textArray:Array<String>,yOffset:Int = 200)
Expand Down Expand Up @@ -1238,6 +1250,8 @@ class TitleState extends MusicBeatState
textGroup.remove(textGroup.members[0], true);
}
}
var tweensy:FlxTween;
var tweenr:FlxTween;
var tweeny:FlxTween;
var ttBounce:FlxTween;
var cachingText:Alphabet;
Expand All @@ -1250,11 +1264,14 @@ class TitleState extends MusicBeatState
if(beatAmounts.exists(curBeat)) beatIntensity = beatAmounts[curBeat];
if (logoBl != null){

if(tweensy != null)tweensy.cancel();
if(tweeny != null)tweeny.cancel();
if(tweenr != null)tweenr.cancel();
var amount = 0.9 + beatIntensity;
logoBl.scale.set(amount,amount);
// FlxTween.tween(logoBl.scale,{x:1,y:1},0.1);
tweeny = FlxTween.tween(logoBl.scale,{x:0.9,y:0.9},(60 / Conductor.bpm),{ease:FlxEase.expoOut});
tweensy = FlxTween.tween(logoBl.scale,{x:0.9,y:0.9},(60 / Conductor.bpm),{ease:FlxEase.expoOut});
tweenr = FlxTween.tween(logoBl,{angle:curBeat % 2 == 0 ? 15 : -15},(60 / Conductor.bpm),{ease:FlxEase.expoOut});
if(ttBounce != null)ttBounce.cancel();
titleText.scale.set(0.1 + amount,0.1 + amount);
ttBounce = FlxTween.tween(titleText.scale,{x:1,y:1},(60 / Conductor.bpm),{ease:FlxEase.expoOut});
Expand Down Expand Up @@ -1375,7 +1392,7 @@ class TitleState extends MusicBeatState
FlxG.camera.flash(FlxColor.WHITE, 2);
remove(credGroup);
skippedIntro = true;
FlxG.camera.scroll.x += 100;
// FlxG.camera.scroll.x += 100;
FlxG.camera.scroll.y += 100;
logoBl.screenCenter();
logoBl.y -= 100;
Expand All @@ -1390,7 +1407,7 @@ class TitleState extends MusicBeatState
titleText.color=0xffff8b0f;
}

FlxTween.tween(FlxG.camera.scroll,{x: 0,y:0},1,{ease:FlxEase.cubeOut});
FlxTween.tween(FlxG.camera.scroll,{y:0},1,{ease:FlxEase.cubeOut});

}
override function stepHit(){
Expand Down Expand Up @@ -1418,9 +1435,8 @@ class TitleState extends MusicBeatState
function showHaxe(){
_times = [0.041, 0.184, 0.334, 0.495, 0.636,1];
_colors = [0x00b922, 0xffc132, 0xf5274e, 0x3641ff, 0x04cdfb,0xFFFFFF,0xFFFFFF];
_functions = [drawGreen, drawYellow, drawRed, drawBlue, drawLightBlue,function(){return;}];
_sprite = new Sprite();
FlxG.stage.addChild(_sprite);
_functions = [drawGreen, drawYellow, drawRed, drawBlue, drawLightBlue,()->{}];
FlxG.stage.addChild(_sprite = new Sprite());
_gfx = _sprite.graphics;
_sprite.filters = [new flash.filters.GlowFilter(0xFFFFFF,1,6,6,1,1)];

Expand Down
11 changes: 9 additions & 2 deletions source/multi/MultiMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,15 @@ class MultiMenuState extends onlinemod.OfflineMenuState {
function favChart(){
var songInfo = grpSongs.members[curSelected].menuValue;
if(songInfo == null) return showTempmessage('This is not a song!',FlxColor.RED);
if(!SESave.data.favourites.remove(songInfo)){
if(songInfo.favouriteID > 0){
SESave.data.favourites.remove(SESave.data.favourites[songInfo.favouriteID-1]);
curSelected = 0;
}else{
SESave.data.favourites.push(songInfo);
}
// if(!SESave.data.favourites.remove(songInfo)){
// SESave.data.favourites.push(songInfo);
// }
SEFlxSaveWrapper.save();
reloadList(false,'');
reloadList(true,searchField.text);
Expand Down Expand Up @@ -285,12 +291,13 @@ class MultiMenuState extends onlinemod.OfflineMenuState {
var containsSong = false;
var missingSongs:Array<Dynamic> = [];
_packCount++;
for (osong in SESave.data.favourites){
for (i => osong in SESave.data.favourites){
var song:SongInfo = null;
var worked:Bool = false;
try{
song = new SongInfo(osong.name, osong.charts,osong.path,osong.namespace,osong.isCategory,osong.categoryID);
worked = CoolUtil.applyAnonToObject(song,osong);
song.favouriteID = i+1;
}catch(e){
trace('$osong is an invalid song!');
missingSongs.push(osong);
Expand Down
1 change: 1 addition & 0 deletions source/se/SESave.hx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ typedef YourMother = Dynamic;
var persistGF:Bool = false;
var menuScripts:Bool = false;
var easterEggs:Bool = true;
var resultsInst:Bool = false;

var profiler(default,set):Bool = false;
function set_profiler(v){
Expand Down
1 change: 1 addition & 0 deletions source/se/formats/SongInfo.hx
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ package se.formats;
this.isCategory = isCategory;
this.categoryID=categoryID;
}
var favouriteID:Int = 0;
}
9 changes: 7 additions & 2 deletions source/se/objects/SEJoinedSound.hx
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,32 @@ import flixel.FlxG;
sounds.remove(sound);
return sound;
}
function setVolume(index:Int,volume:Float){
function setVolume(index:Int,volume:Float):Float{
if(length == 0) return 0;
return (sounds[index] is FlxSound ? sounds[index] : sound).volume = volume;
}

function getVolume(index:Int){
function getVolume(index:Int):Float{
if(length == 0) return 0;
return (sounds[index] is FlxSound ? sounds[index] : sound).volume;
}



// Shadowed Variables/Functions. This shit is dumb tbh
function stop() {
if(length == 0) return;
for(sound in sounds) sound.stop();
sync();
}
// function start() for(sound in sounds) sound.start();s
function play() {
if(length == 0) return;
for(sound in sounds) sound.play();
sync();
}
function pause() {
if(length == 0) return;
for(sound in sounds) sound.pause();
sync();
}
Expand Down
2 changes: 1 addition & 1 deletion version.downloadMe
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
24.08.23.2304;
24.09.10.2241;
* Better Psych character support(Still kinda experimental but should be more stable)
* Fix some small errors
* Fix characters not loading due to using ID instead of folderName
Expand Down

0 comments on commit f6265a7

Please sign in to comment.