コード例 #1
0
        void RedrawChunk()
        {
            if (LoadedChunkVer == (int)RSDKver.RSDK4)
            {
                DisplayedChunk = Chunksv4.RenderChunk(curChunk, Tiles);                                        //Draw the current chunk!
                OrientationBox.SelectedIndex = Chunksv4.BlockList[curChunk].Mapping[selectedTile].Direction;
                VisualBox.SelectedIndex      = Chunksv4.BlockList[curChunk].Mapping[selectedTile].VisualPlane; //Update Chunk Values!
                CollisionABox.SelectedIndex  = Chunksv4.BlockList[curChunk].Mapping[selectedTile].CollisionFlag0;
                CollisionBBox.SelectedIndex  = Chunksv4.BlockList[curChunk].Mapping[selectedTile].CollisionFlag1;
                ChunkNoLabel.Text            = "Chunk " + (curChunk + 1) + " Of " + Chunksv4.BlockList.Count + ":"; //What chunk are we on?
            }
            if (LoadedChunkVer == (int)RSDKver.RSDK3)
            {
                DisplayedChunk = Chunksv3.RenderChunk(curChunk, Tiles);                                        //Draw the current chunk!
                OrientationBox.SelectedIndex = Chunksv3.BlockList[curChunk].Mapping[selectedTile].Direction;
                VisualBox.SelectedIndex      = Chunksv3.BlockList[curChunk].Mapping[selectedTile].VisualPlane; //Update Chunk Values!
                CollisionABox.SelectedIndex  = Chunksv3.BlockList[curChunk].Mapping[selectedTile].CollisionFlag0;
                CollisionBBox.SelectedIndex  = Chunksv3.BlockList[curChunk].Mapping[selectedTile].CollisionFlag1;
                ChunkNoLabel.Text            = "Chunk " + (curChunk + 1) + " Of " + Chunksv3.BlockList.Count + ":";//What chunk are we on?
            }
            if (LoadedChunkVer == (int)RSDKver.RSDK2)
            {
                DisplayedChunk = Chunksv2.RenderChunk(curChunk, Tiles);                                        //Draw the current chunk!
                OrientationBox.SelectedIndex = Chunksv2.BlockList[curChunk].Mapping[selectedTile].Direction;
                VisualBox.SelectedIndex      = Chunksv2.BlockList[curChunk].Mapping[selectedTile].VisualPlane; //Update Chunk Values!
                CollisionABox.SelectedIndex  = Chunksv2.BlockList[curChunk].Mapping[selectedTile].CollisionFlag0;
                CollisionBBox.SelectedIndex  = Chunksv2.BlockList[curChunk].Mapping[selectedTile].CollisionFlag1;
                ChunkNoLabel.Text            = "Chunk " + (curChunk + 1) + " Of " + Chunksv2.BlockList.Count + ":";//What chunk are we on?
            }
            if (LoadedChunkVer == (int)RSDKver.RSDK1)
            {
                DisplayedChunk = Chunksv1.RenderChunk(curChunk, Tiles);                                        //Draw the current chunk!
                OrientationBox.SelectedIndex = Chunksv1.BlockList[curChunk].Mapping[selectedTile].Orientation; //Update Chunk Values!
                VisualBox.SelectedIndex      = Chunksv1.BlockList[curChunk].Mapping[selectedTile].VisualPlane;
                CollisionABox.SelectedIndex  = Chunksv1.BlockList[curChunk].Mapping[selectedTile].CollisionFlag0;
                CollisionBBox.SelectedIndex  = Chunksv1.BlockList[curChunk].Mapping[selectedTile].CollisionFlag1;
                ChunkNoLabel.Text            = "Chunk " + (curChunk + 1) + " Of " + Chunksv1.BlockList.Count + ":";//What chunk are we on?
            }

            using (Graphics g = Graphics.FromImage(DisplayedChunk))
            {
                if (showGrid)                                                                     // Do we want a grid?
                {
                    Size   gridCellSize = new Size(16 * (int)ZoomLevel, 16 * (int)ZoomLevel);     // how big should each cell be?
                    Bitmap mapLine      = new Bitmap(128 * (int)ZoomLevel, 128 * (int)ZoomLevel); // how big is the image?

                    Pen pen = new Pen(Color.DarkGray);

                    if (gridCellSize.Width >= 8 && gridCellSize.Height >= 8)
                    {
                        int lft  = 0 % gridCellSize.Width;
                        int top  = 0 % gridCellSize.Height;
                        int cntX = 128 / gridCellSize.Width;
                        int cntY = 128 / gridCellSize.Height;

                        for (int i = 0; i <= mapLine.Width; ++i)
                        {
                            g.DrawLine(pen, lft + i * gridCellSize.Width, 0, lft + i * gridCellSize.Width, mapLine.Height); //Draw Lines every 128 Pixels along the width
                        }

                        for (int j = 0; j <= mapLine.Height; ++j)
                        {
                            g.DrawLine(pen, 0, top + j * gridCellSize.Height, mapLine.Width, top + j * gridCellSize.Height); //Draw Lines every 128 Pixels along the height
                        }
                    }

                    g.TranslateTransform(0, 0); // No idea lmao
                    g.ResetTransform();         //Still No idea lmao
                    mapLine.Dispose();          //Delet This!
                }

                Pen Recpen = new Pen(Color.Yellow); //Draw a yellow rectangle to show the user what tile they are editing!
                g.DrawRectangle(Recpen, new Rectangle(tilepoint.X * 16, tilepoint.Y * 16, 16, 16));
            }

            ChunkDisplay.BackgroundImage = DisplayedChunk; //We want the chunk to show up! So make the background image display the currect chunk!
        }