void UndoSelf(Player p) { UndoDrawOpEntry[] entries = p.DrawOps.Items; if (entries.Length == 0) { Player.Message(p, "You have no draw operations to undo."); Player.Message(p, "Try using %T/undo [seconds] %Sinstead."); return; } for (int i = entries.Length - 1; i >= 0; i--) { UndoDrawOpEntry entry = entries[i]; if (entry.DrawOpName == "UndoSelf") { continue; } p.DrawOps.Remove(entry); UndoSelfDrawOp op = new UndoSelfDrawOp(); op.who = p; op.Start = entry.Start; op.End = entry.End; DrawOp.DoDrawOp(op, null, p, new Vec3S32[] { Vec3U16.MaxVal, Vec3U16.MaxVal }); Player.Message(p, "Undo performed."); return; } Player.Message(p, "Unable to undo any draw operations, as all of the " + "past 50 draw operations are %T/undo %Sor %T/undo [seconds]."); Player.Message(p, "Try using %T/undo [seconds] %Sinstead."); }
bool DoMaze(Player p, Vec3S32[] marks, object state, byte type, byte extType) { MazeDrawOp op = new MazeDrawOp(); op.randomizer = (int)state; return(DrawOp.DoDrawOp(op, null, p, marks)); }
public override BlockID NextBlock(DrawOp op) { // Figure out local coords for this block int x = (op.Coords.X - op.Min.X) % state.Width; if (x < 0) { x += state.Width; } int y = (op.Coords.Y - op.Min.Y) % state.Height; if (y < 0) { y += state.Height; } int z = (op.Coords.Z - op.Min.Z) % state.Length; if (z < 0) { z += state.Length; } int index = (y * state.Length + z) * state.Width + x; BlockID block = state.Get(index); for (int i = 0; i < Include.Length; i++) { if (block == Include[i]) { return(block); } } return(Block.Invalid); }
void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { type = type < 128 ? p.bindings[type] : type; RevertAndClearState(p, x, y, z); CatchPos cpos = (CatchPos)p.blockchangeObject; Level lvl = p.level; if (x == cpos.x && z == cpos.z) { Player.SendMessage(p, "No direction was selected"); return; } WriteDrawOp op = new WriteDrawOp(); op.Text = cpos.givenMessage; op.Scale = cpos.scale; op.Spacing = cpos.spacing; Brush brush = new SolidBrush(type, extType); if (!DrawOp.DoDrawOp(op, brush, p, cpos.x, cpos.y, cpos.z, x, y, z)) { return; } if (p.staticCommands) { p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); } }
bool DoReplace(Player p, Vec3S32[] marks, object state, byte type, byte extType) { string[] args = ((string)state).SplitSpaces(3); byte extBlock = 0; int block = DrawCmd.GetBlockIfAllowed(p, args[0], out extBlock); if (block == -1) { return(false); } BrushFactory factory = BrushFactory.Find(args[1]); string brushMessage = args.Length > 2 ? args[2] : ""; BrushArgs bArgs = new BrushArgs(p, brushMessage, type, extType); Brush brush = factory.Construct(bArgs); if (brush == null) { return(false); } DrawOp op = null; if (ReplaceNot) { op = new ReplaceNotDrawOp((byte)block, extBlock); } else { op = new ReplaceDrawOp((byte)block, extBlock); } return(DrawOp.DoDrawOp(op, brush, p, marks)); }
public override byte NextBlock(DrawOp op) { // Figure out local coords for this block int x = (op.Coords.X - op.Min.X) % state.Width; if (x < 0) { x += state.Width; } int y = (op.Coords.Y - op.Min.Y) % state.Height; if (y < 0) { y += state.Height; } int z = (op.Coords.Z - op.Min.Z) % state.Length; if (z < 0) { z += state.Length; } index = state.GetIndex(x, y, z); return(state.Blocks[index]); }
static void PerformRedo(Player p) { UndoDrawOpEntry[] entries = p.DrawOps.Items; if (entries.Length == 0) { Player.SendMessage(p, "You have no %T/undo%S or %T/undo <seconds>%S to redo."); return; } for (int i = entries.Length - 1; i >= 0; i--) { UndoDrawOpEntry entry = entries[i]; if (entry.DrawOpName != "UndoSelf") { continue; } p.DrawOps.Remove(entry); RedoSelfDrawOp op = new RedoSelfDrawOp(); op.Start = entry.Start; op.End = entry.End; DrawOp.DoDrawOp(op, null, p, new [] { Vec3U16.MaxVal, Vec3U16.MaxVal }); Player.SendMessage(p, "Redo performed."); return; } Player.SendMessage(p, "No %T/undo%S or %T/undo <seconds>%S calls were " + "found in the last 200 draw operations."); }
protected void UndoOnlinePlayer(Player p, TimeSpan delta, Player who, Vec3S32[] marks) { if (p != null && p != who && !CheckUndoPerms(p, who.group)) { return; } UndoOnlineDrawOp op; if (p == who) { op = new UndoSelfDrawOp(); } else { op = new UndoOnlineDrawOp(); } op.Start = DateTime.UtcNow.Subtract(delta); op.who = who; DrawOp.DoDrawOp(op, null, p, marks); if (p == who) { Player.Message(p, "Undid your actions for the past &b" + delta.Shorten(true) + "%S."); } else { Player.SendChatFrom(who, who.ColoredName + "%S's actions for the past &b" + delta.Shorten(true) + " %Swere undone.", false); } Server.s.Log(who.name + "'s actions for the past " + delta.Shorten(true) + " were undone."); }
bool DoHollow(Player p, Vec3S32[] marks, object state, byte type, byte extType) { HollowDrawOp op = new HollowDrawOp(); op.Skip = (byte)state; return(DrawOp.DoDrawOp(op, null, p, marks)); }
public override BlockID NextBlock(DrawOp op) { // Figure out local coords for this block int x = (op.Coords.X - op.Min.X) % state.Width; if (x < 0) { x += state.Width; } int y = (op.Coords.Y - op.Min.Y) % state.Height; if (y < 0) { y += state.Height; } int z = (op.Coords.Z - op.Min.Z) % state.Length; if (z < 0) { z += state.Length; } int index = (y * state.Length + z) * state.Width + x; return(state.Get(index)); }
protected void UndoOfflinePlayer(Player p, TimeSpan delta, string whoName, Vec3S32[] marks) { if (p != null && !CheckUndoPerms(p, Group.findPlayerGroup(whoName))) { return; } UndoOfflineDrawOp op = new UndoOfflineDrawOp(); op.Start = DateTime.UtcNow.Subtract(delta); op.whoName = whoName; DrawOp.DoDrawOp(op, null, p, marks); if (op.found) { Chat.MessageAll("{0}%S's actions for the past &b{1} %Swere undone.", PlayerInfo.GetColoredName(p, whoName), delta.Shorten(true)); Server.s.Log(whoName + "'s actions for the past " + delta.Shorten(true) + " were undone."); if (p != null) { p.level.Save(true); } } else { Player.Message(p, "Could not find player specified."); } }
/// <summary> /// 打印指定页 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dtOrder == null || dtOrder.Rows.Count <= 0) { MessageBox.Show("医嘱数据为空"); return; } if (IsLongOrder) { List <Metafile> metaList = new List <Metafile>(); dept = dtOrder.Rows[0]["开立科室"].ToString(); for (int i = 0; i < circulateCount; i++) { pageIndex = i + 1; XmlCommomOp.Doc = null; XmlCommomOp.CopyTempalteXmlFile(AppDomain.CurrentDomain.BaseDirectory + "LongtermTaskTemp.xml", AppDomain.CurrentDomain.BaseDirectory + "LongtermTask.xml"); XmlCommomOp.xmlPath = AppDomain.CurrentDomain.BaseDirectory + "LongtermTask.xml"; XmlCommomOp.CreaetDocument(); XmlCommomOp.BindingDate(CreateDataSet(), CreateDate()); metaList.Add(DrawOp.MakeImagesByXmlDocument(XmlCommomOp.Doc)[0]); } rowsIndex = 0; circulateCount = 1; DrawOp.PrintView(metaList); if (File.Exists(XmlCommomOp.xmlPath)) { File.Delete(XmlCommomOp.xmlPath); } } else { List <Metafile> metaList = new List <Metafile>(); dept = dtOrder.Rows[0]["开立科室"].ToString(); for (int i = 0; i < circulateCount; i++) { XmlCommomOp.Doc = null; pageIndex = i + 1; XmlCommomOp.CopyTempalteXmlFile(AppDomain.CurrentDomain.BaseDirectory + "ShorttermTaskTemp.xml", AppDomain.CurrentDomain.BaseDirectory + "ShorttermTask.xml"); XmlCommomOp.xmlPath = AppDomain.CurrentDomain.BaseDirectory + "ShorttermTask.xml"; XmlCommomOp.CreaetDocument(); XmlCommomOp.BindingDate(CreateDataSet(), CreateDate()); metaList.Add(DrawOp.MakeImagesByXmlDocument(XmlCommomOp.Doc)[0]); } rowsIndex = 0; circulateCount = 1; DrawOp.PrintView(metaList); if (File.Exists(XmlCommomOp.xmlPath)) { File.Delete(XmlCommomOp.xmlPath); } } } catch (Exception ex) { MyMessageBox.Show(1, ex); } }
void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); CatchPos cpos = (CatchPos)p.blockchangeObject; type = type < 128 ? p.bindings[type] : type; string[] parts = cpos.message.Split(trimChars, 3); if (parts.Length < 2) { Help(p); return; } byte extTile = 0; byte tile = DrawCmd.GetBlock(p, parts[0], out extTile); if (tile == Block.Zero) { return; } string brushName = CmdBrush.FindBrush(parts[1]); if (brushName == null) { Player.SendMessage(p, "No brush found with name \"" + parts[1] + "\"."); Player.SendMessage(p, "Available brushes: " + CmdBrush.AvailableBrushes); return; } string brushMessage = parts.Length > 2 ? parts[2].ToLower() : ""; BrushArgs args = new BrushArgs(p, brushMessage, type, extType); Brush brush = Brush.Brushes[brushName](args); if (brush == null) { return; } DrawOp drawOp = null; if (ReplaceNot) { drawOp = new ReplaceNotDrawOp(tile, extTile); } else { drawOp = new ReplaceDrawOp(tile, extTile); } if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z)) { return; } if (p.staticCommands) { p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); } }
bool DoOutline(Player p, Vec3S32[] marks, object state, byte type, byte extType) { DrawArgs dArgs = (DrawArgs)state; OutlineDrawOp op = new OutlineDrawOp(); op.Block = dArgs.block; op.ExtBlock = dArgs.extBlock; op.NewBlock = dArgs.newBlock; op.NewExtBlock = dArgs.newExtBlock; return(DrawOp.DoDrawOp(op, null, p, marks)); }
public override void Perform(Vec3S32[] marks, DrawOp op, Brush brush, DrawOpOutput output) { P = (op.Min + op.Max) / 2; if (!CentreOrigin) { P = op.Origin; } op.Perform(marks, brush, b => OutputBlock(b, output)); }
public override BlockID NextBlock(DrawOp op) { int i = (op.Coords.X + op.Coords.Y + op.Coords.Z) % blocks.Length; if (i < 0) { i += blocks.Length; } return(blocks[i]); }
public override byte NextBlock(DrawOp op) { int offset = (op.Coords.X + op.Coords.Y + op.Coords.Z) % 8; if (offset < 0) { offset += 8; } return(blocks[offset]); }
public override byte NextBlock(DrawOp op) { int offset = (op.Coords.X + op.Coords.Y + op.Coords.Z) % 13; if (offset < 0) { offset += 13; } return((byte)(Block.red + offset)); }
public override byte NextBlock(DrawOp op) { // Sourced from http://freespace.virgin.net/hugo.elias/models/m_perlin.htm int n = (op.Coords.X + 1217 * op.Coords.Y + 4751 * op.Coords.Z + 673 * seed) & mask; n = (n >> 13) ^ n; int raw = (n * (n * n * 60493 + 19990303) + 1376312589) & mask; next = (int)Math.Floor((raw / (double)mask) * blocks.Length); return(blocks[next].Block); }
public override void Perform(Vec3S32[] marks, Player p, Level lvl, DrawOp op, Brush brush, Action <DrawOpBlock> output) { P = (op.Min + op.Max) / 2; width = lvl.Width; height = lvl.Height; length = lvl.Length; if (!CentreOrigin) { P = op.Origin; } op.Perform(marks, brush, b => OutputBlock(b, output)); }
void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { CatchPos cpos = (CatchPos)p.blockchangeObject; RevertAndClearState(p, x, y, z); int offX = p.copyoffset[0] + x, offY = p.copyoffset[1] + y, offZ = p.copyoffset[2] + z; CopyState state = p.CopyBuffer; if (state.X != state.OriginX) { offX -= (state.Width - 1); } if (state.Y != state.OriginY) { offY -= (state.Height - 1); } if (state.Z != state.OriginZ) { offZ -= (state.Length - 1); } DrawOp op; if (cpos.message == "") { op = new SimplePasteDrawOp(); ((SimplePasteDrawOp)op).CopyState = p.CopyBuffer; } else { op = new PasteDrawOp(); ((PasteDrawOp)op).CopyState = p.CopyBuffer; string[] args = cpos.message.Split(' '); if (args[0].CaselessEq("not")) { ((PasteDrawOp)op).Exclude = ReplaceBrush.GetBlocks(p, 1, args.Length, args); } else { ((PasteDrawOp)op).Include = ReplaceBrush.GetBlocks(p, 0, args.Length, args); } } if (!DrawOp.DoDrawOp(op, null, p, (ushort)offX, (ushort)offY, (ushort)offZ, 0, 0, 0)) { return; } if (p.staticCommands) { p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); } }
protected override void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); CatchPos cpos = (CatchPos)p.blockchangeObject; GetRealBlock(type, extType, p, ref cpos); DrawOp op = null; Func <BrushArgs, Brush> constructor = null; switch (cpos.mode) { case DrawMode.solid: op = new CuboidDrawOp(); constructor = SolidBrush.Process; break; case DrawMode.normal: op = new CuboidDrawOp(); break; case DrawMode.hollow: op = new CuboidHollowsDrawOp(); break; case DrawMode.walls: op = new CuboidWallsDrawOp(); break; case DrawMode.holes: op = new CuboidDrawOp(); constructor = CheckeredBrush.Process; break; case DrawMode.wire: op = new CuboidWireframeDrawOp(); break; case DrawMode.random: op = new CuboidDrawOp(); constructor = RandomBrush.Process; break; } int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1; Brush brush = GetBrush(p, cpos, brushOffset, constructor); if (brush == null) { return; } if (!DrawOp.DoDrawOp(op, brush, p, cpos.x, cpos.y, cpos.z, x, y, z)) { return; } if (p.staticCommands) { p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); } }
public override ExtBlock NextBlock(DrawOp op) { ushort x = op.Coords.X, y = op.Coords.Y, z = op.Coords.Z; ExtBlock block = op.Level.GetBlock(x, y, z); for (int i = 0; i < exclude.Length; i++) { if (block == exclude[i]) { return(ExtBlock.Invalid); } } return(target); }
protected override void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); CatchPos cpos = (CatchPos)p.blockchangeObject; GetRealBlock(type, extType, p, ref cpos); if (cpos.mode == DrawMode.straight) { int dx = Math.Abs(cpos.x - x), dy = Math.Abs(cpos.y - y), dz = Math.Abs(cpos.z - z); if (dx > dy && dx > dz) { y = cpos.y; z = cpos.z; } else if (dy > dx && dy > dz) { x = cpos.x; z = cpos.z; } else if (dz > dy && dz > dx) { y = cpos.y; x = cpos.x; } } LineDrawOp drawOp = new LineDrawOp(); drawOp.WallsMode = cpos.mode == DrawMode.walls; int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1; if (cpos.data != null) { drawOp.MaxLength = (ushort)cpos.data; brushOffset++; } Brush brush = GetBrush(p, cpos, brushOffset); if (brush == null) { return; } if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z)) { return; } if (p.staticCommands) { p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); } }
bool DoReplace(Player p, Vec3S32[] marks, object state, byte type, byte extType) { BrushArgs args = new BrushArgs(p, (string)state, type, extType); string name = ReplaceNot ? "replacenot" : "replace"; Brush brush = BrushFactory.Find(name).Construct(args); if (brush == null) { return(false); } DrawOp drawOp = new CuboidDrawOp(); return(DrawOp.DoDrawOp(drawOp, brush, p, marks)); }
void UndoOnlinePlayer(Player p, Player who, CatchPos cpos, ushort x, ushort y, ushort z) { if (p != who && who.group.Permission >= p.group.Permission) { MessageTooHighRank(p, "undo", false); return; } UndoOnlineDrawOp op = new UndoOnlineDrawOp(); op.Start = DateTime.UtcNow.AddTicks(-cpos.seconds * TimeSpan.TicksPerSecond); op.who = who; DrawOp.DoDrawOp(op, null, p, cpos.x, cpos.y, cpos.z, x, y, z); Level saveLevel = op.saveLevel; Player.SendChatFrom(who, who.color + who.DisplayName + "%S's actions for the past &b" + cpos.seconds + " seconds were undone.", false); Server.s.Log(who.name + "'s actions for the past " + cpos.seconds + " seconds were undone."); if (saveLevel != null) saveLevel.Save(true); }
public override ExtBlock NextBlock(DrawOp op) { // Figure out local coords for this block int x = (op.Coords.X - op.Min.X) % state.Width; if (x < 0) { x += state.Width; } int y = (op.Coords.Y - op.Min.Y) % state.Height; if (y < 0) { y += state.Height; } int z = (op.Coords.Z - op.Min.Z) % state.Length; if (z < 0) { z += state.Length; } ExtBlock block = state.Get(x, y, z); if (Exclude != null) { for (int i = 0; i < Exclude.Length; i++) { if (block == Exclude[i]) { return(ExtBlock.Invalid); } } return(block); } else { for (int i = 0; i < Include.Length; i++) { if (block == Include[i]) { return(block); } } return(ExtBlock.Invalid); } }
void DoDrawImageCore(Player p, Vec3S32[] m, DrawArgs dArgs) { Bitmap bmp = HeightmapGen.ReadBitmap(dArgs.name, "extra/images/", p); if (bmp == null) { return; } try { bmp.RotateFlip(RotateFlipType.RotateNoneFlipY); } catch (Exception ex) { Server.ErrorLog(ex); bmp.Dispose(); return; } ImagePrintDrawOp op = new ImagePrintDrawOp(); if (Math.Abs(m[1].X - m[0].X) > Math.Abs(m[1].Z - m[0].Z)) { op.Direction = m[1].X <= m[0].X ? 1 : 0; } else { op.Direction = m[1].Z <= m[0].Z ? 3 : 2; } op.Level = p.level; op.Player = p; op.Source = bmp; op.Layer = dArgs.layer; op.Mode = dArgs.popType; op.Filename = dArgs.name; if (op.Layer) { if (op.Mode == 1) { op.Mode = 2; } if (op.Mode == 3) { op.Mode = 4; } } DrawOp.DoDrawOp(op, null, p, m, false); }
protected override DrawOp GetDrawOp(DrawArgs dArgs) { string[] args = dArgs.Message.SplitSpaces(3); Player p = dArgs.Player; if (args.Length < 2) { Help(p); return(null); } string replaceCmd = ReplaceNot ? "ReplaceNot" : "Replace"; if (!p.CanUse(replaceCmd) || !p.CanUse("Brush")) { p.Message("You cannot use /brush and/or /" + replaceCmd + ", so therefore cannot use this command."); return(null); } BlockID target; if (!CommandParser.GetBlockIfAllowed(p, args[0], out target)) { return(null); } BrushFactory factory = BrushFactory.Find(args[1]); if (factory == null) { p.Message("No brush found with name \"{0}\".", args[1]); CmdBrush.List(p); return(null); } DrawOp op = null; if (ReplaceNot) { op = new ReplaceNotDrawOp(target); } else { op = new ReplaceDrawOp(target); } return(op); }
bool DoWrite(Player p, Vec3S32[] marks, object state, byte type, byte extType) { WriteArgs wArgs = (WriteArgs)state; if (marks[0].X == marks[1].X && marks[0].Z == marks[1].Z) { Player.Message(p, "No direction was selected"); return(false); } WriteDrawOp op = new WriteDrawOp(); op.Text = wArgs.message; op.Scale = wArgs.scale; op.Spacing = wArgs.spacing; Brush brush = new SolidBrush(type, extType); return(DrawOp.DoDrawOp(op, brush, p, marks)); }