Пример #1
0
 public void setGfxData(Bitmap[] allbitmaps, JsonData jsonData, Map16 map)
 {
     typeString.Clear();
     this.allbitmaps = allbitmaps;
     this.jsonData   = jsonData;
     //blocksetsBitmap = new Bitmap(128, 512,64,PixelFormat.Format4bppIndexed, allgfx8array);
     blocksetsBitmap         = new Bitmap(128, 512, 128, PixelFormat.Format8bppIndexed, allgfx8array8bpp);
     tileBitmap              = new Bitmap(16, 16, 16, PixelFormat.Format8bppIndexed, tile16gfx8bpp);
     blocksetsBitmap.Palette = map.GetPalette();
     tileBitmap.Palette      = map.GetPalette();
     //blocksetPicturebox.Image = blocksetsBitmap;
     blocksetpictureBox.Refresh();
     for (int i = 0; i < 16; i++)
     {
         allTypesSet[i] = new byte[512];
         for (int j = 0; j < 512; j++)
         {
             allTypesSet[i][j] = jsonData.tileTypeSet[i][j];
         }
     }
     typeString.Add("Normal Passable", 0);
     typeString.Add("Normal Blocked", 1);
     typeString.Add("Deep Water", 8);
     typeString.Add("Shallow Water", 9);
     //typeString.Add("Moving Floor - Dungeon Only?", 12);
     typeString.Add("Spike Floor", 13);
     typeString.Add("Ice1 Floor", 14);
     typeString.Add("Ice2 Floor", 15);
     typeString.Add("Hole", 32);
     typeString.Add("Stair Tile (slow down)", 34);
     typeString.Add("Ledge Up", 40);
     typeString.Add("Ledge Down", 41);
     typeString.Add("Ledge Left", 42);
     typeString.Add("Ledge Right", 43);
     typeString.Add("Ledge Up Left", 44);
     typeString.Add("Ledge Down Left", 45);
     typeString.Add("Ledge Up Right", 46);
     typeString.Add("Ledge Down Right", 47);
     typeString.Add("High Grass", 64);
     typeString.Add("Spike Block", 68);
     typeString.Add("Plain Grass (Diggable)", 72);
     typeString.Add("Warp", 75);
     typeString.Add("Bush", 80);
     typeString.Add("Off color Bush", 81);
     typeString.Add("Small Light Rock", 82);
     typeString.Add("Small Heavy Rock", 83);
     typeString.Add("Sign", 84);
     typeString.Add("Large Light Rock", 85);
     typeString.Add("Large Heavy Rock", 86);
     typeString.Add("Chest - not quite working on OW", 88);
     foreach (KeyValuePair <string, byte> s in typeString)
     {
         listBox1.Items.Add(s.Value + ": " + s.Key);
     }
 }
Пример #2
0
        public void DrawOverlay(Graphics g)
        {
            IntPtr tileGfxPtr = Marshal.AllocHGlobal(16 * 16);

            unsafe
            {
                byte *gfx16Data = (byte *)allgfx16Ptr.ToPointer();
                byte *gfxData   = (byte *)tileGfxPtr.ToPointer();
                int   mid       = mouseOverMap;
                if (allmaps[mouseOverMap].parentMapId != 255)
                {
                    mid = allmaps[mouseOverMap].parentMapId;
                }
                int yT = (mid / 8);
                int xT = mid - (yT * 8);
                foreach (OverlayData od in jsonData.overlayDatas[mid])
                {
                    using (Bitmap b = new Bitmap(16, 16, 16, PixelFormat.Format8bppIndexed, tileGfxPtr))
                    {
                        b.Palette = selectedMap.GetPalette();
                        for (int i = 0; i < 16; i++)
                        {
                            for (int j = 0; j < 16; j++)
                            {
                                gfxData[((0) * 16) + j + (i * 16)] = gfx16Data[GetTilePos(od.tileId) + j + (i * 128)];
                            }
                        }
                        g.DrawImage(b, new Point((xT * 512) + (od.x * 16), (yT * 512) + (od.y * 16)));
                    }
                }

                Marshal.FreeHGlobal(tileGfxPtr);
            }
        }
Пример #3
0
        private void tilesetPicturebox_Paint(object sender, PaintEventArgs e)
        {
            Map16 map = overworldDisplay.selectedMap;



            if (map != null)
            {
                //musicUpDown.Value = jsonData.mapdata[map.index].m
                Bitmap tilesgfx = new Bitmap(128, 8192, 128, PixelFormat.Format8bppIndexed, allgfx16Ptr);
                tilesgfx.Palette = map.GetPalette();
                map.UpdateGfx(jsonData.allgfx8array, allgfx16Ptr, jsonData.tilesetBitmaps);
                e.Graphics.DrawImage(tilesgfx, new Rectangle(0, 0, 128, 8192), 0, 0, 128, 8192, GraphicsUnit.Pixel);
                //e.Graphics.DrawImage(tilesgfx, new Rectangle(128, 0, 128, 3760), 0, 3760, 128, 3760, GraphicsUnit.Pixel);
            }

            int y = (overworldDisplay.selectedTile / 8);
            int x = overworldDisplay.selectedTile - (y * 8);

            e.Graphics.DrawRectangle(Pens.LightGreen, new Rectangle(x * 16, y * 16, 16, 16));



            //overworldDisplay.
        }
Пример #4
0
        public void setGfxData(Bitmap[] allbitmaps, JsonData jsonData, Map16 map, ushort tile)
        {
            this.Text       = "Tile 16 editor - Editing tile : " + tile.ToString();
            this.allbitmaps = allbitmaps;
            this.jsonData   = jsonData;
            editingTile     = new Tile16(jsonData.alltiles16[tile].Info[0], jsonData.alltiles16[tile].Info[1],
                                         jsonData.alltiles16[tile].Info[2], jsonData.alltiles16[tile].Info[3]);

            editingMap = map;
            tilePicturebox.Refresh();
            //blocksetsBitmap = new Bitmap(128, 512,64,PixelFormat.Format4bppIndexed, allgfx8array);
            blocksetsBitmap         = new Bitmap(128, 512, 128, PixelFormat.Format8bppIndexed, allgfx8array8bpp);
            tileBitmap              = new Bitmap(16, 16, 16, PixelFormat.Format8bppIndexed, tile16gfx8bpp);
            blocksetsBitmap.Palette = map.GetPalette();
            tileBitmap.Palette      = map.GetPalette();
            //blocksetPicturebox.Image = blocksetsBitmap;
            blocksetPicturebox.Refresh();
            tilePicturebox.Refresh();
        }
Пример #5
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;
        }