Esempio n. 1
0
        public void SetCursor(string cursorName)
        {
            if ((cursorName == null && cursor == null) || (cursor != null && cursorName == cursor.Name))
                return;

            if (cursorName == null || !cursorProvider.Cursors.TryGetValue(cursorName, out cursor))
                cursor = null;

            Update();
        }
Esempio n. 2
0
        public void SetCursor(string cursorName)
        {
            if ((cursorName == null && cursor == null) || (cursor != null && cursorName == cursor.Name))
            {
                return;
            }

            if (cursorName == null || !cursorProvider.Cursors.TryGetValue(cursorName, out cursor))
            {
                cursor = null;
            }

            Update();
        }
Esempio n. 3
0
		IHardwareCursor CreateCursor(ISpriteFrame f, ImmutablePalette palette, string name, CursorSequence sequence)
		{
			var hotspot = sequence.Hotspot - f.Offset.ToInt2() + new int2(f.Size) / 2;

			// Expand the frame if required to include the hotspot
			var frameWidth = f.Size.Width;
			var dataWidth = f.Size.Width;
			var dataX = 0;
			if (hotspot.X < 0)
			{
				dataX = -hotspot.X;
				dataWidth += dataX;
				hotspot = hotspot.WithX(0);
			}
			else if (hotspot.X >= frameWidth)
				dataWidth = hotspot.X + 1;

			var frameHeight = f.Size.Height;
			var dataHeight = f.Size.Height;
			var dataY = 0;
			if (hotspot.Y < 0)
			{
				dataY = -hotspot.Y;
				dataHeight += dataY;
				hotspot = hotspot.WithY(0);
			}
			else if (hotspot.Y >= frameHeight)
				dataHeight = hotspot.Y + 1;

			var data = new byte[4 * dataWidth * dataHeight];
			for (var j = 0; j < frameHeight; j++)
			{
				for (var i = 0; i < frameWidth; i++)
				{
					var bytes = BitConverter.GetBytes(palette[f.Data[j * frameWidth + i]]);
					var start = 4 * ((j + dataY) * dataWidth + dataX + i);
					for (var k = 0; k < 4; k++)
						data[start + k] = bytes[k];
				}
			}

			return Game.Renderer.Device.CreateHardwareCursor(name, new Size(dataWidth, dataHeight), data, hotspot);
		}
Esempio n. 4
0
        IHardwareCursor CreateCursor(ISpriteFrame f, ImmutablePalette palette, string name, CursorSequence sequence)
        {
            var hotspot = sequence.Hotspot - f.Offset.ToInt2() + new int2(f.Size) / 2;

            // Expand the frame if required to include the hotspot
            var frameWidth = f.Size.Width;
            var dataWidth  = f.Size.Width;
            var dataX      = 0;

            if (hotspot.X < 0)
            {
                dataX      = -hotspot.X;
                dataWidth += dataX;
                hotspot    = hotspot.WithX(0);
            }
            else if (hotspot.X >= frameWidth)
            {
                dataWidth = hotspot.X + 1;
            }

            var frameHeight = f.Size.Height;
            var dataHeight  = f.Size.Height;
            var dataY       = 0;

            if (hotspot.Y < 0)
            {
                dataY       = -hotspot.Y;
                dataHeight += dataY;
                hotspot     = hotspot.WithY(0);
            }
            else if (hotspot.Y >= frameHeight)
            {
                dataHeight = hotspot.Y + 1;
            }

            var data = new byte[4 * dataWidth * dataHeight];

            for (var j = 0; j < frameHeight; j++)
            {
                for (var i = 0; i < frameWidth; i++)
                {
                    var bytes = BitConverter.GetBytes(palette[f.Data[j * frameWidth + i]]);
                    var start = 4 * ((j + dataY) * dataWidth + dataX + i);
                    for (var k = 0; k < 4; k++)
                    {
                        data[start + k] = bytes[k];
                    }
                }
            }

            return(Game.Renderer.Window.CreateHardwareCursor(name, new Size(dataWidth, dataHeight), data, hotspot));
        }
Esempio n. 5
0
 public Cursor(string cursor)
 {
     sequence = CursorProvider.GetCursorSequence(cursor);
 }