Exemplo n.º 1
0
        public void ReadLibrary()
        {
            lock (LoadLocker)
            {
                if (Loading)
                {
                    return;
                }
                Loading = true;
            }

            if (_BReader == null)
            {
                Loaded = true;
                return;
            }

            using (MemoryStream mstream = new MemoryStream(_BReader.ReadBytes(_BReader.ReadInt32())))
                using (BinaryReader reader = new BinaryReader(mstream))
                {
                    Images = new MirImage[reader.ReadInt32()];

                    for (int i = 0; i < Images.Length; i++)
                    {
                        if (!reader.ReadBoolean())
                        {
                            continue;
                        }

                        Images[i] = new MirImage(reader);
                    }
                }

            Loaded = true;
        }
Exemplo n.º 2
0
        public MirImage CreateImage(int index, ImageType type)
        {
            if (!CheckImage(index))
            {
                return(null);
            }

            MirImage image = Images[index];

            Texture texture;

            switch (type)
            {
            case ImageType.Image:
                if (!image.ImageValid)
                {
                    image.CreateImage(_BReader);
                }
                texture = image.Image;
                break;

            case ImageType.Shadow:
                if (!image.ShadowValid)
                {
                    image.CreateShadow(_BReader);
                }
                texture = image.Shadow;
                break;

            case ImageType.Overlay:
                if (!image.OverlayValid)
                {
                    image.CreateOverlay(_BReader);
                }
                texture = image.Overlay;
                break;

            default:
                return(null);
            }

            if (texture == null)
            {
                return(null);
            }

            return(image);
        }
Exemplo n.º 3
0
        public bool VisiblePixel(int index, Point location, bool accurate = true, bool offSet = false)
        {
            if (!CheckImage(index))
            {
                return(false);
            }

            MirImage image = Images[index];

            if (offSet)
            {
                location = new Point(location.X - image.OffSetX, location.Y - image.OffSetY);
            }

            return(image.VisiblePixel(location, accurate));
        }
Exemplo n.º 4
0
        public void DrawBlend(int index, float x, float y, Color4 colour, bool useOffSet, float rate, ImageType type, byte shadow = 0)
        {
            if (!CheckImage(index))
            {
                return;
            }

            MirImage image = Images[index];

            Texture texture;

            switch (type)
            {
            case ImageType.Image:
                if (!image.ImageValid)
                {
                    image.CreateImage(_BReader);
                }
                texture = image.Image;
                if (useOffSet)
                {
                    x += image.OffSetX;
                    y += image.OffSetY;
                }
                break;

            case ImageType.Shadow:
                return;

            /*     if (!image.ShadowValid) image.CreateShadow(_BReader);
             *   texture = image.Shadow;
             *
             *   if (useOffSet)
             *   {
             *       x += image.ShadowOffSetX;
             *       y += image.ShadowOffSetY;
             *   }
             *   break;*/
            case ImageType.Overlay:
                if (!image.OverlayValid)
                {
                    image.CreateOverlay(_BReader);
                }
                texture = image.Overlay;

                if (useOffSet)
                {
                    x += image.OffSetX;
                    y += image.OffSetY;
                }
                break;

            default:
                return;
            }
            if (texture == null)
            {
                return;
            }


            bool  oldBlend = DXManager.Blending;
            float oldRate  = DXManager.BlendRate;

            DXManager.SetBlend(true, rate);

            DXManager.Sprite.Draw(texture, Vector3.Zero, new Vector3(x, y, 0), colour);
            CEnvir.DPSCounter++;

            DXManager.SetBlend(oldBlend, oldRate);

            image.ExpireTime = Time.Now + Config.CacheDuration;
        }
Exemplo n.º 5
0
        public void DrawBlend(int index, float size, Color4 colour, float x, float y, float angle, float opacity, ImageType type, bool useOffSet = false, byte shadow = 0)
        {
            if (!CheckImage(index))
            {
                return;
            }

            MirImage image = Images[index];

            Texture texture;

            switch (type)
            {
            case ImageType.Image:
                if (!image.ImageValid)
                {
                    image.CreateImage(_BReader);
                }
                texture = image.Image;
                if (useOffSet)
                {
                    x += image.OffSetX;
                    y += image.OffSetY;
                }
                break;

            case ImageType.Shadow:
                return;

            /*     if (!image.ShadowValid) image.CreateShadow(_BReader);
             *   texture = image.Shadow;
             *
             *   if (useOffSet)
             *   {
             *       x += image.ShadowOffSetX;
             *       y += image.ShadowOffSetY;
             *   }
             *   break;*/
            case ImageType.Overlay:
                if (!image.OverlayValid)
                {
                    image.CreateOverlay(_BReader);
                }
                texture = image.Overlay;

                if (useOffSet)
                {
                    x += image.OffSetX;
                    y += image.OffSetY;
                }
                break;

            default:
                return;
            }
            if (texture == null)
            {
                return;
            }


            bool  oldBlend = DXManager.Blending;
            float oldRate  = DXManager.BlendRate;

            DXManager.SetBlend(true, opacity);

            var scaling     = Matrix.Scaling(size, size, 0f);
            var rotationZ   = Matrix.RotationZ(angle);
            var translation = Matrix.Translation(x + (image.Width / 2), y + (image.Height / 2), 0);

            DXManager.Sprite.Transform = scaling * rotationZ * translation;

            DXManager.Sprite.Draw(texture, Vector3.Zero, new Vector3((image.Width / 2) * -1, (image.Height / 2) * -1, 0), colour);

            DXManager.Sprite.Transform = Matrix.Identity;

            CEnvir.DPSCounter++;

            DXManager.SetBlend(oldBlend, oldRate);

            image.ExpireTime = Time.Now + Config.CacheDuration;
        }
Exemplo n.º 6
0
        public void Draw(int index, float x, float y, Color4 colour, bool useOffSet, float opacity, ImageType type)
        {
            if (!CheckImage(index))
            {
                return;
            }

            MirImage image = Images[index];

            Texture texture;

            float oldOpacity = DXManager.Opacity;

            switch (type)
            {
            case ImageType.Image:
                if (!image.ImageValid)
                {
                    image.CreateImage(_BReader);
                }
                texture = image.Image;
                if (useOffSet)
                {
                    x += image.OffSetX;
                    y += image.OffSetY;
                }
                break;

            case ImageType.Shadow:
                if (!image.ShadowValid)
                {
                    image.CreateShadow(_BReader);
                }
                texture = image.Shadow;

                if (useOffSet)
                {
                    x += image.ShadowOffSetX;
                    y += image.ShadowOffSetY;
                }


                if (texture == null)
                {
                    if (!image.ImageValid)
                    {
                        image.CreateImage(_BReader);
                    }
                    texture = image.Image;

                    switch (image.ShadowType)
                    {
                    case 177:
                    case 176:
                    case 49:
                        Matrix m = Matrix.Scaling(1F, 0.5f, 0);

                        m.M21 = -0.50F;
                        DXManager.Sprite.Transform = m * Matrix.Translation(x + image.Height / 2, y, 0);

                        DXManager.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.None);
                        if (oldOpacity != 0.5F)
                        {
                            DXManager.SetOpacity(0.5F);
                        }

                        DXManager.Sprite.Draw(texture, Vector3.Zero, Vector3.Zero, Color.Black);
                        CEnvir.DPSCounter++;

                        DXManager.SetOpacity(oldOpacity);
                        DXManager.Sprite.Transform = Matrix.Identity;
                        DXManager.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Point);

                        image.ExpireTime = Time.Now + Config.CacheDuration;
                        break;

                    case 50:
                        if (oldOpacity != 0.5F)
                        {
                            DXManager.SetOpacity(0.5F);
                        }

                        DXManager.Sprite.Draw(texture, Vector3.Zero, new Vector3(x, y, 0), Color.Black);
                        CEnvir.DPSCounter++;
                        DXManager.SetOpacity(oldOpacity);

                        image.ExpireTime = Time.Now + Config.CacheDuration;
                        break;
                    }



                    return;
                }

                break;

            case ImageType.Overlay:
                if (!image.OverlayValid)
                {
                    image.CreateOverlay(_BReader);
                }
                texture = image.Overlay;

                if (useOffSet)
                {
                    x += image.OffSetX;
                    y += image.OffSetY;
                }
                break;

            default:
                return;
            }

            if (texture == null)
            {
                return;
            }

            DXManager.SetOpacity(opacity);

            DXManager.Sprite.Draw(texture, Vector3.Zero, new Vector3(x, y, 0), colour);
            CEnvir.DPSCounter++;

            DXManager.SetOpacity(oldOpacity);

            image.ExpireTime = Time.Now + Config.CacheDuration;
        }