From 6c836eae7170fe844e504a4779ccbd3928ed6be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sat, 8 Mar 2025 19:04:19 +0100 Subject: [PATCH] resize fixes + starting global and local events will continue later --- source/funkin/backend/MusicBeatTransition.hx | 43 ++++++++++++------- source/funkin/editors/EditorTreeMenu.hx | 12 ------ source/funkin/editors/charter/Charter.hx | 4 +- .../funkin/editors/charter/CharterEventAdd.hx | 4 +- source/funkin/options/OptionsScreen.hx | 2 +- source/funkin/options/TreeMenu.hx | 30 ++++++++++--- source/funkin/options/type/NewOption.hx | 2 +- 7 files changed, 59 insertions(+), 38 deletions(-) diff --git a/source/funkin/backend/MusicBeatTransition.hx b/source/funkin/backend/MusicBeatTransition.hx index 0cb44df0..1a1897fd 100644 --- a/source/funkin/backend/MusicBeatTransition.hx +++ b/source/funkin/backend/MusicBeatTransition.hx @@ -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]); diff --git a/source/funkin/editors/EditorTreeMenu.hx b/source/funkin/editors/EditorTreeMenu.hx index a35bdd98..6a22e54e 100644 --- a/source/funkin/editors/EditorTreeMenu.hx +++ b/source/funkin/editors/EditorTreeMenu.hx @@ -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; diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 5f478163..282aae02 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -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); diff --git a/source/funkin/editors/charter/CharterEventAdd.hx b/source/funkin/editors/charter/CharterEventAdd.hx index a286edf7..b5e4d5ce 100644 --- a/source/funkin/editors/charter/CharterEventAdd.hx +++ b/source/funkin/editors/charter/CharterEventAdd.hx @@ -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); } diff --git a/source/funkin/options/OptionsScreen.hx b/source/funkin/options/OptionsScreen.hx index b703d994..4a5eb806 100644 --- a/source/funkin/options/OptionsScreen.hx +++ b/source/funkin/options/OptionsScreen.hx @@ -36,7 +36,7 @@ class OptionsScreen extends FlxTypedSpriteGroup { 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; diff --git a/source/funkin/options/TreeMenu.hx b/source/funkin/options/TreeMenu.hx index 92540656..b7bbde3e 100644 --- a/source/funkin/options/TreeMenu.hx +++ b/source/funkin/options/TreeMenu.hx @@ -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 = 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)); } diff --git a/source/funkin/options/type/NewOption.hx b/source/funkin/options/type/NewOption.hx index 6804608b..0008566e 100644 --- a/source/funkin/options/type/NewOption.hx +++ b/source/funkin/options/type/NewOption.hx @@ -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); } } \ No newline at end of file