Пример #1
0
        private void tileChange_Click(object sender, EventArgs e)
        {
            if (metaTileGridBox.SelectedIndex == -1)
            {
                return;
            }

            var room = MapManager.Instance.MapAreas.Single(a => a.Index == currentArea).Rooms.First();

            room.SetMetaTileData(currentTileInfo, metaTileGridBox.SelectedIndex, currentLayer);
            var image = metaTiles[currentLayer - 1];
            int x     = metaTileGridBox.SelectedIndex % 16;
            int y     = metaTileGridBox.SelectedIndex / 16;

            MetaTileSet.DrawTileData(ref image, currentTileInfo, new Point(x * 16, y * 16), room.tileSet, room.palettes, currentLayer == 1, true);
            metaTileGridBox.Image = image;
            if (currentLayer == 1)
            {
                MainWindow.AddPendingChange(new Bg1MetaTileSetChange(currentArea));
            }
            if (currentLayer == 2)
            {
                MainWindow.AddPendingChange(new Bg2MetaTileSetChange(currentArea));
            }
        }
        private void tileChange_Click(object sender, EventArgs e)
        {
            if (metaTileGridBox.SelectedIndex == -1)
            {
                return;
            }

            var room = MapManager.Instance.MapAreas.Single(a => a.Index == currentArea).Rooms.First();

            byte[] metatypes     = new byte[2];
            var    metadata      = room.GetMetaTileData(ref metatypes, metaTileGridBox.SelectedIndex, currentLayer);
            var    hasTypeChange = !metatypes.SequenceEqual(currentTileType);
            var    hasInfoChange = !metadata.SequenceEqual(currentTileInfo);

            if (hasTypeChange || hasInfoChange)
            {
                room.SetMetaTileData(currentTileInfo, currentTileType, metaTileGridBox.SelectedIndex, currentLayer);
            }

            if (hasInfoChange)
            {
                if (currentLayer == 1)
                {
                    Project.Instance.AddPendingChange(new Bg1MetaTileSetChange(currentArea));
                }
                if (currentLayer == 2)
                {
                    Project.Instance.AddPendingChange(new Bg2MetaTileSetChange(currentArea));
                }
            }
            if (hasTypeChange)
            {
                if (currentLayer == 1)
                {
                    Project.Instance.AddPendingChange(new Bg1MetaTileTypeChange(currentArea));
                }
                if (currentLayer == 2)
                {
                    Project.Instance.AddPendingChange(new Bg2MetaTileTypeChange(currentArea));
                }
            }

            var image = metaTiles[currentLayer - 1];
            int x     = metaTileGridBox.SelectedIndex % 16;
            int y     = metaTileGridBox.SelectedIndex / 16;

            MetaTileSet.DrawTileData(ref image, currentTileInfo, new Point(x * 16, y * 16), room.tileSet, room.palettes, currentLayer == 1, true);
            metaTileGridBox.Image = image;
        }