mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 20:53:40 -04:00
Show information about current selection in bottom right HUD
This commit is contained in:
parent
644663a0a7
commit
1ebdbd6e1f
@ -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) {
|
||||
|
@ -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.");
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,6 @@ namespace MCGalaxy.Commands.World {
|
||||
Level.LoadMetadata(lvl);
|
||||
|
||||
if (!PlayerActions.ChangeMap(p, lvl)) return;
|
||||
p.ClearBlockchange();
|
||||
}
|
||||
|
||||
static void SetLevelProps(Level lvl) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
/// <summary> Called when the player has finished providing all the marks for a selection. </summary>
|
||||
|
@ -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, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user