public override void Execute() { var clipboardPath = Tools.GetClipboardPath(plr.User.ID); var data = Tools.LoadWorldData(clipboardPath); using (var writer = WorldSectionData.WriteHeader(clipboardPath, 0, 0, data.Width * _scale, data.Height * _scale)) { var r = new List <ITile>(); // TODO: Decreased scaling for (var i = 0; i < data.Width; i++) { for (var j = 0; j < data.Height; j++) { for (var a = 0; a < _scale; a++) { writer.Write(data.Tiles[i, j]); } r.Add(data.Tiles[i, j]); if (j != data.Height - 1) { continue; } for (var a = 0; a < _scale - 1; a++) { foreach (var t in r) { for (var b = 0; b < _scale; b++) { writer.Write(t); } } } r.Clear(); } } } plr.SendSuccessMessage("Scaled clipboard to {0}x.", _scale); }
public override void Execute() { var clipboardPath = Tools.GetClipboardPath(plr.Account.ID); var data = Tools.LoadWorldData(clipboardPath); BinaryWriter writer = null; switch ((_degrees / 90 % 4 + 4) % 4) { case 0: writer = WorldSectionData.WriteHeader(clipboardPath, 0, 0, data.Width, data.Height); for (var i = 0; i < data.Width; i++) { for (var j = 0; j < data.Height; j++) { writer.Write(data.Tiles[i, j]); } } break; case 1: writer = WorldSectionData.WriteHeader(clipboardPath, 0, 0, data.Height, data.Width); for (var j = data.Height - 1; j >= 0; j--) { for (var i = 0; i < data.Width; i++) { switch (data.Tiles[i, j].slope()) { case 0: break; case 1: data.Tiles[i, j].slope(3); break; case 2: data.Tiles[i, j].slope(1); break; case 3: data.Tiles[i, j].slope(4); break; case 4: data.Tiles[i, j].slope(2); break; } writer.Write(data.Tiles[i, j]); } } break; case 2: writer = WorldSectionData.WriteHeader(clipboardPath, 0, 0, data.Width, data.Height); for (int i = data.Width - 1; i >= 0; i--) { for (int j = data.Height - 1; j >= 0; j--) { switch (data.Tiles[i, j].slope()) { case 0: break; case 1: data.Tiles[i, j].slope(4); break; case 2: data.Tiles[i, j].slope(3); break; case 3: data.Tiles[i, j].slope(2); break; case 4: data.Tiles[i, j].slope(1); break; } writer.Write(data.Tiles[i, j]); } } break; case 3: writer = WorldSectionData.WriteHeader(clipboardPath, 0, 0, data.Height, data.Width); for (int j = 0; j < data.Height; j++) { for (int i = data.Width - 1; i >= 0; i--) { switch (data.Tiles[i, j].slope()) { case 0: break; case 1: data.Tiles[i, j].slope(2); break; case 2: data.Tiles[i, j].slope(4); break; case 3: data.Tiles[i, j].slope(1); break; case 4: data.Tiles[i, j].slope(3); break; } writer.Write(data.Tiles[i, j]); } } break; } writer?.Close(); plr.SendSuccessMessage("Rotated clipboard {0} degrees.", _degrees); }
public override void Execute() { string clipboardPath = Tools.GetClipboardPath(plr.User.ID); var data = Tools.LoadWorldData(clipboardPath); int endX = flipX ? -1 : data.Width; int endY = flipY ? -1 : data.Height; int incX = flipX ? -1 : 1; int incY = flipY ? -1 : 1; using (var writer = WorldSectionData.WriteHeader(clipboardPath, 0, 0, data.Width, data.Height)) { for (int i = flipX ? data.Width - 1 : 0; i != endX; i += incX) { for (int j = flipY ? data.Height - 1 : 0; j != endY; j += incY) { switch (data.Tiles[i, j].slope()) { case 0: break; case 1: if (flipX && flipY) { data.Tiles[i, j].slope(4); } else if (flipX) { data.Tiles[i, j].slope(2); } else if (flipY) { data.Tiles[i, j].slope(3); } break; case 2: if (flipX && flipY) { data.Tiles[i, j].slope(3); } else if (flipX) { data.Tiles[i, j].slope(1); } else if (flipY) { data.Tiles[i, j].slope(4); } break; case 3: if (flipX && flipY) { data.Tiles[i, j].slope(2); } else if (flipX) { data.Tiles[i, j].slope(4); } else if (flipY) { data.Tiles[i, j].slope(1); } break; case 4: if (flipX && flipY) { data.Tiles[i, j].slope(1); } else if (flipX) { data.Tiles[i, j].slope(3); } else if (flipY) { data.Tiles[i, j].slope(2); } break; } writer.Write(data.Tiles[i, j]); } } } plr.SendSuccessMessage("Flipped clipboard."); }
public override void Execute() { int newX = x + right, newY = y + down; if (newX < 0) { newX = 0; } if (newY < 0) { newY = 0; } if (newX >= Main.maxTilesX - Math.Abs(x - x2)) { newX = Main.maxTilesX - Math.Abs(x - x2) - 1; } if (newY >= Main.maxTilesY - Math.Abs(y - y2)) { newY = Main.maxTilesY - Math.Abs(y - y2) - 1; } int newX2 = newX + Math.Abs(x - x2), newY2 = newY + Math.Abs(y - y2); int tX = Math.Min(x, Math.Min(newX, newX2)); int tY = Math.Min(y, Math.Min(newY, newY2)); int tX2 = Math.Max(x2, Math.Max(newX, newX2)); int tY2 = Math.Max(y2, Math.Max(newY, newY2)); if (!CanUseCommand(tX, tY, tX2, tY2)) { return; } Tools.PrepareUndo(tX, tY, tX2, tY2, plr); WorldSectionData data = Tools.SaveWorldSection(x, y, x2, y2); int edits = 0; for (int i = x; i <= x2; i++) { for (int j = y; j <= y2; j++) { if (magicWand.InSelection(i, j) && expression.Evaluate(Main.tile[i, j])) { Main.tile[i, j] = new Tile(); edits++; } } } for (var i = newX; i <= newX2; i++) { for (var j = newY; j <= newY2; j++) { var index1 = i - newX; var index2 = j - newY; if (i < 0 || j < 0 || i >= Main.maxTilesX || j >= Main.maxTilesY || !magicWand.InSelection(i - right, j - down) || !expression.Evaluate(data.Tiles[index1, index2])) { continue; } Main.tile[i, j] = data.Tiles[index1, index2]; } } Tools.LoadWorldSection(data, newX, newY, false); ResetSection(); PlayerInfo info = plr.GetPlayerInfo(); info.X = newX; info.Y = newY; info.X2 = newX2; info.Y2 = newY2; plr.SendInfoMessage("Moved tiles ({0}).", edits); }
public override void Execute() { WorldSectionData data = Tools.LoadWorldData(path); var width = data.Width - 1; var height = data.Height - 1; if ((alignment & 1) == 0) { x2 = x + width; } else { x2 = x; x -= width; } if ((alignment & 2) == 0) { y2 = y + height; } else { y2 = y; y -= height; } if (x < 0) { x = 0; } if (x2 < 0) { x2 = 0; } if (y < 0) { y = 0; } if (y2 < 0) { y2 = 0; } if (x >= Main.maxTilesX) { x = Main.maxTilesX - 1; } if (x2 >= Main.maxTilesX) { x2 = Main.maxTilesX - 1; } if (y >= Main.maxTilesY) { y = Main.maxTilesY - 1; } if (y2 >= Main.maxTilesY) { y2 = Main.maxTilesY - 1; } if (!CanUseCommand()) { return; } if (prepareUndo) { Tools.PrepareUndo(x, y, x2, y2, plr); } for (var i = x; i <= x2; i++) { for (var j = y; j <= y2; j++) { var index1 = i - x; var index2 = j - y; if (i < 0 || j < 0 || i >= Main.maxTilesX || j >= Main.maxTilesY || expression != null && !expression.Evaluate(mode_MainBlocks ? Main.tile[i, j] : data.Tiles[index1, index2])) { continue; } Main.tile[i, j] = data.Tiles[index1, index2]; } } Tools.LoadWorldSection(data, x, y, false); ResetSection(); plr.SendSuccessMessage("Pasted clipboard to selection."); }
public override void Execute() { var clipboardPath = Tools.GetClipboardPath(plr.Account.ID); var data = Tools.LoadWorldData(clipboardPath); if (_addition) { using (var writer = WorldSectionData.WriteHeader(clipboardPath, 0, 0, data.Width * _scale, data.Height * _scale)) { var r = new List <ITile>(); for (var i = 0; i < data.Width; i++) { for (var j = 0; j < data.Height; j++) { for (var a = 0; a < _scale; a++) { writer.Write(data.Tiles[i, j]); } r.Add(data.Tiles[i, j]); if (j != data.Height - 1) { continue; } for (var a = 0; a < _scale - 1; a++) { foreach (var t in r) { for (var b = 0; b < _scale; b++) { writer.Write(t); } } } r.Clear(); } } } } else { int _x = (data.Width % _scale), _y = (data.Height % _scale); int x = (data.Width / _scale), y = (data.Height / _scale); int width = ((_x == 0) ? x : (x + 1)); int height = ((_y == 0) ? y : (y + 1)); ITile[,] newData = new ITile[width, height]; for (int i1 = 0; i1 < width; i1++) { for (int j1 = 0; j1 < height; j1++) { List <ITile> Square = new List <ITile>(); for (int i2 = 0; i2 < _scale; i2++) { for (int j2 = 0; j2 < _scale; j2++) { Square.Add((((i1 * _scale + i2) < data.Width) && ((j1 * _scale + j2) < data.Height)) ? data.Tiles[(i1 * _scale + i2), (j1 * _scale + j2)] : new Tile()); } } newData[i1, j1] = Square .GroupBy(g => g.type) .OrderByDescending(g => g.Count()) .SelectMany(g => g) .First(); } } using (var writer = WorldSectionData.WriteHeader(clipboardPath, 0, 0, width, height)) { for (var i = 0; i < width; i++) { for (var j = 0; j < height; j++) { writer.Write(newData[i, j]); } } } } plr.SendSuccessMessage("Clipboard {0}creased by {1} times.", (_addition ? "in" : "de"), _scale); }