From 929dccb75a1405737975d76648e015a3e7c00177 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 7 Oct 2017 23:07:10 -0400 Subject: reorganise repo structure --- src/SMAPI/StardewModdingAPI.csproj | 277 +++++++++++++++++++++++++++++++++++++ 1 file changed, 277 insertions(+) create mode 100644 src/SMAPI/StardewModdingAPI.csproj (limited to 'src/SMAPI/StardewModdingAPI.csproj') diff --git a/src/SMAPI/StardewModdingAPI.csproj b/src/SMAPI/StardewModdingAPI.csproj new file mode 100644 index 00000000..c6ff75d1 --- /dev/null +++ b/src/SMAPI/StardewModdingAPI.csproj @@ -0,0 +1,277 @@ + + + + + Debug + x86 + {F1A573B0-F436-472C-AE29-0B91EA6B9F8F} + Exe + Properties + StardewModdingAPI + StardewModdingAPI + v4.5 + 512 + false + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true + + + x86 + false + DEBUG;TRACE + true + false + $(SolutionDir)\..\bin\Debug\SMAPI + $(SolutionDir)\..\bin\Debug\SMAPI\StardewModdingAPI.xml + true + + + x86 + false + $(SolutionDir)\..\bin\Release\SMAPI + $(SolutionDir)\..\bin\Debug\SMAPI\StardewModdingAPI.xml + TRACE + true + true + pdbonly + true + + + icon.ico + + + + ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll + True + + + ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Mdb.dll + True + + + ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Pdb.dll + True + + + ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll + True + + + + + + + True + + + True + + + + + + + + + + + Properties\GlobalAssemblyInfo.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Designer + + + Designer + + + Always + + + Always + + + + + + Always + + + + + False + Microsoft .NET Framework 4.5 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + + + {10db0676-9fc1-4771-a2c8-e2519f091e49} + StardewModdingAPI.AssemblyRewriters + + + + + \ No newline at end of file -- cgit From b7fb188513a844afed66b9b292ecfddb58528a42 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 7 Oct 2017 23:57:47 -0400 Subject: rename shared project for broader use --- src/SMAPI.Common/Models/ModInfoModel.cs | 48 ++++++++++++++++++++++ src/SMAPI.Common/Models/ModSeachModel.cs | 30 ++++++++++++++ .../StardewModdingAPI.Common.projitems | 18 ++++++++ src/SMAPI.Common/StardewModdingAPI.Common.shproj | 13 ++++++ src/SMAPI.Models/ModInfoModel.cs | 48 ---------------------- src/SMAPI.Models/ModSeachModel.cs | 30 -------------- .../StardewModdingAPI.Models.projitems | 15 ------- src/SMAPI.Models/StardewModdingAPI.Models.shproj | 13 ------ src/SMAPI.Web/Controllers/ModsController.cs | 2 +- .../Framework/ModRepositories/BaseRepository.cs | 2 +- .../ModRepositories/ChucklefishRepository.cs | 2 +- .../Framework/ModRepositories/GitHubRepository.cs | 2 +- .../Framework/ModRepositories/IModRepository.cs | 2 +- .../Framework/ModRepositories/NexusRepository.cs | 2 +- src/SMAPI.Web/StardewModdingAPI.Web.csproj | 2 +- src/SMAPI.sln | 6 +-- src/SMAPI/Framework/WebApiClient.cs | 2 +- src/SMAPI/Program.cs | 2 +- src/SMAPI/StardewModdingAPI.csproj | 2 +- 19 files changed, 122 insertions(+), 119 deletions(-) create mode 100644 src/SMAPI.Common/Models/ModInfoModel.cs create mode 100644 src/SMAPI.Common/Models/ModSeachModel.cs create mode 100644 src/SMAPI.Common/StardewModdingAPI.Common.projitems create mode 100644 src/SMAPI.Common/StardewModdingAPI.Common.shproj delete mode 100644 src/SMAPI.Models/ModInfoModel.cs delete mode 100644 src/SMAPI.Models/ModSeachModel.cs delete mode 100644 src/SMAPI.Models/StardewModdingAPI.Models.projitems delete mode 100644 src/SMAPI.Models/StardewModdingAPI.Models.shproj (limited to 'src/SMAPI/StardewModdingAPI.csproj') diff --git a/src/SMAPI.Common/Models/ModInfoModel.cs b/src/SMAPI.Common/Models/ModInfoModel.cs new file mode 100644 index 00000000..e071c0bb --- /dev/null +++ b/src/SMAPI.Common/Models/ModInfoModel.cs @@ -0,0 +1,48 @@ +using Newtonsoft.Json; + +namespace StardewModdingAPI.Common.Models +{ + /// Generic metadata about a mod. + internal class ModInfoModel + { + /********* + ** Accessors + *********/ + /// The mod name. + public string Name { get; } + + /// The mod's semantic version number. + public string Version { get; } + + /// The mod's web URL. + public string Url { get; } + + /// The error message indicating why the mod is invalid (if applicable). + public string Error { get; } + + + /********* + ** Public methods + *********/ + /// Construct a valid instance. + /// The mod name. + /// The mod's semantic version number. + /// The mod's web URL. + /// The error message indicating why the mod is invalid (if applicable). + [JsonConstructor] + public ModInfoModel(string name, string version, string url, string error = null) + { + this.Name = name; + this.Version = version; + this.Url = url; + this.Error = error; // mainly initialised here for the JSON deserialiser + } + + /// Construct an valid instance. + /// The error message indicating why the mod is invalid. + public ModInfoModel(string error) + { + this.Error = error; + } + } +} diff --git a/src/SMAPI.Common/Models/ModSeachModel.cs b/src/SMAPI.Common/Models/ModSeachModel.cs new file mode 100644 index 00000000..3f69f0ae --- /dev/null +++ b/src/SMAPI.Common/Models/ModSeachModel.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using System.Linq; + +namespace StardewModdingAPI.Common.Models +{ + /// Specifies mods whose update-check info to fetch. + internal class ModSearchModel + { + /********* + ** Accessors + *********/ + /// The namespaced mod keys to search. + public string[] ModKeys { get; set; } + + + /********* + ** Public methods + *********/ + /// Construct an empty instance. + /// This constructed is needed for JSON deserialisation. + public ModSearchModel() { } + + /// Construct an valid instance. + /// The namespaced mod keys to search. + public ModSearchModel(IEnumerable modKeys) + { + this.ModKeys = modKeys.ToArray(); + } + } +} diff --git a/src/SMAPI.Common/StardewModdingAPI.Common.projitems b/src/SMAPI.Common/StardewModdingAPI.Common.projitems new file mode 100644 index 00000000..b3296570 --- /dev/null +++ b/src/SMAPI.Common/StardewModdingAPI.Common.projitems @@ -0,0 +1,18 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 2aa02fb6-ff03-41cf-a215-2ee60ab4f5dc + + + StardewModdingAPI.Common + + + + + + + + + \ No newline at end of file diff --git a/src/SMAPI.Common/StardewModdingAPI.Common.shproj b/src/SMAPI.Common/StardewModdingAPI.Common.shproj new file mode 100644 index 00000000..0ef29144 --- /dev/null +++ b/src/SMAPI.Common/StardewModdingAPI.Common.shproj @@ -0,0 +1,13 @@ + + + + 2aa02fb6-ff03-41cf-a215-2ee60ab4f5dc + 14.0 + + + + + + + + diff --git a/src/SMAPI.Models/ModInfoModel.cs b/src/SMAPI.Models/ModInfoModel.cs deleted file mode 100644 index 44071230..00000000 --- a/src/SMAPI.Models/ModInfoModel.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Newtonsoft.Json; - -namespace StardewModdingAPI.Models -{ - /// Generic metadata about a mod. - internal class ModInfoModel - { - /********* - ** Accessors - *********/ - /// The mod name. - public string Name { get; } - - /// The mod's semantic version number. - public string Version { get; } - - /// The mod's web URL. - public string Url { get; } - - /// The error message indicating why the mod is invalid (if applicable). - public string Error { get; } - - - /********* - ** Public methods - *********/ - /// Construct a valid instance. - /// The mod name. - /// The mod's semantic version number. - /// The mod's web URL. - /// The error message indicating why the mod is invalid (if applicable). - [JsonConstructor] - public ModInfoModel(string name, string version, string url, string error = null) - { - this.Name = name; - this.Version = version; - this.Url = url; - this.Error = error; // mainly initialised here for the JSON deserialiser - } - - /// Construct an valid instance. - /// The error message indicating why the mod is invalid. - public ModInfoModel(string error) - { - this.Error = error; - } - } -} diff --git a/src/SMAPI.Models/ModSeachModel.cs b/src/SMAPI.Models/ModSeachModel.cs deleted file mode 100644 index 526fbaf3..00000000 --- a/src/SMAPI.Models/ModSeachModel.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace StardewModdingAPI.Models -{ - /// Specifies mods whose update-check info to fetch. - internal class ModSearchModel - { - /********* - ** Accessors - *********/ - /// The namespaced mod keys to search. - public string[] ModKeys { get; set; } - - - /********* - ** Public methods - *********/ - /// Construct an empty instance. - /// This constructed is needed for JSON deserialisation. - public ModSearchModel() { } - - /// Construct an valid instance. - /// The namespaced mod keys to search. - public ModSearchModel(IEnumerable modKeys) - { - this.ModKeys = modKeys.ToArray(); - } - } -} diff --git a/src/SMAPI.Models/StardewModdingAPI.Models.projitems b/src/SMAPI.Models/StardewModdingAPI.Models.projitems deleted file mode 100644 index e2cb29e1..00000000 --- a/src/SMAPI.Models/StardewModdingAPI.Models.projitems +++ /dev/null @@ -1,15 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - 2aa02fb6-ff03-41cf-a215-2ee60ab4f5dc - - - StardewModdingAPI.Models - - - - - - \ No newline at end of file diff --git a/src/SMAPI.Models/StardewModdingAPI.Models.shproj b/src/SMAPI.Models/StardewModdingAPI.Models.shproj deleted file mode 100644 index c80517af..00000000 --- a/src/SMAPI.Models/StardewModdingAPI.Models.shproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - 2aa02fb6-ff03-41cf-a215-2ee60ab4f5dc - 14.0 - - - - - - - - diff --git a/src/SMAPI.Web/Controllers/ModsController.cs b/src/SMAPI.Web/Controllers/ModsController.cs index 7dcfcf13..a671ddca 100644 --- a/src/SMAPI.Web/Controllers/ModsController.cs +++ b/src/SMAPI.Web/Controllers/ModsController.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Options; -using StardewModdingAPI.Models; +using StardewModdingAPI.Common.Models; using StardewModdingAPI.Web.Framework.ConfigModels; using StardewModdingAPI.Web.Framework.ModRepositories; diff --git a/src/SMAPI.Web/Framework/ModRepositories/BaseRepository.cs b/src/SMAPI.Web/Framework/ModRepositories/BaseRepository.cs index d98acd89..edb00454 100644 --- a/src/SMAPI.Web/Framework/ModRepositories/BaseRepository.cs +++ b/src/SMAPI.Web/Framework/ModRepositories/BaseRepository.cs @@ -1,6 +1,6 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; -using StardewModdingAPI.Models; +using StardewModdingAPI.Common.Models; namespace StardewModdingAPI.Web.Framework.ModRepositories { diff --git a/src/SMAPI.Web/Framework/ModRepositories/ChucklefishRepository.cs b/src/SMAPI.Web/Framework/ModRepositories/ChucklefishRepository.cs index ed7bd60b..06ec58ed 100644 --- a/src/SMAPI.Web/Framework/ModRepositories/ChucklefishRepository.cs +++ b/src/SMAPI.Web/Framework/ModRepositories/ChucklefishRepository.cs @@ -3,7 +3,7 @@ using System.Net; using System.Threading.Tasks; using HtmlAgilityPack; using Pathoschild.Http.Client; -using StardewModdingAPI.Models; +using StardewModdingAPI.Common.Models; namespace StardewModdingAPI.Web.Framework.ModRepositories { diff --git a/src/SMAPI.Web/Framework/ModRepositories/GitHubRepository.cs b/src/SMAPI.Web/Framework/ModRepositories/GitHubRepository.cs index 174fb79a..9d43adf0 100644 --- a/src/SMAPI.Web/Framework/ModRepositories/GitHubRepository.cs +++ b/src/SMAPI.Web/Framework/ModRepositories/GitHubRepository.cs @@ -3,7 +3,7 @@ using System.Net; using System.Threading.Tasks; using Newtonsoft.Json; using Pathoschild.Http.Client; -using StardewModdingAPI.Models; +using StardewModdingAPI.Common.Models; namespace StardewModdingAPI.Web.Framework.ModRepositories { diff --git a/src/SMAPI.Web/Framework/ModRepositories/IModRepository.cs b/src/SMAPI.Web/Framework/ModRepositories/IModRepository.cs index 98e4c957..4496400c 100644 --- a/src/SMAPI.Web/Framework/ModRepositories/IModRepository.cs +++ b/src/SMAPI.Web/Framework/ModRepositories/IModRepository.cs @@ -1,6 +1,6 @@ using System; using System.Threading.Tasks; -using StardewModdingAPI.Models; +using StardewModdingAPI.Common.Models; namespace StardewModdingAPI.Web.Framework.ModRepositories { diff --git a/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs b/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs index 71970bec..8a4bb0d8 100644 --- a/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs +++ b/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs @@ -2,7 +2,7 @@ using System; using System.Threading.Tasks; using Newtonsoft.Json; using Pathoschild.Http.Client; -using StardewModdingAPI.Models; +using StardewModdingAPI.Common.Models; namespace StardewModdingAPI.Web.Framework.ModRepositories { diff --git a/src/SMAPI.Web/StardewModdingAPI.Web.csproj b/src/SMAPI.Web/StardewModdingAPI.Web.csproj index 6b1d0687..ec1311f4 100644 --- a/src/SMAPI.Web/StardewModdingAPI.Web.csproj +++ b/src/SMAPI.Web/StardewModdingAPI.Web.csproj @@ -21,6 +21,6 @@ - + diff --git a/src/SMAPI.sln b/src/SMAPI.sln index fcb805a7..7941394d 100644 --- a/src/SMAPI.sln +++ b/src/SMAPI.sln @@ -29,7 +29,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StardewModdingAPI.Web", "SM EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Internal", "Internal", "{82D22ED7-A0A7-4D64-8E92-4B6A5E74ED11}" EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "StardewModdingAPI.Models", "SMAPI.Models\StardewModdingAPI.Models.shproj", "{2AA02FB6-FF03-41CF-A215-2EE60AB4F5DC}" +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "StardewModdingAPI.Common", "SMAPI.Common\StardewModdingAPI.Common.shproj", "{2AA02FB6-FF03-41CF-A215-2EE60AB4F5DC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{EB35A917-67B9-4EFA-8DFC-4FB49B3949BB}" ProjectSection(SolutionItems) = preProject @@ -47,8 +47,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{09CF91E5 EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution - SMAPI.Models\StardewModdingAPI.Models.projitems*{2aa02fb6-ff03-41cf-a215-2ee60ab4f5dc}*SharedItemsImports = 13 - SMAPI.Models\StardewModdingAPI.Models.projitems*{f1a573b0-f436-472c-ae29-0b91ea6b9f8f}*SharedItemsImports = 4 + SMAPI.Common\StardewModdingAPI.Common.projitems*{2aa02fb6-ff03-41cf-a215-2ee60ab4f5dc}*SharedItemsImports = 13 + SMAPI.Common\StardewModdingAPI.Common.projitems*{f1a573b0-f436-472c-ae29-0b91ea6b9f8f}*SharedItemsImports = 4 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/src/SMAPI/Framework/WebApiClient.cs b/src/SMAPI/Framework/WebApiClient.cs index f3c7de28..e78ac14b 100644 --- a/src/SMAPI/Framework/WebApiClient.cs +++ b/src/SMAPI/Framework/WebApiClient.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Net; using Newtonsoft.Json; -using StardewModdingAPI.Models; +using StardewModdingAPI.Common.Models; namespace StardewModdingAPI.Framework { diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index 7dfdc745..293c9da7 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -12,6 +12,7 @@ using System.Management; using System.Windows.Forms; #endif using Newtonsoft.Json; +using StardewModdingAPI.Common.Models; using StardewModdingAPI.Events; using StardewModdingAPI.Framework; using StardewModdingAPI.Framework.Exceptions; @@ -21,7 +22,6 @@ using StardewModdingAPI.Framework.ModHelpers; using StardewModdingAPI.Framework.ModLoading; using StardewModdingAPI.Framework.Reflection; using StardewModdingAPI.Framework.Serialisation; -using StardewModdingAPI.Models; using StardewValley; using Monitor = StardewModdingAPI.Framework.Monitor; using SObject = StardewValley.Object; diff --git a/src/SMAPI/StardewModdingAPI.csproj b/src/SMAPI/StardewModdingAPI.csproj index c6ff75d1..35a784cd 100644 --- a/src/SMAPI/StardewModdingAPI.csproj +++ b/src/SMAPI/StardewModdingAPI.csproj @@ -265,7 +265,7 @@ false - + {10db0676-9fc1-4771-a2c8-e2519f091e49} -- cgit From ff718d7993793ef4e93d49dc82f5ce3bb7de208e Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 13 Oct 2017 13:17:58 -0400 Subject: update Json.NET --- docs/release-notes.md | 1 + src/SMAPI.Tests/StardewModdingAPI.Tests.csproj | 4 ++-- src/SMAPI.Tests/packages.config | 2 +- src/SMAPI/StardewModdingAPI.csproj | 7 +++---- src/SMAPI/packages.config | 2 +- src/TrainerMod/TrainerMod.csproj | 7 +++---- src/TrainerMod/packages.config | 2 +- 7 files changed, 12 insertions(+), 13 deletions(-) (limited to 'src/SMAPI/StardewModdingAPI.csproj') diff --git a/docs/release-notes.md b/docs/release-notes.md index 64588744..39662784 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -24,6 +24,7 @@ For mod developers: * Added support for specifying the mod version as a string (like `"1.0-alpha"`) in `manifest.json`. * Added day of week to `SDate` instances. * Added `IEquatable` to `ISemanticVersion`. +* Updated Json.NET from 8.0.3 to 10.0.3. * Removed the TrainerMod's `save` and `load` commands. * Removed all deprecated code. * Removed support for mods with no `Name`, `Version`, or `UniqueID` in their manifest. diff --git a/src/SMAPI.Tests/StardewModdingAPI.Tests.csproj b/src/SMAPI.Tests/StardewModdingAPI.Tests.csproj index c3823cdb..c7a67306 100644 --- a/src/SMAPI.Tests/StardewModdingAPI.Tests.csproj +++ b/src/SMAPI.Tests/StardewModdingAPI.Tests.csproj @@ -36,8 +36,8 @@ ..\packages\Moq.4.7.142\lib\net45\Moq.dll - - ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll ..\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll diff --git a/src/SMAPI.Tests/packages.config b/src/SMAPI.Tests/packages.config index 97fb2801..7a91e807 100644 --- a/src/SMAPI.Tests/packages.config +++ b/src/SMAPI.Tests/packages.config @@ -2,6 +2,6 @@ - + \ No newline at end of file diff --git a/src/SMAPI/StardewModdingAPI.csproj b/src/SMAPI/StardewModdingAPI.csproj index 35a784cd..6bd803c3 100644 --- a/src/SMAPI/StardewModdingAPI.csproj +++ b/src/SMAPI/StardewModdingAPI.csproj @@ -1,4 +1,4 @@ - + @@ -65,9 +65,8 @@ ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Pdb.dll True - - ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll - True + + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll diff --git a/src/SMAPI/packages.config b/src/SMAPI/packages.config index e5fa3c3a..98d742c7 100644 --- a/src/SMAPI/packages.config +++ b/src/SMAPI/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/src/TrainerMod/TrainerMod.csproj b/src/TrainerMod/TrainerMod.csproj index 3182338c..cb5ec47e 100644 --- a/src/TrainerMod/TrainerMod.csproj +++ b/src/TrainerMod/TrainerMod.csproj @@ -1,4 +1,4 @@ - + @@ -36,9 +36,8 @@ x86 - - ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll - False + + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll diff --git a/src/TrainerMod/packages.config b/src/TrainerMod/packages.config index 75e68e71..ee51c237 100644 --- a/src/TrainerMod/packages.config +++ b/src/TrainerMod/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file -- cgit From 11b889992cd4d29099116e08e5560e040edd4506 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 13 Oct 2017 23:29:24 -0400 Subject: move SButtons into root --- src/SMAPI/SButton.cs | 675 +++++++++++++++++++++++++++++++++++++ src/SMAPI/StardewModdingAPI.csproj | 2 +- src/SMAPI/Utilities/SButton.cs | 675 ------------------------------------- 3 files changed, 676 insertions(+), 676 deletions(-) create mode 100644 src/SMAPI/SButton.cs delete mode 100644 src/SMAPI/Utilities/SButton.cs (limited to 'src/SMAPI/StardewModdingAPI.csproj') diff --git a/src/SMAPI/SButton.cs b/src/SMAPI/SButton.cs new file mode 100644 index 00000000..0ec799db --- /dev/null +++ b/src/SMAPI/SButton.cs @@ -0,0 +1,675 @@ +using System; +using Microsoft.Xna.Framework.Input; +using StardewValley; + +namespace StardewModdingAPI +{ + /// A unified button constant which includes all controller, keyboard, and mouse buttons. + /// Derived from , , and . + public enum SButton + { + /// No valid key. + None = 0, + + /********* + ** Mouse + *********/ + /// The left mouse button. + MouseLeft = 1000, + + /// The right mouse button. + MouseRight = 1001, + + /// The middle mouse button. + MouseMiddle = 1002, + + /// The first mouse XButton. + MouseX1 = 1003, + + /// The second mouse XButton. + MouseX2 = 1004, + + /********* + ** Controller + *********/ + /// The 'A' button on a controller. + ControllerA = SButtonExtensions.ControllerOffset + Buttons.A, + + /// The 'B' button on a controller. + ControllerB = SButtonExtensions.ControllerOffset + Buttons.B, + + /// The 'X' button on a controller. + ControllerX = SButtonExtensions.ControllerOffset + Buttons.X, + + /// The 'Y' button on a controller. + ControllerY = SButtonExtensions.ControllerOffset + Buttons.Y, + + /// The back button on a controller. + ControllerBack = SButtonExtensions.ControllerOffset + Buttons.Back, + + /// The start button on a controller. + ControllerStart = SButtonExtensions.ControllerOffset + Buttons.Start, + + /// The up button on the directional pad of a controller. + DPadUp = SButtonExtensions.ControllerOffset + Buttons.DPadUp, + + /// The down button on the directional pad of a controller. + DPadDown = SButtonExtensions.ControllerOffset + Buttons.DPadDown, + + /// The left button on the directional pad of a controller. + DPadLeft = SButtonExtensions.ControllerOffset + Buttons.DPadLeft, + + /// The right button on the directional pad of a controller. + DPadRight = SButtonExtensions.ControllerOffset + Buttons.DPadRight, + + /// The left bumper (shoulder) button on a controller. + LeftShoulder = SButtonExtensions.ControllerOffset + Buttons.LeftShoulder, + + /// The right bumper (shoulder) button on a controller. + RightShoulder = SButtonExtensions.ControllerOffset + Buttons.RightShoulder, + + /// The left trigger on a controller. + LeftTrigger = SButtonExtensions.ControllerOffset + Buttons.LeftTrigger, + + /// The right trigger on a controller. + RightTrigger = SButtonExtensions.ControllerOffset + Buttons.RightTrigger, + + /// The left analog stick on a controller (when pressed). + LeftStick = SButtonExtensions.ControllerOffset + Buttons.LeftStick, + + /// The right analog stick on a controller (when pressed). + RightStick = SButtonExtensions.ControllerOffset + Buttons.RightStick, + + /// The 'big button' on a controller. + BigButton = SButtonExtensions.ControllerOffset + Buttons.BigButton, + + /// The left analog stick on a controller (when pushed left). + LeftThumbstickLeft = SButtonExtensions.ControllerOffset + Buttons.LeftThumbstickLeft, + + /// The left analog stick on a controller (when pushed right). + LeftThumbstickRight = SButtonExtensions.ControllerOffset + Buttons.LeftThumbstickRight, + + /// The left analog stick on a controller (when pushed down). + LeftThumbstickDown = SButtonExtensions.ControllerOffset + Buttons.LeftThumbstickDown, + + /// The left analog stick on a controller (when pushed up). + LeftThumbstickUp = SButtonExtensions.ControllerOffset + Buttons.LeftThumbstickUp, + + /// The right analog stick on a controller (when pushed left). + RightThumbstickLeft = SButtonExtensions.ControllerOffset + Buttons.RightThumbstickLeft, + + /// The right analog stick on a controller (when pushed right). + RightThumbstickRight = SButtonExtensions.ControllerOffset + Buttons.RightThumbstickRight, + + /// The right analog stick on a controller (when pushed down). + RightThumbstickDown = SButtonExtensions.ControllerOffset + Buttons.RightThumbstickDown, + + /// The right analog stick on a controller (when pushed up). + RightThumbstickUp = SButtonExtensions.ControllerOffset + Buttons.RightThumbstickUp, + + /********* + ** Keyboard + *********/ + /// The A button on a keyboard. + A = Keys.A, + + /// The Add button on a keyboard. + Add = Keys.Add, + + /// The Applications button on a keyboard. + Apps = Keys.Apps, + + /// The Attn button on a keyboard. + Attn = Keys.Attn, + + /// The B button on a keyboard. + B = Keys.B, + + /// The Backspace button on a keyboard. + Back = Keys.Back, + + /// The Browser Back button on a keyboard in Windows 2000/XP. + BrowserBack = Keys.BrowserBack, + + /// The Browser Favorites button on a keyboard in Windows 2000/XP. + BrowserFavorites = Keys.BrowserFavorites, + + /// The Browser Favorites button on a keyboard in Windows 2000/XP. + BrowserForward = Keys.BrowserForward, + + /// The Browser Home button on a keyboard in Windows 2000/XP. + BrowserHome = Keys.BrowserHome, + + /// The Browser Refresh button on a keyboard in Windows 2000/XP. + BrowserRefresh = Keys.BrowserRefresh, + + /// The Browser Search button on a keyboard in Windows 2000/XP. + BrowserSearch = Keys.BrowserSearch, + + /// The Browser Stop button on a keyboard in Windows 2000/XP. + BrowserStop = Keys.BrowserStop, + + /// The C button on a keyboard. + C = Keys.C, + + /// The Caps Lock button on a keyboard. + CapsLock = Keys.CapsLock, + + /// The Green ChatPad button on a keyboard. + ChatPadGreen = Keys.ChatPadGreen, + + /// The Orange ChatPad button on a keyboard. + ChatPadOrange = Keys.ChatPadOrange, + + /// The CrSel button on a keyboard. + Crsel = Keys.Crsel, + + /// The D button on a keyboard. + D = Keys.D, + + /// A miscellaneous button on a keyboard; can vary by keyboard. + D0 = Keys.D0, + + /// A miscellaneous button on a keyboard; can vary by keyboard. + D1 = Keys.D1, + + /// A miscellaneous button on a keyboard; can vary by keyboard. + D2 = Keys.D2, + + /// A miscellaneous button on a keyboard; can vary by keyboard. + D3 = Keys.D3, + + /// A miscellaneous button on a keyboard; can vary by keyboard. + D4 = Keys.D4, + + /// A miscellaneous button on a keyboard; can vary by keyboard. + D5 = Keys.D5, + + /// A miscellaneous button on a keyboard; can vary by keyboard. + D6 = Keys.D6, + + /// A miscellaneous button on a keyboard; can vary by keyboard. + D7 = Keys.D7, + + /// A miscellaneous button on a keyboard; can vary by keyboard. + D8 = Keys.D8, + + /// A miscellaneous button on a keyboard; can vary by keyboard. + D9 = Keys.D9, + + /// The Decimal button on a keyboard. + Decimal = Keys.Decimal, + + /// The Delete button on a keyboard. + Delete = Keys.Delete, + + /// The Divide button on a keyboard. + Divide = Keys.Divide, + + /// The Down arrow button on a keyboard. + Down = Keys.Down, + + /// The E button on a keyboard. + E = Keys.E, + + /// The End button on a keyboard. + End = Keys.End, + + /// The Enter button on a keyboard. + Enter = Keys.Enter, + + /// The Erase EOF button on a keyboard. + EraseEof = Keys.EraseEof, + + /// The Escape button on a keyboard. + Escape = Keys.Escape, + + /// The Execute button on a keyboard. + Execute = Keys.Execute, + + /// The ExSel button on a keyboard. + Exsel = Keys.Exsel, + + /// The F button on a keyboard. + F = Keys.F, + + /// The F1 button on a keyboard. + F1 = Keys.F1, + + /// The F10 button on a keyboard. + F10 = Keys.F10, + + /// The F11 button on a keyboard. + F11 = Keys.F11, + + /// The F12 button on a keyboard. + F12 = Keys.F12, + + /// The F13 button on a keyboard. + F13 = Keys.F13, + + /// The F14 button on a keyboard. + F14 = Keys.F14, + + /// The F15 button on a keyboard. + F15 = Keys.F15, + + /// The F16 button on a keyboard. + F16 = Keys.F16, + + /// The F17 button on a keyboard. + F17 = Keys.F17, + + /// The F18 button on a keyboard. + F18 = Keys.F18, + + /// The F19 button on a keyboard. + F19 = Keys.F19, + + /// The F2 button on a keyboard. + F2 = Keys.F2, + + /// The F20 button on a keyboard. + F20 = Keys.F20, + + /// The F21 button on a keyboard. + F21 = Keys.F21, + + /// The F22 button on a keyboard. + F22 = Keys.F22, + + /// The F23 button on a keyboard. + F23 = Keys.F23, + + /// The F24 button on a keyboard. + F24 = Keys.F24, + + /// The F3 button on a keyboard. + F3 = Keys.F3, + + /// The F4 button on a keyboard. + F4 = Keys.F4, + + /// The F5 button on a keyboard. + F5 = Keys.F5, + + /// The F6 button on a keyboard. + F6 = Keys.F6, + + /// The F7 button on a keyboard. + F7 = Keys.F7, + + /// The F8 button on a keyboard. + F8 = Keys.F8, + + /// The F9 button on a keyboard. + F9 = Keys.F9, + + /// The G button on a keyboard. + G = Keys.G, + + /// The H button on a keyboard. + H = Keys.H, + + /// The Help button on a keyboard. + Help = Keys.Help, + + /// The Home button on a keyboard. + Home = Keys.Home, + + /// The I button on a keyboard. + I = Keys.I, + + /// The IME Convert button on a keyboard. + ImeConvert = Keys.ImeConvert, + + /// The IME NoConvert button on a keyboard. + ImeNoConvert = Keys.ImeNoConvert, + + /// The INS button on a keyboard. + Insert = Keys.Insert, + + /// The J button on a keyboard. + J = Keys.J, + + /// The K button on a keyboard. + K = Keys.K, + + /// The Kana button on a Japanese keyboard. + Kana = Keys.Kana, + + /// The Kanji button on a Japanese keyboard. + Kanji = Keys.Kanji, + + /// The L button on a keyboard. + L = Keys.L, + + /// The Start Applications 1 button on a keyboard in Windows 2000/XP. + LaunchApplication1 = Keys.LaunchApplication1, + + /// The Start Applications 2 button on a keyboard in Windows 2000/XP. + LaunchApplication2 = Keys.LaunchApplication2, + + /// The Start Mail button on a keyboard in Windows 2000/XP. + LaunchMail = Keys.LaunchMail, + + /// The Left arrow button on a keyboard. + Left = Keys.Left, + + /// The Left Alt button on a keyboard. + LeftAlt = Keys.LeftAlt, + + /// The Left Control button on a keyboard. + LeftControl = Keys.LeftControl, + + /// The Left Shift button on a keyboard. + LeftShift = Keys.LeftShift, + + /// The Left Windows button on a keyboard. + LeftWindows = Keys.LeftWindows, + + /// The M button on a keyboard. + M = Keys.M, + + /// The MediaNextTrack button on a keyboard in Windows 2000/XP. + MediaNextTrack = Keys.MediaNextTrack, + + /// The MediaPlayPause button on a keyboard in Windows 2000/XP. + MediaPlayPause = Keys.MediaPlayPause, + + /// The MediaPreviousTrack button on a keyboard in Windows 2000/XP. + MediaPreviousTrack = Keys.MediaPreviousTrack, + + /// The MediaStop button on a keyboard in Windows 2000/XP. + MediaStop = Keys.MediaStop, + + /// The Multiply button on a keyboard. + Multiply = Keys.Multiply, + + /// The N button on a keyboard. + N = Keys.N, + + /// The Num Lock button on a keyboard. + NumLock = Keys.NumLock, + + /// The Numeric keypad 0 button on a keyboard. + NumPad0 = Keys.NumPad0, + + /// The Numeric keypad 1 button on a keyboard. + NumPad1 = Keys.NumPad1, + + /// The Numeric keypad 2 button on a keyboard. + NumPad2 = Keys.NumPad2, + + /// The Numeric keypad 3 button on a keyboard. + NumPad3 = Keys.NumPad3, + + /// The Numeric keypad 4 button on a keyboard. + NumPad4 = Keys.NumPad4, + + /// The Numeric keypad 5 button on a keyboard. + NumPad5 = Keys.NumPad5, + + /// The Numeric keypad 6 button on a keyboard. + NumPad6 = Keys.NumPad6, + + /// The Numeric keypad 7 button on a keyboard. + NumPad7 = Keys.NumPad7, + + /// The Numeric keypad 8 button on a keyboard. + NumPad8 = Keys.NumPad8, + + /// The Numeric keypad 9 button on a keyboard. + NumPad9 = Keys.NumPad9, + + /// The O button on a keyboard. + O = Keys.O, + + /// A miscellaneous button on a keyboard; can vary by keyboard. + Oem8 = Keys.Oem8, + + /// The OEM Auto button on a keyboard. + OemAuto = Keys.OemAuto, + + /// The OEM Angle Bracket or Backslash button on the RT 102 keyboard in Windows 2000/XP. + OemBackslash = Keys.OemBackslash, + + /// The Clear button on a keyboard. + OemClear = Keys.OemClear, + + /// The OEM Close Bracket button on a US standard keyboard in Windows 2000/XP. + OemCloseBrackets = Keys.OemCloseBrackets, + + /// The ',' button on a keyboard in any country/region in Windows 2000/XP. + OemComma = Keys.OemComma, + + /// The OEM Copy button on a keyboard. + OemCopy = Keys.OemCopy, + + /// The OEM Enlarge Window button on a keyboard. + OemEnlW = Keys.OemEnlW, + + /// The '-' button on a keyboard in any country/region in Windows 2000/XP. + OemMinus = Keys.OemMinus, + + /// The OEM Open Bracket button on a US standard keyboard in Windows 2000/XP. + OemOpenBrackets = Keys.OemOpenBrackets, + + /// The '.' button on a keyboard in any country/region. + OemPeriod = Keys.OemPeriod, + + /// The OEM Pipe button on a US standard keyboard. + OemPipe = Keys.OemPipe, + + /// The '+' button on a keyboard in Windows 2000/XP. + OemPlus = Keys.OemPlus, + + /// The OEM Question Mark button on a US standard keyboard. + OemQuestion = Keys.OemQuestion, + + /// The OEM Single/Double Quote button on a US standard keyboard. + OemQuotes = Keys.OemQuotes, + + /// The OEM Semicolon button on a US standard keyboard. + OemSemicolon = Keys.OemSemicolon, + + /// The OEM Tilde button on a US standard keyboard. + OemTilde = Keys.OemTilde, + + /// The P button on a keyboard. + P = Keys.P, + + /// The PA1 button on a keyboard. + Pa1 = Keys.Pa1, + + /// The Page Down button on a keyboard. + PageDown = Keys.PageDown, + + /// The Page Up button on a keyboard. + PageUp = Keys.PageUp, + + /// The Pause button on a keyboard. + Pause = Keys.Pause, + + /// The Play button on a keyboard. + Play = Keys.Play, + + /// The Print button on a keyboard. + Print = Keys.Print, + + /// The Print Screen button on a keyboard. + PrintScreen = Keys.PrintScreen, + + /// The IME Process button on a keyboard in Windows 95/98/ME/NT 4.0/2000/XP. + ProcessKey = Keys.ProcessKey, + + /// The Q button on a keyboard. + Q = Keys.Q, + + /// The R button on a keyboard. + R = Keys.R, + + /// The Right Arrow button on a keyboard. + Right = Keys.Right, + + /// The Right Alt button on a keyboard. + RightAlt = Keys.RightAlt, + + /// The Right Control button on a keyboard. + RightControl = Keys.RightControl, + + /// The Right Shift button on a keyboard. + RightShift = Keys.RightShift, + + /// The Right Windows button on a keyboard. + RightWindows = Keys.RightWindows, + + /// The S button on a keyboard. + S = Keys.S, + + /// The Scroll Lock button on a keyboard. + Scroll = Keys.Scroll, + + /// The Select button on a keyboard. + Select = Keys.Select, + + /// The Select Media button on a keyboard in Windows 2000/XP. + SelectMedia = Keys.SelectMedia, + + /// The Separator button on a keyboard. + Separator = Keys.Separator, + + /// The Computer Sleep button on a keyboard. + Sleep = Keys.Sleep, + + /// The Space bar on a keyboard. + Space = Keys.Space, + + /// The Subtract button on a keyboard. + Subtract = Keys.Subtract, + + /// The T button on a keyboard. + T = Keys.T, + + /// The Tab button on a keyboard. + Tab = Keys.Tab, + + /// The U button on a keyboard. + U = Keys.U, + + /// The Up Arrow button on a keyboard. + Up = Keys.Up, + + /// The V button on a keyboard. + V = Keys.V, + + /// The Volume Down button on a keyboard in Windows 2000/XP. + VolumeDown = Keys.VolumeDown, + + /// The Volume Mute button on a keyboard in Windows 2000/XP. + VolumeMute = Keys.VolumeMute, + + /// The Volume Up button on a keyboard in Windows 2000/XP. + VolumeUp = Keys.VolumeUp, + + /// The W button on a keyboard. + W = Keys.W, + + /// The X button on a keyboard. + X = Keys.X, + + /// The Y button on a keyboard. + Y = Keys.Y, + + /// The Z button on a keyboard. + Z = Keys.Z, + + /// The Zoom button on a keyboard. + Zoom = Keys.Zoom + } + + /// Provides extension methods for . + public static class SButtonExtensions + { + /********* + ** Accessors + *********/ + /// The offset added to values when converting them to to avoid collisions with values. + internal const int ControllerOffset = 2000; + + + /********* + ** Public methods + *********/ + /// Get the equivalent for the given button. + /// The keyboard button to convert. + internal static SButton ToSButton(this Keys key) + { + return (SButton)key; + } + + /// Get the equivalent for the given button. + /// The controller button to convert. + internal static SButton ToSButton(this Buttons key) + { + return (SButton)(SButtonExtensions.ControllerOffset + key); + } + + /// Get the equivalent for the given button. + /// The button to convert. + /// The keyboard equivalent. + /// Returns whether the value was converted successfully. + public static bool TryGetKeyboard(this SButton input, out Keys key) + { + if (Enum.IsDefined(typeof(Keys), (int)input)) + { + key = (Keys)input; + return true; + } + + key = Keys.None; + return false; + } + + /// Get the equivalent for the given button. + /// The button to convert. + /// The controller equivalent. + /// Returns whether the value was converted successfully. + public static bool TryGetController(this SButton input, out Buttons button) + { + if (Enum.IsDefined(typeof(Buttons), (int)input - SButtonExtensions.ControllerOffset)) + { + button = (Buttons)(input - SButtonExtensions.ControllerOffset); + return true; + } + + button = 0; + return false; + } + + /// Get the equivalent for the given button. + /// The button to convert. + /// The Stardew Valley input button equivalent. + /// Returns whether the value was converted successfully. + public static bool TryGetStardewInput(this SButton input, out InputButton button) + { + // keyboard + if (input.TryGetKeyboard(out Keys key)) + { + button = new InputButton(key); + return true; + } + + // mouse + if (input == SButton.MouseLeft || input == SButton.MouseRight) + { + button = new InputButton(mouseLeft: input == SButton.MouseLeft); + return true; + } + + // not valid + button = default(InputButton); + return false; + } + } +} diff --git a/src/SMAPI/StardewModdingAPI.csproj b/src/SMAPI/StardewModdingAPI.csproj index 6bd803c3..b8d5990e 100644 --- a/src/SMAPI/StardewModdingAPI.csproj +++ b/src/SMAPI/StardewModdingAPI.csproj @@ -229,7 +229,7 @@ - + diff --git a/src/SMAPI/Utilities/SButton.cs b/src/SMAPI/Utilities/SButton.cs deleted file mode 100644 index fa5ae648..00000000 --- a/src/SMAPI/Utilities/SButton.cs +++ /dev/null @@ -1,675 +0,0 @@ -using System; -using Microsoft.Xna.Framework.Input; -using StardewValley; - -namespace StardewModdingAPI.Utilities -{ - /// A unified button constant which includes all controller, keyboard, and mouse buttons. - /// Derived from , , and . - public enum SButton - { - /// No valid key. - None = 0, - - /********* - ** Mouse - *********/ - /// The left mouse button. - MouseLeft = 1000, - - /// The right mouse button. - MouseRight = 1001, - - /// The middle mouse button. - MouseMiddle = 1002, - - /// The first mouse XButton. - MouseX1 = 1003, - - /// The second mouse XButton. - MouseX2 = 1004, - - /********* - ** Controller - *********/ - /// The 'A' button on a controller. - ControllerA = SButtonExtensions.ControllerOffset + Buttons.A, - - /// The 'B' button on a controller. - ControllerB = SButtonExtensions.ControllerOffset + Buttons.B, - - /// The 'X' button on a controller. - ControllerX = SButtonExtensions.ControllerOffset + Buttons.X, - - /// The 'Y' button on a controller. - ControllerY = SButtonExtensions.ControllerOffset + Buttons.Y, - - /// The back button on a controller. - ControllerBack = SButtonExtensions.ControllerOffset + Buttons.Back, - - /// The start button on a controller. - ControllerStart = SButtonExtensions.ControllerOffset + Buttons.Start, - - /// The up button on the directional pad of a controller. - DPadUp = SButtonExtensions.ControllerOffset + Buttons.DPadUp, - - /// The down button on the directional pad of a controller. - DPadDown = SButtonExtensions.ControllerOffset + Buttons.DPadDown, - - /// The left button on the directional pad of a controller. - DPadLeft = SButtonExtensions.ControllerOffset + Buttons.DPadLeft, - - /// The right button on the directional pad of a controller. - DPadRight = SButtonExtensions.ControllerOffset + Buttons.DPadRight, - - /// The left bumper (shoulder) button on a controller. - LeftShoulder = SButtonExtensions.ControllerOffset + Buttons.LeftShoulder, - - /// The right bumper (shoulder) button on a controller. - RightShoulder = SButtonExtensions.ControllerOffset + Buttons.RightShoulder, - - /// The left trigger on a controller. - LeftTrigger = SButtonExtensions.ControllerOffset + Buttons.LeftTrigger, - - /// The right trigger on a controller. - RightTrigger = SButtonExtensions.ControllerOffset + Buttons.RightTrigger, - - /// The left analog stick on a controller (when pressed). - LeftStick = SButtonExtensions.ControllerOffset + Buttons.LeftStick, - - /// The right analog stick on a controller (when pressed). - RightStick = SButtonExtensions.ControllerOffset + Buttons.RightStick, - - /// The 'big button' on a controller. - BigButton = SButtonExtensions.ControllerOffset + Buttons.BigButton, - - /// The left analog stick on a controller (when pushed left). - LeftThumbstickLeft = SButtonExtensions.ControllerOffset + Buttons.LeftThumbstickLeft, - - /// The left analog stick on a controller (when pushed right). - LeftThumbstickRight = SButtonExtensions.ControllerOffset + Buttons.LeftThumbstickRight, - - /// The left analog stick on a controller (when pushed down). - LeftThumbstickDown = SButtonExtensions.ControllerOffset + Buttons.LeftThumbstickDown, - - /// The left analog stick on a controller (when pushed up). - LeftThumbstickUp = SButtonExtensions.ControllerOffset + Buttons.LeftThumbstickUp, - - /// The right analog stick on a controller (when pushed left). - RightThumbstickLeft = SButtonExtensions.ControllerOffset + Buttons.RightThumbstickLeft, - - /// The right analog stick on a controller (when pushed right). - RightThumbstickRight = SButtonExtensions.ControllerOffset + Buttons.RightThumbstickRight, - - /// The right analog stick on a controller (when pushed down). - RightThumbstickDown = SButtonExtensions.ControllerOffset + Buttons.RightThumbstickDown, - - /// The right analog stick on a controller (when pushed up). - RightThumbstickUp = SButtonExtensions.ControllerOffset + Buttons.RightThumbstickUp, - - /********* - ** Keyboard - *********/ - /// The A button on a keyboard. - A = Keys.A, - - /// The Add button on a keyboard. - Add = Keys.Add, - - /// The Applications button on a keyboard. - Apps = Keys.Apps, - - /// The Attn button on a keyboard. - Attn = Keys.Attn, - - /// The B button on a keyboard. - B = Keys.B, - - /// The Backspace button on a keyboard. - Back = Keys.Back, - - /// The Browser Back button on a keyboard in Windows 2000/XP. - BrowserBack = Keys.BrowserBack, - - /// The Browser Favorites button on a keyboard in Windows 2000/XP. - BrowserFavorites = Keys.BrowserFavorites, - - /// The Browser Favorites button on a keyboard in Windows 2000/XP. - BrowserForward = Keys.BrowserForward, - - /// The Browser Home button on a keyboard in Windows 2000/XP. - BrowserHome = Keys.BrowserHome, - - /// The Browser Refresh button on a keyboard in Windows 2000/XP. - BrowserRefresh = Keys.BrowserRefresh, - - /// The Browser Search button on a keyboard in Windows 2000/XP. - BrowserSearch = Keys.BrowserSearch, - - /// The Browser Stop button on a keyboard in Windows 2000/XP. - BrowserStop = Keys.BrowserStop, - - /// The C button on a keyboard. - C = Keys.C, - - /// The Caps Lock button on a keyboard. - CapsLock = Keys.CapsLock, - - /// The Green ChatPad button on a keyboard. - ChatPadGreen = Keys.ChatPadGreen, - - /// The Orange ChatPad button on a keyboard. - ChatPadOrange = Keys.ChatPadOrange, - - /// The CrSel button on a keyboard. - Crsel = Keys.Crsel, - - /// The D button on a keyboard. - D = Keys.D, - - /// A miscellaneous button on a keyboard; can vary by keyboard. - D0 = Keys.D0, - - /// A miscellaneous button on a keyboard; can vary by keyboard. - D1 = Keys.D1, - - /// A miscellaneous button on a keyboard; can vary by keyboard. - D2 = Keys.D2, - - /// A miscellaneous button on a keyboard; can vary by keyboard. - D3 = Keys.D3, - - /// A miscellaneous button on a keyboard; can vary by keyboard. - D4 = Keys.D4, - - /// A miscellaneous button on a keyboard; can vary by keyboard. - D5 = Keys.D5, - - /// A miscellaneous button on a keyboard; can vary by keyboard. - D6 = Keys.D6, - - /// A miscellaneous button on a keyboard; can vary by keyboard. - D7 = Keys.D7, - - /// A miscellaneous button on a keyboard; can vary by keyboard. - D8 = Keys.D8, - - /// A miscellaneous button on a keyboard; can vary by keyboard. - D9 = Keys.D9, - - /// The Decimal button on a keyboard. - Decimal = Keys.Decimal, - - /// The Delete button on a keyboard. - Delete = Keys.Delete, - - /// The Divide button on a keyboard. - Divide = Keys.Divide, - - /// The Down arrow button on a keyboard. - Down = Keys.Down, - - /// The E button on a keyboard. - E = Keys.E, - - /// The End button on a keyboard. - End = Keys.End, - - /// The Enter button on a keyboard. - Enter = Keys.Enter, - - /// The Erase EOF button on a keyboard. - EraseEof = Keys.EraseEof, - - /// The Escape button on a keyboard. - Escape = Keys.Escape, - - /// The Execute button on a keyboard. - Execute = Keys.Execute, - - /// The ExSel button on a keyboard. - Exsel = Keys.Exsel, - - /// The F button on a keyboard. - F = Keys.F, - - /// The F1 button on a keyboard. - F1 = Keys.F1, - - /// The F10 button on a keyboard. - F10 = Keys.F10, - - /// The F11 button on a keyboard. - F11 = Keys.F11, - - /// The F12 button on a keyboard. - F12 = Keys.F12, - - /// The F13 button on a keyboard. - F13 = Keys.F13, - - /// The F14 button on a keyboard. - F14 = Keys.F14, - - /// The F15 button on a keyboard. - F15 = Keys.F15, - - /// The F16 button on a keyboard. - F16 = Keys.F16, - - /// The F17 button on a keyboard. - F17 = Keys.F17, - - /// The F18 button on a keyboard. - F18 = Keys.F18, - - /// The F19 button on a keyboard. - F19 = Keys.F19, - - /// The F2 button on a keyboard. - F2 = Keys.F2, - - /// The F20 button on a keyboard. - F20 = Keys.F20, - - /// The F21 button on a keyboard. - F21 = Keys.F21, - - /// The F22 button on a keyboard. - F22 = Keys.F22, - - /// The F23 button on a keyboard. - F23 = Keys.F23, - - /// The F24 button on a keyboard. - F24 = Keys.F24, - - /// The F3 button on a keyboard. - F3 = Keys.F3, - - /// The F4 button on a keyboard. - F4 = Keys.F4, - - /// The F5 button on a keyboard. - F5 = Keys.F5, - - /// The F6 button on a keyboard. - F6 = Keys.F6, - - /// The F7 button on a keyboard. - F7 = Keys.F7, - - /// The F8 button on a keyboard. - F8 = Keys.F8, - - /// The F9 button on a keyboard. - F9 = Keys.F9, - - /// The G button on a keyboard. - G = Keys.G, - - /// The H button on a keyboard. - H = Keys.H, - - /// The Help button on a keyboard. - Help = Keys.Help, - - /// The Home button on a keyboard. - Home = Keys.Home, - - /// The I button on a keyboard. - I = Keys.I, - - /// The IME Convert button on a keyboard. - ImeConvert = Keys.ImeConvert, - - /// The IME NoConvert button on a keyboard. - ImeNoConvert = Keys.ImeNoConvert, - - /// The INS button on a keyboard. - Insert = Keys.Insert, - - /// The J button on a keyboard. - J = Keys.J, - - /// The K button on a keyboard. - K = Keys.K, - - /// The Kana button on a Japanese keyboard. - Kana = Keys.Kana, - - /// The Kanji button on a Japanese keyboard. - Kanji = Keys.Kanji, - - /// The L button on a keyboard. - L = Keys.L, - - /// The Start Applications 1 button on a keyboard in Windows 2000/XP. - LaunchApplication1 = Keys.LaunchApplication1, - - /// The Start Applications 2 button on a keyboard in Windows 2000/XP. - LaunchApplication2 = Keys.LaunchApplication2, - - /// The Start Mail button on a keyboard in Windows 2000/XP. - LaunchMail = Keys.LaunchMail, - - /// The Left arrow button on a keyboard. - Left = Keys.Left, - - /// The Left Alt button on a keyboard. - LeftAlt = Keys.LeftAlt, - - /// The Left Control button on a keyboard. - LeftControl = Keys.LeftControl, - - /// The Left Shift button on a keyboard. - LeftShift = Keys.LeftShift, - - /// The Left Windows button on a keyboard. - LeftWindows = Keys.LeftWindows, - - /// The M button on a keyboard. - M = Keys.M, - - /// The MediaNextTrack button on a keyboard in Windows 2000/XP. - MediaNextTrack = Keys.MediaNextTrack, - - /// The MediaPlayPause button on a keyboard in Windows 2000/XP. - MediaPlayPause = Keys.MediaPlayPause, - - /// The MediaPreviousTrack button on a keyboard in Windows 2000/XP. - MediaPreviousTrack = Keys.MediaPreviousTrack, - - /// The MediaStop button on a keyboard in Windows 2000/XP. - MediaStop = Keys.MediaStop, - - /// The Multiply button on a keyboard. - Multiply = Keys.Multiply, - - /// The N button on a keyboard. - N = Keys.N, - - /// The Num Lock button on a keyboard. - NumLock = Keys.NumLock, - - /// The Numeric keypad 0 button on a keyboard. - NumPad0 = Keys.NumPad0, - - /// The Numeric keypad 1 button on a keyboard. - NumPad1 = Keys.NumPad1, - - /// The Numeric keypad 2 button on a keyboard. - NumPad2 = Keys.NumPad2, - - /// The Numeric keypad 3 button on a keyboard. - NumPad3 = Keys.NumPad3, - - /// The Numeric keypad 4 button on a keyboard. - NumPad4 = Keys.NumPad4, - - /// The Numeric keypad 5 button on a keyboard. - NumPad5 = Keys.NumPad5, - - /// The Numeric keypad 6 button on a keyboard. - NumPad6 = Keys.NumPad6, - - /// The Numeric keypad 7 button on a keyboard. - NumPad7 = Keys.NumPad7, - - /// The Numeric keypad 8 button on a keyboard. - NumPad8 = Keys.NumPad8, - - /// The Numeric keypad 9 button on a keyboard. - NumPad9 = Keys.NumPad9, - - /// The O button on a keyboard. - O = Keys.O, - - /// A miscellaneous button on a keyboard; can vary by keyboard. - Oem8 = Keys.Oem8, - - /// The OEM Auto button on a keyboard. - OemAuto = Keys.OemAuto, - - /// The OEM Angle Bracket or Backslash button on the RT 102 keyboard in Windows 2000/XP. - OemBackslash = Keys.OemBackslash, - - /// The Clear button on a keyboard. - OemClear = Keys.OemClear, - - /// The OEM Close Bracket button on a US standard keyboard in Windows 2000/XP. - OemCloseBrackets = Keys.OemCloseBrackets, - - /// The ',' button on a keyboard in any country/region in Windows 2000/XP. - OemComma = Keys.OemComma, - - /// The OEM Copy button on a keyboard. - OemCopy = Keys.OemCopy, - - /// The OEM Enlarge Window button on a keyboard. - OemEnlW = Keys.OemEnlW, - - /// The '-' button on a keyboard in any country/region in Windows 2000/XP. - OemMinus = Keys.OemMinus, - - /// The OEM Open Bracket button on a US standard keyboard in Windows 2000/XP. - OemOpenBrackets = Keys.OemOpenBrackets, - - /// The '.' button on a keyboard in any country/region. - OemPeriod = Keys.OemPeriod, - - /// The OEM Pipe button on a US standard keyboard. - OemPipe = Keys.OemPipe, - - /// The '+' button on a keyboard in Windows 2000/XP. - OemPlus = Keys.OemPlus, - - /// The OEM Question Mark button on a US standard keyboard. - OemQuestion = Keys.OemQuestion, - - /// The OEM Single/Double Quote button on a US standard keyboard. - OemQuotes = Keys.OemQuotes, - - /// The OEM Semicolon button on a US standard keyboard. - OemSemicolon = Keys.OemSemicolon, - - /// The OEM Tilde button on a US standard keyboard. - OemTilde = Keys.OemTilde, - - /// The P button on a keyboard. - P = Keys.P, - - /// The PA1 button on a keyboard. - Pa1 = Keys.Pa1, - - /// The Page Down button on a keyboard. - PageDown = Keys.PageDown, - - /// The Page Up button on a keyboard. - PageUp = Keys.PageUp, - - /// The Pause button on a keyboard. - Pause = Keys.Pause, - - /// The Play button on a keyboard. - Play = Keys.Play, - - /// The Print button on a keyboard. - Print = Keys.Print, - - /// The Print Screen button on a keyboard. - PrintScreen = Keys.PrintScreen, - - /// The IME Process button on a keyboard in Windows 95/98/ME/NT 4.0/2000/XP. - ProcessKey = Keys.ProcessKey, - - /// The Q button on a keyboard. - Q = Keys.Q, - - /// The R button on a keyboard. - R = Keys.R, - - /// The Right Arrow button on a keyboard. - Right = Keys.Right, - - /// The Right Alt button on a keyboard. - RightAlt = Keys.RightAlt, - - /// The Right Control button on a keyboard. - RightControl = Keys.RightControl, - - /// The Right Shift button on a keyboard. - RightShift = Keys.RightShift, - - /// The Right Windows button on a keyboard. - RightWindows = Keys.RightWindows, - - /// The S button on a keyboard. - S = Keys.S, - - /// The Scroll Lock button on a keyboard. - Scroll = Keys.Scroll, - - /// The Select button on a keyboard. - Select = Keys.Select, - - /// The Select Media button on a keyboard in Windows 2000/XP. - SelectMedia = Keys.SelectMedia, - - /// The Separator button on a keyboard. - Separator = Keys.Separator, - - /// The Computer Sleep button on a keyboard. - Sleep = Keys.Sleep, - - /// The Space bar on a keyboard. - Space = Keys.Space, - - /// The Subtract button on a keyboard. - Subtract = Keys.Subtract, - - /// The T button on a keyboard. - T = Keys.T, - - /// The Tab button on a keyboard. - Tab = Keys.Tab, - - /// The U button on a keyboard. - U = Keys.U, - - /// The Up Arrow button on a keyboard. - Up = Keys.Up, - - /// The V button on a keyboard. - V = Keys.V, - - /// The Volume Down button on a keyboard in Windows 2000/XP. - VolumeDown = Keys.VolumeDown, - - /// The Volume Mute button on a keyboard in Windows 2000/XP. - VolumeMute = Keys.VolumeMute, - - /// The Volume Up button on a keyboard in Windows 2000/XP. - VolumeUp = Keys.VolumeUp, - - /// The W button on a keyboard. - W = Keys.W, - - /// The X button on a keyboard. - X = Keys.X, - - /// The Y button on a keyboard. - Y = Keys.Y, - - /// The Z button on a keyboard. - Z = Keys.Z, - - /// The Zoom button on a keyboard. - Zoom = Keys.Zoom - } - - /// Provides extension methods for . - public static class SButtonExtensions - { - /********* - ** Accessors - *********/ - /// The offset added to values when converting them to to avoid collisions with values. - internal const int ControllerOffset = 2000; - - - /********* - ** Public methods - *********/ - /// Get the equivalent for the given button. - /// The keyboard button to convert. - internal static SButton ToSButton(this Keys key) - { - return (SButton)key; - } - - /// Get the equivalent for the given button. - /// The controller button to convert. - internal static SButton ToSButton(this Buttons key) - { - return (SButton)(SButtonExtensions.ControllerOffset + key); - } - - /// Get the equivalent for the given button. - /// The button to convert. - /// The keyboard equivalent. - /// Returns whether the value was converted successfully. - public static bool TryGetKeyboard(this SButton input, out Keys key) - { - if (Enum.IsDefined(typeof(Keys), (int)input)) - { - key = (Keys)input; - return true; - } - - key = Keys.None; - return false; - } - - /// Get the equivalent for the given button. - /// The button to convert. - /// The controller equivalent. - /// Returns whether the value was converted successfully. - public static bool TryGetController(this SButton input, out Buttons button) - { - if (Enum.IsDefined(typeof(Buttons), (int)input - SButtonExtensions.ControllerOffset)) - { - button = (Buttons)(input - SButtonExtensions.ControllerOffset); - return true; - } - - button = 0; - return false; - } - - /// Get the equivalent for the given button. - /// The button to convert. - /// The Stardew Valley input button equivalent. - /// Returns whether the value was converted successfully. - public static bool TryGetStardewInput(this SButton input, out InputButton button) - { - // keyboard - if (input.TryGetKeyboard(out Keys key)) - { - button = new InputButton(key); - return true; - } - - // mouse - if (input == SButton.MouseLeft || input == SButton.MouseRight) - { - button = new InputButton(mouseLeft: input == SButton.MouseLeft); - return true; - } - - // not valid - button = default(InputButton); - return false; - } - } -} -- cgit