Esempio n. 1
0
        public void mouseDown(MouseEventArgs e, Map16 map, IntPtr allgfx8array)
        {
            if (sceneMode == SceneMode.door)
            {
                if (e.Button == MouseButtons.Left)
                {
                    if (map.parentMapId != 255)
                    {
                        int mapy = (exitsHandler.lastselectedExit.mapId / 8);
                        int mapx = exitsHandler.lastselectedExit.mapId - (mapy * 8);
                        mouse_tile_x_down = mouse_tile_x - (mapx * 32);
                        mouse_tile_y_down = mouse_tile_y - (mapy * 32);
                    }
                    else
                    {
                        int mx = (mouse_tile_x / 32);
                        int my = (mouse_tile_y / 32);
                        mouse_tile_x_down = mouse_tile_x - (mx * 32);
                        mouse_tile_y_down = mouse_tile_y - (my * 32);
                    }

                    exitsHandler.lastselectedExit.doorXEditor = (byte)mouse_tile_x_down;
                    exitsHandler.lastselectedExit.doorYEditor = (byte)mouse_tile_y_down;
                    exitsHandler.exitProperty_Click(null, null);
                }
            }
            else if (sceneMode == SceneMode.entrances)
            {
                entrancesHandler.onMouseDown(e, mouse_x, mouse_y, mouse_down);
            }
            else if (sceneMode == SceneMode.holes)
            {
                holesHandler.onMouseDown(e, mouse_x, mouse_y, mouse_down);
            }
            else if (sceneMode == SceneMode.exits)
            {
                exitsHandler.onMouseDown(e, mouse_x, mouse_y, rightClick);
            }
            else if (sceneMode == SceneMode.sprites)
            {
                spritesHandler.onMouseDown(e, mouse_x, mouse_y, mouse_down);
            }
            else if (sceneMode == SceneMode.items)
            {
                itemsHandler.onMouseDown(e, mouse_x, mouse_y, mouse_down);
            }
            else if (sceneMode == SceneMode.tiles)
            {
                int yT = (mouseOverMap / 8);
                int xT = mouseOverMap - (yT * 8);
                int mx = (mouse_tile_x / 32);
                int my = (mouse_tile_y / 32);
                mouse_tile_x_down = mouse_tile_x - (mx * 32);
                mouse_tile_y_down = mouse_tile_y - (my * 32);
                if (e.Button == MouseButtons.Right)
                {
                    allowCopy     = true;
                    selectionSize = new Rectangle(mouse_tile_x_down * 16, mouse_tile_y_down * 16, 16, 16);
                    selectedTiles = map.getTiles(mouse_tile_x_down, mouse_tile_y_down, 1, 1);
                }
                else if (e.Button == MouseButtons.Left)
                {
                    AddUndo(new OverworldUndo(mouseOverMap + offset, (ushort[, ])map.mapdata.tiles.Clone()));
                    map.setTiles(allgfx16Ptr, mouse_tile_x - (mx * 32), mouse_tile_y - (my * 32), selectedTiles);
                }

                map.UpdateMap(allgfx16Ptr);
                //setOverlaytiles(allgfx16Ptr);
                //map.setTile(allgfx16Ptr,mouse_tile_x, mouse_tile_y, 500);
            }
            else if (sceneMode == SceneMode.overlay)
            {
                int mid = mouseOverMap;
                if (allmaps[mouseOverMap].parentMapId != 255)
                {
                    mid = allmaps[mouseOverMap].parentMapId;
                }
                int yT = (mid / 8);
                int xT = mid - (yT * 8);
                if (e.Button == MouseButtons.Left)
                {
                    OverlayData toChange = new OverlayData(50, 50, 5000);
                    foreach (OverlayData od in jsonData.overlayDatas[mid])
                    {
                        if ((mouse_x - (xT * 512)) >= (od.x * 16) && (mouse_x - (xT * 512)) < (od.x * 16) + 16 &&
                            (mouse_y - (yT * 512)) >= (od.y * 16) && (mouse_y - (yT * 512)) < (od.y * 16) + 16)
                        {
                            toChange = od;
                        }
                    }

                    if (toChange.tileId != 5000)
                    {
                        jsonData.overlayDatas[mid].Remove(toChange);
                    }
                    if (selectedTiles[0, 0] != 0)
                    {
                        jsonData.overlayDatas[mid].Add(new OverlayData((byte)((mouse_x - (xT * 512)) / 16), (byte)((mouse_y - (yT * 512)) / 16), selectedTiles[0, 0]));
                    }
                }
                else if (e.Button == MouseButtons.Right)
                {
                    selectedTiles[0, 0] = 0;
                    Console.WriteLine("mapid = " + mid.ToString() + "," + mouse_x + "," + mouse_y);
                    foreach (OverlayData od in jsonData.overlayDatas[mid])
                    {
                        if ((mouse_x) >= (od.x * 16) && (mouse_x) <= ((od.x * 16) + 16) &&
                            (mouse_y) >= (od.y * 16) && (mouse_y) <= ((od.y * 16) + 16))
                        {
                            Console.WriteLine(mouse_x + "," + mouse_y);
                            selectedTiles[0, 0] = od.tileId;
                            break;
                        }
                    }
                }
            }
            mouse_down = true;
        }
Esempio n. 2
0
        public void Scene_MouseTileChanged(MouseEventArgs e, Map16 map, IntPtr allgfx8array)
        {
            int mx = (mouse_tile_x / 32);
            int my = (mouse_tile_y / 32);

            mouseOverMap             = mx + (my * 8);
            selectionSize.X          = mouse_tile_x * 16;
            selectionSize.Y          = mouse_tile_y * 16;
            selectedTilesGfx.Palette = map.GetPalette();

            if (mouseOverMap != last_mouseOverMap)
            {
                if (mouse_down)
                {
                    AddUndo(new OverworldUndo(mouseOverMap + offset, (ushort[, ])allmaps[mouseOverMap].mapdata.tiles.Clone()));
                    map = allmaps[mouseOverMap + offset];
                }

                setOverlaytiles(allgfx16Ptr);
                screenChanged     = last_mouseOverMap;
                last_mouseOverMap = mouseOverMap;
            }
            if (mouse_down)
            {
                //Tiles Editing Mode
                if (sceneMode == SceneMode.tiles)
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        map.setTiles(allgfx16Ptr, mouse_tile_x - (mx * 32), mouse_tile_y - (my * 32), selectedTiles);
                    }
                    else if (e.Button == MouseButtons.Right)
                    {
                        if (screenChanged != -1)
                        {
                            allowCopy  = false;
                            mouse_down = false;
                        }
                        else
                        {
                            allowCopy = true;
                        }
                        int startX      = mouse_tile_x_down;
                        int startY      = mouse_tile_y_down;
                        int sizeX       = 0;
                        int sizeY       = 0;
                        int mouse_x_map = mouse_tile_x - (mx * 32);
                        int mouse_y_map = mouse_tile_y - (my * 32);

                        if (mouse_tile_x_down < mouse_x_map)
                        {
                            sizeX = (mouse_x_map - mouse_tile_x_down) + 1;
                        }
                        else
                        {
                            startX = mouse_x_map;
                            sizeX  = Math.Abs(mouse_x_map - mouse_tile_x_down) + 1;
                        }

                        if (mouse_tile_y_down < mouse_y_map)
                        {
                            sizeY = (mouse_y_map - mouse_tile_y_down) + 1;
                        }
                        else
                        {
                            startY = mouse_y_map;
                            sizeY  = Math.Abs(mouse_y_map - mouse_tile_y_down) + 1;
                        }
                        selectionSize = new Rectangle(((startX + (mx * 32)) * 16), ((startY + (my * 32)) * 16), (sizeX * 16), (sizeY * 16));
                        //overlayGraphics.DrawRectangle(new Pen(Brushes.Yellow), new Rectangle(startX * 16, startY * 16, (sizeX * 16), (sizeY * 16)));
                    }
                }
                else if (sceneMode == SceneMode.overlay)
                {
                    int mid = mouseOverMap;
                    if (allmaps[mouseOverMap].parentMapId != 255)
                    {
                        mid = allmaps[mouseOverMap].parentMapId;
                    }
                    int yT = (mid / 8);
                    int xT = mid - (yT * 8);
                    if (e.Button == MouseButtons.Left)
                    {
                        OverlayData toChange = new OverlayData(50, 50, 5000);
                        foreach (OverlayData od in jsonData.overlayDatas[mid])
                        {
                            if ((mouse_x - (xT * 512)) >= (od.x * 16) && (mouse_x - (xT * 512)) < (od.x * 16) + 16 &&
                                (mouse_y - (yT * 512)) >= (od.y * 16) && (mouse_y - (yT * 512)) < (od.y * 16) + 16)
                            {
                                toChange = od;
                            }
                        }

                        if (toChange.tileId != 5000)
                        {
                            jsonData.overlayDatas[mid].Remove(toChange);
                        }
                        if (selectedTiles[0, 0] != 0)
                        {
                            jsonData.overlayDatas[mid].Add(new OverlayData((byte)((mouse_x - (xT * 512)) / 16), (byte)((mouse_y - (yT * 512)) / 16), selectedTiles[0, 0]));
                        }
                    }
                    else if (e.Button == MouseButtons.Right)
                    {
                        selectedTiles[0, 0] = 0;
                        Console.WriteLine("mapid = " + mid.ToString() + "," + mouse_x + "," + mouse_y);
                        foreach (OverlayData od in jsonData.overlayDatas[mid])
                        {
                            if ((mouse_x) >= (od.x * 16) && (mouse_x) <= ((od.x * 16) + 16) &&
                                (mouse_y) >= (od.y * 16) && (mouse_y) <= ((od.y * 16) + 16))
                            {
                                Console.WriteLine(mouse_x + "," + mouse_y);
                                selectedTiles[0, 0] = od.tileId;
                                break;
                            }
                        }
                    }
                }
                else if (sceneMode == SceneMode.entrances)
                {
                    entrancesHandler.onMouseTileChanged(e, mouse_tile_x, mouse_tile_y, mouse_down);
                }
                else if (sceneMode == SceneMode.holes)
                {
                    holesHandler.onMouseTileChanged(e, mouse_tile_x, mouse_tile_y, mouse_down);
                }
                else if (sceneMode == SceneMode.sprites)
                {
                    spritesHandler.onMouseTileChanged(e, mouse_tile_x, mouse_tile_y, mouse_down);
                }
                else if (sceneMode == SceneMode.items)
                {
                    itemsHandler.onMouseTileChanged(e, mouse_tile_x, mouse_tile_y, mouse_down);
                }
            }
            map.UpdateMap(allgfx16Ptr);
            refresh = true;
        }