diff --git a/codenamefanscomplainingaboutnoupdates/WOW!.png b/codenamefanscomplainingaboutnoupdates/WOW!.png deleted file mode 100644 index 364bf88f..00000000 Binary files a/codenamefanscomplainingaboutnoupdates/WOW!.png and /dev/null differ diff --git a/codenamefanscomplainingaboutnoupdates/i love testing.png b/codenamefanscomplainingaboutnoupdates/i love testing.png deleted file mode 100644 index 93f46e40..00000000 Binary files a/codenamefanscomplainingaboutnoupdates/i love testing.png and /dev/null differ diff --git a/codenamefanscomplainingaboutnoupdates/image.png b/codenamefanscomplainingaboutnoupdates/image.png deleted file mode 100644 index 273e3343..00000000 Binary files a/codenamefanscomplainingaboutnoupdates/image.png and /dev/null differ diff --git a/codenamefanscomplainingaboutnoupdates/socool.png b/codenamefanscomplainingaboutnoupdates/socool.png deleted file mode 100644 index fda718e3..00000000 Binary files a/codenamefanscomplainingaboutnoupdates/socool.png and /dev/null differ diff --git a/source/funkin/editors/charter/CharterSelection.hx b/source/funkin/editors/charter/CharterSelection.hx index b671a914..1a641dbd 100644 --- a/source/funkin/editors/charter/CharterSelection.hx +++ b/source/funkin/editors/charter/CharterSelection.hx @@ -1,5 +1,8 @@ package funkin.editors.charter; +import haxe.Json; +import funkin.backend.assets.ModsFolder; +import funkin.editors.charter.SongCreationScreen.SongCreationData; import funkin.options.type.NewOption; import funkin.backend.system.framerate.Framerate; import flixel.util.FlxColor; @@ -8,6 +11,8 @@ import funkin.editors.EditorTreeMenu; import funkin.options.*; import funkin.options.type.*; +using StringTools; + class CharterSelection extends EditorTreeMenu { public var freeplayList:FreeplaySonglist; public override function create() { @@ -26,15 +31,13 @@ class CharterSelection extends EditorTreeMenu { FlxG.switchState(new Charter(s.name, d)); }) ]; - list.push(new NewOption("New Difficulty", "New Difficulty", function() { - - })); + list.push(new NewOption("New Difficulty", "New Difficulty", function() {})); optionsTree.add(new OptionsScreen(s.name, "Select a difficulty to continue.", list)); }) ]; list.insert(0, new NewOption("New Chart", "New Chart", function() { - FlxG.state.openSubState(new SongCreationScreen()); + FlxG.state.openSubState(new SongCreationScreen(saveSong)); })); main = new OptionsScreen("Chart Editor", "Select a song to modify the charts from.", list); @@ -73,4 +76,34 @@ class CharterSelection extends EditorTreeMenu { bg.colorTransform.blueMultiplier = FlxMath.lerp(1, color.blueFloat, 0.25); } } + + public function saveSong(creation:SongCreationData) { + // Paths + var songsDir:String = ModsFolder.currentModFolder != null ? '${ModsFolder.modsPath}${ModsFolder.currentModFolder}/songs/' : './assets/songs/'; + var songFolder:String = '$songsDir${creation.meta.name.replace("-", " ")}'; + + #if sys + // Make Directories + sys.FileSystem.createDirectory(songFolder); + sys.FileSystem.createDirectory('$songFolder/song'); + sys.FileSystem.createDirectory('$songFolder/charts'); + + // Save Files + sys.io.File.saveContent('$songFolder/meta.json', Json.stringify(creation.meta, "\t")); + if (creation.instBytes != null) sys.io.File.saveBytes('$songFolder/song/Inst.${Paths.SOUND_EXT}', creation.instBytes); + if (creation.voicesBytes != null) sys.io.File.saveBytes('$songFolder/song/Voices.${Paths.SOUND_EXT}', creation.voicesBytes); + #end + + // Add to List + main.members.insert(1, new IconOption(creation.meta.name, "Press ACCEPT to choose a difficulty to edit.", creation.meta.icon, function() { + var list:Array = [ + for(d in creation.meta.difficulties) + if (d != "") new TextOption(d, "Press ACCEPT to edit the chart for the selected difficulty", function() { + FlxG.switchState(new Charter(creation.meta.name, d)); + }) + ]; + list.push(new NewOption("New Difficulty", "New Difficulty", function() {})); + optionsTree.add(new OptionsScreen(creation.meta.name, "Select a difficulty to continue.", list)); + })); + } } \ No newline at end of file diff --git a/source/funkin/editors/charter/SongCreationScreen.hx b/source/funkin/editors/charter/SongCreationScreen.hx index 046885c3..82bf9777 100644 --- a/source/funkin/editors/charter/SongCreationScreen.hx +++ b/source/funkin/editors/charter/SongCreationScreen.hx @@ -13,7 +13,7 @@ typedef SongCreationData = { } class SongCreationScreen extends UISubstateWindow { - private var onSave:SongCreationData -> Void = null; + private var onSave:Null -> Void = null; public var songNameTextBox:UITextBox; public var bpmStepper:UINumericStepper; @@ -158,7 +158,7 @@ class SongCreationScreen extends UISubstateWindow { saveButton = new UIButton(windowSpr.x + windowSpr.bWidth - 20 - 125, windowSpr.y + windowSpr.bHeight - 16 - 32, "Save & Close", function() { if (curPage == pages.length-1) { - if (onSave != null) onSave(null); + saveSongInfo(); close(); } else { curPage++; @@ -249,4 +249,30 @@ class SongCreationScreen extends UISubstateWindow { iconSprite.setPosition(iconTextBox.x + 150 + 8, (iconTextBox.y + 16) - (iconSprite.height/2)); } + function saveSongInfo() { + for (stepper in [bpmStepper, beatsPerMesureStepper, stepsPerBeatStepper]) + @:privateAccess stepper.__onChange(stepper.label.text); + + var meta:ChartMetaData = { + name: songNameTextBox.label.text, + bpm: bpmStepper.value, + beatsPerMesure: Std.int(beatsPerMesureStepper.value), + stepsPerBeat: Std.int(stepsPerBeatStepper.value), + needsVoices: needsVoicesCheckbox.checked, + displayName: displayNameTextBox.label.text, + icon: iconTextBox.label.text, + color: colorWheel.curColorString, + parsedColor: colorWheel.curColor, + opponentModeAllowed: opponentModeCheckbox.checked, + coopAllowed: coopAllowedCheckbox.checked, + difficulties: [for (diff in difficulitesTextBox.label.text.split(",")) diff.trim()], + }; + + if (onSave != null) onSave({ + meta: meta, + instBytes: instExplorer.file, + voicesBytes: voicesExplorer.file + }); + } + } \ No newline at end of file