mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-14 19:25:16 -05:00
Compare commits
4 commits
1f7bffe3af
...
5b6902e8e1
Author | SHA1 | Date | |
---|---|---|---|
|
5b6902e8e1 | ||
|
557d6cb667 | ||
|
c7b9214ca8 | ||
|
dbd9e5c7e0 |
4 changed files with 30 additions and 70 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,15 +15,6 @@ 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);
|
||||
|
@ -74,14 +66,4 @@ class ConversationRegistry extends BaseRegistry<Conversation, ConversationData>
|
|||
}
|
||||
return parser.value;
|
||||
}
|
||||
|
||||
function createScriptedEntry(clsName:String):Conversation
|
||||
{
|
||||
return ScriptedConversation.init(clsName, "unknown");
|
||||
}
|
||||
|
||||
function getScriptedClassNames():Array<String>
|
||||
{
|
||||
return ScriptedConversation.listScriptClasses();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ 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.speaker.SpeakerRegistry,
|
||||
funkin.data.dialogue.dialoguebox.DialogueBoxRegistry))
|
||||
class Conversation extends FlxSpriteGroup implements IDialogueScriptedClass implements IRegistryEntry<ConversationData>
|
||||
{
|
||||
/**
|
||||
|
@ -636,11 +638,6 @@ class Conversation extends FlxSpriteGroup implements IDialogueScriptedClass impl
|
|||
{
|
||||
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.
|
||||
|
|
|
@ -35,7 +35,7 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
function get_fallback():Null<NoteStyle>
|
||||
{
|
||||
if (_data == null || _data.fallback == null) return null;
|
||||
return registryInstance.fetchEntry(_data.fallback);
|
||||
return NoteStyleRegistry.instance.fetchEntry(_data.fallback);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -879,7 +879,7 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
|
||||
static function _fetchData(id:String):NoteStyleData
|
||||
{
|
||||
var result = registryInstance.parseEntryDataWithMigration(id, registryInstance.fetchEntryVersion(id));
|
||||
var result = NoteStyleRegistry.instance.parseEntryDataWithMigration(id, NoteStyleRegistry.instance.fetchEntryVersion(id));
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
|
|
|
@ -4,11 +4,12 @@ import haxe.macro.Context;
|
|||
import haxe.macro.Expr;
|
||||
import haxe.macro.Type;
|
||||
|
||||
using haxe.macro.ExprTools;
|
||||
using StringTools;
|
||||
|
||||
class EntryMacro
|
||||
{
|
||||
public static macro function build(registryExpr:ExprOf<Class<Dynamic>>):Array<Field>
|
||||
public static macro function build(registryExpr:ExprOf<Class<Dynamic>>, ...additionalReferencedRegistries:ExprOf<Class<Dynamic>>):Array<Field>
|
||||
{
|
||||
var fields = Context.getBuildFields();
|
||||
|
||||
|
@ -16,13 +17,13 @@ class EntryMacro
|
|||
|
||||
var entryData = getEntryData(cls);
|
||||
|
||||
makeReferenceRegistryFieldsCallable(additionalReferencedRegistries.append(registryExpr), fields);
|
||||
|
||||
buildIdField(fields);
|
||||
|
||||
buildDataField(entryData, fields);
|
||||
|
||||
buildRegistryInstanceField(registryExpr, fields);
|
||||
|
||||
buildFetchDataField(entryData, fields);
|
||||
buildFetchDataField(entryData, registryExpr, fields);
|
||||
|
||||
buildToStringField(cls, fields);
|
||||
|
||||
|
@ -100,31 +101,16 @@ class EntryMacro
|
|||
});
|
||||
}
|
||||
|
||||
static function buildRegistryInstanceField(registryExpr:ExprOf<Class<Dynamic>>, fields:Array<Field>):Void
|
||||
static function makeReferenceRegistryFieldsCallable(registryExprs:Array<ExprOf<Class<Dynamic>>>, fields:Array<Field>):Void
|
||||
{
|
||||
if (!shouldBuildField('registryInstance', fields))
|
||||
for (registryExpr in registryExprs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var registryCls = MacroUtil.getClassTypeFromExpr(registryExpr);
|
||||
var expr:String = '${registryExpr.toString()}.instance';
|
||||
|
||||
fields.push(
|
||||
{
|
||||
name: 'registryInstance',
|
||||
access: [Access.APrivate, Access.AStatic],
|
||||
kind: FieldType.FProp("get", "never", ComplexType.TPath(
|
||||
{
|
||||
pack: registryCls.pack,
|
||||
name: registryCls.name,
|
||||
params: []
|
||||
})),
|
||||
pos: Context.currentPos()
|
||||
});
|
||||
|
||||
fields.push(
|
||||
{
|
||||
name: 'get_registryInstance',
|
||||
name: '_${registryCls.pack.join('_')}_${registryCls.name}',
|
||||
access: [Access.APrivate, Access.AStatic],
|
||||
kind: FFun(
|
||||
{
|
||||
|
@ -133,19 +119,14 @@ class EntryMacro
|
|||
{
|
||||
return ${registryExpr}.instance;
|
||||
},
|
||||
params: [],
|
||||
ret: ComplexType.TPath(
|
||||
{
|
||||
pack: registryCls.pack,
|
||||
name: registryCls.name,
|
||||
params: []
|
||||
})
|
||||
}),
|
||||
pos: Context.currentPos()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static function buildFetchDataField(entryData:Dynamic, fields:Array<Field>):Void
|
||||
static function buildFetchDataField(entryData:Dynamic, registryExpr:ExprOf<Class<Dynamic>>, fields:Array<Field>):Void
|
||||
{
|
||||
if (!shouldBuildField('_fetchData', fields))
|
||||
{
|
||||
|
@ -166,7 +147,7 @@ class EntryMacro
|
|||
],
|
||||
expr: macro
|
||||
{
|
||||
return registryInstance.parseEntryDataWithMigration(id, registryInstance.fetchEntryVersion(id));
|
||||
return ${registryExpr}.instance.parseEntryDataWithMigration(id, ${registryExpr}.instance.fetchEntryVersion(id));
|
||||
},
|
||||
params: [],
|
||||
ret: ComplexType.TPath(
|
||||
|
|
Loading…
Reference in a new issue