From f7a53b081f46399fd1121c532b7dbb60366f058c Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 20 Jul 2021 17:27:23 +1000 Subject: [PATCH] Split up /spin into /spin and /mirror --- GUI/Controls/HackyPropertyGrid.cs | 2 - MCGalaxy/Commands/building/CmdMirror.cs | 63 +++++++++++++++++++++++++ MCGalaxy/Commands/building/CmdSpin.cs | 54 ++++++++------------- MCGalaxy/Games/ZombieSurvival/ZSGame.cs | 2 +- MCGalaxy/MCGalaxy_.csproj | 1 + 5 files changed, 85 insertions(+), 37 deletions(-) create mode 100644 MCGalaxy/Commands/building/CmdMirror.cs diff --git a/GUI/Controls/HackyPropertyGrid.cs b/GUI/Controls/HackyPropertyGrid.cs index 61138333e..19c66a2f3 100644 --- a/GUI/Controls/HackyPropertyGrid.cs +++ b/GUI/Controls/HackyPropertyGrid.cs @@ -41,7 +41,6 @@ namespace MCGalaxy.Gui { Type: IndexOutOfRangeException Source: System.Windows.Forms Message: Index was outside the bounds of the array. -Target: UpdatePropertiesViewTabVisibility Trace: at System.Windows.Forms.PropertyGrid.UpdatePropertiesViewTabVisibility () at System.Windows.Forms.PropertyGrid.ShowEventsButton (System.Boolean value) at System.Windows.Forms.PropertyGrid.set_SelectedObjects (System.Object[] value) @@ -58,7 +57,6 @@ Trace: at System.Windows.Forms.PropertyGrid.UpdatePropertiesViewTabVisibility Type: IndexOutOfRangeException Source: System.Windows.Forms Message: Index was outside the bounds of the array. -Target: RefreshProperties Trace: at System.Windows.Forms.PropertyGrid.RefreshProperties (System.Boolean clearCached) at System.Windows.Forms.PropertyGrid.Refresh (System.Boolean clearCached) at System.Windows.Forms.PropertyGrid.Refresh () diff --git a/MCGalaxy/Commands/building/CmdMirror.cs b/MCGalaxy/Commands/building/CmdMirror.cs new file mode 100644 index 000000000..6c591bb98 --- /dev/null +++ b/MCGalaxy/Commands/building/CmdMirror.cs @@ -0,0 +1,63 @@ +/* + Copyright 2011 MCForge + + Dual-licensed under the Educational Community License, Version 2.0 and + the GNU General Public License, Version 3 (the "Licenses"); you may + not use this file except in compliance with the Licenses. You may + obtain a copy of the Licenses at + + http://www.opensource.org/licenses/ecl2.php + http://www.gnu.org/licenses/gpl-3.0.html + + Unless required by applicable law or agreed to in writing, + software distributed under the Licenses are distributed on an "AS IS" + BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + or implied. See the Licenses for the specific language governing + permissions and limitations under the Licenses. + */ +using System.Collections.Generic; +using MCGalaxy.Drawing; + +namespace MCGalaxy.Commands.Building { + public sealed class CmdMirror : Command2 { + public override string name { get { return "Mirror"; } } + public override string type { get { return CommandTypes.Building; } } + public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } } + public override bool SuperUseable { get { return false; } } + public override CommandAlias[] Aliases { + get { return new [] { new CommandAlias("Flip") }; } + } + + public override void Use(Player p, string message, CommandData data) { + if (message.Length == 0) { Help(p); return; } + if (p.CurrentCopy == null) { + p.Message("You haven't copied anything yet"); return; + } + + CopyState cState = p.CurrentCopy; + BlockDefinition[] defs = p.level.CustomBlockDefs; + + foreach (string arg in message.SplitSpaces()) + { + if (arg.CaselessEq("x")) { + Flip.MirrorX(cState, defs); + p.Message("Flipped copy across the X (east/west) axis."); + } else if (arg.CaselessEq("y") || arg.CaselessEq("u")) { + Flip.MirrorY(cState, defs); + p.Message("Flipped copy across the Y (vertical) axis."); + } else if (arg.CaselessEq("z")) { + Flip.MirrorZ(cState, defs); + p.Message("Flipped copy across the Z (north/south) axis."); + } + } + } + + public override void Help(Player p) { + p.Message("&T/Mirror X/Y/Z"); + p.Message("&HFlips/Mirrors the copied object around that axis."); + p.Message(" &HX = horizontal axis (east-west)"); + p.Message(" &HY = vertical axis"); + p.Message(" &HZ = horizontal axis (north-south)"); + } + } +} diff --git a/MCGalaxy/Commands/building/CmdSpin.cs b/MCGalaxy/Commands/building/CmdSpin.cs index d43ae45d9..8829205d6 100644 --- a/MCGalaxy/Commands/building/CmdSpin.cs +++ b/MCGalaxy/Commands/building/CmdSpin.cs @@ -25,7 +25,7 @@ namespace MCGalaxy.Commands.Building { public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } } public override bool SuperUseable { get { return false; } } public override CommandAlias[] Aliases { - get { return new [] { new CommandAlias("Mirror", "mirror"), new CommandAlias("Rotate") }; } + get { return new [] { new CommandAlias("Rotate") }; } } public override void Use(Player p, string message, CommandData data) { @@ -38,38 +38,26 @@ namespace MCGalaxy.Commands.Building { string opt = message.ToLower(); BlockDefinition[] defs = p.level.CustomBlockDefs; - // Mirroring - if (opt == "mirrorx" || opt == "mirror x") { - Flip.MirrorX(cState, defs); - p.Message("Flipped copy across the X (east/west) axis."); - } else if (opt == "mirrory" || opt == "mirror y" || opt == "u") { - Flip.MirrorY(cState, defs); - p.Message("Flipped copy across the Y (vertical) axis."); - } else if (opt == "mirrorz" || opt == "mirror z" || opt == "m") { - Flip.MirrorZ(cState, defs); - p.Message("Flipped copy across the Z (north/south) axis."); - } else { - string[] args = opt.SplitSpaces(); - char axis = 'Y'; - int angle = 90; - if (!Handle(ref axis, ref angle, args[0])) { Help(p); return; } - if (args.Length > 1 && !Handle(ref axis, ref angle, args[1])) { Help(p); return; } - - CopyState newState = cState; - if (angle == 0) { - } else if (axis == 'X') { - newState = Flip.RotateX(cState, angle, defs); - } else if (axis == 'Y') { - newState = Flip.RotateY(cState, angle, defs); - } else if (axis == 'Z') { - newState = Flip.RotateZ(cState, angle, defs); - } + string[] args = opt.SplitSpaces(); + char axis = 'Y'; + int angle = 90; + if (!Handle(ref axis, ref angle, args[0])) { Help(p); return; } + if (args.Length > 1 && !Handle(ref axis, ref angle, args[1])) { Help(p); return; } + + CopyState newState = cState; + if (angle == 0) { + } else if (axis == 'X') { + newState = Flip.RotateX(cState, angle, defs); + } else if (axis == 'Y') { + newState = Flip.RotateY(cState, angle, defs); + } else if (axis == 'Z') { + newState = Flip.RotateZ(cState, angle, defs); + } - newState.CopySource = cState.CopySource; - newState.CopyTime = cState.CopyTime; - p.CurrentCopy = newState; - p.Message("Rotated copy {0} degrees around the {1} axis", angle, axis); - } + newState.CopySource = cState.CopySource; + newState.CopyTime = cState.CopyTime; + p.CurrentCopy = newState; + p.Message("Rotated copy {0} degrees around the {1} axis", angle, axis); } bool Handle(ref char axis, ref int angle, string arg) { @@ -87,8 +75,6 @@ namespace MCGalaxy.Commands.Building { } public override void Help(Player p) { - p.Message("&T/Spin mirrorx/mirrory/mirrorz"); - p.Message("&HFlips/Mirrors the copied object around that axis."); p.Message("&T/Spin X/Y/Z 90/180/270"); p.Message("&HRotates the copied object around that axis by the given angle. " + "If no angle is given, 90 degrees is used."); diff --git a/MCGalaxy/Games/ZombieSurvival/ZSGame.cs b/MCGalaxy/Games/ZombieSurvival/ZSGame.cs index 38127d545..aeadc4386 100644 --- a/MCGalaxy/Games/ZombieSurvival/ZSGame.cs +++ b/MCGalaxy/Games/ZombieSurvival/ZSGame.cs @@ -304,7 +304,7 @@ namespace MCGalaxy.Games { Player target = PlayerInfo.FindMatches(p, name); if (target == null) return false; - p.Message("{0} was queued.", p.FormatNick(target)); + p.Message("{0} &Swas queued.", p.FormatNick(target)); QueuedZombie = target.name; if (Map != null) Map.Message(target.ColoredName + " &Swas queued as the next zombie."); diff --git a/MCGalaxy/MCGalaxy_.csproj b/MCGalaxy/MCGalaxy_.csproj index 97b5c48ba..b59ab879a 100644 --- a/MCGalaxy/MCGalaxy_.csproj +++ b/MCGalaxy/MCGalaxy_.csproj @@ -137,6 +137,7 @@ +