diff --git a/MouseDrag/Hooks.cs b/MouseDrag/Hooks.cs index b6dca3d..549a575 100644 --- a/MouseDrag/Hooks.cs +++ b/MouseDrag/Hooks.cs @@ -130,6 +130,22 @@ static void RainWorldGameRawUpdateHook(On.RainWorldGame.orig_RawUpdate orig, Rai if (Options.duplicateOneKey?.Value != null && Input.GetKeyDown(Options.duplicateOneKey.Value)) Duplicate.DuplicateObject(); + if (Options.clipboardCtrlXCV?.Value == true) { + if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) { + if (Input.GetKeyDown(KeyCode.X)) + Clipboard.CutObject(); + if (Input.GetKeyDown(KeyCode.C)) + Clipboard.CopyObject(); + if (Input.GetKeyDown(KeyCode.V) && self.cameras[0]?.room != null) { + Clipboard.PasteObject( + self, + self.cameras[0].room, + self.cameras[0].room.ToWorldCoordinate((Vector2)Futile.mousePosition + self.cameras[0].pos) + ); + } + } + } + if (Options.tameOneKey?.Value != null && Input.GetKeyDown(Options.tameOneKey.Value)) Tame.TameCreature(self); diff --git a/MouseDrag/Options.cs b/MouseDrag/Options.cs index a9e206d..08ea440 100644 --- a/MouseDrag/Options.cs +++ b/MouseDrag/Options.cs @@ -24,7 +24,7 @@ public class Options : OptionInterface public static Configurable pauseAllCreaturesMenu, pauseAllObjectsMenu; public static Configurable killOneMenu, killAllCreaturesMenu, reviveOneMenu, reviveAllCreaturesMenu; public static Configurable duplicateOneMenu; - public static Configurable clipboardMenu; + public static Configurable clipboardMenu, clipboardCtrlXCV; public static Configurable tameOneMenu, tameAllCreaturesMenu, clearRelOneMenu, clearRelAllMenu; public static Configurable stunOneMenu, stunRoomMenu, unstunAllMenu, stunAllMenu; public static Configurable destroyOneMenu, destroyAllCreaturesMenu, destroyAllObjectsMenu; @@ -68,9 +68,9 @@ public Options() unpauseAllKey = config.Bind("unpauseAllKey", KeyCode.None, new ConfigurableInfo("KeyBind to unpause all objects/creatures, including individually paused creatures.", null, "", "Unpause all")); pauseAllCreaturesKey = config.Bind("pauseAllCreaturesKey", KeyCode.None, new ConfigurableInfo("KeyBind to pause/unpause all creatures except Player and SlugNPC, including creatures that still need to spawn.\nIndividually (un)paused creatures remain paused.", null, "", "Pause all creatures")); pauseAllObjectsKey = config.Bind("pauseAllObjectsKey", KeyCode.None, new ConfigurableInfo("KeyBind to pause/unpause all objects except creatures, including objects that still need to spawn.\nIndividually (un)paused objects remain paused.", null, "", "Pause all objects")); - killOneKey = config.Bind("killOneKey", KeyCode.None, new ConfigurableInfo("KeyBind to kill the creature which you're currently dragging.", null, "", "Kill")); + killOneKey = config.Bind("killOneKey", KeyCode.None, new ConfigurableInfo("KeyBind to kill the creature which you're currently dragging. Can also trigger objects like bombs.", null, "", "Kill")); killAllCreaturesKey = config.Bind("killAllCreaturesKey", KeyCode.None, new ConfigurableInfo("KeyBind to kill all creatures in current room except Player and SlugNPC.", null, "", "Kill creatures\nin room")); - reviveOneKey = config.Bind("reviveOneKey", KeyCode.None, new ConfigurableInfo("KeyBind to revive and heal the creature which you're currently dragging.", null, "", "Revive/heal")); + reviveOneKey = config.Bind("reviveOneKey", KeyCode.None, new ConfigurableInfo("KeyBind to revive and heal the creature which you're currently dragging. Can also reset objects like popcorn plants.", null, "", "Revive/heal")); reviveAllCreaturesKey = config.Bind("reviveAllCreaturesKey", KeyCode.None, new ConfigurableInfo("KeyBind to revive and heal all creatures in current room.", null, "", "Revive/heal\ncreatures\nin room")); duplicateOneKey = config.Bind("duplicateOneKey", KeyCode.None, new ConfigurableInfo("KeyBind to duplicate the object/creature which you're currently dragging. Hold button to repeat.", null, "", "Duplicate")); @@ -97,6 +97,7 @@ public Options() reviveAllCreaturesMenu = config.Bind("reviveAllCreaturesMenu", defaultValue: true, new ConfigurableInfo("Add action to menu.", null, "", "")); duplicateOneMenu = config.Bind("duplicateOneMenu", defaultValue: true, new ConfigurableInfo("Add action to menu.", null, "", "")); clipboardMenu = config.Bind("clipboardMenu", defaultValue: false, new ConfigurableInfo("Add action to menu.\nCut/paste AbstractPhysicalObjects with a clipboard (LIFO buffer). Clipboard is lost when game is closed.", null, "", "")); + clipboardCtrlXCV = config.Bind("clipboardCtrlXCV", defaultValue: false, new ConfigurableInfo("Using Control + X/C/V will cut, copy or paste the object/creature which you're currently dragging.", null, "", "Ctrl + X/C/V")); tameOneMenu = config.Bind("tameOneMenu", defaultValue: true, new ConfigurableInfo("Add action to menu.", null, "", "")); tameAllCreaturesMenu = config.Bind("tameAllCreaturesMenu", defaultValue: false, new ConfigurableInfo("Add action to menu.", null, "", "")); @@ -156,7 +157,7 @@ public override void Initialize() curTab++; x = 70; y = 600f; - AddKeyBinder(menuOpen, new Vector2(x, y -= 50f)); + AddKeyBinder(menuOpen, new Vector2(x, y -= 40f)); AddKeyBinder(pauseOneKey, new Vector2(x, y -= 50f)); AddIcon(new Vector2(x - 25f, y + 6f), "mousedragPause"); AddCheckbox(pauseOneMenu, new Vector2(x - 56f, y + 3f)); @@ -190,10 +191,11 @@ public override void Initialize() AddCheckbox(clipboardMenu, new Vector2(x - 56f, (y -= 50f) + 3f)); AddIcon(new Vector2(x - 25f, y + 6f), "mousedragCut"); AddIcon(new Vector2(x, y + 6f), "mousedragPaste"); + AddCheckbox(clipboardCtrlXCV, new Vector2(x + 25f, y + 3f)); x += 300; y = 600f; - AddKeyBinder(tameOneKey, new Vector2(x, y -= 50f)); + AddKeyBinder(tameOneKey, new Vector2(x, y -= 40f)); AddIcon(new Vector2(x - 25f, y + 6f), "mousedragHeart"); AddCheckbox(tameOneMenu, new Vector2(x - 56f, y + 3f)); AddKeyBinder(tameAllCreaturesKey, new Vector2(x, y -= 50f)); diff --git a/MouseDrag/Tools/Clipboard.cs b/MouseDrag/Tools/Clipboard.cs index 6655976..350d4c6 100644 --- a/MouseDrag/Tools/Clipboard.cs +++ b/MouseDrag/Tools/Clipboard.cs @@ -36,6 +36,13 @@ public static void CutObject(PhysicalObject obj = null) } + public static void CopyObject(PhysicalObject obj = null) + { + PhysicalObject dup = Duplicate.DuplicateObject(obj); + CutObject(dup); + } + + public static void PasteObject(RainWorldGame game, Room room, WorldCoordinate pos) { if (room?.world == null || room?.abstractRoom == null || game == null) diff --git a/MouseDrag/Tools/Duplicate.cs b/MouseDrag/Tools/Duplicate.cs index 99cdcf1..2a9dce1 100644 --- a/MouseDrag/Tools/Duplicate.cs +++ b/MouseDrag/Tools/Duplicate.cs @@ -8,19 +8,19 @@ namespace MouseDrag { public static class Duplicate { - public static void DuplicateObject(PhysicalObject obj = null) + public static PhysicalObject DuplicateObject(PhysicalObject obj = null) { if (obj == null) obj = Drag.dragChunk?.owner; if (obj?.room?.abstractRoom == null || obj.room.game == null) - return; + return null; WorldCoordinate coord = obj.room.GetWorldCoordinate(obj.firstChunk?.pos ?? new Vector2()); AbstractPhysicalObject oldApo = obj?.abstractPhysicalObject ?? (obj as Creature)?.abstractCreature; AbstractPhysicalObject newApo = null; if (oldApo == null) - return; + return null; if (obj is Creature) { EntityID id = Options.copyID?.Value == false ? obj.room.game.GetNewID() : oldApo.ID; @@ -50,7 +50,7 @@ public static void DuplicateObject(PhysicalObject obj = null) } catch (Exception ex) { Plugin.Logger.LogWarning("DuplicateObject exception: " + ex.ToString()); - return; + return null; } newApo.pos = coord; } @@ -59,6 +59,7 @@ public static void DuplicateObject(PhysicalObject obj = null) Plugin.Logger.LogDebug("DuplicateObject, AddEntity " + newApo.type + " at " + coord.SaveToString()); obj.room.abstractRoom.AddEntity(newApo); newApo.RealizeInRoom(); //actually places object/creature + return newApo.realizedObject; } diff --git a/MouseDrag/bin/mousedrag/plugins/MouseDrag.dll b/MouseDrag/bin/mousedrag/plugins/MouseDrag.dll index 299871d..73cd405 100644 Binary files a/MouseDrag/bin/mousedrag/plugins/MouseDrag.dll and b/MouseDrag/bin/mousedrag/plugins/MouseDrag.dll differ