diff --git a/FinModelUtility/Fin/Fin/src/util/types/TypesUtil.cs b/FinModelUtility/Fin/Fin/src/util/types/TypesUtil.cs new file mode 100644 index 000000000..1a30721c4 --- /dev/null +++ b/FinModelUtility/Fin/Fin/src/util/types/TypesUtil.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using fin.util.asserts; +using fin.util.linq; + +namespace fin.util.types; + +public static class TypesUtil { + public static IEnumerable GetAllImplementationTypes() + => AppDomain.CurrentDomain.GetAssemblies() + .SelectMany(s => s.GetTypes()) + .Where(typeof(TInterface).IsAssignableFrom) + .Where(t => t is { + IsAbstract: false, ContainsGenericParameters: false + }); + + public static IEnumerable + InstantiateAllImplementationsWithDefaultConstructor() + => GetAllImplementationTypes() + .SelectWhere( + TryToInstantiateWIthDefaultConstructor_); + + private static bool TryToInstantiateWIthDefaultConstructor_( + Type type, + out TInterface value) { + var constructor = type.GetConstructor([]); + if (constructor == null) { + value = default; + return false; + } + + value = constructor.Invoke([]).AssertAsA(); + return true; + } +} \ No newline at end of file diff --git a/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/cli/Cli.cs b/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/cli/Cli.cs index 61c90244b..dedc16413 100644 --- a/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/cli/Cli.cs +++ b/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/cli/Cli.cs @@ -5,6 +5,7 @@ using fin.model.io; using fin.model.io.exporters; using fin.model.io.exporters.assimp.indirect; +using fin.util.types; namespace uni.cli; @@ -14,10 +15,8 @@ public static void Run(string[] args, Action? runDebug = null) { IEnumerable? errors = null; - var massExporterOptionTypes = - AppDomain.CurrentDomain.GetAssemblies() - .SelectMany(s => s.GetTypes()) - .Where(typeof(IMassExporterOptions).IsAssignableFrom); + var massExporterOptionTypes + = TypesUtil.GetAllImplementationTypes(); var plugins = PluginUtil.Plugins; diff --git a/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/RootFileBundleGatherer.cs b/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/RootFileBundleGatherer.cs index 7a2dddb03..bd4793191 100644 --- a/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/RootFileBundleGatherer.cs +++ b/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/RootFileBundleGatherer.cs @@ -1,91 +1,16 @@ using fin.io.bundles; using fin.util.progress; +using fin.util.types; using uni.config; -using uni.games.animal_crossing; -using uni.games.animal_crossing_wild_world; -using uni.games.battalion_wars_1; -using uni.games.battalion_wars_2; -using uni.games.chibi_robo; -using uni.games.custom_robo; -using uni.games.dead_space_1; -using uni.games.dead_space_2; -using uni.games.dead_space_3; -using uni.games.doshin_the_giant; -using uni.games.ever_oasis; -using uni.games.glover; -using uni.games.great_ace_attorney; -using uni.games.halo_wars; -using uni.games.kirby_air_ride; -using uni.games.luigis_mansion; -using uni.games.luigis_mansion_3d; -using uni.games.majoras_mask_3d; -using uni.games.mario_kart_double_dash; -using uni.games.midnight_club_2; -using uni.games.nintendogs_labrador_and_friends; -using uni.games.ocarina_of_time; -using uni.games.ocarina_of_time_3d; -using uni.games.odyssey_of_hyrule; -using uni.games.paper_mario_directors_cut; -using uni.games.paper_mario_the_thousand_year_door; -using uni.games.pikmin_1; -using uni.games.pikmin_2; -using uni.games.professor_layton_vs_phoenix_wright; -using uni.games.soulcalibur_ii; -using uni.games.super_mario_64; -using uni.games.super_mario_64_ds; -using uni.games.super_mario_sunshine; -using uni.games.super_smash_bros_melee; -using uni.games.timesplitters_2; -using uni.games.twilight_princess; -using uni.games.vrwdw; -using uni.games.wind_waker; namespace uni.games; public class RootFileBundleGatherer { public IFileBundleDirectory GatherAllFiles( IMutablePercentageProgress mutablePercentageProgress) { - var gatherers = new IAnnotatedFileBundleGatherer[] { - new AnimalCrossingFileBundleGatherer(), - new AnimalCrossingWildWorldFileBundleGatherer(), - new BattalionWars1FileBundleGatherer(), - new BattalionWars2FileBundleGatherer(), - new ChibiRoboFileBundleGatherer(), - new CustomRoboFileBundleGatherer(), - new DeadSpace1FileBundleGatherer(), - new DeadSpace2FileBundleGatherer(), - new DeadSpace3FileBundleGatherer(), - new DoshinTheGiantFileBundleGatherer(), - new EverOasisFileBundleGatherer(), - new GloverFileBundleGatherer(), - new GreatAceAttorneyFileBundleGatherer(), - new HaloWarsFileBundleGatherer(), - new KirbyAirRideFileBundleGatherer(), - new LuigisMansionFileBundleGatherer(), - new LuigisMansion3dFileBundleGatherer(), - new MajorasMask3dFileBundleGatherer(), - new MarioKartDoubleDashFileBundleGatherer(), - new MidnightClub2FileBundleGatherer(), - new NintendogsLabradorAndFriendsFileBundleGatherer(), - new OcarinaOfTimeFileBundleGatherer(), - new OcarinaOfTime3dFileBundleGatherer(), - new OdysseyOfHyruleFileBundleGatherer(), - new PaperMarioDirectorsCutFileBundleGatherer(), - new PaperMarioTheThousandYearDoorFileBundleGatherer(), - new Pikmin1FileBundleGatherer(), - new Pikmin2FileBundleGatherer(), - new ProfessorLaytonVsPhoenixWrightFileBundleGatherer(), - new SoulcaliburIIFileBundleGatherer(), - new SuperMario64DsFileBundleGatherer(), - new SuperMario64FileBundleGatherer(), - new SuperMarioSunshineFileBundleGatherer(), - new SuperSmashBrosMeleeFileBundleGatherer(), - new Timesplitters2FileBundleGatherer(), - new TwilightPrincessFileBundleGatherer(), - new VrwdwFileBundleGatherer(), - new WindWakerFileBundleGatherer(), - }; + var gatherers + = TypesUtil.InstantiateAllImplementationsWithDefaultConstructor(); IAnnotatedFileBundleGatherer rootGatherer; if (Config.Instance.Extractor.ExtractRomsInParallel) { diff --git a/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/phantom_hourglass/PhantomHourglassFileBundleGatherer.cs b/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/phantom_hourglass/PhantomHourglassFileBundleGatherer.cs new file mode 100644 index 000000000..2471bf16e --- /dev/null +++ b/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/phantom_hourglass/PhantomHourglassFileBundleGatherer.cs @@ -0,0 +1,32 @@ +using fin.io.bundles; +using fin.util.progress; + +using SceneGate.Ekona.Containers.Rom; + +using uni.platforms; + +using Yarhl.FileSystem; + +namespace uni.games.phantom_hourglass; + +public class PhantomHourglassFileBundleGatherer + : IAnnotatedFileBundleGatherer { + public void GatherFileBundles( + IFileBundleOrganizer organizer, + IMutablePercentageProgress mutablePercentageProgress) { + if (!DirectoryConstants.ROMS_DIRECTORY.TryToGetExistingFile( + "phantom_hourglass.nds", + out var phantomHourglassRom)) { + return; + } + + using var game = NodeFactory.FromFile(phantomHourglassRom.FullPath); + game.TransformWith(); + + var names = new List(); + + foreach (var node in Navigator.IterateNodes(game)) { + names.Add(node.Name); + } + } +} \ No newline at end of file