Merge branch 'main' into translations-system

This commit is contained in:
NeeEoo
2024-04-10 16:14:55 +02:00
59 changed files with 345 additions and 162 deletions
+6 -16
View File
@@ -33,6 +33,8 @@ enum abstract XMLAnimType(Int)
class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements IOffsetCompatible implements IXMLEvents
{
public var extra:Map<String, Dynamic> = [];
public var spriteAnimType:XMLAnimType = NONE;
public var beatAnims:Array<BeatAnim> = [];
public var name:String;
@@ -225,7 +227,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
for (key in animOffsets.keys()) {
final point = animOffsets[key];
animOffsets.remove(key);
if(point != null)
if (point != null)
point.put();
}
animOffsets = null;
@@ -320,19 +322,8 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
return animateAtlas != null ? (animateAtlas.anim.animsMap.exists(AnimName)
|| animateAtlas.anim.symbolDictionary.exists(AnimName)) : animation.exists(AnimName);
public inline function getAnimName()
{
var name = null;
if (animateAtlas != null)
{
name = atlasPlayingAnim;
}
else
{
if (animation.curAnim != null)
name = animation.curAnim.name;
}
return name;
public inline function getAnimName() {
return (animateAtlas != null) ? atlasPlayingAnim : animation.name;
}
public inline function removeAnimation(name:String) {
@@ -356,8 +347,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
animation.stop();
}
public inline function isAnimFinished()
{
public inline function isAnimFinished() {
return animateAtlas != null ? (animateAtlas.anim.finished) : (animation.curAnim != null ? animation.curAnim.finished : true);
}
#end
+1 -1
View File
@@ -230,7 +230,7 @@ class Chart {
if(data.meta != null && Reflect.hasField(data.meta, "parsedColor")) Reflect.deleteField(data.meta, "parsedColor");
}
data.events = saveEventsInChart != true ? null : Reflect.copy(chart.events); // same here once again
data.events = saveEventsInChart != true ? null : Reflect.copy(chart.events); // same here once again
data.fromMods = null;
var sortedData:Dynamic = {};
@@ -131,7 +131,7 @@ class FNFLegacyParser {
if ((swagSection.mustHitSection && strumLine.type == OPPONENT) ||
(!swagSection.mustHitSection && strumLine.type == PLAYER))
sectionNote[1] += 4;
sectionNote[1] += 4;
swagSection.sectionNotes.push(note);
}
}
@@ -14,8 +14,8 @@ final class FreeplayAlphaUpdateEvent extends CancellableEvent {
*/
public var selectedAlpha:Float;
/**
* The alpha when something is playing and selected
*/
* The alpha when something is playing and selected
*/
public var selectedPlayingAlpha:Float;
/**
* The lerp of the alpha
+34 -42
View File
@@ -363,12 +363,12 @@ class FunkinShader extends FlxShader implements IHScriptCustomBehaviour {
}
public function hget(name:String):Dynamic {
if (__instanceFields.contains(name) || __instanceFields.contains('get_${name}')) {
if (__instanceFields.contains(name) || __instanceFields.contains('get_${name}'))
return Reflect.getProperty(this, name);
}
if (!Reflect.hasField(data, name)) return null;
var field = Reflect.field(data, name);
var cl = Type.getClassName(Type.getClass(field));
if (!Reflect.hasField(data, name))
return null;
var field:Dynamic = Reflect.field(data, name);
var cl:String = Type.getClassName(Type.getClass(field));
// little problem we are facing boys...
@@ -394,45 +394,37 @@ class FunkinShader extends FlxShader implements IHScriptCustomBehaviour {
if (!Reflect.hasField(data, name)) {
Reflect.setField(data, name, val);
return val;
} else {
var field = Reflect.field(data, name);
var cl = Type.getClassName(Type.getClass(field));
// cant do "field is ShaderInput" for some reason
if (cl.startsWith("openfl.display.ShaderParameter")) {
@:privateAccess
if (field.__length <= 1) {
// that means we wait for a single number, instead of an array
@:privateAccess
if (field.__isInt && !(val is Int)) {
throw new ShaderTypeException(name, Type.getClass(val), 'Int');
return null;
} else
@:privateAccess
if (field.__isBool && !(val is Bool)) {
throw new ShaderTypeException(name, Type.getClass(val), 'Bool');
return null;
} else
@:privateAccess
if (field.__isFloat && !(val is Float)) {
throw new ShaderTypeException(name, Type.getClass(val), 'Float');
return null;
}
return field.value = [val];
} else {
if (!(val is Array)) {
throw new ShaderTypeException(name, Type.getClass(val), Array);
return null;
}
}
var field:Dynamic = Reflect.field(data, name);
var cl:String = Type.getClassName(Type.getClass(field));
// cant do "field is ShaderInput" for some reason
if (cl.startsWith("openfl.display.ShaderParameter")) {
@:privateAccess
if (field.__length <= 1) {
if ((val is Array))
return field.value = val;
}
} else if (cl.startsWith("openfl.display.ShaderInput")) {
// shader input!!
if (!(val is BitmapData)) {
throw new ShaderTypeException(name, Type.getClass(val), BitmapData);
return null;
}
field.input = cast val;
// that means we wait for a single number, instead of an array
if (field.__isInt && !(val is Int))
throw new ShaderTypeException(name, Type.getClass(val), 'Int');
else if (field.__isBool && !(val is Bool))
throw new ShaderTypeException(name, Type.getClass(val), 'Bool');
else if (field.__isFloat && !(val is Float))
throw new ShaderTypeException(name, Type.getClass(val), 'Float');
return field.value = [val];
} else {
if (!(val is Array))
throw new ShaderTypeException(name, Type.getClass(val), Array);
return field.value = val;
}
} else if (cl.startsWith("openfl.display.ShaderInput")) {
// shader input!!
if (!(val is BitmapData)) {
throw new ShaderTypeException(name, Type.getClass(val), BitmapData);
}
field.input = cast val;
}
return val;
@@ -19,6 +19,7 @@ class CommandLineHandler {
#end
Sys.println("-nocolor | Disables colors in the terminal");
Sys.println("-nogpubitmap | Forces GPU only bitmaps off");
Sys.println("-nocwdfix | Turns off automatic working directory fix");
Sys.exit(0);
#if MOD_SUPPORT
case "-m" | "-mod" | "-currentmod":
@@ -59,6 +60,8 @@ class CommandLineHandler {
Main.noTerminalColor = true;
case "-nogpubitmap":
Main.forceGPUOnlyBitmapsOff = true;
case "-nocwdfix":
Main.noCwdFix = true;
case "-livereload":
// do nothing
default:
+1 -1
View File
@@ -585,7 +585,7 @@ class Controls extends FlxActionSet
#else
for (gamepad in controls.gamepadsAdded)
if (gamepadsAdded.indexOf(gamepad) == -1)
gamepadsAdded.push(gamepad);
gamepadsAdded.push(gamepad);
#end
mergeKeyboardScheme(controls.keyboardScheme);
+10 -10
View File
@@ -32,11 +32,11 @@ class Logs {
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) {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;
if (!(d is Array))
@@ -56,11 +56,11 @@ class Logs {
logText('${Std.string(time.getHours()).addZeros(2)}:${Std.string(time.getMinutes()).addZeros(2)}:${Std.string(time.getSeconds()).addZeros(2)}', DARKMAGENTA),
logText(' |'),
switch(level) {
case WARNING: logText(' WARNING ', DARKYELLOW);
case ERROR: logText(' ERROR ', DARKRED);
case TRACE: logText(' TRACE ', GRAY);
case VERBOSE: logText(' VERBOSE ', DARKMAGENTA);
default: logText(' INFORMATION ', CYAN);
case WARNING: logText(' WARNING ', DARKYELLOW);
case ERROR: logText(' ERROR ', DARKRED);
case TRACE: logText(' TRACE ', GRAY);
case VERBOSE: logText(' VERBOSE ', DARKMAGENTA);
default: logText(' INFORMATION ', CYAN);
},
logText('] ')
];
+18
View File
@@ -24,6 +24,10 @@ import sys.thread.Thread;
import sys.io.File;
#end
import funkin.backend.assets.ModsFolder;
#if android
import android.content.Context;
import android.os.Build;
#end
class Main extends Sprite
{
@@ -198,9 +202,23 @@ class Main extends Sprite
for(b in pool.clear())
b.destroy();
}
openfl.display3D.utils.UInt8Buff._pools.clear();
}
MemoryUtil.clearMajor();
}
public static var noCwdFix:Bool = false;
public static function fixWorkingDirectory() {
#if windows
if (!noCwdFix && !sys.FileSystem.exists('manifest/default.json')) {
Sys.setCwd(haxe.io.Path.directory(Sys.programPath()));
}
#elseif android
Sys.setCwd(Path.addTrailingSlash(VERSION.SDK_INT > 30 ? Context.getObbDir() : Context.getExternalFilesDir()));
#elseif (ios || switch)
Sys.setCwd(Path.addTrailingSlash(openfl.filesystem.File.applicationStorageDirectory.nativePath));
#end
}
}
@@ -3,7 +3,7 @@ package funkin.backend.system.macros;
#if macro
class NewHaxeWarning {
public static function warn() {
#if (haxe >= "4.3.0")
#if (haxe >= "4.3.0" && !display)
Sys.println("====================");
Sys.println("[ WARNING ]");
Sys.println("Compiling with Haxe 4.3.0 isnt fully recommended yet, but it does work.");
@@ -101,7 +101,7 @@ class AsyncUpdater {
progress.files = files.length;
progress.step = DOWNLOADING_ASSETS;
trace('starting assets download');
doFile([for(e in files) e], [for(e in fileNames) e], function() {
doFile([for(e in files) e], fileNames.copy(), function() {
progress.curFile = -1;
progress.curFileName = null;
progress.files = 1;
+1 -1
View File
@@ -207,7 +207,7 @@ class CoolUtil
* @return String Result without any kind of IP
*/
public static inline function removeIP(msg:String):String {
return ~/\d+.\d+.\d+.\d+/.replace(msg, "[Your IP]"); // For now its just IPs but who knows in the future.. - Nex
return ~/\d+.\d+.\d+.\d+/.replace(msg, "[Your IP]"); // For now its just IPs but who knows in the future.. - Nex
}
/**
+1 -1
View File
@@ -134,7 +134,7 @@ class MemoryUtil {
if (process.exitCode() != 0) return "Unknown";
var lines = process.stdout.readAll().toString().split("\n");
for (line in lines) {
if (line.indexOf("Type:") == 0) {
if (line.startsWith("Type:")) {
return line.substring("Type:".length).trim();
}
}
+3 -1
View File
@@ -285,10 +285,12 @@ class XMLUtil {
}
/**
* Trims and removes spacing from the nodeValue in the XML
*
* WARNING: will edit directly the node!
*/
public static function fixSpacingInNode(node:Access):Access {
var arr = [for(x in node.x) x];
var arr = Lambda.array(node.x);
for(i => n in arr) {
if(n.nodeType == PCData) {
if(i == 0) n.nodeValue = n.nodeValue.ltrim();
+1 -1
View File
@@ -1811,7 +1811,7 @@ class Charter extends UIState {
public inline function __fixSelection(selection:Selection):Selection {
var newSelection:Selection = new Selection();
for (s in selection) if (newSelection.indexOf(s) == -1) newSelection.push(s);
for (s in selection) if (!newSelection.contains(s)) newSelection.push(s);
return newSelection.filter((s:ICharterSelectable) -> {return s != null;});
}
@@ -31,7 +31,7 @@ class CharterAutoSaveUI extends UISliceSprite {
progressBarBack = new FlxSprite(x + 10, y + bHeight - 20).makeGraphic(Std.int(bWidth-20), 10, 0x00000000, true);
progressBarBack.drawRoundRect(0, 0, progressBarBack.width, progressBarBack.height, 4, 6, 0xFF727272, null, {smoothing: false});
progressBarBack.drawRoundRect(1, 1, progressBarBack.width-2, progressBarBack.height-2, 4, 6, 0xFF0D0D0D, null, {smoothing: false});
members.push(progressBarBack); progressBarBack.antialiasing = false;
members.push(progressBarBack); progressBarBack.antialiasing = false;
progressBar = new FlxSprite(x + 10, y + bHeight - 20).makeGraphic(Std.int(bWidth-20), 10, 0x00000000, true);
progressBar.drawRoundRect(0, 0, progressBar.width, progressBar.height, 4, 6, 0xFF727272, null, {smoothing: false});
@@ -65,7 +65,7 @@ class CharterAutoSaveUI extends UISliceSprite {
public function startAutoSave(time:Float, sucessText:String) {
appearAnimation();
__tween = FlxTween.num(0, 1, time, null, (v:Float) -> {
if ((progress = v) < .95) {
autosavingText.text = 'Autosaving in ${Math.min(Math.round(time), 1+Math.floor(Math.abs(time-(progress*time))))} seconds';
@@ -100,7 +100,7 @@ class CharterAutoSaveUI extends UISliceSprite {
autosavingText.follow(this, 12+10+4, 8);
autosavingText.alpha = alpha;
for (bar in [progressBar, progressBarBack]) {
bar.follow(this, 10, bHeight-20);
bar.alpha = alpha;
@@ -253,7 +253,7 @@ class CharterBackdropDummy extends UISprite {
public override function draw() {
@:privateAccess
__lastDrawCameras = [for(c in cameras) c];
__lastDrawCameras = cameras.copy();
}
}
+1 -1
View File
@@ -69,7 +69,7 @@ class UISprite extends FlxSprite {
public function drawSuper() {
super.draw();
__lastDrawCameras = [for(c in cameras) c];
__lastDrawCameras = cameras.copy();
}
public function drawMembers() {
+3 -6
View File
@@ -25,8 +25,6 @@ using StringTools;
@:allow(funkin.game.PlayState)
class Character extends FunkinSprite implements IBeatReceiver implements IOffsetCompatible
{
public var extra:Map<String, String> = [];
private var __stunnedTime:Float = 0;
private var __lockAnimThisFrame:Bool = false;
@@ -407,11 +405,10 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
if (hasInterval) beatInterval = Std.parseInt(xml.x.get("interval"));
var tempList = ["isPlayer", "isGF", "x", "y", "gameOverChar", "camx", "camy", "holdTime", "flipX", "icon", "color", "scale", "antialiasing", "sprite", "interval"];
var atts = [for (i in xml.x.attributes()) i];
var atts = xml.x.attributes();
for (i in atts)
if (!tempList.contains(i)) {
if (!tempList.contains(i))
extra[i] = xml.x.get(i);
}
loadSprite(Paths.image('characters/$sprite'));
@@ -453,7 +450,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
for (name in animsOrder)
if (animDatas.exists(name)) anims.push(animDatas.get(name));
} else
anims = [for (anim in animDatas) anim];
anims = Lambda.array(animDatas);
for (anim in anims)
{
+2 -3
View File
@@ -27,7 +27,7 @@ class Note extends FlxSprite
return strumLine = strLine;
}
private function get_mustPress():Bool {
private inline function get_mustPress():Bool {
return false;
}
public var noteData:Int = 0;
@@ -191,7 +191,6 @@ class Note extends FlxSprite
}
public var lastScrollSpeed:Null<Float> = null;
public var angleOffsets:Bool = true;
public var gapFix:Single = 0;
public var useAntialiasingFix(get, set):Bool;
inline function set_useAntialiasingFix(v:Bool) {
@@ -290,7 +289,7 @@ class Note extends FlxSprite
setClipRect(swagRect);
}
public function setClipRect(rect:FlxRect) {
public inline function setClipRect(rect:FlxRect) {
this.clipRect = rect;
}
+1 -2
View File
@@ -106,8 +106,7 @@ class NoteGroup extends FlxTypedGroup<Note> {
if (members == null)
return null;
// TODO: maybe lastIndexOf
var index:Int = members.indexOfFromLast(Object);
var index:Int = members.lastIndexOf(Object);
if (index < 0)
return null;
+10 -8
View File
@@ -967,7 +967,7 @@ class PlayState extends MusicBeatState
{
if (songData == null) songData = SONG;
events = songData.events != null ? [for(e in songData.events) e] : [];
events = songData.events != null ? songData.events.copy() : [];
// get first camera focus
for(e in events) {
if (e.time > 10) break;
@@ -1678,8 +1678,9 @@ class PlayState extends MusicBeatState
}
public function displayRating(myRating:String, ?evt:NoteHitEvent = null):Void {
var pre:String = evt != null ? evt.ratingPrefix : "";
var suf:String = evt != null ? evt.ratingSuffix : "";
var hasEvent = evt != null;
var pre:String = hasEvent ? evt.ratingPrefix : "";
var suf:String = hasEvent ? evt.ratingSuffix : "";
var rating:FlxSprite = comboGroup.recycleLoop(FlxSprite);
rating.resetSprite(comboGroup.x + -40, comboGroup.y + -60);
@@ -1687,7 +1688,7 @@ class PlayState extends MusicBeatState
rating.acceleration.y = 550;
rating.velocity.y -= FlxG.random.int(140, 175);
rating.velocity.x -= FlxG.random.int(0, 10);
if (evt != null) {
if (hasEvent) {
rating.scale.set(evt.ratingScale, evt.ratingScale);
rating.antialiasing = evt.ratingAntialiasing;
}
@@ -1702,8 +1703,9 @@ class PlayState extends MusicBeatState
}
public function displayCombo(?evt:NoteHitEvent = null):Void {
var pre:String = evt != null ? evt.ratingPrefix : "";
var suf:String = evt != null ? evt.ratingSuffix : "";
var hasEvent = evt != null;
var pre:String = hasEvent ? evt.ratingPrefix : "";
var suf:String = hasEvent ? evt.ratingSuffix : "";
var separatedScore:String = Std.string(combo).addZeros(3);
@@ -1715,7 +1717,7 @@ class PlayState extends MusicBeatState
comboSpr.velocity.y -= 150;
comboSpr.velocity.x += FlxG.random.int(1, 10);
if (evt != null) {
if (hasEvent) {
comboSpr.scale.set(evt.ratingScale, evt.ratingScale);
comboSpr.antialiasing = evt.ratingAntialiasing;
}
@@ -1734,7 +1736,7 @@ class PlayState extends MusicBeatState
{
var numScore:FlxSprite = comboGroup.recycleLoop(FlxSprite).loadAnimatedGraphic(Paths.image('${pre}num${separatedScore.charAt(i)}${suf}'));
numScore.resetSprite(comboGroup.x + (43 * i) - 90, comboGroup.y + 80);
if (evt != null) {
if (hasEvent) {
numScore.antialiasing = evt.numAntialiasing;
numScore.scale.set(evt.numScale, evt.numScale);
}
+2 -2
View File
@@ -74,7 +74,7 @@ class Strum extends FlxSprite {
}
public override function draw() {
lastDrawCameras = [for(c in cameras) c];
lastDrawCameras = cameras.copy();
super.draw();
}
@@ -159,7 +159,7 @@ class Strum extends FlxSprite {
centerOffsets();
centerOrigin();
}
public function getAnim() {
public inline function getAnim() {
return animation.name;
}
}
+1
View File
@@ -536,6 +536,7 @@ class System
#if (sys && !macro)
funkin.backend.utils.NativeAPI.registerAsDPICompatible();
funkin.backend.system.CommandLineHandler.parseCommandLine(Sys.args());
funkin.backend.system.Main.fixWorkingDirectory();
#end
if (__applicationEntryPoint == null)