diff --git a/MiraAPI.Example/Buttons/ExampleButton.cs b/MiraAPI.Example/Buttons/ExampleButton.cs index a7aa9fb..336896e 100644 --- a/MiraAPI.Example/Buttons/ExampleButton.cs +++ b/MiraAPI.Example/Buttons/ExampleButton.cs @@ -12,7 +12,7 @@ public class ExampleButton : CustomActionButton public override float Cooldown => 5f; public override float EffectDuration => 0f; public override int MaxUses => 5; - public override LoadableAsset Sprite { get; } = new LoadableResourceAsset("MiraAPI.Resources.ExampleButton.png"); + public override LoadableAsset Sprite { get; } = ExampleAssets.ExampleButton; protected override void OnClick() { diff --git a/MiraAPI.Example/ExampleAssets.cs b/MiraAPI.Example/ExampleAssets.cs new file mode 100644 index 0000000..b4abb94 --- /dev/null +++ b/MiraAPI.Example/ExampleAssets.cs @@ -0,0 +1,9 @@ +using MiraAPI.Utilities.Assets; + +namespace MiraAPI.Example; + +public static class ExampleAssets +{ + public static LoadableResourceAsset ExampleButton { get; } = new("MiraAPI.Example.Resources.ExampleButton.png"); + public static LoadableResourceAsset Banner { get; } = new("MiraAPI.Example.Resources.FortniteBanner.png"); +} \ No newline at end of file diff --git a/MiraAPI.Example/MiraAPI.Example.csproj b/MiraAPI.Example/MiraAPI.Example.csproj index bafb3f3..6c406ee 100644 --- a/MiraAPI.Example/MiraAPI.Example.csproj +++ b/MiraAPI.Example/MiraAPI.Example.csproj @@ -23,7 +23,12 @@ - + + + + + + diff --git a/MiraAPI.Example/Resources/ExampleButton.png b/MiraAPI.Example/Resources/ExampleButton.png new file mode 100644 index 0000000..2052930 Binary files /dev/null and b/MiraAPI.Example/Resources/ExampleButton.png differ diff --git a/MiraAPI/Resources/FortniteBanner.jpeg b/MiraAPI.Example/Resources/FortniteBanner.jpeg similarity index 100% rename from MiraAPI/Resources/FortniteBanner.jpeg rename to MiraAPI.Example/Resources/FortniteBanner.jpeg diff --git a/MiraAPI.Example/Roles/CustomRole.cs b/MiraAPI.Example/Roles/CustomRole.cs index 44dfbe8..4e3c9a4 100644 --- a/MiraAPI.Example/Roles/CustomRole.cs +++ b/MiraAPI.Example/Roles/CustomRole.cs @@ -12,6 +12,6 @@ public class CustomRole : ImpostorRole, ICustomRole public string RoleDescription => RoleLongDescription; public Color RoleColor => Palette.Orange; public ModdedRoleTeams Team => ModdedRoleTeams.Impostor; - public LoadableAsset OptionsScreenshot => MiraAssets.Banner; + public LoadableAsset OptionsScreenshot => ExampleAssets.Banner; } \ No newline at end of file diff --git a/MiraAPI.Example/Roles/CustomRole2.cs b/MiraAPI.Example/Roles/CustomRole2.cs index b5bbe48..019c891 100644 --- a/MiraAPI.Example/Roles/CustomRole2.cs +++ b/MiraAPI.Example/Roles/CustomRole2.cs @@ -12,6 +12,6 @@ public class CustomRole2 : CrewmateRole, ICustomRole public string RoleDescription => RoleLongDescription; public Color RoleColor => Palette.AcceptedGreen; public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate; - public LoadableAsset OptionsScreenshot => MiraAssets.Banner; + public LoadableAsset OptionsScreenshot => ExampleAssets.Banner; } \ No newline at end of file diff --git a/MiraAPI.Example/Roles/CustomRole3.cs b/MiraAPI.Example/Roles/CustomRole3.cs index a97f9df..111aa83 100644 --- a/MiraAPI.Example/Roles/CustomRole3.cs +++ b/MiraAPI.Example/Roles/CustomRole3.cs @@ -12,6 +12,6 @@ public class CustomRole3 : CrewmateRole, ICustomRole public string RoleDescription => RoleLongDescription; public Color RoleColor => Palette.Brown; public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate; - public LoadableAsset OptionsScreenshot => MiraAssets.Banner; + public LoadableAsset OptionsScreenshot => ExampleAssets.Banner; } \ No newline at end of file diff --git a/MiraAPI/MiraAPI.csproj b/MiraAPI/MiraAPI.csproj index e4dad34..fbc3e66 100644 --- a/MiraAPI/MiraAPI.csproj +++ b/MiraAPI/MiraAPI.csproj @@ -13,10 +13,8 @@ - - diff --git a/MiraAPI/Resources/ExampleButton.png b/MiraAPI/Resources/ExampleButton.png deleted file mode 100644 index c1680cc..0000000 Binary files a/MiraAPI/Resources/ExampleButton.png and /dev/null differ diff --git a/MiraAPI/Utilities/Assets/MiraAssets.cs b/MiraAPI/Utilities/Assets/MiraAssets.cs index fa6ad54..0ed16b0 100644 --- a/MiraAPI/Utilities/Assets/MiraAssets.cs +++ b/MiraAPI/Utilities/Assets/MiraAssets.cs @@ -7,5 +7,4 @@ public static class MiraAssets public static readonly LoadableResourceAsset NextButton = new("MiraAPI.Resources.NextButton.png"); public static readonly LoadableResourceAsset NextButtonActive = new("MiraAPI.Resources.NextButtonActive.png"); public static readonly LoadableResourceAsset Cog = new("MiraAPI.Resources.Cog.png"); - public static readonly LoadableResourceAsset Banner = new("MiraAPI.Resources.FortniteBanner.jpeg"); } \ No newline at end of file diff --git a/README.md b/README.md index 21b6334..b978c28 100644 --- a/README.md +++ b/README.md @@ -27,28 +27,28 @@ Roles are very simple in Mira API. There are 3 things you need to do to create a 2. Implement the `ICustomRole` interface from Mira API. 3. Add the `[RegisterCustomRole]` attribute to the class. -See [this file](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI.Example/CustomRole.cs) for a code example. +See [this file](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI.Example/Roles/CustomRole.cs) for a code example. ## Options Options are also very simple in Mira API. Options are split up into Groups and Options. Every Option needs to be in a Group. -To create a group, you need to create a class that implements the `IModdedOptionGroup` interface. Groups contain 4 properties, `GroupName`, `GroupColor`, `GroupVisible`, and `AdvancedRole`. Only the `GroupName` is required. +To create a group, you need to create a class that inherits from the `AbstractOptionGroup` abstract class. Groups contain 4 properties, `GroupName`, `GroupColor`, `GroupVisible`, and `AdvancedRole`. Only the `GroupName` is required. Here is an example of a group class: ```csharp -public class MyOptionsGroup : IModdedOptionGroup +public class MyOptionsGroup : AbstractOptionGroup { - public string GroupName => "My Options"; // this is required + public override string GroupName => "My Options"; // this is required [ModdedNumberOption("My Number Option", min: 0, max: 10)] public float MyNumberOption { get; set; } = 5f; } ``` -You can access any group class using the `ModdedGroupSingleton` class like this: +You can access any group class using the `OptionGroupSingleton` class like this: ``` -// MyOptionsGroup is a class that implements IModdedOptionGroup -var myGroup = ModdedGroupSingleton.Instance; // gets the instance of the group +// MyOptionsGroup is a class that inherits from AbstractOptionGroup +var myGroup = OptionGroupSingleton.Instance; // gets the instance of the group System.Out.Console.WriteLine(myGroup.MyNumberOption); // prints the value of the option to the console ``` @@ -74,7 +74,7 @@ Here is a full list of ModdedOption classes you can use: - `ModdedStringOption` - `ModdedToggleOption` -To see a full example of an options class, see [this file](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI.Example/ExampleOptions.cs). +To see a full example of an options class, see [this file](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI.Example/Options/ExampleOptions.cs). ### Role Options @@ -82,10 +82,10 @@ You can also specify a role type for an option or option group. To set the role type for an entire group, set the `AdvancedRole` property on that group like this: ```csharp -public class MyOptionsGroup : IModdedOptionGroup +public class MyOptionsGroup : AbstractOptionGroup { - public string GroupName => "My Options"; - public Type AdvancedRole => typeof(MyRole); // this is the role that will have these options + public override string GroupName => "My Options"; + public override Type AdvancedRole => typeof(MyRole); // this is the role that will have these options [ModdedNumberOption("Ability Uses", min: 0, max: 10)] public float AbilityUses { get; set; } = 5f; @@ -95,9 +95,9 @@ public class MyOptionsGroup : IModdedOptionGroup To set the role type for individual options, specify the `roleType` parameter in the option like this: ```csharp // this group doesnt specify a role, so it will show up in the global settings -public class MyOptionsGroup : IModdedOptionGroup +public class MyOptionsGroup : AbstractOptionGroup { - public string GroupName => "My Options"; + public override string GroupName => "My Options"; // this option will only show up in the settings for MyRole [ModdedNumberOption("Ability Uses", min: 0, max: 10, roleType: typeof(MyRole))] @@ -115,7 +115,7 @@ Mira API provides a simple interface for adding ability buttons to the game. The The button API is simple, but provides a lot of flexibility. There are various methods you can override to customize the behaviour of your button. See [this file](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI/Hud/CustomActionButton.cs) for a full list of methods you can override. -An example button can be found [here](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI.Example/ExampleButton.cs). +An example button can be found [here](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI.Example/Buttons/ExampleButton.cs). ## Assets @@ -138,6 +138,8 @@ LoadableAsset buttonAsset = new LoadableResourceAsset("ExampleMod.Resour Sprite button = buttonSpriteAsset.LoadAsset(); ``` +You can view an example file [here](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI.Example/ExampleAssets.cs). + You can create your own asset loaders by inheriting from `LoadableAsset` and implementing the `LoadAsset` method. # Disclaimer