/// <summary> /// "Cements" either a dragged selection or a newly pasted selection. /// </summary> /// <param name="buffer">The dragged selection or the newly pasted selection.</param> private void Defloat(CopyBuffer buffer) { byte[] oldTileset = Bits.Copy(tileset.Tileset_bytes); // selection = null; int x_ = overlay.SelectTS.X / 16; int y_ = overlay.SelectTS.Y / 16; for (int y = 0; y < buffer.Height / 16; y++) { for (int x = 0; x < buffer.Width / 16; x++) { if (y + y_ < 0 || y + y_ >= 16 || x + x_ < 0 || x + x_ >= 16) { continue; } Tile tile = buffer.Tiles[y * (buffer.Width / 16) + x]; tileset.Tileset_tiles[(y + y_) * 16 + x + x_] = tile.Copy(); tileset.Tileset_tiles[(y + y_) * 16 + x + x_].Index = (y + y_) * 16 + x + x_; } } tileset.DrawTileset(tileset.Tileset_tiles, tileset.Tileset_bytes); commandStack.Push(commandCount + 1); commandCount = 0; SetWorldMapImage(); defloating = true; // commandStack.Push(new TilesetCommand(tileset, oldTileset, Model.WorldMapGraphics, 0x20, worldMapName)); }
// spawning public Mod Copy(Level level, Tileset tileset) { Mod copy = new Mod(); copy.B0b7 = b0b7; copy.Height = height; copy.Layer1 = layer1; copy.Layer2 = layer2; copy.Layer3 = layer3; copy.Set = set; copy.TilemapsA[0] = Bits.Copy(tilemapsA[0]); copy.TilemapsA[1] = Bits.Copy(tilemapsA[1]); copy.TilemapsA[2] = Bits.Copy(tilemapsA[2]); copy.TilemapA = new LevelTilemap(level, tileset, this, false); if (this.set) { copy.TilemapsB[0] = Bits.Copy(tilemapsB[0]); copy.TilemapsB[1] = Bits.Copy(tilemapsB[1]); copy.TilemapsB[2] = Bits.Copy(tilemapsB[2]); copy.TilemapB = new LevelTilemap(level, tileset, this, true); } copy.Width = width; copy.X = x; copy.Y = y; return(copy); }
private void coordY_ValueChanged(object sender, EventArgs e) { if (this.Updating) { return; } // int index = (int)((NumericUpDown)sender).Tag; if (!move) { byte[] Y = Bits.Copy(formation.Y); Y[index] = (byte)coordY[index].Value; commandStack.Push(new MoveEdit(formation, Bits.Copy(formation.X), Y)); } this.formation.Y[index] = (byte)coordY[index].Value; // if (waitBothCoords) { return; } if (!move) { formation.PixelIndexes = null; } pictureBoxFormation.Invalidate(); }
private void importTilesetToolStripMenuItem_Click(object sender, EventArgs e) { BattlefieldTileset tileset = new BattlefieldTileset(); tileset = (BattlefieldTileset)Do.Import(tileset); if (tileset == null) { return; } // byte[] oldTileset = Bits.Copy(tileset.Tileset_bytes); // tileset.Palettes.BUFFER = Model.ROM; this.battlefield.GraphicSetA = tileset.Battlefield.GraphicSetA; this.battlefield.GraphicSetB = tileset.Battlefield.GraphicSetB; this.battlefield.GraphicSetC = tileset.Battlefield.GraphicSetC; this.battlefield.GraphicSetD = tileset.Battlefield.GraphicSetD; this.battlefield.GraphicSetE = tileset.Battlefield.GraphicSetE; this.tileset.Palettes = tileset.Palettes; this.tileset.Palettes.CopyTo(Model.PaletteSetsBF[palette]); this.tileset.Graphics = tileset.Graphics; this.tileset.Tileset_tiles = tileset.Tileset_tiles; this.tileset.DrawTileset(this.tileset.Tileset_tiles, this.tileset.Tileset_bytes); this.tileset.Assemble(16, 16); // RefreshBattlefield(); // if (!Bits.Compare(oldTileset, tileset.Tileset_bytes)) { commandStack.Push(new TilesetCommand(tileset, oldTileset, this)); commandStack.Push(1); } }
private void Delete() { if (overlay.SelectTS.Empty) { return; } byte[] oldTileset = Bits.Copy(tileset.Tileset_bytes); // int x_ = overlay.SelectTS.Location.X / 16; int y_ = overlay.SelectTS.Location.Y / 16; for (int y = 0; y < overlay.SelectTS.Height / 16; y++) { for (int x = 0; x < overlay.SelectTS.Width / 16; x++) { int x__ = (x + x_) & 15; int y__ = (y + y_) & 15; int index = y__ * 16 + x__; index += ((x + x_) >> 4) * 256; index += ((y + y_) >> 4) * 512; if (index >= tileset.Tileset_tiles.Length) { continue; } tileset.Tileset_tiles[index].Clear(); tileset.Tileset_bytes[index * 2] = 0; } } tileset.DrawTileset(tileset.Tileset_tiles, tileset.Tileset_bytes); SetBattlefieldImage(); // commandStack.Push(new TilesetCommand(tileset, oldTileset, this)); commandCount++; }
private void pictureBoxFormation_Paint(object sender, PaintEventArgs e) { if (formationBGImage != null) { e.Graphics.DrawImage(formationBGImage, -8, 26); } if (isometricGrid.Checked) { new Overlay().DrawIsometricGrid(e.Graphics, Color.Gray, pictureBoxFormation.Size, new Size(16, 16), 1); } byte[] items = new byte[8]; for (byte i = 0; i < 8; i++) { items[i] = i; } byte[] keys = Bits.Copy(formation.Y); Array.Sort(keys, items); for (int a = 0; a < 8; a++) { int i = items[a]; if (!formation.Use[i]) { continue; } int elevation = monsters[formation.Monsters[i]].Elevation * 16; int x = formation.X[i] - 8; int y = formation.Y[i] + 14; if (elevation > 0) { e.Graphics.DrawImage(shadowImages[i], x, y); } // x = formation.X[i] - 128; y = formation.Y[i] - 96 - elevation - 1; e.Graphics.DrawImage(monsterImages[i], x, y); } if (toggleAllies.Checked) { if (allyImages == null || portraits == null) { SetAllyImages(); } e.Graphics.DrawImage(allyImages[0], Model.ROM[0x0296BD] - 128, Model.ROM[0x0296BE] - 96 - 1); e.Graphics.DrawImage(allyImages[2], Model.ROM[0x0296BF] - 128, Model.ROM[0x0296C0] - 96 - 1); e.Graphics.DrawImage(allyImages[3], Model.ROM[0x0296C1] - 128, Model.ROM[0x0296C2] - 96 - 1); // draw HPs e.Graphics.DrawImage(statImages[0], 24, 94); e.Graphics.DrawImage(statImages[2], 48, 70); e.Graphics.DrawImage(statImages[3], 72, 46); // draw portraits e.Graphics.DrawImage(portraits[0], 20 - 128, 82 - 96 - 1); e.Graphics.DrawImage(portraits[2], 44 - 128, 58 - 96 - 1); e.Graphics.DrawImage(portraits[3], 68 - 128, 34 - 96 - 1); } if (select.Checked && overlay.Select != null) { overlay.Select.DrawSelectionBox(e.Graphics, 1); } }
public HexEditor(byte[] current, byte[] original) { this.current_unmodified = current; this.current = Bits.Copy(current); this.original = original; InitializeComponent(); RefreshHexEditor(); Do.AddShortcut(toolStrip2, Keys.F1, helpTips); new ToolTipLabel(this, null, helpTips); }
// spawning public PaletteSet Copy() { PaletteSet copy = new PaletteSet(buffer, index, offset, count, size, length); copy.BUFFER = Bits.Copy(buffer); copy.Reds = Bits.Copy(reds); copy.Greens = Bits.Copy(greens); copy.Blues = Bits.Copy(blues); return(copy); }
// spawning public LevelMod Copy() { LevelMod copy = new LevelMod(); copy.Tiles = Bits.Copy(tiles); copy.Pixels = Bits.Copy(pixels); copy.Tilemap_Bytes = Bits.Copy(tilemap_Bytes); copy.Width = width; copy.Height = height; copy.X = x; copy.Y = y; return(copy); }
public Tile Copy() { Tile copy = new Tile(); copy.Gridplane = gridplane; copy.Invert = invert; copy.Is16bit = is16bit; copy.Mirror = mirror; copy.Subtile_bytes = Bits.Copy(subtile_bytes); copy.Format = format; copy.TileOffset = tileOffset; copy.Length = length; copy.X = x; copy.Y = y; copy.YMinusOne = yMinusOne; copy.YPlusOne = yPlusOne; return(copy); }
private void clear_Click(object sender, EventArgs e) { byte[] oldTileset = Bits.Copy(tileset.Tileset_bytes); // ClearElements clearElements = new ClearElements(null, index, "CLEAR BATTLEFIELD TILESETS..."); clearElements.ShowDialog(); if (clearElements.DialogResult == DialogResult.Cancel) { return; } RefreshBattlefield(); // if (!Bits.Compare(oldTileset, tileset.Tileset_bytes)) { commandStack.Push(new TilesetCommand(tileset, oldTileset, this)); commandStack.Push(1); } }
private void e_moldWidth_ValueChanged(object sender, EventArgs e) { if (this.Updating) { return; } Defloat(); int width = animation.Width; animation.Width = (byte)e_moldWidth.Value; for (int i = 0; i < molds.Count; i++) { byte[] temp = Bits.Copy(molds[i].Mold); for (int y = 0; y < animation.Height; y++) { for (int x = 0; x < animation.Width; x++) { if (x >= width) { molds[i].Mold[y * animation.Width + x] = 0xFF; } else { molds[i].Mold[y * animation.Width + x] = temp[y * width + x]; } } } } SetTilemapImage(); if (sequences != null) { sequences.SetSequenceFrameImages(); sequences.RealignFrames(); sequences.RealignFrames(); } // update free space animation.Assemble(); effectsEditor.CalculateFreeSpace(); }
private void SetPixelIndexes() { pixelIndexes = new int[256 * 256]; Bits.Fill(pixelIndexes, -1); int[] order = new int[8]; for (int i = 0; i < 8; i++) { order[i] = i; } byte[] temp = Bits.Copy(this.y); Array.Sort(temp, order); for (int g = 0; g < 8; g++) { int i = order[g]; // If monster is used in formation if (use[i]) { // Get correct monster image int[] pixels = Model.Monsters[monsters[i]].Pixels; int elevation = Model.Monsters[monsters[i]].Elevation * 16; for (int y = 0; y < 256; y++) { for (int x = 0; x < 256; x++) { int x_ = this.x[i] + x - 128; int y_ = this.y[i] + y - 96 - elevation; if ((pixels[y * 256 + x] & 0xFF000000) != 0) { if (x_ > 0 && x_ < 256 && y_ > 0 && y_ < 256) { pixelIndexes[(y_ - 1) * 256 + x_] = i; } } } } } } }
/// <summary> /// "Cements" either a dragged selection or a newly pasted selection. /// </summary> /// <param name="buffer">The dragged selection or the newly pasted selection.</param> private void Defloat(CopyBuffer buffer) { byte[] oldTileset = Bits.Copy(tileset.Tileset_bytes); // selection = null; int x_ = overlay.SelectTS.X / 16; int y_ = overlay.SelectTS.Y / 16; for (int y = 0; y < buffer.Height / 16; y++) { for (int x = 0; x < buffer.Width / 16; x++) { int x__ = (x + x_) & 15; int y__ = (y + y_) & 15; int index = y__ * 16 + x__; index += ((x + x_) >> 4) * 256; index += ((y + y_) >> 4) * 512; if (index >= tileset.Tileset_tiles.Length || index < 0) { continue; } if (y < 0 || x < 0) { continue; } Tile tile = buffer.Tiles[y * (buffer.Width / 16) + x]; tileset.Tileset_tiles[index] = tile.Copy(); tileset.Tileset_tiles[index].Index = index; } } tileset.DrawTileset(tileset.Tileset_tiles, tileset.Tileset_bytes); commandStack.Push(commandCount + 1); commandCount = 0; SetBattlefieldImage(); // commandStack.Push(new TilesetCommand(tileset, oldTileset, this)); }
private void Delete() { if (overlay.SelectTS.Empty) { return; } byte[] oldTileset = Bits.Copy(tileset.Tileset_bytes); // int x_ = overlay.SelectTS.Location.X / 16; int y_ = overlay.SelectTS.Location.Y / 16; for (int y = 0; y < overlay.SelectTS.Height / 16 && y + y_ < 0x100; y++) { for (int x = 0; x < overlay.SelectTS.Width / 16 && x + x_ < 0x100; x++) { tileset.Tileset_tiles[(y + y_) * 16 + x + x_].Clear(); } } tileset.DrawTileset(tileset.Tileset_tiles, tileset.Tileset_bytes); SetWorldMapImage(); // commandStack.Push(new TilesetCommand(tileset, oldTileset, Model.WorldMapGraphics, 0x20, worldMapName)); commandCount++; }
public Change(int offset, byte[] values, Color color) { Offset = offset; Values = Bits.Copy(values); Color = color; }
// class functions public SPCCommand Copy() { return(new SPCCommand(Bits.Copy(commandData), this.spc, this.channel)); }