resize fixes + starting global and local events
will continue later
This commit is contained in:
@@ -4,9 +4,10 @@ import flixel.FlxState;
|
||||
import flixel.tweens.FlxTween;
|
||||
import funkin.backend.scripting.Script;
|
||||
import funkin.backend.scripting.events.CancellableEvent;
|
||||
import funkin.backend.scripting.events.ResizeEvent;
|
||||
import funkin.backend.scripting.events.TransitionCreationEvent;
|
||||
import funkin.backend.utils.FunkinParentDisabler;
|
||||
|
||||
import funkin.editors.ui.UIState;
|
||||
class MusicBeatTransition extends MusicBeatSubstate {
|
||||
public static var script:String = Flags.DEFAULT_TRANSITION_SCRIPT;
|
||||
public var transitionScript:Script;
|
||||
@@ -52,23 +53,13 @@ class MusicBeatTransition extends MusicBeatSubstate {
|
||||
return;
|
||||
}
|
||||
|
||||
blackSpr = new FlxSprite(0, transOut ? -transitionCamera.height : transitionCamera.height).makeGraphic(1, 1, -1);
|
||||
blackSpr.scale.set(transitionCamera.width, transitionCamera.height);
|
||||
add(blackSpr = new FlxSprite(0, transOut ? -transitionCamera.height : transitionCamera.height).makeGraphic(1, 1, -1));
|
||||
blackSpr.color = 0xFF000000;
|
||||
blackSpr.updateHitbox();
|
||||
add(blackSpr);
|
||||
|
||||
transitionSprite = new FunkinSprite();
|
||||
add(transitionSprite = new FunkinSprite());
|
||||
transitionSprite.loadSprite(Paths.image('menus/transitionSpr'));
|
||||
if (transitionSprite.animateAtlas == null) {
|
||||
transitionSprite.setGraphicSize(transitionCamera.width, transitionCamera.height);
|
||||
transitionSprite.updateHitbox();
|
||||
} else {
|
||||
transitionSprite.screenCenter();
|
||||
}
|
||||
transitionCamera.flipY = !transOut;
|
||||
add(transitionSprite);
|
||||
resizeDefaultSprites();
|
||||
|
||||
transitionCamera.flipY = !transOut;
|
||||
transitionCamera.scroll.y = transitionCamera.height;
|
||||
transitionTween = FlxTween.tween(transitionCamera.scroll, {y: -transitionCamera.height}, 2/3, {
|
||||
ease: FlxEase.sineOut,
|
||||
@@ -110,6 +101,28 @@ class MusicBeatTransition extends MusicBeatSubstate {
|
||||
transitionScript.call('postUpdate', [elapsed]);
|
||||
}
|
||||
|
||||
public override function onResize(w:Int, h:Int) {
|
||||
super.onResize(w, h);
|
||||
if (FlxG.state is UIState && UIState.resolutionAware) resizeDefaultSprites();
|
||||
transitionScript.call('onResize', [EventManager.get(ResizeEvent).recycle(w, h, null, null)]);
|
||||
}
|
||||
|
||||
public function resizeDefaultSprites() {
|
||||
if (blackSpr != null) {
|
||||
blackSpr.scale.set(transitionCamera.width, transitionCamera.height);
|
||||
blackSpr.updateHitbox();
|
||||
}
|
||||
|
||||
if (transitionSprite != null) {
|
||||
if (transitionSprite.animateAtlas == null) {
|
||||
transitionSprite.setGraphicSize(transitionCamera.width, transitionCamera.height);
|
||||
transitionSprite.updateHitbox();
|
||||
} else {
|
||||
transitionSprite.screenCenter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function finish() {
|
||||
var event = new CancellableEvent();
|
||||
transitionScript.call('onFinish', [event]);
|
||||
|
||||
@@ -25,18 +25,6 @@ class EditorTreeMenu extends TreeMenu {
|
||||
FlxG.switchState(new MainMenuState());
|
||||
}
|
||||
|
||||
public override function onResize(width:Int, height:Int) {
|
||||
super.onResize(width, height);
|
||||
if (!UIState.resolutionAware) return;
|
||||
|
||||
if (width < FlxG.initialWidth || height < FlxG.initialHeight) {
|
||||
width = FlxG.initialWidth; height = FlxG.initialHeight;
|
||||
}
|
||||
|
||||
if (pathDesc != null && pathLabel != null)
|
||||
pathDesc.width = pathLabel.width = width - 8;
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
bg.x += elapsed * 125;
|
||||
|
||||
@@ -642,7 +642,7 @@ class Charter extends UIState {
|
||||
// Just for now until i add event stacking -lunar
|
||||
try {__relinkUndos();}
|
||||
catch (e) {Logs.trace('Failed to relink undos: ${Std.string(e)}', ERROR);}
|
||||
|
||||
|
||||
__applyPlaytestInfo();
|
||||
}
|
||||
|
||||
@@ -1791,7 +1791,7 @@ class Charter extends UIState {
|
||||
function _view_scrollreset(_) {
|
||||
sideScroll = 0;
|
||||
}
|
||||
|
||||
|
||||
inline function _snap_increasesnap(_) changequant(1);
|
||||
inline function _snap_decreasesnap(_) changequant(-1);
|
||||
inline function _snap_resetsnap(_) setquant(16);
|
||||
|
||||
@@ -33,7 +33,7 @@ class CharterEventAdd extends UISliceSprite {
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
|
||||
text.follow(this, global ? bWidth - text.width - (text.text == "Add event" ? 15 : 20) : 20, (bHeight - text.height) / 2);
|
||||
text.follow(this, global ? bWidth - text.width - 20 : 20, (bHeight - text.height) / 2);
|
||||
alpha = sprAlpha * 0.75;
|
||||
text.alpha = sprAlpha;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ class CharterEventAdd extends UISliceSprite {
|
||||
curCharterEvent = null;
|
||||
this.step = step;
|
||||
this.y = (step * 40) - (bHeight / 2);
|
||||
text.text = "Add event";
|
||||
text.text = "Add " + (global ? "global" : "local") + " event";
|
||||
framesOffset = 0; bWidth = 37 + Math.ceil(text.width);
|
||||
x = global ? Charter.instance.strumLines.members[Charter.instance.strumLines.members.length-1].x + (40*Charter.instance.strumLines.members[Charter.instance.strumLines.members.length-1].keyCount) : -(bWidth);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class OptionsScreen extends FlxTypedSpriteGroup<OptionType> {
|
||||
|
||||
option.selected = false;
|
||||
option.y = __firstFrame ? y : CoolUtil.fpsLerp(option.y, y, 0.25);
|
||||
option.x = x + (-50 + (Math.abs(Math.cos((option.y + (optionHeight / 2) - (FlxG.camera.scroll.y + (FlxG.height / 2))) / (FlxG.height * 1.25) * Math.PI)) * 150));
|
||||
option.x = x + (-50 + (Math.abs(Math.cos((option.y + (optionHeight / 2) - (FlxG.camera.scroll.y + (FlxG.camera.height / 2))) / (FlxG.camera.height * 1.25) * Math.PI)) * 150));
|
||||
}
|
||||
if (__firstFrame) {
|
||||
__firstFrame = false;
|
||||
|
||||
@@ -17,17 +17,23 @@ class TreeMenu extends UIState {
|
||||
public var pathDesc:FunkinText;
|
||||
public var pathBG:FlxSprite;
|
||||
|
||||
public var screenScroll(default, set):Float;
|
||||
private inline function set_screenScroll(val:Float) {
|
||||
FlxG.camera.scroll.x = val * FlxG.camera.width;
|
||||
return screenScroll = val;
|
||||
}
|
||||
|
||||
public static var lastState:Class<FlxState> = null; // Static for fixing the softlock bugs when resetting the state - Nex
|
||||
|
||||
public function new(scriptsAllowed:Bool = true, ?scriptName:String) {
|
||||
if(lastState == null) lastState = Type.getClass(FlxG.state);
|
||||
if (lastState == null) lastState = Type.getClass(FlxG.state);
|
||||
super(scriptsAllowed, scriptName);
|
||||
}
|
||||
|
||||
public override function createPost() {
|
||||
if (main == null) main = new OptionsScreen("Fallback Treemenu", "Please set the \"main\" variable in your extended class before createPost", [new TextOption("Oops! No Options", "This doesn't look like it was supposed to happen...", () -> FlxG.resetState() ) ]);
|
||||
|
||||
FlxG.camera.scroll.set(-FlxG.width, 0);
|
||||
screenScroll = -1;
|
||||
|
||||
pathLabel = new FunkinText(4, 4, FlxG.width - 8, "> Tree Menu", 32, true);
|
||||
pathLabel.borderSize = 1.25;
|
||||
@@ -65,10 +71,10 @@ class TreeMenu extends UIState {
|
||||
if (menuChangeTween != null)
|
||||
menuChangeTween.cancel();
|
||||
|
||||
menuChangeTween = FlxTween.tween(FlxG.camera.scroll, {x: FlxG.width * Math.max(0, (optionsTree.members.length-1))}, 1.5, {ease: menuTransitionEase, onComplete: function(t) {
|
||||
menuChangeTween = FlxTween.num(screenScroll, Math.max(0, (optionsTree.members.length-1)), 1.5, {ease: menuTransitionEase, onComplete: function(t) {
|
||||
optionsTree.clearLastMenu();
|
||||
menuChangeTween = null;
|
||||
}});
|
||||
}}, (val:Float) -> screenScroll = val);
|
||||
|
||||
var t = "";
|
||||
for(o in optionsTree.members)
|
||||
@@ -99,13 +105,27 @@ class TreeMenu extends UIState {
|
||||
var menuChangeTween:FlxTween;
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
|
||||
|
||||
Framerate.offset.y = pathBG.height;
|
||||
|
||||
// in case path gets so long it goes offscreen
|
||||
pathLabel.x = lerp(pathLabel.x, Math.max(0, FlxG.width - 4 - pathLabel.width), 0.125);
|
||||
}
|
||||
|
||||
public override function onResize(width:Int, height:Int) {
|
||||
super.onResize(width, height);
|
||||
if (!UIState.resolutionAware) return;
|
||||
|
||||
if (width < FlxG.initialWidth || height < FlxG.initialHeight) {
|
||||
width = FlxG.initialWidth; height = FlxG.initialHeight;
|
||||
}
|
||||
|
||||
screenScroll = screenScroll; // Updating the cam position - Nex
|
||||
|
||||
if (pathDesc != null && pathLabel != null)
|
||||
pathDesc.width = pathLabel.width = width - 8;
|
||||
}
|
||||
|
||||
public static inline function menuTransitionEase(e:Float)
|
||||
return FlxEase.quintInOut(FlxEase.cubeOut(e));
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class NewOption extends TextOption {
|
||||
iconSpr.setPosition(90 - iconSpr.width, (__text.height - iconSpr.height) / 2);
|
||||
iconSpr.scale.set(1.4, 1.4);
|
||||
iconSpr.updateHitbox();
|
||||
iconSpr.offset.set(20, -15);
|
||||
iconSpr.offset.set(15, -15);
|
||||
add(iconSpr);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user