mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-14 11:15:24 -05:00
add these registries back
This commit is contained in:
parent
488ba73f39
commit
273bdcfa57
6 changed files with 7 additions and 207 deletions
|
@ -3,6 +3,7 @@ package funkin.data.dialogue.conversation;
|
|||
import funkin.play.cutscene.dialogue.Conversation;
|
||||
import funkin.play.cutscene.dialogue.ScriptedConversation;
|
||||
|
||||
@:build(funkin.util.macro.RegistryMacro.build())
|
||||
class ConversationRegistry extends BaseRegistry<Conversation, ConversationData>
|
||||
{
|
||||
/**
|
||||
|
@ -14,74 +15,8 @@ class ConversationRegistry extends BaseRegistry<Conversation, ConversationData>
|
|||
|
||||
public static final CONVERSATION_DATA_VERSION_RULE:thx.semver.VersionRule = "1.0.x";
|
||||
|
||||
public static var instance(get, never):ConversationRegistry;
|
||||
static var _instance:Null<ConversationRegistry> = null;
|
||||
|
||||
static function get_instance():ConversationRegistry
|
||||
{
|
||||
if (_instance == null) _instance = new ConversationRegistry();
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public function new()
|
||||
{
|
||||
super('CONVERSATION', 'dialogue/conversations', CONVERSATION_DATA_VERSION_RULE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read, parse, and validate the JSON data and produce the corresponding data object.
|
||||
*/
|
||||
public function parseEntryData(id:String):Null<ConversationData>
|
||||
{
|
||||
// JsonParser does not take type parameters,
|
||||
// otherwise this function would be in BaseRegistry.
|
||||
var parser = new json2object.JsonParser<ConversationData>();
|
||||
parser.ignoreUnknownVariables = false;
|
||||
|
||||
switch (loadEntryFile(id))
|
||||
{
|
||||
case {fileName: fileName, contents: contents}:
|
||||
parser.fromJson(contents, fileName);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
if (parser.errors.length > 0)
|
||||
{
|
||||
printErrors(parser.errors, id);
|
||||
return null;
|
||||
}
|
||||
return parser.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse and validate the JSON data and produce the corresponding data object.
|
||||
*
|
||||
* NOTE: Must be implemented on the implementation class.
|
||||
* @param contents The JSON as a string.
|
||||
* @param fileName An optional file name for error reporting.
|
||||
*/
|
||||
public function parseEntryDataRaw(contents:String, ?fileName:String):Null<ConversationData>
|
||||
{
|
||||
var parser = new json2object.JsonParser<ConversationData>();
|
||||
parser.ignoreUnknownVariables = false;
|
||||
parser.fromJson(contents, fileName);
|
||||
|
||||
if (parser.errors.length > 0)
|
||||
{
|
||||
printErrors(parser.errors, fileName);
|
||||
return null;
|
||||
}
|
||||
return parser.value;
|
||||
}
|
||||
|
||||
function createScriptedEntry(clsName:String):Conversation
|
||||
{
|
||||
return ScriptedConversation.init(clsName, "unknown");
|
||||
}
|
||||
|
||||
function getScriptedClassNames():Array<String>
|
||||
{
|
||||
return ScriptedConversation.listScriptClasses();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import funkin.play.notes.notestyle.NoteStyle;
|
|||
import funkin.play.notes.notestyle.ScriptedNoteStyle;
|
||||
import funkin.data.notestyle.NoteStyleData;
|
||||
|
||||
@:build(funkin.util.macro.RegistryMacro.build())
|
||||
class NoteStyleRegistry extends BaseRegistry<NoteStyle, NoteStyleData>
|
||||
{
|
||||
/**
|
||||
|
@ -15,15 +16,6 @@ class NoteStyleRegistry extends BaseRegistry<NoteStyle, NoteStyleData>
|
|||
|
||||
public static final NOTE_STYLE_DATA_VERSION_RULE:thx.semver.VersionRule = "1.1.x";
|
||||
|
||||
public static var instance(get, never):NoteStyleRegistry;
|
||||
static var _instance:Null<NoteStyleRegistry> = null;
|
||||
|
||||
static function get_instance():NoteStyleRegistry
|
||||
{
|
||||
if (_instance == null) _instance = new NoteStyleRegistry();
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public function new()
|
||||
{
|
||||
super('NOTESTYLE', 'notestyles', NOTE_STYLE_DATA_VERSION_RULE);
|
||||
|
@ -33,61 +25,4 @@ class NoteStyleRegistry extends BaseRegistry<NoteStyle, NoteStyleData>
|
|||
{
|
||||
return fetchEntry(Constants.DEFAULT_NOTE_STYLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read, parse, and validate the JSON data and produce the corresponding data object.
|
||||
*/
|
||||
public function parseEntryData(id:String):Null<NoteStyleData>
|
||||
{
|
||||
// JsonParser does not take type parameters,
|
||||
// otherwise this function would be in BaseRegistry.
|
||||
var parser = new json2object.JsonParser<NoteStyleData>();
|
||||
parser.ignoreUnknownVariables = false;
|
||||
|
||||
switch (loadEntryFile(id))
|
||||
{
|
||||
case {fileName: fileName, contents: contents}:
|
||||
parser.fromJson(contents, fileName);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
if (parser.errors.length > 0)
|
||||
{
|
||||
printErrors(parser.errors, id);
|
||||
return null;
|
||||
}
|
||||
return parser.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse and validate the JSON data and produce the corresponding data object.
|
||||
*
|
||||
* NOTE: Must be implemented on the implementation class.
|
||||
* @param contents The JSON as a string.
|
||||
* @param fileName An optional file name for error reporting.
|
||||
*/
|
||||
public function parseEntryDataRaw(contents:String, ?fileName:String):Null<NoteStyleData>
|
||||
{
|
||||
var parser = new json2object.JsonParser<NoteStyleData>();
|
||||
parser.ignoreUnknownVariables = false;
|
||||
parser.fromJson(contents, fileName);
|
||||
|
||||
if (parser.errors.length > 0)
|
||||
{
|
||||
printErrors(parser.errors, fileName);
|
||||
return null;
|
||||
}
|
||||
return parser.value;
|
||||
}
|
||||
|
||||
function createScriptedEntry(clsName:String):NoteStyle
|
||||
{
|
||||
return ScriptedNoteStyle.init(clsName, "unknown");
|
||||
}
|
||||
|
||||
function getScriptedClassNames():Array<String>
|
||||
{
|
||||
return ScriptedNoteStyle.listScriptClasses();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import funkin.util.VersionUtil;
|
|||
using funkin.data.song.migrator.SongDataMigrator;
|
||||
|
||||
@:nullSafety
|
||||
@:build(funkin.util.macro.RegistryMacro.build())
|
||||
class SongRegistry extends BaseRegistry<Song, SongMetadata>
|
||||
{
|
||||
/**
|
||||
|
@ -39,19 +40,6 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
|
|||
return '${Constants.TITLE} - ${Constants.VERSION}';
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: What if there was a Singleton macro which automatically created the property for us?
|
||||
*/
|
||||
public static var instance(get, never):SongRegistry;
|
||||
|
||||
static var _instance:Null<SongRegistry> = null;
|
||||
|
||||
static function get_instance():SongRegistry
|
||||
{
|
||||
if (_instance == null) _instance = new SongRegistry();
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public function new()
|
||||
{
|
||||
super('SONG', 'songs', SONG_METADATA_VERSION_RULE);
|
||||
|
@ -417,16 +405,6 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
|
|||
}
|
||||
}
|
||||
|
||||
function createScriptedEntry(clsName:String):Song
|
||||
{
|
||||
return ScriptedSong.init(clsName, "unknown");
|
||||
}
|
||||
|
||||
function getScriptedClassNames():Array<String>
|
||||
{
|
||||
return ScriptedSong.listScriptClasses();
|
||||
}
|
||||
|
||||
function loadEntryMetadataFile(id:String, ?variation:String):Null<JsonFile>
|
||||
{
|
||||
variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
|
||||
|
|
|
@ -30,23 +30,15 @@ import funkin.util.EaseUtil;
|
|||
*
|
||||
* This shit is great for modders but it's pretty elaborate for how much it'll actually be used, lolol. -Eric
|
||||
*/
|
||||
@:build(funkin.util.macro.EntryMacro.build(funkin.data.dialogue.conversation.ConversationRegistry, funkin.data.dialogue.dialoguebox.DialogueBoxRegistry,
|
||||
funkin.data.dialogue.speaker.SpeakerRegistry))
|
||||
class Conversation extends FlxSpriteGroup implements IDialogueScriptedClass implements IRegistryEntry<ConversationData>
|
||||
{
|
||||
/**
|
||||
* The ID of the conversation.
|
||||
*/
|
||||
public final id:String;
|
||||
|
||||
/**
|
||||
* The current state of the conversation.
|
||||
*/
|
||||
var state:ConversationState = ConversationState.Start;
|
||||
|
||||
/**
|
||||
* Conversation data as parsed from the JSON file.
|
||||
*/
|
||||
public final _data:ConversationData;
|
||||
|
||||
/**
|
||||
* The current entry in the dialogue.
|
||||
*/
|
||||
|
@ -631,16 +623,6 @@ class Conversation extends FlxSpriteGroup implements IDialogueScriptedClass impl
|
|||
outroTween = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override function toString():String
|
||||
{
|
||||
return 'Conversation($id)';
|
||||
}
|
||||
|
||||
static function _fetchData(id:String):Null<ConversationData>
|
||||
{
|
||||
return ConversationRegistry.instance.parseEntryDataWithMigration(id, ConversationRegistry.instance.fetchEntryVersion(id));
|
||||
}
|
||||
}
|
||||
|
||||
// Managing things with a single enum is a lot easier than a multitude of flags.
|
||||
|
|
|
@ -18,13 +18,9 @@ using funkin.data.animation.AnimationData.AnimationDataUtil;
|
|||
* and provides convenience methods for building sprites based on them.
|
||||
*/
|
||||
@:nullSafety
|
||||
@:build(funkin.util.macro.EntryMacro.build(funkin.data.notestyle.NoteStyleRegistry))
|
||||
class NoteStyle implements IRegistryEntry<NoteStyleData>
|
||||
{
|
||||
/**
|
||||
* The ID of the note style.
|
||||
*/
|
||||
public final id:String;
|
||||
|
||||
/**
|
||||
* Note style data as parsed from the JSON file.
|
||||
*/
|
||||
|
@ -881,13 +877,6 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
}
|
||||
}
|
||||
|
||||
public function destroy():Void {}
|
||||
|
||||
public function toString():String
|
||||
{
|
||||
return 'NoteStyle($id)';
|
||||
}
|
||||
|
||||
static function _fetchData(id:String):NoteStyleData
|
||||
{
|
||||
var result = NoteStyleRegistry.instance.parseEntryDataWithMigration(id, NoteStyleRegistry.instance.fetchEntryVersion(id));
|
||||
|
|
|
@ -28,6 +28,7 @@ import funkin.util.SortUtil;
|
|||
* can be used to perform custom gameplay behaviors only on specific songs.
|
||||
*/
|
||||
@:nullSafety
|
||||
@:build(funkin.util.macro.EntryMacro.build(funkin.data.song.SongRegistry))
|
||||
class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMetadata>
|
||||
{
|
||||
/**
|
||||
|
@ -65,19 +66,6 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
|
|||
*/
|
||||
public static final DEFAULT_SCROLLSPEED:Float = 1.0;
|
||||
|
||||
/**
|
||||
* The internal ID of the song.
|
||||
*/
|
||||
public final id:String;
|
||||
|
||||
/**
|
||||
* Song metadata as parsed from the JSON file.
|
||||
* This is the data for the `default` variation specifically,
|
||||
* and is needed for the IRegistryEntry interface.
|
||||
* Will only be null if the song data could not be loaded.
|
||||
*/
|
||||
public final _data:Null<SongMetadata>;
|
||||
|
||||
// key = variation id, value = metadata
|
||||
final _metadata:Map<String, SongMetadata>;
|
||||
|
||||
|
@ -624,13 +612,6 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
|
|||
}
|
||||
}
|
||||
|
||||
public function toString():String
|
||||
{
|
||||
return 'Song($id)';
|
||||
}
|
||||
|
||||
public function destroy():Void {}
|
||||
|
||||
public function onPause(event:PauseScriptEvent):Void {};
|
||||
|
||||
public function onResume(event:ScriptEvent):Void {};
|
||||
|
|
Loading…
Reference in a new issue