diff --git a/README.md b/README.md index b4d4bcc9..93b36034 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ Also, the command `.\cne test` uses the source assets folder instead of the expo ## Codename Engine Codename Engine is a new Friday Night Funkin' Engine aimed at simplifying modding, along with extensiblity and ease of use.
-Make sure to read the wiki and join the Discord server linked there!
-#### It includes many new features, as seen [here](FEATURES.md)
+### Before making issues or need help with something, check our website [HERE](https://fnf-cne-devs.github.io/) (it contains a wiki of how to mod with EXAMPLES, an api, lists of mods made with Codename Engine and more)!!! +#### The Engine includes many new features, as seen [here](FEATURES.md)
#### Wanna see the new features added in the most recent update? Click [here](PATCHNOTES.md)
## How to download diff --git a/assets/data/config/credits.xml b/assets/data/config/credits.xml deleted file mode 100644 index 4f300fcb..00000000 --- a/assets/data/config/credits.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/assets/data/config/options.xml b/assets/data/config/options.xml deleted file mode 100644 index 888288d7..00000000 --- a/assets/data/config/options.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/assets/shaders/engine/editorBlur.frag b/assets/shaders/engine/editorBlur.frag index 59b91c72..85754b99 100644 --- a/assets/shaders/engine/editorBlur.frag +++ b/assets/shaders/engine/editorBlur.frag @@ -3,19 +3,17 @@ // Used for editors -int steps = 16; -int stepsInside = 2; -float strength = 0.0075; +const int steps = 16; +const int stepsInside = 2; +const float strength = 0.0075; + vec4 getColor(vec2 pos) { - vec2 ps = (pos); - ps = clamp(ps, vec2(0.0), 1.0 - (1.0 / openfl_TextureSize.xy)); - return flixel_texture2D(bitmap, (ps)); + pos = clamp(pos, vec2(0.0), vec2(1.0));//1.0 - (1.0 / openfl_TextureSize.xy)); + return flixel_texture2D(bitmap, pos); } + void main() { - // vec2 camPos = getCamPos(openfl_TextureCoordv); vec2 camPos = openfl_TextureCoordv; - if (camPos.x < 0.0 || camPos.x > 1.0 || camPos.y < 0.0 || camPos.y > 1.0) - return; vec4 color = getColor(camPos); float fsteps = float(steps); diff --git a/assets/shaders/engine/editorBlurFast.frag b/assets/shaders/engine/editorBlurFast.frag index 75ef96af..db476ae8 100644 --- a/assets/shaders/engine/editorBlurFast.frag +++ b/assets/shaders/engine/editorBlurFast.frag @@ -2,58 +2,29 @@ // Used for editors (faster) -//#define iResolution _camSize -#define getTexture textureCam - -#define iResolution openfl_TextureSize -//#define getTexture flixel_texture2D - -float uBlur = 0.015; -float uBrightness = 0.6; +const float uBlur = 0.015; +const float uBrightness = 0.6; vec4 getColor(vec2 pos) { - vec2 ps = (pos); - if (ps.x < 0.0) ps.x = 0.0; - //else if (ps.x > 1.0 - (1.0 / iResolution.x)) ps.x = 1.0 - (1.0 / iResolution.x); - else if (ps.x > 1.0) return vec4(0.0); - if (ps.y < 0.0) ps.y = 0.0; - //else if (ps.y > 1.0 - (1.0 / iResolution.y)) return ps.y = 1.0 - (1.0 / iResolution.y); - else if (ps.y > 1.0) return vec4(0.0); - return flixel_texture2D(bitmap, (ps)); + pos = clamp(pos, vec2(0.0), vec2(1.0));//1.0 - (1.0 / openfl_TextureSize.xy)); + return flixel_texture2D(bitmap, pos); } - -vec2 fixvec2(float x, float y) { // makes an uv the same across sizes - vec2 val = vec2(x, y); - val.xy *= vec2(1280.0, 720.0); - val.xy /= iResolution.xy; - return val; -} -vec2 fixvec2(vec2 uv) { // makes an uv the same across sizes - vec2 val = uv; - val.xy *= vec2(1280.0, 720.0); - val.xy /= iResolution.xy; - return val; -} +uniform sampler2D noiseTexture; +uniform vec2 noiseTextureSize; vec2 random(vec2 p) { - p = vec2(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3))); - return fract(sin(p)*4375.5); + p *= openfl_TextureSize; + return texture2D(noiseTexture, p / noiseTextureSize).rg - vec2(0.5); } void main() { - vec2 camPos = (openfl_TextureCoordv); - //vec2 camPos = openfl_TextureCoordv; - if (camPos.x < 0.0 || camPos.x > 1.0 || camPos.y < 0.0 || camPos.y > 1.0) - return; + vec2 camPos = openfl_TextureCoordv; + vec2 blur = vec2(uBlur) * vec2(1.0, openfl_TextureSize.x / openfl_TextureSize.y); - //vec4 color = getColor(camPos); - - vec2 blur = vec2(uBlur) * vec2(1.0, iResolution.x / iResolution.y); - - vec4 a = getColor(camPos+(random(camPos)*blur - blur / 2.0)) * uBrightness; - a += getColor(camPos+(random(camPos+0.1)*blur - blur / 2.0)) * uBrightness; - a += getColor(camPos+(random(camPos+0.2)*blur - blur / 2.0)) * uBrightness; - //a += getColor(camPos+(random(camPos+0.3)*blur - blur / 2.0)) * uBrightness; - gl_FragColor = a / 3.0; + vec4 a = getColor(camPos+random(camPos)*blur); + a += getColor(camPos+random(camPos+0.1)*blur); + //a += getColor(camPos+random(camPos+0.2)*blur); + //a += getColor(camPos+random(camPos+0.3)*blur); + gl_FragColor = (a / 2.0) * uBrightness; } \ No newline at end of file diff --git a/assets/shaders/noise128.png b/assets/shaders/noise128.png new file mode 100644 index 00000000..682cb32a Binary files /dev/null and b/assets/shaders/noise128.png differ diff --git a/assets/shaders/noise256.png b/assets/shaders/noise256.png new file mode 100644 index 00000000..fd2a1410 Binary files /dev/null and b/assets/shaders/noise256.png differ diff --git a/assets/shaders/noise512.png b/assets/shaders/noise512.png new file mode 100644 index 00000000..d50270af Binary files /dev/null and b/assets/shaders/noise512.png differ diff --git a/source/StringTools.hx b/source/StringTools.hx index 0b495af1..40397636 100644 --- a/source/StringTools.hx +++ b/source/StringTools.hx @@ -219,7 +219,7 @@ class StringTools { If `start` is the empty String `""`, the result is true. **/ - public static #if (java || python || (js && js_es >= 6)) inline #end function startsWith(s:String, start:String):Bool { + public static #if (java || python || (js && js_es >= 6) || cpp) inline #end function startsWith(s:String, start:String):Bool { #if java return (cast s : java.NativeString).startsWith(start); #elseif hl @@ -230,6 +230,8 @@ class StringTools { return (cast s).startsWith(start); #elseif lua return untyped __lua__("{0}:sub(1, #{1}) == {1}", s, start); + #elseif cpp + return untyped s.__StartsWith(start); #else return (s.length >= start.length && s.indexOf(start, 0) == 0); #end @@ -242,7 +244,7 @@ class StringTools { If `end` is the empty String `""`, the result is true. **/ - public static #if (java || python || (js && js_es >= 6)) inline #end function endsWith(s:String, end:String):Bool { + public static #if (java || python || (js && js_es >= 6) || cpp) inline #end function endsWith(s:String, end:String):Bool { #if java return (cast s : java.NativeString).endsWith(end); #elseif hl @@ -255,6 +257,8 @@ class StringTools { return (cast s).endsWith(end); #elseif lua return end == "" || untyped __lua__("{0}:sub(-#{1}) == {1}", s, end); + #elseif cpp + return untyped s.__EndsWith(end); #else var elen = end.length; var slen = s.length; diff --git a/source/funkin/backend/system/Logs.hx b/source/funkin/backend/system/Logs.hx index 4f47c150..336f9443 100644 --- a/source/funkin/backend/system/Logs.hx +++ b/source/funkin/backend/system/Logs.hx @@ -11,8 +11,7 @@ class Logs { public static var nativeTrace = Log.trace; public static function init() { - - Log.trace = function(v : Dynamic, ?infos : Null) { + Log.trace = function(v:Dynamic, ?infos:Null) { var data = [ logText('${infos.fileName}:${infos.lineNumber}: ', CYAN), logText(Std.string(v)) @@ -28,22 +27,48 @@ class Logs { __showInConsole(prepareColoredTrace(data, TRACE)); }; - LogFrontEnd.onLogs = function(Data, Style, FireOnce) { + LogFrontEnd.onLogs = function(data, style, fireOnce) { var prefix = "[FLIXEL]"; var color:ConsoleColor = LIGHTGRAY; var level:Level = INFO; - if (Style == LogStyle.CONSOLE) {prefix = "> "; color = WHITE; level = INFO; } else - if (Style == LogStyle.ERROR) {prefix = "[FLIXEL]"; color = RED; level = ERROR; } else - if (Style == LogStyle.NORMAL) {prefix = "[FLIXEL]"; color = WHITE; level = INFO; } else - if (Style == LogStyle.NOTICE) {prefix = "[FLIXEL]"; color = GREEN; level = VERBOSE;} else - if (Style == LogStyle.WARNING) {prefix = "[FLIXEL]"; color = YELLOW; level = WARNING;} + if (style == LogStyle.CONSOLE) // cant place a switch here as these arent inline values - Nex + { + prefix = "> "; + color = WHITE; + level = INFO; + } + else if (style == LogStyle.ERROR) + { + prefix = "[FLIXEL]"; + color = RED; + level = ERROR; + } + else if (style == LogStyle.NORMAL) + { + prefix = "[FLIXEL]"; + color = WHITE; + level = INFO; + } + else if (style == LogStyle.NOTICE) + { + prefix = "[FLIXEL]"; + color = GREEN; + level = VERBOSE; + } + else if (style == LogStyle.WARNING) + { + prefix = "[FLIXEL]"; + color = YELLOW; + level = WARNING; + } - var d:Dynamic = Data; + var d:Dynamic = data; if (!(d is Array)) d = [d]; var a:Array = d; var strs = [for(e in a) Std.string(e)]; - for(e in strs) { + for(e in strs) + { Logs.trace('$prefix $e', level, color); } }; @@ -55,7 +80,8 @@ class Logs { logText('[ '), logText('${Std.string(time.getHours()).addZeros(2)}:${Std.string(time.getMinutes()).addZeros(2)}:${Std.string(time.getSeconds()).addZeros(2)}', DARKMAGENTA), logText(' |'), - switch(level) { + switch (level) + { case WARNING: logText(' WARNING ', DARKYELLOW); case ERROR: logText(' ERROR ', DARKRED); case TRACE: logText(' TRACE ', GRAY); @@ -79,7 +105,7 @@ class Logs { } public static function __showInConsole(text:Array) { - #if sys + #if (sys && !mobile) while(__showing) { Sys.sleep(0.05); } @@ -91,15 +117,23 @@ class Logs { NativeAPI.setConsoleColors(); Sys.print("\r\n"); __showing = false; + #elseif mobile + while(__showing) { + Sys.sleep(0.05); + } + __showing = true; + @:privateAccess + Sys.print([for(t in text) t.text].join("")); + __showing = false; #else @:privateAccess nativeTrace([for(t in text) t.text].join("")); #end } - public static function traceColored(text:Array, level:Level = INFO) { + public static function traceColored(text:Array, level:Level = INFO) __showInConsole(prepareColoredTrace(text, level)); - } + public static function trace(text:String, level:Level = INFO, color:ConsoleColor = LIGHTGRAY, ?prefix:String) { var text = [logText(text, color)]; if(prefix != null) text.insert(0, getPrefix(prefix)); @@ -144,7 +178,8 @@ enum abstract Level(Int) { var SUCCESS = 5; var FAILURE = 6; } + typedef LogText = { var text:String; var color:ConsoleColor; -} \ No newline at end of file +} diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index e52f7732..df8bf94d 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -751,7 +751,10 @@ class CoolUtil */ @:noUsing public static inline function openURL(url:String) { #if linux - Sys.command('/usr/bin/xdg-open', [url]); + // generally `xdg-open` should work in every distro + var cmd = Sys.command("xdg-open", [url]); + // run old command JUST IN CASE it fails, which it shouldn't + if (cmd != 0) cmd = Sys.command("/usr/bin/xdg-open", [url]); #else FlxG.openURL(url); #end diff --git a/source/funkin/backend/utils/MemoryUtil.hx b/source/funkin/backend/utils/MemoryUtil.hx index 6c27629e..cd27cb0e 100644 --- a/source/funkin/backend/utils/MemoryUtil.hx +++ b/source/funkin/backend/utils/MemoryUtil.hx @@ -140,14 +140,16 @@ class MemoryUtil { reg.match(process.stdout.readAll().toString()); if (process.exitCode() == 0) return reg.matched(1); #elseif linux - var process = new HiddenProcess("sudo", ["dmidecode", "--type", "17"]); + /*var process = new HiddenProcess("sudo", ["dmidecode", "--type", "17"]); if (process.exitCode() != 0) return "Unknown"; var lines = process.stdout.readAll().toString().split("\n"); for (line in lines) { if (line.startsWith("Type:")) { return line.substring("Type:".length).trim(); } - } + }*/ + // TODO: sort of unsafe? also requires users to use `sudo` + // when launching the engine through the CLI, REIMPLEMENT LATER. #end return "Unknown"; } diff --git a/source/funkin/editors/character/CharacterSelection.hx b/source/funkin/editors/character/CharacterSelection.hx index 4416a1ae..b7a83adb 100644 --- a/source/funkin/editors/character/CharacterSelection.hx +++ b/source/funkin/editors/character/CharacterSelection.hx @@ -4,6 +4,7 @@ import funkin.game.Character; import funkin.options.OptionsScreen; import funkin.options.type.IconOption; import funkin.options.type.NewOption; +import funkin.options.type.TextOption; import funkin.options.type.OptionType; class CharacterSelection extends EditorTreeMenu @@ -16,22 +17,46 @@ class CharacterSelection extends EditorTreeMenu bgType = "charter"; super.create(); - var modsList:Array = Character.getList(true); + var isMods:Bool = true; + var modsList:Array = Character.getList(true, true); - var list:Array = [ - for (char in (modsList.length == 0 ? Character.getList(false) : modsList)) - new IconOption(char, translate("acceptCharacter"), Character.getIconFromCharName(char), - function() { - FlxG.switchState(new CharacterEditor(char)); - }) - ]; + if(modsList.length == 0) { + modsList = Character.getList(false, true); + isMods = false; + } - var newChar = translate("newCharacter"); - list.insert(0, new NewOption(newChar, newChar, function() { - openSubState(new UIWarningSubstate(translate("warnings.notImplemented-title"), translate("warnings.notImplemented-body"), [ - {label: TU.translate("editor.ok"), color: 0xFFFF0000, onClick: function(t) {}} - ])); - })); + function generateList(modsList:Array, isMods:Bool, folderPath:String = ""):Array { + var list:Array = []; + + for(char in modsList) { + if(char.endsWith("/")) { + var folderName = CoolUtil.getFilename(char.substr(0, char.length-1)); + + list.push(new TextOption(folderName + " >", translate("acceptFolder"), function() { + var newModsList = Character.getList(isMods, true, char); + var newList:Array = generateList(newModsList, isMods, folderPath + folderName + "/"); + optionsTree.add(new OptionsScreen(folderPath + folderName, translate("desc-folder", [folderPath + folderName + "/"]), newList)); + })); + } else { + list.push(new IconOption(char, translate("acceptCharacter"), Character.getIconFromCharName(folderPath + char, char), + function() { + FlxG.switchState(new CharacterEditor(folderPath + char)); + }) + ); + } + } + + var newChar = translate("newCharacter"); + list.insert(0, new NewOption(newChar, newChar, function() { + openSubState(new UIWarningSubstate(translate("warnings.notImplemented-title"), translate("warnings.notImplemented-body"), [ + {label: TU.translate("editor.ok"), color: 0xFFFF0000, onClick: function(t) {}} + ])); + })); + + return list; + } + + var list = generateList(modsList, isMods); main = new OptionsScreen(TU.translate("characterEditor.name"), translate("desc"), list); diff --git a/source/funkin/editors/charter/CharterEventScreen.hx b/source/funkin/editors/charter/CharterEventScreen.hx index 2189e5af..522bab6a 100644 --- a/source/funkin/editors/charter/CharterEventScreen.hx +++ b/source/funkin/editors/charter/CharterEventScreen.hx @@ -174,7 +174,11 @@ class CharterEventScreen extends UISubstateWindow { colorWheel; case TDropDown(options): addLabel(); - var dropdown = new UIDropDown(eventName.x, y, 320, 32, options, Std.int(Math.abs(options.indexOf(cast value)))); + var optionIndex = options.indexOf(cast value); + if(optionIndex < 0) { + optionIndex = 0; + } + var dropdown = new UIDropDown(eventName.x, y, 320, 32, options, optionIndex); paramsPanel.add(dropdown); paramsFields.push(dropdown); dropdown; case TCharacter: diff --git a/source/funkin/editors/ui/UISubstateWindow.hx b/source/funkin/editors/ui/UISubstateWindow.hx index f99e184b..71550ef0 100644 --- a/source/funkin/editors/ui/UISubstateWindow.hx +++ b/source/funkin/editors/ui/UISubstateWindow.hx @@ -1,5 +1,8 @@ package funkin.editors.ui; +import openfl.display.ShaderParameter; +import openfl.display.ShaderInput; +import openfl.filters.ShaderFilter; import flixel.tweens.FlxTween; import funkin.backend.shaders.CustomShader; import openfl.filters.ShaderFilter; @@ -7,7 +10,17 @@ import openfl.filters.ShaderFilter; // TODO: make UIWarningSubstate extend this class UISubstateWindow extends MusicBeatSubstate { var camShaders:Array = []; - var blurShader:CustomShader = new CustomShader(Options.intensiveBlur ? "engine/editorBlur" : "engine/editorBlurFast"); + var blurShader:CustomShader = { + var _ = new CustomShader(Options.intensiveBlur ? "engine/editorBlur" : "engine/editorBlurFast"); + if(!Options.intensiveBlur) { + var noiseTexture:ShaderInput = _.data.noiseTexture; + noiseTexture.input = Assets.getBitmapData("assets/shaders/noise256.png"); + noiseTexture.wrap = REPEAT; + var noiseTextureSize:ShaderParameter = _.data.noiseTextureSize; + noiseTextureSize.value = [noiseTexture.input.width, noiseTexture.input.height]; + } + _; + }; var titleSpr:UIText; var messageSpr:UIText; diff --git a/source/funkin/editors/ui/UIWarningSubstate.hx b/source/funkin/editors/ui/UIWarningSubstate.hx index 84edf922..4f4a0380 100644 --- a/source/funkin/editors/ui/UIWarningSubstate.hx +++ b/source/funkin/editors/ui/UIWarningSubstate.hx @@ -1,5 +1,8 @@ package funkin.editors.ui; +import openfl.display.ShaderParameter; +import openfl.display.ShaderInput; +import openfl.filters.ShaderFilter; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import funkin.backend.shaders.CustomShader; @@ -7,7 +10,17 @@ import openfl.filters.ShaderFilter; class UIWarningSubstate extends MusicBeatSubstate { var camShaders:Array = []; - var blurShader:CustomShader = new CustomShader(Options.intensiveBlur ? "engine/editorBlur" : "engine/editorBlurFast"); + var blurShader:CustomShader = { + var _ = new CustomShader(Options.intensiveBlur ? "engine/editorBlur" : "engine/editorBlurFast"); + if(!Options.intensiveBlur) { + var noiseTexture:ShaderInput = _.data.noiseTexture; + noiseTexture.input = Assets.getBitmapData("assets/shaders/noise256.png"); + noiseTexture.wrap = REPEAT; + var noiseTextureSize:ShaderParameter = _.data.noiseTextureSize; + noiseTextureSize.value = [noiseTexture.input.width, noiseTexture.input.height]; + } + _; + }; var title:String; var message:String; diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index 5f02dbd0..a7e93933 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -519,9 +519,10 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset return xml; } - public static function getIconFromCharName(?character:String) { + public static function getIconFromCharName(?character:String, ?defaultIcon:String = null) { if(character == null) return "face"; - var icon:String = character; + if(defaultIcon == null) defaultIcon = character; + var icon:String = defaultIcon; var xml:Access = getXMLFromCharName(character); if (xml != null && xml.x.exists("icon")) icon = xml.x.get("icon"); @@ -529,9 +530,17 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset return icon; } - public static function getList(?mods:Bool = false):Array - return [ - for (path in Paths.getFolderContent('data/characters/', true, mods ? MODS : BOTH)) - if (Path.extension(path) == "xml") CoolUtil.getFilename(path) - ]; + public static function getList(?mods:Bool = false, includeFolders:Bool = false, folder:String = 'data/characters/'):Array { + var list:Array = []; + if(includeFolders) { + for (path in Paths.getFolderDirectories(folder, true, mods ? MODS : BOTH)) { + if(!path.endsWith("/")) path += "/"; + list.push(path); + } + } + for (path in Paths.getFolderContent(folder, true, mods ? MODS : BOTH)) + if (Path.extension(path) == "xml") + list.push(CoolUtil.getFilename(path)); + return list; + } } \ No newline at end of file diff --git a/source/funkin/game/HealthIcon.hx b/source/funkin/game/HealthIcon.hx index 1c7bb59d..07feba62 100644 --- a/source/funkin/game/HealthIcon.hx +++ b/source/funkin/game/HealthIcon.hx @@ -90,11 +90,9 @@ class HealthIcon extends FlxSprite if (animation.curAnim != null) { var i:Int = -1; var oldKey:Int = -1; - for(k=>icon in healthSteps) { - if (k > oldKey && k < health * 100) { - oldKey = k; - i = icon; - } + for (k=>icon in healthSteps) if (k > oldKey && k <= health * 100) { + oldKey = k; + i = icon; } if (i >= 0 && curAnimState != i) { var event = EventManager.get(funkin.backend.scripting.events.HealthIconChangeEvent).recycle(i, this); diff --git a/source/funkin/game/cutscenes/DialogueCutscene.hx b/source/funkin/game/cutscenes/DialogueCutscene.hx index 7d43e951..6f850007 100644 --- a/source/funkin/game/cutscenes/DialogueCutscene.hx +++ b/source/funkin/game/cutscenes/DialogueCutscene.hx @@ -91,7 +91,7 @@ class DialogueCutscene extends Cutscene { musicVolume: node.has.musicVolume ? (volume = Std.parseFloat(node.att.speed).getDefaultFloat(0.8)) : null, changeMusic: node.has.changeMusic ? FlxG.sound.load(Paths.music(node.att.changeMusic), volume, true) : null, playSound: node.has.playSound ? FlxG.sound.load(Paths.sound(node.att.playSound)) : null, - nextSound: node.has.nextSound ? FlxG.sound.load(Paths.music(node.att.nextSound)) : null, + nextSound: node.has.nextSound ? FlxG.sound.load(Paths.sound(node.att.nextSound)) : null, textSound: null }; @@ -217,4 +217,4 @@ typedef DialogueLine = { var nextSound:FlxSound; var textSound:FlxSound; var changeDefAnim:String; -} \ No newline at end of file +} diff --git a/source/funkin/menus/MainMenuState.hx b/source/funkin/menus/MainMenuState.hx index 509a9d82..802b8e46 100644 --- a/source/funkin/menus/MainMenuState.hx +++ b/source/funkin/menus/MainMenuState.hx @@ -163,7 +163,7 @@ class MainMenuState extends MusicBeatState var event = event("onSelectItem", EventManager.get(NameEvent).recycle(daChoice)); if (event.cancelled) return; - switch (daChoice) + switch (event.name) { case 'story mode': FlxG.switchState(new StoryMenuState()); case 'freeplay': FlxG.switchState(new FreeplayState()); diff --git a/source/funkin/menus/PauseSubState.hx b/source/funkin/menus/PauseSubState.hx index 82a6173e..1f4008a0 100644 --- a/source/funkin/menus/PauseSubState.hx +++ b/source/funkin/menus/PauseSubState.hx @@ -14,6 +14,7 @@ import funkin.editors.charter.Charter; import funkin.menus.StoryMenuState; import funkin.options.OptionsMenu; import funkin.options.keybinds.KeybindsOptions; +import funkin.options.TreeMenu; class PauseSubState extends MusicBeatSubstate { @@ -167,9 +168,10 @@ class PauseSubState extends MusicBeatSubstate persistentDraw = false; openSubState(new KeybindsOptions()); case "Change Options": + TreeMenu.lastState = PlayState; FlxG.switchState(new OptionsMenu()); case "Exit to charter": - FlxG.switchState(new funkin.editors.charter.Charter(PlayState.SONG.meta.name, PlayState.difficulty, false)); + FlxG.switchState(new Charter(PlayState.SONG.meta.name, PlayState.difficulty, false)); case "Exit to menu": if (PlayState.chartingMode && Charter.undos.unsaved) game.saveWarn(false); @@ -217,4 +219,4 @@ class PauseSubState extends MusicBeatSubstate item.alpha = (item.targetY == 0) ? 1 : 0.6; } } -} \ No newline at end of file +} diff --git a/source/funkin/menus/StoryMenuState.hx b/source/funkin/menus/StoryMenuState.hx index b67c3cfc..56a708f5 100644 --- a/source/funkin/menus/StoryMenuState.hx +++ b/source/funkin/menus/StoryMenuState.hx @@ -114,6 +114,12 @@ class StoryMenuState extends MusicBeatState { } } + // default difficulty should be the middle difficulty in the array + // to be consistent with base game and whatnot, you know the drill + curDifficulty = Math.floor(weeks[0].difficulties.length * 0.5); + // debug stuff lol + Logs.trace('Middle Difficulty for Week 1 is ${weeks[0].difficulties[curDifficulty]} (ID: $curDifficulty)'); + changeWeek(0, true); DiscordUtil.call("onMenuLoaded", ["Story Menu"]); @@ -163,6 +169,7 @@ class StoryMenuState extends MusicBeatState { if (!force) CoolUtil.playMenuSFX(); for(k=>e in weekSprites.members) { e.targetY = k - curWeek; + e.alpha = k == curWeek ? 1.0 : 0.6; } var str = new StringBuf(); str.add(TU.translate("story.tracks") + "\n\n"); @@ -354,13 +361,13 @@ class StoryMenuState extends MusicBeatState { if (char.animation.exists("confirm")) char.animation.play("confirm"); - PlayState.loadWeek(weeks[curWeek], weeks[curWeek].difficulties[curDifficulty]); + PlayState.loadWeek(event.week, event.difficulty); new FlxTimer().start(1, function(tmr:FlxTimer) { FlxG.switchState(new PlayState()); }); - weekSprites.members[curWeek].startFlashing(); + weekSprites.members[event.weekID].startFlashing(); } } diff --git a/source/lime/system/System.hx b/source/lime/system/System.hx index ae32a5e2..2184f5fe 100644 --- a/source/lime/system/System.hx +++ b/source/lime/system/System.hx @@ -367,7 +367,10 @@ class System #elseif mac Sys.command("/usr/bin/open", [path]); #elseif linux - Sys.command("/usr/bin/xdg-open", [path]); + // generally `xdg-open` should work in every distro + var cmd = Sys.command("xdg-open", [path, "&"]); + // run old command JUST IN CASE it fails, which it shouldn't + if (cmd != 0) cmd = Sys.command("/usr/bin/xdg-open", [path, "&"]); #elseif (js && html5) Browser.window.open(path, "_blank"); #elseif flash