コード例 #1
0
        internal void LoadPlayerImages(string path)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            else
            {
                DirectoryInfo d = new DirectoryInfo(path);

                foreach (var file in d.GetFiles("*.jpg"))
                {
                    int    id;
                    String name = file.Name.Substring(0, file.Name.Length - 4);
                    if (int.TryParse(name, out id))
                    {
                        if (File.Exists(path + @"\" + name + "s.jpg"))
                        {
                            PlayerImage image = new PlayerImage
                            {
                                Portrait      = Image.FromFile(path + @"\" + name + ".jpg"),
                                SmallPortrait = Image.FromFile(path + @"\" + name + "s.jpg")
                            };
                            this.PlayerImages.Remove(id);
                            this.PlayerImages.Add(id, image);
                        }
                    }
                }
            }
        }
コード例 #2
0
        internal void LoadPlayerImages(string path)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            else
            {
                DirectoryInfo d = new DirectoryInfo(path);

                foreach (var file in d.GetFiles("*.jpg"))
                {
                    int id;
                    String name = file.Name.Substring(0, file.Name.Length - 4);
                    if (int.TryParse(name, out id))
                    {
                        if (File.Exists(path + @"\" + name + "s.jpg"))
                        {
                            PlayerImage image = new PlayerImage
                            {
                                Portrait = Image.FromFile(path + @"\" + name + ".jpg"),
                                SmallPortrait = Image.FromFile(path + @"\" + name + "s.jpg")
                            };
                            this.PlayerImages.Remove(id);
                            this.PlayerImages.Add(id, image);
                        }
                    }
                }
            }
        }
コード例 #3
0
        private PortraitItem GetItem(int id)
        {
            PortraitItem item;

            this.portraits.TryGetValue(id, out item);
            if (item == null)
            {
                PlayerImage image = null;
                this.PlayerImages.TryGetValue(id, out image);
                if (image == null)
                {
                    image = this.LoadImage(id);
                    this.PlayerImages.Add(id, image);
                    if (image == null)
                    {
                        image = defaultImage;
                    }
                }
                item = new PortraitItem();
                image.Portrait.Save(this.TempImageFileName);
                item.PortraitTexture = Texture2D.FromFile(this.Device, this.TempImageFileName);
                image.SmallPortrait.Save(this.TempImageFileName);
                item.SmallPortraitTexture = Texture2D.FromFile(this.Device, this.TempImageFileName);
                this.portraits.Add(id, item);
            }
            return(item);
        }
コード例 #4
0
ファイル: PersonPortrait.cs プロジェクト: bwj1007/wodeZHSAN
 private PlayerImage LoadImage(string path, float id)
 {
     if (File.Exists(path + @"\" + id + "f.jpg"))
     {
         if (File.Exists(path + @"\" + id + "s.jpg"))
         {
             if (File.Exists(path + @"\" + id + "t.jpg"))
             {
                 PlayerImage image = new PlayerImage
                 {
                     Portrait      = Image.FromFile(path + @"\" + id + ".jpg"),
                     SmallPortrait = Image.FromFile(path + @"\" + id + "s.jpg"),
                     TroopPortrait = Image.FromFile(path + @"\" + id + "t.jpg"),
                     FullPortrait  = Image.FromFile(path + @"\" + id + "f.jpg")
                 };
                 return(image);
             }
             else
             {
                 PlayerImage image = new PlayerImage
                 {
                     Portrait      = Image.FromFile(path + @"\" + id + ".jpg"),
                     SmallPortrait = Image.FromFile(path + @"\" + id + "s.jpg"),
                     TroopPortrait = Image.FromFile(path + @"\" + id + "s.jpg"),
                     FullPortrait  = Image.FromFile(path + @"\" + id + "f.jpg")
                 };
                 return(image);
             }
         }
     }
     else
     {
         if (File.Exists(path + @"\" + id + "s.jpg"))
         {
             if (File.Exists(path + @"\" + id + "t.jpg"))
             {
                 PlayerImage image = new PlayerImage
                 {
                     Portrait      = Image.FromFile(path + @"\" + id + ".jpg"),
                     SmallPortrait = Image.FromFile(path + @"\" + id + "s.jpg"),
                     TroopPortrait = Image.FromFile(path + @"\" + id + "t.jpg"),
                     FullPortrait  = Image.FromFile(path + @"\9999f.jpg")
                 };
                 return(image);
             }
             else
             {
                 PlayerImage image = new PlayerImage
                 {
                     Portrait      = Image.FromFile(path + @"\" + id + ".jpg"),
                     SmallPortrait = Image.FromFile(path + @"\" + id + "s.jpg"),
                     TroopPortrait = Image.FromFile(path + @"\" + id + "s.jpg"),
                     FullPortrait  = Image.FromFile(path + @"\9999f.jpg")
                 };
                 return(image);
             }
         }
     }
     return(null);
 }
コード例 #5
0
        private PlayerImage LoadImage(int id)
        {
            PlayerImage result = this.LoadImage(@"GameComponents\PersonPortrait\Images\Player", id);

            if (result == null)
            {
                result = this.LoadImage(@"GameComponents\PersonPortrait\Images\Default", id);
            }
            return(result);
        }
コード例 #6
0
        internal Image GetImage(int id)
        {
            Image       portrait = null;
            PlayerImage image2   = null;

            if (this.PlayerImages.TryGetValue(id, out image2))
            {
                portrait = image2.Portrait;
            }
            return(portrait);
        }
コード例 #7
0
 private PlayerImage LoadImage(string path, int id)
 {
     if (File.Exists(path + @"\" + id + "s.jpg"))
     {
         PlayerImage image = new PlayerImage
         {
             Portrait      = Image.FromFile(path + @"\" + id + ".jpg"),
             SmallPortrait = Image.FromFile(path + @"\" + id + "s.jpg")
         };
         return(image);
     }
     return(null);
 }
コード例 #8
0
        internal Image GetImage(int id)
        {
            string key      = this.GetKey(id);
            Image  portrait = (Image)this.PortraitRM.GetObject(key);

            if (portrait == null)
            {
                PlayerImage image2 = null;
                if (this.PlayerImages.TryGetValue(id, out image2))
                {
                    portrait = image2.Portrait;
                }
            }
            return(portrait);
        }
コード例 #9
0
        private PortraitItem GetItem(int id)
        {
            PortraitItem item;

            this.portraits.TryGetValue(id, out item);
            if (item == null)
            {
                PlayerImage image = null;
                this.PlayerImages.TryGetValue(id, out image);
                item = new PortraitItem();
                if (image == null)
                {
                    string key = this.GetKey(id);
                    try
                    {
                        Image image2 = (Image)this.PortraitRM.GetObject(key);
                        if (image2 != null)
                        {
                            image2.Save(this.TempImageFileName);
                            item.PortraitTexture = Texture2D.FromFile(this.Device, this.TempImageFileName);
                            image2 = (Image)this.SmallPortraitRM.GetObject(key + "s");
                            if (image2 == null)
                            {
                                return(null);
                            }
                            image2.Save(this.TempImageFileName);
                            item.SmallPortraitTexture = Texture2D.FromFile(this.Device, this.TempImageFileName);
                            this.portraits.Add(id, item);
                            return(item);
                        }
                        return(null);
                    }
                    finally
                    {
                        File.Delete(this.TempImageFileName);
                    }
                    return(item);
                }
                image.Portrait.Save(this.TempImageFileName);
                item.PortraitTexture = Texture2D.FromFile(this.Device, this.TempImageFileName);
                image.SmallPortrait.Save(this.TempImageFileName);
                item.SmallPortraitTexture = Texture2D.FromFile(this.Device, this.TempImageFileName);
                this.portraits.Add(id, item);
            }
            return(item);
        }
コード例 #10
0
        internal Image GetImage(int id)
        {
            Image       portrait = null;
            PlayerImage image    = null;

            if (!this.PlayerImages.TryGetValue(id, out image))
            {
                image = this.LoadImage(id);
                if (image == null)
                {
                    image = defaultImage;
                }
                this.PlayerImages.Add(id, image);
            }

            portrait = image.Portrait;

            return(portrait);
        }
コード例 #11
0
 internal void LoadPlayerImages(string path)
 {
     if (!Directory.Exists(path))
     {
         Directory.CreateDirectory(path);
     }
     else
     {
         for (int i = 0; i <= 32767; i++)
         {
             string str = path + @"\" + i.ToString() + ".jpg";
             string str2 = path + @"\" + i.ToString() + "s.jpg";
             if (File.Exists(str) && File.Exists(str2))
             {
                 PlayerImage image = new PlayerImage {
                     Portrait = Image.FromFile(str),
                     SmallPortrait = Image.FromFile(str2)
                 };
                 this.PlayerImages.Add(i, image);
             }
         }
     }
 }
コード例 #12
0
 internal void LoadPlayerImages(string path)
 {
     if (!Directory.Exists(path))
     {
         Directory.CreateDirectory(path);
     }
     else
     {
         for (int i = 0x1388; i <= 0x270f; i++)
         {
             string str  = path + @"\" + i.ToString() + ".jpg";
             string str2 = path + @"\" + i.ToString() + "s.jpg";
             if (File.Exists(str) && File.Exists(str2))
             {
                 PlayerImage image = new PlayerImage {
                     Portrait      = Image.FromFile(str),
                     SmallPortrait = Image.FromFile(str2)
                 };
                 this.PlayerImages.Add(i, image);
             }
         }
     }
 }
コード例 #13
0
 private PlayerImage LoadImage(string path, int id)
 {
     if (File.Exists(path + @"\" + id + "s.jpg"))
     {
         PlayerImage image = new PlayerImage
         {
             Portrait = Image.FromFile(path + @"\" + id + ".jpg"),
             SmallPortrait = Image.FromFile(path + @"\" + id + "s.jpg")
         };
         return image;
     }
     return null;
 }
コード例 #14
0
 public PersonPortrait()
 {
     defaultImage = LoadImage(9999);
 }
コード例 #15
0
 public PersonPortrait()
 {
     defaultImage = LoadImage(9999);
 }