Merge branch 'new-editors' of https://github.com/FNF-CNE-Devs/CodenameEngine-Dev into new-editors
This commit is contained in:
@@ -81,7 +81,8 @@ class GlobalScript {
|
||||
call("update", [FlxG.elapsed]);
|
||||
});
|
||||
|
||||
onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
|
||||
// Commented this out, because it might be the cause why global runs twice - Neo
|
||||
//onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
|
||||
}
|
||||
|
||||
public static function event<T:CancellableEvent>(name:String, event:T):T {
|
||||
|
||||
@@ -151,7 +151,7 @@ class Script extends FlxBasic implements IFlxDestroyable {
|
||||
public static function getDefaultPreprocessors():Map<String, Dynamic> {
|
||||
var defines = funkin.backend.system.macros.DefinesMacro.defines;
|
||||
defines.set("CODENAME_ENGINE", true);
|
||||
defines.set("CODENAME_VER", Application.current.meta.get('version'));
|
||||
defines.set("CODENAME_VER", Flags.VERSION);
|
||||
defines.set("CODENAME_BUILD", 2675); // 2675 being the last build num before it was removed
|
||||
defines.set("CODENAME_COMMIT", Flags.COMMIT_NUMBER);
|
||||
return defines;
|
||||
|
||||
@@ -19,7 +19,8 @@ class CustomShader extends FunkinShader {
|
||||
* @param name Name of the frag and vert files.
|
||||
* @param glslVersion GLSL version to use. Defaults to `120`.
|
||||
*/
|
||||
public function new(name:String, glslVersion:String = "120") {
|
||||
public function new(name:String, glslVersion:String = null) {
|
||||
if (glslVersion == null) glslVersion = Flags.DEFAULT_GLSL_VERSION;
|
||||
var fragShaderPath = Paths.fragShader(name);
|
||||
var vertShaderPath = Paths.vertShader(name);
|
||||
var fragCode = Assets.exists(fragShaderPath) ? Assets.getText(fragShaderPath) : null;
|
||||
|
||||
@@ -26,7 +26,7 @@ class FunkinShader extends FlxShader implements IHScriptCustomBehaviour {
|
||||
public var onGLUpdate:FlxTypedSignal<Void->Void> = new FlxTypedSignal<Void->Void>();
|
||||
public var onProcessGLData:FlxTypedSignal<(String, String)->Void> = new FlxTypedSignal<(String, String)->Void>();
|
||||
|
||||
public var glslVer:String = "120";
|
||||
public var glslVer:String = Flags.DEFAULT_GLSL_VERSION;
|
||||
public var fileName:String = "FunkinShader";
|
||||
public var fragFileName:String = "FunkinShader";
|
||||
public var vertFileName:String = "FunkinShader";
|
||||
@@ -42,7 +42,8 @@ class FunkinShader extends FlxShader implements IHScriptCustomBehaviour {
|
||||
* @param vert Vertex source (pass `null` to use default)
|
||||
* @param glslVer Version of GLSL to use (defaults to 120)
|
||||
*/
|
||||
public override function new(frag:String, vert:String, glslVer:String = "120") {
|
||||
public override function new(frag:String, vert:String, glslVer:String = null) {
|
||||
if (glslVer == null) glslVer = Flags.DEFAULT_GLSL_VERSION;
|
||||
if (frag == null) frag = ShaderTemplates.defaultFragmentSource;
|
||||
if (vert == null) vert = ShaderTemplates.defaultVertexSource;
|
||||
this.glFragmentSource = frag;
|
||||
|
||||
@@ -64,6 +64,8 @@ final class CommandLineHandler {
|
||||
Main.noCwdFix = true;
|
||||
case "-livereload":
|
||||
// do nothing
|
||||
case "-verbose":
|
||||
// do nothing
|
||||
default:
|
||||
Sys.println("Unknown command");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package funkin.backend.system;
|
||||
|
||||
import lime.utils.AssetLibrary;
|
||||
import lime.utils.AssetLibrary as LimeAssetLibrary;
|
||||
import lime.utils.AssetType;
|
||||
import flixel.util.FlxColor;
|
||||
|
||||
@@ -18,7 +18,11 @@ class Flags {
|
||||
public static var COMMIT_NUMBER:Int = GitCommitMacro.commitNumber;
|
||||
public static var COMMIT_HASH:String = GitCommitMacro.commitHash;
|
||||
public static var COMMIT_MESSAGE:String = 'Commit $COMMIT_NUMBER ($COMMIT_HASH)';
|
||||
@:lazy public static var VERSION_MESSAGE:String = 'Codename Engine v${Application.current.meta.get('version')}';
|
||||
|
||||
@:lazy public static var TITLE:String = Application.current.meta.get('name');
|
||||
@:lazy public static var VERSION:String = Application.current.meta.get('version');
|
||||
|
||||
@:lazy public static var VERSION_MESSAGE:String = 'Codename Engine v$VERSION';
|
||||
|
||||
public static var REPO_NAME:String = "CodenameEngine";
|
||||
public static var REPO_OWNER:String = "CodenameCrew";
|
||||
@@ -142,6 +146,14 @@ class Flags {
|
||||
public static var DEFAULT_PAUSE_SCRIPT:String = "";
|
||||
@:also(funkin.game.GameOverSubstate.script)
|
||||
public static var DEFAULT_GAMEOVER_SCRIPT:String = "";
|
||||
|
||||
public static var URL_WIKI:String = "https://codename-engine.com/";
|
||||
public static var URL_EDITOR_FALLBACK:String = "https://www.youtube.com/watch?v=9Youam7GYdQ";
|
||||
public static var URL_FNF_ITCH:String = "https://ninja-muffin24.itch.io/funkin";
|
||||
|
||||
public static var DEFAULT_GLSL_VERSION:String = "120";
|
||||
@:also(funkin.backend.utils.HttpUtil.userAgent)
|
||||
public static var USER_AGENT:String = 'request';
|
||||
// -- End of Codename's Default Flags --
|
||||
|
||||
/**
|
||||
@@ -149,45 +161,64 @@ class Flags {
|
||||
*/
|
||||
@:bypass public static var customFlags:Map<String, String> = [];
|
||||
|
||||
public static function load() {
|
||||
var flags:Map<String, String> = [];
|
||||
public static function loadFromData(flags:Map<String, String>, data:String) {
|
||||
var trimmed:String;
|
||||
var splitContent = [for(e in data.split("\n")) if ((trimmed = e.trim()) != "") trimmed];
|
||||
|
||||
final flagsPath = Paths.getPath("flags.ini");
|
||||
for(line in splitContent) {
|
||||
if(line.startsWith(";")) continue;
|
||||
if(line.startsWith("#")) continue;
|
||||
if(line.startsWith("//")) continue;
|
||||
if(line.length == 0) continue;
|
||||
if(line.charAt(0) == "[" && line.charAt(line.length-1) == "]") continue;
|
||||
|
||||
for(lib in Paths.assetsTree.libraries) {
|
||||
if(lib.exists(flagsPath, AssetType.TEXT)) {
|
||||
var data:String = lib.getAsset(flagsPath, AssetType.TEXT);
|
||||
var trimmed:String;
|
||||
var splitContent = [for(e in data.split("\n")) if ((trimmed = e.trim()) != "") trimmed];
|
||||
var index = line.indexOf("=");
|
||||
if(index == -1) continue;
|
||||
var name = line.substr(0, index).trim();
|
||||
var value = line.substr(index+1).trim();
|
||||
|
||||
for(line in splitContent) {
|
||||
if(line.startsWith(";")) continue;
|
||||
if(line.startsWith("#")) continue;
|
||||
if(line.startsWith("//")) continue;
|
||||
if(line.length == 0) continue;
|
||||
if(line.charAt(0) == "[" && line.charAt(line.length-1) == "]") continue;
|
||||
var wasQuoted = value.length > 1 && value.charCodeAt(0) == '"'.code && value.charCodeAt(value.length-1) == '"'.code;
|
||||
if(wasQuoted) value = value.substr(1, value.length - 2);
|
||||
if((!wasQuoted && value.length == 0) || name.length == 0)
|
||||
continue;
|
||||
|
||||
var index = line.indexOf("=");
|
||||
if(index == -1) continue;
|
||||
var name = line.substr(0, index).trim();
|
||||
var value = line.substr(index+1).trim();
|
||||
|
||||
var wasQuoted = value.length > 1 && value.charCodeAt(0) == '"'.code && value.charCodeAt(value.length-1) == '"'.code;
|
||||
if(wasQuoted) value = value.substr(1, value.length - 2);
|
||||
if((!wasQuoted && value.length == 0) || name.length == 0)
|
||||
continue;
|
||||
|
||||
if(!flags.exists(name))
|
||||
flags[name] = value;
|
||||
}
|
||||
}
|
||||
if(!flags.exists(name))
|
||||
flags[name] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static function loadFromDatas(files:Array<String>) {
|
||||
var flags:Map<String, String> = [];
|
||||
for(file in files) {
|
||||
var data:String = Assets.getText(file);
|
||||
if(data != null)
|
||||
loadFromData(flags, data);
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
public static function parseFlags(flags:Map<String, String>) {
|
||||
customFlags = [];
|
||||
reset();
|
||||
for(name=>value in flags)
|
||||
if(!parse(name, value)) {
|
||||
if(!parse(name, value))
|
||||
customFlags.set(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the flags from the assets.
|
||||
**/
|
||||
public static function load(?libs:Array<LimeAssetLibrary> = null) {
|
||||
if (libs == null)
|
||||
libs = Paths.assetsTree.libraries;
|
||||
final flagsPath = Paths.getPath("flags.ini");
|
||||
var datas:Array<String> = [
|
||||
for(lib in libs)
|
||||
if(lib.exists(flagsPath, AssetType.TEXT))
|
||||
lib.getAsset(flagsPath, AssetType.TEXT)
|
||||
];
|
||||
|
||||
var flags:Map<String, String> = loadFromDatas(datas);
|
||||
parseFlags(flags);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ final class Logs {
|
||||
);
|
||||
}
|
||||
}
|
||||
__showInConsole(prepareColoredTrace(data, TRACE));
|
||||
traceColored(data, TRACE);
|
||||
};
|
||||
|
||||
LogFrontEnd.onLogs = function(data, style, fireOnce) {
|
||||
@@ -134,16 +134,33 @@ final class Logs {
|
||||
#end
|
||||
}
|
||||
|
||||
public static function traceColored(text:Array<LogText>, level:Level = INFO)
|
||||
public inline static function traceColored(text:Array<LogText>, level:Level = INFO)
|
||||
__showInConsole(prepareColoredTrace(text, level));
|
||||
|
||||
public static function trace(text:String, level:Level = INFO, color:ConsoleColor = LIGHTGRAY) {
|
||||
traceColored([
|
||||
{
|
||||
text: text,
|
||||
color: color
|
||||
}
|
||||
], 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));
|
||||
traceColored(text, level);
|
||||
}
|
||||
|
||||
public inline static function getPrefix(prefix:String) {
|
||||
return logText('[${prefix}] ', BLUE);
|
||||
}
|
||||
|
||||
public inline static function infos(text:String, color:ConsoleColor = LIGHTGRAY, ?prefix:String) {
|
||||
Logs.trace(text, INFO, color, prefix);
|
||||
}
|
||||
|
||||
public inline static function verbose(text:String, color:ConsoleColor = LIGHTGRAY, ?prefix:String) {
|
||||
Logs.trace(text, VERBOSE, color, prefix);
|
||||
}
|
||||
|
||||
public inline static function warn(text:String, color:ConsoleColor = YELLOW, ?prefix:String) {
|
||||
Logs.trace(text, WARNING, color, prefix);
|
||||
}
|
||||
|
||||
public inline static function error(text:String, color:ConsoleColor = RED, ?prefix:String) {
|
||||
Logs.trace(text, ERROR, color, prefix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -179,8 +179,6 @@ class Main extends Sprite
|
||||
}
|
||||
|
||||
public static function refreshAssets() @:privateAccess {
|
||||
WindowUtils.resetTitle();
|
||||
|
||||
var game = FlxG.game;
|
||||
var daSndTray = Type.createInstance(game._customSoundTray = funkin.menus.ui.FunkinSoundTray, []);
|
||||
var index:Int = game.numChildren - 1;
|
||||
|
||||
@@ -60,6 +60,7 @@ class MainState extends FlxState {
|
||||
Flags.load();
|
||||
ModsFolder.onModSwitch.dispatch(ModsFolder.currentModFolder); // Loads global.hx
|
||||
MusicBeatTransition.script = Flags.DEFAULT_TRANSITION_SCRIPT;
|
||||
WindowUtils.resetTitle();
|
||||
Main.refreshAssets();
|
||||
DiscordUtil.init();
|
||||
EventsData.reloadEvents();
|
||||
|
||||
@@ -21,7 +21,7 @@ class MemoryCounter extends Sprite {
|
||||
label.autoSize = LEFT;
|
||||
label.x = 0;
|
||||
label.y = 0;
|
||||
label.text = "FPS";
|
||||
label.text = "MEM";
|
||||
label.multiline = label.wordWrap = false;
|
||||
label.defaultTextFormat = new TextFormat(Framerate.fontName, 12, -1);
|
||||
label.selectable = false;
|
||||
|
||||
@@ -92,10 +92,7 @@ class FlagMacro {
|
||||
case macro: Array<Float>:
|
||||
parser = macro value.split(",").map((e) -> Std.parseFloat(e));
|
||||
case macro: Array<Bool>:
|
||||
parser = macro value.split(",").map((e) -> {
|
||||
e = e.trim();
|
||||
e == "true" || e == "t" || e == "1";
|
||||
});
|
||||
parser = macro value.split(",").map(parseBool);
|
||||
case macro: TrimmedString:
|
||||
field.kind = FVar(macro: String, expr);
|
||||
parser = macro value.trim();
|
||||
@@ -106,7 +103,7 @@ class FlagMacro {
|
||||
case macro: Float:
|
||||
parser = macro Std.parseFloat(value);
|
||||
case macro: Bool:
|
||||
parser = macro value == "true" || value == "t" || value == "1";
|
||||
parser = macro parseBool(value);
|
||||
case TPath({name: "Allow", pack: [], params: params}):
|
||||
final NONE = 0;
|
||||
final STRING = 1;
|
||||
@@ -276,6 +273,22 @@ class FlagMacro {
|
||||
meta: []
|
||||
});
|
||||
|
||||
fields.push({
|
||||
name: "parseBool",
|
||||
access: [APrivate, AStatic],
|
||||
kind: FFun({
|
||||
args: [{name: "e", type: macro: String}],
|
||||
expr: macro {
|
||||
e = e.trim();
|
||||
return e == "true" || e == "t" || e == "1";
|
||||
},
|
||||
ret: macro: Bool
|
||||
}),
|
||||
pos: Context.currentPos(),
|
||||
doc: null,
|
||||
meta: []
|
||||
});
|
||||
|
||||
//var printer = new haxe.macro.Printer();
|
||||
//for(field in fields) {
|
||||
// trace(printer.printField(field));
|
||||
|
||||
@@ -29,6 +29,14 @@ class GitCommitMacro {
|
||||
* Returns the current commit date + time
|
||||
**/
|
||||
public static var commitDate(get, never):Date;
|
||||
/**
|
||||
* Returns the current branch name
|
||||
**/
|
||||
public static var currentBranch(get, never):String;
|
||||
/**
|
||||
* Returns if there are uncommitted changes
|
||||
**/
|
||||
public static var hasUncommittedChanges(get, never):Bool;
|
||||
|
||||
// GETTERS
|
||||
#if REGION
|
||||
@@ -46,6 +54,11 @@ class GitCommitMacro {
|
||||
return __getCommitAuthor();
|
||||
private static inline function get_commitDate()
|
||||
return __getCommitDate();
|
||||
|
||||
private static inline function get_currentBranch()
|
||||
return __getCurrentBranch();
|
||||
private static inline function get_hasUncommittedChanges()
|
||||
return __getHasUncommittedChanges();
|
||||
#end
|
||||
|
||||
// INTERNAL MACROS
|
||||
@@ -149,5 +162,35 @@ class GitCommitMacro {
|
||||
return macro Date.fromString("1970-01-01T00:00:00"); // failed to parse date
|
||||
#end
|
||||
}
|
||||
|
||||
private static macro function __getCurrentBranch() {
|
||||
#if display
|
||||
return macro $v{"-"};
|
||||
#else
|
||||
try {
|
||||
var process = new Process("git", ["rev-parse", "--abbrev-ref", "HEAD"], false);
|
||||
if (process.exitCode() != 0)
|
||||
throw 'Could not fetch current branch';
|
||||
|
||||
return macro $v{process.stdout.readLine().toString()};
|
||||
} catch(e) {}
|
||||
return macro $v{"-"}
|
||||
#end
|
||||
}
|
||||
|
||||
private static macro function __getHasUncommittedChanges() {
|
||||
#if display
|
||||
return macro $v{false};
|
||||
#else
|
||||
try {
|
||||
var process = new Process("git", ["status", "--porcelain"], false);
|
||||
if (process.exitCode() != 0)
|
||||
throw 'Could not fetch current branch';
|
||||
|
||||
return macro $v{process.stdout.readLine().toString() != ""};
|
||||
} catch(e) {}
|
||||
return macro $v{false}
|
||||
#end
|
||||
}
|
||||
#end
|
||||
}
|
||||
@@ -151,7 +151,4 @@ class HashLinkFixer {
|
||||
return fields;
|
||||
}
|
||||
}
|
||||
#else
|
||||
class HashLinkFixer {
|
||||
}
|
||||
#end
|
||||
@@ -9,9 +9,6 @@ import sys.FileSystem;
|
||||
using funkin.backend.system.github.GitHub;
|
||||
|
||||
class UpdateUtil {
|
||||
public static final repoOwner:String = "YoshiCrafter29";
|
||||
public static final repoName:String = "CodenameTestRepo";
|
||||
|
||||
public static function init() {
|
||||
// deletes old bak file if it exists
|
||||
#if sys
|
||||
@@ -22,12 +19,12 @@ class UpdateUtil {
|
||||
}
|
||||
|
||||
public static function checkForUpdates():UpdateCheckCallback {
|
||||
var curTag = 'v${Application.current.meta.get('version')}';
|
||||
var curTag = 'v${Flags.VERSION}';
|
||||
trace(curTag);
|
||||
|
||||
var error = false;
|
||||
|
||||
var newUpdates = __doReleaseFiltering(GitHub.getReleases(repoOwner, repoName, function(e) {
|
||||
var newUpdates = __doReleaseFiltering(GitHub.getReleases(Flags.REPO_NAME, Flags.REPO_OWNER, function(e) {
|
||||
error = true;
|
||||
}), curTag);
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ final class DiscordUtil
|
||||
user = DUser.initRaw(request);
|
||||
|
||||
Logs.traceColored([
|
||||
Logs.logText("[Discord] ", BLUE),
|
||||
Logs.getPrefix("Discord"),
|
||||
Logs.logText("Connected to User " + user.globalName + " ("),
|
||||
Logs.logText(user.handle, GRAY),
|
||||
Logs.logText(")")
|
||||
@@ -321,7 +321,7 @@ final class DiscordUtil
|
||||
var finalMsg:String = cast(message, String);
|
||||
|
||||
Logs.traceColored([
|
||||
Logs.logText("[Discord] ", BLUE),
|
||||
Logs.getPrefix("Discord"),
|
||||
Logs.logText("Disconnected ("),
|
||||
Logs.logText('$errorCode: $finalMsg', RED),
|
||||
Logs.logText(")")
|
||||
@@ -335,7 +335,7 @@ final class DiscordUtil
|
||||
var finalMsg:String = cast(message, String);
|
||||
|
||||
Logs.traceColored([
|
||||
Logs.logText("[Discord] ", BLUE),
|
||||
Logs.getPrefix("Discord"),
|
||||
Logs.logText('Error ($errorCode: $finalMsg)', RED)
|
||||
], ERROR);
|
||||
|
||||
@@ -344,7 +344,7 @@ final class DiscordUtil
|
||||
|
||||
private static function onJoin(joinSecret:cpp.ConstCharStar):Void
|
||||
{
|
||||
Logs.traceColored([Logs.logText("[Discord] ", BLUE), Logs.logText("Someone has just joined", GREEN)], INFO);
|
||||
Logs.traceColored([Logs.getPrefix("Discord"), Logs.logText("Someone has just joined", GREEN)], INFO);
|
||||
|
||||
call("onJoinGame", [cast(joinSecret, String)]);
|
||||
}
|
||||
@@ -352,7 +352,7 @@ final class DiscordUtil
|
||||
private static function onSpectate(spectateSecret:cpp.ConstCharStar):Void
|
||||
{
|
||||
Logs.traceColored([
|
||||
Logs.logText("[Discord] ", BLUE),
|
||||
Logs.getPrefix("Discord"),
|
||||
Logs.logText("Someone started spectating your game", YELLOW)
|
||||
], INFO);
|
||||
|
||||
@@ -362,7 +362,7 @@ final class DiscordUtil
|
||||
private static function onJoinReq(request:cpp.RawConstPointer<DiscordUser>):Void
|
||||
{
|
||||
Logs.traceColored([
|
||||
Logs.logText("[Discord] ", BLUE),
|
||||
Logs.getPrefix("Discord"),
|
||||
Logs.logText("Someone has just requested to join", YELLOW)
|
||||
], WARNING);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import haxe.Http;
|
||||
|
||||
final class HttpUtil
|
||||
{
|
||||
public static var userAgent:String = "request";
|
||||
public static var userAgent:String = Flags.USER_AGENT;
|
||||
public static function requestText(url:String)
|
||||
{
|
||||
var r = null;
|
||||
|
||||
@@ -45,7 +45,7 @@ final class WindowUtils {
|
||||
* Resets the window title to the application name and resets the prefix and suffix.
|
||||
**/
|
||||
public static inline function resetTitle() {
|
||||
title = Lib.application.meta["name"];
|
||||
title = Flags.TITLE == null ? Lib.application.meta.get('name') : Flags.TITLE;
|
||||
resetAffixes();
|
||||
}
|
||||
|
||||
@@ -65,18 +65,18 @@ final class WindowUtils {
|
||||
|
||||
// backwards compat
|
||||
@:noCompletion public static var endfix(get, set):String;
|
||||
@:noCompletion private static function set_endfix(value:String):String {
|
||||
@:noCompletion private inline static function set_endfix(value:String):String {
|
||||
return suffix = value;
|
||||
}
|
||||
@:noCompletion private static function get_endfix():String {
|
||||
@:noCompletion private inline static function get_endfix():String {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
@:noCompletion public static var winTitle(get, set):String;
|
||||
@:noCompletion private static function get_winTitle():String {
|
||||
@:noCompletion private inline static function get_winTitle():String {
|
||||
return title;
|
||||
}
|
||||
@:noCompletion private static function set_winTitle(value:String):String {
|
||||
@:noCompletion private inline static function set_winTitle(value:String):String {
|
||||
return title = value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user