Merge remote-tracking branch 'master/main'

This commit is contained in:
⍚~Nex
2024-06-09 01:27:43 +02:00
7 changed files with 104 additions and 32 deletions
+11 -11
View File
@@ -1,21 +1,21 @@
<!DOCTYPE codename-engine-stage>
<stage zoom="0.8" name="mall" folder="stages/mall/" startCamPosY="450" startCamPosX="500">
<sprite name="bg" x="-1000" y="-500" sprite="bgWalls" scroll="0.2"/>
<sprite name="bg" x="-1380" y="-620" sprite="bgWalls" scale="0.8" scroll="0.2"/>
<high-memory>
<sprite name="upperBoppers" x="-240" y="-90" sprite="upperBop" scroll="0.2" type="onbeat" beatInterval="1"/>
<sprite name="upperBoppers" x="-400" y="-60" sprite="upperBop" scale="0.85" scroll="0.33" type="onbeat" beatInterval="1"/>
</high-memory>
<sprite name="bgEscalator" x="-1100" y="-600" sprite="bgEscalator" scroll="0.3" scale="0.9" updateHitbox="true"/>
<sprite name="bgEscalator" x="-1090" y="-540" sprite="bgEscalator" scroll="0.3" scale="0.9" updateHitbox="true"/>
<sprite name="tree" x="370" y="-250" sprite="christmasTree" scroll="0.4"/>
<sprite name="bottomBoppers" x="-300" y="140" sprite="bottomBop" scroll="0.9" type="onbeat" beatInterval="1"/>
<sprite name="fgSnow" x="-600" y="700" sprite="fgSnow"/>
<sprite name="bottomBoppers" x="-297" y="120" sprite="bottomBop" scroll="0.9" type="onbeat" beatInterval="1"/>
<sprite name="fgSnow" x="-600" y="680" sprite="fgSnow"/>
<girlfriend x="540" y="110"/>
<dad/>
<boyfriend x="1030" camyoffset="-150" camxoffset="-150"/>
<high-memory>
<sprite name="santa" x="-840" y="150" sprite="santa" type="onbeat" beatInterval="1"/>
</high-memory>
<girlfriend />
<dad />
<boyfriend x="870" camyoffset="-200"/>
</stage>
</stage>
+1 -4
View File
@@ -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);
}
}
+27 -12
View File
@@ -1,5 +1,8 @@
package funkin.backend.utils;
#if sys
import sys.FileSystem;
#end
import flixel.animation.FlxAnimation;
import flixel.input.keyboard.FlxKey;
import flixel.sound.FlxSound;
@@ -62,18 +65,15 @@ class CoolUtil
*/
@:noUsing public static function deleteFolder(delete:String) {
#if sys
if (!sys.FileSystem.exists(delete)) return;
var files:Array<String> = sys.FileSystem.readDirectory(delete);
if (!FileSystem.exists(delete)) return;
var files:Array<String> = 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;
+45 -3
View File
@@ -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;
@@ -1,6 +1,7 @@
package funkin.backend.utils.native;
#if windows
import funkin.backend.utils.NativeAPI.FileAttribute;
import funkin.backend.utils.NativeAPI.MessageBoxIcon;
@:buildXml('
<target id="haxe">
@@ -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);
-2
View File
@@ -48,8 +48,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;
+3
View File
@@ -7,6 +7,7 @@ import funkin.backend.FunkinText;
import funkin.editors.ui.UIState;
import funkin.menus.MainMenuState;
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);