diff --git a/MiraAPI.Example/ExamplePlugin.cs b/MiraAPI.Example/ExamplePlugin.cs index ff4efb1..dc0783b 100644 --- a/MiraAPI.Example/ExamplePlugin.cs +++ b/MiraAPI.Example/ExamplePlugin.cs @@ -20,7 +20,7 @@ public partial class ExamplePlugin : BasePlugin, IMiraPlugin { public Harmony Harmony { get; } = new(Id); public string OptionsTitleText => "Mira API\nExample Mod"; - public LoadableAsset? ModIcon => ExampleAssets.ExampleButton; + public string CustomOptionMenuNameTwo => "angxl's Options"; public ConfigFile GetConfigFile() => Config; public override void Load() { diff --git a/MiraAPI.Example/GameModes/ExampleMode.cs b/MiraAPI.Example/GameModes/ExampleMode.cs index 4868516..c15e1d5 100644 --- a/MiraAPI.Example/GameModes/ExampleMode.cs +++ b/MiraAPI.Example/GameModes/ExampleMode.cs @@ -1,4 +1,5 @@ using MiraAPI.GameModes; +using MiraAPI.Utilities.Assets; using UnityEngine; namespace MiraAPI.Example.GameModes; @@ -7,5 +8,6 @@ public class ExampleMode : AbstractGameMode { public override string Name => "Example Mode"; public override string Description => "An example gamemode."; + public override LoadableAsset? Icon => ExampleAssets.ExampleButton; public override Color Color => Color.red; } diff --git a/MiraAPI/GameModes/AbstractGameMode.cs b/MiraAPI/GameModes/AbstractGameMode.cs index 7539277..cf3b2d8 100644 --- a/MiraAPI/GameModes/AbstractGameMode.cs +++ b/MiraAPI/GameModes/AbstractGameMode.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using AmongUs.GameOptions; using MiraAPI.GameOptions; using MiraAPI.PluginLoading; +using MiraAPI.Utilities.Assets; using Reactor.Utilities.Extensions; using UnityEngine; @@ -29,6 +30,11 @@ public abstract class AbstractGameMode : IOptionable /// public virtual Color Color { get; } = Color.white; + /// + /// Gets the icon of the gamemode. Will be shown in options menu underneath the gamemode option. + /// + public virtual LoadableAsset? Icon => null; + /// /// Gets the colored game mode name, using the color and name properties. /// diff --git a/MiraAPI/GameModes/ClassicMode.cs b/MiraAPI/GameModes/ClassicMode.cs index 7eff012..44b43da 100644 --- a/MiraAPI/GameModes/ClassicMode.cs +++ b/MiraAPI/GameModes/ClassicMode.cs @@ -1,4 +1,6 @@ using MiraAPI.PluginLoading; +using MiraAPI.Utilities.Assets; +using UnityEngine; namespace MiraAPI.GameModes; @@ -13,4 +15,6 @@ public class ClassicMode : AbstractGameMode /// public override string Description => "The classic Among Us experience!\nFind the Impostors or deceive the Crew."; + + public override LoadableAsset? Icon => MiraAssets.ClassicGamemodeIcon; } diff --git a/MiraAPI/GameModes/HideAndSeekMode.cs b/MiraAPI/GameModes/HideAndSeekMode.cs index 6ec83ae..f1b5953 100644 --- a/MiraAPI/GameModes/HideAndSeekMode.cs +++ b/MiraAPI/GameModes/HideAndSeekMode.cs @@ -11,6 +11,7 @@ using MiraAPI.HnsReimplemented.Options; using MiraAPI.PluginLoading; using MiraAPI.Roles; using MiraAPI.Utilities; +using MiraAPI.Utilities.Assets; using PowerTools; using UnityEngine; @@ -29,7 +30,7 @@ public class HideAndSeekMode : AbstractGameMode public override string Description => "You can run, but you can't hide!\nOutlive the timer or eliminate the crew."; public override Color Color { get; } = new Color32(255, 88, 90, 255); - + public override LoadableAsset? Icon => MiraAssets.HnSGamemodeIcon; public override bool CanReport(DeadBody body) => false; public override bool ShouldShowSabotageMap(MapBehaviour map) => false; public override bool ShowGameModeIntroCutscene => true; diff --git a/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs b/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs index 0468ef7..9190568 100644 --- a/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs +++ b/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs @@ -87,21 +87,24 @@ internal static class GameOptionsMenuPatch instance.Children.Add(opt); } - var mod = CustomGameModeManager.FindParentMod(gameMode); - if (mod is { MiraPlugin.ModIcon: not null }) + var icon = gameMode.Icon; + if (icon != null) { _modIcon.gameObject.SetActive(true); _gamemodeDescription.transform.localPosition = new Vector3(0.3f, 0, -0.01f); _gamemodeDescription.horizontalAlignment = HorizontalAlignmentOptions.Left; - var texture = mod.MiraPlugin.ModIcon.LoadAsset().texture; + var texture = icon.LoadAsset().texture; + var scale = Mathf.Min(128f / texture.width, 128f / texture.height); + var newSprite = Sprite.Create( texture, - new Rect(0, 0, 128, 128), + new Rect(0, 0, texture.width, texture.height), Vector2.one / 2, - 100 + 100f / scale ); + _modIcon.sprite = newSprite; - _modIcon.drawMode = SpriteDrawMode.Sliced; + _modIcon.drawMode = SpriteDrawMode.Simple; } else { @@ -247,7 +250,7 @@ internal static class GameOptionsMenuPatch { parent = modeInfoHolder, localPosition = new Vector3(-1.75f, 0, -0.1f), - localScale = new Vector3(0.4f, 0.4f, 1), + localScale = new Vector3(0.45f, 0.45f, 1), }, layer = gamemodeBg.layer, }; diff --git a/MiraAPI/PluginLoading/IMiraPlugin.cs b/MiraAPI/PluginLoading/IMiraPlugin.cs index bb3e29d..6fb13ed 100644 --- a/MiraAPI/PluginLoading/IMiraPlugin.cs +++ b/MiraAPI/PluginLoading/IMiraPlugin.cs @@ -54,11 +54,6 @@ public interface IMiraPlugin /// public virtual string CustomOptionMenuTwoDescription => "Apply game settings for this mod!"; - /// - /// Gets the icon of the mod. - /// - public virtual LoadableAsset? ModIcon => null; - /// /// Gets the for the plugin. /// diff --git a/MiraAPI/Resources/ClassicGamemodeIcon.png b/MiraAPI/Resources/ClassicGamemodeIcon.png new file mode 100644 index 0000000..163ac1a Binary files /dev/null and b/MiraAPI/Resources/ClassicGamemodeIcon.png differ diff --git a/MiraAPI/Resources/HnSGamemodeIcon.png b/MiraAPI/Resources/HnSGamemodeIcon.png new file mode 100644 index 0000000..8b60c3d Binary files /dev/null and b/MiraAPI/Resources/HnSGamemodeIcon.png differ diff --git a/MiraAPI/Utilities/Assets/MiraAssets.cs b/MiraAPI/Utilities/Assets/MiraAssets.cs index 10bceda..799f324 100644 --- a/MiraAPI/Utilities/Assets/MiraAssets.cs +++ b/MiraAPI/Utilities/Assets/MiraAssets.cs @@ -130,6 +130,16 @@ public static class MiraAssets /// public static LoadableResourceAsset ModifierFile { get; } = new("MiraAPI.Resources.ModifierFile.png"); + /// + /// Gets the sprite used for the Classic gamemode. + /// + public static LoadableResourceAsset ClassicGamemodeIcon { get; } = new("MiraAPI.Resources.ClassicGamemodeIcon.png"); + + /// + /// Gets the sprite used for the Hide n Seek gamemode. + /// + public static LoadableResourceAsset HnSGamemodeIcon { get; } = new("MiraAPI.Resources.HnSGamemodeIcon.png"); + /// /// Gets the sprite used for timed modifier file in TaskAdderGame. ///