Esempio n. 1
0
        public static void Export(PortraitSheet sheet, string baseDirectory)
        {
            foreach (int emoteIndex in sheet.emoteMap.Keys)
            {
                string emotion = GraphicsManager.Emotions[emoteIndex].Name;

                int ii = sheet.emoteMap[emoteIndex].Position;
                {
                    Texture2D tex = new Texture2D(device, GraphicsManager.PortraitSize, GraphicsManager.PortraitSize);
                    BaseSheet.Blit(sheet.baseTexture, tex, ii % sheet.TotalX * GraphicsManager.PortraitSize, ii / sheet.TotalX * GraphicsManager.PortraitSize, GraphicsManager.PortraitSize, GraphicsManager.PortraitSize, 0, 0);
                    using (Stream stream = new FileStream(baseDirectory + emotion + ".png", FileMode.Create, FileAccess.Write, FileShare.None))
                        ExportTex(stream, tex);
                    tex.Dispose();
                }

                if (sheet.emoteMap[emoteIndex].HasReverse)
                {
                    ii++;
                    Texture2D tex2 = new Texture2D(device, GraphicsManager.PortraitSize, GraphicsManager.PortraitSize);
                    BaseSheet.Blit(sheet.baseTexture, tex2, ii % sheet.TotalX * GraphicsManager.PortraitSize, ii / sheet.TotalX * GraphicsManager.PortraitSize, GraphicsManager.PortraitSize, GraphicsManager.PortraitSize, 0, 0);
                    using (Stream stream = new FileStream(baseDirectory + emotion + "^.png", FileMode.Create, FileAccess.Write, FileShare.None))
                        ExportTex(stream, tex2);
                    tex2.Dispose();
                }
            }
        }
Esempio n. 2
0
        public static PortraitSheet GetPortrait(MonsterID data)
        {
            data = GetFallbackForm(PortraitIndex, data);

            PortraitSheet sheet;

            if (portraitCache.TryGetValue(data, out sheet))
            {
                return(sheet);
            }

            if (data.IsValid())
            {
                try
                {
                    using (FileStream stream = File.OpenRead(String.Format(PORTRAIT_PATTERN, data.Species)))
                    {
                        using (BinaryReader reader = new BinaryReader(stream))
                        {
                            long position = PortraitIndex.GetPosition(data.Species, data.Form, (int)data.Skin, (int)data.Gender);
                            // Jump to the correct position
                            stream.Seek(position, SeekOrigin.Begin);
                            sheet = PortraitSheet.Load(reader);
                            portraitCache.Add(data, sheet);
                            return(sheet);
                        }
                    }
                }
                catch (Exception ex)
                {
                    DiagManager.Instance.LogError(new Exception("Error loading portrait " + data.Species + " " + data.Form + "-" + data.Skin + "-" + data.Gender + "\n", ex));
                }
            }

            //add error sheet
            PortraitSheet error = PortraitSheet.LoadError();

            portraitCache.Add(data, error);
            return(error);
        }