Example #1
0
 private void ParseTree(ASTNode root, string filename, PortraitData data)
 {
     foreach (ASTNode child in root.Children)
     {
         ParsePortraits(child, filename, data);
     }
 }
Example #2
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);
        }
Example #3
0
 internal static bool EnsureImagesImport(this PortraitData portraitData, bool force = false)
 {
     return(portraitData.IsCustom &&
            (portraitData.EnsureImageImport(PortraitType.SmallPortrait, force) &
             portraitData.EnsureImageImport(PortraitType.HalfLengthPortrait, force) &
             portraitData.EnsureImageImport(PortraitType.FullLengthPortrait, force)));
 }
Example #4
0
        //Load portrait data for 1 ID
        public static PortraitData LoadPortraitData(string customID)
        {
            PortraitData result = new PortraitData(customID);

            result.EnsureImages(false);
            return(result);
        }
Example #5
0
 internal void OnEnable()
 {
     _portrait            = (PortraitCache)target;
     _data                = _portrait.data;
     _portrait.guiAction -= DrawGameViewRect;
     _portrait.guiAction += DrawGameViewRect;
 }
Example #6
0
        // Token: 0x06000053 RID: 83 RVA: 0x00005694 File Offset: 0x00003894
        public static void Postfix(LeaderState.Leader __instance, PortraitData __result)
        {
            if (!Main.modEnabled)
            {
                return;
            }
            if (!Main.settings.useKingdomManagementCustomPortraitFix)
            {
                return;
            }



            if (__result.FullLengthPortrait != null && !__result.FullLengthPortrait.texture.name.StartsWith("sactx") &&
                !__result.FullLengthPortrait.name.Equals("resized"))
            {
                Sprite sprite = Sprite.Create(__result.FullLengthPortrait.texture, __result.FullLengthPortrait.textureRect, new Vector2((float)0.5, (float)0.5), 100);

                sprite.name = "resized";


                typeof(PortraitData).GetField("m_FullLengthImage", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__result, sprite);
            }

            return;
        }
 // Update is called once per frame
 void Update()
 {
     if (pd)
     {
         if (r)
         {
             Material mat = r.material;
             if (mat && mat.color != pd.TeamColor)
             {
                 mat.color = pd.TeamColor;
                 mat.SetColor("_EmissionColor", pd.TeamColor);
             }
         }
     }
     else
     {
         foreach (PortraitData p in FindObjectsOfType <PortraitData>())
         {
             if (p.team == t)
             {
                 pd = p;
             }
         }
     }
 }
Example #8
0
 private void MergePortraitData()
 {
     ActivePortraitData = new PortraitData();
     foreach (Content content in ActiveContent)
     {
         ActivePortraitData.MergeWith(content.PortraitData);
     }
 }
Example #9
0
 internal static void Unload()
 {
     allPortraitsData = null;
     portraitData     = null;
     portraitIDs      = null;
     tagsData         = null;
     tagListAll       = null;
     _tagList         = null;
     _tagData         = null;
 }
 // Use this for initialization
 void Start()
 {
     r = GetComponent <Renderer>();
     foreach (PortraitData p in FindObjectsOfType <PortraitData>())
     {
         if (p.team == t)
         {
             pd = p;
         }
     }
 }
Example #11
0
        private void MergePortraitData()
        {
            activePortraitData = new PortraitData();

            activePortraitData.MergeWith(vanilla.PortraitData);
            // Recalculate merged portrait data
            foreach (Content content in activeContents)
            {
                activePortraitData.MergeWith(content.PortraitData);
            }
        }
Example #12
0
 public Player(string name, string race, string league, int place, int points, int wins, int losses, PortraitData portrait)
 {
     Name     = name;
     Place    = place;
     Race     = Matchup.RaceFromString(race);
     League   = LeagueFromString(league);
     Points   = points;
     Portrait = portrait;
     Wins     = wins;
     Losses   = losses;
 }
Example #13
0
        /// <summary>
        /// Parses a given portrait.gfx file.
        /// </summary>
        /// <param name="filename">Path of the file to parse.</param>
        private void Parse(string filename, PortraitData data)
        {
            if (!File.Exists(filename))
            {
                logger.Error(string.Format("File not found: {0}", filename));
                return;
            }
            // Exclude vanilla files with known errors
            if (filename.EndsWith("DefaultDialog.gfx") || filename.EndsWith("EU3_mapitems.gfx") || filename.EndsWith("chatfonts.gfx") ||
                filename.EndsWith("fonts.gfx") || filename.EndsWith("mapitems.gfx"))
            {
                logger.Info(string.Format("Skipping parsing of file: {0}", filename));
                return;
            }

            StreamReader stream      = new StreamReader(filename, Encoding.GetEncoding(1252));
            string       fileContent = stream.ReadToEnd();

            stream.Dispose();

            //Check the file isn't empty
            string[] lines   = fileContent.Split(fileContent.Contains('\r') ? '\r' : '\n');
            bool     isEmpty = true;

            for (int i = 0; i < lines.Length; i++)
            {
                if (!lines[i].Trim().StartsWith("#") && !String.IsNullOrEmpty(lines[i].Trim()))
                {
                    isEmpty = false;
                    break;
                }
            }

            if (isEmpty)
            {
                logger.Warn("File is empty: " + filename);
                return;
            }

            //Parse the file
            PortraitReaderLexer  lexer  = new PortraitReaderLexer(fileContent);
            PortraitReaderParser parser = new PortraitReaderParser(lexer);

            ParseResult result = parser.Parse();

            if (!result.IsSuccess)
            {
                logger.Error(String.Format("Lexical error in file {0}, line {1}", (new FileInfo(filename).Name), string.Concat(result.Errors)));
                return;
            }

            ParseTree(result.Root, filename, data);
        }
Example #14
0
        public void LoadVanilla()
        {
            vanilla              = new Content();
            vanilla.Name         = "vanilla";
            vanilla.AbsolutePath = user.GameDir;

            logger.Info("Loading portraits from vanilla.");
            vanilla.PortraitData = portraitReader.Parse(user.GameDir);

            // Init
            activePortraitData = vanilla.PortraitData;
            activeContents.Add(vanilla);
        }
Example #15
0
        /// <summary>
        /// Parse Portrait data.
        ///
        /// Parsing errors are catched at layer, propertyType or file level, so the PortraitData may be partial or even empty.
        /// </summary>
        /// <param name="dir">The content root directory to parse from</param>
        /// <returns></returns>
        public PortraitData Parse()
        {
            var data = new PortraitData();

            try
            {
                var fileNames = Enumerable.Empty <string>();
                logger.LogDebug("Scanning for portrait data files in " + BaseDir);
                logger.LogDebug("Directories: " + Directory.GetDirectories(BaseDir));

                if (Directory.Exists(InterfaceDirectory))
                {
                    fileNames = fileNames.Concat(Directory.EnumerateFiles(InterfaceDirectory, "*.gfx"));
                }
                else
                {
                    logger.LogDebug("Folder not found: " + Path.Combine(BaseDir, "interface"));
                }

                // interface/portraits seems to be loaded after interface/, and override (cf byzantinegfx)
                if (Directory.Exists(PortraitsDirectory))
                {
                    fileNames = fileNames.Concat(Directory.EnumerateFiles(PortraitsDirectory, "*.gfx"));
                }
                else
                {
                    logger.LogDebug("Folder not found: " + Path.Combine(BaseDir, "interface", "portraits"));
                }

                foreach (string fileName in fileNames)
                {
                    Parse(fileName, data);
                }

                if (Directory.Exists(PortraitOffsetsDirectory))
                {
                    data.Offsets = Directory.EnumerateFiles(PortraitOffsetsDirectory, "*.txt")
                                   .SelectMany(portraitOffsetReader.Parse)
                                   .Concat(data.Offsets)
                                   .ToLookup(d => d.Key, d => d.Value)
                                   .ToDictionary(d => d.Key, d => d.First());
                }
            }
            catch (Exception e)
            {
                logger.LogError("Failed to parse portrait data in " + BaseDir, e);
            }

            return(data);
        }
Example #16
0
 private PortraitData CharacterDataFromUI(PortraitData data)
 {
     data.Name              = txtCharactersName.Text;
     data.DisplayName       = txtCharactersDisplayName.Text;
     data.ForegroundColorID = fgpCharactersFGPalette.Data;
     data.BackgroundColor   = pltCharactersBGPalette.Data;
     data.Background        = picCharactersBG.Image;
     data.Foreground        = picCharactersFG.Image;
     data.AccentColor       = fgpCharacterAccent.Data;
     data.Voice.Pitch       = (float)nudPitch.Value;
     data.Voice.VoiceType   = (VoiceType)cmbVoiceType.SelectedIndex;
     CurrentFile            = data.Name;
     Dirty = false;
     return(data);
 }
Example #17
0
        /// <summary>
        /// Parses a given portrait.gfx file.
        /// </summary>
        /// <param name="filename">Path of the file to parse.</param>
        private void Parse(string filename, PortraitData data)
        {
            var fi = new FileInfo(filename);

            if (!fi.Exists)
            {
                logger.LogError($"File not found: {filename}");
                return;
            }

            // Exclude vanilla files with known errors
            if (BadFiles.Contains(fi.Name))
            {
                logger.LogInformation($"Skipping parsing of file: {filename}");
                return;
            }

            //Check the file isn't empty
            var hasContent = File.ReadLines(filename, WesternEncoding)
                             .Select(l => l.Trim())
                             .Any(l => !l.StartsWith("#"));

            if (!hasContent)
            {
                logger.LogWarning($"File is empty: {filename}");
                return;
            }

            ParseResult result;

            using (var fs = File.OpenRead(filename))
                using (var fileReader = new StreamReader(fs, WesternEncoding))
                {
                    //Parse the file
                    PortraitReaderLexer  lexer  = new PortraitReaderLexer(fileReader);
                    PortraitReaderParser parser = new PortraitReaderParser(lexer);

                    result = parser.Parse();
                }

            if (!result.IsSuccess)
            {
                logger.LogError($"Lexical error in file {fi.Name}, line {result.Errors}");
                return;
            }

            ParseTree(result.Root, filename, data);
        }
Example #18
0
        /// <summary>
        /// Parse Portrait data.
        ///
        /// Parsing errors are catched at layer, propertyType or file level, so the PortraitData may be partial or even empty.
        /// </summary>
        /// <param name="dir">The content root directory to parse from</param>
        /// <returns></returns>
        public PortraitData Parse(string dir)
        {
            PortraitData data = new PortraitData();

            try {
                List <string> fileNames = new List <string>();
                logger.Debug("Scanning for portrait data files in " + dir);
                logger.Debug("Directories: " + Directory.GetDirectories(dir));

                if (Directory.Exists(Path.Combine(dir, "interface")))
                {
                    fileNames.AddRange(Directory.GetFiles(Path.Combine(dir, "interface"), "*.gfx"));
                }
                else
                {
                    logger.Debug("Folder not found: " + Path.Combine(dir, "interface"));
                }
                // interface/portraits seems to be loaded after interface/, and override (cf byzantinegfx)
                if (Directory.Exists(Path.Combine(dir, "interface", "portraits")))
                {
                    fileNames.AddRange(Directory.GetFiles(Path.Combine(dir, "interface", "portraits"), "*.gfx"));
                }
                else
                {
                    logger.Debug("Folder not found: " + Path.Combine(dir, "interface", "portraits"));
                }

                foreach (string fileName in fileNames)
                {
                    Parse(fileName, data);
                }

                if (Directory.Exists(Path.Combine(dir, "interface", "portrait_offsets")))
                {
                    string[] offsetFileNames = Directory.GetFiles(Path.Combine(dir, "interface", "portrait_offsets"), "*.txt");
                    foreach (string offsetFileName in offsetFileNames)
                    {
                        Dictionary <string, Point> offsets = portraitOffsetReader.Parse(offsetFileName);
                        data.Offsets = data.Offsets.Concat(offsets).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.First().Value);
                    }
                }
            } catch (Exception e) {
                logger.Error("Failed to parse portrait data in " + dir, e);
            }

            return(data);
        }
Example #19
0
    public void SetTeam(Team t)
    {
        TroopActor ta = bigBase.GetComponentInChildren <TroopActor>();

        HangerSpawner[] hangers = bigBase.GetComponentsInChildren <HangerSpawner>();
        TriggerWin      tw      = bigBase.GetComponentInChildren <TriggerWin>();
        PortraitData    pd      = bigBase.GetComponentInChildren <PortraitData>();

        if (pd)
        {
            pd.team      = t;
            pd.TeamColor = primaryColour;
        }
        else
        {
            Debug.LogWarning("Please assign a PortraitData Component to " + bigBase.name);
        }

        if (ta)
        {
            ta.team = t;
        }
        else
        {
            Debug.LogWarning("please assign a Troop Actor Component to " + bigBase.name);
        }
        if (hangers.Length > 0)
        {
            foreach (HangerSpawner hanger in hangers)
            {
                hanger.team = t;
            }
        }
        else
        {
            Debug.LogWarning("please assign at least one HangerSpawner Component to " + bigBase.name);
        }
        if (tw)
        {
            tw.team = t;
        }
        else
        {
            Debug.LogWarning("please assign a TriggerWin Component to " + bigBase.name);
        }
    }
Example #20
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);
        }
Example #21
0
 private void CharacterDataToUI(PortraitData data)
 {
     data.LoadImages(WorkingDirectory);
     txtCharactersName.Text        = data.Name;
     txtCharactersDisplayName.Text = data.DisplayName;
     fgpCharactersFGPalette.Data   = data.ForegroundColorID;
     pltCharactersBGPalette.Data   = data.BackgroundColor;
     picCharactersBG.Image         = data.Background ?? new PalettedImage(new Bitmap(1, 1));
     picCharactersBG.Palette       = data.BackgroundColor;
     picCharactersFG.Image         = data.Foreground ?? new PalettedImage(new Bitmap(1, 1));
     picCharactersFG.Palette       = BaseSpritePalettes[fgpCharactersFGPalette.Data];
     fgpCharacterAccent.Data       = data.AccentColor;
     nudPitch.Value             = (decimal)data.Voice.Pitch;
     cmbVoiceType.SelectedIndex = (int)data.Voice.VoiceType;
     UpdateCharacterPreview();
     CurrentFile = data.Name;
     Dirty       = false;
 }
Example #22
0
    // Use this for initialization
    void Start()
    {
        foreach (TroopController tci in FindObjectsOfType <TroopController>())
        {
            if (tci.team == team)
            {
                tc = tci;
            }
        }

        foreach (PortraitData pdi in FindObjectsOfType <PortraitData>())
        {
            if (pdi.team == team)
            {
                pd = pdi;
            }
        }
    }
Example #23
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);
        }
Example #24
0
        private void DrawEditCamera()
        {
            GUILayout.Label("Ref Camera", EditStyles.boldLabel);
            Camera cam = _portrait.editCamera;

            cam.fieldOfView           = EditorGUILayout.FloatField("Field Of View", cam.fieldOfView);
            cam.farClipPlane          = EditorGUILayout.FloatField("Far clip Plane", cam.farClipPlane);
            cam.nearClipPlane         = EditorGUILayout.FloatField("Near clip Plane", cam.nearClipPlane);
            cam.transform.position    = EditorGUILayout.Vector3Field("Position", cam.transform.position);
            cam.transform.eulerAngles = EditorGUILayout.Vector3Field("Rotate", cam.transform.eulerAngles);
            _portrait.drawRect        = EditorGUILayout.Toggle("Draw Rect", _portrait.drawRect);
            syncSceneView             = EditorGUILayout.Toggle("Sync to Scene View", syncSceneView);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Copy"))
            {
                copyData = new PortraitData();
                copyData.CopyFrom(_data);
            }
            if (GUILayout.Button("Paste"))
            {
                if (copyData != null)
                {
                    _data.CopyFrom(copyData);
                    EditorUtility.SetDirty(_portrait);
                    SyncToSceneView();
                }
            }

            if (GUILayout.Button("Back To Setting"))
            {
                PortraitData.DataToCamera(cam, _data);
                SyncToSceneView();
            }
            if (GUILayout.Button("Snap"))
            {
                PortraitData.CameraToData(cam, _data);
                EditorUtility.SetDirty(_portrait);
            }

            GUILayout.EndHorizontal();
        }
Example #25
0
    IEnumerator moveLips(Image image, PortraitData portraitData)
    {
        int aux = 0;

        while (true)
        {
            if (aux % 2 == 0)
            {
                image.sprite = portraitData.spriteMouthClosed;
            }
            else
            {
                image.sprite = portraitData.spriteMouthOpen;
            }
            aux++;
            float time = Random.Range(0.2f, 0.4f);
            time /= dialogue.speed;
            yield return(new WaitForSeconds(time));
        }
    }
Example #26
0
        public static bool Prefix(ref PortraitData __result, BlueprintPortrait ___m_Portrait)
        {
            if (!Main.enabled)
            {
                return(true);
            }
            if (___m_Portrait?.AssetGuid == null)
            {
                return(true);
            }

            BlueprintPortrait p = CompanionCustomPortraitsManager.Instance.GetPortrait(___m_Portrait.AssetGuid);

            if (p != null)
            {
                __result = p.Data;
                return(false);
            }

            return(true);
        }
Example #27
0
        private void LoadPortrait(string name)
        {
            if (name.Contains("?"))
            {
                picPreviewSpeaker.BackgroundImage = null;
                picPreviewSpeaker.Image           = null;
                return;
            }
            PortraitData portrait = Portraits.Find(a => a.Name == name);

            if (portrait == null)
            {
                picPreviewSpeaker.BackgroundImage = null;
                picPreviewSpeaker.Image           = null;
                return;
            }
            portrait.LoadImages(WorkingDirectory);
            picPreviewSpeaker.BackgroundImage = portrait.Background.ToBitmap(portrait.BackgroundColor).Resize(2);
            picPreviewSpeaker.Image           = portrait.Foreground.ToBitmap(BaseSpritePalettes[portrait.ForegroundColorID]).Resize(2);
            lblPreviewName.Text = portrait.DisplayName;
        }
Example #28
0
        internal static bool EnsureImageImport(this PortraitData portraitData, PortraitType portraitType, bool force = false)
        {
            EnsureCustomPortraitsImport(portraitData.m_CustomPortraitId, true);
            switch (portraitType)
            {
            case PortraitType.SmallPortrait:
                portraitData.m_PortraitImage = PortraitData.UploadSprite(GetSmallPortraitPathImport(portraitData.CustomId), BlueprintRoot.Instance.CharGen.BasePortraitSmall, force);
                return(portraitData.m_PortraitImage != null);

            case PortraitType.HalfLengthPortrait:
                portraitData.m_HalfLengthImage = PortraitData.UploadSprite(GetMediumPortraitPathImport(portraitData.CustomId), BlueprintRoot.Instance.CharGen.BasePortraitMedium, force);
                return(portraitData.m_HalfLengthImage != null);

            case PortraitType.FullLengthPortrait:
                portraitData.m_FullLengthImage = PortraitData.UploadSprite(GetBigPortraitPathImport(portraitData.CustomId), BlueprintRoot.Instance.CharGen.BasePortraitBig, force);
                return(portraitData.m_FullLengthImage != null);

            default:
                return(false);
            }
        }
Example #29
0
    void changePortrait(string portrait)
    {
        //receiving "arjuna_normal"
        int index = 0;

        char[] array = portrait.ToCharArray();

        for (; index < portrait.Length && array[index] != '_'; index++)
        {
            ;
        }

        string character = portrait.Substring(0, index);
        string emote     = portrait.Substring(index + 1, portrait.Length - index - 1);

        PortraitData newPortrait = portraitDatabase.getPortraitSprite(character, emote);

        if (character == "noir")
        {
            if (portraitRightTalking != null)
            {
                StopCoroutine(portraitRightTalking);
                portraitRightTalking = null;
            }
            portraitRightData      = newPortrait;
            portraitRightText.text = portraitDatabase.getPortraitTitle(character);
            portraitRightTalking   = StartCoroutine(moveLips(portraitRight, newPortrait));
        }
        else
        {
            if (portraitLeftTalking != null)
            {
                StopCoroutine(portraitLeftTalking);
                portraitLeftTalking = null;
            }
            portraitLeftData      = newPortrait;
            portraitLeftText.text = portraitDatabase.getPortraitTitle(character);
            portraitLeftTalking   = StartCoroutine(moveLips(portraitLeft, newPortrait));
        }
    }
Example #30
0
        private void ParsePortraits(ASTNode node, string filename, PortraitData data)
        {
            IEnumerable <ASTNode> children = node.Children.Where(child => child.Symbol.Name == "groupOption");
            String id;

            foreach (ASTNode child in children)
            {
                id = child.Children[0].Value;

                if (id == "spriteType")
                {
                    try {
                        Sprite sprite = ParseSpriteType(child, filename);
                        if (data.Sprites.ContainsKey(sprite.Name))
                        {
                            logger.Debug("Sprite already exists. Replacing.");
                            data.Sprites.Remove(sprite.Name);
                        }
                        data.Sprites.Add(sprite.Name, sprite);
                    } catch (Exception e) {
                        logger.Error(string.Format("Could not parse spriteType in file {0}", filename), e);
                    }
                }
                else if (id == "portraitType")
                {
                    try {
                        PortraitType portraitType = ParsePortraitType(child, filename);
                        if (data.PortraitTypes.ContainsKey(portraitType.Name))
                        {
                            logger.Debug("Portrait type " + portraitType.Name + "exists. Replacing.");
                            data.PortraitTypes.Remove(portraitType.Name);
                        }
                        data.PortraitTypes.Add(portraitType.Name, portraitType);
                    } catch (Exception e) {
                        logger.Error(string.Format("Could not parse portraitType in file {0}", filename), e);
                    }
                }
            }
        }