From 983466c0feb080bb591799fb6649ba82592786ee Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 27 Jun 2023 15:21:09 -0400 Subject: [PATCH 01/17] Visual fixes for story menu --- source/funkin/ui/story/Level.hx | 35 ++++++++-- source/funkin/ui/story/StoryMenuState.hx | 89 +++++++++++++++++------- 2 files changed, 90 insertions(+), 34 deletions(-) diff --git a/source/funkin/ui/story/Level.hx b/source/funkin/ui/story/Level.hx index 83682fec9..b936ab513 100644 --- a/source/funkin/ui/story/Level.hx +++ b/source/funkin/ui/story/Level.hx @@ -93,19 +93,40 @@ class Level implements IRegistryEntry return true; } + /** + * Build a sprite for the background of the level. + * Can be overriden by ScriptedLevel. Not used if `isBackgroundSimple` returns true. + */ public function buildBackground():FlxSprite { - if (_data.background.startsWith('#')) - { - // Color specified - var color:FlxColor = FlxColor.fromString(_data.background); - return new FlxSprite().makeGraphic(FlxG.width, 400, color); - } - else + if (!_data.background.startsWith('#')) { // Image specified return new FlxSprite().loadGraphic(Paths.image(_data.background)); } + + // Color specified + var result:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, 400, FlxColor.WHITE); + result.color = getBackgroundColor(); + return result; + } + + /** + * Returns true if the background is a solid color. + * If you have a ScriptedLevel with a fancy background, you may want to override this to false. + */ + public function isBackgroundSimple():Bool + { + return _data.background.startsWith('#'); + } + + /** + * Returns true if the background is a solid color. + * If you have a ScriptedLevel with a fancy background, you may want to override this to false. + */ + public function getBackgroundColor():FlxColor + { + return FlxColor.fromString(_data.background); } public function getDifficulties():Array diff --git a/source/funkin/ui/story/StoryMenuState.hx b/source/funkin/ui/story/StoryMenuState.hx index 1dc59f3ec..853d5ecc0 100644 --- a/source/funkin/ui/story/StoryMenuState.hx +++ b/source/funkin/ui/story/StoryMenuState.hx @@ -145,6 +145,10 @@ class StoryMenuState extends MusicBeatState updateBackground(); + var black:FlxSprite = new FlxSprite(levelBackground.x, 0).makeGraphic(FlxG.width, Std.int(400 + levelBackground.y), FlxColor.BLACK); + black.zIndex = levelBackground.zIndex - 1; + add(black); + levelProps = new FlxTypedGroup(); levelProps.zIndex = 1000; add(levelProps); @@ -378,6 +382,7 @@ class StoryMenuState extends MusicBeatState if (currentIndex < 0) currentIndex = levelList.length - 1; if (currentIndex >= levelList.length) currentIndex = 0; + var previousLevelId:String = currentLevelId; currentLevelId = levelList[currentIndex]; updateData(); @@ -393,18 +398,14 @@ class StoryMenuState extends MusicBeatState currentLevelTitle = item; item.alpha = 1.0; } - else if (index > currentIndex) - { - item.alpha = 0.6; - } else { - item.alpha = 0.0; + item.alpha = 0.6; } } updateText(); - updateBackground(); + updateBackground(previousLevelId); updateProps(); refresh(); } @@ -517,32 +518,66 @@ class StoryMenuState extends MusicBeatState }); } - function updateBackground():Void + function updateBackground(?previousLevelId:String = ''):Void { - if (levelBackground != null) + if (levelBackground == null || previousLevelId == '') { - var oldBackground:FlxSprite = levelBackground; - - FlxTween.tween(oldBackground, {alpha: 0.0}, 0.6, - { - ease: FlxEase.linear, - onComplete: function(_) { - remove(oldBackground); - } - }); + // Build a new background and display it immediately. + levelBackground = currentLevel.buildBackground(); + levelBackground.x = 0; + levelBackground.y = 56; + levelBackground.zIndex = 100; + levelBackground.alpha = 1.0; // Not hidden. + add(levelBackground); } + else + { + var previousLevel = LevelRegistry.instance.fetchEntry(previousLevelId); - levelBackground = currentLevel.buildBackground(); - levelBackground.x = 0; - levelBackground.y = 56; - levelBackground.alpha = 0.0; - levelBackground.zIndex = 100; - add(levelBackground); - - FlxTween.tween(levelBackground, {alpha: 1.0}, 0.6, + if (currentLevel.isBackgroundSimple() && previousLevel.isBackgroundSimple()) { - ease: FlxEase.linear - }); + var previousColor:FlxColor = previousLevel.getBackgroundColor(); + var currentColor:FlxColor = currentLevel.getBackgroundColor(); + if (previousColor != currentColor) + { + // Both the previous and current level were simple backgrounds. + // Fade between colors directly, rather than fading one background out and another in. + FlxTween.color(levelBackground, 0.4, previousColor, currentColor); + } + else + { + // Do no fade at all if the colors aren't different. + } + } + else + { + // Either the previous or current level has a complex background. + // We need to fade the old background out and the new one in. + + // Reference the old background and fade it out. + var oldBackground:FlxSprite = levelBackground; + FlxTween.tween(oldBackground, {alpha: 0.0}, 0.6, + { + ease: FlxEase.linear, + onComplete: function(_) { + remove(oldBackground); + } + }); + + // Build a new background and fade it in. + levelBackground = currentLevel.buildBackground(); + levelBackground.x = 0; + levelBackground.y = 56; + levelBackground.alpha = 0.0; // Hidden to start. + levelBackground.zIndex = 100; + add(levelBackground); + + FlxTween.tween(levelBackground, {alpha: 1.0}, 0.6, + { + ease: FlxEase.linear + }); + } + } } function updateProps():Void From e157c23ea75c6ea6b49d2f2fcad53e7d528c43fb Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 30 Aug 2023 02:24:35 -0400 Subject: [PATCH 02/17] Apply @:nullSafety to chart editor classes. --- .../ui/debug/charting/ChartEditorCommand.hx | 16 ++++++++++++++++ .../debug/charting/ChartEditorDialogHandler.hx | 1 + .../ui/debug/charting/ChartEditorEventSprite.hx | 1 + .../debug/charting/ChartEditorHoldNoteSprite.hx | 1 + .../ui/debug/charting/ChartEditorNotePreview.hx | 1 + .../ui/debug/charting/ChartEditorNoteSprite.hx | 1 + .../ui/debug/charting/ChartEditorThemeHandler.hx | 1 + 7 files changed, 22 insertions(+) diff --git a/source/funkin/ui/debug/charting/ChartEditorCommand.hx b/source/funkin/ui/debug/charting/ChartEditorCommand.hx index fd179c481..5b2fb6053 100644 --- a/source/funkin/ui/debug/charting/ChartEditorCommand.hx +++ b/source/funkin/ui/debug/charting/ChartEditorCommand.hx @@ -35,6 +35,7 @@ interface ChartEditorCommand public function toString():String; } +@:nullSafety class AddNotesCommand implements ChartEditorCommand { var notes:Array; @@ -98,6 +99,7 @@ class AddNotesCommand implements ChartEditorCommand } } +@:nullSafety class RemoveNotesCommand implements ChartEditorCommand { var notes:Array; @@ -153,6 +155,7 @@ class RemoveNotesCommand implements ChartEditorCommand /** * Appends one or more items to the selection. */ +@:nullSafety class SelectItemsCommand implements ChartEditorCommand { var notes:Array; @@ -220,6 +223,7 @@ class SelectItemsCommand implements ChartEditorCommand } } +@:nullSafety class AddEventsCommand implements ChartEditorCommand { var events:Array; @@ -278,6 +282,7 @@ class AddEventsCommand implements ChartEditorCommand } } +@:nullSafety class RemoveEventsCommand implements ChartEditorCommand { var events:Array; @@ -327,6 +332,7 @@ class RemoveEventsCommand implements ChartEditorCommand } } +@:nullSafety class RemoveItemsCommand implements ChartEditorCommand { var notes:Array; @@ -385,6 +391,7 @@ class RemoveItemsCommand implements ChartEditorCommand } } +@:nullSafety class SwitchDifficultyCommand implements ChartEditorCommand { var prevDifficulty:String; @@ -424,6 +431,7 @@ class SwitchDifficultyCommand implements ChartEditorCommand } } +@:nullSafety class DeselectItemsCommand implements ChartEditorCommand { var notes:Array; @@ -478,6 +486,7 @@ class DeselectItemsCommand implements ChartEditorCommand * Sets the selection rather than appends it. * Deselects any notes that are not in the new selection. */ +@:nullSafety class SetItemSelectionCommand implements ChartEditorCommand { var notes:Array; @@ -518,6 +527,7 @@ class SetItemSelectionCommand implements ChartEditorCommand } } +@:nullSafety class SelectAllItemsCommand implements ChartEditorCommand { var previousNoteSelection:Array; @@ -553,6 +563,7 @@ class SelectAllItemsCommand implements ChartEditorCommand } } +@:nullSafety class InvertSelectedItemsCommand implements ChartEditorCommand { var previousNoteSelection:Array; @@ -587,6 +598,7 @@ class InvertSelectedItemsCommand implements ChartEditorCommand } } +@:nullSafety class DeselectAllItemsCommand implements ChartEditorCommand { var previousNoteSelection:Array; @@ -622,6 +634,7 @@ class DeselectAllItemsCommand implements ChartEditorCommand } } +@:nullSafety class CutItemsCommand implements ChartEditorCommand { var notes:Array; @@ -679,6 +692,7 @@ class CutItemsCommand implements ChartEditorCommand } } +@:nullSafety class FlipNotesCommand implements ChartEditorCommand { var notes:Array; @@ -729,6 +743,7 @@ class FlipNotesCommand implements ChartEditorCommand } } +@:nullSafety class PasteItemsCommand implements ChartEditorCommand { var targetTimestamp:Float; @@ -787,6 +802,7 @@ class PasteItemsCommand implements ChartEditorCommand } } +@:nullSafety class ExtendNoteLengthCommand implements ChartEditorCommand { var note:SongNoteData; diff --git a/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx b/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx index 63dc8bd92..d3160a1a0 100644 --- a/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx +++ b/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx @@ -40,6 +40,7 @@ using Lambda; /** * Handles dialogs for the new Chart Editor. */ +@:nullSafety class ChartEditorDialogHandler { static final CHART_EDITOR_DIALOG_ABOUT_LAYOUT:String = Paths.ui('chart-editor/dialogs/about'); diff --git a/source/funkin/ui/debug/charting/ChartEditorEventSprite.hx b/source/funkin/ui/debug/charting/ChartEditorEventSprite.hx index 2524f014c..7c0a1e5d7 100644 --- a/source/funkin/ui/debug/charting/ChartEditorEventSprite.hx +++ b/source/funkin/ui/debug/charting/ChartEditorEventSprite.hx @@ -16,6 +16,7 @@ import funkin.play.song.SongData.SongEventData; * A event sprite that can be used to display a song event in a chart. * Designed to be used and reused efficiently. Has no gameplay functionality. */ +@:nullSafety class ChartEditorEventSprite extends FlxSprite { public static final DEFAULT_EVENT = 'Default'; diff --git a/source/funkin/ui/debug/charting/ChartEditorHoldNoteSprite.hx b/source/funkin/ui/debug/charting/ChartEditorHoldNoteSprite.hx index 5805874f6..4d37343ce 100644 --- a/source/funkin/ui/debug/charting/ChartEditorHoldNoteSprite.hx +++ b/source/funkin/ui/debug/charting/ChartEditorHoldNoteSprite.hx @@ -14,6 +14,7 @@ import funkin.play.song.SongData.SongNoteData; * A hold note sprite that can be used to display a note in a chart. * Designed to be used and reused efficiently. Has no gameplay functionality. */ +@:nullSafety class ChartEditorHoldNoteSprite extends SustainTrail { /** diff --git a/source/funkin/ui/debug/charting/ChartEditorNotePreview.hx b/source/funkin/ui/debug/charting/ChartEditorNotePreview.hx index 69655bfe5..be45676f2 100644 --- a/source/funkin/ui/debug/charting/ChartEditorNotePreview.hx +++ b/source/funkin/ui/debug/charting/ChartEditorNotePreview.hx @@ -10,6 +10,7 @@ import flixel.util.FlxSpriteUtil; /** * Handles the note scrollbar preview in the chart editor. */ +@:nullSafety class ChartEditorNotePreview extends FlxSprite { // diff --git a/source/funkin/ui/debug/charting/ChartEditorNoteSprite.hx b/source/funkin/ui/debug/charting/ChartEditorNoteSprite.hx index 0adbf1a20..f46d4c3fb 100644 --- a/source/funkin/ui/debug/charting/ChartEditorNoteSprite.hx +++ b/source/funkin/ui/debug/charting/ChartEditorNoteSprite.hx @@ -11,6 +11,7 @@ import funkin.play.song.SongData.SongNoteData; * A note sprite that can be used to display a note in a chart. * Designed to be used and reused efficiently. Has no gameplay functionality. */ +@:nullSafety class ChartEditorNoteSprite extends FlxSprite { /** diff --git a/source/funkin/ui/debug/charting/ChartEditorThemeHandler.hx b/source/funkin/ui/debug/charting/ChartEditorThemeHandler.hx index 9b1e82df1..e0ef33158 100644 --- a/source/funkin/ui/debug/charting/ChartEditorThemeHandler.hx +++ b/source/funkin/ui/debug/charting/ChartEditorThemeHandler.hx @@ -20,6 +20,7 @@ enum ChartEditorTheme /** * Static functions which handle building themed UI elements for a provided ChartEditorState. */ +@:nullSafety class ChartEditorThemeHandler { // TODO: There's probably a better system of organization for these colors. From c78c6439a6e47e7b4ed80054e7911ea4251c1eaf Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 31 Aug 2023 18:47:23 -0400 Subject: [PATCH 03/17] Filled out null safety checks. --- source/funkin/Conductor.hx | 16 +- source/funkin/input/TurboKeyHandler.hx | 2 +- source/funkin/play/PlayState.hx | 8 +- source/funkin/play/character/BaseCharacter.hx | 6 +- .../play/cutscene/dialogue/Conversation.hx | 8 +- .../play/cutscene/dialogue/DialogueBox.hx | 2 +- .../funkin/play/cutscene/dialogue/Speaker.hx | 8 +- source/funkin/play/notes/Strumline.hx | 2 +- source/funkin/play/notes/SustainTrail.hx | 2 +- source/funkin/play/song/SongValidator.hx | 2 +- .../ui/debug/charting/ChartEditorCommand.hx | 10 +- .../charting/ChartEditorDialogHandler.hx | 184 +++++++++++------- .../debug/charting/ChartEditorEventSprite.hx | 16 +- .../charting/ChartEditorHoldNoteSprite.hx | 4 +- .../debug/charting/ChartEditorNoteSprite.hx | 26 ++- .../ui/debug/charting/ChartEditorState.hx | 16 +- .../debug/charting/ChartEditorThemeHandler.hx | 1 + .../charting/ChartEditorToolboxHandler.hx | 141 +++++++++----- .../ui/haxeui/components/CharacterPlayer.hx | 2 +- source/funkin/util/Constants.hx | 2 +- 20 files changed, 285 insertions(+), 173 deletions(-) diff --git a/source/funkin/Conductor.hx b/source/funkin/Conductor.hx index 9bd668b69..b0ad6c221 100644 --- a/source/funkin/Conductor.hx +++ b/source/funkin/Conductor.hx @@ -47,7 +47,7 @@ class Conductor /** * Beats per minute of the current song at the current time. */ - public static var bpm(get, null):Float; + public static var bpm(get, never):Float; static function get_bpm():Float { @@ -67,7 +67,7 @@ class Conductor /** * Duration of a measure in milliseconds. Calculated based on bpm. */ - public static var measureLengthMs(get, null):Float; + public static var measureLengthMs(get, never):Float; static function get_measureLengthMs():Float { @@ -77,7 +77,7 @@ class Conductor /** * Duration of a beat (quarter note) in milliseconds. Calculated based on bpm. */ - public static var beatLengthMs(get, null):Float; + public static var beatLengthMs(get, never):Float; static function get_beatLengthMs():Float { @@ -88,14 +88,14 @@ class Conductor /** * Duration of a step (sixtennth note) in milliseconds. Calculated based on bpm. */ - public static var stepLengthMs(get, null):Float; + public static var stepLengthMs(get, never):Float; static function get_stepLengthMs():Float { return beatLengthMs / timeSignatureNumerator; } - public static var timeSignatureNumerator(get, null):Int; + public static var timeSignatureNumerator(get, never):Int; static function get_timeSignatureNumerator():Int { @@ -104,7 +104,7 @@ class Conductor return currentTimeChange.timeSignatureNum; } - public static var timeSignatureDenominator(get, null):Int; + public static var timeSignatureDenominator(get, never):Int; static function get_timeSignatureDenominator():Int { @@ -151,7 +151,7 @@ class Conductor public static var audioOffset:Float = 0; public static var offset:Float = 0; - public static var beatsPerMeasure(get, null):Float; + public static var beatsPerMeasure(get, never):Float; static function get_beatsPerMeasure():Float { @@ -159,7 +159,7 @@ class Conductor return stepsPerMeasure / Constants.STEPS_PER_BEAT; } - public static var stepsPerMeasure(get, null):Int; + public static var stepsPerMeasure(get, never):Int; static function get_stepsPerMeasure():Int { diff --git a/source/funkin/input/TurboKeyHandler.hx b/source/funkin/input/TurboKeyHandler.hx index 3719ff7cc..099d373b4 100644 --- a/source/funkin/input/TurboKeyHandler.hx +++ b/source/funkin/input/TurboKeyHandler.hx @@ -26,7 +26,7 @@ class TurboKeyHandler extends FlxBasic /** * Whether all of the keys for this handler are pressed. */ - public var allPressed(get, null):Bool; + public var allPressed(get, never):Bool; /** * Whether all of the keys for this handler are activated, diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index ed82d6e99..068f32f97 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -251,14 +251,14 @@ class PlayState extends MusicBeatSubState var overrideMusic:Bool = false; - public var isSubState(get, null):Bool; + public var isSubState(get, never):Bool; function get_isSubState():Bool { return this._parentState != null; } - public var isChartingMode(get, null):Bool; + public var isChartingMode(get, never):Bool; function get_isChartingMode():Bool { @@ -427,7 +427,7 @@ class PlayState extends MusicBeatSubState * Data for the current difficulty for the current song. * Includes chart data, scroll speed, and other information. */ - public var currentChart(get, null):SongDifficulty; + public var currentChart(get, never):SongDifficulty; function get_currentChart():SongDifficulty { @@ -439,7 +439,7 @@ class PlayState extends MusicBeatSubState * The internal ID of the currently active Stage. * Used to retrieve the data required to build the `currentStage`. */ - public var currentStageId(get, null):String; + public var currentStageId(get, never):String; function get_currentStageId():String { diff --git a/source/funkin/play/character/BaseCharacter.hx b/source/funkin/play/character/BaseCharacter.hx index c7b58c393..30b549fd3 100644 --- a/source/funkin/play/character/BaseCharacter.hx +++ b/source/funkin/play/character/BaseCharacter.hx @@ -66,7 +66,7 @@ class BaseCharacter extends Bopper * The offset between the corner of the sprite and the origin of the sprite (at the character's feet). * cornerPosition = stageData - characterOrigin */ - public var characterOrigin(get, null):FlxPoint; + public var characterOrigin(get, never):FlxPoint; function get_characterOrigin():FlxPoint { @@ -103,7 +103,7 @@ class BaseCharacter extends Bopper /** * The absolute position of the character's feet, at the bottom-center of the sprite. */ - public var feetPosition(get, null):FlxPoint; + public var feetPosition(get, never):FlxPoint; function get_feetPosition():FlxPoint { @@ -264,7 +264,7 @@ class BaseCharacter extends Bopper /** * The per-character camera offset. */ - var characterCameraOffsets(get, null):Array; + var characterCameraOffsets(get, never):Array; function get_characterCameraOffsets():Array { diff --git a/source/funkin/play/cutscene/dialogue/Conversation.hx b/source/funkin/play/cutscene/dialogue/Conversation.hx index a6851f0f9..2b7db381c 100644 --- a/source/funkin/play/cutscene/dialogue/Conversation.hx +++ b/source/funkin/play/cutscene/dialogue/Conversation.hx @@ -50,7 +50,7 @@ class Conversation extends FlxSpriteGroup implements IDialogueScriptedClass */ var currentDialogueEntry:Int = 0; - var currentDialogueEntryCount(get, null):Int; + var currentDialogueEntryCount(get, never):Int; function get_currentDialogueEntryCount():Int { @@ -62,14 +62,14 @@ class Conversation extends FlxSpriteGroup implements IDialogueScriptedClass * **/ var currentDialogueLine:Int = 0; - var currentDialogueLineCount(get, null):Int; + var currentDialogueLineCount(get, never):Int; function get_currentDialogueLineCount():Int { return currentDialogueEntryData.text.length; } - var currentDialogueEntryData(get, null):DialogueEntryData; + var currentDialogueEntryData(get, never):DialogueEntryData; function get_currentDialogueEntryData():DialogueEntryData { @@ -79,7 +79,7 @@ class Conversation extends FlxSpriteGroup implements IDialogueScriptedClass return conversationData.dialogue[currentDialogueEntry]; } - var currentDialogueLineString(get, null):String; + var currentDialogueLineString(get, never):String; function get_currentDialogueLineString():String { diff --git a/source/funkin/play/cutscene/dialogue/DialogueBox.hx b/source/funkin/play/cutscene/dialogue/DialogueBox.hx index bfc0e9233..cdac3c233 100644 --- a/source/funkin/play/cutscene/dialogue/DialogueBox.hx +++ b/source/funkin/play/cutscene/dialogue/DialogueBox.hx @@ -13,7 +13,7 @@ import flixel.util.FlxColor; class DialogueBox extends FlxSpriteGroup implements IDialogueScriptedClass { public final dialogueBoxId:String; - public var dialogueBoxName(get, null):String; + public var dialogueBoxName(get, never):String; function get_dialogueBoxName():String { diff --git a/source/funkin/play/cutscene/dialogue/Speaker.hx b/source/funkin/play/cutscene/dialogue/Speaker.hx index 1fb341009..d7ed004f1 100644 --- a/source/funkin/play/cutscene/dialogue/Speaker.hx +++ b/source/funkin/play/cutscene/dialogue/Speaker.hx @@ -8,7 +8,7 @@ import funkin.modding.IScriptedClass.IDialogueScriptedClass; /** * The character sprite which displays during dialogue. - * + * * Most conversations have two speakers, with one being flipped. */ class Speaker extends FlxSprite implements IDialogueScriptedClass @@ -26,7 +26,7 @@ class Speaker extends FlxSprite implements IDialogueScriptedClass /** * A readable name for this speaker. */ - public var speakerName(get, null):String; + public var speakerName(get, never):String; function get_speakerName():String { @@ -129,7 +129,7 @@ class Speaker extends FlxSprite implements IDialogueScriptedClass /** * Set the sprite scale to the appropriate value. - * @param scale + * @param scale */ public function setScale(scale:Null):Void { @@ -184,7 +184,7 @@ class Speaker extends FlxSprite implements IDialogueScriptedClass /** * Ensure that a given animation exists before playing it. * Will gracefully check for name, then name with stripped suffixes, then 'idle', then fail to play. - * @param name + * @param name */ function correctAnimationName(name:String):String { diff --git a/source/funkin/play/notes/Strumline.hx b/source/funkin/play/notes/Strumline.hx index 8847636bd..2b21e6b7e 100644 --- a/source/funkin/play/notes/Strumline.hx +++ b/source/funkin/play/notes/Strumline.hx @@ -31,7 +31,7 @@ class Strumline extends FlxSpriteGroup static final KEY_COUNT:Int = 4; static final NOTE_SPLASH_CAP:Int = 6; - static var RENDER_DISTANCE_MS(get, null):Float; + static var RENDER_DISTANCE_MS(get, never):Float; static function get_RENDER_DISTANCE_MS():Float { diff --git a/source/funkin/play/notes/SustainTrail.hx b/source/funkin/play/notes/SustainTrail.hx index 72d22191b..4bcbe0528 100644 --- a/source/funkin/play/notes/SustainTrail.hx +++ b/source/funkin/play/notes/SustainTrail.hx @@ -31,7 +31,7 @@ class SustainTrail extends FlxSprite public var noteDirection:NoteDirection = 0; public var sustainLength(default, set):Float = 0; // millis public var fullSustainLength:Float = 0; - public var noteData:SongNoteData; + public var noteData:Null; public var cover:NoteHoldCover = null; diff --git a/source/funkin/play/song/SongValidator.hx b/source/funkin/play/song/SongValidator.hx index 16ea88664..11cc758b9 100644 --- a/source/funkin/play/song/SongValidator.hx +++ b/source/funkin/play/song/SongValidator.hx @@ -20,7 +20,7 @@ class SongValidator public static final DEFAULT_STAGE:String = "mainStage"; public static final DEFAULT_SCROLLSPEED:Float = 1.0; - public static var DEFAULT_GENERATEDBY(get, null):String; + public static var DEFAULT_GENERATEDBY(get, never):String; static function get_DEFAULT_GENERATEDBY():String { diff --git a/source/funkin/ui/debug/charting/ChartEditorCommand.hx b/source/funkin/ui/debug/charting/ChartEditorCommand.hx index 5b2fb6053..f0ecb573b 100644 --- a/source/funkin/ui/debug/charting/ChartEditorCommand.hx +++ b/source/funkin/ui/debug/charting/ChartEditorCommand.hx @@ -695,12 +695,13 @@ class CutItemsCommand implements ChartEditorCommand @:nullSafety class FlipNotesCommand implements ChartEditorCommand { - var notes:Array; - var flippedNotes:Array; + var notes:Array = []; + var flippedNotes:Array = []; public function new(notes:Array) { this.notes = notes; + this.flippedNotes = SongDataUtils.flipNotes(notes); } public function execute(state:ChartEditorState):Void @@ -709,7 +710,6 @@ class FlipNotesCommand implements ChartEditorCommand state.currentSongChartNoteData = SongDataUtils.subtractNotes(state.currentSongChartNoteData, notes); // Add the flipped notes. - flippedNotes = SongDataUtils.flipNotes(notes); state.currentSongChartNoteData = state.currentSongChartNoteData.concat(flippedNotes); state.currentNoteSelection = flippedNotes; @@ -748,8 +748,8 @@ class PasteItemsCommand implements ChartEditorCommand { var targetTimestamp:Float; // Notes we added with this command, for undo. - var addedNotes:Array; - var addedEvents:Array; + var addedNotes:Array = []; + var addedEvents:Array = []; public function new(targetTimestamp:Float) { diff --git a/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx b/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx index d3160a1a0..d3711ae7f 100644 --- a/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx +++ b/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx @@ -60,7 +60,7 @@ class ChartEditorDialogHandler * @param state The current chart editor state. * @return The dialog that was opened. */ - public static inline function openAboutDialog(state:ChartEditorState):Dialog + public static inline function openAboutDialog(state:ChartEditorState):Null { return openDialog(state, CHART_EDITOR_DIALOG_ABOUT_LAYOUT, true, true); } @@ -71,12 +71,14 @@ class ChartEditorDialogHandler * @param closable Whether the dialog can be closed by the user. * @return The dialog that was opened. */ - public static function openWelcomeDialog(state:ChartEditorState, closable:Bool = true):Dialog + public static function openWelcomeDialog(state:ChartEditorState, closable:Bool = true):Null { - var dialog:Dialog = openDialog(state, CHART_EDITOR_DIALOG_WELCOME_LAYOUT, true, closable); + var dialog:Null = openDialog(state, CHART_EDITOR_DIALOG_WELCOME_LAYOUT, true, closable); + if (dialog == null) throw 'Could not locate Welcome dialog'; // Add handlers to the "Create From Song" section. - var linkCreateBasic:Link = dialog.findComponent('splashCreateFromSongBasic', Link); + var linkCreateBasic:Null = dialog.findComponent('splashCreateFromSongBasic', Link); + if (linkCreateBasic == null) throw 'Could not locate splashCreateFromSongBasic link in Welcome dialog'; linkCreateBasic.onClick = function(_event) { // Hide the welcome dialog dialog.hideDialog(DialogButton.CANCEL); @@ -87,7 +89,8 @@ class ChartEditorDialogHandler openCreateSongWizard(state, false); } - var linkImportChartLegacy:Link = dialog.findComponent('splashImportChartLegacy', Link); + var linkImportChartLegacy:Null = dialog.findComponent('splashImportChartLegacy', Link); + if (linkImportChartLegacy == null) throw 'Could not locate splashImportChartLegacy link in Welcome dialog'; linkImportChartLegacy.onClick = function(_event) { // Hide the welcome dialog dialog.hideDialog(DialogButton.CANCEL); @@ -96,7 +99,8 @@ class ChartEditorDialogHandler openImportChartWizard(state, 'legacy', false); }; - var buttonBrowse:Button = dialog.findComponent('splashBrowse', Button); + var buttonBrowse:Null