Split up /spin into /spin and /mirror

This commit is contained in:
UnknownShadow200 2021-07-20 17:27:23 +10:00
parent 341df3498a
commit f7a53b081f
5 changed files with 85 additions and 37 deletions

View File

@ -41,7 +41,6 @@ namespace MCGalaxy.Gui {
Type: IndexOutOfRangeException Type: IndexOutOfRangeException
Source: System.Windows.Forms Source: System.Windows.Forms
Message: Index was outside the bounds of the array. Message: Index was outside the bounds of the array.
Target: UpdatePropertiesViewTabVisibility
Trace: at System.Windows.Forms.PropertyGrid.UpdatePropertiesViewTabVisibility () Trace: at System.Windows.Forms.PropertyGrid.UpdatePropertiesViewTabVisibility ()
at System.Windows.Forms.PropertyGrid.ShowEventsButton (System.Boolean value) at System.Windows.Forms.PropertyGrid.ShowEventsButton (System.Boolean value)
at System.Windows.Forms.PropertyGrid.set_SelectedObjects (System.Object[] value) at System.Windows.Forms.PropertyGrid.set_SelectedObjects (System.Object[] value)
@ -58,7 +57,6 @@ Trace: at System.Windows.Forms.PropertyGrid.UpdatePropertiesViewTabVisibility
Type: IndexOutOfRangeException Type: IndexOutOfRangeException
Source: System.Windows.Forms Source: System.Windows.Forms
Message: Index was outside the bounds of the array. Message: Index was outside the bounds of the array.
Target: RefreshProperties
Trace: at System.Windows.Forms.PropertyGrid.RefreshProperties (System.Boolean clearCached) 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 (System.Boolean clearCached)
at System.Windows.Forms.PropertyGrid.Refresh () at System.Windows.Forms.PropertyGrid.Refresh ()

View File

@ -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)");
}
}
}

View File

@ -25,7 +25,7 @@ namespace MCGalaxy.Commands.Building {
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } } public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
public override bool SuperUseable { get { return false; } } public override bool SuperUseable { get { return false; } }
public override CommandAlias[] Aliases { 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) { public override void Use(Player p, string message, CommandData data) {
@ -38,38 +38,26 @@ namespace MCGalaxy.Commands.Building {
string opt = message.ToLower(); string opt = message.ToLower();
BlockDefinition[] defs = p.level.CustomBlockDefs; BlockDefinition[] defs = p.level.CustomBlockDefs;
// Mirroring string[] args = opt.SplitSpaces();
if (opt == "mirrorx" || opt == "mirror x") { char axis = 'Y';
Flip.MirrorX(cState, defs); int angle = 90;
p.Message("Flipped copy across the X (east/west) axis."); if (!Handle(ref axis, ref angle, args[0])) { Help(p); return; }
} else if (opt == "mirrory" || opt == "mirror y" || opt == "u") { if (args.Length > 1 && !Handle(ref axis, ref angle, args[1])) { Help(p); return; }
Flip.MirrorY(cState, defs);
p.Message("Flipped copy across the Y (vertical) axis."); CopyState newState = cState;
} else if (opt == "mirrorz" || opt == "mirror z" || opt == "m") { if (angle == 0) {
Flip.MirrorZ(cState, defs); } else if (axis == 'X') {
p.Message("Flipped copy across the Z (north/south) axis."); newState = Flip.RotateX(cState, angle, defs);
} else { } else if (axis == 'Y') {
string[] args = opt.SplitSpaces(); newState = Flip.RotateY(cState, angle, defs);
char axis = 'Y'; } else if (axis == 'Z') {
int angle = 90; newState = Flip.RotateZ(cState, angle, defs);
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.CopySource = cState.CopySource;
newState.CopyTime = cState.CopyTime; newState.CopyTime = cState.CopyTime;
p.CurrentCopy = newState; p.CurrentCopy = newState;
p.Message("Rotated copy {0} degrees around the {1} axis", angle, axis); p.Message("Rotated copy {0} degrees around the {1} axis", angle, axis);
}
} }
bool Handle(ref char axis, ref int angle, string arg) { bool Handle(ref char axis, ref int angle, string arg) {
@ -87,8 +75,6 @@ namespace MCGalaxy.Commands.Building {
} }
public override void Help(Player p) { 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("&T/Spin X/Y/Z 90/180/270");
p.Message("&HRotates the copied object around that axis by the given angle. " + p.Message("&HRotates the copied object around that axis by the given angle. " +
"If no angle is given, 90 degrees is used."); "If no angle is given, 90 degrees is used.");

View File

@ -304,7 +304,7 @@ namespace MCGalaxy.Games {
Player target = PlayerInfo.FindMatches(p, name); Player target = PlayerInfo.FindMatches(p, name);
if (target == null) return false; if (target == null) return false;
p.Message("{0} was queued.", p.FormatNick(target)); p.Message("{0} &Swas queued.", p.FormatNick(target));
QueuedZombie = target.name; QueuedZombie = target.name;
if (Map != null) Map.Message(target.ColoredName + " &Swas queued as the next zombie."); if (Map != null) Map.Message(target.ColoredName + " &Swas queued as the next zombie.");

View File

@ -137,6 +137,7 @@
<Compile Include="Commands\building\CmdMaze.cs" /> <Compile Include="Commands\building\CmdMaze.cs" />
<Compile Include="Commands\building\CmdMeasure.cs" /> <Compile Include="Commands\building\CmdMeasure.cs" />
<Compile Include="Commands\building\CmdMessageBlock.cs" /> <Compile Include="Commands\building\CmdMessageBlock.cs" />
<Compile Include="Commands\building\CmdMirror.cs" />
<Compile Include="Commands\building\CmdMode.cs" /> <Compile Include="Commands\building\CmdMode.cs" />
<Compile Include="Commands\building\CmdOutline.cs" /> <Compile Include="Commands\building\CmdOutline.cs" />
<Compile Include="Commands\building\CmdPaint.cs" /> <Compile Include="Commands\building\CmdPaint.cs" />