Merge branch 'main' into new-editors

This commit is contained in:
Ne_Eo
2024-08-10 14:43:11 +02:00
10 changed files with 74 additions and 2 deletions
@@ -70,6 +70,8 @@ final class EventsData {
hscriptInterp.variables.set("StrumLine", TStrumLine);
hscriptInterp.variables.set("ColorWheel", TColorWheel);
hscriptInterp.variables.set("DropDown", Reflect.makeVarArgs((args) -> {return args.length > 0 ? TDropDown([for (arg in args) Std.string(arg)]) : TDropDown(["null"]);}));
hscriptInterp.variables.set("Character", TCharacter);
hscriptInterp.variables.set("Stage", TStage);
var hscriptParser:Parser = new Parser();
hscriptParser.allowJSON = hscriptParser.allowMetadata = false;
@@ -127,4 +129,6 @@ enum EventParamType {
TStrumLine;
TColorWheel;
TDropDown(?options:Array<String>);
TCharacter;
TStage;
}
@@ -0,0 +1,13 @@
package funkin.backend.scripting.events;
final class HealthIconChangeEvent extends CancellableEvent {
/**
* Amount
*/
public var amount:Int;
/**
* The health icon
*/
public var healthIcon:funkin.game.HealthIcon;
}
@@ -5,6 +5,7 @@ using StringTools;
#if macro
class BuildInfo {
public static function printBuildInfo() {
if(haxe.macro.Context.defined("display")) return;
var haxeVersion = haxe.macro.Context.definedValue("haxe");
Sys.println('--- BUILD INFO ---');
Sys.println('Haxe Version: ${haxeVersion}');
@@ -107,14 +107,28 @@ final class DiscordUtil
public static function loadScript()
{
#if DISCORD_RPC
if (script != null)
{
call("destroy");
script = FlxDestroyUtil.destroy(script);
}
script = Script.create(Paths.script('data/discord'));
script.set("ActivityType", {
Playing: ActivityType.Playing,
PLAYING: ActivityType.Playing,
Streaming: ActivityType.Streaming,
STREAMING: ActivityType.Streaming,
Watching: ActivityType.Watching,
WATCHING: ActivityType.Watching,
Listening: ActivityType.Listening,
LISTENING: ActivityType.Listening,
Competing: ActivityType.Competing,
COMPETING: ActivityType.Competing
});
// script.setParent(DiscordUtil);
script.load();
#end
}
public static function changePresence(details:String, state:String, ?smallImageKey:String)
@@ -218,6 +232,8 @@ final class DiscordUtil
Utils.safeSetWrapper(dp.joinSecret, data.joinSecret, fixString);
Utils.safeSetWrapper(dp.spectateSecret, data.spectateSecret, fixString);
Utils.safeSet(dp.instance, data.instance);
Utils.safeSet(dp.activityType, data.activityType);
Utils.safeSetWrapper(dp.streamUrl, data.streamUrl, fixString);
if (data.matchSecret == null && data.joinSecret == null && data.spectateSecret == null)
{
Utils.safeSetWrapper(dp.button1Label, data.button1Label, fixString);
@@ -476,6 +492,8 @@ typedef DPresence =
var ?button1Url:String; /* max 512 bytes */
var ?button2Label:String; /* max 32 bytes */
var ?button2Url:String; /* max 512 bytes */
var ?activityType:ActivityType;
var ?streamUrl:String; /* max 512 bytes */
}
typedef DEvents =
@@ -5,6 +5,8 @@ import flixel.util.FlxColor;
import funkin.backend.chart.ChartData.ChartEvent;
import funkin.backend.chart.EventsData;
import funkin.backend.system.Conductor;
import funkin.game.Character;
import funkin.game.Stage;
using StringTools;
@@ -163,6 +165,20 @@ class CharterEventScreen extends UISubstateWindow {
var dropdown = new UIDropDown(eventName.x, y, 320, 32, options, Std.int(Math.abs(options.indexOf(cast value))));
paramsPanel.add(dropdown); paramsFields.push(dropdown);
dropdown;
case TCharacter:
addLabel();
var charFileList = Character.getList(false);
var textBox:UIAutoCompleteTextBox = new UIAutoCompleteTextBox(eventName.x, y, cast value);
textBox.suggestItems = charFileList;
paramsPanel.add(textBox); paramsFields.push(textBox);
textBox;
case TStage:
addLabel();
var stageFileList = Stage.getList(false);
var textBox:UIAutoCompleteTextBox = new UIAutoCompleteTextBox(eventName.x, y, cast value);
textBox.suggestItems = stageFileList;
paramsPanel.add(textBox); paramsFields.push(textBox);
textBox;
default:
paramsFields.push(null);
null;
+13 -1
View File
@@ -24,6 +24,11 @@ class HealthIcon extends FlxSprite
*/
public var healthSteps:Map<Int, Int> = null;
/**
* current animation state
*/
public var curAnimState:Int = -1;
/**
* Helper for HScript who can't make maps
* @param steps Something like this: `[[0, 1], [20, 0]]`
@@ -91,7 +96,14 @@ class HealthIcon extends FlxSprite
i = icon;
}
}
if (i >= 0) animation.curAnim.curFrame = i;
if (i >= 0 && curAnimState != i) {
var event = EventManager.get(funkin.backend.scripting.events.HealthIconChangeEvent).recycle(i, this);
funkin.backend.scripting.GlobalScript.event("onHealthIconAnimChange", event);
if (!event.cancelled)
animation.curAnim.curFrame = event.amount;
curAnimState = event.amount;
}
}
}
}
+2
View File
@@ -1425,6 +1425,8 @@ class PlayState extends MusicBeatState
FlxG.sound.music.stop();
for (strumLine in strumLines.members) strumLine.vocals.stop();
deathCounter++;
openSubState(new GameOverSubstate(event.x, event.y, event.deathCharID, event.isPlayer, event.gameOverSong, event.lossSFX, event.retrySFX));
scripts.event("onPostGameOver", event);
+4 -1
View File
@@ -40,7 +40,10 @@ class SplashHandler extends FlxTypedGroup<FunkinSprite> {
var __grp:SplashGroup;
public function showSplash(name:String, strum:Strum) {
__grp = getSplashGroup(name);
add(__grp.showOnStrum(strum));
var event = funkin.backend.scripting.EventManager.get(funkin.backend.scripting.events.DynamicEvent).recycle(__grp.showOnStrum(strum), strum);
event = PlayState.instance.scripts.event("onSplashShown", event);
if (!event.cancelled)
add(event.value1);
// max 8 rendered splashes
while(members.length > 8)
+2
View File
@@ -14,6 +14,8 @@ class Strum extends FlxSprite {
public var cpu = false; // Unused
public var lastHit:Float = -5000;
public var strumLine = null;
public var scrollSpeed:Null<Float> = null; // custom scroll speed per strum
public var noteAngle:Null<Float> = null;
+1
View File
@@ -303,6 +303,7 @@ class StrumLine extends FlxTypedGroup<Strum> {
animPrefix = strumAnimPrefix[i % strumAnimPrefix.length];
var babyArrow:Strum = new Strum(startingPos.x + ((Note.swagWidth * strumScale) * i), startingPos.y);
babyArrow.ID = i;
babyArrow.strumLine = this;
if(data.scrollSpeed != null)
babyArrow.scrollSpeed = data.scrollSpeed;