mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
Move icons to gamemode and add icons for vanilla modes
This commit is contained in:
1 parent
27e14488af
commit
951af42358
10 files changed
+35
-14
No files matched your search
@@ -20,7 +20,7 @@ public partial class ExamplePlugin : BasePlugin, IMiraPlugin
|
|||||||
{
|
{
|
||||||
public Harmony Harmony { get; } = new(Id);
|
public Harmony Harmony { get; } = new(Id);
|
||||||
public string OptionsTitleText => "Mira API\nExample Mod";
|
public string OptionsTitleText => "Mira API\nExample Mod";
|
||||||
public LoadableAsset<Sprite>? ModIcon => ExampleAssets.ExampleButton;
|
public string CustomOptionMenuNameTwo => "angxl's Options";
|
||||||
public ConfigFile GetConfigFile() => Config;
|
public ConfigFile GetConfigFile() => Config;
|
||||||
public override void Load()
|
public override void Load()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using MiraAPI.GameModes;
|
using MiraAPI.GameModes;
|
||||||
|
using MiraAPI.Utilities.Assets;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace MiraAPI.Example.GameModes;
|
namespace MiraAPI.Example.GameModes;
|
||||||
@@ -7,5 +8,6 @@ public class ExampleMode : AbstractGameMode
|
|||||||
{
|
{
|
||||||
public override string Name => "Example Mode";
|
public override string Name => "Example Mode";
|
||||||
public override string Description => "An example gamemode.";
|
public override string Description => "An example gamemode.";
|
||||||
|
public override LoadableAsset<Sprite>? Icon => ExampleAssets.ExampleButton;
|
||||||
public override Color Color => Color.red;
|
public override Color Color => Color.red;
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using AmongUs.GameOptions;
|
using AmongUs.GameOptions;
|
||||||
using MiraAPI.GameOptions;
|
using MiraAPI.GameOptions;
|
||||||
using MiraAPI.PluginLoading;
|
using MiraAPI.PluginLoading;
|
||||||
|
using MiraAPI.Utilities.Assets;
|
||||||
using Reactor.Utilities.Extensions;
|
using Reactor.Utilities.Extensions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@@ -29,6 +30,11 @@ public abstract class AbstractGameMode : IOptionable
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual Color Color { get; } = Color.white;
|
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>
|
/// <summary>
|
||||||
/// Gets the colored game mode name, using the color and name properties.
|
/// Gets the colored game mode name, using the color and name properties.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using MiraAPI.PluginLoading;
|
using MiraAPI.PluginLoading;
|
||||||
|
using MiraAPI.Utilities.Assets;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace MiraAPI.GameModes;
|
namespace MiraAPI.GameModes;
|
||||||
|
|
||||||
@@ -13,4 +15,6 @@ public class ClassicMode : AbstractGameMode
|
|||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override string Description => "The classic Among Us experience!\nFind the Impostors or deceive the Crew.";
|
public override string Description => "The classic Among Us experience!\nFind the Impostors or deceive the Crew.";
|
||||||
|
|
||||||
|
public override LoadableAsset<Sprite>? Icon => MiraAssets.ClassicGamemodeIcon;
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ using MiraAPI.HnsReimplemented.Options;
|
|||||||
using MiraAPI.PluginLoading;
|
using MiraAPI.PluginLoading;
|
||||||
using MiraAPI.Roles;
|
using MiraAPI.Roles;
|
||||||
using MiraAPI.Utilities;
|
using MiraAPI.Utilities;
|
||||||
|
using MiraAPI.Utilities.Assets;
|
||||||
using PowerTools;
|
using PowerTools;
|
||||||
using UnityEngine;
|
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 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 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 CanReport(DeadBody body) => false;
|
||||||
public override bool ShouldShowSabotageMap(MapBehaviour map) => false;
|
public override bool ShouldShowSabotageMap(MapBehaviour map) => false;
|
||||||
public override bool ShowGameModeIntroCutscene => true;
|
public override bool ShowGameModeIntroCutscene => true;
|
||||||
|
|||||||
@@ -87,21 +87,24 @@ internal static class GameOptionsMenuPatch
|
|||||||
instance.Children.Add(opt);
|
instance.Children.Add(opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
var mod = CustomGameModeManager.FindParentMod(gameMode);
|
var icon = gameMode.Icon;
|
||||||
if (mod is { MiraPlugin.ModIcon: not null })
|
if (icon != null)
|
||||||
{
|
{
|
||||||
_modIcon.gameObject.SetActive(true);
|
_modIcon.gameObject.SetActive(true);
|
||||||
_gamemodeDescription.transform.localPosition = new Vector3(0.3f, 0, -0.01f);
|
_gamemodeDescription.transform.localPosition = new Vector3(0.3f, 0, -0.01f);
|
||||||
_gamemodeDescription.horizontalAlignment = HorizontalAlignmentOptions.Left;
|
_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(
|
var newSprite = Sprite.Create(
|
||||||
texture,
|
texture,
|
||||||
new Rect(0, 0, 128, 128),
|
new Rect(0, 0, texture.width, texture.height),
|
||||||
Vector2.one / 2,
|
Vector2.one / 2,
|
||||||
100
|
100f / scale
|
||||||
);
|
);
|
||||||
|
|
||||||
_modIcon.sprite = newSprite;
|
_modIcon.sprite = newSprite;
|
||||||
_modIcon.drawMode = SpriteDrawMode.Sliced;
|
_modIcon.drawMode = SpriteDrawMode.Simple;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -247,7 +250,7 @@ internal static class GameOptionsMenuPatch
|
|||||||
{
|
{
|
||||||
parent = modeInfoHolder,
|
parent = modeInfoHolder,
|
||||||
localPosition = new Vector3(-1.75f, 0, -0.1f),
|
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,
|
layer = gamemodeBg.layer,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -54,11 +54,6 @@ public interface IMiraPlugin
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual string CustomOptionMenuTwoDescription => "Apply game settings for this mod!";
|
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>
|
/// <summary>
|
||||||
/// Gets the <see cref="ConfigFile"/> for the plugin.
|
/// Gets the <see cref="ConfigFile"/> for the plugin.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
@@ -130,6 +130,16 @@ public static class MiraAssets
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LoadableResourceAsset ModifierFile { get; } = new("MiraAPI.Resources.ModifierFile.png");
|
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>
|
/// <summary>
|
||||||
/// Gets the sprite used for timed modifier file in TaskAdderGame.
|
/// Gets the sprite used for timed modifier file in TaskAdderGame.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in new issue
Block a user