Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomSprite"/> class used for drawing external textures on the screen.
        /// </summary>
        /// <param name="filename">Full path to location of the <see cref="CustomSprite"/> on the disc</param>
        /// <param name="size">Set the <see cref="Size"/> of the <see cref="CustomSprite"/></param>
        /// <param name="position">Set the <see cref="Position"/> on screen where to draw the <see cref="CustomSprite"/></param>
        /// <param name="color">Set the <see cref="Color"/> used to draw the <see cref="CustomSprite"/></param>
        /// <param name="rotation">Set the rotation to draw the sprite, measured in degrees, see also <seealso cref="Rotation"/></param>
        /// <param name="centered">Position the <see cref="CustomSprite"/> based on its center instead of top left corner, see also <seealso cref="Centered"/></param>
        /// <exception cref="FileNotFoundException">Thrown if the specified file doesnt exist</exception>
        public CustomSprite(string filename, SizeF size, PointF position, Color color, float rotation, bool centered)
        {
            if (!File.Exists(filename))
            {
                throw new FileNotFoundException(filename);
            }

            if (_textures.ContainsKey(filename))
            {
                _id = _textures[filename];
            }
            else
            {
                _id = MemoryAccess.CreateTexture(filename);
                _textures.Add(filename, _id);
            }

            if (!_indexes.ContainsKey(_id))
            {
                _indexes.Add(_id, 0);
            }
            if (!_lastDraw.ContainsKey(_id))
            {
                _lastDraw.Add(_id, 0);
            }

            Enabled  = true;
            Size     = size;
            Position = position;
            Color    = color;
            Rotation = rotation;
            Centered = centered;
        }
Example #2
0
        public static void RawDraw(string filename, int time, PointF Position, SizeF Size, PointF center,
                                   float rotation, System.Drawing.Color color)
        {
            if (!File.Exists(filename))
            {
                throw new FileNotFoundException(filename);
            }

            int _id;

            if (_textures.ContainsKey(filename))
            {
                _id = _textures[filename];
            }
            else
            {
                _id = MemoryAccess.CreateTexture(filename);
                _textures.Add(filename, _id);
            }

            if (!_indexes.ContainsKey(_id))
            {
                _indexes.Add(_id, 0);
            }
            if (!_lastDraw.ContainsKey(_id))
            {
                _lastDraw.Add(_id, 0);
            }

            int frameCount = Function.Call <int>(Hash.GET_FRAME_COUNT);

            if (_lastDraw[_id] != frameCount)
            {
                _indexes[_id]  = 0;
                _lastDraw[_id] = frameCount;
            }
            if (_globalLastDrawFrame != frameCount)
            {
                _globalLevel         = 0;
                _globalLastDrawFrame = frameCount;
            }

            float aspectRatio = Screen.AspectRatio;

            MemoryAccess.DrawTexture(_id, _indexes[_id]++, _globalLevel++, 100, Size.Width, Size.Height, center.X, center.Y, Position.X, Position.Y, rotation * 0.00277777778f, aspectRatio, color);
        }
Example #3
0
        public static void RawDraw(string filename, int time, PointF Position, SizeF Size, PointF center, float rotation, System.Drawing.Color color)
        {
            int num;

            if (_textures.ContainsKey(filename))
            {
                num = _textures[filename];
            }
            else
            {
                if (!File.Exists(filename))
                {
                    throw new FileNotFoundException(filename);
                }
                num = MemoryAccess.CreateTexture(filename);
                _textures.Add(filename, num);
            }
            if (!_indexes.ContainsKey(num))
            {
                _indexes.Add(num, 0);
            }
            if (!_lastDraw.ContainsKey(num))
            {
                _lastDraw.Add(num, 0);
            }
            int num2 = Function.Call <int>(Hash.GET_FRAME_COUNT, Array.Empty <InputArgument>());

            if (_lastDraw[num] != num2)
            {
                _indexes[num]  = 0;
                _lastDraw[num] = num2;
            }
            if (_globalLastDrawFrame != num2)
            {
                _globalLevel         = 0;
                _globalLastDrawFrame = num2;
            }
            float aspectRatio = Screen.AspectRatio;
            int   num4        = num;
            int   index       = _indexes[num4];

            _indexes[num4] = index + 1;
            _globalLevel++;
            MemoryAccess.DrawTexture(num, index, _globalLevel, 100, Size.Width, Size.Height, center.X, center.Y, Position.X, Position.Y, rotation * 0.002777778f, aspectRatio, color);
        }
        public static void RawDraw(
            string filename,
            int time,
            PointF Position,
            SizeF Size,
            PointF center,
            float rotation,
            Color color)
        {
            int num1;

            if (CustomSprite._textures.ContainsKey(filename))
            {
                num1 = CustomSprite._textures[filename];
            }
            else
            {
                num1 = File.Exists(filename) ? MemoryAccess.CreateTexture(filename) : throw new FileNotFoundException(filename);
                CustomSprite._textures.Add(filename, num1);
            }
            if (!CustomSprite._indexes.ContainsKey(num1))
            {
                CustomSprite._indexes.Add(num1, 0);
            }
            if (!CustomSprite._lastDraw.ContainsKey(num1))
            {
                CustomSprite._lastDraw.Add(num1, 0);
            }
            int num2 = Function.Call <int>(Hash.GET_FRAME_COUNT, (InputArgument[])Array.Empty <InputArgument>());

            if (CustomSprite._lastDraw[num1] != num2)
            {
                CustomSprite._indexes[num1]  = 0;
                CustomSprite._lastDraw[num1] = num2;
            }
            if (CustomSprite._globalLastDrawFrame != num2)
            {
                CustomSprite._globalLevel         = 0;
                CustomSprite._globalLastDrawFrame = num2;
            }
            float aspectRatio = Screen.AspectRatio;

            MemoryAccess.DrawTexture(num1, CustomSprite._indexes[num1]++, CustomSprite._globalLevel++, 100, Size.Width, Size.Height, center.X, center.Y, Position.X, Position.Y, rotation * (1f / 360f), aspectRatio, color);
        }