Пример #1
0
 internal static void ResolveStudioObject(StudioResolveInfo extResolve, ObjectInfo OI, ResolveType resolveType = ResolveType.Load)
 {
     if (OI is OIItemInfo Item)
     {
         StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == Item.no && x.GUID == extResolve.GUID);
         if (intResolve != null)
         {
             if (resolveType == ResolveType.Load && Sideloader.DebugLogging.Value)
             {
                 Sideloader.Logger.Log(LogLevel.Debug, $"Resolving (Studio Item) [{extResolve.GUID}] {Item.no}->{intResolve.LocalSlot}");
             }
             Traverse.Create(Item).Property("no").SetValue(intResolve.LocalSlot);
         }
         else if (resolveType == ResolveType.Load)
         {
             ShowGUIDError(extResolve.GUID);
         }
     }
     else if (OI is OILightInfo Light)
     {
         StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == Light.no && x.GUID == extResolve.GUID);
         if (intResolve != null)
         {
             if (resolveType == ResolveType.Load && Sideloader.DebugLogging.Value)
             {
                 Sideloader.Logger.Log(LogLevel.Debug, $"Resolving (Studio Light) [{extResolve.GUID}] {Light.no}->{intResolve.LocalSlot}");
             }
             Traverse.Create(Light).Property("no").SetValue(intResolve.LocalSlot);
         }
         else if (resolveType == ResolveType.Load)
         {
             ShowGUIDError(extResolve.GUID);
         }
     }
 }
Пример #2
0
        public static void SavePrefix()
        {
            Dictionary <string, object>  ExtendedData         = new Dictionary <string, object>();
            List <StudioResolveInfo>     ObjectResolutionInfo = new List <StudioResolveInfo>();
            Dictionary <int, ObjectInfo> ObjectList           = FindObjectInfoAndOrder(SearchType.All, typeof(OIItemInfo), out Dictionary <int, int> ItemOrder);
            Dictionary <int, int>        LightOrder           = FindObjectInfoOrder(SearchType.All, typeof(OILightInfo));

            foreach (ObjectInfo oi in ObjectList.Where(x => x.Value is OIItemInfo || x.Value is OILightInfo).Select(x => x.Value))
            {
                if (oi is OIItemInfo Item && Item.no >= 100000000)
                {
                    StudioResolveInfo extResolve = UniversalAutoResolver.LoadedStudioResolutionInfo.Where(x => x.LocalSlot == Item.no).FirstOrDefault();
                    if (extResolve != null)
                    {
                        StudioResolveInfo intResolve = new StudioResolveInfo
                        {
                            GUID        = extResolve.GUID,
                            Slot        = extResolve.Slot,
                            LocalSlot   = extResolve.LocalSlot,
                            DicKey      = Item.dicKey,
                            ObjectOrder = ItemOrder[Item.dicKey]
                        };
                        ObjectResolutionInfo.Add(intResolve);

                        //set item ID back to default
                        //Logger.Log(LogLevel.Info, $"Setting [{item.dicKey}] ID:{item.no}->{extResolve.Slot}");
                        Traverse.Create(Item).Property("no").SetValue(extResolve.Slot);
                    }
                }
Пример #3
0
        internal static void ResolveStudioObjects(ExtensibleSaveFormat.PluginData extendedData, ResolveType resolveType)
        {
            Dictionary <int, ObjectInfo> ObjectList = StudioObjectSearch.FindObjectInfo(StudioObjectSearch.SearchType.All);

            //Resolve all patterns for objects
            if (extendedData != null && extendedData.data.ContainsKey("patternInfo"))
            {
                List <StudioPatternResolveInfo> extPatternInfo;

                if (resolveType == ResolveType.Save)
                {
                    extPatternInfo = ((List <byte[]>)extendedData.data["patternInfo"]).Select(x => StudioPatternResolveInfo.Deserialize(x)).ToList();
                }
                else
                {
                    extPatternInfo = ((object[])extendedData.data["patternInfo"]).Select(x => StudioPatternResolveInfo.Deserialize((byte[])x)).ToList();
                }

                foreach (StudioPatternResolveInfo extPatternResolve in extPatternInfo)
                {
                    ResolveStudioObjectPattern(extPatternResolve, ObjectList[extPatternResolve.DicKey], resolveType);
                }
            }

            //Resolve every item with extended data
            if (extendedData != null && extendedData.data.ContainsKey("itemInfo"))
            {
                List <StudioResolveInfo> extInfo;

                if (resolveType == ResolveType.Save)
                {
                    extInfo = ((List <byte[]>)extendedData.data["itemInfo"]).Select(x => StudioResolveInfo.Deserialize(x)).ToList();
                }
                else
                {
                    extInfo = ((object[])extendedData.data["itemInfo"]).Select(x => StudioResolveInfo.Deserialize((byte[])x)).ToList();
                }

                foreach (StudioResolveInfo extResolve in extInfo)
                {
                    ResolveStudioObject(extResolve, ObjectList[extResolve.DicKey], resolveType);
                    ObjectList.Remove(extResolve.DicKey);
                }
            }

            //Resolve every item without extended data in case of hard mods
            if (resolveType == ResolveType.Load)
            {
                foreach (ObjectInfo OI in ObjectList.Where(x => x.Value is OIItemInfo || x.Value is OILightInfo || x.Value is OICharInfo).Select(x => x.Value))
                {
                    ResolveStudioObject(OI);
                }
            }
        }
Пример #4
0
 internal static void ResolveStudioObject(StudioResolveInfo extResolve, ObjectInfo OI, ResolveType resolveType = ResolveType.Load)
 {
     if (OI is OIItemInfo Item)
     {
         StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == Item.no && x.GUID == extResolve.GUID);
         if (intResolve != null)
         {
             if (resolveType == ResolveType.Load && Sideloader.DebugLogging.Value)
             {
                 Sideloader.Logger.LogDebug($"Resolving (Studio Item) [{extResolve.GUID}] {Item.no}->{intResolve.LocalSlot}");
             }
             Item.no = intResolve.LocalSlot;
         }
         else if (resolveType == ResolveType.Load)
         {
             ShowGUIDError(extResolve.GUID);
         }
     }
     else if (OI is OILightInfo Light)
     {
         StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == Light.no && x.GUID == extResolve.GUID);
         if (intResolve != null)
         {
             if (resolveType == ResolveType.Load && Sideloader.DebugLogging.Value)
             {
                 Sideloader.Logger.LogDebug($"Resolving (Studio Light) [{extResolve.GUID}] {Light.no}->{intResolve.LocalSlot}");
             }
             Light.no = intResolve.LocalSlot;
         }
         else if (resolveType == ResolveType.Load)
         {
             ShowGUIDError(extResolve.GUID);
         }
     }
     else if (OI is OICharInfo CharInfo)
     {
         //Resolve the animation ID for the character
         StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == CharInfo.animeInfo.no && x.GUID == extResolve.GUID && x.Group == extResolve.Group && x.Category == extResolve.Category);
         if (intResolve != null)
         {
             if (resolveType == ResolveType.Load && Sideloader.DebugLogging.Value)
             {
                 Sideloader.Logger.LogDebug($"Resolving (Studio Animation) [{extResolve.GUID}] {CharInfo.animeInfo.group}:{CharInfo.animeInfo.category}:{CharInfo.animeInfo.no}->{intResolve.LocalSlot}");
             }
             CharInfo.animeInfo.no = intResolve.LocalSlot;
         }
         else if (resolveType == ResolveType.Load)
         {
             ShowGUIDError(extResolve.GUID);
         }
     }
 }
Пример #5
0
        internal static void ResolveStudioMap(ExtensibleSaveFormat.PluginData extData, ResolveType resolveType)
        {
            //Set map ID to the resolved ID
            int MapID = Singleton <Studio.Studio> .Instance.sceneInfo.map;

            if (MapID == -1) //Loaded scene has no map
            {
                return;
            }

            if (extData != null && extData.data.ContainsKey("mapInfoGUID"))
            {
                string MapGUID = (string)extData.data["mapInfoGUID"];

                StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == MapID && x.GUID == MapGUID);
                if (intResolve != null)
                {
                    if (resolveType == ResolveType.Load && Sideloader.DebugLogging.Value)
                    {
                        Sideloader.Logger.Log(LogLevel.Debug, $"Resolving (Studio Map) [{MapGUID}] {MapID}->{intResolve.LocalSlot}");
                    }
                    Singleton <Studio.Studio> .Instance.sceneInfo.map = intResolve.LocalSlot;
                }
                else
                {
                    ShowGUIDError(MapGUID);
                }
            }
            else if (resolveType == ResolveType.Load)
            {
                if (!Singleton <Info> .Instance.dicMapLoadInfo.TryGetValue(MapID, out Info.MapLoadInfo mapInfo))
                {
                    //Map ID saved to the scene doesn't exist in the map list, try compatibility resolving
                    StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == MapID);
                    if (intResolve != null)
                    {
                        //Found a matching sideloader mod
                        if (Sideloader.DebugLogging.Value)
                        {
                            Sideloader.Logger.Log(LogLevel.Debug, $"Compatibility resolving (Studio Map) {MapID}->{intResolve.LocalSlot}");
                        }
                        Singleton <Studio.Studio> .Instance.sceneInfo.map = intResolve.LocalSlot;
                    }
                    else
                    {
                        Sideloader.Logger.Log(LogLevel.Warning | LogLevel.Message, $"[UAR] Compatibility resolving (Studio Map) failed, no match found for ID {MapID}");
                    }
                }
            }
        }
Пример #6
0
        internal static void ResolveStudioBGM(ExtensibleSaveFormat.PluginData extData, ResolveType resolveType)
        {
            //Set bgm ID to the resolved ID
            int bgmID = Singleton <Studio.Studio> .Instance.sceneInfo.bgmCtrl.no;

            if (bgmID == -1) //Loaded scene has no bgm
            {
                return;
            }

            if (extData != null && extData.data.ContainsKey("bgmInfoGUID"))
            {
                string bgmGUID = (string)extData.data["bgmInfoGUID"];

                StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == bgmID && x.GUID == bgmGUID);
                if (intResolve != null)
                {
                    if (resolveType == ResolveType.Load && Sideloader.DebugLogging.Value)
                    {
                        Sideloader.Logger.LogDebug($"Resolving (Studio BGM) [{bgmGUID}] {bgmID}->{intResolve.LocalSlot}");
                    }
                    Singleton <Studio.Studio> .Instance.sceneInfo.bgmCtrl.no = intResolve.LocalSlot;
                }
                else
                {
                    ShowGUIDError(bgmGUID);
                }
            }
            else if (resolveType == ResolveType.Load)
            {
                if (!Singleton <Info> .Instance.dicBGMLoadInfo.TryGetValue(bgmID, out Info.LoadCommonInfo bgmInfo))
                {
                    //BGM ID saved to the scene doesn't exist in the bgm list, try compatibility resolving
                    StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == bgmID);
                    if (intResolve != null)
                    {
                        //Found a matching sideloader mod
                        if (Sideloader.DebugLogging.Value)
                        {
                            Sideloader.Logger.LogDebug($"Compatibility resolving (Studio BGM) {bgmID}->{intResolve.LocalSlot}");
                        }
                        Singleton <Studio.Studio> .Instance.sceneInfo.bgmCtrl.no = intResolve.LocalSlot;
                    }
                    else
                    {
                        Sideloader.Logger.Log(BepInEx.Logging.LogLevel.Warning | BepInEx.Logging.LogLevel.Message, $"[UAR] Compatibility resolving (Studio BGM) failed, no match found for ID {bgmID}");
                    }
                }
            }
        }
Пример #7
0
        private static void ExtendedSceneImport(string path)
        {
            PluginData ExtendedData = ExtendedSave.GetSceneExtendedDataById(UniversalAutoResolver.UARExtID);
            Dictionary <int, ObjectInfo> ObjectList = FindObjectInfo(SearchType.All);

            if (ExtendedData != null && ExtendedData.data.ContainsKey("itemInfo"))
            {
                object[] tmpExtInfo = (object[])ExtendedData.data["itemInfo"];
                List <StudioResolveInfo> extInfo          = tmpExtInfo.Select(x => StudioResolveInfo.Unserialize((byte[])x)).ToList();
                Dictionary <int, int>    ItemImportOrder  = FindObjectInfoOrder(SearchType.Import, typeof(OIItemInfo));
                Dictionary <int, int>    LightImportOrder = FindObjectInfoOrder(SearchType.Import, typeof(OILightInfo));

                //Match objects from the StudioResolveInfo to objects in the scene based on the item order that was generated and saved to the scene data
                foreach (StudioResolveInfo extResolve in extInfo)
                {
                    int NewDicKey = ItemImportOrder.Where(x => x.Value == extResolve.ObjectOrder).Select(x => x.Key).FirstOrDefault();
                    if (ObjectList[NewDicKey] is OIItemInfo Item)
                    {
                        UniversalAutoResolver.ResolveStudioObject(extResolve, Item);
                        ObjectList.Remove(NewDicKey);
                    }
                    else
                    {
                        NewDicKey = LightImportOrder.Where(x => x.Value == extResolve.ObjectOrder).Select(x => x.Key).FirstOrDefault();
                        if (ObjectList[extResolve.DicKey] is OILightInfo Light)
                        {
                            UniversalAutoResolver.ResolveStudioObject(extResolve, Light);
                            ObjectList.Remove(NewDicKey);
                        }
                    }
                }
            }

            //Resolve every item without extended data in case of hard mods
            foreach (ObjectInfo OI in ObjectList.Where(x => x.Value is OIItemInfo || x.Value is OILightInfo).Select(x => x.Value))
            {
                if (OI is OIItemInfo Item)
                {
                    UniversalAutoResolver.ResolveStudioObject(Item);
                }
                else if (OI is OILightInfo Light)
                {
                    UniversalAutoResolver.ResolveStudioObject(Light);
                }
            }

            //Maps are not imported
            //UniversalAutoResolver.ResolveStudioMap(extData);
        }
Пример #8
0
        internal static void ResolveStudioFilter(ExtensibleSaveFormat.PluginData extData, ResolveType resolveType)
        {
#if KK
            //Set filter ID to the resolved ID
            int filterID = Studio.Studio.Instance.sceneInfo.aceNo;

            if (extData != null && extData.data.ContainsKey("filterInfoGUID"))
            {
                string filterGUID = (string)extData.data["filterInfoGUID"];

                StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == filterID && x.GUID == filterGUID);
                if (intResolve != null)
                {
                    if (resolveType == ResolveType.Load && Sideloader.DebugLogging.Value)
                    {
                        Sideloader.Logger.LogDebug($"Resolving (Studio Filter) [{filterGUID}] {filterID}->{intResolve.LocalSlot}");
                    }
                    Studio.Studio.Instance.sceneInfo.aceNo = intResolve.LocalSlot;
                }
                else
                {
                    ShowGUIDError(filterGUID);
                }
            }
            else if (resolveType == ResolveType.Load)
            {
                if (!Info.Instance.dicFilterLoadInfo.TryGetValue(filterID, out Info.LoadCommonInfo filterInfo))
                {
                    //Filter ID saved to the scene doesn't exist in the filter list, try compatibility resolving
                    StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == filterID);
                    if (intResolve != null)
                    {
                        //Found a matching sideloader mod
                        if (Sideloader.DebugLogging.Value)
                        {
                            Sideloader.Logger.LogDebug($"Compatibility resolving (Studio Filter) {filterID}->{intResolve.LocalSlot}");
                        }
                        Studio.Studio.Instance.sceneInfo.aceNo = intResolve.LocalSlot;
                    }
                    else
                    {
                        Sideloader.Logger.Log(BepInEx.Logging.LogLevel.Warning | BepInEx.Logging.LogLevel.Message, $"[UAR] Compatibility resolving (Studio Filter) failed, no match found for ID {filterID}");
                    }
                }
            }
#endif
        }
Пример #9
0
 internal static void ResolveStudioObject(ObjectInfo OI)
 {
     if (OI is OIItemInfo Item)
     {
         if (!ListLoader.InternalStudioItemList.Contains(Item.no))
         {
             //Item does not exist in the item list, probably a missing hard mod. See if we have a sideloader mod with the same ID
             StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == Item.no);
             if (intResolve != null)
             {
                 //Found a match
                 if (Sideloader.DebugLogging.Value)
                 {
                     Sideloader.Logger.Log(LogLevel.Debug, $"Compatibility resolving (Studio Item) {Item.no}->{intResolve.LocalSlot}");
                 }
                 Traverse.Create(Item).Property("no").SetValue(intResolve.LocalSlot);
             }
             else
             {
                 //No match was found
                 Sideloader.Logger.Log(LogLevel.Warning | LogLevel.Message, $"[UAR] Compatibility resolving (Studio Item) failed, no match found for ID {Item.no}");
             }
         }
     }
     else if (OI is OILightInfo Light)
     {
         if (!Singleton <Info> .Instance.dicLightLoadInfo.TryGetValue(Light.no, out Info.LightLoadInfo lightLoadInfo))
         {
             StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == Light.no);
             if (intResolve != null)
             {
                 //Found a match
                 if (Sideloader.DebugLogging.Value)
                 {
                     Sideloader.Logger.Log(LogLevel.Debug, $"Compatibility resolving (Studio Light) {Light.no}->{intResolve.LocalSlot}");
                 }
                 Traverse.Create(Light).Property("no").SetValue(intResolve.LocalSlot);
             }
             else
             {
                 //No match was found
                 Sideloader.Logger.Log(LogLevel.Warning | LogLevel.Message, $"[UAR] Compatibility resolving (Studio Light) failed, no match found for ID {Light.no}");
             }
         }
     }
 }
Пример #10
0
        /// <summary>
        /// Compatibility resolving for objects with no extended save data
        /// </summary>
        internal static void ResolveStudioObject(ObjectInfo OI)
        {
            if (OI is OIItemInfo Item)
            {
                if (!Lists.InternalStudioItemList.Contains(Item.no))
                {
                    //Item does not exist in the item list, probably a missing hard mod. See if we have a sideloader mod with the same ID
                    StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == Item.no);
                    if (intResolve != null)
                    {
                        //Found a match
                        if (Sideloader.DebugLogging.Value)
                        {
                            Sideloader.Logger.LogDebug($"Compatibility resolving (Studio Item) {Item.no}->{intResolve.LocalSlot}");
                        }
                        Item.no = intResolve.LocalSlot;
                    }
                    else
                    {
                        //No match was found
                        Sideloader.Logger.Log(BepInEx.Logging.LogLevel.Warning | BepInEx.Logging.LogLevel.Message, $"[UAR] Compatibility resolving (Studio Item) failed, no match found for ID {Item.no}");
                    }
                }
            }
            else if (OI is OILightInfo Light)
            {
                if (!Singleton <Info> .Instance.dicLightLoadInfo.TryGetValue(Light.no, out Info.LightLoadInfo lightLoadInfo))
                {
                    StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == Light.no);
                    if (intResolve != null)
                    {
                        //Found a match
                        if (Sideloader.DebugLogging.Value)
                        {
                            Sideloader.Logger.LogDebug($"Compatibility resolving (Studio Light) {Light.no}->{intResolve.LocalSlot}");
                        }
                        Light.no = intResolve.LocalSlot;
                    }
                    else
                    {
                        //No match was found
                        Sideloader.Logger.Log(BepInEx.Logging.LogLevel.Warning | BepInEx.Logging.LogLevel.Message, $"[UAR] Compatibility resolving (Studio Light) failed, no match found for ID {Light.no}");
                    }
                }
            }
            else if (OI is OICharInfo CharInfo)
            {
                bool animationFound = false;
                if (Singleton <Info> .Instance.dicAnimeLoadInfo.TryGetValue(CharInfo.animeInfo.group, out var animeLoadInfo1))
                {
                    if (animeLoadInfo1.TryGetValue(CharInfo.animeInfo.category, out var animeLoadInfo2))
                    {
                        if (animeLoadInfo2.TryGetValue(CharInfo.animeInfo.no, out var animeLoadInfo3))
                        {
                            animationFound = true;
                        }
                    }
                }

                //Animation does not exist in the animation list, probably a missing hard mod. See if we have a sideloader mod with the same ID, Group, and Category
                if (!animationFound)
                {
                    StudioResolveInfo intResolve = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.Slot == CharInfo.animeInfo.no && x.Group == CharInfo.animeInfo.group && x.Category == CharInfo.animeInfo.category);
                    if (intResolve != null)
                    {
                        //Found a match
                        if (Sideloader.DebugLogging.Value)
                        {
                            Sideloader.Logger.LogDebug($"Compatibility resolving (Studio Animation) {CharInfo.animeInfo.no}->{intResolve.LocalSlot} Group {CharInfo.animeInfo.group} Category {CharInfo.animeInfo.category}");
                        }
                        CharInfo.animeInfo.no = intResolve.LocalSlot;
                    }
                    else
                    {
                        //No match was found
                        Sideloader.Logger.Log(BepInEx.Logging.LogLevel.Warning | BepInEx.Logging.LogLevel.Message, $"[UAR] Compatibility resolving (Studio Animation) failed, no match found for ID {CharInfo.animeInfo} Group {CharInfo.animeInfo.group} Category {CharInfo.animeInfo.category}");
                    }
                }
            }
        }
Пример #11
0
        internal static void GenerateStudioResolutionInfo(Manifest manifest, Lists.StudioListData data)
        {
            string StudioListType;

            if (data.FileNameWithoutExtension.Contains('_'))
            {
                StudioListType = data.FileNameWithoutExtension.Split('_')[0].ToLower();
            }
            else
            {
                return; //Not a studio list
            }
            if (StudioListType == "itembonelist")
            {
                foreach (List <string> entry in data.Entries)
                {
                    int slot = int.Parse(entry[0]);
                    int newSlot;

                    //See if the item this bone info cooresponds to has been resolved and set the ID to the same resolved ID
                    var item = LoadedStudioResolutionInfo.FirstOrDefault(x => x.ResolveItem && x.GUID == manifest.GUID && x.Slot == slot);
                    newSlot = item == null ? slot : item.LocalSlot;

                    LoadedStudioResolutionInfo.Add(new StudioResolveInfo
                    {
                        GUID        = manifest.GUID,
                        Slot        = slot,
                        LocalSlot   = newSlot,
                        ResolveItem = false
                    });

                    entry[0] = newSlot.ToString();
                }
            }
            else if (Sideloader.StudioListResolveBlacklist.Contains(StudioListType))
            {
                foreach (List <string> entry in data.Entries)
                {
                    //Add it to the resolution info as is, studio will automatically merge groups with the same IDs without causing exceptions.
                    //The IDs are expected to stay the same anyway as ItemLists will contain a reference to them.
                    //Because of this, all ID lookups should check if the thing is a ResolveItem.
                    LoadedStudioResolutionInfo.Add(new StudioResolveInfo
                    {
                        GUID        = manifest.GUID,
                        Slot        = int.Parse(entry[0]),
                        LocalSlot   = int.Parse(entry[0]),
                        ResolveItem = false
                    });
                }
            }
            else
            {
                foreach (List <string> entry in data.Entries)
                {
                    int newSlot = Interlocked.Increment(ref CurrentSlotID);

                    StudioResolveInfo studioResolveInfo = new StudioResolveInfo
                    {
                        GUID        = manifest.GUID,
                        Slot        = int.Parse(entry[0]),
                        LocalSlot   = newSlot,
                        ResolveItem = true
                    };

                    //Group and category is important for animations since the same ID can be used in different groups and categories
                    //...probably other item types too, but don't tell anyone or I'll have to add support for it
                    if (StudioListType == "anime" || StudioListType == "hanime")
                    {
#if KK
                        studioResolveInfo.Group    = int.Parse(entry[1]);
                        studioResolveInfo.Category = int.Parse(entry[2]);
#elif AI || HS2
                        studioResolveInfo.Group    = int.Parse(entry[2]);
                        studioResolveInfo.Category = int.Parse(entry[3]);
#endif
                    }

                    LoadedStudioResolutionInfo.Add(studioResolveInfo);

                    if (Sideloader.DebugLoggingResolveInfo.Value)
                    {
                        Sideloader.Logger.LogInfo($"StudioResolveInfo - " +
                                                  $"GUID: {manifest.GUID} " +
                                                  $"Slot: {int.Parse(entry[0])} " +
                                                  $"LocalSlot: {newSlot} " +
                                                  $"Count: {LoadedStudioResolutionInfo.Count}");
                    }

                    entry[0] = newSlot.ToString();
                }
            }
        }
Пример #12
0
            private static void SavePrefix()
            {
                Dictionary <string, object>     ExtendedData          = new Dictionary <string, object>();
                List <StudioResolveInfo>        ObjectResolutionInfo  = new List <StudioResolveInfo>();
                List <StudioPatternResolveInfo> PatternResolutionInfo = new List <StudioPatternResolveInfo>();
                Dictionary <int, ObjectInfo>    ObjectList            = FindObjectInfoAndOrder(SearchType.All, typeof(OIItemInfo), out Dictionary <int, int> ItemOrder);
                Dictionary <int, int>           LightOrder            = FindObjectInfoOrder(SearchType.All, typeof(OILightInfo));
                Dictionary <int, int>           CharOrder             = FindObjectInfoOrder(SearchType.All, typeof(OICharInfo));

                foreach (ObjectInfo oi in ObjectList.Select(x => x.Value))
                {
                    if (oi is OIItemInfo Item)
                    {
                        //Resolve the IDs of any patterns applied to the item
                        StudioPatternResolveInfo studioPatternResolveInfo = new StudioPatternResolveInfo
                        {
                            DicKey            = Item.dicKey,
                            ObjectOrder       = ItemOrder[Item.dicKey],
                            ObjectPatternInfo = new Dictionary <int, StudioPatternResolveInfo.PatternInfo>()
                        };
#if KK
                        for (int i = 0; i < Item.pattern.Length; i++)
                        {
                            if (Item.pattern[i].key >= BaseSlotID)
                            {
                                var intResolve = TryGetResolutionInfo(ChaListDefine.CategoryNo.mt_pattern, Item.pattern[i].key);

                                if (intResolve != null)
                                {
                                    studioPatternResolveInfo.ObjectPatternInfo[i] = new StudioPatternResolveInfo.PatternInfo
                                    {
                                        GUID      = intResolve.GUID,
                                        Slot      = intResolve.Slot,
                                        LocalSlot = Item.pattern[i].key
                                    };

                                    //Set pattern ID back to original non-resolved ID
                                    if (Sideloader.DebugLogging.Value)
                                    {
                                        Sideloader.Logger.LogDebug($"Setting [{Item.dicKey}] ID:{Item.pattern[i].key}->{intResolve.Slot}");
                                    }
                                    Item.pattern[i].key = intResolve.Slot;
                                }
                            }
                        }
#elif AI || HS2
                        for (int i = 0; i < Item.colors.Length; i++)
                        {
                            if (Item.colors[i].pattern.key >= BaseSlotID)
                            {
                                var intResolve = TryGetResolutionInfo(AIChara.ChaListDefine.CategoryNo.st_pattern, Item.colors[i].pattern.key);

                                if (intResolve != null)
                                {
                                    studioPatternResolveInfo.ObjectPatternInfo[i] = new StudioPatternResolveInfo.PatternInfo
                                    {
                                        GUID      = intResolve.GUID,
                                        Slot      = intResolve.Slot,
                                        LocalSlot = Item.colors[i].pattern.key
                                    };

                                    //Set pattern ID back to original non-resolved ID
                                    if (Sideloader.DebugLogging.Value)
                                    {
                                        Sideloader.Logger.LogDebug($"Setting [{Item.dicKey}] ID:{Item.colors[i].pattern.key}->{intResolve.Slot}");
                                    }
                                    Item.colors[i].pattern.key = intResolve.Slot;
                                }
                            }
                        }
#endif
                        if (studioPatternResolveInfo.ObjectPatternInfo.Count > 0)
                        {
                            PatternResolutionInfo.Add(studioPatternResolveInfo);
                        }

                        if (Item.no >= BaseSlotID)
                        {
                            StudioResolveInfo extResolve = LoadedStudioResolutionInfo.Where(x => x.LocalSlot == Item.no).FirstOrDefault();
                            if (extResolve != null)
                            {
                                StudioResolveInfo intResolve = new StudioResolveInfo
                                {
                                    GUID        = extResolve.GUID,
                                    Slot        = extResolve.Slot,
                                    LocalSlot   = extResolve.LocalSlot,
                                    DicKey      = Item.dicKey,
                                    ObjectOrder = ItemOrder[Item.dicKey]
                                };
                                ObjectResolutionInfo.Add(intResolve);

                                //Set item ID back to original non-resolved ID
                                if (Sideloader.DebugLogging.Value)
                                {
                                    Sideloader.Logger.LogDebug($"Setting [{Item.dicKey}] ID:{Item.no}->{extResolve.Slot}");
                                }
                                Traverse.Create(Item).Property("no").SetValue(extResolve.Slot);
                            }
                        }
                    }
                    else if (oi is OILightInfo Light && Light.no >= BaseSlotID)
                    {
                        StudioResolveInfo extResolve = LoadedStudioResolutionInfo.Where(x => x.LocalSlot == Light.no).FirstOrDefault();
                        if (extResolve != null)
                        {
                            StudioResolveInfo intResolve = new StudioResolveInfo
                            {
                                GUID        = extResolve.GUID,
                                Slot        = extResolve.Slot,
                                LocalSlot   = extResolve.LocalSlot,
                                DicKey      = Light.dicKey,
                                ObjectOrder = LightOrder[Light.dicKey]
                            };
                            ObjectResolutionInfo.Add(intResolve);

                            //Set item ID back to original non-resolved ID
                            if (Sideloader.DebugLogging.Value)
                            {
                                Sideloader.Logger.LogDebug($"Setting [{Light.dicKey}] ID:{Light.no}->{extResolve.Slot}");
                            }
                            Traverse.Create(Light).Property("no").SetValue(extResolve.Slot);
                        }
                    }