From b34ddaf4edc1d672b6ce5dff39c754ae53d968bf Mon Sep 17 00:00:00 2001 From: lperniciaro Date: Wed, 27 Nov 2024 23:20:29 -0800 Subject: [PATCH 1/2] Added reference size change function --- TTMouseclickSimulator/Core/Toontown/MouseHelpers.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/TTMouseclickSimulator/Core/Toontown/MouseHelpers.cs b/TTMouseclickSimulator/Core/Toontown/MouseHelpers.cs index e5772b6..7c6ad62 100644 --- a/TTMouseclickSimulator/Core/Toontown/MouseHelpers.cs +++ b/TTMouseclickSimulator/Core/Toontown/MouseHelpers.cs @@ -4,7 +4,18 @@ namespace TTMouseClickSimulator.Core.Toontown.Actions; public static class MouseHelpers { - public static readonly Size ReferenceWindowSize = new(1600, 1151); + public static Size ReferenceWindowSize = new(1600, 1151); + + public static void ChangeReferenceSize(Size newSize) + { + ReferenceWindowSize = newSize; + } + + public static void SetDefaultReferenceSize() + { + Size newSize = new(1600, 1151); + ReferenceWindowSize = newSize; + } public static void DoSimpleMouseClick( IInteractionProvider provider, From 0df3718b9f7a01992ecf62a28f9138a8f8eb978a Mon Sep 17 00:00:00 2001 From: lperniciaro Date: Wed, 27 Nov 2024 23:21:20 -0800 Subject: [PATCH 2/2] Add water training --- .../Actions/Gardening/PlantTreeAction.cs | 58 +++++++++++++++++++ .../Actions/Gardening/RemovePlantAction.cs | 56 ++++++++++++++++++ .../Actions/Gardening/RemoveTreeAction.cs | 55 ++++++++++++++++++ .../Project/XmlProjectDeserializer.cs | 3 + .../Gardening/Water Training Plant.xml | 30 ++++++++++ .../Gardening/Water Training Tree.xml | 30 ++++++++++ 6 files changed, 232 insertions(+) create mode 100644 TTMouseclickSimulator/Core/Toontown/Actions/Gardening/PlantTreeAction.cs create mode 100644 TTMouseclickSimulator/Core/Toontown/Actions/Gardening/RemovePlantAction.cs create mode 100644 TTMouseclickSimulator/Core/Toontown/Actions/Gardening/RemoveTreeAction.cs create mode 100644 TTMouseclickSimulator/SampleProjects/ToontownRewritten/Gardening/Water Training Plant.xml create mode 100644 TTMouseclickSimulator/SampleProjects/ToontownRewritten/Gardening/Water Training Tree.xml diff --git a/TTMouseclickSimulator/Core/Toontown/Actions/Gardening/PlantTreeAction.cs b/TTMouseclickSimulator/Core/Toontown/Actions/Gardening/PlantTreeAction.cs new file mode 100644 index 0000000..bb0ba18 --- /dev/null +++ b/TTMouseclickSimulator/Core/Toontown/Actions/Gardening/PlantTreeAction.cs @@ -0,0 +1,58 @@ +using System; +using System.Text; + +using TTMouseClickSimulator.Core.Actions; +using TTMouseClickSimulator.Core.Environment; + +namespace TTMouseClickSimulator.Core.Toontown.Actions.Gardening; + +/// +/// An action which plants a cupcake tree. +/// +public class PlantTreeAction : AbstractAction +{ + + + public PlantTreeAction() + { + + } + + public override SimulatorCapabilities RequiredCapabilities + { + get => SimulatorCapabilities.MouseInput; + } + + public override sealed void Run(IInteractionProvider provider) + { + provider.ThrowIfNotToontownRewritten(nameof(PlantTreeAction)); + + // Click on the "Plant Flower" button. + MouseHelpers.DoSimpleMouseClick( + provider, + new Coordinates(76, 264), + HorizontalScaleAlignment.Left); + + provider.Wait(200); + + // Click on the cupcake + // Reference size is the Client window coordinates on Auto Hot Key Window Spy + Size newSize = new(1920, 1003); + MouseHelpers.ChangeReferenceSize(newSize); + MouseHelpers.DoSimpleMouseClick( + provider, + new Coordinates(640, 550), + HorizontalScaleAlignment.NoAspectRatio); + // Reset to default scale so other actions still work + MouseHelpers.SetDefaultReferenceSize(); + + provider.Wait(200); + + } + + public override string ToString() + { + + return $"Planting cupcake tree"; + } +} diff --git a/TTMouseclickSimulator/Core/Toontown/Actions/Gardening/RemovePlantAction.cs b/TTMouseclickSimulator/Core/Toontown/Actions/Gardening/RemovePlantAction.cs new file mode 100644 index 0000000..a96af1f --- /dev/null +++ b/TTMouseclickSimulator/Core/Toontown/Actions/Gardening/RemovePlantAction.cs @@ -0,0 +1,56 @@ +using System; +using System.Text; + +using TTMouseClickSimulator.Core.Actions; +using TTMouseClickSimulator.Core.Environment; + +namespace TTMouseClickSimulator.Core.Toontown.Actions.Gardening; + +/// +/// An action which removes a flower and confirms. +/// +public class RemovePlantAction : AbstractAction +{ + + public RemovePlantAction() + { + + } + + public override SimulatorCapabilities RequiredCapabilities + { + get => SimulatorCapabilities.MouseInput; + } + + public override sealed void Run(IInteractionProvider provider) + { + provider.ThrowIfNotToontownRewritten(nameof(RemovePlantAction)); + + // Click on the "Remove Flower" button. + MouseHelpers.DoSimpleMouseClick( + provider, + new Coordinates(76, 264), + HorizontalScaleAlignment.Left); + + provider.Wait(200); + + // Click yes + Size newSize = new(1920, 1003); + MouseHelpers.ChangeReferenceSize(newSize); + MouseHelpers.DoSimpleMouseClick( + provider, + new Coordinates(900, 680), + HorizontalScaleAlignment.NoAspectRatio); + + + MouseHelpers.SetDefaultReferenceSize(); + + provider.Wait(200); + + } + + public override string ToString() + { + return $"Removing Flower"; + } +} diff --git a/TTMouseclickSimulator/Core/Toontown/Actions/Gardening/RemoveTreeAction.cs b/TTMouseclickSimulator/Core/Toontown/Actions/Gardening/RemoveTreeAction.cs new file mode 100644 index 0000000..3f56fa2 --- /dev/null +++ b/TTMouseclickSimulator/Core/Toontown/Actions/Gardening/RemoveTreeAction.cs @@ -0,0 +1,55 @@ +using System; +using System.Text; + +using TTMouseClickSimulator.Core.Actions; +using TTMouseClickSimulator.Core.Environment; + +namespace TTMouseClickSimulator.Core.Toontown.Actions.Gardening; + +/// +/// An action which plants a flower. +/// +public class RemoveTreeAction : AbstractAction +{ + + public RemoveTreeAction() + { + + } + + public override SimulatorCapabilities RequiredCapabilities + { + get => SimulatorCapabilities.MouseInput; + } + + public override sealed void Run(IInteractionProvider provider) + { + provider.ThrowIfNotToontownRewritten(nameof(RemoveTreeAction)); + + // Click on the "Remove Flower" button. + MouseHelpers.DoSimpleMouseClick( + provider, + new Coordinates(76, 264), + HorizontalScaleAlignment.Left); + + provider.Wait(200); + + // Click yes + Size newSize = new(1920, 1003); + MouseHelpers.ChangeReferenceSize(newSize); + MouseHelpers.DoSimpleMouseClick( + provider, + new Coordinates(900, 630), + HorizontalScaleAlignment.NoAspectRatio); + + MouseHelpers.SetDefaultReferenceSize(); + + provider.Wait(200); + + } + + public override string ToString() + { + return $"Removing Tree"; + } +} diff --git a/TTMouseclickSimulator/Project/XmlProjectDeserializer.cs b/TTMouseclickSimulator/Project/XmlProjectDeserializer.cs index 68e7364..c91014c 100644 --- a/TTMouseclickSimulator/Project/XmlProjectDeserializer.cs +++ b/TTMouseclickSimulator/Project/XmlProjectDeserializer.cs @@ -45,6 +45,9 @@ static XmlProjectDeserializer() actionTypes.Add("DoodlePanel", typeof(DoodlePanelAction)); actionTypes.Add("PlantFlower", typeof(PlantFlowerAction)); + actionTypes.Add("PlantTree", typeof(PlantTreeAction)); + actionTypes.Add("RemoveTree", typeof(RemoveTreeAction)); + actionTypes.Add("RemovePlant", typeof(RemovePlantAction)); actionTypes.Add("Water", typeof(WaterAction)); actionTypes.Add("ConfirmFlowerPlantedDialog", typeof(ConfirmFlowerPlantedDialogAction)); diff --git a/TTMouseclickSimulator/SampleProjects/ToontownRewritten/Gardening/Water Training Plant.xml b/TTMouseclickSimulator/SampleProjects/ToontownRewritten/Gardening/Water Training Plant.xml new file mode 100644 index 0000000..8929034 --- /dev/null +++ b/TTMouseclickSimulator/SampleProjects/ToontownRewritten/Gardening/Water Training Plant.xml @@ -0,0 +1,30 @@ + + + Water Training - Plant + +This project replants and waters a plant to train the watering can. Stand in front of an empty pot. + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TTMouseclickSimulator/SampleProjects/ToontownRewritten/Gardening/Water Training Tree.xml b/TTMouseclickSimulator/SampleProjects/ToontownRewritten/Gardening/Water Training Tree.xml new file mode 100644 index 0000000..c2824e6 --- /dev/null +++ b/TTMouseclickSimulator/SampleProjects/ToontownRewritten/Gardening/Water Training Tree.xml @@ -0,0 +1,30 @@ + + + Gardening – 1 Jellybean Combinations + +This project plants a cupcake tree and replants to train the watering can. Stand in front of an empty pot. + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file