public void mouseMove(MouseEventArgs e, Map16 map, IntPtr allgfx8array) { if (e.X >= 0 && e.Y >= 0 && e.X < 4096 && e.Y < 4096) { mouse_x = e.X; mouse_y = e.Y; mouse_tile_x = e.X / 16; mouse_tile_y = e.Y / 16; if (mouse_tile_x != last_mouse_tile_x || mouse_tile_y != last_mouse_tile_y) { //used for tiles, sprites, items (they are lock on 16x16 pixels) //can be used for entrances and exits if snap to grid is on Scene_MouseTileChanged(e, map, allgfx8array); //the mouse is not hovering the same tile } if (sceneMode == SceneMode.exits) { exitsHandler.onMouseMove(e, mouse_x, mouse_y, map, mouseOverMap); } last_mouse_tile_x = mouse_tile_x; last_mouse_tile_y = mouse_tile_y; selectedMap = map; } }
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. }
public void CreateProject() { this.Image = new Bitmap(4096, 4096); allgfx8 = new Bitmap(128, 512, 64, PixelFormat.Format4bppIndexed, jsonData.allgfx8array); //temporary variable used for all rooms getLargeMaps(); for (int i = 0; i < 128; i++) { if (allmaps[i] != null) { allmaps[i].Dispose(); allmaps[i] = null; } if (jsonData.mapdata[i].largeMap) { jsonData.mapdata[i].palette = jsonData.mapdata[mapParent[i]].palette; jsonData.mapdata[i].blockset = jsonData.mapdata[mapParent[i]].blockset; } allmaps[i] = new Map16(jsonData.allgfx8array, jsonData, jsonData.mapdata[i], jsonData.tilesetBitmaps); allmaps[i].index = i; } setLargeMaps(); scene = new SceneOverworld(jsonData.tilesetBitmaps, allmaps[0], jsonData.allgfx8array, jsonData); scene.SetAllMaps(allmaps); }
public void Draw(Graphics g, Map16 focusedMap) { int yT = (mouseOverMap / 8); int xT = mouseOverMap - (yT * 8); if (sceneMode == SceneMode.tiles) { g.CompositingMode = CompositingMode.SourceOver; if (!mouse_down) { cm.Matrix33 = 0.50f; cm.Matrix22 = 2f; ia.SetColorMatrix(cm); g.DrawImage(selectedTilesGfx, new Rectangle((mouse_tile_x * 16), (mouse_tile_y * 16), (selectedTiles.GetLength(0) * 16), (selectedTiles.GetLength(1) * 16)), 0, 0, (selectedTiles.GetLength(0) * 16), (selectedTiles.GetLength(1) * 16), GraphicsUnit.Pixel, ia); } g.CompositingMode = CompositingMode.SourceCopy; g.DrawRectangle(Pens.LightGreen, selectionSize); } else if (sceneMode == SceneMode.door || sceneMode == SceneMode.overlay) { g.DrawImage(selectedTilesGfx, new Rectangle((mouse_tile_x * 16), (mouse_tile_y * 16), (selectedTiles.GetLength(0) * 16), (selectedTiles.GetLength(1) * 16)), 0, 0, (selectedTiles.GetLength(0) * 16), (selectedTiles.GetLength(1) * 16), GraphicsUnit.Pixel); g.DrawRectangle(Pens.LightGreen, selectionSize); } g.DrawRectangle(Pens.DarkOrange, new Rectangle(xT * 512, yT * 512, 511, 511)); if (selectedMap != null) { if (debugMode) { DrawText(g, selectionSize.ToString(), new Point(xT * 512, yT * 512)); DrawText(g, selectedMap.largeMap.ToString() + " ParentID : " + selectedMap.parentMapId.ToString(), new Point(xT * 512, (yT * 512) + 32)); } } if (sceneMode == SceneMode.overlay) { DrawOverlay(g); } if (focusedMap != null) { int yT2 = (focusedMap.index / 8); int xT2 = focusedMap.index - (yT * 8); g.DrawRectangle(Pens.DarkRed, new Rectangle(xT2 * 512, yT2 * 512, 511, 511)); /*for (int y = 0; y < 32; y++) * { * for (int x = 0; x < 32; x++) * { * DrawText(g, selectedMap.mapdata.tiles[x, y].ToString("X4"), new Point((x * 16) + (xT*512), (y * 16) + (yT*512))); * } * }*/ } }
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); } }
private void DrawTest_MouseMove(object sender, MouseEventArgs e) { if (scene != null) { scene.mouseMove(e, allmaps[(scene.mouseOverMap + worldOffset)], jsonData.allgfx8array); if (scene.refresh) { // Stopwatch sw = new Stopwatch(); //sw.Start(); //Refresh(); int yT = ((scene.mouseOverMap) / 8); int xT = (scene.mouseOverMap) - (yT * 8); if (allmaps[(scene.mouseOverMap + worldOffset)].largeMap) { yT = (allmaps[(scene.mouseOverMap)].parentMapId / 8); xT = allmaps[(scene.mouseOverMap)].parentMapId - (yT * 8); Invalidate(new Rectangle(xT * 512, yT * 512, 1024, 1024)); } else { Invalidate(new Rectangle(xT * 512, yT * 512, 512, 512)); } if (scene.screenChanged != -1) { if (mouseDown) { selectedMap = allmaps[(scene.mouseOverMap + worldOffset)]; } if (allmaps[(scene.mouseOverMap + worldOffset)].largeMap) { scene.UpdateGfx(jsonData.allgfx8array, allmaps[(scene.mouseOverMap + worldOffset)]); } else { scene.UpdateGfx(jsonData.allgfx8array, allmaps[(scene.mouseOverMap + worldOffset)]); } scene.setOverlaytiles(scene.allgfx16Ptr); yT = (scene.screenChanged / 8); xT = scene.screenChanged - (yT * 8); //invalidate last screen as well to prevent artifact Invalidate(new Rectangle(xT * 512, yT * 512, 512, 512)); scene.screenChanged = -1; } scene.refresh = false; //sw.Stop(); //Console.WriteLine(sw.ElapsedMilliseconds); } } }
private void DrawTest_MouseDown(object sender, MouseEventArgs e) { if (scene != null) { scene.mouseDown(e, allmaps[scene.mouseOverMap + worldOffset], jsonData.allgfx8array); int yT = (scene.mouseOverMap / 8); int xT = scene.mouseOverMap - (yT * 8); selectedMap = allmaps[scene.mouseOverMap + worldOffset]; Invalidate(new Rectangle(xT * 512, yT * 512, 512, 512)); mouseDown = true; } }
public SceneOverworld(Bitmap[] allbitmaps, Map16 map, IntPtr allgfx8array, JsonData jsonData) { this.allbitmaps = allbitmaps; selectedTilesGfx = new Bitmap(512, 512, 512, PixelFormat.Format8bppIndexed, selectedTilesGfxPtr); selectedTiles = new ushort[1, 1]; selectedTiles[0, 0] = 0; UpdateGfx(allgfx8array, map); this.jsonData = jsonData; fontBitmap[0] = new Bitmap("Resources//font.png"); fontBitmap[1] = new Bitmap("Resources//fonta50.png"); fontBitmap[2] = new Bitmap("Resources//fonta25.png"); entrancesHandler = new EntrancesHandler(this, jsonData); holesHandler = new HolesHandler(this, jsonData); exitsHandler = new ExitsHandler(this, jsonData); spritesHandler = new SpritesHandler(this, jsonData); itemsHandler = new ItemsHandler(this, jsonData); }
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(); }
private void overworldDisplay_MouseClick(object sender, MouseEventArgs e) { Map16 map = overworldDisplay.selectedMap; Map16 lastmap = overworldDisplay.lastSelectedMap; if (map != null) { if (lastmap != map) { nameTextbox.Text = jsonData.mapdata[map.index].name; blocksetUpDown.Value = jsonData.mapdata[map.index].blockset; paletteUpDown.Value = jsonData.mapdata[map.index].palette; spritepalUpDown.Value = jsonData.mapdata[map.index].sprite_palette; spritegfxUpDown.Value = jsonData.mapdata[map.index].spriteset; tiletypesetUpDown.Value = jsonData.mapdata[map.index].tileTypeSet; textUpDown.Value = jsonData.mapdata[map.index].msgid; lastmap = map; } //Marshal.FreeHGlobal(allgfx16Ptr); } }
public void onMouseMove(MouseEventArgs e, int mouse_x, int mouse_y, Map16 map, int mouseOverMap) { if (scene.mouse_down) { if (selectedExit != null) { selectedExit.playerX = (short)mouse_x; selectedExit.playerY = (short)mouse_y; if (scene.snapToGrid) { selectedExit.playerX = (short)((mouse_x / 8) * 8); selectedExit.playerY = (short)((mouse_y / 8) * 8); } byte mid = map.parentMapId; if (map.parentMapId == 255) { mid = (byte)(mouseOverMap + scene.offset); } selectedExit.updateMapStuff(mid, jsonData, scene.allmaps); scene.refresh = true; } } }
public void onMouseUp(MouseEventArgs e, int mouse_x, int mouse_y, bool mouse_down, short mouseOverMap, Map16 map) { if (e.Button == MouseButtons.Left) { if (selectedHole != null) { //Console.WriteLine("OldMPos" + selectedEntrance.mapPos); short mid = map.parentMapId; if (map.parentMapId == 255) { mid = (short)mouseOverMap; } selectedHole.updateMapStuff(mid); selectedHole = null; } } }
public void onMouseUp(MouseEventArgs e, int mouse_x, int mouse_y, bool mouse_down, short mouseOverMap, Map16 map) { if (e.Button == MouseButtons.Left) { if (selectedSprite != null) { byte mid = map.parentMapId; if (map.parentMapId == 255) { mid = (byte)(mouseOverMap + scene.offset); } selectedSprite.updateMapStuff(mid); lastselectedSprite = selectedSprite; selectedSprite = null; } else { lastselectedSprite = null; } } else if (e.Button == MouseButtons.Right) { ContextMenuStrip menu = new ContextMenuStrip(); menu.Items.Add("Add Sprite"); menu.Items.Add("Sprite Properties"); menu.Items.Add("Delete Sprite"); if (lastselectedSprite == null) { menu.Items[1].Enabled = false; menu.Items[2].Enabled = false; } menu.Items[0].Click += addSprite_Click; menu.Items[1].Click += spriteProperties_Click; menu.Items[2].Click += deleteSprite_Click; menu.Show(Cursor.Position); } }
public void onMouseUp(MouseEventArgs e, int mouse_x, int mouse_y, short mouseOverMap, Map16 map) { if (e.Button == MouseButtons.Left) { if (selectedExit != null) { lastselectedExit = selectedExit; selectedExit = null; } } else if (e.Button == MouseButtons.Right) { for (int i = 0; i < 78; i++) { ExitOW en = jsonData.exitsOWs[i]; if (en.mapId >= scene.offset && en.mapId < 64 + scene.offset) { if (mouse_x >= en.playerX && mouse_x < en.playerX + 16 && mouse_y >= en.playerY && mouse_y < en.playerY + 16) { ContextMenuStrip menu = new ContextMenuStrip(); menu.Items.Add("Exit Properties"); lastselectedExit = en; selectedExit = null; scene.mouse_down = false; scene.rightClick = true; if (lastselectedExit == null) { menu.Items[0].Enabled = false; } menu.Items[0].Click += exitProperty_Click; menu.Show(Cursor.Position); } } } } }
public void onMouseUp(MouseEventArgs e, int mouse_x, int mouse_y, bool mouse_down, short mouseOverMap, Map16 map) { if (e.Button == MouseButtons.Left) { if (selectedEntrance != null) { short mid = map.parentMapId; if (map.parentMapId == 255) { mid = (short)mouseOverMap; } selectedEntrance.updateMapStuff(mid); selectedEntrance = null; } } else if (e.Button == MouseButtons.Right) { if (e.Button == MouseButtons.Left) { if (selectedEntrance != null) { lastselectedEntrance = selectedEntrance; selectedEntrance = null; } } else if (e.Button == MouseButtons.Right) { for (int i = 0; i < jsonData.entranceOWsEditor.Length; i++) { EntranceOWEditor en = jsonData.entranceOWsEditor[i]; if (en.mapId >= scene.offset && en.mapId < 64 + scene.offset) { if (mouse_x >= en.x && mouse_x < en.x + 16 && mouse_y >= en.y && mouse_y < en.y + 16) { ContextMenuStrip menu = new ContextMenuStrip(); menu.Items.Add("Entrance Properties"); lastselectedEntrance = en; selectedEntrance = null; mouse_down = false; if (lastselectedEntrance == null) { menu.Items[0].Enabled = false; } menu.Items[0].Click += entranceProperty_Click; menu.Show(Cursor.Position); } } } } } }
public void UpdateGfx(IntPtr allgfx8array, Map16 map) { map.UpdateGfx(allgfx8array, allgfx16Ptr, allbitmaps); }
public void UpdateMap(Map16 map) { UpdateGfx(jsonData.allgfx8array, map); map.LoadPalette(jsonData.allPalettes); map.BuildMap(allgfx16Ptr); }
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; }
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; }
public void mouseUp(MouseEventArgs e, Map16 map) { if (sceneMode == SceneMode.tiles) { int mx = (mouse_tile_x / 32); int my = (mouse_tile_y / 32); int mouse_x_map = mouse_tile_x - (mx * 32); int mouse_y_map = mouse_tile_y - (my * 32); if (e.Button == MouseButtons.Right) { if (allowCopy) { int sizeX = 0; int sizeY = 0; if (mouse_tile_x_down < mouse_x_map) { sizeX = (mouse_x_map - mouse_tile_x_down) + 1; } else { int oldmdownx = mouse_tile_x_down; mouse_tile_x_down = mouse_x_map; mouse_x_map = oldmdownx; sizeX = (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 { int oldmdowny = mouse_tile_y_down; mouse_tile_y_down = mouse_y_map; mouse_y_map = oldmdowny; sizeY = (mouse_y_map - mouse_tile_y_down) + 1; } //selectedTiles = new ushort[sizeX, sizeY]; /*for (int x = 0; x < sizeX; x++) * { * for (int y = 0; y < sizeY; y++) * { * * } * }*/ selectionSize = new Rectangle(mouse_tile_x_down * 16, mouse_tile_y_down * 16, (sizeX * 16), (sizeY * 16)); selectedTiles = map.getTiles(mouse_tile_x_down, mouse_tile_y_down, sizeX, sizeY); setOverlaytiles(allgfx16Ptr); } } else if (e.Button == MouseButtons.Middle) { selectionSize = new Rectangle(mouse_tile_x_down * 16, mouse_tile_y_down * 16, (1 * 16), (1 * 16)); selectedTiles = map.getTiles(mouse_tile_x_down, mouse_tile_y_down, 1, 1); Tile16EditorForm tile16Editor = new Tile16EditorForm(); tile16Editor.setGfxData(allbitmaps, jsonData, map, selectedTiles[0, 0]); if (tile16Editor.ShowDialog() == DialogResult.OK) { jsonData.alltiles16[selectedTiles[0, 0]] = tile16Editor.editingTile; map.UpdateMap(allgfx16Ptr); refresh = true; } } } else if (sceneMode == SceneMode.entrances) { entrancesHandler.onMouseUp(e, mouse_x, mouse_y, mouse_down, (short)mouseOverMap, map); } else if (sceneMode == SceneMode.holes) { holesHandler.onMouseUp(e, mouse_x, mouse_y, mouse_down, (short)mouseOverMap, map); } else if (sceneMode == SceneMode.exits) { exitsHandler.onMouseUp(e, mouse_x, mouse_y, (short)mouseOverMap, map); } else if (sceneMode == SceneMode.sprites) { spritesHandler.onMouseUp(e, mouse_x, mouse_y, mouse_down, (short)mouseOverMap, map); } else if (sceneMode == SceneMode.items) { itemsHandler.onMouseUp(e, mouse_x, mouse_y, mouse_down, (short)mouseOverMap, map); } refresh = true; //refresh = true; mouse_down = false; }