diff --git a/assets/languages/en/Options.xml b/assets/languages/en/Options.xml index 3eb3ca62..e4ce1bdc 100644 --- a/assets/languages/en/Options.xml +++ b/assets/languages/en/Options.xml @@ -24,6 +24,9 @@ Miscellaneous Use this menu to reset save data or engine settings. + Debug Options + Debug Options for Developer Mode. + @@ -169,8 +172,14 @@ Editor SFXs If checked, will play sound effects when working on editors (ex: will play sfxs when checking checkboxes...) - Pretty Print - If checked, the saved files from the editor will be formatted to be easily viewable (does not apply to xmls...) + Chart Pretty Print + If checked, the saved files from the chart editor will be formatted to be easily viewable + + Character Pretty Print + If checked, the saved files from the character editor will be formatted to be easily viewable + + Stage Pretty Print + If checked, the saved files from the stage editor will be formatted to be easily viewable Intensive Blur If checked, will use more intensive blur that may be laggier but look better. diff --git a/assets/languages/pl/Options.xml b/assets/languages/pl/Options.xml index de4512d7..68526dde 100644 --- a/assets/languages/pl/Options.xml +++ b/assets/languages/pl/Options.xml @@ -159,9 +159,6 @@ Dźwięki Edytorów Jeśli włączone, niektóre elementy edytorów będą grać dźwięki. (Na przykład: dźwięki pól wyboru...) - Ładny Druk - Jeśli włączone, zapisane pliki z edytorów będą używać formatowania łatwiejszego do odczytania. (opcja nie dotyczy plików xml, tylko po angielsku...) - Mocniejszy Rozmaz Jeśli włączone, gra użyje mocniejszego rozmazu, który kosztuje wydajność, ale wygląda lepiej. diff --git a/source/flixel/sound/FlxSound.hx b/source/flixel/sound/FlxSound.hx index e40bc407..eb39c4ac 100644 --- a/source/flixel/sound/FlxSound.hx +++ b/source/flixel/sound/FlxSound.hx @@ -881,7 +881,7 @@ class FlxSound extends FlxBasic { cleanup(false, true); startSound(time); } - else if (playing) { + else { _source.offset = 0; _source.currentTime = time + _offset; } diff --git a/source/funkin/editors/EditorPicker.hx b/source/funkin/editors/EditorPicker.hx index ff349203..ea751908 100644 --- a/source/funkin/editors/EditorPicker.hx +++ b/source/funkin/editors/EditorPicker.hx @@ -8,11 +8,6 @@ class EditorPicker extends MusicBeatSubstate { // Name is for backwards compatibility, don't use it, use id instead public var options:Array = [ - { - name: "Alphabet Editor", - id: "alphabet", - state: funkin.editors.alphabet.AlphabetSelection - }, { name: "Chart Editor", id: "chart", @@ -28,6 +23,11 @@ class EditorPicker extends MusicBeatSubstate { id: "stage", state: funkin.editors.stage.StageSelection }, + { + name: "Alphabet Editor", + id: "alphabet", + state: funkin.editors.alphabet.AlphabetSelection + }, #if (debug || debug_ui) { name: "UI Debug State", @@ -42,11 +42,6 @@ class EditorPicker extends MusicBeatSubstate { onClick: function() { CoolUtil.openURL(Flags.URL_WIKI); } - }, - { - name: "Debug Options", - id: "debugOptions", - state: DebugOptions } ]; diff --git a/source/funkin/editors/character/CharacterEditor.hx b/source/funkin/editors/character/CharacterEditor.hx index 264f7039..68f167fd 100644 --- a/source/funkin/editors/character/CharacterEditor.hx +++ b/source/funkin/editors/character/CharacterEditor.hx @@ -486,7 +486,8 @@ class CharacterEditor extends UIState { button.anim ]); - return "\n" + Printer.print(charXML, true); + var xmlThingYea:String = "\n" + Printer.print(charXML, Options.editorCharacterPrettyPrint); + return Options.editorCharacterPrettyPrint ? xmlThingYea : xmlThingYea.replace("\n", ""); } var clipboard:FlxPoint = FlxPoint.get(); diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 84d1dd57..f1e2a3ce 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -789,9 +789,9 @@ class Charter extends UIState { var songPath:String = '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}'; if (Options.charterAutoSavesSeparateFolder) - Chart.save(songPath, PlayState.SONG, __autoSaveLocation, {saveMetaInChart: true, saveLocalEvents: true, saveGlobalEvents: true, folder: "autosaves", prettyPrint: Options.editorPrettyPrint}); + Chart.save(songPath, PlayState.SONG, __autoSaveLocation, {saveMetaInChart: true, saveLocalEvents: true, saveGlobalEvents: true, folder: "autosaves", prettyPrint: Options.editorCharterPrettyPrint}); else // These two chart saves are particular, to avoid any kind of loss, stuff like meta, global and local events will be save all together - Nex - Chart.save(songPath, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: true, saveLocalEvents: true, saveGlobalEvents: true, prettyPrint: Options.editorPrettyPrint}); + Chart.save(songPath, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: true, saveLocalEvents: true, saveGlobalEvents: true, prettyPrint: Options.editorCharterPrettyPrint}); undos.save(); } autoSaveNotif.cancelled = false; @@ -1483,7 +1483,7 @@ class Charter extends UIState { } public static function saveChartAs(shouldBuild:Bool = true, withEvents:Bool = true) { - saveAs(Chart.filterChartForSaving(PlayState.SONG, false, withEvents, false), null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, { + saveAs(Chart.filterChartForSaving(PlayState.SONG, false, withEvents, false), null, Options.editorCharterPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, { defaultSaveFile: '${__diff.toLowerCase()}.json' }, null, shouldBuild); if (undos != null) undos.save(); @@ -1496,7 +1496,7 @@ class Charter extends UIState { var data = {events: Chart.filterChartForSaving(PlayState.SONG, false, false, true).events}; var path = '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/events.json'; - if (data.events != null && data.events.length > 0) CoolUtil.safeSaveFile(path, Json.stringify(data, null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null)); + if (data.events != null && data.events.length > 0) CoolUtil.safeSaveFile(path, Json.stringify(data, null, Options.editorCharterPrettyPrint ? Flags.JSON_PRETTY_PRINT : null)); else if (FileSystem.exists(path)) FileSystem.deleteFile(path); // Instead of replacing with a useless empty file, deletes the file directly - Nex #else saveEventsAs(shouldBuild); @@ -1507,7 +1507,7 @@ class Charter extends UIState { if (shouldBuild && instance != null) instance.buildChart(); var data = {events: Chart.filterChartForSaving(PlayState.SONG, false, false, true).events}; - saveAs(data, null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, { + saveAs(data, null, Options.editorCharterPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, { defaultSaveFile: 'events.json' }, null, false); } @@ -1532,13 +1532,13 @@ class Charter extends UIState { } public static function saveLegacyChartAs(shouldBuild:Bool = true) { - saveAs(FNFLegacyParser.encode(PlayState.SONG), null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, { + saveAs(FNFLegacyParser.encode(PlayState.SONG), null, Options.editorCharterPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, { defaultSaveFile: '${__song.toLowerCase().replace(" ", "-")}${__diff.toLowerCase() == Flags.DEFAULT_DIFFICULTY ? "" : '-${__diff.toLowerCase()}'}.json', }, null, shouldBuild); } public static function savePsychChartAs(shouldBuild:Bool = true) { - saveAs(PsychParser.encode(PlayState.SONG), null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, { + saveAs(PsychParser.encode(PlayState.SONG), null, Options.editorCharterPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, { defaultSaveFile: '${__song.toLowerCase().replace(" ", "-")}${__diff.toLowerCase() == Flags.DEFAULT_DIFFICULTY ? "" : '-${__diff.toLowerCase()}'}.json', }, null, shouldBuild); } @@ -1556,7 +1556,7 @@ class Charter extends UIState { #if sys public static function saveTo(path:String, separateEvents:Bool = false, shouldBuild:Bool = true) { if (shouldBuild && instance != null) instance.buildChart(); - Chart.save(path, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, saveLocalEvents: !separateEvents, prettyPrint: Options.editorPrettyPrint}); + Chart.save(path, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, saveLocalEvents: !separateEvents, prettyPrint: Options.editorCharterPrettyPrint}); } #end #end diff --git a/source/funkin/editors/stage/StageEditor.hx b/source/funkin/editors/stage/StageEditor.hx index d02cc997..8900c24f 100644 --- a/source/funkin/editors/stage/StageEditor.hx +++ b/source/funkin/editors/stage/StageEditor.hx @@ -726,8 +726,8 @@ class StageEditor extends UIState { } } - var xmlThingYea:String = "\n" + Printer.print(xml, Options.editorPrettyPrint); - return Options.editorPrettyPrint ? xmlThingYea : xmlThingYea.replace("\n", ""); + var xmlThingYea:String = "\n" + Printer.print(xml, Options.editorStagePrettyPrint); + return Options.editorStagePrettyPrint ? xmlThingYea : xmlThingYea.replace("\n", ""); } function _edit_undo(_) { diff --git a/source/funkin/editors/ui/UIAudioPlayer.hx b/source/funkin/editors/ui/UIAudioPlayer.hx index 4b87dd4d..bd7aaec7 100644 --- a/source/funkin/editors/ui/UIAudioPlayer.hx +++ b/source/funkin/editors/ui/UIAudioPlayer.hx @@ -29,9 +29,9 @@ class UIAudioPlayer extends UIButton { public function new(x:Float, y:Float, bytes:Bytes) { sound = FlxG.sound.load(Sound.fromAudioBuffer(AudioBuffer.fromBytes(bytes))); - super(x, y, null, function () { + super(x, y, null, () -> { if (sound.playing) sound.pause(); - else sound.play(false, sound.time); + else sound.play(); }, 58 - 16, 58 - 16); playingSprite = new FlxSprite(x + ((58 - 16)/2) - 8, y + ((58 - 16)/2) - 8).loadGraphic(Paths.image('editors/ui/audio-buttons'), true, 16, 16); @@ -107,20 +107,17 @@ class UIAudioPlayer extends UIButton { var spritePos:FlxPoint = sprite.getScreenPosition(FlxPoint.get(), __lastDrawCameras[0]); - if (((mousePos.x > (spritePos.x)) && (mousePos.x < (spritePos.x) + timeBar.barWidth)) - && ((mousePos.y > (spritePos.y)) && (mousePos.y < (spritePos.y) + timeBar.barHeight))) { - if (FlxG.mouse.justPressed) { - draggingObj = sprite; - wasPlaying = draggingObj == timeBar ? sound.playing : false; - } + if (((mousePos.x > spritePos.x) && (mousePos.x < spritePos.x + sprite.barWidth)) + && ((mousePos.y > spritePos.y) && (mousePos.y < spritePos.y + sprite.barHeight))) { + if (FlxG.mouse.justPressed) { + if ((draggingObj = sprite) == timeBar && (wasPlaying = sound.playing)) sound.pause(); + } if (FlxG.mouse.pressed) { - if (draggingObj == timeBar) { - if (sound.playing) sound.pause(); + if (draggingObj == timeBar) sound.time = FlxMath.remapToRange(mousePos.x - spritePos.x, 0, timeBar.barWidth, 0, sound.length); - } else if (draggingObj == volumeBar) { + else if (draggingObj == volumeBar) sound.volume = FlxMath.remapToRange(mousePos.x - spritePos.x, 0, volumeBar.barWidth, 0, 1); - } } } spritePos.put(); @@ -128,8 +125,10 @@ class UIAudioPlayer extends UIButton { mousePos.put(); if (FlxG.mouse.released) { - if (draggingObj == timeBar && wasPlaying) - sound.play(wasPlaying = false, sound.time); + if (draggingObj == timeBar && wasPlaying) { + sound.play(); + wasPlaying = false; + } draggingObj = null; } } diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index 15a9729f..32008f18 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -429,12 +429,12 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset var realFlipped:Bool = isPlayer ? !__baseFlipped : __baseFlipped; if (realFlipped) xml.set("flipX", "true"); - xml.set("icon", getIcon()); + if (icon != curCharacter) xml.set("icon", getIcon()); if (gameOverCharacter != Character.FALLBACK_DEAD_CHARACTER) xml.set("gameOverChar", gameOverCharacter); if (iconColor != null) xml.set("color", iconColor.toWebString()); - xml.set("sprite", sprite); + if (sprite != curCharacter) xml.set("sprite", sprite); if (scale.x != 1) xml.set("scale", Std.string(FlxMath.roundDecimal(scale.x, 4))); if (!antialiasing) xml.set("antialiasing", antialiasing == true ? "true" : "false"); @@ -453,12 +453,12 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset animXml.set("name", anim.name); animXml.set("anim", anim.anim); - animXml.set("loop", Std.string(anim.loop)); - animXml.set("fps", Std.string(FlxMath.roundDecimal(anim.fps, 2))); + if (anim.loop) animXml.set("loop", Std.string(anim.loop)); + if (FlxMath.roundDecimal(anim.fps, 2) != 24) animXml.set("fps", Std.string(FlxMath.roundDecimal(anim.fps, 2))); var offset:FlxPoint = getAnimOffset(anim.name); - animXml.set("x", Std.string(FlxMath.roundDecimal(offset.x, 2))); - animXml.set("y", Std.string(FlxMath.roundDecimal(offset.y, 2))); + if (FlxMath.roundDecimal(offset.x, 2) != 0) animXml.set("x", Std.string(FlxMath.roundDecimal(offset.x, 2))); + if (FlxMath.roundDecimal(offset.y, 2) != 0) animXml.set("y", Std.string(FlxMath.roundDecimal(offset.y, 2))); offset.putWeak(); if (anim.indices.length > 0) @@ -474,6 +474,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset } this.xml = new Access(xml); + return xml; } diff --git a/source/funkin/options/Options.hx b/source/funkin/options/Options.hx index 39d03594..cbb90d1b 100644 --- a/source/funkin/options/Options.hx +++ b/source/funkin/options/Options.hx @@ -57,7 +57,11 @@ class Options */ public static var intensiveBlur:Bool = true; public static var editorSFX:Bool = true; - public static var editorPrettyPrint:Bool = false; + + public static var editorCharterPrettyPrint:Bool = false; + public static var editorCharacterPrettyPrint:Bool = true; + public static var editorStagePrettyPrint:Bool = true; + public static var editorsResizable:Bool = true; public static var bypassEditorsResize:Bool = false; public static var maxUndos:Int = 120; diff --git a/source/funkin/options/OptionsMenu.hx b/source/funkin/options/OptionsMenu.hx index 93cd0d82..8fd3e238 100644 --- a/source/funkin/options/OptionsMenu.hx +++ b/source/funkin/options/OptionsMenu.hx @@ -47,6 +47,7 @@ class OptionsMenu extends TreeMenu { ]; var bg:FlxSprite; + var debugOption:TextOption; override function create() { super.create(); @@ -87,6 +88,9 @@ class OptionsMenu extends TreeMenu { } })])); + tree.first().add(debugOption = new TextOption('optionsTree.debug-name', 'optionsTree.debug-desc', ' >', () -> addMenu(new DebugOptions()))); + debugOption.locked = !Options.devMode; + for (i in funkin.backend.assets.ModsFolder.getLoadedMods()) { var xmlPath = Paths.xml('config/options/LIB_$i'); @@ -113,6 +117,11 @@ class OptionsMenu extends TreeMenu { updateBG(); } + override function menuChanged() { + super.menuChanged(); + debugOption.locked = !Options.devMode; + } + override function exit() { Options.save(); Options.applySettings(); diff --git a/source/funkin/editors/DebugOptions.hx b/source/funkin/options/categories/DebugOptions.hx similarity index 50% rename from source/funkin/editors/DebugOptions.hx rename to source/funkin/options/categories/DebugOptions.hx index 67799bbc..b0ff8e71 100644 --- a/source/funkin/editors/DebugOptions.hx +++ b/source/funkin/options/categories/DebugOptions.hx @@ -1,52 +1,18 @@ -package funkin.editors; +package funkin.options.categories; -import funkin.backend.utils.NativeAPI; -import funkin.options.TreeMenu; -import funkin.options.TreeMenuScreen; -import funkin.options.type.*; - -class DebugOptions extends TreeMenu { - var bg:FlxSprite; - - override function create() { - super.create(); - - add(bg = new FlxSprite().loadAnimatedGraphic(Paths.image('menus/menuBGBlue'))); - bg.antialiasing = true; - bg.scrollFactor.set(); - - addMenu(new DebugOptionsScreen()); - - FlxG.camera.fade(0xFF000000, 0.5, true); - UIState.setResolutionAware(); - } - - public function updateBG() { - var scaleX:Float = FlxG.width / bg.width; - var scaleY:Float = FlxG.height / bg.height; - bg.scale.x = bg.scale.y = Math.max(scaleX, scaleY) * 1.15; - bg.screenCenter(); - } - - override function onResize(width:Int, height:Int) { - super.onResize(width, height); - if (!UIState.resolutionAware) return; - - updateBG(); - } -} - -class DebugOptionsScreen extends TreeMenuScreen { +class DebugOptions extends TreeMenuScreen { public function new() { super('DebugOptions.title', 'DebugOptions.desc', 'DebugOptions.'); #if windows - add(new TextOption(getNameID("showConsole"), getDescID("showConsole"), () -> NativeAPI.allocConsole())); + add(new TextOption(getNameID("showConsole"), getDescID("showConsole"), () -> funkin.backend.utils.NativeAPI.allocConsole())); #end add(new Checkbox(getNameID("editorsResizable"), getDescID("editorsResizable"), "editorsResizable")); add(new Checkbox(getNameID("bypassEditorsResize"), getDescID("bypassEditorsResize"), "bypassEditorsResize")); add(new Checkbox(getNameID("editorSFX"), getDescID("editorSFX"), "editorSFX")); - add(new Checkbox(getNameID("editorPrettyPrint"), getDescID("editorPrettyPrint"), "editorPrettyPrint")); + add(new Checkbox(getNameID("editorCharterPrettyPrint"), getDescID("editorCharterPrettyPrint"), "editorCharterPrettyPrint")); + add(new Checkbox(getNameID("editorCharacterPrettyPrint"), getDescID("editorCharacterPrettyPrint"), "editorCharacterPrettyPrint")); + add(new Checkbox(getNameID("editorStagePrettyPrint"), getDescID("editorStagePrettyPrint"), "editorStagePrettyPrint")); add(new Checkbox(getNameID("intensiveBlur"), getDescID("intensiveBlur"), "intensiveBlur")); add(new Checkbox(getNameID("charterAutoSaves"), getDescID("charterAutoSaves"), "charterAutoSaves")); add(new NumOption(getNameID("charterAutoSaveTime"), getDescID("charterAutoSaveTime"), 60, 60*10, 1, "charterAutoSaveTime")); diff --git a/source/lime/_internal/backend/native/NativeAudioSource.hx b/source/lime/_internal/backend/native/NativeAudioSource.hx index 478ed150..4332fba4 100644 --- a/source/lime/_internal/backend/native/NativeAudioSource.hx +++ b/source/lime/_internal/backend/native/NativeAudioSource.hx @@ -394,6 +394,7 @@ class NativeAudioSource { AL.sourcePlay(handle); } } + else completed = value + 1 < getLength(); if (!playing && streamed) bufferTimes[STREAM_MAX_BUFFERS - (requestBuffers = queuedBuffers = 1)] = value / 1000; diff --git a/source/lime/media/AudioBuffer.hx b/source/lime/media/AudioBuffer.hx index 40ebfbec..aba05b8b 100644 --- a/source/lime/media/AudioBuffer.hx +++ b/source/lime/media/AudioBuffer.hx @@ -178,6 +178,12 @@ class AudioBuffer return audioBuffer; #elseif (lime_cffi && !macro) + #if lime_vorbis // CNE + if (funkin.options.Options.streamedMusic) { + var vorbisFile = VorbisFile.fromBytes(bytes); + if (vorbisFile != null) return fromVorbisFile(vorbisFile); + } + #end #if !cs var audioBuffer = new AudioBuffer(); audioBuffer.data = new UInt8Array(Bytes.alloc(0));