Merge remote-tracking branch 'upstream/main'
This commit is contained in:
@@ -2,14 +2,23 @@ package funkin.backend;
|
||||
|
||||
import flixel.FlxState;
|
||||
import flixel.tweens.FlxTween;
|
||||
import funkin.backend.scripting.Script;
|
||||
import funkin.backend.scripting.events.CancellableEvent;
|
||||
import funkin.backend.scripting.events.TransitionCreationEvent;
|
||||
import funkin.backend.utils.FunkinParentDisabler;
|
||||
|
||||
class MusicBeatTransition extends MusicBeatSubstate {
|
||||
public static var script:String = "";
|
||||
public var transitionScript:Script;
|
||||
|
||||
var nextFrameSkip:Bool = false;
|
||||
|
||||
public var transitionTween:FlxTween = null;
|
||||
public var transitionCamera:FlxCamera;
|
||||
public var newState:FlxState;
|
||||
public var transOut:Bool = false;
|
||||
|
||||
public var allowSkip:Bool = true;
|
||||
|
||||
public var blackSpr:FlxSprite;
|
||||
public var transitionSprite:FunkinSprite;
|
||||
@@ -20,16 +29,30 @@ class MusicBeatTransition extends MusicBeatSubstate {
|
||||
|
||||
public override function create() {
|
||||
if (newState != null)
|
||||
add(new FunkinParentDisabler(true));
|
||||
add(new FunkinParentDisabler(true, false));
|
||||
|
||||
transitionCamera = new FlxCamera();
|
||||
transitionCamera.bgColor = 0;
|
||||
FlxG.cameras.add(transitionCamera, false);
|
||||
|
||||
cameras = [transitionCamera];
|
||||
var out = newState != null;
|
||||
|
||||
blackSpr = new FlxSprite(0, out ? -transitionCamera.height : transitionCamera.height).makeGraphic(1, 1, -1);
|
||||
transitionScript = Script.create(Paths.script(script));
|
||||
transitionScript.setParent(this);
|
||||
transitionScript.load();
|
||||
|
||||
var event = EventManager.get(TransitionCreationEvent).recycle(newState != null, newState);
|
||||
transitionScript.call('create', [event]);
|
||||
|
||||
transOut = event.transOut;
|
||||
newState = event.newState;
|
||||
|
||||
if (event.cancelled) {
|
||||
super.create();
|
||||
return;
|
||||
}
|
||||
|
||||
blackSpr = new FlxSprite(0, transOut ? -transitionCamera.height : transitionCamera.height).makeGraphic(1, 1, -1);
|
||||
blackSpr.scale.set(transitionCamera.width, transitionCamera.height);
|
||||
blackSpr.color = 0xFF000000;
|
||||
blackSpr.updateHitbox();
|
||||
@@ -43,7 +66,7 @@ class MusicBeatTransition extends MusicBeatSubstate {
|
||||
} else {
|
||||
transitionSprite.screenCenter();
|
||||
}
|
||||
transitionCamera.flipY = !out;
|
||||
transitionCamera.flipY = !transOut;
|
||||
add(transitionSprite);
|
||||
|
||||
transitionCamera.scroll.y = transitionCamera.height;
|
||||
@@ -55,41 +78,59 @@ class MusicBeatTransition extends MusicBeatSubstate {
|
||||
});
|
||||
|
||||
super.create();
|
||||
transitionScript.call('postCreate', [event]);
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
transitionScript.call('update', [elapsed]);
|
||||
super.update(elapsed);
|
||||
|
||||
if (nextFrameSkip) {
|
||||
finish();
|
||||
return;
|
||||
var event = new CancellableEvent();
|
||||
transitionScript.call('onSkip', [event]);
|
||||
if (!event.cancelled) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!parent.persistentUpdate && FlxG.keys.pressed.SHIFT) {
|
||||
if (allowSkip && !parent.persistentUpdate && FlxG.keys.pressed.SHIFT) {
|
||||
// skip
|
||||
if (newState != null) {
|
||||
nextFrameSkip = true;
|
||||
parent.persistentDraw = false;
|
||||
} else {
|
||||
finish();
|
||||
var event = new CancellableEvent();
|
||||
transitionScript.call('onSkip', [event]);
|
||||
if (!event.cancelled) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
transitionScript.call('postUpdate', [elapsed]);
|
||||
}
|
||||
|
||||
public function finish() {
|
||||
var event = new CancellableEvent();
|
||||
transitionScript.call('onFinish', [event]);
|
||||
if (event.cancelled) return;
|
||||
|
||||
if (newState != null)
|
||||
FlxG.switchState(newState);
|
||||
close();
|
||||
|
||||
transitionScript.call('onPostFinish');
|
||||
}
|
||||
|
||||
public override function destroy() {
|
||||
if (transitionTween != null)
|
||||
transitionTween.cancel();
|
||||
transitionScript.call('destroy');
|
||||
|
||||
if (transitionTween != null) transitionTween.cancel();
|
||||
transitionTween = FlxDestroyUtil.destroy(transitionTween);
|
||||
if (newState == null && FlxG.cameras.list.contains(transitionCamera))
|
||||
FlxG.cameras.remove(transitionCamera);
|
||||
else
|
||||
transitionCamera.bgColor = 0xFF000000;
|
||||
if (newState == null && FlxG.cameras.list.contains(transitionCamera)) FlxG.cameras.remove(transitionCamera);
|
||||
else transitionCamera.bgColor = 0xFF000000;
|
||||
|
||||
transitionScript.destroy();
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package funkin.backend.scripting.events;
|
||||
|
||||
import flixel.FlxState;
|
||||
|
||||
/**
|
||||
* CANCEL this event to prevent default behaviour!
|
||||
*/
|
||||
final class TransitionCreationEvent extends CancellableEvent {
|
||||
/**
|
||||
* If the transition is going out into another state
|
||||
*/
|
||||
public var transOut:Bool;
|
||||
|
||||
/**
|
||||
* The state that is about to be loaded (only on trans out)
|
||||
*/
|
||||
public var newState:FlxState;
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
@@ -58,6 +58,7 @@ class MainState extends FlxState {
|
||||
|
||||
Flags.load();
|
||||
ModsFolder.onModSwitch.dispatch(ModsFolder.currentModFolder); // Loads global.hx
|
||||
MusicBeatTransition.script = "";
|
||||
Main.refreshAssets();
|
||||
DiscordUtil.init();
|
||||
EventsData.reloadEvents();
|
||||
|
||||
@@ -4,7 +4,7 @@ import flixel.sound.FlxSound;
|
||||
import lime.media.AudioBuffer;
|
||||
|
||||
// Thank you yosh :DDD -lunar
|
||||
// (https://github.com/FNF-CNE-Devs/YoshiCrafterEngine/blob/main/source/WaveformSprite.hx)
|
||||
// (https://github.com/CodenameCrew/YoshiCrafterEngine/blob/main/source/WaveformSprite.hx)
|
||||
class AudioAnalyzer {
|
||||
public var buffer:AudioBuffer;
|
||||
var __peakByte:Float = 0;
|
||||
|
||||
@@ -19,9 +19,11 @@ class FunkinParentDisabler extends FlxBasic {
|
||||
var __timers:Array<FlxTimer>;
|
||||
var __sounds:Array<FlxSound>;
|
||||
var __replaceUponDestroy:Bool;
|
||||
public function new(replaceUponDestroy:Bool = false) {
|
||||
var __restoreUponDestroy:Bool;
|
||||
public function new(replaceUponDestroy:Bool = false, restoreUponDestroy:Bool = true) {
|
||||
super();
|
||||
__replaceUponDestroy = replaceUponDestroy;
|
||||
__restoreUponDestroy = restoreUponDestroy;
|
||||
@:privateAccess {
|
||||
// tweens
|
||||
__tweens = FlxTween.globalManager._tweens.copy();
|
||||
@@ -53,6 +55,11 @@ class FunkinParentDisabler extends FlxBasic {
|
||||
public override function destroy() {
|
||||
super.destroy();
|
||||
@:privateAccess {
|
||||
if (!__restoreUponDestroy) {
|
||||
for(t in __tweens) { t.cancel(); t.destroy(); };
|
||||
for(t in __timers) { t.cancel(); t.destroy(); };
|
||||
return;
|
||||
}
|
||||
if (__replaceUponDestroy) {
|
||||
FlxTween.globalManager._tweens = __tweens;
|
||||
FlxTimer.globalManager._timers = __timers;
|
||||
|
||||
@@ -147,8 +147,8 @@ class XMLUtil {
|
||||
var graphicSizey:Null<Int> = Std.parseInt(node.att.graphicSizey);
|
||||
if (graphicSizey.isNotNull()) spr.setGraphicSize(0, graphicSizey);
|
||||
}
|
||||
|
||||
if (node.has.flipX && node.att.flipX == "true") spr.flipX = true;
|
||||
if (node.has.flipX) spr.flipX = node.att.flipX == "true";
|
||||
if (node.has.flipY) spr.flipY = node.att.flipY == "true";
|
||||
if (node.has.updateHitbox && node.att.updateHitbox == "true") spr.updateHitbox();
|
||||
|
||||
if (node.has.zoomfactor)
|
||||
@@ -400,4 +400,4 @@ typedef BeatAnim = {
|
||||
|
||||
interface IXMLEvents {
|
||||
public function onPropertySet(property:String, value:Dynamic):Void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
||||
public function updatePos(step:Float, id:Int, susLength:Float = 0, ?type:Int = 0, ?strumLine:CharterStrumline = null) {
|
||||
this.step = step;
|
||||
this.id = id;
|
||||
this.susLength = susLength;
|
||||
this.susLength = Math.max(susLength, 0);
|
||||
this.type = type;
|
||||
if (strumLine != null) this.strumLine = strumLine;
|
||||
|
||||
|
||||
@@ -119,12 +119,21 @@ class UITextBox extends UISliceSprite implements IUIFocusable {
|
||||
case END:
|
||||
position = label.text.length;
|
||||
case V:
|
||||
if (modifier == KeyModifier.LEFT_CTRL || modifier == KeyModifier.RIGHT_CTRL) {
|
||||
// paste
|
||||
var data:String = Clipboard.generalClipboard.getData(TEXT_FORMAT);
|
||||
if (data != null)
|
||||
onTextInput(data);
|
||||
}
|
||||
// Hey lj here, fixed copying because before we checked if the modifier was left or right ctrl
|
||||
// but somehow it gave a int outside of the KeyModifier's range :sob:
|
||||
// apparently there is a boolean that just checks for you. yw :D
|
||||
|
||||
// if we are not holding ctrl, ignore
|
||||
if (!modifier.ctrlKey) return;
|
||||
// we pasting
|
||||
var data:String = Clipboard.generalClipboard.getData(TEXT_FORMAT);
|
||||
if (data != null) onTextInput(data);
|
||||
case C:
|
||||
// if we are not holding ctrl, ignore
|
||||
if (!modifier.ctrlKey) return;
|
||||
|
||||
// copying
|
||||
Clipboard.generalClipboard.setData(TEXT_FORMAT, label.text);
|
||||
default:
|
||||
// nothing
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user