예제 #1
0
        //Load all tags for all portraits in folder
        public static Dictionary <string, TagData> LoadAllPortraitsTags(Dictionary <string, TagData> customTags, Boolean skipDefault)
        {
            PortraitTagSelector.portraitIDsUI = new string[] { };
            string[] existingCustomPortraitIds = CustomPortraitsManager.Instance.GetExistingCustomPortraitIds();

            Dictionary <string, TagData> result = new Dictionary <string, TagData>();

            for (int i = 0; i < existingCustomPortraitIds.Length; i++)
            {
                PortraitData portraitData = new PortraitData(existingCustomPortraitIds[i]);
                portraitData.EnsureImages(false);
                portraitData.CheckIfDefaultPortraitData();
                if (portraitData.IsDefault && skipDefault)
                {
                    continue;
                }
                List <string> tagList;
                if (customTags.ContainsKey(portraitData.CustomId))
                {
                    tagList = new List <string>(customTags[portraitData.CustomId].tags);
                }
                else
                {
                    tagList = new List <string>();
                }
                TagData resultTag = new TagData(GetPseudoHash(portraitData.FullLengthPortrait.texture).ToString(),
                                                portraitData.CustomId, tagList);
                result[resultTag.CustomId] = resultTag;
                portraitData = null;
            }
            return(result);
        }
예제 #2
0
        //Modified LoadAllCustomPortraits from the game. Added skipping default portraits. Not in use now
        public static List <PortraitData> LoadAllCustomPortraits(Boolean skipDefault)
        {
            string[]            existingCustomPortraitIds = CustomPortraitsManager.Instance.GetExistingCustomPortraitIds();
            List <PortraitData> list = new List <PortraitData>();

            for (int i = 0; i < existingCustomPortraitIds.Length; i++)
            {
                PortraitData portraitData = new PortraitData(existingCustomPortraitIds[i]);
                portraitData.EnsureImages(false);
                portraitData.CheckIfDefaultPortraitData();
                if (portraitData.IsDefault && skipDefault)
                {
                    continue;
                }
                list.Add(portraitData);
            }
            return(list);
        }
예제 #3
0
        //Test portraits and return available tags from the Import directory
        public static Dictionary <string, TagData> ImportPortraitsTags(Dictionary <string, TagData> customTags, Boolean skipDefault)
        {
            Dictionary <string, TagData> result = new Dictionary <string, TagData>();
            var existingCustomPortraitIdsList   = Enumerable.ToList <string>(Enumerable.Select <string, string>(
                                                                                 Directory.GetDirectories(ModPath + @"/Import"), (string p) => new DirectoryInfo(p).Name)
                                                                             );

            existingCustomPortraitIdsList.Remove("tags");
            string[] existingCustomPortraitIds = existingCustomPortraitIdsList.ToArray();
            for (int i = 0; i < existingCustomPortraitIds.Length; i++)
            {
                try
                {
                    PortraitData portraitData = new PortraitData(existingCustomPortraitIds[i]);
                    portraitData.EnsureImagesImport(false);
                    portraitData.CheckIfDefaultPortraitData();
                    if (portraitData.IsDefault && skipDefault)
                    {
                        continue;
                    }
                    List <string> tagList;
                    if (customTags.ContainsKey(portraitData.CustomId))
                    {
                        tagList = new List <string>(customTags[portraitData.CustomId].tags);
                    }
                    else
                    {
                        tagList = new List <string>();
                    }
                    TagData resultTag = new TagData(GetPseudoHash(portraitData.FullLengthPortrait.texture).ToString(),
                                                    portraitData.CustomId, tagList);
                    result[resultTag.CustomId] = resultTag;
                    portraitData = null;
                }
                catch (Exception ex)
                {
                    Main.Mod.Log($"Error processing {existingCustomPortraitIds[i]}");
#if (DEBUG)
                    Main.Mod.Log(ex.StackTrace);
#endif
                }
            }
            return(result);
        }