mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
Show gamemode change notification
This commit is contained in:
1 parent
b4ed14f7f2
commit
d1d11e2bec
5 files changed
+25
-1
No files matched your search
@@ -5,6 +5,7 @@ using MiraAPI.GameOptions;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.GameModes;
|
||||
@@ -35,6 +36,11 @@ public abstract class AbstractGameMode : IOptionable
|
||||
/// </summary>
|
||||
public virtual LoadableAsset<Sprite>? Icon => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the icon of the gamemode for use on the options pop-up.
|
||||
/// </summary>
|
||||
public TMP_SpriteAsset TmpIcon { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the colored game mode name, using the color and name properties.
|
||||
/// </summary>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities;
|
||||
|
||||
namespace MiraAPI.GameModes;
|
||||
|
||||
@@ -111,6 +111,14 @@ public static class GameModeOption
|
||||
Value = val;
|
||||
CustomGameModeManager.GetAndSetGameMode();
|
||||
HudPatches.SetGameModeText(CustomGameModeManager.GetMode(Values.ElementAt(_lastValue).Key).ColoredName);
|
||||
var gm = CustomGameModeManager.ActiveMode!;
|
||||
ModdedOptionsManager.AddSettingsChangeMessage(
|
||||
HudManager.Instance.Notifier,
|
||||
GamemodeName,
|
||||
gm.ColoredName,
|
||||
new Color(0.7333f, 0.7333f, 0.7333f, 1),
|
||||
gm.TmpIcon,
|
||||
true);
|
||||
// could make Values a dict of AbstractGameMode too
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public static class ModdedOptionsManager
|
||||
|
||||
public static void AddSettingsChangeMessage(NotificationPopper notif, StringNames key, string value, Color textColor, TMP_SpriteAsset? sprite, bool playSound = true)
|
||||
{
|
||||
var item = string.Empty;
|
||||
string item;
|
||||
var text = textColor.ToTextColor();
|
||||
if (sprite != null)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using HarmonyLib;
|
||||
using MiraAPI.GameModes;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
|
||||
namespace MiraAPI.Patches.Roles;
|
||||
|
||||
@@ -22,6 +24,13 @@ public static class GameStartupPatch
|
||||
}
|
||||
|
||||
_runOnce = true;
|
||||
foreach (var mode in CustomGameModeManager.IdToModeMap.Values)
|
||||
{
|
||||
if (mode.Icon != null)
|
||||
{
|
||||
mode.TmpIcon = TmpSpriteUtils.CreateSpriteAsset(mode.Icon.LoadAsset(), $"MiraApi.Gamemode.{mode.Name.Replace(" ", string.Empty)}.png", 1.35f);
|
||||
}
|
||||
}
|
||||
|
||||
if (MiraPluginManager.Instance.QueuedRoleRegistrations.Count <= 0)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user