public void Copy()
        {
            Clipboard.Clear();
            EntranceOWEditor ed = lastselectedEntrance.Copy();

            Clipboard.SetData("owentrance", ed);
        }
Beispiel #2
0
        public void loadEntrances()
        {
            for (int i = 0; i < 129; i++)
            {
                short  mapId  = (short)((ROM.IMPORTDATA[Constants.OWEntranceMap + (i * 2) + 1] << 8) + (ROM.IMPORTDATA[Constants.OWEntranceMap + (i * 2)]));
                ushort mapPos = (ushort)((ROM.IMPORTDATA[Constants.OWEntrancePos + (i * 2) + 1] << 8) + (ROM.IMPORTDATA[Constants.OWEntrancePos + (i * 2)]));

                byte             entranceId = (byte)((ROM.IMPORTDATA[Constants.OWEntranceEntranceId + i]));
                int              p          = mapPos >> 1;
                int              x          = (p % 64);
                int              y          = (p >> 6);
                EntranceOWEditor eo         = new EntranceOWEditor((x * 16) + (((mapId % 64) - (((mapId % 64) / 8) * 8)) * 512), (y * 16) + (((mapId % 64) / 8) * 512), entranceId, mapId, mapPos);
                if (mapPos == 0xFFFF)
                {
                    eo.deleted = true;
                }
                ow.allentrances[i] = eo;
            }


            for (int i = 0; i < 0x13; i++)
            {
                short            mapId      = (short)((ROM.IMPORTDATA[Constants.OWHoleArea + (i * 2) + 1] << 8) + (ROM.IMPORTDATA[Constants.OWHoleArea + (i * 2)]));
                short            mapPos     = (short)((ROM.IMPORTDATA[Constants.OWHolePos + (i * 2) + 1] << 8) + (ROM.IMPORTDATA[Constants.OWHolePos + (i * 2)]));
                byte             entranceId = (byte)((ROM.IMPORTDATA[Constants.OWHoleEntrance + i]));
                int              p          = (mapPos + 0x400) >> 1;
                int              x          = (p % 64);
                int              y          = (p >> 6);
                EntranceOWEditor eo         = new EntranceOWEditor((x * 16) + (((mapId % 64) - (((mapId % 64) / 8) * 8)) * 512), (y * 16) + (((mapId % 64) / 8) * 512), entranceId, mapId, (ushort)(mapPos + 0x400));
                ow.allholes[i] = eo;
            }
        }
Beispiel #3
0
        public void onMouseDoubleClick(MouseEventArgs e)
        {
            string tname = "";

            for (int i = 0; i < scene.ow.allentrances.Length; i++)
            {
                EntranceOWEditor en = scene.ow.allentrances[i];
                if (en.mapId >= scene.ow.worldOffset && en.mapId < 64 + scene.ow.worldOffset)
                {
                    if (e.X >= en.x && e.X < en.x + 16 && e.Y >= en.y && e.Y < en.y + 16)
                    {
                        if (e.Button == MouseButtons.Left)
                        {
                            TreeNode[] treeNodes = scene.mainForm.entrancetreeView.Nodes[0].Nodes
                                                   .Cast <TreeNode>()
                                                   .Where(r => (int)(r.Tag) == en.entranceId)
                                                   .ToArray();

                            if (treeNodes.Length != 0)
                            {
                                scene.mainForm.entrancetreeView.SelectedNode = treeNodes[0];
                            }

                            scene.mainForm.addRoomTab(DungeonsData.entrances[en.entranceId].Room);
                            scene.mainForm.editorsTabControl.SelectedIndex = 0;
                            //scene.mainForm.dungeonButton_Click(scene.mainForm.dungeonButton, null);
                        }
                    }
                }
            }

            for (int i = 0; i < scene.ow.allholes.Length; i++)
            {
                EntranceOWEditor en = scene.ow.allholes[i];
                if (en.mapId >= scene.ow.worldOffset && en.mapId < 64 + scene.ow.worldOffset)
                {
                    if (e.X >= en.x && e.X < en.x + 16 && e.Y >= en.y && e.Y < en.y + 16)
                    {
                        if (scene.mouse_down == false)
                        {
                            if (e.Button == MouseButtons.Left)
                            {
                                TreeNode[] treeNodes = scene.mainForm.entrancetreeView.Nodes[0].Nodes
                                                       .Cast <TreeNode>()
                                                       .Where(r => (int)(r.Tag) == en.entranceId)
                                                       .ToArray();

                                if (treeNodes.Length != 0)
                                {
                                    scene.mainForm.entrancetreeView.SelectedNode = treeNodes[0];
                                }

                                scene.mainForm.addRoomTab(DungeonsData.entrances[en.entranceId].Room);
                                scene.mainForm.editorsTabControl.SelectedIndex = 0;
                            }
                        }
                    }
                }
            }
        }
        public void onMouseDown(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                isLeftPress = true;
            }
            else
            {
                isLeftPress = false;
            }
            for (int i = 0; i < scene.ow.allentrances.Length; i++)
            {
                EntranceOWEditor en = scene.ow.allentrances[i];
                if (en.mapId >= scene.ow.worldOffset && en.mapId < 64 + scene.ow.worldOffset)
                {
                    if (e.X >= en.x && e.X < en.x + 16 && e.Y >= en.y && e.Y < en.y + 16)
                    {
                        if (scene.mouse_down == false)
                        {
                            if (e.Button == MouseButtons.Left)
                            {
                                selectedEntrance     = en;
                                lastselectedEntrance = en;
                                scene.mouse_down     = true;
                            }
                            else if (e.Button == MouseButtons.Right)
                            {
                                lastselectedEntrance = en;
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < scene.ow.allholes.Length; i++)
            {
                EntranceOWEditor en = scene.ow.allholes[i];
                if (en.mapId >= scene.ow.worldOffset && en.mapId < 64 + scene.ow.worldOffset)
                {
                    if (e.X >= en.x && e.X < en.x + 16 && e.Y >= en.y && e.Y < en.y + 16)
                    {
                        if (scene.mouse_down == false)
                        {
                            if (e.Button == MouseButtons.Left)
                            {
                                selectedEntrance     = en;
                                lastselectedEntrance = en;
                                scene.mouse_down     = true;
                            }
                            else if (e.Button == MouseButtons.Right)
                            {
                                lastselectedEntrance = en;
                            }
                        }
                    }
                }
            }
        }
 public void Paste()
 {
     selectedEntrance = AddEntrance(true);
     if (selectedEntrance != null)
     {
         lastselectedEntrance = selectedEntrance;
         scene.mouse_down     = true;
         scene.Invalidate(new Rectangle(scene.mainForm.panel5.HorizontalScroll.Value, scene.mainForm.panel5.VerticalScroll.Value, scene.mainForm.panel5.Width, scene.mainForm.panel5.Height));
     }
 }
        public void Draw(Graphics g)
        {
            int   transparency = 200;
            Brush bgrBrush     = new SolidBrush(Color.FromArgb(transparency, 255, 200, 16));
            Pen   contourPen   = new Pen(Color.FromArgb(transparency, 0, 0, 0));

            g.CompositingMode = CompositingMode.SourceOver;
            for (int i = 0; i < scene.ow.allentrances.Length; i++)
            {
                EntranceOWEditor e = scene.ow.allentrances[i];

                if (e.mapId < 64 + scene.ow.worldOffset && e.mapId >= scene.ow.worldOffset)
                {
                    if (selectedEntrance != null)
                    {
                        if (e == selectedEntrance)
                        {
                            bgrBrush = new SolidBrush(Color.FromArgb((int)transparency, 0, 55, 240));
                            scene.drawText(g, e.x - 1, e.y + 16, "map : " + e.mapId.ToString());
                            scene.drawText(g, e.x - 1, e.y + 26, "entrance : " + e.entranceId.ToString());
                            scene.drawText(g, e.x - 1, e.y + 36, "mpos : " + e.mapPos.ToString());
                        }
                        else
                        {
                            bgrBrush = new SolidBrush(Color.FromArgb((int)transparency, 255, 200, 16));
                        }
                    }

                    g.FillRectangle(bgrBrush, new Rectangle(e.x, e.y, 16, 16));
                    g.DrawRectangle(contourPen, new Rectangle(e.x, e.y, 16, 16));
                    scene.drawText(g, e.x - 1, e.y + 1, e.entranceId.ToString("X2") + "- " + scene.mainForm.all_rooms[scene.mainForm.entrances[e.entranceId].Room].name);
                }
            }

            for (int i = 0; i < scene.ow.allholes.Length; i++)
            {
                EntranceOWEditor e = scene.ow.allholes[i];
                bgrBrush = new SolidBrush(Color.FromArgb((int)transparency, 32, 32, 32));
                if (e.mapId < 64 + scene.ow.worldOffset && e.mapId >= scene.ow.worldOffset)
                {
                    if (selectedEntrance != null)
                    {
                        if (e == selectedEntrance)
                        {
                            bgrBrush = new SolidBrush(Color.FromArgb((int)transparency, 0, 55, 240));
                        }
                    }

                    g.FillRectangle(bgrBrush, new Rectangle(e.x, e.y, 16, 16));
                    g.DrawRectangle(contourPen, new Rectangle(e.x, e.y, 16, 16));
                    scene.drawText(g, e.x - 1, e.y + 1, e.entranceId.ToString("X2") + "- " + scene.mainForm.all_rooms[scene.mainForm.entrances[e.entranceId].Room].name);
                }
            }
            g.CompositingMode = CompositingMode.SourceCopy;
        }
 public void onMouseUp(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (selectedEntrance != null)
         {
             byte mid = scene.ow.allmaps[scene.mapHover + scene.ow.worldOffset].parent;
             if (mid == 255)
             {
                 mid = (byte)(scene.mapHover + scene.ow.worldOffset);
             }
             selectedEntrance.updateMapStuff((short)mid);
             selectedEntrance = null;
             scene.mouse_down = false;
         }
     }
     else if (e.Button == MouseButtons.Right)
     {
         ContextMenuStrip menu = new ContextMenuStrip();
         for (int i = 0; i < scene.ow.allentrances.Length; i++)
         {
             EntranceOWEditor en = scene.ow.allentrances[i];
             if (en.mapId >= scene.ow.worldOffset && en.mapId < 64 + scene.ow.worldOffset)
             {
                 if (e.X >= en.x && e.X < en.x + 16 && e.Y >= en.y && e.Y < en.y + 16)
                 {
                     menu.Items.Add("Add Entrance");
                     menu.Items.Add("Entrance Properties");
                     menu.Items.Add("Delete Entrance");
                     lastselectedEntrance = en;
                     selectedEntrance     = null;
                     scene.mouse_down     = false;
                     if (lastselectedEntrance == null)
                     {
                         menu.Items[1].Enabled = false;
                         menu.Items[2].Enabled = false;
                     }
                     menu.Items[0].Click += entranceAdd_Click;
                     menu.Items[1].Click += entranceProperty_Click;
                     menu.Items[2].Click += Delete_Click;
                     menu.Show(Cursor.Position);
                 }
             }
         }
     }
 }
        public void onMouseDoubleClick(MouseEventArgs e)
        {
            for (int i = 0; i < scene.ow.allentrances.Length; i++)
            {
                EntranceOWEditor en = scene.ow.allentrances[i];
                if (en.mapId >= scene.ow.worldOffset && en.mapId < 64 + scene.ow.worldOffset)
                {
                    if (e.X >= en.x && e.X < en.x + 16 && e.Y >= en.y && e.Y < en.y + 16)
                    {
                        if (e.Button == MouseButtons.Left)
                        {
                            scene.mainForm.selectedEntrance = scene.mainForm.entrances[en.entranceId];
                            scene.mainForm.addRoomTab(scene.mainForm.entrances[en.entranceId].Room);
                            scene.mainForm.dungeonButton_Click(scene.mainForm.dungeonButton, null);
                        }
                    }
                }
            }

            for (int i = 0; i < scene.ow.allholes.Length; i++)
            {
                EntranceOWEditor en = scene.ow.allholes[i];
                if (en.mapId >= scene.ow.worldOffset && en.mapId < 64 + scene.ow.worldOffset)
                {
                    if (e.X >= en.x && e.X < en.x + 16 && e.Y >= en.y && e.Y < en.y + 16)
                    {
                        if (scene.mouse_down == false)
                        {
                            if (e.Button == MouseButtons.Left)
                            {
                                selectedEntrance     = en;
                                lastselectedEntrance = en;
                                scene.mouse_down     = true;
                            }
                        }
                    }
                }
            }
        }
        public EntranceOWEditor AddEntrance(bool clipboard = false)
        {
            byte entranceID = 0;
            bool ishole     = false;

            if (clipboard)
            {
                EntranceOWEditor data = (EntranceOWEditor)Clipboard.GetData("owentrance");
                if (data != null)
                {
                    entranceID = data.entranceId;
                    ishole     = data.isHole;
                }
            }


            int found = -1;

            if (ishole)
            {
                for (int i = 0; i < scene.ow.allholes.Length; i++)
                {
                    if (scene.ow.allholes[i].deleted)
                    {
                        byte mid = scene.ow.allmaps[scene.mapHover + scene.ow.worldOffset].parent;
                        if (mid == 255)
                        {
                            mid = (byte)(scene.mapHover + scene.ow.worldOffset);
                        }
                        scene.ow.allholes[i].deleted    = false;
                        scene.ow.allholes[i].mapId      = mid;
                        scene.ow.allholes[i].x          = (ushort)((mxRightclick / 16) * 16);
                        scene.ow.allholes[i].y          = (ushort)((myRightclick / 16) * 16);
                        scene.ow.allholes[i].entranceId = entranceID;


                        scene.ow.allholes[i].updateMapStuff(mid);


                        found = i;
                        scene.Invalidate(new Rectangle(scene.mainForm.panel5.HorizontalScroll.Value, scene.mainForm.panel5.VerticalScroll.Value, scene.mainForm.panel5.Width, scene.mainForm.panel5.Height));
                        break;
                    }
                }
            }
            else
            {
                for (int i = 0; i < scene.ow.allentrances.Length; i++)
                {
                    if (scene.ow.allentrances[i].deleted)
                    {
                        byte mid = scene.ow.allmaps[scene.mapHover + scene.ow.worldOffset].parent;
                        if (mid == 255)
                        {
                            mid = (byte)(scene.mapHover + scene.ow.worldOffset);
                        }
                        scene.ow.allentrances[i].deleted    = false;
                        scene.ow.allentrances[i].mapId      = mid;
                        scene.ow.allentrances[i].x          = (ushort)((mxRightclick / 16) * 16);
                        scene.ow.allentrances[i].y          = (ushort)((myRightclick / 16) * 16);
                        scene.ow.allentrances[i].entranceId = entranceID;


                        scene.ow.allentrances[i].updateMapStuff(mid);


                        found = i;
                        scene.Invalidate(new Rectangle(scene.mainForm.panel5.HorizontalScroll.Value, scene.mainForm.panel5.VerticalScroll.Value, scene.mainForm.panel5.Width, scene.mainForm.panel5.Height));
                        break;
                    }
                }
            }


            if (found == -1)
            {
                if (ishole)
                {
                    MessageBox.Show("No space available for new hole, delete one first");
                }
                else
                {
                    MessageBox.Show("No space available for new entrance, delete one first");
                }
                return(null);
            }

            return(scene.ow.allentrances[found]);
        }
Beispiel #10
0
        public void onMouseDown(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                isLeftPress = true;
            }
            else
            {
                isLeftPress = false;
            }

            for (int i = 0; i < scene.ow.allentrances.Length; i++)
            {
                EntranceOWEditor en = scene.ow.allentrances[i];
                if (en.mapId >= scene.ow.worldOffset && en.mapId < 64 + scene.ow.worldOffset)
                {
                    if (e.X >= en.x && e.X < en.x + 16 && e.Y >= en.y && e.Y < en.y + 16)
                    {
                        if (scene.mouse_down == false)
                        {
                            if (e.Button == MouseButtons.Left)
                            {
                                selectedEntrance     = en;
                                lastselectedEntrance = en;
                                scene.mouse_down     = true;
                            }
                            else if (e.Button == MouseButtons.Right)
                            {
                                lastselectedEntrance = en;
                                scene.mouse_down     = true;
                                mxRightclick         = (e.X);
                                myRightclick         = (e.Y);
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < scene.ow.allholes.Length; i++)
            {
                EntranceOWEditor en = scene.ow.allholes[i];
                if (en.mapId >= scene.ow.worldOffset && en.mapId < 64 + scene.ow.worldOffset)
                {
                    if (e.X >= en.x && e.X < en.x + 16 && e.Y >= en.y && e.Y < en.y + 16)
                    {
                        if (scene.mouse_down == false)
                        {
                            if (e.Button == MouseButtons.Left)
                            {
                                selectedEntrance     = en;
                                lastselectedEntrance = en;
                                scene.mouse_down     = true;
                            }
                            else if (e.Button == MouseButtons.Right)
                            {
                                lastselectedEntrance = en;
                                scene.mouse_down     = true;
                                mxRightclick         = (e.X);
                                myRightclick         = (e.Y);
                            }
                        }
                    }
                }
            }

            if (selectedEntrance != null)
            {
                //scene.owForm.thumbnailBox.Visible = true;
                //scene.owForm.thumbnailBox.Size = new Size(256, 256);
                int roomId = DungeonsData.entrances[selectedEntrance.entranceId].Room;
                if (roomId >= 296)
                {
                    //scene.owForm.thumbnailBox.Visible = false;
                    return;
                }

                if (scene.mainForm.lastRoomID != roomId)
                {
                    scene.mainForm.previewRoom = DungeonsData.all_rooms[roomId];
                    scene.mainForm.previewRoom.reloadGfx();
                    GFX.loadedPalettes = GFX.LoadDungeonPalette(scene.mainForm.previewRoom.palette);
                    scene.mainForm.DrawRoom();
                    DrawTempEntrance();
                    scene.entrancePreview = true;
                    //scene.Refresh();

                    if (scene.mainForm.activeScene.room != null)
                    {
                        GFX.loadedPalettes = GFX.LoadDungeonPalette(scene.mainForm.activeScene.room.palette);
                        scene.mainForm.activeScene.room.reloadGfx();
                        scene.mainForm.activeScene.DrawRoom();
                    }
                }

                scene.mainForm.lastRoomID = roomId;
            }
        }