Move icons to gamemode and add icons for vanilla modes

This commit is contained in:
ang-xd committed 2026-08-14 16:39:16 -04:00
1 parent 27e14488af
commit 951af42358
10 files changed
+35 -14

No files matched your search

+1 -1
View File
@@ -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<Sprite>? ModIcon => ExampleAssets.ExampleButton;
public string CustomOptionMenuNameTwo => "angxl's Options";
public ConfigFile GetConfigFile() => Config;
public override void Load()
{
+2
View File
@@ -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<Sprite>? Icon => ExampleAssets.ExampleButton;
public override Color Color => Color.red;
}
+6
View File
@@ -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
/// </summary>
public virtual Color Color { get; } = Color.white;
/// <summary>
/// Gets the icon of the gamemode. Will be shown in options menu underneath the gamemode option.
/// </summary>
public virtual LoadableAsset<Sprite>? Icon => null;
/// <summary>
/// Gets the colored game mode name, using the color and name properties.
/// </summary>
+4
View File
@@ -1,4 +1,6 @@
using MiraAPI.PluginLoading;
using MiraAPI.Utilities.Assets;
using UnityEngine;
namespace MiraAPI.GameModes;
@@ -13,4 +15,6 @@ public class ClassicMode : AbstractGameMode
/// <inheritdoc/>
public override string Description => "The classic Among Us experience!\nFind the Impostors or deceive the Crew.";
public override LoadableAsset<Sprite>? Icon => MiraAssets.ClassicGamemodeIcon;
}
+2 -1
View File
@@ -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<Sprite>? Icon => MiraAssets.HnSGamemodeIcon;
public override bool CanReport(DeadBody body) => false;
public override bool ShouldShowSabotageMap(MapBehaviour map) => false;
public override bool ShowGameModeIntroCutscene => true;
@@ -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,
};
-5
View File
@@ -54,11 +54,6 @@ public interface IMiraPlugin
/// </summary>
public virtual string CustomOptionMenuTwoDescription => "Apply game settings for this mod!";
/// <summary>
/// Gets the icon of the mod.
/// </summary>
public virtual LoadableAsset<Sprite>? ModIcon => null;
/// <summary>
/// Gets the <see cref="ConfigFile"/> for the plugin.
/// </summary>
Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

+10
View File
@@ -130,6 +130,16 @@ public static class MiraAssets
/// </summary>
public static LoadableResourceAsset ModifierFile { get; } = new("MiraAPI.Resources.ModifierFile.png");
/// <summary>
/// Gets the sprite used for the Classic gamemode.
/// </summary>
public static LoadableResourceAsset ClassicGamemodeIcon { get; } = new("MiraAPI.Resources.ClassicGamemodeIcon.png");
/// <summary>
/// Gets the sprite used for the Hide n Seek gamemode.
/// </summary>
public static LoadableResourceAsset HnSGamemodeIcon { get; } = new("MiraAPI.Resources.HnSGamemodeIcon.png");
/// <summary>
/// Gets the sprite used for timed modifier file in TaskAdderGame.
/// </summary>