From d50ff73d3ce42ec4b4d11d0662402f81c039f1b3 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 22 Mar 2024 02:47:21 -0400 Subject: [PATCH 1/7] Registries now get added to the Flixel console (and get lazy instantiated so they don't start before the game does) --- source/funkin/data/BaseRegistry.hx | 7 +++++++ source/funkin/data/dialogue/ConversationRegistry.hx | 9 ++++++++- source/funkin/data/dialogue/DialogueBoxRegistry.hx | 9 ++++++++- source/funkin/data/dialogue/SpeakerRegistry.hx | 9 ++++++++- source/funkin/data/level/LevelRegistry.hx | 9 ++++++++- source/funkin/data/notestyle/NoteStyleRegistry.hx | 9 ++++++++- source/funkin/data/song/SongRegistry.hx | 13 ++++++++++--- source/funkin/data/stage/StageRegistry.hx | 9 ++++++++- 8 files changed, 65 insertions(+), 9 deletions(-) diff --git a/source/funkin/data/BaseRegistry.hx b/source/funkin/data/BaseRegistry.hx index ad028fa94..7419d9425 100644 --- a/source/funkin/data/BaseRegistry.hx +++ b/source/funkin/data/BaseRegistry.hx @@ -55,6 +55,13 @@ abstract class BaseRegistry & Constructible(); this.scriptedEntryIds = []; + + // Lazy initialization of singletons should let this get called, + // but we have this check just in case. + if (FlxG.game != null) + { + FlxG.console.registerObject('registry$registryId', this); + } } /** diff --git a/source/funkin/data/dialogue/ConversationRegistry.hx b/source/funkin/data/dialogue/ConversationRegistry.hx index 9186ef786..4a8af2162 100644 --- a/source/funkin/data/dialogue/ConversationRegistry.hx +++ b/source/funkin/data/dialogue/ConversationRegistry.hx @@ -15,7 +15,14 @@ class ConversationRegistry extends BaseRegistry public static final CONVERSATION_DATA_VERSION_RULE:thx.semver.VersionRule = "1.0.x"; - public static final instance:ConversationRegistry = new ConversationRegistry(); + public static var instance(get, never):ConversationRegistry; + static var _instance:Null = null; + + static function get_instance():ConversationRegistry + { + if (_instance == null) _instance = new ConversationRegistry(); + return _instance; + } public function new() { diff --git a/source/funkin/data/dialogue/DialogueBoxRegistry.hx b/source/funkin/data/dialogue/DialogueBoxRegistry.hx index 87205d96c..d07ea6da2 100644 --- a/source/funkin/data/dialogue/DialogueBoxRegistry.hx +++ b/source/funkin/data/dialogue/DialogueBoxRegistry.hx @@ -15,7 +15,14 @@ class DialogueBoxRegistry extends BaseRegistry public static final DIALOGUEBOX_DATA_VERSION_RULE:thx.semver.VersionRule = "1.1.x"; - public static final instance:DialogueBoxRegistry = new DialogueBoxRegistry(); + public static var instance(get, never):DialogueBoxRegistry; + static var _instance:Null = null; + + static function get_instance():DialogueBoxRegistry + { + if (_instance == null) _instance = new DialogueBoxRegistry(); + return _instance; + } public function new() { diff --git a/source/funkin/data/dialogue/SpeakerRegistry.hx b/source/funkin/data/dialogue/SpeakerRegistry.hx index 6bd301dd7..c76c6d766 100644 --- a/source/funkin/data/dialogue/SpeakerRegistry.hx +++ b/source/funkin/data/dialogue/SpeakerRegistry.hx @@ -15,7 +15,14 @@ class SpeakerRegistry extends BaseRegistry public static final SPEAKER_DATA_VERSION_RULE:thx.semver.VersionRule = "1.0.x"; - public static final instance:SpeakerRegistry = new SpeakerRegistry(); + public static var instance(get, never):SpeakerRegistry; + static var _instance:Null = null; + + static function get_instance():SpeakerRegistry + { + if (_instance == null) _instance = new SpeakerRegistry(); + return _instance; + } public function new() { diff --git a/source/funkin/data/level/LevelRegistry.hx b/source/funkin/data/level/LevelRegistry.hx index 96712cba5..e37e78d8c 100644 --- a/source/funkin/data/level/LevelRegistry.hx +++ b/source/funkin/data/level/LevelRegistry.hx @@ -15,7 +15,14 @@ class LevelRegistry extends BaseRegistry public static final LEVEL_DATA_VERSION_RULE:thx.semver.VersionRule = "1.0.x"; - public static final instance:LevelRegistry = new LevelRegistry(); + public static var instance(get, never):LevelRegistry; + static var _instance:Null = null; + + static function get_instance():LevelRegistry + { + if (_instance == null) _instance = new LevelRegistry(); + return _instance; + } public function new() { diff --git a/source/funkin/data/notestyle/NoteStyleRegistry.hx b/source/funkin/data/notestyle/NoteStyleRegistry.hx index ffb9bf490..5e9fa9a3d 100644 --- a/source/funkin/data/notestyle/NoteStyleRegistry.hx +++ b/source/funkin/data/notestyle/NoteStyleRegistry.hx @@ -15,7 +15,14 @@ class NoteStyleRegistry extends BaseRegistry public static final NOTE_STYLE_DATA_VERSION_RULE:thx.semver.VersionRule = "1.0.x"; - public static final instance:NoteStyleRegistry = new NoteStyleRegistry(); + public static var instance(get, never):NoteStyleRegistry; + static var _instance:Null = null; + + static function get_instance():NoteStyleRegistry + { + if (_instance == null) _instance = new NoteStyleRegistry(); + return _instance; + } public function new() { diff --git a/source/funkin/data/song/SongRegistry.hx b/source/funkin/data/song/SongRegistry.hx index e7f74569c..d82e184a5 100644 --- a/source/funkin/data/song/SongRegistry.hx +++ b/source/funkin/data/song/SongRegistry.hx @@ -40,10 +40,17 @@ class SongRegistry extends BaseRegistry } /** - * TODO: What if there was a Singleton macro which created static functions - * that redirected to the instance? + * TODO: What if there was a Singleton macro which automatically created the property for us? */ - public static final instance:SongRegistry = new SongRegistry(); + public static var instance(get, never):SongRegistry; + + static var _instance:Null = null; + + static function get_instance():SongRegistry + { + if (_instance == null) _instance = new SongRegistry(); + return _instance; + } public function new() { diff --git a/source/funkin/data/stage/StageRegistry.hx b/source/funkin/data/stage/StageRegistry.hx index b78292e5b..13a5afb8d 100644 --- a/source/funkin/data/stage/StageRegistry.hx +++ b/source/funkin/data/stage/StageRegistry.hx @@ -15,7 +15,14 @@ class StageRegistry extends BaseRegistry public static final STAGE_DATA_VERSION_RULE:thx.semver.VersionRule = "1.0.x"; - public static final instance:StageRegistry = new StageRegistry(); + public static var instance(get, never):StageRegistry; + static var _instance:Null = null; + + static function get_instance():StageRegistry + { + if (_instance == null) _instance = new StageRegistry(); + return _instance; + } public function new() { From 4524b66170f1c0391c4a719bce7d090ed0415bc3 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 22 Mar 2024 02:47:43 -0400 Subject: [PATCH 2/7] Only show easy/normal/hard in story mode for now --- source/funkin/ui/story/StoryMenuState.hx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/funkin/ui/story/StoryMenuState.hx b/source/funkin/ui/story/StoryMenuState.hx index 9ce110c73..a5e133725 100644 --- a/source/funkin/ui/story/StoryMenuState.hx +++ b/source/funkin/ui/story/StoryMenuState.hx @@ -446,7 +446,11 @@ class StoryMenuState extends MusicBeatState */ function changeDifficulty(change:Int = 0):Void { - var difficultyList:Array = currentLevel.getDifficulties(); + // "For now, NO erect in story mode" -Dave + + var difficultyList:Array = Constants.DEFAULT_DIFFICULTY_LIST; + // Use this line to displays all difficulties + // var difficultyList:Array = currentLevel.getDifficulties(); var currentIndex:Int = difficultyList.indexOf(currentDifficultyId); currentIndex += change; From 2b477c9bd1183ba2a35ced7d22233c9c3f2d722e Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 22 Mar 2024 02:47:56 -0400 Subject: [PATCH 3/7] Make Conductor a lazy instance --- source/funkin/Conductor.hx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/funkin/Conductor.hx b/source/funkin/Conductor.hx index 05c23108f..383a49084 100644 --- a/source/funkin/Conductor.hx +++ b/source/funkin/Conductor.hx @@ -36,7 +36,15 @@ class Conductor * You can also do stuff like store a reference to the Conductor and pass it around or temporarily replace it, * or have a second Conductor running at the same time, or other weird stuff like that if you need to. */ - public static var instance:Conductor = new Conductor(); + public static var instance(get, never):Conductor; + + static var _instance:Null = null; + + static function get_instance():Conductor + { + if (_instance == null) _instance = new Conductor(); + return _instance; + } /** * Signal fired when the current Conductor instance advances to a new measure. @@ -505,6 +513,6 @@ class Conductor */ public static function reset():Void { - Conductor.instance = new Conductor(); + _instance = new Conductor(); } } From aea9213eeaca4686acec8f7cd6e5c3e8f4faf95a Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 22 Mar 2024 03:04:33 -0400 Subject: [PATCH 4/7] Make sure the BPM label gets updated properly --- source/funkin/ui/debug/charting/ChartEditorState.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index bdc0d311e..565488da3 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -4949,7 +4949,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState playbarNoteSnap.text = '1/${noteSnapQuant}'; playbarDifficulty.text = '${selectedDifficulty.toTitleCase()}'; - // playbarBPM.text = 'BPM: ${(Conductor.currentTimeChange?.bpm ?? 0.0)}'; + playbarBPM.text = 'BPM: ${(Conductor.instance.bpm ?? 0.0)}'; } function handlePlayhead():Void From c765249030db27e092a4a544c0f614c0ee306a8f Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 22 Mar 2024 03:04:52 -0400 Subject: [PATCH 5/7] Complain if the main metadata file specifies a variation (like erect) but the game can't find it. --- source/funkin/play/song/Song.hx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/funkin/play/song/Song.hx b/source/funkin/play/song/Song.hx index 567c388c7..b0b477ff4 100644 --- a/source/funkin/play/song/Song.hx +++ b/source/funkin/play/song/Song.hx @@ -139,7 +139,16 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry = fetchVariationMetadata(id, vari); - if (variMeta != null) _metadata.set(variMeta.variation, variMeta); + if (variMeta != null) + { + _metadata.set(variMeta.variation, variMeta); + trace(' Loaded variation: $vari'); + } + else + { + FlxG.log.warn('[SONG] Failed to load variation metadata (${id}:${vari}), is the path correct?'); + trace(' FAILED to load variation: $vari'); + } } } From eb5f853e2cf9df81045effd13f70851d8bed6104 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 22 Mar 2024 03:05:18 -0400 Subject: [PATCH 6/7] Update assets submodule --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 203bb6024..d6f82ec8b 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 203bb60249e0a419d473eb6dc1763e62e29ee7fd +Subproject commit d6f82ec8b91823eee809d73e2c4744210a8e7e0b From a66b746e4393220b03acf53e38a2a7990eac8653 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 25 Mar 2024 16:01:38 -0400 Subject: [PATCH 7/7] assets submod --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index d6f82ec8b..8bb6214e1 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit d6f82ec8b91823eee809d73e2c4744210a8e7e0b +Subproject commit 8bb6214e16c823b8b5a522a39b7a7e01d6283abf