FUCK SPACES!!!! TABS RULES!!! 💪💪💪💪

This commit is contained in:
Yoshman29
2023-03-25 22:53:47 +01:00
parent c259385f2a
commit a63e5f5958
135 changed files with 6799 additions and 6799 deletions
+10 -10
View File
@@ -4,15 +4,15 @@ package funkin.scripting;
* Simple class for empty scripts or scripts whose language isn't imported yet.
*/
class DummyScript extends Script {
public var variables:Map<String, Dynamic> = [];
public override function get(v:String) {return variables.get(v);}
public override function set(v:String, v2:Dynamic) {return variables.set(v, v2);}
public override function onCall(method:String, parameters:Array<Dynamic>):Dynamic {
var func = variables.get(method);
if (Reflect.isFunction(func))
return (parameters != null && parameters.length > 0) ? Reflect.callMethod(null, func, parameters) : func();
public var variables:Map<String, Dynamic> = [];
public override function get(v:String) {return variables.get(v);}
public override function set(v:String, v2:Dynamic) {return variables.set(v, v2);}
public override function onCall(method:String, parameters:Array<Dynamic>):Dynamic {
var func = variables.get(method);
if (Reflect.isFunction(func))
return (parameters != null && parameters.length > 0) ? Reflect.callMethod(null, func, parameters) : func();
return null;
}
return null;
}
}
+23 -23
View File
@@ -4,35 +4,35 @@ import flixel.FlxState;
import funkin.scripting.events.*;
class EventManager {
// map doesnt work for that
public static var eventValues:Array<CancellableEvent> = [];
public static var eventKeys:Array<Class<CancellableEvent>> = [];
// map doesnt work for that
public static var eventValues:Array<CancellableEvent> = [];
public static var eventKeys:Array<Class<CancellableEvent>> = [];
public static function get<T:CancellableEvent>(cl:Class<T>):T {
var c:Class<CancellableEvent> = cast cl;
public static function get<T:CancellableEvent>(cl:Class<T>):T {
var c:Class<CancellableEvent> = cast cl;
var index = eventKeys.indexOf(c);
if (index < 0) {
eventKeys.push(c);
eventValues.push(Type.createInstance(c, []));
return cast eventValues.last();
}
var index = eventKeys.indexOf(c);
if (index < 0) {
eventKeys.push(c);
eventValues.push(Type.createInstance(c, []));
return cast eventValues.last();
}
return cast eventValues[index];
}
return cast eventValues[index];
}
public static function reset() {
for(v in eventValues)
v.destroy();
eventValues = [];
eventKeys = [];
}
public static function reset() {
for(v in eventValues)
v.destroy();
eventValues = [];
eventKeys = [];
}
public static function init() {
public static function init() {
FlxG.signals.preStateCreate.add(onStateSwitch);
}
}
private static inline function onStateSwitch(newState:FlxState)
reset();
private static inline function onStateSwitch(newState:FlxState)
reset();
}
+91 -91
View File
@@ -9,103 +9,103 @@ import funkin.mods.ModsFolder;
* Class for THE Global Script, aka script that runs in the background at all times.
*/
class GlobalScript {
public static var script:Script;
public static var script:Script;
public static function init() {
#if MOD_SUPPORT
ModsFolder.onModSwitch.add(onModSwitch);
#end
public static function init() {
#if MOD_SUPPORT
ModsFolder.onModSwitch.add(onModSwitch);
#end
Conductor.onBeatHit.add(beatHit);
Conductor.onStepHit.add(stepHit);
FlxG.signals.focusGained.add(function() {
call("focusGained");
});
FlxG.signals.focusLost.add(function() {
call("focusLost");
});
FlxG.signals.gameResized.add(function(w:Int, h:Int) {
call("gameResized", [w, h]);
});
FlxG.signals.postDraw.add(function() {
call("postDraw");
});
FlxG.signals.postGameReset.add(function() {
call("postGameReset");
});
FlxG.signals.postGameStart.add(function() {
call("postGameStart");
});
FlxG.signals.postStateSwitch.add(function() {
call("postStateSwitch");
});
FlxG.signals.postUpdate.add(function() {
call("postUpdate", [FlxG.elapsed]);
if (FlxG.keys.justPressed.F5) {
if (script != null && !(script is DummyScript)) {
Logs.trace('Reloading global script...', WARNING, YELLOW);
script.reload();
Logs.trace('Global script successfully reloaded.', WARNING, GREEN);
} else {
Logs.trace('Loading global script...', WARNING, YELLOW);
onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
if (script is DummyScript)
Logs.trace('Global script not found. Are you sure "data/global.hx" exists?', ERROR, RED);
else
Logs.trace('Global script successfully loaded.', WARNING, GREEN);
}
}
});
FlxG.signals.preDraw.add(function() {
call("preDraw");
});
FlxG.signals.preGameReset.add(function() {
call("preGameReset");
});
FlxG.signals.preGameStart.add(function() {
call("preGameStart");
});
FlxG.signals.preStateCreate.add(function(state:FlxState) {
call("preStateCreate", [state]);
});
FlxG.signals.preStateSwitch.add(function() {
call("preStateSwitch", []);
});
FlxG.signals.preUpdate.add(function() {
call("preUpdate", [FlxG.elapsed]);
call("update", [FlxG.elapsed]);
});
Conductor.onBeatHit.add(beatHit);
Conductor.onStepHit.add(stepHit);
FlxG.signals.focusGained.add(function() {
call("focusGained");
});
FlxG.signals.focusLost.add(function() {
call("focusLost");
});
FlxG.signals.gameResized.add(function(w:Int, h:Int) {
call("gameResized", [w, h]);
});
FlxG.signals.postDraw.add(function() {
call("postDraw");
});
FlxG.signals.postGameReset.add(function() {
call("postGameReset");
});
FlxG.signals.postGameStart.add(function() {
call("postGameStart");
});
FlxG.signals.postStateSwitch.add(function() {
call("postStateSwitch");
});
FlxG.signals.postUpdate.add(function() {
call("postUpdate", [FlxG.elapsed]);
if (FlxG.keys.justPressed.F5) {
if (script != null && !(script is DummyScript)) {
Logs.trace('Reloading global script...', WARNING, YELLOW);
script.reload();
Logs.trace('Global script successfully reloaded.', WARNING, GREEN);
} else {
Logs.trace('Loading global script...', WARNING, YELLOW);
onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
if (script is DummyScript)
Logs.trace('Global script not found. Are you sure "data/global.hx" exists?', ERROR, RED);
else
Logs.trace('Global script successfully loaded.', WARNING, GREEN);
}
}
});
FlxG.signals.preDraw.add(function() {
call("preDraw");
});
FlxG.signals.preGameReset.add(function() {
call("preGameReset");
});
FlxG.signals.preGameStart.add(function() {
call("preGameStart");
});
FlxG.signals.preStateCreate.add(function(state:FlxState) {
call("preStateCreate", [state]);
});
FlxG.signals.preStateSwitch.add(function() {
call("preStateSwitch", []);
});
FlxG.signals.preUpdate.add(function() {
call("preUpdate", [FlxG.elapsed]);
call("update", [FlxG.elapsed]);
});
onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
}
onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
}
public static function event<T:CancellableEvent>(name:String, event:T):T {
if (script == null) return event;
script.call(name, [event]);
return event;
}
public static function event<T:CancellableEvent>(name:String, event:T):T {
if (script == null) return event;
script.call(name, [event]);
return event;
}
public static function call(name:String, ?args:Array<Dynamic>) {
if (script == null) return;
script.call(name, args);
}
public static function onModSwitch(newMod:String) {
call("onDestroy");
if (script != null) {
script.destroy();
script = null;
}
script = Script.create(Paths.script('data/global'));
script.load();
}
public static function call(name:String, ?args:Array<Dynamic>) {
if (script == null) return;
script.call(name, args);
}
public static function onModSwitch(newMod:String) {
call("onDestroy");
if (script != null) {
script.destroy();
script = null;
}
script = Script.create(Paths.script('data/global'));
script.load();
}
public static function beatHit(curBeat:Int) {
call("beatHit", [curBeat]);
}
public static function beatHit(curBeat:Int) {
call("beatHit", [curBeat]);
}
public static function stepHit(curStep:Int) {
call("stepHit", [curStep]);
}
public static function stepHit(curStep:Int) {
call("stepHit", [curStep]);
}
}
#end
+86 -86
View File
@@ -5,112 +5,112 @@ import openfl.Assets;
import hscript.*;
class HScript extends Script {
public var interp:Interp;
public var expr:Expr;
public var interp:Interp;
public var expr:Expr;
public override function onCreate(path:String) {
super.onCreate(path);
public override function onCreate(path:String) {
super.onCreate(path);
interp = new Interp();
interp = new Interp();
var code:String = Assets.getText(path);
var parser = new hscript.Parser();
parser.allowJSON = parser.allowMetadata = parser.allowTypes = true;
parser.preprocesorValues = Script.getDefaultPreprocessors();
interp.errorHandler = _errorHandler;
interp.staticVariables = Script.staticVariables;
interp.allowStaticVariables = interp.allowPublicVariables = true;
var code:String = Assets.getText(path);
var parser = new hscript.Parser();
parser.allowJSON = parser.allowMetadata = parser.allowTypes = true;
parser.preprocesorValues = Script.getDefaultPreprocessors();
interp.errorHandler = _errorHandler;
interp.staticVariables = Script.staticVariables;
interp.allowStaticVariables = interp.allowPublicVariables = true;
interp.variables.set("trace", Reflect.makeVarArgs((args) -> {
var v:String = Std.string(args.shift());
for (a in args) v += ", " + Std.string(a);
this.trace(v);
}));
interp.variables.set("trace", Reflect.makeVarArgs((args) -> {
var v:String = Std.string(args.shift());
for (a in args) v += ", " + Std.string(a);
this.trace(v);
}));
try {
expr = parser.parseString(code, fileName);
} catch(e:Error) {
_errorHandler(e);
} catch(e) {
_errorHandler(new Error(ECustom(e.toString()), 0, 0, fileName, 0));
}
}
try {
expr = parser.parseString(code, fileName);
} catch(e:Error) {
_errorHandler(e);
} catch(e) {
_errorHandler(new Error(ECustom(e.toString()), 0, 0, fileName, 0));
}
}
private function _errorHandler(error:Error) {
private function _errorHandler(error:Error) {
var fn = '$fileName:${error.line}: ';
var err = error.toString();
if (err.startsWith(fn)) err = err.substr(fn.length);
var fn = '$fileName:${error.line}: ';
var err = error.toString();
if (err.startsWith(fn)) err = err.substr(fn.length);
Logs.traceColored([
Logs.logText(fn, GREEN),
Logs.logText(err, RED)
], ERROR);
}
Logs.traceColored([
Logs.logText(fn, GREEN),
Logs.logText(err, RED)
], ERROR);
}
public override function setParent(parent:Dynamic) {
interp.scriptObject = parent;
}
public override function setParent(parent:Dynamic) {
interp.scriptObject = parent;
}
public override function onLoad() {
if (expr != null) {
interp.execute(expr);
call("new", []);
}
}
public override function onLoad() {
if (expr != null) {
interp.execute(expr);
call("new", []);
}
}
public override function reload() {
// save variables
interp.allowStaticVariables = interp.allowPublicVariables = false;
var savedVariables:Map<String, Dynamic> = [];
for(k=>e in interp.variables) {
if (!Reflect.isFunction(e)) {
savedVariables[k] = e;
}
}
var oldParent = interp.scriptObject;
onCreate(path);
public override function reload() {
// save variables
interp.allowStaticVariables = interp.allowPublicVariables = false;
var savedVariables:Map<String, Dynamic> = [];
for(k=>e in interp.variables) {
if (!Reflect.isFunction(e)) {
savedVariables[k] = e;
}
}
var oldParent = interp.scriptObject;
onCreate(path);
for(k=>e in Script.getDefaultVariables(this))
set(k, e);
for(k=>e in Script.getDefaultVariables(this))
set(k, e);
load();
setParent(oldParent);
load();
setParent(oldParent);
for(k=>e in savedVariables)
interp.variables.set(k, e);
for(k=>e in savedVariables)
interp.variables.set(k, e);
interp.allowStaticVariables = interp.allowPublicVariables = true;
}
interp.allowStaticVariables = interp.allowPublicVariables = true;
}
private override function onCall(funcName:String, parameters:Array<Dynamic>):Dynamic {
if (interp == null) return null;
private override function onCall(funcName:String, parameters:Array<Dynamic>):Dynamic {
if (interp == null) return null;
var func = interp.variables.get(funcName);
if (func != null && Reflect.isFunction(func))
return (parameters != null && parameters.length > 0) ? Reflect.callMethod(null, func, parameters) : func();
var func = interp.variables.get(funcName);
if (func != null && Reflect.isFunction(func))
return (parameters != null && parameters.length > 0) ? Reflect.callMethod(null, func, parameters) : func();
return null;
}
return null;
}
public override function get(val:String):Dynamic {
return interp.variables.get(val);
}
public override function get(val:String):Dynamic {
return interp.variables.get(val);
}
public override function set(val:String, value:Dynamic) {
interp.variables.set(val, value);
}
public override function set(val:String, value:Dynamic) {
interp.variables.set(val, value);
}
public override function trace(v:Dynamic) {
var posInfo = interp.posInfos();
Logs.traceColored([
Logs.logText('${fileName}:${posInfo.lineNumber}: ', GREEN),
Logs.logText(Std.isOfType(v, String) ? v : Std.string(v))
], TRACE);
}
public override function trace(v:Dynamic) {
var posInfo = interp.posInfos();
Logs.traceColored([
Logs.logText('${fileName}:${posInfo.lineNumber}: ', GREEN),
Logs.logText(Std.isOfType(v, String) ? v : Std.string(v))
], TRACE);
}
public override function setPublicMap(map:Map<String, Dynamic>) {
this.interp.publicVariables = map;
}
public override function setPublicMap(map:Map<String, Dynamic>) {
this.interp.publicVariables = map;
}
}
+3 -3
View File
@@ -1,7 +1,7 @@
package funkin.scripting;
class ModState extends MusicBeatState {
public function new(stateName:String) {
super(true, stateName);
}
public function new(stateName:String) {
super(true, stateName);
}
}
+3 -3
View File
@@ -1,7 +1,7 @@
package funkin.scripting;
class ModSubState extends MusicBeatSubstate {
public function new(scriptName:String) {
super(true, scriptName);
}
public function new(scriptName:String) {
super(true, scriptName);
}
}
+69 -69
View File
@@ -8,91 +8,91 @@ import hscript.IHScriptCustomBehaviour;
import flixel.util.FlxDestroyUtil;
class MultiThreadedScript implements IFlxDestroyable implements IHScriptCustomBehaviour {
var thread:#if ALLOW_MULTITHREADING Thread #else Dynamic #end;
var thread:#if ALLOW_MULTITHREADING Thread #else Dynamic #end;
/**
* Script being ran.
*/
public var script:Script;
/**
* Script being ran.
*/
public var script:Script;
private var __variables:Array<String>;
private var __variables:Array<String>;
/**
* Return value of the last call.
*/
public var returnValue:Dynamic = null;
/**
* Return value of the last call.
*/
public var returnValue:Dynamic = null;
/**
* Whenever the current call has ended.
*/
public var callEnded:Bool = true;
/**
* Whenever the current call has ended.
*/
public var callEnded:Bool = true;
public function new(path:String, ?parentScript:Script) {
script = Script.create(path);
public function new(path:String, ?parentScript:Script) {
script = Script.create(path);
if (parentScript != null) {
if (script is HScript && parentScript is HScript) {
var hscript = cast(script, HScript);
var parentHScript = cast(parentScript, HScript);
if (parentScript != null) {
if (script is HScript && parentScript is HScript) {
var hscript = cast(script, HScript);
var parentHScript = cast(parentScript, HScript);
hscript.interp.variables = parentHScript.interp.variables;
hscript.interp.publicVariables = parentHScript.interp.publicVariables;
hscript.interp.staticVariables = parentHScript.interp.staticVariables;
hscript.interp.variables = parentHScript.interp.variables;
hscript.interp.publicVariables = parentHScript.interp.publicVariables;
hscript.interp.staticVariables = parentHScript.interp.staticVariables;
script.setParent(parentHScript.interp.scriptObject);
}
}
script.setParent(parentHScript.interp.scriptObject);
}
}
script.load();
script.load();
#if ALLOW_MULTITHREADING
thread = Thread.createWithEventLoop(function() {
// Prevent the thread from being auto deleted
Thread.current().events.promise();
});
#end
#if ALLOW_MULTITHREADING
thread = Thread.createWithEventLoop(function() {
// Prevent the thread from being auto deleted
Thread.current().events.promise();
});
#end
__variables = Type.getInstanceFields(Type.getClass(this));
}
__variables = Type.getInstanceFields(Type.getClass(this));
}
public inline function hget(name:String):Dynamic
return __variables.contains(name) ? Reflect.getProperty(this, name) : script.get(name);
public inline function hget(name:String):Dynamic
return __variables.contains(name) ? Reflect.getProperty(this, name) : script.get(name);
public inline function hset(name:String, val:Dynamic):Dynamic {
if (__variables.contains(name))
Reflect.setProperty(this, name, val);
else
script.set(name, val);
return val;
}
public inline function hset(name:String, val:Dynamic):Dynamic {
if (__variables.contains(name))
Reflect.setProperty(this, name, val);
else
script.set(name, val);
return val;
}
public function call(func:String, args:Array<Dynamic>) {
#if ALLOW_MULTITHREADING
thread.events.run(function() {
callEnded = false;
returnValue = script.call(func, args);
callEnded = true;
});
#else
returnValue = script.call(func, args);
callEnded = true;
#end
}
public function call(func:String, args:Array<Dynamic>) {
#if ALLOW_MULTITHREADING
thread.events.run(function() {
callEnded = false;
returnValue = script.call(func, args);
callEnded = true;
});
#else
returnValue = script.call(func, args);
callEnded = true;
#end
}
public function destroy() {
if (script != null) {
script.call("onDestroy");
script.destroy();
}
public function destroy() {
if (script != null) {
script.call("onDestroy");
script.destroy();
}
#if ALLOW_MULTITHREADING
if (thread != null) {
thread.events.runPromised(function() {
// close the thing
});
}
#end
}
#if ALLOW_MULTITHREADING
if (thread != null) {
thread.events.runPromised(function() {
// close the thing
});
}
#end
}
}
+230 -230
View File
@@ -8,266 +8,266 @@ import haxe.io.Path;
* Class used for scripting.
*/
class Script extends FlxBasic implements IFlxDestroyable {
/**
* Use "static var thing = true;" in hscript to use those!!
* are reset every mod switch so once you're done with them make sure to make them null!!
*/
public static var staticVariables:Map<String, Dynamic> = [];
/**
* Use "static var thing = true;" in hscript to use those!!
* are reset every mod switch so once you're done with them make sure to make them null!!
*/
public static var staticVariables:Map<String, Dynamic> = [];
public static function getDefaultVariables(?script:Script):Map<String, Dynamic> {
return [
// Haxe related stuff
"Std" => Std,
"Math" => Math,
"StringTools" => StringTools,
"Json" => haxe.Json,
public static function getDefaultVariables(?script:Script):Map<String, Dynamic> {
return [
// Haxe related stuff
"Std" => Std,
"Math" => Math,
"StringTools" => StringTools,
"Json" => haxe.Json,
// OpenFL & Lime related stuff
"Assets" => openfl.utils.Assets,
"Application" => lime.app.Application,
"window" => lime.app.Application.current.window,
// OpenFL & Lime related stuff
"Assets" => openfl.utils.Assets,
"Application" => lime.app.Application,
"window" => lime.app.Application.current.window,
// Flixel related stuff
"FlxG" => flixel.FlxG,
"FlxSprite" => flixel.FlxSprite,
"FlxBasic" => flixel.FlxBasic,
"FlxCamera" => flixel.FlxCamera,
"state" => flixel.FlxG.state,
"FlxEase" => flixel.tweens.FlxEase,
"FlxTween" => flixel.tweens.FlxTween,
"FlxSound" => flixel.system.FlxSound,
"FlxAssets" => flixel.system.FlxAssets,
"FlxMath" => flixel.math.FlxMath,
"FlxGroup" => flixel.group.FlxGroup,
"FlxTypedGroup" => flixel.group.FlxGroup.FlxTypedGroup,
"FlxSpriteGroup" => flixel.group.FlxSpriteGroup,
"FlxTypeText" => flixel.addons.text.FlxTypeText,
"FlxText" => flixel.text.FlxText,
"FlxTimer" => flixel.util.FlxTimer,
"FlxPoint" => CoolUtil.getMacroAbstractClass("flixel.math.FlxPoint"),
"FlxAxes" => CoolUtil.getMacroAbstractClass("flixel.util.FlxAxes"),
"FlxColor" => CoolUtil.getMacroAbstractClass("flixel.util.FlxColor"),
// Flixel related stuff
"FlxG" => flixel.FlxG,
"FlxSprite" => flixel.FlxSprite,
"FlxBasic" => flixel.FlxBasic,
"FlxCamera" => flixel.FlxCamera,
"state" => flixel.FlxG.state,
"FlxEase" => flixel.tweens.FlxEase,
"FlxTween" => flixel.tweens.FlxTween,
"FlxSound" => flixel.system.FlxSound,
"FlxAssets" => flixel.system.FlxAssets,
"FlxMath" => flixel.math.FlxMath,
"FlxGroup" => flixel.group.FlxGroup,
"FlxTypedGroup" => flixel.group.FlxGroup.FlxTypedGroup,
"FlxSpriteGroup" => flixel.group.FlxSpriteGroup,
"FlxTypeText" => flixel.addons.text.FlxTypeText,
"FlxText" => flixel.text.FlxText,
"FlxTimer" => flixel.util.FlxTimer,
"FlxPoint" => CoolUtil.getMacroAbstractClass("flixel.math.FlxPoint"),
"FlxAxes" => CoolUtil.getMacroAbstractClass("flixel.util.FlxAxes"),
"FlxColor" => CoolUtil.getMacroAbstractClass("flixel.util.FlxColor"),
// Engine related stuff
"engine" => {
// Engine related stuff
"engine" => {
commit: funkin.macros.GitCommitMacro.commitNumber,
build: 2675, // 2675 being the last build num before it was removed
name: "Codename Engine"
},
"ModState" => funkin.scripting.ModState,
"ModSubState" => funkin.scripting.ModSubState,
"PlayState" => funkin.game.PlayState,
"GameOverSubstate" => funkin.game.GameOverSubstate,
"HealthIcon" => funkin.game.HealthIcon,
"HudCamera" => funkin.game.HudCamera,
"Note" => funkin.game.Note,
"Strum" => funkin.game.Strum,
"StrumLine" => funkin.game.StrumLine,
"Character" => funkin.game.Character,
"Boyfriend" => funkin.game.Character, // for compatibility
"PauseSubstate" => funkin.menus.PauseSubState,
"FreeplayState" => funkin.menus.FreeplayState,
"MainMenuState" => funkin.menus.MainMenuState,
"PauseSubState" => funkin.menus.PauseSubState,
"StoryMenuState" => funkin.menus.StoryMenuState,
"TitleState" => funkin.menus.TitleState,
"Options" => funkin.options.Options,
"Paths" => funkin.system.Paths,
"Conductor" => funkin.system.Conductor,
"FunkinShader" => funkin.shaders.FunkinShader,
"CustomShader" => funkin.shaders.CustomShader,
"FunkinText" => funkin.ui.FunkinText,
"Alphabet" => funkin.ui.Alphabet,
build: 2675, // 2675 being the last build num before it was removed
name: "Codename Engine"
},
"ModState" => funkin.scripting.ModState,
"ModSubState" => funkin.scripting.ModSubState,
"PlayState" => funkin.game.PlayState,
"GameOverSubstate" => funkin.game.GameOverSubstate,
"HealthIcon" => funkin.game.HealthIcon,
"HudCamera" => funkin.game.HudCamera,
"Note" => funkin.game.Note,
"Strum" => funkin.game.Strum,
"StrumLine" => funkin.game.StrumLine,
"Character" => funkin.game.Character,
"Boyfriend" => funkin.game.Character, // for compatibility
"PauseSubstate" => funkin.menus.PauseSubState,
"FreeplayState" => funkin.menus.FreeplayState,
"MainMenuState" => funkin.menus.MainMenuState,
"PauseSubState" => funkin.menus.PauseSubState,
"StoryMenuState" => funkin.menus.StoryMenuState,
"TitleState" => funkin.menus.TitleState,
"Options" => funkin.options.Options,
"Paths" => funkin.system.Paths,
"Conductor" => funkin.system.Conductor,
"FunkinShader" => funkin.shaders.FunkinShader,
"CustomShader" => funkin.shaders.CustomShader,
"FunkinText" => funkin.ui.FunkinText,
"Alphabet" => funkin.ui.Alphabet,
"CoolUtil" => funkin.utils.CoolUtil,
"IniUtil" => funkin.utils.IniUtil,
"XMLUtil" => funkin.utils.XMLUtil,
#if sys "ZipUtil" => funkin.utils.ZipUtil, #end
"MarkdownUtil" => funkin.utils.MarkdownUtil,
"EngineUtil" => funkin.utils.EngineUtil,
];
}
public static function getDefaultPreprocessors():Map<String, Dynamic> {
return [
"CODENAME_ENGINE" => true,
"CODENAME_VER" => Application.current.meta.get('version'),
"CODENAME_BUILD" => 2675,
"CODENAME_COMMIT" => funkin.macros.GitCommitMacro.commitNumber,
"desktop" => #if desktop true #else false #end,
"windows" => #if windows true #else false #end,
"hl" => #if hl true #else false #end,
"neko" => #if neko true #else false #end,
"linux" => #if linux true #else false #end,
"mac" => #if mac true #else false #end,
"macos" => #if macos true #else false #end,
"android" => #if android true #else false #end,
"web" => #if web true #else false #end,
"debug" => #if debug true #else false #end,
"release" => #if release true #else false #end,
"final" => #if final true #else false #end,
"MOD_SUPPORT" => #if MOD_SUPPORT true #else false #end,
"GLOBAL_SCRIPT" => #if GLOBAL_SCRIPT true #else false #end,
"SOFTCODED_STATES" => #if SOFTCODED_STATES true #else false #end,
"USE_SOURCE_ASSETS" => #if USE_SOURCE_ASSETS true #else false #end,
"USE_ADAPTED_ASSETS" => #if USE_ADAPTED_ASSETS true #else false #end,
];
}
/**
* All available script extensions
*/
public static var scriptExtensions:Array<String> = [
"hx", "hscript", "hsc", "hxs", "lua" /** ACTUALLY NOT SUPPORTED, ONLY FOR THE MESSAGE **/
];
"CoolUtil" => funkin.utils.CoolUtil,
"IniUtil" => funkin.utils.IniUtil,
"XMLUtil" => funkin.utils.XMLUtil,
#if sys "ZipUtil" => funkin.utils.ZipUtil, #end
"MarkdownUtil" => funkin.utils.MarkdownUtil,
"EngineUtil" => funkin.utils.EngineUtil,
];
}
public static function getDefaultPreprocessors():Map<String, Dynamic> {
return [
"CODENAME_ENGINE" => true,
"CODENAME_VER" => Application.current.meta.get('version'),
"CODENAME_BUILD" => 2675,
"CODENAME_COMMIT" => funkin.macros.GitCommitMacro.commitNumber,
"desktop" => #if desktop true #else false #end,
"windows" => #if windows true #else false #end,
"hl" => #if hl true #else false #end,
"neko" => #if neko true #else false #end,
"linux" => #if linux true #else false #end,
"mac" => #if mac true #else false #end,
"macos" => #if macos true #else false #end,
"android" => #if android true #else false #end,
"web" => #if web true #else false #end,
"debug" => #if debug true #else false #end,
"release" => #if release true #else false #end,
"final" => #if final true #else false #end,
"MOD_SUPPORT" => #if MOD_SUPPORT true #else false #end,
"GLOBAL_SCRIPT" => #if GLOBAL_SCRIPT true #else false #end,
"SOFTCODED_STATES" => #if SOFTCODED_STATES true #else false #end,
"USE_SOURCE_ASSETS" => #if USE_SOURCE_ASSETS true #else false #end,
"USE_ADAPTED_ASSETS" => #if USE_ADAPTED_ASSETS true #else false #end,
];
}
/**
* All available script extensions
*/
public static var scriptExtensions:Array<String> = [
"hx", "hscript", "hsc", "hxs", "lua" /** ACTUALLY NOT SUPPORTED, ONLY FOR THE MESSAGE **/
];
/**
* Currently executing script.
*/
public static var curScript:Script = null;
/**
* Currently executing script.
*/
public static var curScript:Script = null;
/**
* Script name (with extension)
*/
public var fileName:String;
/**
* Script name (with extension)
*/
public var fileName:String;
/**
* Path to the script.
*/
public var path:String = null;
/**
* Path to the script.
*/
public var path:String = null;
/**
* Creates a script from the specified asset path. The language is automatically determined.
* @param path Path in assets
*/
public static function create(path:String):Script {
if (Assets.exists(path)) {
return switch(Path.extension(path).toLowerCase()) {
case "hx" | "hscript" | "hsc" | "hxs":
new HScript(path);
case "lua":
Logs.trace("Lua is not supported in this engine. Use HScript instead.", ERROR);
new DummyScript(path);
default:
new DummyScript(path);
}
}
return new DummyScript(path);
}
/**
* Creates a script from the specified asset path. The language is automatically determined.
* @param path Path in assets
*/
public static function create(path:String):Script {
if (Assets.exists(path)) {
return switch(Path.extension(path).toLowerCase()) {
case "hx" | "hscript" | "hsc" | "hxs":
new HScript(path);
case "lua":
Logs.trace("Lua is not supported in this engine. Use HScript instead.", ERROR);
new DummyScript(path);
default:
new DummyScript(path);
}
}
return new DummyScript(path);
}
/**
* Creates a new instance of the script class.
* @param path
*/
public function new(path:String) {
super();
/**
* Creates a new instance of the script class.
* @param path
*/
public function new(path:String) {
super();
fileName = Path.withoutDirectory(path);
this.path = path;
onCreate(path);
for(k=>e in getDefaultVariables(this)) {
set(k, e);
}
}
fileName = Path.withoutDirectory(path);
this.path = path;
onCreate(path);
for(k=>e in getDefaultVariables(this)) {
set(k, e);
}
}
/**
* Loads the script
*/
public function load() {
var oldScript = curScript;
curScript = this;
onLoad();
curScript = oldScript;
}
/**
* Loads the script
*/
public function load() {
var oldScript = curScript;
curScript = this;
onLoad();
curScript = oldScript;
}
/**
* HSCRIPT ONLY FOR NOW
* Sets the "public" variables map for ScriptPack
*/
public function setPublicMap(map:Map<String, Dynamic>) {
/**
* HSCRIPT ONLY FOR NOW
* Sets the "public" variables map for ScriptPack
*/
public function setPublicMap(map:Map<String, Dynamic>) {
}
}
/**
* Hot-reloads the script, if possible
*/
public function reload() {
/**
* Hot-reloads the script, if possible
*/
public function reload() {
}
}
/**
* Traces something as this script.
*/
public function trace(v:Dynamic) {
Logs.traceColored([
Logs.logText('${fileName}: ', GREEN),
Logs.logText(Std.string(v))
], TRACE);
}
/**
* Traces something as this script.
*/
public function trace(v:Dynamic) {
Logs.traceColored([
Logs.logText('${fileName}: ', GREEN),
Logs.logText(Std.string(v))
], TRACE);
}
/**
* Calls the function `func` defined in the script.
* @param func Name of the function
* @param parameters (Optional) Parameters of the function.
* @return Result (if void, then null)
*/
public function call(func:String, ?parameters:Array<Dynamic>):Dynamic {
var oldScript = curScript;
curScript = this;
/**
* Calls the function `func` defined in the script.
* @param func Name of the function
* @param parameters (Optional) Parameters of the function.
* @return Result (if void, then null)
*/
public function call(func:String, ?parameters:Array<Dynamic>):Dynamic {
var oldScript = curScript;
curScript = this;
var result = onCall(func, parameters == null ? [] : parameters);
var result = onCall(func, parameters == null ? [] : parameters);
curScript = oldScript;
return result;
}
curScript = oldScript;
return result;
}
/**
* Sets a script's parent object so that its properties can be accessed easily. Ex: Passing `PlayState.instance` will allow `boyfriend` to be typed instead of `PlayState.instance.boyfriend`.
* @param variable Parent variable.
*/
public function setParent(variable:Dynamic) {}
/**
* Sets a script's parent object so that its properties can be accessed easily. Ex: Passing `PlayState.instance` will allow `boyfriend` to be typed instead of `PlayState.instance.boyfriend`.
* @param variable Parent variable.
*/
public function setParent(variable:Dynamic) {}
/**
* Gets the variable `variable` from the script's variables.
* @param variable Name of the variable.
* @return Variable (or null if it doesn't exists)
*/
public function get(variable:String):Dynamic {return null;}
/**
* Gets the variable `variable` from the script's variables.
* @param variable Name of the variable.
* @return Variable (or null if it doesn't exists)
*/
public function get(variable:String):Dynamic {return null;}
/**
* Gets the variable `variable` from the script's variables.
* @param variable Name of the variable.
* @return Variable (or null if it doesn't exists)
*/
public function set(variable:String, value:Dynamic):Void {}
/**
* Gets the variable `variable` from the script's variables.
* @param variable Name of the variable.
* @return Variable (or null if it doesn't exists)
*/
public function set(variable:String, value:Dynamic):Void {}
/**
* Shows an error from this script.
* @param text Text of the error (ex: Null Object Reference).
* @param additionalInfo Additional information you could provide.
*/
public function error(text:String, ?additionalInfo:Dynamic):Void {
Logs.traceColored([
Logs.logText(fileName, RED),
Logs.logText(text)
], ERROR);
}
/**
* Shows an error from this script.
* @param text Text of the error (ex: Null Object Reference).
* @param additionalInfo Additional information you could provide.
*/
public function error(text:String, ?additionalInfo:Dynamic):Void {
Logs.traceColored([
Logs.logText(fileName, RED),
Logs.logText(text)
], ERROR);
}
/**
* PRIVATE HANDLERS - DO NOT TOUCH
*/
private function onCall(func:String, parameters:Array<Dynamic>):Dynamic {
return null;
}
public function onCreate(path:String) {}
/**
* PRIVATE HANDLERS - DO NOT TOUCH
*/
private function onCall(func:String, parameters:Array<Dynamic>):Dynamic {
return null;
}
public function onCreate(path:String) {}
public function onLoad() {}
public function onLoad() {}
public function onDestroy() {};
public function onDestroy() {};
public override function destroy() {
super.destroy();
onDestroy();
}
public override function destroy() {
super.destroy();
onDestroy();
}
}
+98 -98
View File
@@ -4,117 +4,117 @@ import funkin.scripting.events.CancellableEvent;
@:access(CancellableEvent)
class ScriptPack extends Script {
public var scripts:Array<Script> = [];
public var additionalDefaultVariables:Map<String, Dynamic> = [];
public var publicVariables:Map<String, Dynamic> = [];
public var parent:Dynamic = null;
public var scripts:Array<Script> = [];
public var additionalDefaultVariables:Map<String, Dynamic> = [];
public var publicVariables:Map<String, Dynamic> = [];
public var parent:Dynamic = null;
public override function load() {
for(e in scripts) {
e.load();
}
}
public override function load() {
for(e in scripts) {
e.load();
}
}
public function contains(path:String) {
for(e in scripts)
if (e.path == path)
return true;
return false;
}
public function new(name:String) {
additionalDefaultVariables["importScript"] = importScript;
super(name);
}
public function contains(path:String) {
for(e in scripts)
if (e.path == path)
return true;
return false;
}
public function new(name:String) {
additionalDefaultVariables["importScript"] = importScript;
super(name);
}
public function getByPath(name:String) {
for(s in scripts)
if (s.path == name)
return s;
return null;
}
public function getByPath(name:String) {
for(s in scripts)
if (s.path == name)
return s;
return null;
}
public function getByName(name:String) {
for(s in scripts)
if (s.fileName == name)
return s;
return null;
}
public function importScript(path:String):Script {
var script = Script.create(Paths.script(path));
if (script is DummyScript) {
throw 'Script at ${path} does not exist.';
return null;
}
add(script);
script.load();
return script;
}
public function getByName(name:String) {
for(s in scripts)
if (s.fileName == name)
return s;
return null;
}
public function importScript(path:String):Script {
var script = Script.create(Paths.script(path));
if (script is DummyScript) {
throw 'Script at ${path} does not exist.';
return null;
}
add(script);
script.load();
return script;
}
public override function call(func:String, ?parameters:Array<Dynamic>):Dynamic {
for(e in scripts)
e.call(func, parameters);
return null;
}
public override function call(func:String, ?parameters:Array<Dynamic>):Dynamic {
for(e in scripts)
e.call(func, parameters);
return null;
}
/**
* Sends an event to every single script, and returns the event.
* @param func Function to call
* @param event Event (will be the first parameter of the function)
* @return (modified by scripts)
*/
public function event<T:CancellableEvent>(func:String, event:T):T {
for(e in scripts) {
e.call(func, [event]);
@:privateAccess
if (event.cancelled && !event.__continueCalls) break;
}
return event;
}
/**
* Sends an event to every single script, and returns the event.
* @param func Function to call
* @param event Event (will be the first parameter of the function)
* @return (modified by scripts)
*/
public function event<T:CancellableEvent>(func:String, event:T):T {
for(e in scripts) {
e.call(func, [event]);
@:privateAccess
if (event.cancelled && !event.__continueCalls) break;
}
return event;
}
public override function get(val:String):Dynamic {
for(e in scripts) {
var v = e.get(val);
if (v != null) return v;
}
return null;
}
public override function get(val:String):Dynamic {
for(e in scripts) {
var v = e.get(val);
if (v != null) return v;
}
return null;
}
public override function reload() {
for(e in scripts) e.reload();
}
public override function reload() {
for(e in scripts) e.reload();
}
public override function set(val:String, value:Dynamic) {
for(e in scripts) e.set(val, value);
}
public override function set(val:String, value:Dynamic) {
for(e in scripts) e.set(val, value);
}
public override function setParent(parent:Dynamic) {
this.parent = parent;
for(e in scripts) e.setParent(parent);
}
public override function setParent(parent:Dynamic) {
this.parent = parent;
for(e in scripts) e.setParent(parent);
}
public override function onDestroy() {
for(e in scripts) e.destroy();
}
public override function onCreate(path:String) {}
public override function onDestroy() {
for(e in scripts) e.destroy();
}
public override function onCreate(path:String) {}
public function add(script:Script) {
scripts.push(script);
__configureNewScript(script);
}
public function add(script:Script) {
scripts.push(script);
__configureNewScript(script);
}
public function remove(script:Script) {
scripts.remove(script);
}
public function remove(script:Script) {
scripts.remove(script);
}
public function insert(pos:Int, script:Script) {
scripts.insert(pos, script);
__configureNewScript(script);
}
public function insert(pos:Int, script:Script) {
scripts.insert(pos, script);
__configureNewScript(script);
}
private function __configureNewScript(script:Script) {
if (parent != null) script.setParent(parent);
script.setPublicMap(publicVariables);
for(k=>e in additionalDefaultVariables) script.set(k, e);
}
private function __configureNewScript(script:Script) {
if (parent != null) script.setParent(parent);
script.setPublicMap(publicVariables);
for(k=>e in additionalDefaultVariables) script.set(k, e);
}
}
+12 -12
View File
@@ -4,18 +4,18 @@ import funkin.game.StrumLine;
import flixel.math.FlxPoint;
class CamMoveEvent extends CancellableEvent {
/**
* Final camera position.
*/
public var position:FlxPoint;
/**
* Final camera position.
*/
public var position:FlxPoint;
/**
* Currently focused strumline.
*/
public var strumLine:StrumLine;
/**
* Currently focused strumline.
*/
public var strumLine:StrumLine;
/**
* Number of focused characters
*/
public var focusedCharacters:Int;
/**
* Number of focused characters
*/
public var focusedCharacters:Int;
}
@@ -5,52 +5,52 @@ import flixel.util.FlxDestroyUtil.IFlxDestroyable;
@:allow(ScriptPack)
@:autoBuild(funkin.macros.EventMacro.build())
class CancellableEvent implements IFlxDestroyable {
@:dox(hide) public var cancelled:Bool = false;
@:dox(hide) private var __continueCalls:Bool = true;
@:dox(hide) public var cancelled:Bool = false;
@:dox(hide) private var __continueCalls:Bool = true;
/**
* Additional data if used in scripts
*/
public var data:Dynamic = {};
/**
* Additional data if used in scripts
*/
public var data:Dynamic = {};
/**
* Prevents default action from occurring.
* @param c Whenever the scripts following this one should be called or not. (Defaults to `true`)
*/
public function preventDefault(c:Bool = false) {
cancelled = true;
__continueCalls = c;
}
/**
* Prevents default action from occurring.
* @param c Whenever the scripts following this one should be called or not. (Defaults to `true`)
*/
public function preventDefault(c:Bool = false) {
cancelled = true;
__continueCalls = c;
}
@:dox(hide)
public function cancel(c:Bool = true) {preventDefault(c);}
@:dox(hide)
public function cancel(c:Bool = true) {preventDefault(c);}
/**
* Creates a new cancellable event.
* This allows scripts to call `cancel()` to cancel the event.
*/
public function new() {}
/**
* Creates a new cancellable event.
* This allows scripts to call `cancel()` to cancel the event.
*/
public function new() {}
public function recycleBase() {
data = {};
cancelled = false;
__continueCalls = true;
}
public function recycleBase() {
data = {};
cancelled = false;
__continueCalls = true;
}
/**
* Returns a string representation of the event, in this format:
* `[CancellableEvent]`
* `[CancellableEvent (Cancelled)]`
* @return String
*/
public function toString():String {
var fields = Reflect.fields(this);
var claName = Type.getClassName(Type.getClass(this)).split(".");
var rep = '[${claName[claName.length-1]}${cancelled ? " (Cancelled)" : ""}]';
return rep;
}
/**
* Returns a string representation of the event, in this format:
* `[CancellableEvent]`
* `[CancellableEvent (Cancelled)]`
* @return String
*/
public function toString():String {
var fields = Reflect.fields(this);
var claName = Type.getClassName(Type.getClass(this)).split(".");
var rep = '[${claName[claName.length-1]}${cancelled ? " (Cancelled)" : ""}]';
return rep;
}
public function destroy() {
data = null;
}
public function destroy() {
data = null;
}
}
@@ -4,42 +4,42 @@ import flixel.tweens.FlxTween;
import flixel.system.FlxSound;
class CountdownEvent extends CancellableEvent {
/**
* At which count the countdown is. Normally goes 0-1-2-3-4 unless `PlayState.instance.introLength` is changed.
*/
public var swagCounter:Int;
/**
* Volume at which the intro countdown sound will play.
*/
public var volume:Float;
/**
* Path of the intro sound that'll be played.
*/
public var soundPath:String;
/**
* Path to the sprite path that'll be shown.
*/
public var spritePath:String;
/**
* Scale of the sprite.
*/
public var scale:Float;
/**
* Whenever antialiasing is enabled or not.
*/
public var antialiasing:Bool;
/**
* At which count the countdown is. Normally goes 0-1-2-3-4 unless `PlayState.instance.introLength` is changed.
*/
public var swagCounter:Int;
/**
* Volume at which the intro countdown sound will play.
*/
public var volume:Float;
/**
* Path of the intro sound that'll be played.
*/
public var soundPath:String;
/**
* Path to the sprite path that'll be shown.
*/
public var spritePath:String;
/**
* Scale of the sprite.
*/
public var scale:Float;
/**
* Whenever antialiasing is enabled or not.
*/
public var antialiasing:Bool;
/**
* Created sprite, only available in `onPostCountdown`
*/
public var sprite:FlxSprite;
/**
* Created tween for the sprite, only available in `onPostCountdown`
*/
public var spriteTween:FlxTween;
/**
* Created sound, only available in `onPostCountdown`
*/
public var sound:FlxSound;
/**
* Created sprite, only available in `onPostCountdown`
*/
public var sprite:FlxSprite;
/**
* Created tween for the sprite, only available in `onPostCountdown`
*/
public var spriteTween:FlxTween;
/**
* Created sound, only available in `onPostCountdown`
*/
public var sound:FlxSound;
}
+1 -1
View File
@@ -1,5 +1,5 @@
package funkin.scripting.events;
class DanceEvent extends CancellableEvent {
public var danced:Bool;
public var danced:Bool;
}
@@ -3,32 +3,32 @@ package funkin.scripting.events;
import funkin.scripting.events.PlayAnimEvent.PlayAnimContext;
class DirectionAnimEvent extends CancellableEvent {
/**
Default animation that will be played
**/
public var animName:String;
/**
In which direction the animation will be played
**/
public var direction:Int;
/**
The suffix of the animation (ex: "-alt") - Defaults to ""
**/
public var suffix:String;
/**
Context of the animation. Is either equal to `SING` or `MISS`.
**/
public var context:PlayAnimContext;
/**
Whenever the animation will play reversed or not.
**/
public var reversed:Bool;
/**
At what frame the animation will start playing
**/
public var frame:Int;
/**
Whenever the animation will play reversed or not.
**/
public var force:Bool = true;
/**
Default animation that will be played
**/
public var animName:String;
/**
In which direction the animation will be played
**/
public var direction:Int;
/**
The suffix of the animation (ex: "-alt") - Defaults to ""
**/
public var suffix:String;
/**
Context of the animation. Is either equal to `SING` or `MISS`.
**/
public var context:PlayAnimContext;
/**
Whenever the animation will play reversed or not.
**/
public var reversed:Bool;
/**
At what frame the animation will start playing
**/
public var frame:Int;
/**
Whenever the animation will play reversed or not.
**/
public var force:Bool = true;
}
@@ -5,8 +5,8 @@ import discord_rpc.DiscordRpc.DiscordPresenceOptions;
#end
class DiscordPresenceUpdateEvent extends CancellableEvent {
/**
* Object containing all of the data for the presence. Can be altered.
*/
public var presenceData:#if DISCORD_RPC DiscordPresenceOptions #else Dynamic #end;
/**
* Object containing all of the data for the presence. Can be altered.
*/
public var presenceData:#if DISCORD_RPC DiscordPresenceOptions #else Dynamic #end;
}
@@ -1,20 +1,20 @@
package funkin.scripting.events;
class FreeplaySongSelectEvent extends CancellableEvent {
/**
* Song name that is about to be played
*/
public var song:String;
/**
* Difficulty name
*/
public var difficulty:String;
/**
* Whenever opponent mode is enabled or not.
*/
public var opponentMode:Bool;
/**
* Whenever coop mode is enabled.
*/
public var coopMode:Bool;
/**
* Song name that is about to be played
*/
public var song:String;
/**
* Difficulty name
*/
public var difficulty:String;
/**
* Whenever opponent mode is enabled or not.
*/
public var opponentMode:Bool;
/**
* Whenever coop mode is enabled.
*/
public var coopMode:Bool;
}
@@ -3,31 +3,31 @@ package funkin.scripting.events;
import funkin.game.StrumLine;
class InputSystemEvent extends CancellableEvent {
/**
* Array containing whenever a specific control is pressed or not.
* For example, `pressed[0]` will return whenever the left strum was pressed.
*/
public var pressed:Array<Bool>;
/**
* Array containing whenever a specific control is pressed or not.
* For example, `pressed[0]` will return whenever the left strum was pressed.
*/
public var pressed:Array<Bool>;
/**
* Array containing whenever a specific control was pressed (not hold) this frame or not.
* For example, `justPressed[0]` will return whenever the left strum was just pressed.
*/
public var justPressed:Array<Bool>;
/**
* Array containing whenever a specific control was pressed (not hold) this frame or not.
* For example, `justPressed[0]` will return whenever the left strum was just pressed.
*/
public var justPressed:Array<Bool>;
/**
* Array containing whenever a specific control was released this frame or not.
* For example, `justReleased[0]` will return whenever the left strum was just released.
*/
public var justReleased:Array<Bool>;
/**
* Array containing whenever a specific control was released this frame or not.
* For example, `justReleased[0]` will return whenever the left strum was just released.
*/
public var justReleased:Array<Bool>;
/**
* Strumline which input is being processed.
*/
public var strumLine:StrumLine;
/**
* Strumline which input is being processed.
*/
public var strumLine:StrumLine;
/**
* ID of the Strumline.
*/
public var strumLineID:Int;
/**
* ID of the Strumline.
*/
public var strumLineID:Int;
}
@@ -1,23 +1,23 @@
package funkin.scripting.events;
class MenuChangeEvent extends CancellableEvent {
/**
* Value before the change
*/
public var oldValue:Int;
/**
* Value before the change
*/
public var oldValue:Int;
/**
* Value after the change
*/
public var value:Int;
/**
* Value after the change
*/
public var value:Int;
/**
* Amount of change
*/
public var change:Int;
/**
* Amount of change
*/
public var change:Int;
/**
* Whenever the menu SFX should be played.
*/
public var playMenuSFX:Bool = true;
/**
* Whenever the menu SFX should be played.
*/
public var playMenuSFX:Bool = true;
}
+4 -4
View File
@@ -1,8 +1,8 @@
package funkin.scripting.events;
class NameEvent extends CancellableEvent {
/**
* Name
*/
public var name:String;
/**
* Name
*/
public var name:String;
}
@@ -3,48 +3,48 @@ package funkin.scripting.events;
import funkin.game.Note;
class NoteCreationEvent extends CancellableEvent {
/**
* Note that is being created
*/
public var note:Note;
/**
* Note that is being created
*/
public var note:Note;
/**
* ID of the strum (from 0 to 3)
*/
public var strumID:Int;
/**
* ID of the strum (from 0 to 3)
*/
public var strumID:Int;
/**
* Note Type (ex: "My Super Cool Note", or "Mine")
*/
public var noteType:String;
/**
* Note Type (ex: "My Super Cool Note", or "Mine")
*/
public var noteType:String;
/**
* ID of the note type.
*/
public var noteTypeID:Int;
/**
* ID of the note type.
*/
public var noteTypeID:Int;
/**
* ID of the player.
*/
public var strumLineID:Int;
/**
* ID of the player.
*/
public var strumLineID:Int;
/**
* Whenever the note will need to be hit by the player
*/
public var mustHit:Bool;
/**
* Whenever the note will need to be hit by the player
*/
public var mustHit:Bool;
/**
* Note sprite, if you only want to replace the sprite.
*/
public var noteSprite:String;
/**
* Note sprite, if you only want to replace the sprite.
*/
public var noteSprite:String;
/**
* Note scale, if you only want to replace the scale.
*/
public var noteScale:Float;
/**
* Note scale, if you only want to replace the scale.
*/
public var noteScale:Float;
/**
* Sing animation suffix. "-alt" for alt anim or "" for normal notes.
*/
public var animSuffix:String;
/**
* Sing animation suffix. "-alt" for alt anim or "" for normal notes.
*/
public var animSuffix:String;
}
+156 -156
View File
@@ -4,170 +4,170 @@ import funkin.game.Note;
import funkin.game.Character;
class NoteHitEvent extends CancellableEvent {
@:dox(hide) public var animCancelled:Bool = false;
@:dox(hide) public var strumGlowCancelled:Bool = false;
@:dox(hide) public var deleteNote:Bool = true;
@:dox(hide) public var unmuteVocals:Bool = true;
@:dox(hide) public var enableCamZooming:Bool = true;
@:dox(hide) public var autoHitLastSustain:Bool = true;
@:dox(hide) public var animCancelled:Bool = false;
@:dox(hide) public var strumGlowCancelled:Bool = false;
@:dox(hide) public var deleteNote:Bool = true;
@:dox(hide) public var unmuteVocals:Bool = true;
@:dox(hide) public var enableCamZooming:Bool = true;
@:dox(hide) public var autoHitLastSustain:Bool = true;
/**
* Whenever a miss should be added.
*/
public var misses:Bool = true;
/**
* Whenever a miss should be added.
*/
public var countAsCombo:Bool = true;
/**
* Whenever ratings should be shown or not.
*/
public var showRating:Null<Bool> = null;
/**
* Note that has been pressed
*/
public var note:Note;
/**
* Character that pressed the note.
*/
public var character(get, set):Character;
/**
* Characters that pressed the note.
*/
public var characters:Array<Character>;
/**
* Whenever the Character is a player
*/
public var player:Bool;
/**
* Note Type name (null if default note)
*/
public var noteType:String;
/**
* Suffix of the animation. "-alt" for alt notes, "" for normal ones.
*/
public var animSuffix:String;
/**
* Prefix of the rating sprite path. Defaults to "game/score/"
*/
public var ratingPrefix:String;
/**
* Suffix of the rating sprite path.
*/
public var ratingSuffix:String;
/**
* Direction of the press (0 = Left, 1 = Down, 2 = Up, 3 = Right)
*/
public var direction:Int;
/**
* Score gained after note press.
*/
public var score:Int;
/**
* Accuracy gained from pressing this note. From 0 to 1. null means no accuracy is gained.
*/
public var accuracy:Null<Float>;
/**
* The amount of health that'll be gained from pressing that note. If called from `onPlayerMiss`, the value will be negative.
*/
public var healthGain:Float;
/**
* Rating name. Defaults to "sick", "good", "bad" and "shit". Customisable.
*/
public var rating:String = "sick";
/**
* Whenever a splash should be shown when the note is hit.
*/
public var showSplash:Bool = false;
/**
* Scale of combo numbers.
*/
public var numScale:Float = 0.5;
/**
* Whenever antialiasing should be enabled on combo number.
*/
public var numAntialiasing:Bool = true;
/**
* Scale of ratings.
*/
public var ratingScale:Float = 0.7;
/**
* Whenever antialiasing should be enabled on ratings.
*/
public var ratingAntialiasing:Bool = true;
/**
* Whenever the animation should be forced to play.
*/
public var forceAnim:Bool = true;
/**
* Whenever a miss should be added.
*/
public var misses:Bool = true;
/**
* Whenever a miss should be added.
*/
public var countAsCombo:Bool = true;
/**
* Whenever ratings should be shown or not.
*/
public var showRating:Null<Bool> = null;
/**
* Note that has been pressed
*/
public var note:Note;
/**
* Character that pressed the note.
*/
public var character(get, set):Character;
/**
* Characters that pressed the note.
*/
public var characters:Array<Character>;
/**
* Whenever the Character is a player
*/
public var player:Bool;
/**
* Note Type name (null if default note)
*/
public var noteType:String;
/**
* Suffix of the animation. "-alt" for alt notes, "" for normal ones.
*/
public var animSuffix:String;
/**
* Prefix of the rating sprite path. Defaults to "game/score/"
*/
public var ratingPrefix:String;
/**
* Suffix of the rating sprite path.
*/
public var ratingSuffix:String;
/**
* Direction of the press (0 = Left, 1 = Down, 2 = Up, 3 = Right)
*/
public var direction:Int;
/**
* Score gained after note press.
*/
public var score:Int;
/**
* Accuracy gained from pressing this note. From 0 to 1. null means no accuracy is gained.
*/
public var accuracy:Null<Float>;
/**
* The amount of health that'll be gained from pressing that note. If called from `onPlayerMiss`, the value will be negative.
*/
public var healthGain:Float;
/**
* Rating name. Defaults to "sick", "good", "bad" and "shit". Customisable.
*/
public var rating:String = "sick";
/**
* Whenever a splash should be shown when the note is hit.
*/
public var showSplash:Bool = false;
/**
* Scale of combo numbers.
*/
public var numScale:Float = 0.5;
/**
* Whenever antialiasing should be enabled on combo number.
*/
public var numAntialiasing:Bool = true;
/**
* Scale of ratings.
*/
public var ratingScale:Float = 0.7;
/**
* Whenever antialiasing should be enabled on ratings.
*/
public var ratingAntialiasing:Bool = true;
/**
* Whenever the animation should be forced to play.
*/
public var forceAnim:Bool = true;
/**
* Prevents the default sing animation from being played.
*/
public function preventAnim() {
animCancelled = true;
}
/**
* Prevents the default sing animation from being played.
*/
public function preventAnim() {
animCancelled = true;
}
@:dox(hide)
public function cancelAnim() {preventAnim();}
@:dox(hide)
public function cancelAnim() {preventAnim();}
/**
* Prevents the note from being deleted.
*/
public function preventDeletion() {
deleteNote = false;
}
@:dox(hide)
public function cancelDeletion() {preventDeletion();}
/**
* Prevents the note from being deleted.
*/
public function preventDeletion() {
deleteNote = false;
}
@:dox(hide)
public function cancelDeletion() {preventDeletion();}
/**
* Prevents the vocals volume from being set to 1 after pressing the note.
*/
public function preventVocalsUnmute() {
unmuteVocals = false;
}
@:dox(hide)
public function cancelVocalsUnmute() {preventVocalsUnmute();}
/**
* Prevents the vocals volume from being set to 1 after pressing the note.
*/
public function preventVocalsUnmute() {
unmuteVocals = false;
}
@:dox(hide)
public function cancelVocalsUnmute() {preventVocalsUnmute();}
/**
* Prevents the vocals volume from being muted in case its a parameter of `onPlayerMiss`
*/
public function preventVocalsMute() {
unmuteVocals = true;
}
@:dox(hide)
public function cancelVocalsMute() {preventVocalsMute();}
/**
* Prevents the vocals volume from being muted in case its a parameter of `onPlayerMiss`
*/
public function preventVocalsMute() {
unmuteVocals = true;
}
@:dox(hide)
public function cancelVocalsMute() {preventVocalsMute();}
/**
* Prevents the camera zoom every 4 beats from enabling.
*/
public function preventCamZooming() {
enableCamZooming = false;
}
@:dox(hide)
public function cancelCamZooming() {preventCamZooming();}
/**
* Prevents the camera zoom every 4 beats from enabling.
*/
public function preventCamZooming() {
enableCamZooming = false;
}
@:dox(hide)
public function cancelCamZooming() {preventCamZooming();}
/**
* Prevents the sustain tail (the last one) from being automatically hit when the sustain before it is hit.
*/
public function preventLastSustainHit() {
autoHitLastSustain = false;
}
@:dox(hide)
public function cancelLastSustainHit() {preventLastSustainHit();}
/**
* Prevents the sustain tail (the last one) from being automatically hit when the sustain before it is hit.
*/
public function preventLastSustainHit() {
autoHitLastSustain = false;
}
@:dox(hide)
public function cancelLastSustainHit() {preventLastSustainHit();}
/**
* Prevents the strum from glowing after this note has been pressed.
*/
public function preventStrumGlow() {
strumGlowCancelled = true;
}
@:dox(hide)
public function cancelStrumGlow() {preventStrumGlow();}
/**
* Prevents the strum from glowing after this note has been pressed.
*/
public function preventStrumGlow() {
strumGlowCancelled = true;
}
@:dox(hide)
public function cancelStrumGlow() {preventStrumGlow();}
private inline function get_character()
return characters[0];
private function set_character(char:Character) {
characters = [char];
return char;
}
private inline function get_character()
return characters[0];
private function set_character(char:Character) {
characters = [char];
return char;
}
}
@@ -4,45 +4,45 @@ import funkin.game.Note;
import funkin.game.Strum;
class NoteUpdateEvent extends CancellableEvent {
@:dox(hide) public var __updateHitWindow = true;
@:dox(hide) public var __autoCPUHit = true;
@:dox(hide) public var __reposNote = true;
/**
* Note that is being updated
*/
public var note:Note;
@:dox(hide) public var __updateHitWindow = true;
@:dox(hide) public var __autoCPUHit = true;
@:dox(hide) public var __reposNote = true;
/**
* Note that is being updated
*/
public var note:Note;
/**
* Time elapsed since last frame
*/
public var elapsed:Null<Float>;
/**
* Time elapsed since last frame
*/
public var elapsed:Null<Float>;
/**
* Note's strum (can be changed)
*/
public var strum:Strum;
/**
* Note's strum (can be changed)
*/
public var strum:Strum;
/**
* Cancels the hit window update.
*/
public function cancelWindowUpdate() {
__updateHitWindow = false;
}
@:dox(hide) public function preventWindowUpdate() { cancelWindowUpdate(); }
/**
* Cancels the hit window update.
*/
public function cancelWindowUpdate() {
__updateHitWindow = false;
}
@:dox(hide) public function preventWindowUpdate() { cancelWindowUpdate(); }
/**
* Cancels the automatic CPU hit.
*/
public function cancelAutoCPUHit() {
__autoCPUHit = false;
}
@:dox(hide) public function preventAutoCPUHit() { cancelAutoCPUHit(); }
/**
* Cancels the automatic CPU hit.
*/
public function cancelAutoCPUHit() {
__autoCPUHit = false;
}
@:dox(hide) public function preventAutoCPUHit() { cancelAutoCPUHit(); }
/**
* Cancels the note position update (note will freeze).
*/
public function cancelPositionUpdate() {
__reposNote = false;
}
@:dox(hide) public function preventPositionUpdate() { cancelPositionUpdate(); }
/**
* Cancels the note position update (note will freeze).
*/
public function cancelPositionUpdate() {
__reposNote = false;
}
@:dox(hide) public function preventPositionUpdate() { cancelPositionUpdate(); }
}
@@ -4,13 +4,13 @@ package funkin.scripting.events;
* CANCEL this event to prevent default behaviour!
*/
class PauseCreationEvent extends CancellableEvent {
/**
* Music that is going to be played
*/
public var music:String;
/**
* Music that is going to be played
*/
public var music:String;
/**
* All option names
*/
public var options:Array<String>;
/**
* All option names
*/
public var options:Array<String>;
}
+46 -46
View File
@@ -1,64 +1,64 @@
package funkin.scripting.events;
class PlayAnimEvent extends CancellableEvent {
/**
Name of the animation that's going to be played.
**/
public var animName:String;
/**
Name of the animation that's going to be played.
**/
public var animName:String;
/**
Whenever the animation will be forced or not.
**/
public var force:Bool;
/**
Whenever the animation will be forced or not.
**/
public var force:Bool;
/**
Whenever the animation will play in reverse or not
**/
public var reverse:Bool;
/**
Whenever the animation will play in reverse or not
**/
public var reverse:Bool;
/**
The frame at which the animation will start playing
**/
public var startingFrame:Int = 0;
/**
The frame at which the animation will start playing
**/
public var startingFrame:Int = 0;
/**
Context of the animation
**/
public var context:PlayAnimContext;
/**
Context of the animation
**/
public var context:PlayAnimContext;
}
/**
Contains all contexts possible for `PlayAnimEvent`.
Contains all contexts possible for `PlayAnimEvent`.
**/
@:enum
abstract PlayAnimContext(String) {
/**
No context was given for the animation.
The character won't dance until the animation is finished
**/
var NONE = null;
/**
No context was given for the animation.
The character won't dance until the animation is finished
**/
var NONE = null;
/**
Whenever a note is hit and a sing animation will be played.
The character will only dance after their holdTime is reached.
**/
var SING = "SING";
/**
Whenever a note is hit and a sing animation will be played.
The character will only dance after their holdTime is reached.
**/
var SING = "SING";
/**
Whenever a dance animation is played.
The character's dancing wont be blocked.
**/
var DANCE = "DANCE";
/**
Whenever a dance animation is played.
The character's dancing wont be blocked.
**/
var DANCE = "DANCE";
/**
Whenever a note is missed and a miss animation will be played.
Only for scripting, since it has the same effects as SING.
**/
var MISS = "MISS";
/**
Whenever a note is missed and a miss animation will be played.
Only for scripting, since it has the same effects as SING.
**/
var MISS = "MISS";
/**
Locks the character's animation.
Prevents the character from dancing, even if the animation ended.
**/
var LOCK = "LOCK";
/**
Locks the character's animation.
Prevents the character from dancing, even if the animation ended.
**/
var LOCK = "LOCK";
}
+8 -8
View File
@@ -1,12 +1,12 @@
package funkin.scripting.events;
class PointEvent extends CancellableEvent {
/**
X position
**/
public var x:Float;
/**
Y position
**/
public var y:Float;
/**
X position
**/
public var x:Float;
/**
Y position
**/
public var y:Float;
}
@@ -1,13 +1,13 @@
package funkin.scripting.events;
class RatingUpdateEvent extends CancellableEvent {
/**
New combo
**/
public var rating:ComboRating;
/**
Old combo (may be null)
**/
public var oldRating:ComboRating;
/**
New combo
**/
public var rating:ComboRating;
/**
Old combo (may be null)
**/
public var oldRating:ComboRating;
}
+16 -16
View File
@@ -1,22 +1,22 @@
package funkin.scripting.events;
class ResizeEvent extends CancellableEvent {
/**
* New width
*/
public var width:Int;
/**
* New height
*/
public var height:Int;
/**
* New width
*/
public var width:Int;
/**
* New height
*/
public var height:Int;
/**
* Old width (may be null)
*/
public var oldWidth:Null<Int>;
/**
* Old width (may be null)
*/
public var oldWidth:Null<Int>;
/**
* Old height (may be null)
*/
public var oldHeight:Null<Int>;
/**
* Old height (may be null)
*/
public var oldHeight:Null<Int>;
}
@@ -3,8 +3,8 @@ package funkin.scripting.events;
import funkin.game.Note;
class SimpleNoteEvent extends CancellableEvent {
/**
Note that is affected.
**/
public var note:Note;
/**
Note that is affected.
**/
public var note:Note;
}
+4 -4
View File
@@ -3,8 +3,8 @@ package funkin.scripting.events;
import flixel.FlxState;
class StateEvent extends CancellableEvent {
/**
* Substate that is about to be opened/closed
*/
public var substate:FlxState;
/**
* Substate that is about to be opened/closed
*/
public var substate:FlxState;
}
@@ -3,32 +3,32 @@ package funkin.scripting.events;
import funkin.game.Strum;
class StrumCreationEvent extends CancellableEvent {
@:dox(hide) public var __doAnimation = true;
@:dox(hide) public var __doAnimation = true;
/**
* The strum that is being created
*/
public var strum:Strum;
/**
* The strum that is being created
*/
public var strum:Strum;
/**s
* Player ID
*/
public var player:Int;
/**s
* Player ID
*/
public var player:Int;
/**
* Strum ID, for the sprite.
*/
public var strumID:Int;
/**
* Strum ID, for the sprite.
*/
public var strumID:Int;
/**
* Sprite path, in case you only want to change the sprite.
*/
public var sprite:String = "game/notes/default";
/**
* Sprite path, in case you only want to change the sprite.
*/
public var sprite:String = "game/notes/default";
/**
* Cancels the animation that makes the strum "land" in the strumline.
*/
public function cancelAnimation() {__doAnimation = false;}
@:dox(hide) public function preventAnimation() {cancelAnimation();}
/**
* Cancels the animation that makes the strum "land" in the strumline.
*/
public function cancelAnimation() {__doAnimation = false;}
@:dox(hide) public function preventAnimation() {cancelAnimation();}
}
@@ -3,23 +3,23 @@ package funkin.scripting.events;
import funkin.menus.StoryMenuState.WeekData;
class WeekSelectEvent extends CancellableEvent {
/**
* Week that is going to be selected
*/
public var week:WeekData;
/**
* Week that is going to be selected
*/
public var week:WeekData;
/**
* The difficulty that has been selected
*/
public var difficulty:String;
/**
* The difficulty that has been selected
*/
public var difficulty:String;
/**
* At which emplacement the week is. Goes from 0 to the number of weeks - 1.
*/
public var weekID:Int;
/**
* At which emplacement the week is. Goes from 0 to the number of weeks - 1.
*/
public var weekID:Int;
/**
* At which emplacement the difficulty is. Goes from 0 to the number of weeks - 1.
*/
public var difficultyID:Int;
/**
* At which emplacement the difficulty is. Goes from 0 to the number of weeks - 1.
*/
public var difficultyID:Int;
}