From bf0a6a9bbe48bc5eb6df56077b66ecac7cbbcedd Mon Sep 17 00:00:00 2001 From: syrup <123270096+maplesyruppppppp@users.noreply.github.com> Date: Fri, 7 Jun 2024 06:32:05 -0500 Subject: [PATCH 1/3] FPS Counter offset fix for Options/Credits menu (#307) * pixel note splashes * tyy!! * pixel secret notesplashes * the fix itself lol --- source/funkin/options/OptionsMenu.hx | 3 --- source/funkin/options/TreeMenu.hx | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/funkin/options/OptionsMenu.hx b/source/funkin/options/OptionsMenu.hx index f9232e13..497bfd9b 100644 --- a/source/funkin/options/OptionsMenu.hx +++ b/source/funkin/options/OptionsMenu.hx @@ -1,6 +1,5 @@ package funkin.options; -import funkin.backend.system.framerate.Framerate; import funkin.options.type.Checkbox; import haxe.xml.Access; import funkin.options.type.*; @@ -48,8 +47,6 @@ class OptionsMenu extends TreeMenu { bg.antialiasing = true; add(bg); - Framerate.offset.y = 60; - main = new OptionsScreen("Options", "Select a category to continue.", [for(o in mainOptions) new TextOption(o.name, o.desc, function() { if (o.substate != null) { persistentUpdate = false; diff --git a/source/funkin/options/TreeMenu.hx b/source/funkin/options/TreeMenu.hx index ac027134..b0651fd2 100644 --- a/source/funkin/options/TreeMenu.hx +++ b/source/funkin/options/TreeMenu.hx @@ -7,6 +7,7 @@ import flixel.tweens.FlxTween; import funkin.menus.MainMenuState; import flixel.util.typeLimit.OneOfTwo; import funkin.options.type.OptionType; +import funkin.backend.system.framerate.Framerate; class TreeMenu extends UIState { public var main:OptionsScreen; @@ -97,6 +98,8 @@ class TreeMenu extends UIState { var menuChangeTween:FlxTween; public override function update(elapsed:Float) { super.update(elapsed); + + Framerate.offset.y = pathBG.height; // in case path gets so long it goes offscreen pathLabel.x = lerp(pathLabel.x, Math.max(0, FlxG.width - 4 - pathLabel.width), 0.125); From 1fffb487197c619bb8bae08c736ce868b5eb4df8 Mon Sep 17 00:00:00 2001 From: Kolziak <53307233+Kolziak@users.noreply.github.com> Date: Fri, 7 Jun 2024 13:38:00 +0200 Subject: [PATCH 2/3] Mall fix (why was it like that) (#311) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Mall fix (why was it like that) * smol canon change --------- Co-authored-by: ⍚~Nex <87421482+NexIsDumb@users.noreply.github.com> --- assets/data/stages/mall.xml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/assets/data/stages/mall.xml b/assets/data/stages/mall.xml index 3552cf27..3565f1be 100644 --- a/assets/data/stages/mall.xml +++ b/assets/data/stages/mall.xml @@ -1,21 +1,21 @@ - + - + - + - - + + + + + + + - - - - - - \ No newline at end of file + From 8d0a38419de5ac4cccb5f08c47ea0acc3c6ded85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Fri, 7 Jun 2024 17:45:04 +0200 Subject: [PATCH 3/3] resolved the attrib +h crash in a cool way B) okay this was very funny to add --- source/funkin/backend/system/MainState.hx | 5 +- source/funkin/backend/utils/CoolUtil.hx | 39 ++++++++++----- source/funkin/backend/utils/NativeAPI.hx | 48 +++++++++++++++++-- source/funkin/backend/utils/native/Windows.hx | 17 +++++++ 4 files changed, 90 insertions(+), 19 deletions(-) diff --git a/source/funkin/backend/system/MainState.hx b/source/funkin/backend/system/MainState.hx index 885da7b0..d7238eec 100644 --- a/source/funkin/backend/system/MainState.hx +++ b/source/funkin/backend/system/MainState.hx @@ -66,9 +66,6 @@ class MainState extends FlxState { betaWarningShown = true; } - #if sys - sys.FileSystem.createDirectory('./.temp/'); - #if windows new funkin.backend.utils.native.HiddenProcess("attrib +h .temp"); #end - #end + CoolUtil.safeSetAttribute('./.temp/', HIDDEN); } } \ No newline at end of file diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index 4817bf5d..8cf268e6 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -1,5 +1,8 @@ package funkin.backend.utils; +#if sys +import sys.FileSystem; +#end import flixel.text.FlxText; import funkin.backend.utils.XMLUtil.TextFormat; import flixel.util.typeLimit.OneOfTwo; @@ -62,18 +65,15 @@ class CoolUtil */ @:noUsing public static function deleteFolder(delete:String) { #if sys - if (!sys.FileSystem.exists(delete)) return; - var files:Array = sys.FileSystem.readDirectory(delete); + if (!FileSystem.exists(delete)) return; + var files:Array = FileSystem.readDirectory(delete); for(file in files) { - if (sys.FileSystem.isDirectory(delete + "/" + file)) { + if (FileSystem.isDirectory(delete + "/" + file)) { deleteFolder(delete + "/" + file); - sys.FileSystem.deleteDirectory(delete + "/" + file); + FileSystem.deleteDirectory(delete + "/" + file); } else { - try { - sys.FileSystem.deleteFile(delete + "/" + file); - } catch(e) { - Logs.trace("Could not delete " + delete + "/" + file, WARNING); - } + try FileSystem.deleteFile(delete + "/" + file) + catch(e) Logs.trace("Could not delete " + delete + "/" + file, WARNING); } } #end @@ -98,6 +98,22 @@ class CoolUtil #end } + /** + * Sets an attribute to a file or a folder adding eventual missing folders in the path + * (WARNING: Only works on `windows`. On other platforms the return code it's always going to be `0` but still creates eventual missing folders if the platforms allows it to). + * @param path Path to the file or folder + * @param attrib The attribute to set (WARNING: There are some non settable attributes, such as the `COMPRESSED` one) + * @param useAbsol If it should use the absolute path (By default it's `true` but if it's `false` you can use files outside from this program's directory for example) + * @return The result code: 0 means that it failed setting + */ + @:noUsing public static inline function safeSetAttribute(path:String, attrib:NativeAPI.FileAttribute, useAbsol:Bool = true) { + addMissingFolders(Path.directory(path)); + + var result = NativeAPI.setFileAttribute(path, attrib, useAbsol); + if(result == 0) Logs.trace('Failed to set attribute to $path with a code of: $result', WARNING); + return result; + } + /** * Creates eventual missing folders to the specified `path` * @@ -113,9 +129,8 @@ class CoolUtil for (folder in folders) { currentPath += folder + "/"; - if (!sys.FileSystem.exists(currentPath)) { - sys.FileSystem.createDirectory(currentPath); - } + if (!FileSystem.exists(currentPath)) + FileSystem.createDirectory(currentPath); } #end return path; diff --git a/source/funkin/backend/utils/NativeAPI.hx b/source/funkin/backend/utils/NativeAPI.hx index a651645e..495403dc 100644 --- a/source/funkin/backend/utils/NativeAPI.hx +++ b/source/funkin/backend/utils/NativeAPI.hx @@ -29,6 +29,30 @@ class NativeAPI { #end } + /** + * Gets the specified file's (or folder) attribute. + */ + public static function getFileAttribute(path:String, useAbsol:Bool = true):FileAttribute { + #if windows + if(useAbsol) path = sys.FileSystem.absolutePath(path); + return Windows.getFileAttribute(path); + #else + return NORMAL; + #end + } + + /** + * Sets the specified file's (or folder) attribute. If it fails, the return value is `0`. + */ + public static function setFileAttribute(path:String, attrib:FileAttribute, useAbsol:Bool = true):Int { + #if windows + if(useAbsol) path = sys.FileSystem.absolutePath(path); + return Windows.setFileAttribute(path, attrib); + #else + return 0; + #end + } + public static function setDarkMode(title:String, enable:Bool) { #if windows Windows.setDarkMode(title, enable); @@ -61,15 +85,13 @@ class NativeAPI { var fg = cast(foregroundColor, Int); var bg = cast(backgroundColor, Int); Windows.setConsoleColors((bg * 16) + fg); - #else - #if sys + #elseif sys Sys.print("\x1b[0m"); if(foregroundColor != NONE) Sys.print("\x1b[" + Std.int(consoleColorToANSI(foregroundColor)) + "m"); if(backgroundColor != NONE) Sys.print("\x1b[" + Std.int(consoleColorToANSI(backgroundColor) + 10) + "m"); #end - #end } public static function consoleColorToANSI(color:ConsoleColor) { @@ -115,6 +137,26 @@ class NativeAPI { } } +enum abstract FileAttribute(Int) { + // Settables + var ARCHIVE = 0x20; + var HIDDEN = 0x2; + var NORMAL = 0x80; + var NOT_CONTENT_INDEXED = 0x2000; + var OFFLINE = 0x1000; + var READONLY = 0x1; + var SYSTEM = 0x4; + var TEMPORARY = 0x100; + + // Non Settables + var COMPRESSED = 0x800; + var DEVICE = 0x40; + var DIRECTORY = 0x10; + var ENCRYPTED = 0x4000; + var REPARSE_POINT = 0x400; + var SPARSE_FILE = 0x200; +} + enum abstract ConsoleColor(Int) { var BLACK = 0; var DARKBLUE = 1; diff --git a/source/funkin/backend/utils/native/Windows.hx b/source/funkin/backend/utils/native/Windows.hx index 07312d8d..5b03b904 100644 --- a/source/funkin/backend/utils/native/Windows.hx +++ b/source/funkin/backend/utils/native/Windows.hx @@ -1,6 +1,7 @@ package funkin.backend.utils.native; #if windows +import funkin.backend.utils.NativeAPI.FileAttribute; import funkin.backend.utils.NativeAPI.MessageBoxIcon; @:buildXml(' @@ -153,6 +154,22 @@ class Windows { public static function allocConsole() { } + @:functionCode(' + return GetFileAttributes(path); + ') + public static function getFileAttribute(path:String):FileAttribute + { + return NORMAL; + } + + @:functionCode(' + return SetFileAttributes(path, attrib); + ') + public static function setFileAttribute(path:String, attrib:FileAttribute):Int + { + return 0; + } + @:functionCode(' HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);