private void LoadWorldScreensListbox()
 {
     for (int i = 0; i < _worldScreens.OriginalWorldScreens.Count(); i++)
     {
         WorldScreen ws   = _worldScreens.OriginalWorldScreens[i];
         string[]    data = new string[] {
             ws.ParentWorld.ToString("X2"),
             ws.AmbientSound.ToString("X2"),
             ws.Content.ToString("X2"),
             ws.ObjectSet.ToString("X2"),
             ws.ScreenIndexRight.ToString("X2"),
             ws.ScreenIndexLeft.ToString("X2"),
             ws.ScreenIndexDown.ToString("X2"),
             ws.ScreenIndexUp.ToString("X2"),
             ws.DataPointer.ToString("X2"),
             ws.ExitPosition.ToString("X2"),
             ws.TopTiles.ToString("X2"),
             ws.BottomTiles.ToString("X2"),
             ws.WorldScreenColor.ToString("X2"),
             ws.SpritesColor.ToString("X2"),
             ws.Unknown.ToString("X2"),
             ws.Event.ToString("X2")
         };
         lv_worldScreens.Items.Add(i.ToString("X2") + " (" + i.ToString() + ")").SubItems.AddRange(data);
     }
 }
        public void InitalizeData()
        {
            _worldScreens   = new WorldScreen[32, 32];
            _worldScreenIds = new int[32, 32];
            _mapIndexUsed   = new bool[255];

            farthestLeftTilePosition   = 16;
            farthestRightTilePosition  = 16;
            farthestTopTilePosition    = 16;
            farthestBottomTilePosition = 16;
        }
        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();
        }
        private void lv_worldScreens_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lv_worldScreens.SelectedIndices.Count > 0)
            {
                selectedIndex = lv_worldScreens.SelectedIndices[0];
                WorldScreen selectedScreen = _worldScreens.OriginalWorldScreens[selectedIndex];
                label1.Text = "World Screen 0x" + selectedIndex.ToString("X2") + " (" + selectedIndex + ")";

                selectedIndex      = lv_worldScreens.SelectedIndices[0];
                lbl_grid_vars.Text = "0x" + selectedIndex.ToString("X2") + " (" + selectedIndex + ")\r\n" +
                                     "DataPointer:" + selectedScreen.DataPointer.ToString("X2") + "\r\n" +
                                     "Top: 0x" + selectedScreen.TopTiles.ToString("X2") + " (" + selectedScreen.TopTiles + ")\r\n" +
                                     "Bottom: 0x" + selectedScreen.BottomTiles.ToString("X2") + " (" + selectedScreen.BottomTiles + ")\r\n";
                ;

                updateVariableListBox(_worldScreens.OriginalWorldScreens[selectedIndex]);
                btn_updateMap.PerformClick();
            }
        }
Esempio n. 5
0
        public void LoadDataFromRomFile(ref FileStream fileStream)
        {
            using (BinaryReader reader = new BinaryReader(fileStream))
            {
                reader.BaseStream.Seek(WORLD_SCREEN_DATA_START_INDEX, SeekOrigin.Begin);
                for (int worldScreenIndex = 0; worldScreenIndex < TOTAL_WORLDSCREEN_COUNT; worldScreenIndex++)
                {
                    byte[] block = new byte[16];
                    reader.Read(block, 0, 16);
                    OriginalWorldScreens[worldScreenIndex] = new WorldScreen(block);
                }

                reader.BaseStream.Seek(RANDOMENCOUNTERLINEUP_DATA_START_INDEX, SeekOrigin.Begin);
                for (int randomEncounterLineup = 0; randomEncounterLineup < TOTAL_RANDOMENCOUNTERLINEUP_COUNT; randomEncounterLineup++)
                {
                    byte[] block = new byte[RandomEncounterLineup.Size];
                    reader.Read(block, 0, RandomEncounterLineup.Size);
                    OriginalRandomEncounterLineups[randomEncounterLineup] = new RandomEncounterLineup(block);
                }

                reader.BaseStream.Seek(RANDOMENCOUNTERGROUP_DATA_START_INDEX, SeekOrigin.Begin);
                for (int randomEncounterGroup = 0; randomEncounterGroup < TOTAL_RANDOMENCOUNTERGROUP_COUNT; randomEncounterGroup++)
                {
                    byte[] block = new byte[RandomEncounterGroup.Size];
                    reader.Read(block, 0, RandomEncounterGroup.Size);
                    OriginalRandomEncounterGroups[randomEncounterGroup] = new RandomEncounterGroup(block);
                }

                //Load Tile Data

                int ROMTileDataSize = 0x3AC1;
                TileData = new byte[ROMTileDataSize];
                reader.BaseStream.Seek(TILE_DATA_START_INDEX, SeekOrigin.Begin);
                reader.Read(TileData, 0, ROMTileDataSize);
                for (int worldScreenIndex = 0; worldScreenIndex < TOTAL_WORLDSCREEN_COUNT; worldScreenIndex++)
                {
                    OriginalWorldScreens[worldScreenIndex].LoadTileData(TileData);
                }
            }
        }
Esempio n. 6
0
        public bool CheckThatAllRequiredScreenContentsArePresent()
        {
            bool allRequiredScreensExist = true;

            byte[] requiredContentsW1 = new byte[]
            {
                0x81,                //Faruk
                0x83,                //Kebabu
                0x84                 //Aqua Palace
            };

            byte[] requiredContentsW2 = new byte[]
            {
                0x83                 //Epin
            };
            byte[] requiredContentsW3 = new byte[]
            {
                0x81,                //Cimaron Tree
                0x82,                //Supapa
                0x84,                //Mustafa
                0x85                 //Frozen Palace
            };
            byte[] requiredContentsW4 = new byte[]
            {
                0x80,                //Gubibi
                0x81,                //Rainy
                0x82                 //Yufla Palace
            };
            byte[] requiredContentsW5 = new byte[]
            {
                0x80,                //Hasan
                0x82,                //Legend Sword
                0x83,                //Armor of light
                0x84,                //palace entrance
                0x85                 //sabaron
            };

            WorldScreen matchingItem = null;

            //bool[] exists = new bool[requiredContents.Length];

            //W1
            for (int requiredContentIndex = 0; requiredContentIndex < requiredContentsW1.Length; requiredContentIndex++)
            {
                byte requiredContent = requiredContentsW1[requiredContentIndex];
                matchingItem = _WorldScreenCollections[0].NewWorldScreens.FirstOrDefault(WorldScreen => WorldScreen.Content == requiredContent);
                if (matchingItem == null)
                {
                    allRequiredScreensExist = false;
                }
                else
                {
                }
            }

            //W2
            for (int requiredContentIndex = 0; requiredContentIndex < requiredContentsW2.Length; requiredContentIndex++)
            {
                byte requiredContent = requiredContentsW2[requiredContentIndex];
                matchingItem = _WorldScreenCollections[1].NewWorldScreens.FirstOrDefault(WorldScreen => WorldScreen.Content == requiredContent);
                if (matchingItem == null)
                {
                    allRequiredScreensExist = false;
                }
                else
                {
                }
            }

            //W3
            for (int requiredContentIndex = 0; requiredContentIndex < requiredContentsW3.Length; requiredContentIndex++)
            {
                byte requiredContent = requiredContentsW3[requiredContentIndex];
                matchingItem = _WorldScreenCollections[2].NewWorldScreens.FirstOrDefault(WorldScreen => WorldScreen.Content == requiredContent);
                if (matchingItem == null)
                {
                    allRequiredScreensExist = false;
                }
                else
                {
                }
            }

            //W4
            for (int requiredContentIndex = 0; requiredContentIndex < requiredContentsW4.Length; requiredContentIndex++)
            {
                byte requiredContent = requiredContentsW4[requiredContentIndex];
                matchingItem = _WorldScreenCollections[3].NewWorldScreens.FirstOrDefault(WorldScreen => WorldScreen.Content == requiredContent);
                if (matchingItem == null)
                {
                    allRequiredScreensExist = false;
                }
                else
                {
                }
            }

            //W5
            for (int requiredContentIndex = 0; requiredContentIndex < requiredContentsW5.Length; requiredContentIndex++)
            {
                byte requiredContent = requiredContentsW5[requiredContentIndex];
                matchingItem = _WorldScreenCollections[4].NewWorldScreens.FirstOrDefault(WorldScreen => WorldScreen.Content == requiredContent);
                if (matchingItem == null)
                {
                    allRequiredScreensExist = false;
                }
                else
                {
                }
            }

            return(allRequiredScreensExist);
        }
        public void LoadWorldMap(int currentScreenIndex, int x, int y)
        {
            WorldScreen worldScreen = _worldScreenCollection.OriginalWorldScreens[currentScreenIndex];

            /*  if (worldScreen.IsWizardScreen())
             * {
             *    _mapIndexUsed[currentScreenIndex] = true;
             *    WorldScreen wizardExitScreen;
             *    if (worldScreen.ScreenIndexRight != 0xFF)
             *    {
             *        wizardExitScreen = _worldScreenCollection.OriginalWorldScreens[worldScreen.ScreenIndexRight];
             *        LoadWorldMap(worldScreen.ScreenIndexRight, x , y);
             *    }
             *    else if(worldScreen.ScreenIndexLeft != 0xFF)
             *    {
             *        wizardExitScreen = _worldScreenCollection.OriginalWorldScreens[worldScreen.ScreenIndexRight];
             *        LoadWorldMap(worldScreen.ScreenIndexLeft, x, y);
             *    }
             *    else if (worldScreen.ScreenIndexDown != 0xFF)
             *    {
             *        LoadWorldMap(worldScreen.ScreenIndexDown, x, y);
             *    }
             *    else if (worldScreen.ScreenIndexUp != 0xFF)
             *    {
             *        LoadWorldMap(worldScreen.ScreenIndexUp, x, y);
             *    }
             *    return;
             * }*/


            _mapIndexUsed[currentScreenIndex] = true;
            _parentForm.lv_worldScreens.Items[currentScreenIndex].ForeColor = Color.Green;
            _worldScreens[x, y]   = worldScreen;
            _worldScreenIds[x, y] = currentScreenIndex;

            if (worldScreen.ScreenIndexRight < 0xF0 && !_mapIndexUsed[worldScreen.ScreenIndexRight] &&
                _worldScreenCollection.OriginalWorldScreens[worldScreen.ScreenIndexRight].ParentWorld == worldScreen.ParentWorld)
            {
                int xRight = x + 1;
                if (farthestRightTilePosition < xRight)
                {
                    farthestRightTilePosition = xRight;
                }
                LoadWorldMap(worldScreen.ScreenIndexRight, xRight, y);
            }
            if (worldScreen.ScreenIndexLeft < 0xF0 && !_mapIndexUsed[worldScreen.ScreenIndexLeft] &&
                _worldScreenCollection.OriginalWorldScreens[worldScreen.ScreenIndexLeft].ParentWorld == worldScreen.ParentWorld)
            {
                int xLeft = x - 1;
                if (farthestLeftTilePosition > xLeft)
                {
                    farthestLeftTilePosition = xLeft;
                }
                LoadWorldMap(worldScreen.ScreenIndexLeft, xLeft, y);
            }
            if (worldScreen.ScreenIndexDown < 0xF0 && !_mapIndexUsed[worldScreen.ScreenIndexDown] &&
                _worldScreenCollection.OriginalWorldScreens[worldScreen.ScreenIndexDown].ParentWorld == worldScreen.ParentWorld)
            {
                int yDown = y - 1;
                if (farthestBottomTilePosition > yDown)
                {
                    farthestBottomTilePosition = yDown;
                }
                LoadWorldMap(worldScreen.ScreenIndexDown, x, yDown);
            }
            if (worldScreen.ScreenIndexUp < 0xF0 && !_mapIndexUsed[worldScreen.ScreenIndexUp] &&
                _worldScreenCollection.OriginalWorldScreens[worldScreen.ScreenIndexUp].ParentWorld == worldScreen.ParentWorld)
            {
                int yUp = y + 1;
                if (farthestTopTilePosition < yUp)
                {
                    farthestTopTilePosition = yUp;
                }
                LoadWorldMap(worldScreen.ScreenIndexUp, x, yUp);
            }
        }
        private void updateVariableListBox(WorldScreen ws)
        {
            lv_variables.Items[(int)WorldScreen.DataContent.ParentWorld].SubItems[1].Text      = ws.ParentWorld.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.AmbientSound].SubItems[1].Text     = ws.AmbientSound.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.Content].SubItems[1].Text          = ws.Content.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.ObjectSet].SubItems[1].Text        = ws.ObjectSet.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.ScreenIndexRight].SubItems[1].Text = ws.ScreenIndexRight.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.ScreenIndexLeft].SubItems[1].Text  = ws.ScreenIndexLeft.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.ScreenIndexDown].SubItems[1].Text  = ws.ScreenIndexDown.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.ScreenIndexUp].SubItems[1].Text    = ws.ScreenIndexUp.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.DataPointer].SubItems[1].Text      = ws.DataPointer.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.ExitPosition].SubItems[1].Text     = ws.ExitPosition.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.TopTiles].SubItems[1].Text         = ws.TopTiles.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.BottomTiles].SubItems[1].Text      = ws.BottomTiles.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.WorldScreenColor].SubItems[1].Text = ws.WorldScreenColor.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.SpritesColor].SubItems[1].Text     = ws.SpritesColor.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.Unknown].SubItems[1].Text          = ws.Unknown.ToString("X2");
            lv_variables.Items[(int)WorldScreen.DataContent.Event].SubItems[1].Text            = ws.Event.ToString("X2");

            //hints
            //content
            if (KnownContents.ContainsKey(ws.Content.ToString("X2")))
            {
                lv_variables.Items[(int)WorldScreen.DataContent.Content].SubItems[2].Text = KnownContents[ws.Content.ToString("X2")];
            }
            else
            {
                lv_variables.Items[(int)WorldScreen.DataContent.Content].SubItems[2].Text = "?";
            }

            //objectSets
            if (KnownObjectSets.ContainsKey(ws.ObjectSet.ToString("X2")))
            {
                lv_variables.Items[(int)WorldScreen.DataContent.ObjectSet].SubItems[2].Text = KnownObjectSets[ws.ObjectSet.ToString("X2")];
            }
            else
            {
                lv_variables.Items[(int)WorldScreen.DataContent.ObjectSet].SubItems[2].Text = "?";
            }

            //events
            if (KnownEvents.ContainsKey(ws.Event.ToString("X2")))
            {
                lv_variables.Items[(int)WorldScreen.DataContent.Event].SubItems[2].Text = KnownEvents[ws.Event.ToString("X2")];
            }
            else
            {
                lv_variables.Items[(int)WorldScreen.DataContent.Event].SubItems[2].Text = "?";
            }

            //screenexits
            if (KnownScreenExits.ContainsKey(ws.ScreenIndexLeft.ToString("X2")))
            {
                lv_variables.Items[(int)WorldScreen.DataContent.ScreenIndexLeft].SubItems[2].Text = KnownScreenExits[ws.ScreenIndexLeft.ToString("X2")];
            }
            else
            {
                lv_variables.Items[(int)WorldScreen.DataContent.ScreenIndexLeft].SubItems[2].Text = "enter screen " + ws.ScreenIndexLeft.ToString("X2");
            }

            if (KnownScreenExits.ContainsKey(ws.ScreenIndexRight.ToString("X2")))
            {
                lv_variables.Items[(int)WorldScreen.DataContent.ScreenIndexRight].SubItems[2].Text = KnownScreenExits[ws.ScreenIndexRight.ToString("X2")];
            }
            else
            {
                lv_variables.Items[(int)WorldScreen.DataContent.ScreenIndexRight].SubItems[2].Text = "enter screen " + ws.ScreenIndexRight.ToString("X2");
            }

            if (KnownScreenExits.ContainsKey(ws.ScreenIndexUp.ToString("X2")))
            {
                lv_variables.Items[(int)WorldScreen.DataContent.ScreenIndexUp].SubItems[2].Text = KnownScreenExits[ws.ScreenIndexUp.ToString("X2")];
            }
            else
            {
                lv_variables.Items[(int)WorldScreen.DataContent.ScreenIndexUp].SubItems[2].Text = "enter screen " + ws.ScreenIndexUp.ToString("X2");
            }

            if (KnownScreenExits.ContainsKey(ws.ScreenIndexDown.ToString("X2")))
            {
                lv_variables.Items[(int)WorldScreen.DataContent.ScreenIndexDown].SubItems[2].Text = KnownScreenExits[ws.ScreenIndexDown.ToString("X2")];
            }
            else
            {
                lv_variables.Items[(int)WorldScreen.DataContent.ScreenIndexDown].SubItems[2].Text = "enter screen " + ws.ScreenIndexDown.ToString("X2");
            }
        }
        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);
            }
        }
        public static Color getGroundColor(WorldScreen ws)
        {
            Color gr;

            switch (ws.WorldScreenColor.ToString("X2"))
            {
            case "21":
            case "2A":
            case "32":
            case "45":
                gr = Color.FromArgb(255, 0, 60, 20);            //past
                break;

            case "30":
            //  case "38":
            case "3B":
                // gr = Color.FromArgb(255, 36, 24, 140);
                gr = Color.FromArgb(255, 0, 112, 236);          //water
                break;

            case "25":
            case "41":
            case "47":
                gr = Color.FromArgb(255, 252, 228, 160);        //desert
                break;

            case "1A":
                gr = Color.FromArgb(255, 0, 80, 0);             //Dark palace
                break;

            case "3C":
            case "31":
                //case "34":
                gr = Color.FromArgb(255, 164, 0, 0);            //red
                break;

            case "23":
            case "2B":
            case "39":
                gr = Color.FromArgb(255, 188, 188, 188);        //winter
                break;

            /*  case "1B":
             *    gr = Color.FromArgb(255, 60, 188, 252);     //ice
             *    break;*/
            case "11":
            case "27":
            case "43":
            case "44":
            case "4A":
            case "34":
            case "1F":
            case "20":
                gr = Color.FromArgb(255, 0, 0, 0);              //black
                break;

            case "1C":
            //case "27":
            //case "31":
            //case "34":
            //case "44":
            case "46":
            case "48":
                gr = Color.FromArgb(255, 216, 40, 0);           //lava
                break;

            /* case "1D":
             *   gr = Color.FromArgb(255, 68, 0, 156);       //Sabaron's palace
             *   break;*/
            default:
                gr = Color.FromArgb(255, 0, 148, 0);
                // Console.WriteLine(ws.WorldScreenColor);
                break;
            }
            return(gr);
        }
 public WorldScreenGraphic(WorldScreen worldScreen, int x, int y, int width, int height)
 {
 }