private void ExecCommand(string[] command) { MapLayer map = MapBox.CurrentMapLayer; command[0] = command[0].Trim().ToLower(); if (command[0] == "set") { int x = int.Parse(command[1]); int y = int.Parse(command[2]); map.SetObject(x, y, CurrentObject); } else if (command[0] == "fill") { map.FillObject(CurrentObject); } else if (command[0] == "clear") { map.Clear(); } else if (command[0] == "rect") { int x = int.Parse(command[1]); int y = int.Parse(command[2]); int w = int.Parse(command[3]); int h = int.Parse(command[4]); for (int py = y; py < y + h; py++) { for (int px = x; px < x + w; px++) { map.SetObject(px, py, CurrentObject); } } } else if (command[0] == "hline") { int x = int.Parse(command[1]); int y = int.Parse(command[2]); int w = int.Parse(command[3]); for (int px = x; px < x + w; px++) { map.SetObject(px, y, CurrentObject); } } else if (command[0] == "vline") { int x = int.Parse(command[1]); int y = int.Parse(command[2]); int h = int.Parse(command[3]); for (int py = y; py < y + h; py++) { map.SetObject(x, py, CurrentObject); } } else if (command[0] == "box") { int x = int.Parse(command[1]); int y = int.Parse(command[2]); int w = int.Parse(command[3]); int h = int.Parse(command[4]); for (int px = x; px < x + w + 1; px++) { map.SetObject(px, y, CurrentObject); map.SetObject(px, y + h, CurrentObject); } for (int py = y; py < y + h; py++) { map.SetObject(x, py, CurrentObject); map.SetObject(x + w, py, CurrentObject); } } else if (command[0].StartsWith("print")) { int x = int.Parse(command[1]); int y = int.Parse(command[2]); int px = x; int py = y; string text = command[3]; if (command.Length > 4) { for (int i = 4; i < command.Length; i++) { text += " " + command[i]; } } foreach (char ch in text) { GameObject o = new GameObject(CurrentObject); o.Bytes.Clear(); o.Graphics.Index = ch; if (ch == '\\') { px = x; py++; } else { map.SetObject(px++, py, o); } } } else if (command[0] == "select") { MapBox.SelectArea( int.Parse(command[1]), int.Parse(command[2]), int.Parse(command[3]), int.Parse(command[4])); MapBox.InvalidateAllMapPositionsAndRefresh(); Log("Area selected: " + MapBox.GetSelectedArea()); } else if (command[0] == "deselect") { MapBox.DeselectArea(); MapBox.InvalidateAllMapPositionsAndRefresh(); Log("Area deselected"); } else if (command[0] == "erase") { MapBox.EraseSelectedArea(); MapBox.InvalidateAllMapPositionsAndRefresh(); Log("Selected area erased"); } else if (command[0] == "copy") { int x = int.Parse(command[1]); int y = int.Parse(command[2]); MapBox.CopySelectedAreaTo(x, y, false); MapBox.InvalidateAllMapPositionsAndRefresh(); Log("Selected area copied to X:" + x + ",Y:" + y); } else if (command[0] == "cut") { int x = int.Parse(command[1]); int y = int.Parse(command[2]); MapBox.CopySelectedAreaTo(x, y, true); MapBox.InvalidateAllMapPositionsAndRefresh(); Log("Selected area cut and pasted to X:" + x + ",Y:" + y); } else if (command[0] == "savesel") { SaveFileDialog dialog = new SaveFileDialog(); dialog.InitialDirectory = DataDirectory; dialog.Filter = "PNG image files|*.png"; if (dialog.ShowDialog() != DialogResult.OK) { return; } MapBox.SaveSelectedAreaAsImage(dialog.FileName); Log("Selected area saved to file:" + dialog.FileName); } MapBox.InvalidateAllMapPositionsAndRefresh(); }