Skip to content

Commit

Permalink
solution??
Browse files Browse the repository at this point in the history
at least, i hope
  • Loading branch information
Joalor64GH authored May 30, 2024
1 parent 80ef789 commit 3b18ccb
Show file tree
Hide file tree
Showing 41 changed files with 143 additions and 130 deletions.
6 changes: 3 additions & 3 deletions source/Init.hx
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ class Init extends FlxState
FlxG.camera.fade(FlxColor.BLACK, 0.33, false, function()
{
if (OutdatedState.mustUpdate && !OutdatedState.leftState)
FlxG.switchState(() -> new OutdatedState());
FlxG.switchState(new OutdatedState());
else
{
if (FlxG.save.data.flashing == null && !FlashingState.leftState)
FlxG.switchState(() -> new FlashingState());
FlxG.switchState(new FlashingState());
else
FlxG.switchState(() -> new TitleState());
FlxG.switchState(new TitleState());
}
});
}
Expand Down
44 changes: 29 additions & 15 deletions source/meta/MusicBeatState.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package meta;

import flixel.addons.ui.FlxUIState;
import flixel.util.typeLimit.NextState;

class MusicBeatState extends modcharting.ModchartMusicBeatState
{
Expand Down Expand Up @@ -63,7 +64,7 @@ class MusicBeatState extends modcharting.ModchartMusicBeatState
inline function stepsToSecs(targetStep:Int, isFixedStep:Bool = false):Float {
final playbackRate:Single = PlayState.instance != null ? PlayState.instance.playbackRate : 1;
function calc(stepVal:Single, crochetBPM:Int = -1) {
return ((crochetBPM == -1 ? Conductor.getCrochet(Conductor.bpm) / 4 : Conductor.getCrochet(crochetBPM) / 4) * (stepVal - curStep)) / 1000;
return ((crochetBPM == -1 ? Conductor.calculateCrochet(Conductor.bpm) / 4 : Conductor.calculateCrochet(crochetBPM) / 4) * (stepVal - curStep)) / 1000;
}

final realStep:Single = isFixedStep ? targetStep : targetStep + curStep;
Expand Down Expand Up @@ -133,30 +134,43 @@ class MusicBeatState extends modcharting.ModchartMusicBeatState
curStep = lastChange.stepTime + Math.floor(shit);
}

override function startOutro(onOutroComplete:()->Void):Void
{
if (!FlxTransitionableState.skipNextTransIn)
{
public static function switchState(nextState:NextState) {
var curState:Dynamic = FlxG.state;
var leState:MusicBeatState = curState;
if (!FlxTransitionableState.skipNextTransIn) {
#if sys
ArtemisIntegration.toggleFade (true);
#end
FlxG.state.openSubState(new CustomFadeTransition(0.35, false));
CustomFadeTransition.finishCallback = () -> {
#if sys
ArtemisIntegration.toggleFade (false);
#end
onOutroComplete();
};
leState.openSubState(new CustomFadeTransition(0.35, false));
if(nextState == FlxG.state) {
CustomFadeTransition.finishCallback = function() {
#if sys
ArtemisIntegration.toggleFade (false);
#end
FlxG.resetState();
};
} else {
CustomFadeTransition.finishCallback = function() {
#if sys
ArtemisIntegration.toggleFade (false);
#end
FlxG.switchState(nextState);
};
}
return;
}

FlxTransitionableState.skipNextTransIn = false;
FlxG.switchState(nextState);
}

onOutroComplete();
public static function resetState() {
MusicBeatState.switchState(FlxG.state);
}

public static function getState():MusicBeatState {
return cast (FlxG.state, MusicBeatState);
var curState:Dynamic = FlxG.state;
var leState:MusicBeatState = curState;
return leState;
}

public function stepHit():Void
Expand Down
4 changes: 2 additions & 2 deletions source/meta/data/options/LanguageState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class LanguageState extends MusicBeatState

if (controls.BACK)
{
FlxG.switchState(() -> new OptionsState());
MusicBeatState.switchState(new OptionsState());
FlxG.sound.play(Paths.sound('cancelMenu'));
}

Expand All @@ -108,7 +108,7 @@ class LanguageState extends MusicBeatState
Localization.switchLanguage(ClientPrefs.language);
FlxG.sound.play(Paths.sound('confirmMenu'));
ClientPrefs.saveSettings();
FlxG.switchState(() -> new OptionsState());
MusicBeatState.switchState(new OptionsState());
}

for (num => item in coolGrp.members)
Expand Down
2 changes: 1 addition & 1 deletion source/meta/data/options/NoteOffsetState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class NoteOffsetState extends MusicBeatState

persistentUpdate = false;
CustomFadeTransition.nextCamera = camOther;
FlxG.switchState(() -> new OptionsState());
MusicBeatState.switchState(new OptionsState());
if (PauseSubState.fromPlayState)
{
if (ClientPrefs.pauseMusic != 'None')
Expand Down
10 changes: 5 additions & 5 deletions source/meta/data/options/OptionsState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class OptionsState extends MusicBeatState
case 'Controls':
openSubState(new OptionsSubState.ControlsSubState());
case 'Offsets':
FlxG.switchState(() -> new NoteOffsetState());
MusicBeatState.switchState(new NoteOffsetState());
case 'Visuals':
openSubState(new OptionsSubState.VisualsSubState());
case 'Gameplay':
openSubState(new OptionsSubState.GameplaySubState());
case 'Language':
FlxG.switchState(() -> new LanguageState());
MusicBeatState.switchState(new LanguageState());
case 'Miscellaneous':
openSubState(new OptionsSubState.MiscSubState());
}
Expand Down Expand Up @@ -149,7 +149,7 @@ class OptionsState extends MusicBeatState
bg.offset.set();

if (FlxG.keys.justPressed.D)
FlxG.switchState(() -> new SaveDataState());
MusicBeatState.switchState(new SaveDataState());

if (controls.UI_UP_P || controls.UI_DOWN_P)
changeSelection(controls.UI_UP_P ? -1 : 1);
Expand All @@ -158,10 +158,10 @@ class OptionsState extends MusicBeatState
FlxG.sound.play(Paths.sound('cancelMenu'));
if (PauseSubState.fromPlayState) {
StageData.loadDirectory(PlayState.SONG);
LoadingState.loadAndSwitchState(() -> new PlayState());
LoadingState.loadAndSwitchState(new PlayState());
} else {
FlxG.sound.playMusic(Paths.music('freakyMenu'));
FlxG.switchState((ClientPrefs.simpleMain) ? () -> new SimpleMainMenuState() : () -> new MainMenuState());
MusicBeatState.switchState((ClientPrefs.simpleMain) ? new SimpleMainMenuState() : new MainMenuState());
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/meta/data/options/SaveDataState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SaveDataState extends MusicBeatState

if (controls.BACK)
{
FlxG.switchState(() -> new OptionsState());
MusicBeatState.switchState(new OptionsState());
FlxG.sound.play(Paths.sound('cancelMenu'));
FlxG.mouse.visible = false;
}
Expand Down
6 changes: 3 additions & 3 deletions source/meta/data/scripts/FunkinHscript.hx
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,9 @@ class FunkinHscript extends InterpEx {
CustomFadeTransition.nextCamera = null;

if (PlayState.isStoryMode)
FlxG.switchState(() -> new StoryMenuState());
MusicBeatState.switchState(new StoryMenuState());
else
FlxG.switchState(() -> new FreeplayState());
MusicBeatState.switchState(new FreeplayState());

FlxG.sound.playMusic(Paths.music('freakyMenu'));
PlayState.changedDifficulty = false;
Expand All @@ -469,7 +469,7 @@ class FunkinHscript extends InterpEx {
if (FlxTransitionableState.skipNextTransIn)
CustomFadeTransition.nextCamera = null;

FlxG.switchState(() -> new CreditsState());
MusicBeatState.switchState(new CreditsState());

FlxG.sound.music.stop();
FlxG.sound.playMusic(Paths.music('freakyMenu'));
Expand Down
4 changes: 2 additions & 2 deletions source/meta/data/scripts/FunkinLua.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1529,9 +1529,9 @@ class FunkinLua {
CustomFadeTransition.nextCamera = null;

if (PlayState.isStoryMode)
FlxG.switchState(() -> new StoryMenuState());
MusicBeatState.switchState(new StoryMenuState());
else
FlxG.switchState(() -> new FreeplayState());
MusicBeatState.switchState(new FreeplayState());

FlxG.sound.playMusic(Paths.music('freakyMenu'));
PlayState.changedDifficulty = false;
Expand Down
4 changes: 2 additions & 2 deletions source/meta/state/AchievementsMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ class AchievementsMenuState extends MusicBeatState
if (controls.BACK) {
FlxG.sound.play(Paths.sound('cancelMenu'));
if (ClientPrefs.simpleMain)
FlxG.switchState(() -> new SimpleMainMenuState());
MusicBeatState.switchState(new SimpleMainMenuState());
else
FlxG.switchState(() -> new MainMenuState());
MusicBeatState.switchState(new MainMenuState());
}

for (num => item in grpOptions.members) {
Expand Down
2 changes: 1 addition & 1 deletion source/meta/state/BruhState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BruhState extends MusicBeatState
override function update(elapsed:Float)
{
if (FlxG.keys.justPressed.ESCAPE || FlxG.keys.justPressed.ENTER) {
FlxG.switchState(() -> new MainMenuState());
MusicBeatState.switchState(new MainMenuState());
if (!FlxG.keys.justPressed.ENTER)
CoolUtil.browserLoad('https://github.com/Joalor64GH/Joalor64-Engine-Rewrite/releases/latest');
}
Expand Down
4 changes: 2 additions & 2 deletions source/meta/state/CreditsState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ class CreditsState extends MusicBeatState
}
FlxG.sound.play(Paths.sound('cancelMenu'));
if (ClientPrefs.simpleMain)
FlxG.switchState(() -> new SimpleMainMenuState());
FlxG.switchState(new SimpleMainMenuState());
else
FlxG.switchState(() -> new MainMenuState());
FlxG.switchState(new MainMenuState());
quitting = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/meta/state/DonateScreenState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class DonateScreenState extends MusicBeatState
if (controls.BACK)
{
FlxG.sound.playMusic(Paths.music('freakyMenu'), 1);
FlxG.switchState(() -> new MainMenuState());
MusicBeatState.switchState(new MainMenuState());
}

if (controls.ACCEPT)
Expand Down
4 changes: 2 additions & 2 deletions source/meta/state/EpicState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class EpicState extends MusicBeatState
if (controls.BACK)
{
if (ClientPrefs.simpleMain)
FlxG.switchState(() -> new SimpleMainMenuState());
MusicBeatState.switchState(new SimpleMainMenuState());
else
FlxG.switchState(() -> new MainMenuState());
MusicBeatState.switchState(new MainMenuState());
}

if (controls.ACCEPT)
Expand Down
2 changes: 1 addition & 1 deletion source/meta/state/FlashingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FlashingState extends MusicBeatState
FlxG.sound.play(Paths.sound('cancelMenu'));
FlxTween.tween(bg, {alpha: 0}, 1, {
onComplete: function(twn:FlxTween) {
FlxG.switchState(() -> new TitleState());
MusicBeatState.switchState(new TitleState());
}
});

Expand Down
6 changes: 3 additions & 3 deletions source/meta/state/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class FreeplayState extends MusicBeatState
else if (upP || downP) changeDiff();
#if sys
else if (alt && ClientPrefs.saveReplay)
FlxG.switchState(() -> new ReplaySelectState(songs[curSelected].songName));
MusicBeatState.switchState(new ReplaySelectState(songs[curSelected].songName));
#end

if (controls.BACK)
Expand All @@ -319,9 +319,9 @@ class FreeplayState extends MusicBeatState
}
FlxG.sound.play(Paths.sound('cancelMenu'));
if (ClientPrefs.simpleMain)
FlxG.switchState(() -> new SimpleMainMenuState());
MusicBeatState.switchState(new SimpleMainMenuState());
else
FlxG.switchState(() -> new MainMenuState());
MusicBeatState.switchState(new MainMenuState());
}

if(ctrl)
Expand Down
2 changes: 1 addition & 1 deletion source/meta/state/GameExitState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class GameExitState extends MusicBeatState
FlxG.camera.fade(FlxColor.BLACK, 0.5, false, function() { Sys.exit(0); }, false);
case 'No':
StageData.loadDirectory(PlayState.SONG);
LoadingState.loadAndSwitchState(() -> new PlayState());
LoadingState.loadAndSwitchState(new PlayState());
}
}
}
22 changes: 11 additions & 11 deletions source/meta/state/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class MainMenuState extends MusicBeatState
camFollowPos.setPosition(FlxMath.lerp(camFollowPos.x, camFollow.x, lerpVal), FlxMath.lerp(camFollowPos.y, camFollow.y, lerpVal));

if (FlxG.keys.justPressed.E)
FlxG.switchState(() -> new EpicState());
MusicBeatState.switchState(new EpicState());

if (!selectedSomethin)
{
Expand Down Expand Up @@ -358,7 +358,7 @@ class MainMenuState extends MusicBeatState
selectedSomethin = true;
FlxG.mouse.visible = false;
FlxG.sound.play(Paths.sound('cancelMenu'));
FlxG.switchState(() -> new TitleState());
MusicBeatState.switchState(new TitleState());
}

if (controls.ACCEPT || FlxG.mouse.justPressed)
Expand Down Expand Up @@ -409,23 +409,23 @@ class MainMenuState extends MusicBeatState
switch (daChoice)
{
case 'story_mode':
FlxG.switchState(() -> new StoryMenuState());
MusicBeatState.switchState(new StoryMenuState());
case 'freeplay':
FlxG.switchState(() -> new FreeplayState());
MusicBeatState.switchState(new FreeplayState());
case 'mini':
FlxG.switchState(() -> new MinigamesState());
MusicBeatState.switchState(new MinigamesState());
#if MODS_ALLOWED
case 'mods':
FlxG.switchState(() -> new ModsMenuState());
MusicBeatState.switchState(new ModsMenuState());
#end
#if ACHIEVEMENTS_ALLOWED
case 'awards':
FlxG.switchState(() -> new AchievementsMenuState());
MusicBeatState.switchState(new AchievementsMenuState());
#end
case 'credits':
FlxG.switchState(() -> new CreditsState());
MusicBeatState.switchState(new CreditsState());
case 'options':
LoadingState.loadAndSwitchState(() -> new OptionsState());
LoadingState.loadAndSwitchState(new OptionsState());
}
});
}
Expand All @@ -437,13 +437,13 @@ class MainMenuState extends MusicBeatState
{
selectedSomethin = true;
FlxG.mouse.visible = false;
FlxG.switchState(() -> new MasterEditorMenu());
MusicBeatState.switchState(new MasterEditorMenu());
}
else if (FlxG.keys.anyJustPressed(modShortcutKeys))
{
selectedSomethin = true;
FlxG.mouse.visible = false;
FlxG.switchState(() -> new ModsMenuState());
MusicBeatState.switchState(new ModsMenuState());
}
#end

Expand Down
8 changes: 4 additions & 4 deletions source/meta/state/MinigamesState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class MinigamesState extends MusicBeatState
changeSelection(controls.UI_UP_P ? -1 : 1);

if (controls.BACK)
FlxG.switchState((ClientPrefs.simpleMain) ? () -> new SimpleMainMenuState() : () -> new MainMenuState());
MusicBeatState.switchState((ClientPrefs.simpleMain) ? new SimpleMainMenuState() : new MainMenuState());

if (controls.ACCEPT)
{
Expand All @@ -81,13 +81,13 @@ class MinigamesState extends MusicBeatState
case 0:
PlayState.SONG = Song.loadFromJson('amogus', 'amogus');
PlayState.inMini = true;
LoadingState.loadAndSwitchState(() -> new PlayState());
LoadingState.loadAndSwitchState(new PlayState());
case 1:
PlayState.SONG = Song.loadFromJson('compression', 'compression');
PlayState.inMini = true;
LoadingState.loadAndSwitchState(() -> new PlayState());
LoadingState.loadAndSwitchState(new PlayState());
case 2:
FlxG.switchState(() -> new minigames.KillBF());
MusicBeatState.switchState(new minigames.KillBF());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/meta/state/ModDownloadState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class ModDownloadState extends MusicBeatState

if (controls.BACK && canExit && !idInputText.hasFocus)
{
FlxG.switchState(() -> new ModsMenuState());
MusicBeatState.switchState(new ModsMenuState());
}

super.update(elapsed);
Expand Down
Loading

0 comments on commit 3b18ccb

Please sign in to comment.