Merge branch 'main' into translations-system

This commit is contained in:
Ne_Eo
2025-01-09 20:26:29 +01:00
119 changed files with 1207 additions and 416 deletions
+2 -2
View File
@@ -38,7 +38,7 @@ class Conductor
public static var stepCrochet:Float = crochet / 4; // steps in milliseconds
/**
* Number of beats per mesure (top number in time signature). Defaults to 4.
* Number of beats per measure (top number in time signature). Defaults to 4.
*/
public static var beatsPerMeasure:Float = 4;
@@ -190,7 +190,7 @@ class Conductor
__updateSongPos(FlxG.elapsed);
if (bpm > 0) {
// updates curbeat and stuff
// updates curBeat and stuff
__lastChange = {
stepTime: 0,
songTime: 0,
-10
View File
@@ -1,10 +0,0 @@
package funkin.backend.system;
enum abstract ErrorCode(Int) {
var OK = 0;
var FAILED = 1;
var MISSING_PROPERTY = 2;
var TYPE_INCORRECT = 3;
var VALUE_NULL = 4;
var REFLECT_ERROR = 5;
}
+9 -2
View File
@@ -21,7 +21,7 @@ class Flags {
@:lazy public static var VERSION_MESSAGE:String = 'Codename Engine v${Application.current.meta.get('version')}';
public static var REPO_NAME:String = "CodenameEngine";
public static var REPO_OWNER:String = "FNF-CNE-Devs";
public static var REPO_OWNER:String = "CodenameCrew";
public static var REPO_URL:String = 'https://github.com/$REPO_OWNER/$REPO_NAME';
// make this empty once you guys are done with the project.
@@ -91,7 +91,7 @@ class Flags {
public static var DEFAULT_OPPONENT_MODE_ALLOWED:Bool = false;
@:also(funkin.game.PlayState.coopMode)
public static var DEFAULT_COOP_MODE:Bool = false; // used in playstate if it doesnt find it
public static var DEFAULT_COOP_MODE:Bool = false; // used in playstate if it doesn't find it
@:also(funkin.game.PlayState.opponentMode)
public static var DEFAULT_OPPONENT_MODE:Bool = false;
@@ -150,6 +150,13 @@ class Flags {
public static var DISABLE_EDITORS:Bool = false;
public static var DISABLE_BETA_WARNING_SCREEN:Bool = false;
public static var DISABLE_TRANSITIONS:Bool = false;
@:also(funkin.backend.MusicBeatTransition.script)
public static var DEFAULT_TRANSITION_SCRIPT:String = "";
@:also(funkin.menus.PauseSubState.script)
public static var DEFAULT_PAUSE_SCRIPT:String = "";
@:also(funkin.game.GameOverSubstate.script)
public static var DEFAULT_GAMEOVER_SCRIPT:String = "";
// -- End of Codename's Default Flags --
/**
@@ -3,7 +3,7 @@ package funkin.backend.system;
import flixel.graphics.FlxGraphic;
/**
* Dummy FlxSprite that allows you to cache FlxGraphics, and immediatly send them to GPU memory.
* Dummy FlxSprite that allows you to cache FlxGraphics, and immediately send them to GPU memory.
*/
class GraphicCacheSprite extends FlxSprite {
/**
+1 -1
View File
@@ -31,7 +31,7 @@ class Logs {
var prefix = "[FLIXEL]";
var color:ConsoleColor = LIGHTGRAY;
var level:Level = INFO;
if (style == LogStyle.CONSOLE) // cant place a switch here as these arent inline values - Nex
if (style == LogStyle.CONSOLE) // cant place a switch here as these aren't inline values - Nex
{
prefix = "> ";
color = WHITE;
+17 -3
View File
@@ -47,6 +47,10 @@ class Main extends Sprite
public static var game:FunkinGame;
/**
* The time since the game was focused last time in seconds.
*/
public static var timeSinceFocus(get, never):Float;
public static var time:Int = 0;
// You can pretty much ignore everything from here on - your code should go in your states.
@@ -148,7 +152,7 @@ class Main extends Sprite
Assets.registerLibrary('default', lib);
funkin.options.PlayerSettings.init();
funkin.backend.utils.FunkinSave.init();
funkin.savedata.FunkinSave.init();
Options.load();
FlxG.fixedTimestep = false;
@@ -158,6 +162,7 @@ class Main extends Sprite
Conductor.init();
AudioSwitchFix.init();
EventManager.init();
FlxG.signals.focusGained.add(onFocus);
FlxG.signals.preStateSwitch.add(onStateSwitch);
FlxG.signals.postStateSwitch.add(onStateSwitchPost);
@@ -203,13 +208,17 @@ class Main extends Sprite
{asset: diamond, width: 32, height: 32}, new FlxRect(-200, -200, FlxG.width * 1.4, FlxG.height * 1.4));
}
public static function onFocus() {
_tickFocused = FlxG.game.ticks;
}
private static function onStateSwitch() {
scaleMode.resetSize();
}
private static function onStateSwitchPost() {
// manual asset clearing since base openfl one doesnt clear lime one
// doesnt clear bitmaps since flixel fork does it auto
// manual asset clearing since base openfl one does'nt clear lime one
// does'nt clear bitmaps since flixel fork does it auto
@:privateAccess {
// clear uint8 pools
@@ -236,4 +245,9 @@ class Main extends Sprite
Sys.setCwd(Path.addTrailingSlash(openfl.filesystem.File.applicationStorageDirectory.nativePath));
#end
}
private static var _tickFocused:Float = 0;
public static function get_timeSinceFocus():Float {
return (FlxG.game.ticks - _tickFocused) / 1000;
}
}
@@ -60,6 +60,7 @@ class MainState extends FlxState {
TranslationUtil.findAllLanguages();
TranslationUtil.setLanguage();
ModsFolder.onModSwitch.dispatch(ModsFolder.currentModFolder); // Loads global.hx
MusicBeatTransition.script = Flags.DEFAULT_TRANSITION_SCRIPT;
Main.refreshAssets();
DiscordUtil.init();
EventsData.reloadEvents();
@@ -126,7 +126,7 @@ class Framerate extends Sprite {
bgSprite.scaleY = height;
var selectable = debugMode == 2;
{ // idk i tried to make it more lookable:sob: - Nex
{ // idk i tried to make it more readable:sob: - Nex
memoryCounter.memoryText.selectable = memoryCounter.memoryPeakText.selectable =
fpsCounter.fpsNum.selectable = fpsCounter.fpsLabel.selectable =
#if SHOW_BUILD_ON_FPS codenameBuildField.selectable = #end selectable;
@@ -63,7 +63,7 @@ class SystemInfo extends FramerateCategory {
cpuName = process.stdout.readAll().toString().trim().split("\n")[1].trim();
#elseif mac
var process = new HiddenProcess("sysctl -a | grep brand_string"); // Somehow this isnt able to use the args but it still works
var process = new HiddenProcess("sysctl -a | grep brand_string"); // Somehow this isn't able to use the args but it still works
if (process.exitCode() != 0) throw 'Could not fetch CPU information';
cpuName = process.stdout.readAll().toString().trim().split(":")[1].trim();
@@ -7,6 +7,11 @@ import haxe.Json;
import haxe.Exception;
// TODO: Document further and perhaps make this a Haxelib.
/**
* Set of functions to interact with GitHub.
* Requires the `GITHUB_API` macro to be defined.
* This has no authentication, so it's limited to unauthenticated requests, and rate limits.
**/
class GitHub {
/**
* Gets all the releases from a specific GitHub repository using the GitHub API.
@@ -21,4 +21,12 @@ typedef GitHubContributor = {
var type:String;
var site_admin:Bool;
var contributions:Int;
}
typedef CreditsGitHubContributor = {
var login:String;
var avatar_url:String;
var html_url:String;
var ?id:Int; // Not available in the avatar part
var ?contributions:Int; // Not available in the avatar part
}
@@ -78,9 +78,9 @@ class ControlsMacro
});
function buildBindControl(s:String, prefix:String) {
var prefixxed = prefix + s;
var prefixed = prefix + s;
return macro bindKeys(Control.$s, Options.$prefixxed);
return macro bindKeys(Control.$s, Options.$prefixed);
}
fields.push({
@@ -9,7 +9,7 @@ class DefinesMacro {
/**
* Returns the defined values
*/
public static var defines(get, null):Map<String, Dynamic>;
public static var defines(get, never):Map<String, Dynamic>;
// GETTERS
#if REGION
@@ -184,7 +184,7 @@ class FlagMacro {
}
case TPath({name: "Array", pack: []}):
Context.error("Flag " + field.name + " cannot be an Array that isnt a String or Bool or TrimmedString or Int or Float", field.pos);
Context.error("Flag " + field.name + " cannot be an Array that isn't a String or Bool or TrimmedString or Int or Float", field.pos);
case TPath({name: "Map", pack: []}):
Context.error("Flag " + field.name + " cannot be a Map<K, V>", field.pos);
default:
@@ -42,20 +42,9 @@ class FunkinSaveMacro {
/**
* SAVE FUNCTION
*/
var saveFuncBlocks:Array<Expr> = [for(f in fieldNames)
macro ${{
pos: Context.currentPos(),
expr: EConst(CIdent(saveFieldName))
}}.data.$f = ${{
pos: Context.currentPos(),
expr: EConst(CIdent(f))
}}
];
var saveFuncBlocks:Array<Expr> = [for(f in fieldNames) macro $i{saveFieldName}.data.$f = $i{f}];
saveFuncBlocks.push(macro ${{
pos: Context.currentPos(),
expr: EConst(CIdent(saveFieldName))
}}.flush());
saveFuncBlocks.push(macro $i{saveFieldName}.flush());
fields.push({
pos: Context.currentPos(),
@@ -81,16 +70,8 @@ class FunkinSaveMacro {
expr: {
pos: Context.currentPos(),
expr: EBlock([for(f in fieldNames)
macro if (${{
pos: Context.currentPos(),
expr: EConst(CIdent(saveFieldName))
}}.data.$f != null) ${{
pos: Context.currentPos(),
expr: EConst(CIdent(f))
}} = ${{
pos: Context.currentPos(),
expr: EConst(CIdent(saveFieldName))
}}.data.$f
macro if ($i{saveFieldName}.data.$f != null)
$i{f} = $i{saveFieldName}.data.$f
])
}
}),
@@ -8,11 +8,27 @@ class GitCommitMacro {
/**
* Returns the current commit number
*/
public static var commitNumber(get, null):Int;
public static var commitNumber(get, never):Int;
/**
* Returns the current commit hash
*/
public static var commitHash(get, null):String;
public static var commitHash(get, never):String;
/**
* Returns the current commit hash in long format
*/
public static var commitHashLong(get, never):String;
/**
* Returns the current commit message
*/
public static var commitMessage(get, never):String;
/**
* Returns the current commit author
*/
public static var commitAuthor(get, never):String;
/**
* Returns the current commit date + time
**/
public static var commitDate(get, never):Date;
// GETTERS
#if REGION
@@ -21,6 +37,15 @@ class GitCommitMacro {
private static inline function get_commitHash()
return __getCommitHash();
private static inline function get_commitHashLong()
return __getCommitHashLong();
private static inline function get_commitMessage()
return __getCommitMessage();
private static inline function get_commitAuthor()
return __getCommitAuthor();
private static inline function get_commitDate()
return __getCommitDate();
#end
// INTERNAL MACROS
@@ -52,5 +77,77 @@ class GitCommitMacro {
return macro $v{0}
#end
}
private static macro function __getCommitHashLong() {
#if display
return macro $v{"-"};
#else
try {
var proc = new Process('git', ['rev-parse', 'HEAD'], false);
proc.exitCode(true);
return macro $v{proc.stdout.readLine()};
} catch(e) {}
return macro $v{"-"}
#end
}
private static macro function __getCommitMessage() {
#if display
return macro $v{"-"};
#else
try {
var proc = new Process('git', ['log', '-1', '--pretty=%B'], false);
proc.exitCode(true);
var all = proc.stdout.readAll().toString();
while(StringTools.endsWith(all, "\r\n")) all = all.substr(0, all.length - 2);
while(StringTools.endsWith(all, "\n")) all = all.substr(0, all.length - 1);
while(StringTools.endsWith(all, "\r")) all = all.substr(0, all.length - 1);
return macro $v{all};
} catch(e) {}
return macro $v{"-"}
#end
}
private static macro function __getCommitAuthor() {
#if display
return macro $v{"-"};
#else
try {
var proc = new Process('git', ['log', '-1', '--pretty=%an'], false);
proc.exitCode(true);
return macro $v{StringTools.trim(proc.stdout.readLine())};
} catch(e) {}
return macro $v{"-"}
#end
}
private static macro function __getCommitDate() {
#if display
return macro $v{Date.now()};
#else
try {
// get the time in UTC format
var oldTz = Sys.getEnv("TZ");
Sys.putEnv("TZ", "UTC0");
var proc = new Process('git', ['log', "--date='format-local:%Y-%m-%dT%H:%M:%SZ'", '-1', '--pretty=%cd'], false);
proc.exitCode(true);
Sys.putEnv("TZ", oldTz);
var rawDate = StringTools.trim(proc.stdout.readLine());
try {
Date.fromString(rawDate);
} catch(e) {
throw 'Invalid date format: $rawDate';
}
return macro Date.fromString($v{rawDate});
} catch(e) {}
return macro Date.fromString("1970-01-01T00:00:00"); // failed to parse date
#end
}
#end
}
@@ -24,14 +24,8 @@ class OptionsMacro {
var ptwoname = 'P2_$name';
var newFuncExpr:Expr = macro {
var a:Array<FlxKey> = [];
for(e in ${{
pos: Context.currentPos(),
expr: EConst(CIdent(ponename))
}}) a.push(e);
for(e in ${{
pos: Context.currentPos(),
expr: EConst(CIdent(ptwoname))
}}) a.push(e);
for(e in $i{ponename}) a.push(e);
for(e in $i{ptwoname}) a.push(e);
return a;
};
@@ -6,7 +6,7 @@ import funkin.backend.utils.NativeAPI;
import lime.media.AudioManager;
/**
* if youre stealing this keep this comment at least please lol
* if you are stealing this keep this comment at least please lol
*
* hi gray itsa me yoshicrafter29 i fixed it hehe
*/