Procházet zdrojové kódy

Add helpers for ModItem

habeebweeb před 4 roky
rodič
revize
5cbc7316dc

+ 3 - 12
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Constants.cs

@@ -687,13 +687,10 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             foreach (string modMenuFile in GameUty.ModOnlysMenuFiles)
             {
                 ModItem modItem;
-                if (cache.Has(modMenuFile))
-                {
-                    modItem = cache[modMenuFile];
-                }
+                if (cache.Has(modMenuFile)) modItem = cache[modMenuFile];
                 else
                 {
-                    modItem = new ModItem() { MenuFile = modMenuFile, IsMod = true };
+                    modItem = ModItem.Mod(modMenuFile);
                     MenuFileUtility.ParseMenuFile(modMenuFile, modItem);
                     cache[modMenuFile] = modItem;
                 }
@@ -704,13 +701,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             foreach (string modFile in Menu.GetModFiles())
             {
-                ModItem modItem = new ModItem()
-                {
-                    MenuFile = modFile,
-                    IsMod = true,
-                    IsOfficialMod = true,
-                    Priority = 1000f
-                };
+                ModItem modItem = ModItem.OfficialMod(modFile);
                 if (ParseModMenuFile(modFile, modItem))
                 {
                     ModPropDict[modItem.Category].Add(modItem);

+ 19 - 4
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MenuFileUtility.cs

@@ -454,10 +454,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
         }
 
-        public static GameObject LoadModel(string menuFile)
-        {
-            return LoadModel(new ModItem { MenuFile = menuFile });
-        }
+        public static GameObject LoadModel(string menuFile) => LoadModel(new ModItem(menuFile));
 
         public static GameObject LoadModel(ModItem modItem)
         {
@@ -764,6 +761,24 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             public bool IsMod { get; set; }
             public bool IsOfficialMod { get; set; }
 
+            public static ModItem OfficialMod(string menuFile) => new ModItem()
+            {
+                MenuFile = menuFile,
+                IsMod = true,
+                IsOfficialMod = true,
+                Priority = 1000f
+            };
+
+            public static ModItem Mod(string menuFile) => new ModItem()
+            {
+                MenuFile = menuFile,
+                IsMod = true
+            };
+
+            public ModItem() { }
+
+            public ModItem(string menuFile) => MenuFile = menuFile;
+
             public override string ToString()
             {
                 return IsOfficialMod ? $"{Path.GetFileName(MenuFile)}#{BaseMenuFile}" : MenuFile;