From d17243b1020b394fea774fcf029035cd79bbf330 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Thu, 27 Jul 2023 11:37:18 +0200 Subject: [PATCH] Cleanup + Fixes --- source/funkin/backend/system/Main.hx | 2 ++ source/funkin/editors/EditorPicker.hx | 7 ++++++ source/funkin/editors/UIDebugState.hx | 3 +-- .../editors/charter/CharterStrumlineScreen.hx | 17 ++++---------- source/funkin/editors/ui/UISliceSprite.hx | 20 ++++++++--------- source/funkin/editors/ui/UISubstateWindow.hx | 3 ++- source/funkin/editors/ui/UITextBox.hx | 15 ++++++++++--- source/funkin/editors/ui/UIWarningSubstate.hx | 22 ++++++++++++++++++- source/funkin/game/NoteGroup.hx | 2 +- source/funkin/game/StrumLine.hx | 2 +- source/funkin/menus/ModSwitchMenu.hx | 3 +-- source/funkin/menus/PauseSubState.hx | 3 +-- source/funkin/menus/StoryMenuState.hx | 6 ++--- source/funkin/menus/TitleState.hx | 2 +- 14 files changed, 66 insertions(+), 41 deletions(-) diff --git a/source/funkin/backend/system/Main.hx b/source/funkin/backend/system/Main.hx index e3c29ca8..78c76b97 100644 --- a/source/funkin/backend/system/Main.hx +++ b/source/funkin/backend/system/Main.hx @@ -166,6 +166,8 @@ class Main extends Sprite public static function refreshAssets() { FlxSoundTray.volumeChangeSFX = Paths.sound('menu/volume'); + FlxSoundTray.volumeUpChangeSFX = null; + FlxSoundTray.volumeDownChangeSFX = null; if (FlxG.game.soundTray != null) FlxG.game.soundTray.text.setTextFormat(new TextFormat(Paths.font("vcr.ttf"))); diff --git a/source/funkin/editors/EditorPicker.hx b/source/funkin/editors/EditorPicker.hx index 188756b3..52c74ae9 100644 --- a/source/funkin/editors/EditorPicker.hx +++ b/source/funkin/editors/EditorPicker.hx @@ -121,6 +121,13 @@ class EditorPicker extends MusicBeatSubstate { close(); } + override function destroy() { + super.destroy(); + + oldMousePos.put(); + curMousePos.put(); + } + public function changeSelection(change:Int) { if (change == 0) return; diff --git a/source/funkin/editors/UIDebugState.hx b/source/funkin/editors/UIDebugState.hx index 1320289d..2d02c197 100644 --- a/source/funkin/editors/UIDebugState.hx +++ b/source/funkin/editors/UIDebugState.hx @@ -8,8 +8,7 @@ class UIDebugState extends UIState { FlxG.mouse.useSystemCursor = FlxG.mouse.visible = true; - var bg = new FlxSprite().makeGraphic(1, 1, 0xFF444444); - bg.scale.set(FlxG.width, FlxG.height); + var bg = new FlxSprite().makeSolid(FlxG.width, FlxG.height, 0xFF444444); bg.updateHitbox(); bg.scrollFactor.set(); add(bg); diff --git a/source/funkin/editors/charter/CharterStrumlineScreen.hx b/source/funkin/editors/charter/CharterStrumlineScreen.hx index c3c978f1..7d0bfb50 100644 --- a/source/funkin/editors/charter/CharterStrumlineScreen.hx +++ b/source/funkin/editors/charter/CharterStrumlineScreen.hx @@ -76,29 +76,20 @@ class CharterStrumlineScreen extends UISubstateWindow { usesChartscrollSpeed.onChecked = function(b) { if(b) { - scrollSpeedStepper.alpha = 0.4; - scrollSpeedStepper.label.alpha = 0.4; scrollSpeedStepper.value = PlayState.SONG.scrollSpeed; - scrollSpeedStepper.active = false; + scrollSpeedStepper.selectable = false; } else { - scrollSpeedStepper.alpha = 1; - scrollSpeedStepper.label.alpha = 1; - scrollSpeedStepper.active = true; + scrollSpeedStepper.selectable = true; } - } add(usesChartscrollSpeed); scrollSpeedStepper = new UINumericStepper(typeDropdown.x, typeDropdown.y + 32 + 58, usesChartscrollSpeed.checked ? PlayState.SONG.scrollSpeed : strumLine.scrollSpeed, 0.1, 2, 0, 10, 82); if(usesChartscrollSpeed.checked) { - scrollSpeedStepper.alpha = 0.4; - scrollSpeedStepper.label.alpha = 0.4; - scrollSpeedStepper.active = false; + scrollSpeedStepper.selectable = false; } else { - scrollSpeedStepper.alpha = 1; - scrollSpeedStepper.label.alpha = 1; - scrollSpeedStepper.active = true; + scrollSpeedStepper.selectable = true; } add(scrollSpeedStepper); addLabelOn(scrollSpeedStepper, "Scroll Speed"); diff --git a/source/funkin/editors/ui/UISliceSprite.hx b/source/funkin/editors/ui/UISliceSprite.hx index 06f9eb09..1ce1e5c0 100644 --- a/source/funkin/editors/ui/UISliceSprite.hx +++ b/source/funkin/editors/ui/UISliceSprite.hx @@ -34,17 +34,17 @@ class UISliceSprite extends UISprite { var x:Float = this.x; var y:Float = this.y; - var topleft:FlxFrame = frames.frames[framesOffset]; - var top:FlxFrame = frames.frames[framesOffset + 1]; - var topright:FlxFrame = frames.frames[framesOffset + 2]; - var middleleft:FlxFrame = frames.frames[framesOffset + 3]; - var middle:FlxFrame = frames.frames[framesOffset + 4]; - var middleright:FlxFrame = frames.frames[framesOffset + 5]; - var bottomleft:FlxFrame = frames.frames[framesOffset + 6]; - var bottom:FlxFrame = frames.frames[framesOffset + 7]; - var bottomright:FlxFrame = frames.frames[framesOffset + 8]; - @:privateAccess if (visible) { + var topleft:FlxFrame = frames.frames[framesOffset]; + var top:FlxFrame = frames.frames[framesOffset + 1]; + var topright:FlxFrame = frames.frames[framesOffset + 2]; + var middleleft:FlxFrame = frames.frames[framesOffset + 3]; + var middle:FlxFrame = frames.frames[framesOffset + 4]; + var middleright:FlxFrame = frames.frames[framesOffset + 5]; + var bottomleft:FlxFrame = frames.frames[framesOffset + 6]; + var bottom:FlxFrame = frames.frames[framesOffset + 7]; + var bottomright:FlxFrame = frames.frames[framesOffset + 8]; + // TOP LEFT frame = topleft; setPosition(x, y); diff --git a/source/funkin/editors/ui/UISubstateWindow.hx b/source/funkin/editors/ui/UISubstateWindow.hx index 95d02abf..c1012ee9 100644 --- a/source/funkin/editors/ui/UISubstateWindow.hx +++ b/source/funkin/editors/ui/UISubstateWindow.hx @@ -7,7 +7,7 @@ import funkin.backend.shaders.CustomShader; // TODO: make UIWarningSubstate extend this class UISubstateWindow extends MusicBeatSubstate { var camShaders:Array = []; - var blurShader:CustomShader = Options.intensiveBlur ? new CustomShader("engine/editorBlur") : new CustomShader("engine/editorBlurFast"); + var blurShader:CustomShader = new CustomShader(Options.intensiveBlur ? "engine/editorBlur" : "engine/editorBlurFast"); var titleSpr:UIText; var messageSpr:UIText; @@ -30,6 +30,7 @@ class UISubstateWindow extends MusicBeatSubstate { super.create(); for(c in FlxG.cameras.list) { + // Prevent adding a shader if it already has one @:privateAccess if(c._filters != null) { var shouldSkip = false; for(filter in c._filters) { diff --git a/source/funkin/editors/ui/UITextBox.hx b/source/funkin/editors/ui/UITextBox.hx index 2d7661f1..ff86709f 100644 --- a/source/funkin/editors/ui/UITextBox.hx +++ b/source/funkin/editors/ui/UITextBox.hx @@ -37,7 +37,7 @@ class UITextBox extends UISliceSprite implements IUIFocusable { var cacheRect:Rectangle = new Rectangle(); public override function update(elapsed:Float) { - if (hovered && FlxG.mouse.justReleased && __lastDrawCameras.length > 0) { + if (selectable && hovered && FlxG.mouse.justReleased && __lastDrawCameras.length > 0) { // get caret pos var pos = FlxG.mouse.getScreenPosition(__lastDrawCameras[0], FlxPoint.get()); pos.x -= label.x; @@ -57,11 +57,20 @@ class UITextBox extends UISliceSprite implements IUIFocusable { } super.update(elapsed); + + var selected = selectable && focused; + + if(selectable) { + alpha = label.alpha = 1; + } else { + alpha = label.alpha = 0.4; + } + var off = multiline ? 4 : ((bHeight - label.height) / 2); label.follow(this, 4, off); - framesOffset = (focused ? 18 : (hovered ? 9 : 0)); + framesOffset = (selected ? 18 : (hovered ? 9 : 0)); @:privateAccess { - if (focused) { + if (selected) { __wasFocused = true; caretSpr.alpha = (FlxG.game.ticks % 666) >= 333 ? 1 : 0; diff --git a/source/funkin/editors/ui/UIWarningSubstate.hx b/source/funkin/editors/ui/UIWarningSubstate.hx index 2cf765f4..4c02617a 100644 --- a/source/funkin/editors/ui/UIWarningSubstate.hx +++ b/source/funkin/editors/ui/UIWarningSubstate.hx @@ -1,12 +1,13 @@ package funkin.editors.ui; +import openfl.filters.ShaderFilter; import flixel.tweens.FlxTween; import flixel.tweens.FlxEase; import funkin.backend.shaders.CustomShader; class UIWarningSubstate extends MusicBeatSubstate { var camShaders:Array = []; - var blurShader:CustomShader = Options.intensiveBlur ? new CustomShader("engine/editorBlur") : new CustomShader("engine/editorBlurFast"); + var blurShader:CustomShader = new CustomShader(Options.intensiveBlur ? "engine/editorBlur" : "engine/editorBlurFast"); var title:String; var message:String; @@ -25,6 +26,25 @@ class UIWarningSubstate extends MusicBeatSubstate { public override function create() { for(c in FlxG.cameras.list) { + // Prevent adding a shader if it already has one + @:privateAccess if(c._filters != null) { + var shouldSkip = false; + for(filter in c._filters) { + if(filter is ShaderFilter) { + var filter:ShaderFilter = cast filter; + if(filter.shader is CustomShader) { + var shader:CustomShader = cast filter.shader; + + if(shader.path == blurShader.path) { + shouldSkip = true; + break; + } + } + } + } + if(shouldSkip) + continue; + } camShaders.push(c); c.addShader(blurShader); } diff --git a/source/funkin/game/NoteGroup.hx b/source/funkin/game/NoteGroup.hx index 35c3ca02..dc066ea4 100644 --- a/source/funkin/game/NoteGroup.hx +++ b/source/funkin/game/NoteGroup.hx @@ -9,7 +9,7 @@ class NoteGroup extends FlxTypedGroup { var __currentlyLooping:Bool = false; /** - * Preallocates the members array with nulls, but if theres anything before it clears it + * Preallocates the members array with nulls, but if theres anything in the array already it clears it **/ public inline function preallocate(len:Int) { members = cast new haxe.ds.Vector(len); diff --git a/source/funkin/game/StrumLine.hx b/source/funkin/game/StrumLine.hx index af5f30cc..c44097db 100644 --- a/source/funkin/game/StrumLine.hx +++ b/source/funkin/game/StrumLine.hx @@ -233,7 +233,7 @@ class StrumLine extends FlxTypedGroup { __justPressed = CoolUtil.getDefault(event.justPressed, []); __justReleased = CoolUtil.getDefault(event.justReleased, []); - __notePerStrum = [for(_ in 0...members.length) null]; + __notePerStrum = cast new haxe.ds.Vector(members.length);//[for(_ in 0...members.length) null]; if (__pressed.contains(true)) { diff --git a/source/funkin/menus/ModSwitchMenu.hx b/source/funkin/menus/ModSwitchMenu.hx index 0b4d7ea2..51509ebc 100644 --- a/source/funkin/menus/ModSwitchMenu.hx +++ b/source/funkin/menus/ModSwitchMenu.hx @@ -14,8 +14,7 @@ class ModSwitchMenu extends MusicBeatSubstate { public override function create() { super.create(); - var bg = new FlxSprite(0, 0).makeGraphic(1, 1, 0xFF000000); - bg.scale.set(FlxG.width, FlxG.height); + var bg = new FlxSprite(0, 0).makeSolid(FlxG.width, FlxG.height, 0xFF000000); bg.updateHitbox(); bg.scrollFactor.set(); add(bg); diff --git a/source/funkin/menus/PauseSubState.hx b/source/funkin/menus/PauseSubState.hx index ba33cf6d..4de31238 100644 --- a/source/funkin/menus/PauseSubState.hx +++ b/source/funkin/menus/PauseSubState.hx @@ -60,8 +60,7 @@ class PauseSubState extends MusicBeatSubstate if (__cancelDefault = event.cancelled) return; - var bg:FlxSprite = new FlxSprite().makeGraphic(1, 1, FlxColor.BLACK); - bg.scale.set(FlxG.width, FlxG.height); + var bg:FlxSprite = new FlxSprite().makeSolid(FlxG.width, FlxG.height, FlxColor.BLACK); bg.updateHitbox(); bg.alpha = 0; bg.scrollFactor.set(); diff --git a/source/funkin/menus/StoryMenuState.hx b/source/funkin/menus/StoryMenuState.hx index 495edaf9..3716b43f 100644 --- a/source/funkin/menus/StoryMenuState.hx +++ b/source/funkin/menus/StoryMenuState.hx @@ -45,9 +45,8 @@ class StoryMenuState extends MusicBeatState { persistentUpdate = persistentDraw = true; // WEEK INFO - blackBar = new FlxSprite(0, 0).makeGraphic(1, 1, 0xFFFFFFFF); + blackBar = new FlxSprite(0, 0).makeSolid(FlxG.width, 56, 0xFFFFFFFF); blackBar.color = 0xFF000000; - blackBar.setGraphicSize(FlxG.width, 56); blackBar.updateHitbox(); scoreText = new FunkinText(10, 10, 0, "SCORE: -", 36); @@ -57,9 +56,8 @@ class StoryMenuState extends MusicBeatState { weekTitle.setFormat(Paths.font("vcr.ttf"), 32, FlxColor.WHITE, RIGHT); weekTitle.alpha = 0.7; - weekBG = new FlxSprite(0, 56).makeGraphic(1, 1, 0xFFFFFFFF); + weekBG = new FlxSprite(0, 56).makeSolid(FlxG.width, 400, 0xFFFFFFFF); weekBG.color = 0xFFF9CF51; - weekBG.setGraphicSize(FlxG.width, 400); weekBG.updateHitbox(); weekSprites = new FlxTypedGroup(); diff --git a/source/funkin/menus/TitleState.hx b/source/funkin/menus/TitleState.hx index d830c0b0..d46e04b9 100644 --- a/source/funkin/menus/TitleState.hx +++ b/source/funkin/menus/TitleState.hx @@ -66,7 +66,7 @@ class TitleState extends MusicBeatState persistentUpdate = true; - var bg:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK); + var bg:FlxSprite = new FlxSprite().makeSolid(FlxG.width, FlxG.height, FlxColor.BLACK); add(bg); #if TITLESCREEN_XML