private void pArr_MouseClick(object sender, MouseEventArgs e)
        {
            if (bmpArr == null)
            {
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                // Get the X and Y
                int x = e.X;
                int y = e.Y;

                x /= zoomArr;
                y /= zoomArr;

                x >>= 3;
                y >>= 3;

                if (x >= arrWidth)
                {
                    return;
                }
                if (y >= arrHeight)
                {
                    return;
                }

                if ((Control.ModifierKeys & Keys.Shift) == 0)
                {
                    // Draw tile
                    DrawTile(x, y);
                }
                else
                {
                    // Get tile
                    ArrEntry a = Arrangement[x + (y * arrWidth)];

                    loading          = true;
                    chkFlipH.Checked = a.FlipH;
                    chkFlipV.Checked = a.FlipV;

                    int pnum = a.Palette;
                    if (pnum >= Palette.Count)
                    {
                        pnum = 0;
                    }
                    palSelector.PalIndex = pnum;
                    loading = false;

                    RenderTileset();
                    RefreshTileset();
                    CurrentTile = a.TileNumber;
                }
            }
        }
        public ArrEntry[] GetArrangement()
        {
            var ret = new ArrEntry[Arrangement.Length];

            for (int i = 0; i < ret.Length; i++)
            {
                ret[i] = (ArrEntry)Arrangement[i].Clone();
            }
            return(ret);
        }
예제 #3
0
        public static void WriteArrEntry(this byte[] data, int destOffset, ArrEntry arr)
        {
            ushort ch1 = (ushort)(
                (arr.TileNumber & 0x3FF) |
                (arr.FlipH ? 0x400 : 0) |
                (arr.FlipV ? 0x800 : 0) |
                ((arr.Palette & 0xF) << 12));

            data.WriteUShort(destOffset, ch1);
        }
        private void DrawTile(int x, int y)
        {
            // Get tile
            ArrEntry a = Arrangement[x + (y * arrWidth)];

            a.FlipH      = chkFlipH.Checked;
            a.FlipV      = chkFlipV.Checked;
            a.Palette    = (byte)palSelector.PalIndex;
            a.TileNumber = (ushort)currentTile;

            RenderArr();
            RefreshArr();
        }
예제 #5
0
        public static ArrEntry ReadArrEntry(this byte[] data, int srcOffset)
        {
            var ret = new ArrEntry();

            ushort ch1 = data.ReadUShort(srcOffset);

            ret.TileNumber = (ushort)(ch1 & 0x3FF);
            ret.FlipH      = (ch1 & 0x400) != 0;
            ret.FlipV      = (ch1 & 0x800) != 0;
            ret.Palette    = (byte)((ch1 >> 12) & 0xF);

            return(ret);
        }
예제 #6
0
        public void SetArrangement(ArrEntry[] arr, int w, int h)
        {
            if (arr == null)
            {
                Arrangement = null;
                return;
            }

            if ((w * h) > arr.Length)
                throw new Exception("Canvas is larger than arrangement!");

            if ((Arrangement == null) || (Arrangement.Length != arr.Length))
            {
                Arrangement = new ArrEntry[arr.Length];
            }

            for (int i = 0; i < arr.Length; i++)
                Arrangement[i] = (ArrEntry)arr[i].Clone();

            arrWidth = w;
            arrHeight = h;
        }
예제 #7
0
 public ArrEntry[] GetArrangement()
 {
     var ret = new ArrEntry[Arrangement.Length];
     for (int i = 0; i < ret.Length; i++)
         ret[i] = (ArrEntry)Arrangement[i].Clone();
     return ret;
 }
예제 #8
0
 public static void WriteArrEntry(this byte[] data, ArrEntry arr)
 {
     data.WriteArrEntry(Offset, arr);
     Offset += 2;
 }