Skip to content

Commit

Permalink
Mod Support Just a error is popping up >:(
Browse files Browse the repository at this point in the history
  • Loading branch information
CamLikesKirby committed May 18, 2024
1 parent 9cdd96f commit 67bc155
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 13 deletions.
Binary file added assets/preload/images/packs/mod.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mods/test/data/CustomSongs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test:5:bf-pixel
1 change: 1 addition & 0 deletions mods/test/data/charts/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"song":{"song":"Test","bpm":150.0,"needsVoices":true,"player1":"bf","player2":"bf-pixel-opponent","speed":1.6,"notes":[{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[12800.0,0,0.0],[13199.999,1,0.0],[13599.999,2,0.0],[13999.999,3,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[14399.999,0,0.0],[14799.999,1,0.0],[15199.999,2,0.0],[15599.999,3,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[15999.999,0,0.0],[16199.999,0,0.0],[16400.0,1,0.0],[16600.0,1,0.0],[16800.0,2,0.0],[17000.0,2,0.0],[17200.0,3,0.0],[17400.0,3,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[17600.0,0,0.0],[17800.0,0,0.0],[18000.0,1,0.0],[18200.0,1,0.0],[18400.0,2,0.0],[18600.0,2,0.0],[18800.0,3,0.0],[19000.0,3,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[19200.0,0,300.0],[19600.0,1,300.0],[20000.0,2,300.0],[20400.0,3,300.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[20800.0,0,300.0],[21200.0,1,300.0],[21600.0,2,300.0],[22000.0,3,300.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[22400.0,0,700.0],[22800.0,1,300.0],[23200.0,2,700.0],[23600.0,3,300.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[24000.0,0,700.0],[24400.0,1,300.0],[24800.0,2,700.0],[25200.0,3,300.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[25600.0,0,0.0],[25600.0,1,0.0],[26399.998,3,0.0],[26399.998,2,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[27199.998,0,0.0],[27199.998,2,0.0],[27599.998,0,0.0],[27599.998,2,0.0],[27999.998,3,0.0],[27999.998,1,0.0],[28199.998,1,0.0],[28199.998,3,0.0],[28399.998,3,0.0],[28399.998,1,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[28799.998,0,0.0],[28799.998,1,0.0],[29599.998,3,0.0],[29599.998,2,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[30399.998,0,0.0],[30399.998,2,0.0],[30799.998,0,0.0],[30799.998,2,0.0],[31199.998,3,0.0],[31199.998,1,0.0],[31399.998,1,0.0],[31399.998,3,0.0],[31599.998,3,0.0],[31599.998,1,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[31999.998,0,0.0],[32099.998,1,0.0],[32199.998,0,100.0],[32399.998,3,0.0],[32499.998,2,0.0],[32599.998,3,100.0],[32800.0,0,0.0],[32900.0,1,0.0],[33000.0,0,100.0],[33200.0,3,0.0],[33300.0,2,0.0],[33400.0,3,100.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[33600.0,2,0.0],[33700.0,3,0.0],[33800.0,2,100.0],[34000.0,1,0.0],[34100.0,0,0.0],[34200.0,1,100.0],[34400.0,2,0.0],[34500.0,3,0.0],[34600.0,2,100.0],[34800.0,1,0.0],[34900.0,0,0.0],[35000.0,1,100.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[35200.0,0,0.0],[35300.0,1,0.0],[35400.0,0,100.0],[35600.0,3,0.0],[35700.0,2,0.0],[35800.0,3,100.0],[36000.0,0,0.0],[36100.0,1,0.0],[36200.0,0,100.0],[36400.0,3,0.0],[36500.0,2,0.0],[36600.0,3,100.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[36800.0,2,0.0],[36900.0,3,0.0],[37000.0,2,100.0],[37200.0,1,0.0],[37300.0,0,0.0],[37400.0,1,100.0],[37600.0,2,0.0],[37700.0,3,0.0],[37800.0,2,100.0],[38000.0,1,0.0],[38100.0,0,0.0],[38200.0,1,100.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[38400.0,0,0.0],[38600.0,3,0.0],[38800.0,1,0.0],[38900.0,2,0.0],[39000.0,1,0.0],[39100.0,2,0.0],[39200.0,0,0.0],[39400.0,3,0.0],[39600.0,1,0.0],[39700.0,2,0.0],[39800.0,1,0.0],[39900.0,2,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[40000.0,3,0.0],[40200.0,0,0.0],[40400.0,1,0.0],[40600.0,3,0.0],[40800.0,0,0.0],[41000.0,2,0.0],[41200.0,3,0.0],[41400.0,0,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[41600.0,0,0.0],[41800.0,3,0.0],[42000.0,1,0.0],[42100.0,2,0.0],[42200.0,1,0.0],[42300.0,2,0.0],[42400.0,0,0.0],[42600.0,3,0.0],[42800.0,1,0.0],[42900.0,2,0.0],[43000.0,1,0.0],[43100.0,2,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[43200.0,3,0.0],[43400.0,0,0.0],[43600.0,1,0.0],[43800.0,3,0.0],[44000.0,0,0.0],[44200.0,2,0.0],[44400.0,3,0.0],[44600.0,0,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[44800.0,0,0.0],[45066.6641,0,0.0],[45333.332,0,0.0],[45600.0,3,0.0],[45866.6641,3,0.0],[46133.332,3,0.0],[46266.6641,3,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[46400.0,1,100.0],[46800.0,1,200.0],[47200.0,1,300.0],[47600.0,1,400.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[48000.0,0,0.0],[48266.6641,0,0.0],[48533.332,0,0.0],[48800.0,3,0.0],[49066.6641,3,0.0],[49333.332,3,0.0],[49466.6641,3,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[49600.0,1,100.0],[50000.0,1,200.0],[50400.0,1,300.0],[50800.0,1,400.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[51200.0,0,800.0],[51200.0,1,800.0],[52599.9961,1,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[52799.9961,3,800.0],[52799.9961,1,800.0],[53599.9961,4,700.0],[53799.9961,5,499.999969],[53999.9961,6,300.0],[53999.9961,1,0.0],[53999.9961,2,0.0],[54199.9961,7,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[54399.9961,7,800.0],[54399.9961,6,800.0],[54399.9961,5,800.0],[54399.9961,4,800.0],[54399.9961,2,800.0],[54399.9961,0,800.0],[55799.9961,3,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[55999.9961,2,800.0],[55999.9961,3,800.0],[57199.9961,2,0.0],[57199.9961,1,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[57599.9961,1,800.0],[57599.9961,0,800.0],[58999.9961,1,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[59199.9961,3,800.0],[59199.9961,1,800.0],[59999.9961,4,700.0],[60199.9961,5,499.999969],[60399.9961,6,300.0],[60399.9961,1,0.0],[60399.9961,2,0.0],[60599.9961,7,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[60799.9961,7,800.0],[60799.9961,6,800.0],[60799.9961,5,800.0],[60799.9961,4,800.0],[60799.9961,0,800.0],[60799.9961,2,800.0],[62199.9961,3,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[62399.9961,2,800.0],[62399.9961,3,800.0],[63199.9961,6,0.0],[63299.9961,7,0.0],[63399.9961,6,0.0],[63499.9961,7,0.0],[63599.9961,4,0.0],[63599.9961,2,0.0],[63599.9961,1,0.0],[63649.9961,5,0.0],[63699.9961,6,0.0],[63749.9961,7,0.0],[63799.9961,6,0.0],[63849.9961,5,0.0],[63899.9961,4,0.0],[63949.9961,5,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[63999.9961,3,0.0],[64199.9961,2,0.0],[64399.9961,0,0.0],[64599.9961,3,499.999969],[65199.9961,3,0.0],[65399.9961,0,400.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[66000.0,0,0.0],[66200.0,1,0.0],[66400.0,0,0.0],[66666.6641,3,0.0],[66933.33,2,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[67200.0,3,0.0],[67300.0,2,0.0],[67800.0,2,0.0],[67850.0,0,449.999969],[68400.0,3,100.0],[68600.0,2,0.0],[68700.0,3,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[68800.0,0,0.0],[69000.0,1,0.0],[69200.0,0,0.0],[69400.0,3,0.0],[69600.0,2,0.0],[69800.0,3,300.0],[70200.0,0,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[70400.0,4,0.0],[70400.0,3,0.0],[70600.0,6,0.0],[70600.0,2,0.0],[70800.0,7,0.0],[70800.0,0,0.0],[71000.0,4,499.999969],[71000.0,3,499.999969],[71600.0,4,0.0],[71600.0,3,0.0],[71800.0,7,400.0],[71800.0,0,400.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[72400.0,7,0.0],[72400.0,0,0.0],[72600.0,5,0.0],[72600.0,1,0.0],[72800.0,7,0.0],[72800.0,0,0.0],[73066.6641,4,0.0],[73066.6641,3,0.0],[73333.33,6,0.0],[73333.33,2,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[73600.0,4,0.0],[73600.0,3,0.0],[73700.0,6,0.0],[73700.0,2,0.0],[74200.0,6,0.0],[74200.0,2,0.0],[74250.0,7,449.999969],[74250.0,0,449.999969],[74800.0,4,100.0],[74800.0,3,100.0],[75000.0,6,0.0],[75000.0,2,0.0],[75100.0,4,0.0],[75100.0,3,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[75200.0,7,0.0],[75200.0,0,0.0],[75400.0,5,0.0],[75400.0,1,0.0],[75600.0,7,0.0],[75600.0,0,0.0],[75800.0,4,0.0],[75800.0,3,0.0],[76000.0,6,0.0],[76000.0,2,0.0],[76200.0,4,300.0],[76200.0,3,300.0],[76600.0,0,0.0],[76600.0,7,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[76800.0,3,0.0],[76900.0,2,0.0],[77000.0,3,0.0],[77100.0,2,0.0],[77200.0,0,0.0],[77300.0,2,0.0],[77400.0,0,0.0],[77500.0,2,0.0],[77600.0,4,700.0],[77600.0,3,0.0],[77700.0,2,0.0],[77800.0,3,0.0],[77900.0,2,0.0],[78000.0,0,0.0],[78100.0,2,0.0],[78200.0,0,0.0],[78300.0,2,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[78400.0,7,700.0],[78400.0,3,0.0],[78500.0,1,0.0],[78600.0,3,0.0],[78700.0,1,0.0],[78800.0,0,0.0],[78900.0,1,0.0],[79000.0,0,0.0],[79100.0,1,0.0],[79200.0,5,400.0],[79200.0,3,0.0],[79300.0,1,0.0],[79400.0,3,0.0],[79500.0,1,0.0],[79600.0,0,0.0],[79700.0,1,0.0],[79800.0,0,0.0],[79900.0,1,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[80000.0,3,0.0],[80100.0,2,0.0],[80200.0,3,0.0],[80300.0,2,0.0],[80400.0,0,0.0],[80500.0,2,0.0],[80600.0,0,0.0],[80700.0,2,0.0],[80800.0,7,700.0],[80800.0,3,0.0],[80900.0,2,0.0],[81000.0,3,0.0],[81100.0,2,0.0],[81200.0,0,0.0],[81300.0,2,0.0],[81400.0,0,0.0],[81500.0,2,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[81600.0,4,700.0],[81600.0,3,0.0],[81700.0,1,0.0],[81800.0,3,0.0],[81900.0,1,0.0],[82000.0,0,0.0],[82100.0,1,0.0],[82200.0,0,0.0],[82300.0,1,0.0],[82400.0,5,400.0],[82400.0,3,0.0],[82500.0,1,0.0],[82600.0,3,0.0],[82700.0,1,0.0],[82800.0,0,0.0],[82900.0,1,0.0],[83000.0,0,0.0],[83100.0,1,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[83200.0,2,0.0],[83300.0,2,0.0],[83400.0,2,0.0],[83500.0,2,0.0],[83600.0,0,0.0],[83700.0,0,0.0],[83800.0,0,0.0],[83900.0,0,0.0],[84000.0,3,0.0],[84100.0,3,0.0],[84200.0,3,0.0],[84300.0,3,0.0],[84400.0,1,0.0],[84500.0,1,0.0],[84600.0,1,0.0],[84700.0,1,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[84800.0,0,0.0],[84933.33,0,0.0],[85066.6641,0,0.0],[85200.0,2,0.0],[85333.33,2,0.0],[85466.6641,2,0.0],[85600.0,3,0.0],[85733.33,3,0.0],[85866.6641,3,0.0],[86000.0,0,0.0],[86133.33,0,0.0],[86266.6641,0,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[86400.0,6,600.0],[86400.0,2,0.0],[86500.0,2,0.0],[86600.0,2,0.0],[86700.0,2,0.0],[86800.0,0,0.0],[86900.0,0,0.0],[87000.0,0,0.0],[87100.0,0,0.0],[87200.0,4,600.0],[87200.0,3,0.0],[87300.0,3,0.0],[87400.0,3,0.0],[87500.0,3,0.0],[87600.0,1,0.0],[87700.0,1,0.0],[87800.0,1,0.0],[87900.0,1,0.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[88000.0,7,600.0],[88000.0,0,0.0],[88133.33,0,0.0],[88266.6641,0,0.0],[88400.0,2,0.0],[88533.33,2,0.0],[88666.6641,2,0.0],[88800.0,5,600.0],[88800.0,3,0.0],[88933.33,3,0.0],[89066.6641,3,0.0],[89200.0,0,0.0],[89333.33,0,0.0],[89466.6641,0,0.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[89600.0,0,3200.0],[90000.0,3,300.0],[90400.0,2,300.0],[90800.0,1,300.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[91200.0,2,0.0],[91400.0,3,0.0],[91600.0,2,0.0],[91800.0,1,0.0],[92000.0,2,300.0],[92400.0,3,300.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[92800.0,0,3200.0],[93200.0,3,300.0],[93600.0,2,300.0],[94000.0,1,300.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[94400.0,2,0.0],[94600.0,3,0.0],[94800.0,2,0.0],[95000.0,1,0.0],[95200.0,2,300.0],[95600.0,3,300.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[96000.0,0,2300.0],[96400.0,3,300.0],[96800.0,2,300.0],[97200.0,1,300.0]]},{"lengthInSteps":16,"mustHitSection":false,"sectionNotes":[[97600.0,2,0.0],[97800.0,3,0.0],[98000.0,2,0.0],[98200.0,1,0.0],[98400.0,1,700.0],[98400.0,2,300.0],[98800.0,3,300.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[99200.0,2,300.0],[99200.0,0,700.0],[99600.0,2,0.0],[99800.0,2,0.0],[100000.0,3,300.0],[100000.0,1,300.0],[100400.0,2,300.0],[100400.0,0,300.0]]},{"lengthInSteps":16,"mustHitSection":true,"sectionNotes":[[100800.0,3,300.0],[100800.0,1,700.0],[101200.0,2,300.0],[101600.0,3,300.0],[101600.0,1,700.0],[102000.0,2,300.0]]}]},"generatedBy":"SNIFF ver.6"}
Binary file removed mods/test/icon.png
Binary file not shown.
Binary file added mods/test/songs/test/Inst.ogg
Binary file not shown.
Binary file added mods/test/songs/test/Voices.ogg
Binary file not shown.
6 changes: 5 additions & 1 deletion source/CoolUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import openfl.utils.AssetCache;
import flixel.math.FlxRandom;
import flixel.math.FlxMath;
import lime.utils.Assets;
#if sys
import sys.io.File;
import sys.FileSystem;
#end

using StringTools;

Expand Down Expand Up @@ -40,7 +44,7 @@ class CoolUtil

public static function coolTextFile(path:String):Array<String>
{
var daList:Array<String> = Assets.getText(path).trim().split('\n');
var daList:Array<String> = File.getContent(path).trim().split('\n');

for (i in 0...daList.length)
{
Expand Down
22 changes: 19 additions & 3 deletions source/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ class FreeplayState extends MusicBeatState
private var InMainFreeplayState:Bool = false;

private var CurrentSongIcon:FlxSprite;
var customSongs = CoolUtil.coolTextFile('mods/' + TitleState.currentMod + '/data/CustomSongs.txt'); // idk should work

private var Catagories:Array<String> = ['dave', 'joke', 'extras'];
private var Catagories:Array<String> = ['dave', 'joke', 'extras', 'mod'];
var translatedCatagory:Array<String> = [LanguageManager.getTextString('freeplay_dave'), LanguageManager.getTextString('freeplay_joke'), LanguageManager.getTextString('freeplay_extra')];

private var CurrentPack:Int = 0;
Expand Down Expand Up @@ -116,12 +117,15 @@ class FreeplayState extends MusicBeatState
var bgShader:Shaders.GlitchEffect;
var awaitingExploitation:Bool;
public static var packTransitionDone:Bool = false;
public static var isaCustomSong:Bool = false;
var characterSelectText:FlxText;
var showCharText:Bool = true;

override function create()
{
#if desktop DiscordClient.changePresence("In the Freeplay Menu", null); #end

isaCustomSong = false;

awaitingExploitation = (FlxG.save.data.exploitationState == 'awaiting');
showCharText = FlxG.save.data.wasInCharSelect;
Expand Down Expand Up @@ -154,12 +158,13 @@ class FreeplayState extends MusicBeatState
}
if (FlxG.save.data.terminalFound && !awaitingExploitation)
{
Catagories = ['dave', 'joke', 'extras', 'terminal'];
Catagories = ['dave', 'joke', 'extras', 'terminal', 'mod'];
translatedCatagory = [
LanguageManager.getTextString('freeplay_dave'),
LanguageManager.getTextString('freeplay_joke'),
LanguageManager.getTextString('freeplay_extra'),
LanguageManager.getTextString('freeplay_terminal')];
LanguageManager.getTextString('freeplay_terminal'),
TitleState.currentMod];
}

for (i in 0...Catagories.length)
Expand Down Expand Up @@ -314,6 +319,13 @@ class FreeplayState extends MusicBeatState
addWeek(['Exploitation'], 16, ['expunged']);

addWeek(['Enter Terminal'], 17, ['terminal']);
case 'mod':
isaCustomSong = true;
for (i in 0...customSongs.length)
{
var data:Array<String> = customSongs[i].split(':');
addWeek([data[0]], Std.parseInt(data[1]), [data[2]]);
}
}
}

Expand Down Expand Up @@ -631,7 +643,11 @@ class FreeplayState extends MusicBeatState
FlxG.switchState(new TerminalState());
default:
FlxG.sound.music.fadeOut(1, 0);
if (isaCustomSong) {
PlayState.SONG = Song.loadFromCustomJson(songs[curSelected].songName.toLowerCase()/*, curDifficulty*/);
} else {
PlayState.SONG = Song.loadFromJson(Highscore.formatSong(songs[curSelected].songName.toLowerCase(), curDifficulty));
}
PlayState.isStoryMode = false;
PlayState.storyDifficulty = curDifficulty;

Expand Down
13 changes: 7 additions & 6 deletions source/LoadingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import lime.utils.AssetLibrary;
import lime.utils.AssetManifest;

import haxe.io.Path;
import flash.media.Sound;

class LoadingState extends MusicBeatState
{
Expand Down Expand Up @@ -107,14 +108,14 @@ class LoadingState extends MusicBeatState
FlxG.switchState(target);
}

static function getSongPath()
{
return Paths.inst(PlayState.SONG.song);
}
static function getSongPath(): Null<String>
{
return PlayState.SONG.song;
}

static function getVocalPath()
static function getVocalPath(): Null<String>
{
return Paths.voices(PlayState.SONG.song);
return PlayState.SONG.song;
}

inline static public function loadAndSwitchState(target:FlxState, stopMusic = false)
Expand Down
58 changes: 56 additions & 2 deletions source/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import flixel.graphics.frames.FlxAtlasFrames;
import openfl.utils.AssetType;
import openfl.utils.Assets as OpenFlAssets;
#if sys import sys.FileSystem; #end
import flash.media.Sound;

class Paths
{
Expand Down Expand Up @@ -111,6 +112,13 @@ class Paths
return getPath('data/$key.xml', TEXT, library);
}

inline static public function modsSounds(path:String, key:String) {
return modSongs(path + '/' + key + '.' + SOUND_EXT);
}

static public function modSongs(key:String) {
return 'mods/' + TitleState.currentMod + '/songs/' + key;
}
inline static public function json(key:String, ?library:String)
{
return getPath('data/$key.json', TEXT, library);
Expand Down Expand Up @@ -148,12 +156,28 @@ class Paths

inline static public function voices(song:String, addon:String = "")
{
return 'songs:assets/songs/${song.toLowerCase()}/Voices${addon}.$SOUND_EXT';
if (OpenFlAssets.exists('${(song)}/Voices${(addon)}')) {
var songKey:String = '${(song)}/Voices${(addon)}';
var voices = returnSound(null, songKey, 'songs');
return voices;
} else {
var songKey:String = 'mods/' + TitleState.currentMod + '/songs/${(song)}/Voices${(addon)}';
var voices = returnSound(null, songKey, 'songs');
return voices;
}
}

inline static public function inst(song:String)
{
return 'songs:assets/songs/${song.toLowerCase()}/Inst.$SOUND_EXT';
if (OpenFlAssets.exists('${(song)}/Inst')) {
var songKey:String = '${(song)}/Inst';
var inst = returnSound(null, songKey, 'songs');
return inst;
} else {
var songKey:String = 'mods/' + TitleState.currentMod + '/songs/${(song)}/Inst';
var inst = returnSound(null, songKey, 'songs');
return inst;
}
}

inline static public function externmusic(song:String)
Expand Down Expand Up @@ -181,6 +205,36 @@ class Paths
return defaultReturnPath;
}
}

// Thanks psych engine for the sound code

public static var currentTrackedSounds:Map<String, Sound> = [];
public static var localTrackedAssets:Array<String> = [];
public static function returnSound(path:String, key:String, ?library:String) {

var modLibPath:String = '';
if (library != null) modLibPath = '$library/';
if (path != null) modLibPath += '$path/';

var file:String = modsSounds((path != null ? path : ""), key);
if(FileSystem.exists(file)) {
if(!currentTrackedSounds.exists(file)) {
currentTrackedSounds.set(file, Sound.fromFile(file));
}
localTrackedAssets.push(key);
return currentTrackedSounds.get(file);
}
var gottenPath:String = '$key.$SOUND_EXT';
if(path != null) gottenPath = '$path/$gottenPath';
// gottenPath = getPath(gottenPath, SOUND, library);
gottenPath = gottenPath.substring(gottenPath.indexOf(':') + 1, gottenPath.length);
if(!currentTrackedSounds.exists(gottenPath))

currentTrackedSounds.set(gottenPath, Sound.fromFile('./' + gottenPath));

localTrackedAssets.push(gottenPath);
return currentTrackedSounds.get(gottenPath);
}
/*
WARNING!!
DO NOT USE splashImage, splashFile or getSplashSparrowAtlas for searching stuff in paths!!!!!
Expand Down
20 changes: 20 additions & 0 deletions source/Song.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import lime.utils.Assets;
import lime.app.Application;
#end

#if sys
import sys.io.File;
import sys.FileSystem;
#end

using StringTools;

typedef SwagSong =
Expand Down Expand Up @@ -62,6 +67,21 @@ class Song
return parseJSONshit(rawJson);
}

public static function loadFromCustomJson(jsonInput:String):SwagSong
{
#if sys
var rawJson = File.getContent('mods/' + TitleState.currentMod + '/data/charts/' + jsonInput.toLowerCase()).trim() + '.json';
#else
var rawJson = Assets.getText(Paths.chart(jsonInput.toLowerCase())).trim();
#end

while (!rawJson.endsWith("}"))
{
rawJson = rawJson.substr(0, rawJson.length - 1);
}

return parseJSONshit(rawJson);
}
public static function parseJSONshit(rawJson:String):SwagSong
{
var swagShit:SwagSong = cast Json.parse(rawJson).song;
Expand Down
Loading

0 comments on commit 67bc155

Please sign in to comment.