diff --git a/MCGalaxy/Commands/Information/CmdAbout.cs b/MCGalaxy/Commands/Information/CmdAbout.cs index bfe66c074..a25d67f4b 100644 --- a/MCGalaxy/Commands/Information/CmdAbout.cs +++ b/MCGalaxy/Commands/Information/CmdAbout.cs @@ -36,7 +36,7 @@ namespace MCGalaxy.Commands.Info { public override void Use(Player p, string message) { Player.Message(p, "Break/build a block to display information."); - p.MakeSelection(1, null, PlacedMark); + p.MakeSelection(1, "Selecting location for %SBlock info", null, PlacedMark); } bool PlacedMark(Player p, Vec3S32[] marks, object state, ExtBlock block) { diff --git a/MCGalaxy/Commands/Moderation/CmdRestoreSelection.cs b/MCGalaxy/Commands/Moderation/CmdRestoreSelection.cs index 8023bd8ce..3425f1165 100644 --- a/MCGalaxy/Commands/Moderation/CmdRestoreSelection.cs +++ b/MCGalaxy/Commands/Moderation/CmdRestoreSelection.cs @@ -36,7 +36,7 @@ namespace MCGalaxy.Commands.Moderation { if (LevelInfo.ExistsBackup(p.level.name, message)) { Player.Message(p, "Select two corners for restore."); - p.MakeSelection(2, message, DoRestore); + p.MakeSelection(2, "Selecting region for %SRestore", message, DoRestore); } else { Player.Message(p, "Backup " + message + " does not exist."); } diff --git a/MCGalaxy/Commands/Moderation/CmdUndoPlayer.cs b/MCGalaxy/Commands/Moderation/CmdUndoPlayer.cs index ef60f7078..f6ca09e77 100644 --- a/MCGalaxy/Commands/Moderation/CmdUndoPlayer.cs +++ b/MCGalaxy/Commands/Moderation/CmdUndoPlayer.cs @@ -55,7 +55,7 @@ namespace MCGalaxy.Commands.Moderation { Player.Message(p, "Place or break two blocks to determine the edges."); UndoAreaArgs args = new UndoAreaArgs(); args.ids = ids; args.names = names; args.delta = delta; - p.MakeSelection(2, args, DoUndoArea); + p.MakeSelection(2, "Selecting region for %SUndo player", args, DoUndoArea); } } diff --git a/MCGalaxy/Commands/World/CmdMuseum.cs b/MCGalaxy/Commands/World/CmdMuseum.cs index a1ae51f06..13f10a96e 100644 --- a/MCGalaxy/Commands/World/CmdMuseum.cs +++ b/MCGalaxy/Commands/World/CmdMuseum.cs @@ -64,7 +64,6 @@ namespace MCGalaxy.Commands.World { Level.LoadMetadata(lvl); if (!PlayerActions.ChangeMap(p, lvl)) return; - p.ClearBlockchange(); } static void SetLevelProps(Level lvl) { diff --git a/MCGalaxy/Commands/building/CmdCenter.cs b/MCGalaxy/Commands/building/CmdCenter.cs index 1ca0eb363..7dfc86f56 100644 --- a/MCGalaxy/Commands/building/CmdCenter.cs +++ b/MCGalaxy/Commands/building/CmdCenter.cs @@ -29,7 +29,7 @@ namespace MCGalaxy.Commands.Building { public override void Use(Player p, string message) { Player.Message(p, "Place or break two blocks to determine the edges."); - p.MakeSelection(2, null, DoCentre); + p.MakeSelection(2, "Selecting region for %SCentre", null, DoCentre); } bool DoCentre(Player p, Vec3S32[] m, object state, ExtBlock block) { diff --git a/MCGalaxy/Commands/building/CmdCopy.cs b/MCGalaxy/Commands/building/CmdCopy.cs index 1f8932a25..fb0dc10bd 100644 --- a/MCGalaxy/Commands/building/CmdCopy.cs +++ b/MCGalaxy/Commands/building/CmdCopy.cs @@ -90,7 +90,7 @@ namespace MCGalaxy.Commands.Building { } Player.Message(p, "Place or break two blocks to determine the edges."); - p.MakeSelection(2, cArgs, DoCopy); + p.MakeSelection(2, "Selecting region for %SCopy", cArgs, DoCopy); } bool DoCopy(Player p, Vec3S32[] m, object state, ExtBlock block) { @@ -144,7 +144,7 @@ namespace MCGalaxy.Commands.Building { Player.Message(p, format, cState.UsedBlocks); if (cArgs.offsetIndex != -1) { Player.Message(p, "Place a block to determine where to paste from"); - p.MakeSelection(1, null, PlacedOffsetMark); + p.MakeSelection(1, "Selecting paste offset for %SCopy", null, PlacedOffsetMark); } return false; } diff --git a/MCGalaxy/Commands/building/CmdDrill.cs b/MCGalaxy/Commands/building/CmdDrill.cs index 21676263c..b347775fa 100644 --- a/MCGalaxy/Commands/building/CmdDrill.cs +++ b/MCGalaxy/Commands/building/CmdDrill.cs @@ -31,7 +31,7 @@ namespace MCGalaxy.Commands.Building { if (message != "" && !CommandParser.GetUShort(p, message, "Distance", ref dist)) return; Player.Message(p, "Destroy the block you wish to drill."); - p.MakeSelection(1, dist, DoDrill); + p.MakeSelection(1, "Selecting location for %SDrill", dist, DoDrill); } bool DoDrill(Player p, Vec3S32[] marks, object state, ExtBlock block) { diff --git a/MCGalaxy/Commands/building/CmdImageprint.cs b/MCGalaxy/Commands/building/CmdImageprint.cs index 71037bcc8..b8c7fd6a5 100644 --- a/MCGalaxy/Commands/building/CmdImageprint.cs +++ b/MCGalaxy/Commands/building/CmdImageprint.cs @@ -79,7 +79,7 @@ namespace MCGalaxy.Commands.Building { Player.Message(p, "The URL entered was invalid!"); return; } Player.Message(p, "Place or break two blocks to determine direction."); - p.MakeSelection(2, dArgs, DoImage); + p.MakeSelection(2, "Selecting direction for %SImagePrint", dArgs, DoImage); } bool DownloadWebFile(string url, Player p) { diff --git a/MCGalaxy/Commands/building/CmdMeasure.cs b/MCGalaxy/Commands/building/CmdMeasure.cs index e131dae28..3925b317b 100644 --- a/MCGalaxy/Commands/building/CmdMeasure.cs +++ b/MCGalaxy/Commands/building/CmdMeasure.cs @@ -34,7 +34,7 @@ namespace MCGalaxy.Commands.Building { if (message != "" && !CommandParser.GetBlock(p, message, out skip)) return; Player.Message(p, "Place or break two blocks to determine the edges."); - p.MakeSelection(2, skip, DoMeasure); + p.MakeSelection(2, "Selecting region for %SMeasure", skip, DoMeasure); } bool DoMeasure(Player p, Vec3S32[] m, object state, ExtBlock block) { diff --git a/MCGalaxy/Commands/building/CmdPaste.cs b/MCGalaxy/Commands/building/CmdPaste.cs index 993f54fb1..61f68af32 100644 --- a/MCGalaxy/Commands/building/CmdPaste.cs +++ b/MCGalaxy/Commands/building/CmdPaste.cs @@ -41,7 +41,7 @@ namespace MCGalaxy.Commands.Building { if (brush == null) return; Player.Message(p, "Place a block in the corner of where you want to paste."); - p.MakeSelection(1, brush, DoPaste); + p.MakeSelection(1, "Selecting location for %SPaste", brush, DoPaste); } bool DoPaste(Player p, Vec3S32[] m, object state, ExtBlock block) { diff --git a/MCGalaxy/Commands/building/CmdRestartPhysics.cs b/MCGalaxy/Commands/building/CmdRestartPhysics.cs index e46e40bc6..d975b33b9 100644 --- a/MCGalaxy/Commands/building/CmdRestartPhysics.cs +++ b/MCGalaxy/Commands/building/CmdRestartPhysics.cs @@ -35,7 +35,7 @@ namespace MCGalaxy.Commands.Building { if (message != "" && !ParseArgs(p, message, ref extraInfo)) return; Player.Message(p, "Place or break two blocks to determine the edges."); - p.MakeSelection(2, extraInfo, DoRestart); + p.MakeSelection(2, "Selecting region for %SRestart physics", extraInfo, DoRestart); } bool ParseArgs(Player p, string message, ref PhysicsArgs args) { diff --git a/MCGalaxy/Commands/building/CmdTree.cs b/MCGalaxy/Commands/building/CmdTree.cs index cbac7a73a..9e5c03460 100644 --- a/MCGalaxy/Commands/building/CmdTree.cs +++ b/MCGalaxy/Commands/building/CmdTree.cs @@ -59,7 +59,7 @@ namespace MCGalaxy.Commands.Building { if (!CheckBrush(p, dArgs.brushMsg)) return; Player.Message(p, "Select where you wish your tree to grow"); - p.MakeSelection(1, dArgs, DoTree); + p.MakeSelection(1, "Selecting location for %STree", dArgs, DoTree); } static bool CheckBrush(Player p, string brushMsg) { diff --git a/MCGalaxy/Commands/building/CmdWrite.cs b/MCGalaxy/Commands/building/CmdWrite.cs index 5cb56eddf..4021391f0 100644 --- a/MCGalaxy/Commands/building/CmdWrite.cs +++ b/MCGalaxy/Commands/building/CmdWrite.cs @@ -46,7 +46,7 @@ namespace MCGalaxy.Commands.Building { wArgs.scale = scale; wArgs.spacing = spacing; wArgs.message = args[2].ToUpper(); Player.Message(p, "Place or break two blocks to determine direction."); - p.MakeSelection(2, wArgs, DoWrite); + p.MakeSelection(2, "Selecting direction for %SWrite", wArgs, DoWrite); } bool DoWrite(Player p, Vec3S32[] marks, object state, ExtBlock block) { diff --git a/MCGalaxy/Commands/building/DrawCmd.cs b/MCGalaxy/Commands/building/DrawCmd.cs index ebd94cba2..7ad9991e1 100644 --- a/MCGalaxy/Commands/building/DrawCmd.cs +++ b/MCGalaxy/Commands/building/DrawCmd.cs @@ -48,7 +48,7 @@ namespace MCGalaxy.Commands.Building { if (!factory.Validate(bArgs)) return; Player.Message(p, PlaceMessage); - p.MakeSelection(MarksCount, dArgs, DoDraw); + p.MakeSelection(MarksCount, "Selecting region for %S" + dArgs.Op.Name, dArgs, DoDraw); } protected virtual bool DoDraw(Player p, Vec3S32[] marks, object state, ExtBlock block) { diff --git a/MCGalaxy/Player/Player.Fields.cs b/MCGalaxy/Player/Player.Fields.cs index 09096c896..87b900ef6 100644 --- a/MCGalaxy/Player/Player.Fields.cs +++ b/MCGalaxy/Player/Player.Fields.cs @@ -255,7 +255,7 @@ namespace MCGalaxy { public event OnBlockChange Blockchange; internal bool HasBlockchange { get { return Blockchange != null; } } - public void ClearBlockchange() { Blockchange = null; } + public void ClearBlockchange() { ClearSelection(); } public object blockchangeObject; /// Called when the player has finished providing all the marks for a selection. diff --git a/MCGalaxy/Player/Player.cs b/MCGalaxy/Player/Player.cs index c6c3f7c9c..877ade877 100644 --- a/MCGalaxy/Player/Player.cs +++ b/MCGalaxy/Player/Player.cs @@ -485,19 +485,40 @@ namespace MCGalaxy { return false; } + public void CheckForMessageSpam() { + if (spamChecker != null) spamChecker.CheckChatSpam(); + } + + string selTitle; readonly object selLock = new object(); Vec3S32[] selMarks; object selState; SelectionHandler selCallback; int selIndex; - public void MakeSelection(int marks, object state, SelectionHandler callback) { + public void MakeSelection(int marks, string title, object state, SelectionHandler callback) { lock (selLock) { selMarks = new Vec3S32[marks]; + selTitle = title; selState = state; selCallback = callback; selIndex = 0; Blockchange = SelectionBlockChange; + if (title != null) InitSelectionHUD(); + } + } + + public void MakeSelection(int marks, object state, SelectionHandler callback) { + MakeSelection(marks, null, state, callback); + } + + public void ClearSelection() { + lock (selLock) { + if (selTitle != null) ResetSelectionHUD(); + selTitle = null; + selState = null; + selCallback = null; + Blockchange = null; } } @@ -508,23 +529,43 @@ namespace MCGalaxy { selMarks[selIndex] = new Vec3S32(x, y, z); selIndex++; + + if (selIndex == 1) { + SendCpeMessage(CpeMessageType.BottomRight2, "Mark #1" + FormatSelectionMark(selMarks[0])); + } else if (selIndex == 2) { + SendCpeMessage(CpeMessageType.BottomRight1, "Mark #2" + FormatSelectionMark(selMarks[0])); + } if (selIndex != selMarks.Length) return; - object state = selState; selState = null; - SelectionHandler callback = selCallback; selCallback = null; - - Blockchange = null; + string title = selTitle; + object state = selState; + SelectionHandler callback = selCallback; + ClearSelection(); + if (!block.IsPhysicsType) block = p.BlockBindings[block.RawID]; bool canRepeat = callback(this, selMarks, state, block); if (canRepeat && staticCommands) { - MakeSelection(selIndex, state, callback); + MakeSelection(selIndex, title, state, callback); } } - } + } - public void CheckForMessageSpam() { - if (spamChecker != null) spamChecker.CheckChatSpam(); + string FormatSelectionMark(Vec3S32 P) { + return ": %S(" + P.X + ", " + P.Y + ", " + P.Z + ")"; + } + + void InitSelectionHUD() { + SendCpeMessage(CpeMessageType.BottomRight3, selTitle); + int marks = selMarks.Length; + if (marks >= 1) SendCpeMessage(CpeMessageType.BottomRight2, "Mark #1: %S(Not yet set)"); + if (marks >= 2) SendCpeMessage(CpeMessageType.BottomRight1, "Mark #2: %S(Not yet set)"); + } + + void ResetSelectionHUD() { + SendCpeMessage(CpeMessageType.BottomRight3, ""); + SendCpeMessage(CpeMessageType.BottomRight2, ""); + SendCpeMessage(CpeMessageType.BottomRight1, ""); } } }