Exemple #1
0
        private void DrawTileGrid(int screenIndex)
        {
            WorldScreen         ws              = _worldScreens.OriginalWorldScreens[selectedIndex];
            WorldScreenTileData tileData        = ws.TileData;
            const int           TILEVIEW_SIZE_X = 64;
            const int           TILEVIEW_SIZE_Y = 64;

            using (var g = Graphics.FromImage(pb_tiles.Image))
            {
                Color ground = getGroundColor(ws);
                g.Clear(Color.White);

                for (int y = 0; y < WorldScreenTileData.TILES_Y_COUNT; y++)
                {
                    for (int x = 0; x < WorldScreenTileData.TILES_X_COUNT; x++)
                    {
                        byte tileValue = tileData.Tiles[x, y];

                        Rectangle rect = new Rectangle(x * TILEVIEW_SIZE_X, y * TILEVIEW_SIZE_Y, TILEVIEW_SIZE_X, TILEVIEW_SIZE_Y);

                        Brush brush = new SolidBrush(ground);       //and here
                        g.FillRectangle(brush, rect);

                        //grid
                        //  g.DrawRectangle(Pens.Black, rect);
                        if (cb_show_tile_image.Checked)
                        {
                            if (TileImagePaths.ContainsKey(tileValue.ToString("X2")))
                            {
                                Image image = new Bitmap(@"Images/TileImages/" + TileImagePaths[tileValue.ToString("X2")]);
                                g.DrawImage(image, rect);
                            }
                        }
                        else
                        {
                            g.DrawRectangle(Pens.Black, rect);
                        }


                        if (cb_show_tile_id.Checked)
                        {
                            Font drawFont = new Font("Arial", 9);
                            g.DrawString(tileValue.ToString("X2"), drawFont, Pens.White.Brush, rect.Left + 25, rect.Top + 25);
                        }
                    }
                }
            }
            pb_tiles.Refresh();
        }
Exemple #2
0
 public void LoadTileData(byte[] ROMTileData)
 {
     TileData = new WorldScreenTileData(ROMTileData, DataPointer, TopTiles, BottomTiles);
     int a = 0;
 }
Exemple #3
0
        private void btn_updateMap_Click(object sender, EventArgs e)
        {
            _map.InitalizeData();
            ResetCurrentlyViewingListBoxItems();
            _map.LoadWorldMap(lv_worldScreens.SelectedIndices[0], 16, 16);

            using (var g = Graphics.FromImage(pictureBox1.Image))
            {
                g.Clear(Color.LightGray);

                rectangles = _map.DrawWorldMap(MAP_TILE_SIZE_X, MAP_TILE_SIZE_Y);

                foreach (KeyValuePair <int, Rectangle> item in rectangles)
                {
                    int         wsIndex = item.Key;
                    WorldScreen ws      = _worldScreens.OriginalWorldScreens[item.Key];
                    Rectangle   rect    = item.Value;
                    Brush       bgbrush;
                    if (ws.IsWizardScreen())
                    {
                        bgbrush = new SolidBrush(Color.FromArgb(40, 40, 40, 40));
                    }
                    else
                    {
                        bgbrush = new SolidBrush(Color.FromArgb(255, 255, 255, 255));
                    }

                    // g.FillRectangle(bgbrush, rect);
                    // g.DrawRectangle(Pens.LightGreen, rect);


                    //Draw Tiles on map
                    if (cb_fill_map_tiles.Checked)
                    {
                        RectangleF          tileRect;
                        WorldScreenTileData tileData = ws.TileData;

                        Color ground = getGroundColor(ws);

                        float TILEVIEW_SIZE_X = (float)rect.Width / WorldScreenTileData.TILES_X_COUNT;
                        float TILEVIEW_SIZE_Y = (float)rect.Height / WorldScreenTileData.TILES_Y_COUNT;
                        for (int y = 0; y < WorldScreenTileData.TILES_Y_COUNT; y++)
                        {
                            for (int x = 0; x < WorldScreenTileData.TILES_X_COUNT; x++)
                            {
                                byte tileValue = tileData.Tiles[x, y];
                                tileRect = new RectangleF(rect.Left + (x * TILEVIEW_SIZE_X), rect.Top + (y * TILEVIEW_SIZE_Y), TILEVIEW_SIZE_X, TILEVIEW_SIZE_Y);

                                //  Rectangle tileRect = new Rectangle(rect.Left + (x * TILEVIEW_SIZE_X), rect.Top + (y * TILEVIEW_SIZE_Y), TILEVIEW_SIZE_X, TILEVIEW_SIZE_Y);

                                Brush brush = new SolidBrush(ground);   //here
                                g.FillRectangle(brush, tileRect);

                                //grid
                                //  g.DrawRectangle(Pens.Black, rect);

                                if (TileImagePaths.ContainsKey(tileValue.ToString("X2")))
                                {
                                    Image image = new Bitmap(@"Images/TileImages/" + TileImagePaths[tileValue.ToString("X2")]);
                                    g.DrawImage(image, tileRect);
                                }
                            }
                        }
                    }


                    /*if (selectedIndex == wsIndex)
                     * {
                     *  Brush brush = new SolidBrush(Color.FromArgb(40, 50, 50, 50));
                     *  g.FillRectangle(brush, rect);
                     * }*/

                    Font drawFont = new Font("Arial", 7);



                    PointF drawIdPoint = new PointF(rect.X + 2, rect.Y + 2);
                    //g.DrawString(item.Key.ToString("X2"), drawFont, Pens.Black.Brush, drawIdPoint);

                    PointF drawContentPoint = new PointF(rect.X + rect.Width - 14, rect.Y + 2);
                    if (ws.Content != 0x00 && ws.Content != 0xFF)
                    {
                        // if (ws.Content == 0xFE) g.DrawString(ws.Content.ToString("X2"), drawFont, Pens.Orange.Brush, drawContentPoint);
                        //g.DrawString(ws.WorldScreenColor.ToString("X2"), drawFont, Pens.Blue.Brush, drawContentPoint);
                    }
                    if (ws.Content == 0xFF)
                    {
                        Brush encScreen = new SolidBrush(Color.FromArgb(110, 255, 0, 210));
                        g.FillRectangle(encScreen, rect);
                        //g.FillRectangle(Pens.WhiteSmoke.Brush, rect.Left, rect.Top, MAP_TILE_SIZE_X, MAP_TILE_SIZE_Y);
                    }


                    PointF drawDataPointerPoint = new PointF(rect.X + rect.Width - 14, rect.Y + rect.Height - 24);
                    PointF drawObjectSetPoint   = new PointF(rect.X + rect.Width - 14, rect.Y + rect.Height - 14);

                    /*if (ws.ObjectSet != 0x00)
                     * {
                     *
                     *  g.DrawString(ws.DataPointer.ToString("X2"), drawFont, Pens.Purple.Brush, drawDataPointerPoint);
                     *  g.DrawString(ws.ObjectSet.ToString("X2"), drawFont, Pens.Red.Brush, drawObjectSetPoint);
                     * }*/


                    int worldExitRectangleScaleX = (MAP_TILE_SIZE_X / 3);
                    int worldExitRectangleScaleY = (MAP_TILE_SIZE_Y / 3);

                    //DOWN
                    if (ws.ScreenIndexDown == 0xFF)
                    {
                        // g.DrawLine(Pens.Black, new Point(rect.Left, rect.Bottom - 1), new Point(rect.Right, rect.Bottom - 1));
                    }
                    else if (ws.ScreenIndexDown == 0xFE)
                    {
                        //g.DrawLine(Pens.Blue, new Point(rect.Left, rect.Bottom - 1), new Point(rect.Right, rect.Bottom - 1));
                        //g.DrawString(ws.Content.ToString("X2"), drawFont, Pens.Blue.Brush, drawContentPoint);
                    }
                    else if (_worldScreens.OriginalWorldScreens[ws.ScreenIndexDown].ParentWorld != ws.ParentWorld)
                    {
                        //g.DrawRectangle(Pens.DeepSkyBlue, new Rectangle(rect.Left + worldExitRectangleScaleX, rect.Bottom - 5, worldExitRectangleScaleX, 5));
                        //g.DrawString(ws.ScreenIndexDown.ToString("X2"), drawFont, Pens.DeepSkyBlue.Brush, new Point(rect.Left + 3 + rect.Width / 3, rect.Bottom - 15));
                    }
                    else if (_worldScreens.OriginalWorldScreens[ws.ScreenIndexDown].IsWizardScreen())
                    {
                        // g.DrawLine(Pens.Orange, new Point(rect.Left, rect.Bottom - 1), new Point(rect.Right, rect.Bottom - 1));
                        // g.DrawLine(Pens.Orange, new Point(rect.Left + Left+ rect.Width / 2, rect.Bottom), new Point(rect.Left + rect.Width / 2, rect.Bottom - 7));
                    }

                    //UP
                    if (ws.ScreenIndexUp == 0xFF)
                    {
                        //g.DrawLine(Pens.Black, new Point(rect.Left, rect.Top + 1), new Point(rect.Right, rect.Top + 1));
                    }
                    else if (ws.ScreenIndexUp == 0xFE)
                    {
                        //g.DrawLine(Pens.Blue, new Point(rect.Left, rect.Top + 1), new Point(rect.Right, rect.Top + 1));
                        //g.DrawString(ws.Content.ToString("X2"), drawFont, Pens.Blue.Brush, drawContentPoint);
                    }
                    else if (_worldScreens.OriginalWorldScreens[ws.ScreenIndexUp].ParentWorld != ws.ParentWorld)
                    {
                        //g.DrawRectangle(Pens.DeepSkyBlue, new Rectangle(rect.Left + worldExitRectangleScaleX, rect.Top, worldExitRectangleScaleX, 5));
                        //g.DrawString(ws.ScreenIndexUp.ToString("X2"), drawFont, Pens.DeepSkyBlue.Brush, new Point(rect.Left + 3 +  rect.Width /3, rect.Top + 5));
                    }
                    else if (_worldScreens.OriginalWorldScreens[ws.ScreenIndexUp].IsWizardScreen())
                    {
                        // g.DrawLine(Pens.Orange, new Point(rect.Left, rect.Top + 1), new Point(rect.Right, rect.Top + 1));
                        // g.DrawLine(Pens.Orange, new Point(rect.Left + rect.Width / 2, rect.Top), new Point(rect.Left + rect.Width / 2, rect.Top + 7));
                    }

                    //RIGHT
                    if (ws.ScreenIndexRight == 0xFF)
                    {
                        //g.DrawLine(Pens.Black, new Point(rect.Right - 1, rect.Top), new Point(rect.Right - 1, rect.Bottom));
                    }
                    else if (ws.ScreenIndexRight == 0xFE)
                    {
                        //g.DrawLine(Pens.Blue, new Point(rect.Right - 1, rect.Top), new Point(rect.Right - 1, rect.Bottom));
                        //g.DrawString(ws.Content.ToString("X2"), drawFont, Pens.Blue.Brush, drawContentPoint);
                    }
                    else if (_worldScreens.OriginalWorldScreens[ws.ScreenIndexRight].ParentWorld != ws.ParentWorld)
                    {
                        //g.DrawRectangle(Pens.DeepSkyBlue, new Rectangle(rect.Right, rect.Top + worldExitRectangleScaleY, 5, worldExitRectangleScaleY));
                        //g.DrawString(ws.ScreenIndexRight.ToString("X2"), drawFont, Pens.DeepSkyBlue.Brush, new Point(rect.Right - 10, rect.Bottom - 30));
                    }
                    else if (_worldScreens.OriginalWorldScreens[ws.ScreenIndexRight].IsWizardScreen())
                    {
                        //  g.DrawLine(Pens.Orange, new Point(rect.Right - 1, rect.Top), new Point(rect.Right - 1, rect.Bottom));
                        //  g.DrawLine(Pens.Orange, new Point(rect.Right, rect.Bottom -  rect.Height / 2), new Point(rect.Right + 7, rect.Bottom - rect.Height / 2));
                    }

                    //LEFT
                    if (ws.ScreenIndexLeft == 0xFF)
                    {
                        //g.DrawLine(Pens.Black, new Point(rect.Left + 1, rect.Top), new Point(rect.Left + 1, rect.Bottom));
                    }
                    else if (ws.ScreenIndexLeft == 0xFE)
                    {
                        //g.DrawLine(Pens.Blue, new Point(rect.Left + 1, rect.Top), new Point(rect.Left + 1, rect.Bottom));
                        //g.DrawString(ws.Content.ToString("X2"), drawFont, Pens.Blue.Brush, drawContentPoint);
                    }
                    else if (_worldScreens.OriginalWorldScreens[ws.ScreenIndexLeft].ParentWorld != ws.ParentWorld)
                    {
                        //g.DrawRectangle(Pens.DeepSkyBlue, new Rectangle(rect.Left, rect.Top + worldExitRectangleScaleY, 5, worldExitRectangleScaleY));
                        //g.DrawString(ws.ScreenIndexLeft.ToString("X2"), drawFont, Pens.DeepSkyBlue.Brush, new Point(rect.Left + 5, rect.Bottom - 30));
                    }
                    else if (_worldScreens.OriginalWorldScreens[ws.ScreenIndexLeft].IsWizardScreen())
                    {
                        //  g.DrawLine(Pens.Orange, new Point(rect.Left + 1, rect.Top), new Point(rect.Left + 1, rect.Bottom));
                        //  g.DrawLine(Pens.Orange, new Point(rect.Left, rect.Bottom - rect.Height / 2), new Point(rect.Left - 7, rect.Bottom - rect.Height / 2));
                    }

                    g.DrawRectangle(Pens.Black, rect.Left, rect.Top, rect.Width, rect.Height);
                }

                pictureBox1.Refresh();

                DrawTileGrid(selectedIndex);
            }
        }