mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-01 11:13:06 +00:00
42d8d55067
* Initial test suite * Fix some build warnings * Implemented working unit tests with coverage * Reduced some warnings * Fix a mac-specific issue * Add 2 additional unit test classes. * Multiple new unit tests * Some fixins * Remove auto-generated file * WIP on hiding ignored tests * Added list of debug hotkeys * Remove old website * Remove empty file * Add more unit tests * Fix bug where arrows would nudge BF * Fix bug where ctrl/alt would flash capsules * Fixed bug where bf-old easter egg broke * Remove duplicate lines * More test-related stuff * Some code cleanup * Add mocking and a test assets folder * More TESTS! * Update Hmm... * Update artist on Monster * More minor fixes to individual functions * 1.38% unit test coverage! * Even more tests? :O * More unit test work * Rework migration for BaseRegistry * gameover fix * Fix an issue with Lime * Fix issues with version parsing on data files * 100 total unit tests! * Added even MORE unit tests! * Additional test tweaks :3 * Fixed tests on windows by updating libraries. * Set versions for flixel-ui and hamcrest --------- Co-authored-by: Cameron Taylor <cameron.taylor.ninja@gmail.com>
68 lines
1.8 KiB
Haxe
68 lines
1.8 KiB
Haxe
package funkin.data.notestyle;
|
|
|
|
import funkin.play.notes.notestyle.NoteStyle;
|
|
import funkin.play.notes.notestyle.ScriptedNoteStyle;
|
|
import funkin.data.notestyle.NoteStyleData;
|
|
|
|
class NoteStyleRegistry extends BaseRegistry<NoteStyle, NoteStyleData>
|
|
{
|
|
/**
|
|
* The current version string for the note style data format.
|
|
* Handle breaking changes by incrementing this value
|
|
* and adding migration to the `migrateNoteStyleData()` function.
|
|
*/
|
|
public static final NOTE_STYLE_DATA_VERSION:thx.semver.Version = "1.0.0";
|
|
|
|
public static final NOTE_STYLE_DATA_VERSION_RULE:thx.semver.VersionRule = "1.0.x";
|
|
|
|
public static final DEFAULT_NOTE_STYLE_ID:String = "funkin";
|
|
|
|
public static final instance:NoteStyleRegistry = new NoteStyleRegistry();
|
|
|
|
public function new()
|
|
{
|
|
super('NOTESTYLE', 'notestyles', NOTE_STYLE_DATA_VERSION_RULE);
|
|
}
|
|
|
|
public function fetchDefault():NoteStyle
|
|
{
|
|
return fetchEntry(DEFAULT_NOTE_STYLE_ID);
|
|
}
|
|
|
|
/**
|
|
* Read, parse, and validate the JSON data and produce the corresponding data object.
|
|
*/
|
|
public function parseEntryData(id:String):Null<NoteStyleData>
|
|
{
|
|
if (id == null) id = DEFAULT_NOTE_STYLE_ID;
|
|
|
|
// JsonParser does not take type parameters,
|
|
// otherwise this function would be in BaseRegistry.
|
|
var parser = new json2object.JsonParser<NoteStyleData>();
|
|
var jsonStr:String = loadEntryFile(id);
|
|
|
|
parser.fromJson(jsonStr);
|
|
|
|
if (parser.errors.length > 0)
|
|
{
|
|
trace('[${registryId}] Failed to parse entry data: ${id}');
|
|
for (error in parser.errors)
|
|
{
|
|
trace(error);
|
|
}
|
|
return null;
|
|
}
|
|
return parser.value;
|
|
}
|
|
|
|
function createScriptedEntry(clsName:String):NoteStyle
|
|
{
|
|
return ScriptedNoteStyle.init(clsName, "unknown");
|
|
}
|
|
|
|
function getScriptedClassNames():Array<String>
|
|
{
|
|
return ScriptedNoteStyle.listScriptClasses();
|
|
}
|
|
}
|