Пример #1
0
        public void Init(Gender gender = Gender.None)
        {
            if (IsInitialized)
            {
                return;
            }
            _gender = SpritePath.Contains("[GENDER]") ? gender : Gender.None;
            if (_gender != Gender.None)
            {
                SpritePath = SpritePath.Replace("[GENDER]", (_gender == Gender.Female) ? "female" : "male");
            }
            if (Sprite != null)
            {
                Sprite.Remove();
            }
            Sprite              = new Sprite(SourceElement, "", SpritePath);
            Limb                = (LimbType)Enum.Parse(typeof(LimbType), SourceElement.GetAttributeString("limb", "Head"), true);
            HideLimb            = SourceElement.GetAttributeBool("hidelimb", false);
            HideOtherWearables  = SourceElement.GetAttributeBool("hideotherwearables", false);
            InheritLimbDepth    = SourceElement.GetAttributeBool("inheritlimbdepth", true);
            InheritTextureScale = SourceElement.GetAttributeBool("inherittexturescale", false);
            InheritOrigin       = SourceElement.GetAttributeBool("inheritorigin", false);
            InheritSourceRect   = SourceElement.GetAttributeBool("inheritsourcerect", false);
            DepthLimb           = (LimbType)Enum.Parse(typeof(LimbType), SourceElement.GetAttributeString("depthlimb", "None"), true);
            Sound               = SourceElement.GetAttributeString("sound", "");
            var index = SourceElement.GetAttributePoint("sheetindex", new Point(-1, -1));

            if (index.X > -1 && index.Y > -1)
            {
                SheetIndex = index;
            }
            IsInitialized = true;
        }
Пример #2
0
 private void ParsePath(bool parseSpritePath)
 {
     if (_gender != Gender.None)
     {
         SpritePath = SpritePath.Replace("[GENDER]", (_gender == Gender.Female) ? "female" : "male");
     }
     SpritePath = SpritePath.Replace("[VARIANT]", Variant.ToString());
     if (!File.Exists(SpritePath))
     {
         // If the variant does not exist, parse the path so that it uses first variant.
         Variant = 1;
         ReplaceNumbersWith(Variant.ToString());
     }
     if (parseSpritePath)
     {
         Sprite.ParseTexturePath(file: SpritePath);
     }
 }
        public void MakeBitmapImage(string CCPath)
        {
            if (SpritePath == null)
            {
                this.bitmapSource = null;
            }
            else
            {
                var fullSpritePath           = CCPath + "\\" + SpritePath.Replace('/', '\\');
                System.Drawing.Bitmap bitmap = null;
                try
                {
                    bitmap = new System.Drawing.Bitmap(fullSpritePath);
                }
                catch (ArgumentException)
                {
                    try
                    {
                        var spriteInfo = new FileInfo(fullSpritePath);
                        var image1Path = spriteInfo.FullName.Substring(0, spriteInfo.FullName.Length - spriteInfo.Extension.Length) +
                                         "000" + spriteInfo.Extension;
                        bitmap = new System.Drawing.Bitmap(image1Path);
                    }
                    catch (ArgumentException) { return; }
                }
                System.Drawing.Color transparentColor = System.Drawing.ColorTranslator.FromHtml("#FF00FF");
                bitmap.MakeTransparent(transparentColor);
                System.Drawing.Bitmap map          = new System.Drawing.Bitmap(bitmap);
                BitmapSource          bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                    map.GetHbitmap(),
                    IntPtr.Zero,
                    System.Windows.Int32Rect.Empty,
                    BitmapSizeOptions.FromWidthAndHeight(map.Width, map.Height)
                    );

                this.bitmapSource = bitmapSource;
            }
        }