Skip to content

Commit

Permalink
fix some stuff before I sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealJake12 committed Dec 2, 2023
1 parent 4bf38c1 commit df79fa4
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 31 deletions.
12 changes: 6 additions & 6 deletions Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
<define name="FEATURE_DISCORD" if="desktop" />
<!-- Defines whether the file system can be read/written directly. Does not work in browser. -->
<define name="FEATURE_FILESYSTEM" if="desktop" />
<!-- Defines whether Lua Modcharts should be enabled. Only works on Windows. -->
<define name="FEATURE_LUAMODCHART" if="desktop" />
<!-- Defines whether Lua Modcharts should be enabled. Does not work in browser. -->
<define name="FEATURE_LUAMODCHART" if="FEATURE_FILESYSTEM" />
<!-- Defines whether StepMania files can be loaded. -->
<define name="FEATURE_STEPMANIA" if="desktop" />
<define name="FEATURE_STEPMANIA" if="FEATURE_FILESYSTEM" />
<!-- Defines whether the Thread class can be used. -->
<define name="FEATURE_MULTITHREADING" if="cpp" />
<!-- Videos -->
<define name="VIDEOS" if="desktop || android"/>
<!-- Defines if hscript are enabled. Dosen't work in browser -->
<define name="FEATURE_HSCRIPT" if="desktop" />
<!-- Defines if hscript are enabled. Might Work In Browser. -->
<define name="FEATURE_HSCRIPT" />
<!-- Defines whether modcore can be used. -->
<define name="FEATURE_MODCORE" if="desktop" />
<define name="FEATURE_MODCORE" />

<!-- ____________________________ Window Settings ___________________________ -->

Expand Down
2 changes: 1 addition & 1 deletion source/CoolUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ class CoolUtil
}
return files;
}
#end

public static inline function getFileStringFromPath(file:String):String
{
return Path.withoutDirectory(Path.withoutExtension(file));
}
#end
}

/**
Expand Down
29 changes: 18 additions & 11 deletions source/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -854,10 +854,15 @@ class FreeplayState extends MusicBeatState
{
var songPath:String = null;

if (songs[curSelected].songCharacter == "sm")
songPath = FileSystem.absolutePath(songs[curSelected].path + "/" + songs[curSelected].sm.header.MUSIC);
else
songPath = Paths.inst(songs[curSelected].songName, true);
switch (songs[curSelected].songCharacter)
{
case "sm":
#if (FEATURE_FILESYSTEM && FEATURE_STEPMANIA)
songPath = FileSystem.absolutePath(songs[curSelected].path + "/" + songs[curSelected].sm.header.MUSIC);
#end
default:
songPath = Paths.inst(songs[curSelected].songName, true);
}

FlxG.sound.playMusic(songPath, 0.7, true);

Expand Down Expand Up @@ -921,14 +926,16 @@ class FreeplayState extends MusicBeatState
var currentSongData:SongData = null;
try
{
if (instance.songs[curSelected].songCharacter == "sm")
{
currentSongData = Song.loadFromJsonRAW(#if FEATURE_FILESYSTEM File.getContent(instance.songs[curSelected].sm.jsonPath) #else OpenFlAssets.getText(instance.songs[curSelected].songName) #end);
}
else
switch (instance.songs[curSelected].songCharacter)
{
currentSongData = Song.loadFromJson(instance.songs[curSelected].songName,
CoolUtil.getSuffixFromDiff(CoolUtil.difficultyArray[CoolUtil.difficultyArray.indexOf(instance.songs[curSelected].diffs[difficulty])]));
#if FEATURE_STEPMANIA
case "sm":
currentSongData = Song.loadFromJsonRAW(#if FEATURE_FILESYSTEM File.getContent(instance.songs[curSelected].sm.jsonPath) #else OpenFlAssets.getText(instance.songs[curSelected].songName) #end);
#end
default:
currentSongData = Song.loadFromJson(instance.songs[curSelected].songName,
CoolUtil.getSuffixFromDiff(CoolUtil.difficultyArray[CoolUtil.difficultyArray.indexOf(instance.songs[curSelected].diffs[difficulty])]));

}
}
catch (ex)
Expand Down
2 changes: 2 additions & 0 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ class Main extends Sprite
Sys.println(errMsg);
Sys.println("Crash dump saved in " + Path.normalize(path));
Application.current.window.alert(errMsg, "Error!");
#if FEATURE_DISCORD
DiscordClient.shutdown();
#end
Sys.exit(1);
}

Expand Down
4 changes: 2 additions & 2 deletions source/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package;

import Controls.KeyboardScheme;
import flixel.util.FlxTimer;
#if desktop
#if FEATURE_DISCORD
import Discord.DiscordClient;
#end
import flixel.FlxG;
Expand Down Expand Up @@ -93,7 +93,7 @@ class MainMenuState extends MusicBeatState
{
Paths.clearStoredMemory();
Paths.clearUnusedMemory();
#if desktop
#if FEATURE_DISCORD
// Updating Discord Rich Presence
DiscordClient.changePresence("In the Menus", null);
#end
Expand Down
3 changes: 1 addition & 2 deletions source/ModchartState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,8 @@ class ModchartState
PlayState.instance.addObject(PlayState.instance.dad);
}
}
#end

new LuaSprite(sprite, toBeCalled).Register(lua);
#end

return toBeCalled;
}
Expand Down
2 changes: 1 addition & 1 deletion source/OptionsMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class OptionsMenu extends MusicBeatSubstate
]),
new OptionCata(935, 40, "Saves", [
new General("Traces things in the debug console or logs."),
#if !web
#if FEATURE_FILESYSTEM
new ReplayOption("Watch Replays"), new SaveReplayOption("Allows Replays To Be Saved When A Song Ends."),
#end
new ResetScoreOption("Reset your score on all songs and weeks. This is irreversible!"),
Expand Down
13 changes: 6 additions & 7 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -522,21 +522,20 @@ class PlayState extends MusicBeatState
startTime = 0;

// Search For Lua Modcharts / Hscripts.
#if FEATURE_LUAMODCHART
#if (FEATURE_FILESYSTEM && FEATURE_LUAMODCHART)
executeModchart = FileSystem.exists(Paths.lua('songs/${PlayState.SONG.songId}/modchart')) && PlayStateChangeables.modchart;
if (isSM)
executeModchart = FileSystem.exists(pathToSm + "/modchart.lua");
executeModchart = OpenFlAssets.exists(Paths.lua('songs/${PlayState.SONG.songId}/modchart')) && PlayStateChangeables.modchart;
if (isSM)
executeModchart = OpenFlAssets.exists(pathToSm + "/modchart.lua");
#end
#if !cpp
#if !FEATURE_LUAMODCHART
executeModchart = false;
#end

// Use FileSystem on desktop for cool modcharts with no compile :>

#if !cpp
executeModchart = false;
#end

if (FlxG.save.data.gen)
{
Debug.logInfo('Searching for Lua Modchart? ($executeModchart) at ${Paths.lua('songs/${PlayState.SONG.songId}/modchart')}');
Expand Down Expand Up @@ -6711,7 +6710,7 @@ class PlayState extends MusicBeatState
inCutscene = true;

var filepath:String = Paths.video(name);
#if sys
#if FEATURE_FILESYSTEM
if (!FileSystem.exists(filepath))
#else
if (!OpenFlAssets.exists(filepath))
Expand Down
4 changes: 3 additions & 1 deletion source/script/Script.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import openfl.Lib;
import sys.FileSystem;
import sys.io.File;
#end
#if cpp
import cpp.CPPInterface;
#end

using StringTools;

Expand Down Expand Up @@ -137,7 +139,7 @@ class Script extends FlxBasic

if (OpenFlAssets.exists(path))
{
hx = File.getContent(path);
hx = OpenFlAssets.getText(path);
break;
}
}
Expand Down

0 comments on commit df79fa4

Please sign in to comment.