mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 11:39:45 +00:00
Compare commits
63
Commits
dev-update
...
0.5.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef19f5f7de | ||
|
|
e619acbc2a | ||
|
|
9e21726ced | ||
|
|
7d7d6469ce | ||
|
|
087ea2a4bd | ||
|
|
81c6bac979 | ||
|
|
85fb507a43 | ||
|
|
3e2c6df829 | ||
|
|
6c7b362f95 | ||
|
|
027d4763f3 | ||
|
|
d2f6ba9718 | ||
|
|
28871d0a01 | ||
|
|
b62b8ae216 | ||
|
|
4bdddc6f8a | ||
|
|
fa47d1dec4 | ||
|
|
004f62eb77 | ||
|
|
3f7e30a5c3 | ||
|
|
1d18a2ac7b | ||
|
|
663480c77f | ||
|
|
e95b52dbe8 | ||
|
|
76105b3116 | ||
|
|
c82cc0e173 | ||
|
|
2a432dd928 | ||
|
|
648e9ec185 | ||
|
|
709b59300b | ||
|
|
f064952aa6 | ||
|
|
e532e558b6 | ||
|
|
a3ed901a18 | ||
|
|
48aff163f9 | ||
|
|
28a77f96cb | ||
|
|
4206b74d12 | ||
|
|
276ab0ac79 | ||
|
|
34148499b7 | ||
|
|
5b006ab7d3 | ||
|
|
47582897a8 | ||
|
|
80e1e6e454 | ||
|
|
c449669cf2 | ||
|
|
6da1048d09 | ||
|
|
6a7f58effa | ||
|
|
39da0e7d08 | ||
|
|
5a23c38fba | ||
|
|
0b1b223a6e | ||
|
|
a4a363b015 | ||
|
|
794c762949 | ||
|
|
d37222010d | ||
|
|
1254de742a | ||
|
|
7bbbd7597d | ||
|
|
4b7f17fa30 | ||
|
|
06d62da24d | ||
|
|
0050c34225 | ||
|
|
605c792e8f | ||
|
|
54d7c84e91 | ||
|
|
eb4bff1834 | ||
|
|
e381de033e | ||
|
|
acfe345133 | ||
|
|
182a53442e | ||
|
|
35e4c7cc9d | ||
|
|
b2a5b236c0 | ||
|
|
525f987926 | ||
|
|
0b81a8808a | ||
|
|
b100f92525 | ||
|
|
202b098857 | ||
|
|
fedba71889 |
No files matched your search
@@ -8,7 +8,7 @@
|
||||
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
|
||||
<VersionPrefix>0.4.3</VersionPrefix>
|
||||
<VersionPrefix>0.5.0</VersionPrefix>
|
||||
<VersionSuffix>dev</VersionSuffix>
|
||||
|
||||
<Authors>All Of Us, XtraCube, Angxl</Authors>
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace MiraAPI.Example.Buttons.Freezer;
|
||||
|
||||
public class FreezeButton : CustomActionButton<PlayerControl>
|
||||
{
|
||||
public override string Name => "Freeze";
|
||||
public override string Name => "button.freeze";
|
||||
|
||||
public override float Cooldown => OptionGroupSingleton<FreezerRoleSettings>.Instance.FreezeDuration;
|
||||
public override bool PauseTimerInVent => true;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace MiraAPI.Example.Buttons;
|
||||
|
||||
public class MeetingButton : CustomActionButton
|
||||
{
|
||||
public override string Name => "Call Meeting";
|
||||
public override string Name => "button.callMeeting";
|
||||
|
||||
public override float Cooldown => 15;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace MiraAPI.Example.Buttons;
|
||||
|
||||
public class NeutralKillerButton : CustomActionButton
|
||||
{
|
||||
public override string Name => "Win Game";
|
||||
public override string Name => "button.winGame";
|
||||
public override float Cooldown => 0f;
|
||||
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
|
||||
public override MiraKeybind Keybind => ExampleKeybinds.NeutralWinKeybind;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace MiraAPI.Example.Buttons.Teleporter;
|
||||
|
||||
public class TeleportButton : CustomActionButton
|
||||
{
|
||||
public override string Name => "Teleport";
|
||||
public override string Name => "button.teleport";
|
||||
|
||||
public override float Cooldown => OptionGroupSingleton<TeleporterOptions>.Instance.TeleportCooldown.Value;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MiraAPI.Hud;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -6,7 +7,7 @@ namespace MiraAPI.Example.Buttons;
|
||||
|
||||
public class ThinkButton : CustomActionButton
|
||||
{
|
||||
public override string Name => "Think";
|
||||
public override string Name => "button.think";
|
||||
public override float Cooldown => 15f;
|
||||
public override float EffectDuration => 10f;
|
||||
public override int MaxUses => 1;
|
||||
@@ -14,13 +15,12 @@ public class ThinkButton : CustomActionButton
|
||||
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
|
||||
protected override void OnClick()
|
||||
{
|
||||
// This button does absolutely nothing besides changing its text
|
||||
Button!.OverrideText("Thinking...");
|
||||
Button!.OverrideText("button.think.thinking".Translate());
|
||||
}
|
||||
|
||||
public override void OnEffectEnd()
|
||||
{
|
||||
Button!.OverrideText("Think");
|
||||
Button!.OverrideText("button.think".Translate());
|
||||
}
|
||||
|
||||
public override bool IsEffectCancellable()
|
||||
|
||||
@@ -9,5 +9,6 @@ public static class ExampleAssets
|
||||
|
||||
// Credit to EpicHorrors for the teleport button asset.
|
||||
public static LoadableResourceAsset TeleportButton { get; } = new("MiraAPI.Example.Resources.TeleportButton.png");
|
||||
public static LoadableResourceAsset SharpshootButton { get; } = new("MiraAPI.Example.Resources.SharpshootButton.png");
|
||||
public static LoadableResourceAsset Banner { get; } = new("MiraAPI.Example.Resources.FortniteBanner.jpeg");
|
||||
}
|
||||
@@ -6,12 +6,12 @@ namespace MiraAPI.Example;
|
||||
[RegisterCustomColors]
|
||||
public static class ExampleColors
|
||||
{
|
||||
public static CustomColor Cerulean { get; } = new("Cerulean", new Color(0.0f, 0.48f, 0.65f))
|
||||
public static CustomColor Cerulean { get; } = new("color.cerulean", new Color(0.0f, 0.48f, 0.65f))
|
||||
{
|
||||
ColorBrightness = CustomColorBrightness.Lighter,
|
||||
};
|
||||
|
||||
public static CustomColor Rose { get; } = new("Rose", new Color(0.98f, 0.26f, 0.62f));
|
||||
public static CustomColor Rose { get; } = new("color.rose", new Color(0.98f, 0.26f, 0.62f));
|
||||
|
||||
public static CustomColor Gold { get; } = new("Gold", new Color(1.0f, 0.84f, 0.0f));
|
||||
public static CustomColor Gold { get; } = new("color.gold", new Color(1.0f, 0.84f, 0.0f));
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace MiraAPI.Example;
|
||||
|
||||
public class ExampleLocalSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
{
|
||||
public override string TabName => "Mira Example";
|
||||
public override string TabName => "settings.miraExample";
|
||||
protected override bool ShouldCreateLabels => false;
|
||||
|
||||
public override LocalSettingTabAppearance TabAppearance => new()
|
||||
@@ -18,7 +18,7 @@ public class ExampleLocalSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
};
|
||||
|
||||
[LocalSettingsButton]
|
||||
public LocalSettingsButton ExampleButton { get; private set; } = new("Example Button", OnExampleButtonClick);
|
||||
public LocalSettingsButton ExampleButton { get; private set; } = new("settings.miraExample.button.exampleButton", OnExampleButtonClick);
|
||||
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ExampleToggle { get; private set; } = config.Bind("General", "Example Bool", true);
|
||||
|
||||
@@ -3,11 +3,10 @@ using BepInEx.Configuration;
|
||||
using BepInEx.Unity.IL2CPP;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using MiraAPI.Translation;
|
||||
using Reactor;
|
||||
using Reactor.Networking;
|
||||
using Reactor.Networking.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example;
|
||||
|
||||
@@ -18,6 +17,10 @@ namespace MiraAPI.Example;
|
||||
[ReactorModFlags(ModFlags.RequireOnAllClients)]
|
||||
public partial class ExamplePlugin : BasePlugin, IMiraPlugin
|
||||
{
|
||||
public ExamplePlugin()
|
||||
{
|
||||
MiraLocaleManager.Register("mira.example");
|
||||
}
|
||||
public Harmony Harmony { get; } = new(Id);
|
||||
public string OptionsTitleText => "Mira API\nExample Mod";
|
||||
public string CustomOptionMenuNameTwo => "angxl's Options";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.GameEnd;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -14,7 +15,7 @@ public class NeutralKillerGameOver : CustomGameOver
|
||||
|
||||
public override void AfterEndGameSetup(EndGameManager endGameManager)
|
||||
{
|
||||
endGameManager.WinText.text = "Outcast Killer Wins!";
|
||||
endGameManager.WinText.text = "gameover.outcastKiller.win".Translate();
|
||||
endGameManager.WinText.color = Color.magenta;
|
||||
endGameManager.BackgroundBar.material.SetColor(ShaderID.Color, Color.magenta);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.MeetingAbilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.MeetingAbilities;
|
||||
|
||||
public class EndMeetingButton : MeetingActionButton
|
||||
{
|
||||
public override string Name => "End Meeting";
|
||||
|
||||
public override float Cooldown => 15;
|
||||
|
||||
public override float InitialCooldown => 30;
|
||||
|
||||
public override int MaxUses => 3;
|
||||
|
||||
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
|
||||
|
||||
public override bool Enabled(RoleBehaviour? role)
|
||||
{
|
||||
return PlayerControl.LocalPlayer != null && role is MayorRole;
|
||||
}
|
||||
|
||||
protected override void OnClick()
|
||||
{
|
||||
MeetingHud.Instance.RpcClose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using MiraAPI.MeetingAbilities;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.MeetingAbilities;
|
||||
|
||||
public class ShootButton : TargetedMeetingButton
|
||||
{
|
||||
public override string Name => "Shoot";
|
||||
|
||||
public override int MaxUses => 3;
|
||||
|
||||
public override float InitialCooldown => 5;
|
||||
|
||||
public override float Cooldown => 3;
|
||||
|
||||
public override LoadableAsset<Sprite> Sprite => ExampleAssets.SharpshootButton;
|
||||
|
||||
public override Color OutlineColor => Color.red;
|
||||
|
||||
public override bool Enabled(RoleBehaviour r)
|
||||
{
|
||||
return r.IsImpostor;
|
||||
}
|
||||
|
||||
protected override void OnClick(PlayerVoteArea playerVoteArea)
|
||||
{
|
||||
playerVoteArea.SetDisabled();
|
||||
var player = playerVoteArea.GetPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
PlayerControl.LocalPlayer.RpcCustomMurder(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using MiraAPI.MeetingAbilities;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.MeetingAbilities;
|
||||
|
||||
public class ShotgunButton : MultiTargetMeetingButton
|
||||
{
|
||||
public override string Name => "Shotgun";
|
||||
|
||||
public override int MaxUses => 3;
|
||||
|
||||
public override float InitialCooldown => 5;
|
||||
|
||||
public override float Cooldown => 3;
|
||||
|
||||
public override LoadableAsset<Sprite> Sprite => ExampleAssets.SharpshootButton;
|
||||
|
||||
public override Color OutlineColor => Color.red;
|
||||
|
||||
public override bool Enabled(RoleBehaviour r)
|
||||
{
|
||||
return r.IsImpostor;
|
||||
}
|
||||
|
||||
protected override void OnClick(PlayerVoteArea playerVoteArea)
|
||||
{
|
||||
// Emptu because it only triggers the actual kills once all meeting abilities have been used.
|
||||
}
|
||||
|
||||
public override LoadableAsset<Sprite> SpriteActive => ExampleAssets.CallMeetingButton;
|
||||
|
||||
public override int TargetsCount => 4;
|
||||
|
||||
protected override void OnSelect(PlayerVoteArea playerVoteArea, bool toggle)
|
||||
{
|
||||
HudManager.Instance.PlayerCam.ShakeScreen(0.5f, 2);
|
||||
}
|
||||
|
||||
public override void OnFinish()
|
||||
{
|
||||
foreach (var playerVoteArea in Targets.Keys)
|
||||
{
|
||||
playerVoteArea.SetDisabled();
|
||||
var player = playerVoteArea.GetPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
PlayerControl.LocalPlayer.RpcCustomMurder(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
<Version>1.0.0</Version>
|
||||
<Description>Example mod for Mira API</Description>
|
||||
<Authors>Angxl, XtraCube</Authors>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Modifiers.Types;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -9,7 +10,7 @@ namespace MiraAPI.Example.Modifiers;
|
||||
|
||||
public class CaptainModifier : GameModifier
|
||||
{
|
||||
public override string ModifierName => "Captain";
|
||||
public override string ModifierName => MiraLocaleManager.Get("modifier.captain");
|
||||
public override LoadableAsset<Sprite>? ModifierIcon => ExampleAssets.CallMeetingButton;
|
||||
|
||||
public override void OnDeath(DeathReason reason)
|
||||
@@ -19,7 +20,7 @@ public class CaptainModifier : GameModifier
|
||||
|
||||
public override string GetDescription()
|
||||
{
|
||||
return $"You can call a meeting from anywhere on the map.";
|
||||
return MiraLocaleManager.Get("modifier.captain.TabDescription");
|
||||
}
|
||||
|
||||
public override int GetAssignmentChance()
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
using Il2CppSystem;
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.Modifiers.Types;
|
||||
using MiraAPI.Translation;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example.Modifiers.Freezer;
|
||||
|
||||
public class FreezeModifier : TimedModifier
|
||||
{
|
||||
public override string ModifierName => "Freezed";
|
||||
public override string ModifierName => MiraLocaleManager.Get("modifier.freezed");
|
||||
public override bool HideOnUi => false;
|
||||
public override float Duration => 15f;
|
||||
public override bool AutoStart => true;
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
using MiraAPI.Modifiers.Types;
|
||||
using MiraAPI.Translation;
|
||||
|
||||
namespace MiraAPI.Example.Modifiers;
|
||||
|
||||
public class HighPriorityModifier : GameModifier
|
||||
{
|
||||
public override string ModifierName => "High Priority";
|
||||
public override string ModifierName => MiraLocaleManager.Get("modifier.highPriority");
|
||||
|
||||
public override string GetDescription()
|
||||
{
|
||||
return "You are high priority! Idrk what this means either tbh...";
|
||||
return MiraLocaleManager.Get("modifier.highPriority.TabDescription");
|
||||
}
|
||||
|
||||
public override int GetAssignmentChance()
|
||||
|
||||
@@ -7,19 +7,19 @@ namespace MiraAPI.Example.Options;
|
||||
|
||||
public class ExampleOptions : AbstractOptionGroup
|
||||
{
|
||||
public override string GroupName => "Example Options 1";
|
||||
public override string GroupName => "options.exampleOptions1";
|
||||
public override Color GroupColor => Color.green;
|
||||
|
||||
[ModdedToggleOption("Toggle Opt 1")]
|
||||
[ModdedToggleOption("options.exampleOptions1.toggleOpt1")]
|
||||
public bool ToggleOpt { get; set; } = false;
|
||||
|
||||
[ModdedToggleOption("Toggle Opt 2")]
|
||||
[ModdedToggleOption("options.exampleOptions1.toggleOpt1")]
|
||||
public bool ToggleOpt2 { get; set; } = true;
|
||||
|
||||
[ModdedNumberOption("Number Opt", min: 0, max: 10, increment: .25f, formatString: "0.00", suffixType: MiraNumberSuffixes.Percent)]
|
||||
[ModdedNumberOption("options.exampleOptions1.numberOpt", min: 0, max: 10, increment: .25f, formatString: "0.00", suffixType: MiraNumberSuffixes.Percent)]
|
||||
public float NumberOpt { get; set; } = 4f;
|
||||
|
||||
[ModdedEnumOption("Best API", typeof(BestApi), ["Mira API", "Mitochondria", "Reactor"])]
|
||||
[ModdedEnumOption("options.exampleOptions1.bestApi", typeof(BestApi), ["Mira API", "Mitochondria", "Reactor"])]
|
||||
public BestApi Opt { get; set; } = BestApi.MiraAPI;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,22 +6,22 @@ namespace MiraAPI.Example.Options;
|
||||
|
||||
public class ExampleOptions2 : AbstractOptionGroup
|
||||
{
|
||||
public override string GroupName => "Example Options 2";
|
||||
public override string GroupName => "options.exampleOptions2";
|
||||
|
||||
public override uint GroupPriority => 0; // This group will be displayed first. The default value is uint.MaxValue.
|
||||
|
||||
public override MenuCategory ParentMenu => MenuCategory.CustomTwo;
|
||||
|
||||
public ModdedPlayerOption PlayerOption2 { get; } = new("YOU MUST CHOSE A PLAYER", false);
|
||||
public ModdedPlayerOption PlayerOption { get; } = new("Eh whatever");
|
||||
public ModdedToggleOption ToggleOpt1 { get; } = new("Toggle Option 1", false);
|
||||
public ModdedPlayerOption PlayerOption2 { get; } = new("options.exampleOptions2.youMustChoseAPlayer", false);
|
||||
public ModdedPlayerOption PlayerOption { get; } = new("options.exampleOptions2.ehWhatever");
|
||||
public ModdedToggleOption ToggleOpt1 { get; } = new("options.exampleOptions2.toggleOption1", false);
|
||||
|
||||
public ModdedToggleOption ToggleOpt2 { get; } = new("Toggle Option 2", false)
|
||||
public ModdedToggleOption ToggleOpt2 { get; } = new("options.exampleOptions2.toggleOption2", false)
|
||||
{
|
||||
Visible = () => OptionGroupSingleton<ExampleOptions2>.Instance.ToggleOpt1, // implicit cast from ModdedToggleOption to bool
|
||||
};
|
||||
|
||||
public ModdedEnumOption<TestingData> EnumOpt { get; } = new("Enum Opt", 0)
|
||||
public ModdedEnumOption<TestingData> EnumOpt { get; } = new("options.exampleOptions2.enumOpt", 0)
|
||||
{
|
||||
ChangedEvent = x => Logger<ExamplePlugin>.Info($"changed Enum Opt to {x}"),
|
||||
};
|
||||
|
||||
@@ -6,14 +6,14 @@ namespace MiraAPI.Example.Options.Modifiers;
|
||||
|
||||
public class CaptainModifierSettings : AbstractOptionGroup<CaptainModifier>
|
||||
{
|
||||
public override string GroupName => "Captain Settings";
|
||||
public override string GroupName => "options.captainSettings";
|
||||
|
||||
[ModdedNumberOption("Amount", 0, 5)]
|
||||
[ModdedNumberOption("options.captainSettings.amount", 0, 5)]
|
||||
public float Amount { get; set; } = 1;
|
||||
|
||||
[ModdedNumberOption("Chance", 0, 100, 10)]
|
||||
[ModdedNumberOption("options.captainSettings.chance", 0, 100, 10)]
|
||||
public float Chance { get; set; } = 50;
|
||||
|
||||
[ModdedNumberOption("Uses", 1, 5)]
|
||||
[ModdedNumberOption("options.captainSettings.uses", 1, 5)]
|
||||
public float NumUses { get; set; } = 3;
|
||||
}
|
||||
@@ -6,8 +6,8 @@ namespace MiraAPI.Example.Options.Modifiers;
|
||||
|
||||
public class FreezeModifierSettings : AbstractOptionGroup<FreezeModifier>
|
||||
{
|
||||
public override string GroupName => "Freeze";
|
||||
public override string GroupName => "options.freezeModifierSettings";
|
||||
|
||||
[ModdedToggleOption("Use Color")]
|
||||
[ModdedToggleOption("options.freezeModifierSettings.useColor")]
|
||||
public bool UseColor { get; set; } = true;
|
||||
}
|
||||
@@ -5,15 +5,15 @@ namespace MiraAPI.Example.Options.Modifiers;
|
||||
|
||||
public class GeneralModifierOptions : AbstractOptionGroup
|
||||
{
|
||||
public override string GroupName => "General";
|
||||
public override string GroupName => "options.generalModifier";
|
||||
|
||||
public override uint GroupPriority => 0;
|
||||
|
||||
public override MenuCategory ParentMenu => MenuCategory.Modifiers;
|
||||
|
||||
[ModdedToggleOption("Some Boolean Option")]
|
||||
[ModdedToggleOption("options.generalModifier.someBooleanOption")]
|
||||
public bool SomeBooleanOption { get; set; } = true;
|
||||
|
||||
[ModdedNumberOption("Number Option", 0, 10, 1)]
|
||||
[ModdedNumberOption("options.generalModifier.numberOption", 0, 10, 1)]
|
||||
public float NumberOption { get; set; } = 5;
|
||||
}
|
||||
@@ -13,11 +13,11 @@ public class FreezerRoleSettings : AbstractOptionGroup<FreezerRole>
|
||||
TmpSpriteUtils.CreateSpriteAsset(
|
||||
MiraAssets.ImpostorFile.LoadAsset(),
|
||||
"ApiExample.Role.Impostor.FreezerRole"));
|
||||
public override string GroupName => "Custom Role";
|
||||
public override string GroupName => "ApiExample.Role.Freezer";
|
||||
|
||||
[ModdedNumberOption("Freeze Duration", 1, 15, 1, MiraNumberSuffixes.Seconds)]
|
||||
[ModdedNumberOption("ApiExample.Role.Freezer.Settings.FreezeDuration", 1, 15, 1, MiraNumberSuffixes.Seconds)]
|
||||
public float FreezeDuration { get; set; } = 5;
|
||||
|
||||
[ModdedNumberOption("Freeze Uses", 1, 5)]
|
||||
[ModdedNumberOption("ApiExample.Role.Freezer.Settings.FreezeUses", 1, 5)]
|
||||
public float FreezeUses { get; set; } = 1;
|
||||
}
|
||||
@@ -8,13 +8,13 @@ namespace MiraAPI.Example.Options.Roles;
|
||||
|
||||
public class TeleporterOptions : AbstractRoleOptionGroup<TeleporterRole>
|
||||
{
|
||||
public override string GroupName => "Teleporter";
|
||||
public override string GroupName => "ApiExample.Role.Teleporter";
|
||||
|
||||
public ModdedNumberOption TeleportCooldown { get; set; } = new("Teleport Cooldown", 10, 5, 60, 2.5f, MiraNumberSuffixes.Seconds);
|
||||
public ModdedNumberOption TeleportCooldown { get; set; } = new("ApiExample.Role.Teleporter.Settings.TeleportCooldown", 10, 5, 60, 2.5f, MiraNumberSuffixes.Seconds);
|
||||
|
||||
[ModdedNumberOption("Teleport Duration", 5, 25, 1, MiraNumberSuffixes.Seconds)]
|
||||
[ModdedNumberOption("ApiExample.Role.Teleporter.Settings.TeleportDuration", 5, 25, 1, MiraNumberSuffixes.Seconds)]
|
||||
public float TeleportDuration { get; set; } = 10;
|
||||
|
||||
[ModdedNumberOption("Zoom Distance", 4, 15)]
|
||||
[ModdedNumberOption("ApiExample.Role.Teleporter.Settings.ZoomDistance", 4, 15)]
|
||||
public float ZoomDistance { get; set; } = 6;
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="ApiExample.Role.Crewmate.Teleporter">Teleporter</string>
|
||||
<string name="ApiExample.Role.Crewmate.Teleporter.IntroBlurb">Zoom out and teleport across the map!</string>
|
||||
<string name="ApiExample.Role.Crewmate.Teleporter.MedDescription">Zoom out and teleport across the map!</string>
|
||||
<string name="ApiExample.Role.Crewmate.Teleporter.TabDescription">Zoom out and teleport across the map!</string>
|
||||
<string name="ApiExample.Role.Crewmate.Teleporter.WikiDescription">The Teleporter is a Crewmate role that can move around the map using their dope-ass ability.</string>
|
||||
<string name="ApiExample.Role.Impostor.Freezer">Freezer</string>
|
||||
<string name="ApiExample.Role.Impostor.Freezer.IntroBlurb">Get iced, nerd.</string>
|
||||
<string name="ApiExample.Role.Impostor.Freezer.MedDescription">Freeze others for a duration of time.</string>
|
||||
<string name="ApiExample.Role.Impostor.Freezer.TabDescription">Freeze another player for a duration of time.</string>
|
||||
<string name="ApiExample.Role.Impostor.Freezer.WikiDescription">The Freezer is an Impostor role that can freeze players. Or something along those lines.</string>
|
||||
<string name="ApiExample.Role.Crewmate.Mayor">Mayor</string>
|
||||
<string name="ApiExample.Role.Crewmate.Mayor.IntroBlurb">Democracy is the best policy.</string>
|
||||
<string name="ApiExample.Role.Crewmate.Mayor.MedDescription">Vote out the Impostors with more votes.
|
||||
Your votes have double the power.</string>
|
||||
<string name="ApiExample.Role.Crewmate.Mayor.TabDescription">You get one extra vote in the meeting!</string>
|
||||
<string name="ApiExample.Role.Crewmate.Mayor.WikiDescription">The Mayor is a Crewmate role that gets two votes in the meeting, instead of the singular vote other Crewmates get.</string>
|
||||
<string name="ApiExample.Role.Crewmate.Chamelon">Chamelon</string>
|
||||
<string name="ApiExample.Role.Crewmate.Chamelon.IntroBlurb">Become one with the environment.</string>
|
||||
<string name="ApiExample.Role.Crewmate.Chamelon.MedDescription">Fade out of everyone's vision by not moving.</string>
|
||||
<string name="ApiExample.Role.Crewmate.Chamelon.TabDescription">Stay invisible while not moving.</string>
|
||||
<string name="ApiExample.Role.Crewmate.Chamelon.WikiDescription">The Chamelon is a Crewmate role that slowly becomes invisible while standing still.</string>
|
||||
<string name="ApiExample.Role.Outcast.OutcastKiller">Outcast Killer</string>
|
||||
<string name="ApiExample.Role.Outcast.OutcastKiller.IntroBlurb">Kill everyone else.</string>
|
||||
<string name="ApiExample.Role.Outcast.OutcastKiller.MedDescription">Be the last outcast standing.
|
||||
Eliminate every other faction.</string>
|
||||
<string name="ApiExample.Role.Outcast.OutcastKiller.TabDescription">Outcast who can kill.</string>
|
||||
<string name="ApiExample.Role.Outcast.OutcastKiller.WikiDescription">The Outcast Killer is an Outcast role that can kill, like some sort of neutral killer...</string>
|
||||
<string name="outcast">Outcast</string>
|
||||
<string name="outcast.group">Outcast Roles</string>
|
||||
<string name="outcast.roleTitle">OUTCAST</string>
|
||||
<string name="outcast.teamIntroDescription">You are an Outcast. You do not have a team.</string>
|
||||
<string name="button.think">Think</string>
|
||||
<string name="button.think.thinking">Thinking...</string>
|
||||
<string name="button.freeze">Freeze</string>
|
||||
<string name="button.teleport">Teleport</string>
|
||||
<string name="button.callMeeting">Call Meeting</string>
|
||||
<string name="button.winGame">Win Game</string>
|
||||
<string name="modifier.captain">Captain</string>
|
||||
<string name="modifier.captain.TabDescription">You can call a meeting from anywhere on the map.</string>
|
||||
<string name="modifier.freezed">Freezed</string>
|
||||
<string name="modifier.highPriority">High Priority</string>
|
||||
<string name="modifier.highPriority.TabDescription">You are high priority! Idrk what this means either tbh...</string>
|
||||
<string name="options.exampleOptions1">Example Options 1</string>
|
||||
<string name="options.exampleOptions1.toggleOpt1">Toggle Opt 1</string>
|
||||
<string name="options.exampleOptions1.toggleOpt2">Toggle Opt 2</string>
|
||||
<string name="options.exampleOptions1.numberOpt">Number Opt</string>
|
||||
<string name="options.exampleOptions1.bestApi">Best API</string>
|
||||
<string name="options.exampleOptions2">Example Options 2</string>
|
||||
<string name="options.exampleOptions2.youMustChoseAPlayer">YOU MUST CHOSE A PLAYER</string>
|
||||
<string name="options.exampleOptions2.ehWhatever">Eh whatever</string>
|
||||
<string name="options.exampleOptions2.toggleOption1">Toggle Option 1</string>
|
||||
<string name="options.exampleOptions2.toggleOption2">Toggle Option 2</string>
|
||||
<string name="options.exampleOptions2.enumOpt">Enum Opt</string>
|
||||
<string name="options.captainSettings">Captain Settings</string>
|
||||
<string name="options.captainSettings.amount">Amount</string>
|
||||
<string name="options.captainSettings.chance">Chance</string>
|
||||
<string name="options.captainSettings.uses">Uses</string>
|
||||
<string name="options.freezeModifierSettings">Freeze</string>
|
||||
<string name="options.freezeModifierSettings.useColor">Use Color</string>
|
||||
<string name="options.generalModifier">General</string>
|
||||
<string name="options.generalModifier.someBooleanOption">Some Boolean Option</string>
|
||||
<string name="options.generalModifier.numberOption">Number Option</string>
|
||||
<string name="options.freezerRoleSettings">Custom Role</string>
|
||||
<string name="ApiExample.Role.Freezer.Settings.FreezeDuration">Freeze Duration</string>
|
||||
<string name="ApiExample.Role.Freezer.Settings.FreezeUses">Freeze Uses</string>
|
||||
<string name="ApiExample.Role.Teleporter.Settings.TeleportCooldown">Teleport Cooldown</string>
|
||||
<string name="ApiExample.Role.Teleporter.Settings.TeleportDuration">Teleport Duration</string>
|
||||
<string name="ApiExample.Role.Teleporter.Settings.ZoomDistance">Zoom Distance</string>
|
||||
<string name="settings.miraExample">Mira Example</string>
|
||||
<string name="settings.miraExample.exampleBool">Example Bool</string>
|
||||
<string name="settings.miraExample.exampleBool2">Example Bool 2</string>
|
||||
<string name="settings.miraExample.slider">Slider</string>
|
||||
<string name="settings.miraExample.exampleNumber">Example Number</string>
|
||||
<string name="settings.miraExample.exampleMultiplier">Example Multplier</string>
|
||||
<string name="settings.miraExample.exampleEnum">Example Enum</string>
|
||||
<string name="settings.miraExample.button.exampleButton">Example Button</string>
|
||||
<string name="gameover.outcastKiller.win">Outcast Killer Wins!</string>
|
||||
<string name="color.cerulean">Cerulean</string>
|
||||
<string name="color.rose">Rose</string>
|
||||
<string name="color.gold">Gold</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,66 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="ApiExample.Role.Teleporter">传送者</string>
|
||||
<string name="ApiExample.Role.Teleporter.IntroBlurb">缩小视野并在地图上传送!</string>
|
||||
<string name="ApiExample.Role.Teleporter.MedDescription">缩小视野并在地图上传送!</string>
|
||||
<string name="ApiExample.Role.Teleporter.TabDescription">缩小视野并在地图上传送!</string>
|
||||
<string name="ApiExample.Role.Freezer">冰冻者</string>
|
||||
<string name="ApiExample.Role.Freezer.TabDescription">将其他玩家冰冻一段时间。</string>
|
||||
<string name="ApiExample.Role.Crewmate.Mayor">市长</string>
|
||||
<string name="ApiExample.Role.Crewmate.Mayor.TabDescription">你拥有额外投票权!</string>
|
||||
<string name="ApiExample.Role.Crewmate.Chamelon">变色龙</string>
|
||||
<string name="ApiExample.Role.Crewmate.Chamelon.TabDescription">静止不动时保持隐身。</string>
|
||||
<string name="ApiExample.Role.Outcast.OutcastKiller">流放杀手</string>
|
||||
<string name="ApiExample.Role.Outcast.OutcastKiller.TabDescription">可以击杀的流放者。</string>
|
||||
<string name="outcast">流放者</string>
|
||||
<string name="outcast.roleTitle">流放者</string>
|
||||
<string name="outcast.teamIntroDescription">你是流放者,你没有队伍。</string>
|
||||
<string name="button.think">思考</string>
|
||||
<string name="button.think.thinking">思考中...</string>
|
||||
<string name="button.freeze">冰冻</string>
|
||||
<string name="button.teleport">传送</string>
|
||||
<string name="button.callMeeting">召集会议</string>
|
||||
<string name="button.winGame">赢得游戏</string>
|
||||
<string name="modifier.captain">队长</string>
|
||||
<string name="modifier.captain.TabDescription">你可以在地图上任意位置召集会议。</string>
|
||||
<string name="modifier.freezed">已被冰冻</string>
|
||||
<string name="modifier.highPriority">高优先级</string>
|
||||
<string name="modifier.highPriority.TabDescription">你是高优先级!老实说我也不太清楚这是什么意思……</string>
|
||||
<string name="options.exampleOptions1">示例选项组 1</string>
|
||||
<string name="options.exampleOptions1.toggleOpt1">开关选项 1</string>
|
||||
<string name="options.exampleOptions1.toggleOpt2">开关选项 2</string>
|
||||
<string name="options.exampleOptions1.numberOpt">数字选项</string>
|
||||
<string name="options.exampleOptions1.bestApi">谁是最好的API</string>
|
||||
<string name="options.exampleOptions2">示例选项组 2</string>
|
||||
<string name="options.exampleOptions2.youMustChoseAPlayer">你必须选择一个玩家</string>
|
||||
<string name="options.exampleOptions2.ehWhatever">咕咕嘎嘎</string>
|
||||
<string name="options.exampleOptions2.toggleOption1">开关选项 1</string>
|
||||
<string name="options.exampleOptions2.toggleOption2">开关选项 2</string>
|
||||
<string name="options.exampleOptions2.enumOpt">枚举选项</string>
|
||||
<string name="options.captainSettings">队长设置</string>
|
||||
<string name="options.captainSettings.amount">数量</string>
|
||||
<string name="options.captainSettings.chance">概率</string>
|
||||
<string name="options.captainSettings.uses">使用次数</string>
|
||||
<string name="options.freezeModifierSettings">冰冻</string>
|
||||
<string name="options.freezeModifierSettings.useColor">使用颜色</string>
|
||||
<string name="options.generalModifier">通用</string>
|
||||
<string name="options.generalModifier.someBooleanOption">某个布尔选项</string>
|
||||
<string name="options.generalModifier.numberOption">数字选项</string>
|
||||
<string name="ApiExample.Role.Freezer.Settings.FreezeDuration">冰冻时长</string>
|
||||
<string name="ApiExample.Role.Freezer.Settings.FreezeUses">冰冻次数</string>
|
||||
<string name="ApiExample.Role.Teleporter.Settings.TeleportCooldown">传送冷却</string>
|
||||
<string name="ApiExample.Role.Teleporter.Settings.TeleportDuration">传送持续时间</string>
|
||||
<string name="ApiExample.Role.Teleporter.Settings.ZoomDistance">缩放距离</string>
|
||||
<string name="settings.miraExample">Mira 示例插件</string>
|
||||
<string name="settings.miraExample.exampleBool">示例布尔</string>
|
||||
<string name="settings.miraExample.exampleBool2">示例布尔 2</string>
|
||||
<string name="settings.miraExample.slider">滑块</string>
|
||||
<string name="settings.miraExample.exampleNumber">示例数字</string>
|
||||
<string name="settings.miraExample.exampleMultiplier">示例倍数</string>
|
||||
<string name="settings.miraExample.exampleEnum">示例枚举</string>
|
||||
<string name="settings.miraExample.button.exampleButton">示例按钮</string>
|
||||
<string name="gameover.outcastKiller.win">流放杀手获胜!</string>
|
||||
<string name="color.cerulean">天蓝</string>
|
||||
<string name="color.rose">玫瑰红</string>
|
||||
<string name="color.gold">金色</string>
|
||||
</resources>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
@@ -10,9 +10,8 @@ namespace MiraAPI.Example.Roles;
|
||||
|
||||
public class ChameloenRole : CrewmateRole, ICustomRole
|
||||
{
|
||||
public string RoleName => "Chamelon";
|
||||
public string RoleLongDescription => "Stay invisible while not moving.";
|
||||
public string RoleDescription => RoleLongDescription;
|
||||
public string IdPart => "Chamelon";
|
||||
public string IdPrefix => "ApiExample.Role.Crewmate";
|
||||
public Color RoleColor => Palette.AcceptedGreen;
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
|
||||
|
||||
@@ -22,7 +21,9 @@ public class ChameloenRole : CrewmateRole, ICustomRole
|
||||
{
|
||||
OptionsScreenshot = ExampleAssets.Banner,
|
||||
Icon = MiraAssets.CrewmateFile,
|
||||
IconTmp = TmpSpriteUtils.CreateSpriteAsset(MiraAssets.CrewmateFile.LoadAsset(), "ApiExample.Role.Impostor.ChameleonRole"),
|
||||
IconTmp = TmpSpriteUtils.CreateSpriteAsset(
|
||||
MiraAssets.CrewmateFile.LoadAsset(),
|
||||
"ApiExample.Role.Impostor.ChameleonRole"),
|
||||
IntroSound = CustomRoleUtils.GetIntroSound(RoleTypes.Shapeshifter),
|
||||
};
|
||||
|
||||
@@ -56,12 +57,18 @@ public class ChameloenRole : CrewmateRole, ICustomRole
|
||||
{
|
||||
SpriteRenderer rend = Player.cosmetics.currentBodySprite.BodySprite;
|
||||
TextMeshPro tmp = Player.cosmetics.nameText;
|
||||
tmp.color = Color.Lerp(tmp.color, new Color(tmp.color.r, tmp.color.g, tmp.color.b, Player.AmOwner ? 0.3f : 0), Time.deltaTime * 4f);
|
||||
tmp.color = Color.Lerp(
|
||||
tmp.color,
|
||||
new Color(tmp.color.r, tmp.color.g, tmp.color.b, Player.AmOwner ? 0.3f : 0),
|
||||
Time.deltaTime * 4f);
|
||||
rend.color = Color.Lerp(rend.color, new Color(1, 1, 1, Player.AmOwner ? 0.3f : 0), Time.deltaTime * 4f);
|
||||
|
||||
foreach (var cosmetic in Player.cosmetics.transform.GetComponentsInChildren<SpriteRenderer>())
|
||||
{
|
||||
cosmetic.color = Color.Lerp(cosmetic.color, new Color(1, 1, 1, Player.AmOwner ? 0.3f : 0), Time.deltaTime * 4f);
|
||||
cosmetic.color = Color.Lerp(
|
||||
cosmetic.color,
|
||||
new Color(1, 1, 1, Player.AmOwner ? 0.3f : 0),
|
||||
Time.deltaTime * 4f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,6 +82,7 @@ public class ChameloenRole : CrewmateRole, ICustomRole
|
||||
{
|
||||
cosmetic.color = Color.white;
|
||||
}
|
||||
|
||||
Player.cosmetics.currentBodySprite.BodySprite.color = Color.white;
|
||||
Player.cosmetics.nameText.color = Color.white;
|
||||
}
|
||||
|
||||
@@ -6,16 +6,15 @@ namespace MiraAPI.Example.Roles;
|
||||
|
||||
public class FreezerRole : ImpostorRole, ICustomRole
|
||||
{
|
||||
public string RoleName => "Freezer";
|
||||
public string RoleLongDescription => "Freeze another player for a duration of time.";
|
||||
public string RoleDescription => RoleLongDescription;
|
||||
public string IdPart => "Freezer";
|
||||
public string IdPrefix => "ApiExample.Role.Impostor";
|
||||
public Color RoleColor => Palette.Blue;
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Impostor;
|
||||
|
||||
public CustomRoleConfiguration Configuration => new CustomRoleConfiguration(this)
|
||||
{
|
||||
Icon = MiraAssets.ImpostorFile,
|
||||
IconTmp = TmpSpriteUtils.CreateSpriteAsset(MiraAssets.ImpostorFile.LoadAsset(), "ApiExample.Role.Impostor.FreezerRole"),
|
||||
IconTmp = TmpSpriteUtils.CreateSpriteAsset(MiraAssets.ImpostorFile.LoadAsset(), "ApiExample.Role.Impostor.Freezer"),
|
||||
OptionsScreenshot = ExampleAssets.Banner,
|
||||
MaxRoleCount = 2,
|
||||
};
|
||||
|
||||
@@ -5,9 +5,8 @@ namespace MiraAPI.Example.Roles;
|
||||
|
||||
public class MayorRole : CrewmateRole, ICustomRole
|
||||
{
|
||||
public string RoleName => "Mayor";
|
||||
public string RoleLongDescription => "You get extra votes!";
|
||||
public string RoleDescription => RoleLongDescription;
|
||||
public string IdPart => "Mayor";
|
||||
public string IdPrefix => "ApiExample.Role.Crewmate";
|
||||
public Color RoleColor => new Color32(221, 176, 152, 255);
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
|
||||
public CustomRoleConfiguration Configuration => new(this);
|
||||
|
||||
@@ -8,9 +8,8 @@ namespace MiraAPI.Example.Roles;
|
||||
|
||||
public class NeutralKillerRole : ImpostorRole, ICustomRole
|
||||
{
|
||||
public string RoleName => "Outcast Killer";
|
||||
public string RoleDescription => "Outcast who can kill.";
|
||||
public string RoleLongDescription => RoleDescription;
|
||||
public string IdPart => "OutcastKiller";
|
||||
public string IdPrefix => "ApiExample.Role.Outcast";
|
||||
public Color RoleColor => Color.magenta;
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Custom;
|
||||
|
||||
@@ -21,13 +20,13 @@ public class NeutralKillerRole : ImpostorRole, ICustomRole
|
||||
CanUseVent = true,
|
||||
};
|
||||
|
||||
public RoleOptionsGroup RoleOptionsGroup { get; } = new("Outcast", Color.gray);
|
||||
public RoleOptionsGroup RoleOptionsGroup { get; } = new("outcast.group", Color.gray);
|
||||
|
||||
[HideFromIl2Cpp]
|
||||
public TeamIntroConfiguration? IntroConfiguration { get; } = new(
|
||||
Color.gray,
|
||||
"OUTCAST",
|
||||
"You are an Outcast. You do not have a team.");
|
||||
"outcast.roleTitle",
|
||||
"outcast.teamIntroDescription");
|
||||
|
||||
public override void SpawnTaskHeader(PlayerControl playerControl)
|
||||
{
|
||||
|
||||
@@ -5,9 +5,8 @@ namespace MiraAPI.Example.Roles;
|
||||
|
||||
public class TeleporterRole : CrewmateRole, ICustomRole
|
||||
{
|
||||
public string RoleName => "Teleporter";
|
||||
public string RoleLongDescription => "Zoom out and teleport across the map!";
|
||||
public string RoleDescription => RoleLongDescription;
|
||||
public string IdPart => "Teleporter";
|
||||
public string IdPrefix => "ApiExample.Role.Crewmate";
|
||||
public Color RoleColor => new Color32(221, 176, 152, 255);
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Localization.Utilities;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Colors;
|
||||
@@ -43,7 +43,7 @@ public sealed class CustomColor(StringNames name, Color32 mainColor, Color32 sha
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public CustomColor(string name, Color32 mainColor, Color32 shadowColor) : this(CustomStringName.CreateAndRegister(name), mainColor, shadowColor)
|
||||
public CustomColor(string name, Color32 mainColor, Color32 shadowColor) : this(MiraLocaleManager.GetOrCreateLocaleString(name), mainColor, shadowColor)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ public static class PaletteManager
|
||||
{
|
||||
var colors = CustomColors.Select(x => x.MainColor).ToArray();
|
||||
var shadowColors = CustomColors.Select(x => x.ShadowColor).ToArray();
|
||||
var stringNames = CustomColors.Select(x => x.Name).ToArray();
|
||||
var stringNames = CustomColors.Select(x =>
|
||||
x.Name).ToArray();
|
||||
|
||||
Palette.PlayerColors = Palette.PlayerColors.ToArray().AddRangeToArray(colors);
|
||||
Palette.ShadowColors = Palette.ShadowColors.ToArray().AddRangeToArray(shadowColors);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Events.Mira;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired by Mira API to adjust the UI buttons at the top right of the screen.
|
||||
/// </summary>
|
||||
public class UiButtonPostResetEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="GameObject"/> parent for the very top UI row.
|
||||
/// </summary>
|
||||
public GameObject MainTopUiRow { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="GameObject"/> parent for the second top UI row.
|
||||
/// </summary>
|
||||
public GameObject SecondTopUiRow { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UiButtonPostResetEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="topUiRow">The <see cref="GameObject"/> for the top UI row.</param>
|
||||
/// <param name="secondUiRow">The <see cref="GameObject"/> for the second UI row.</param>
|
||||
public UiButtonPostResetEvent(GameObject topUiRow, GameObject secondUiRow)
|
||||
{
|
||||
MainTopUiRow = topUiRow;
|
||||
SecondTopUiRow = secondUiRow;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace MiraAPI.Events.Mira;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired by Mira API prior to adjusting the UI buttons at the top right of the screen.
|
||||
/// </summary>
|
||||
public class UiButtonResetEvent : MiraEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UiButtonResetEvent"/> class.
|
||||
/// </summary>
|
||||
public UiButtonResetEvent()
|
||||
{
|
||||
// nothing!
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using AmongUs.GameOptions;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -32,7 +33,7 @@ public abstract class AbstractGameMode : IOptionable
|
||||
public abstract string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the game mode description.
|
||||
/// Gets the game mode color to display on the lobby pane.
|
||||
/// </summary>
|
||||
public virtual Color Color { get; } = Color.white;
|
||||
|
||||
@@ -42,14 +43,14 @@ public abstract class AbstractGameMode : IOptionable
|
||||
public virtual LoadableAsset<Sprite>? Icon => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the icon of the gamemode for use on the options pop-up.
|
||||
/// Gets or sets 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>
|
||||
public string ColoredName => $"<color=#{this.Color.ToHtmlStringRGBA()}>{this.Name}</color>";
|
||||
public string ColoredName => $"<color=#{Color.ToHtmlStringRGBA()}>{MiraLocaleManager.Get(Name)}</color>";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the game mode id.
|
||||
|
||||
@@ -11,10 +11,10 @@ namespace MiraAPI.GameModes;
|
||||
public class ClassicMode : AbstractGameMode
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string Name => "Classic";
|
||||
public override string Name => "MiraApi.Gamemode.Classic";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string Description => "The classic Among Us experience!\nFind the Impostors or deceive the Crew.";
|
||||
public override string Description => "MiraApi.Gamemode.Classic.Description";
|
||||
|
||||
public override LoadableAsset<Sprite>? Icon => MiraAssets.ClassicGamemodeIcon;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.PluginLoading;
|
||||
using Reactor.Utilities;
|
||||
|
||||
@@ -58,7 +59,7 @@ public static class CustomGameModeManager
|
||||
/// <summary>
|
||||
/// Checks to see if the current game mode is an instance of the HNS mode.
|
||||
/// </summary>
|
||||
/// <returns>True if the Hide & Seek mode is the current one.</returns>
|
||||
/// <returns>True if the Hide n Seek mode is the current one.</returns>
|
||||
public static bool IsHideNSeek() => ActiveMode != null && ActiveMode.GetType().IsAssignableTo(typeof(HideAndSeekMode));
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,6 +6,7 @@ using MiraAPI.GameOptions;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Patches.GameModes;
|
||||
using MiraAPI.Patches.Options;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Localization.Utilities;
|
||||
@@ -48,17 +49,17 @@ public static class GameModeOption
|
||||
internal static StringOption OptionBehaviour { get; set; } = null!;
|
||||
|
||||
internal static int _lastValue;
|
||||
internal static readonly StringNames GamemodeName = CustomStringName.CreateAndRegister("Gamemode");
|
||||
internal static readonly StringNames CustomName = CustomStringName.CreateAndRegister("Custom");
|
||||
internal static readonly StringNames GamemodeName = MiraLocaleManager.GetOrCreateLocaleString("Gamemode");
|
||||
internal static readonly StringNames CustomName = MiraLocaleManager.GetOrCreateLocaleString("Custom");
|
||||
internal static readonly Dictionary<uint, StringNames> Values = new()
|
||||
{
|
||||
[0] = CustomStringName.CreateAndRegister("Classic"),
|
||||
[0] = MiraLocaleManager.GetOrCreateLocaleString("MiraApi.Gamemode.Classic"),
|
||||
};
|
||||
|
||||
internal static void AddOption(AbstractGameMode mode)
|
||||
{
|
||||
if (!Values.ContainsKey(mode.ID))
|
||||
Values.Add(mode.ID, CustomStringName.CreateAndRegister(mode.ColoredName));
|
||||
Values.Add(mode.ID, MiraLocaleManager.GetOrCreateLocaleString(mode.Name));
|
||||
}
|
||||
/*[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.CreateSettings))]
|
||||
[HarmonyPostfix]
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace MiraAPI.GameModes;
|
||||
public class HideAndSeekMode : AbstractGameMode
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string Name => "Hide n Seek";
|
||||
public override string Name => "MiraApi.Gamemode.HideAndSeek";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string Description => "You can run, but you can't hide!\nOutlive the timer or eliminate the crew.";
|
||||
public override string Description => "MiraApi.Gamemode.HideAndSeek.Description";
|
||||
|
||||
// TODO: Once the Hide n Seek port is ready for release, we will remove this.
|
||||
public override bool HideMode => !MiraApiPlugin.IsDevBuild;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using MiraAPI.GameOptions.OptionTypes;
|
||||
using MiraAPI.Translation;
|
||||
|
||||
namespace MiraAPI.GameOptions.Attributes;
|
||||
|
||||
@@ -13,7 +14,7 @@ public class ModdedEnumOptionAttribute(string title, Type enumType, string[]? va
|
||||
{
|
||||
internal override IModdedOption CreateOption(object? value, PropertyInfo property)
|
||||
{
|
||||
var opt = new ModdedEnumOption(Title, (int)(value ?? 0), enumType, values);
|
||||
var opt = new ModdedEnumOption(Title.Translate(), (int)(value ?? 0), enumType, values);
|
||||
return opt;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using MiraAPI.GameOptions.OptionTypes;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
|
||||
namespace MiraAPI.GameOptions.Attributes;
|
||||
@@ -22,7 +23,7 @@ public class ModdedNumberOptionAttribute(
|
||||
internal override IModdedOption CreateOption(object? value, PropertyInfo property)
|
||||
{
|
||||
return new ModdedNumberOption(
|
||||
Title,
|
||||
Title.Translate(),
|
||||
(float)(value ?? min + increment),
|
||||
min,
|
||||
max,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using MiraAPI.GameOptions.OptionTypes;
|
||||
using MiraAPI.Translation;
|
||||
|
||||
namespace MiraAPI.GameOptions.Attributes;
|
||||
|
||||
@@ -13,7 +14,7 @@ public class ModdedToggleOptionAttribute(string title) : ModdedOptionAttribute(t
|
||||
{
|
||||
internal override IModdedOption CreateOption(object? value, PropertyInfo property)
|
||||
{
|
||||
var toggleOpt = new ModdedToggleOption(Title, (bool)(value ?? false));
|
||||
var toggleOpt = new ModdedToggleOption(Title.Translate(), (bool)(value ?? false));
|
||||
return toggleOpt;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Translation;
|
||||
using Reactor.Localization.Utilities;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
@@ -37,8 +38,8 @@ public class ModdedEnumOption : ModdedOption<int>
|
||||
data.Title = StringName;
|
||||
data.Type = global::OptionTypes.String;
|
||||
data.Values = values is null ?
|
||||
Enum.GetNames(enumType).Select(CustomStringName.CreateAndRegister).ToArray()
|
||||
: [.. values.Select(CustomStringName.CreateAndRegister)];
|
||||
Enum.GetNames(enumType).Select(MiraLocaleManager.GetOrCreateLocaleString).ToArray()
|
||||
: [.. values.Select(MiraLocaleManager.GetOrCreateLocaleString)];
|
||||
|
||||
data.Index = Value;
|
||||
}
|
||||
@@ -136,8 +137,8 @@ public class ModdedEnumOption<T> : ModdedOption<T> where T : Enum
|
||||
data.Title = StringName;
|
||||
data.Type = global::OptionTypes.String;
|
||||
data.Values = values is null ?
|
||||
Enum.GetNames(typeof(T)).Select(CustomStringName.CreateAndRegister).ToArray()
|
||||
: [.. values.Select(CustomStringName.CreateAndRegister)];
|
||||
Enum.GetNames(typeof(T)).Select(MiraLocaleManager.GetOrCreateLocaleString).ToArray()
|
||||
: [.. values.Select(MiraLocaleManager.GetOrCreateLocaleString)];
|
||||
|
||||
data.Index = Convert.ToInt32(Value, NumberFormatInfo.InvariantInfo);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Translation;
|
||||
using Reactor.Localization.Utilities;
|
||||
using Reactor.Networking.Rpc;
|
||||
using UnityEngine;
|
||||
@@ -78,10 +79,10 @@ public abstract class ModdedOption<T> : IModdedOption
|
||||
protected ModdedOption(string title, T defaultValue, bool includeInPreset = true)
|
||||
{
|
||||
Id = ModdedOptionsManager.NextId;
|
||||
Title = title;
|
||||
Title = title.Translate();
|
||||
DefaultValue = defaultValue;
|
||||
Value = defaultValue;
|
||||
StringName = CustomStringName.CreateAndRegister(Title);
|
||||
StringName = MiraLocaleManager.GetOrCreateLocaleString(Title);
|
||||
Visible = () => true;
|
||||
IncludeInPreset = includeInPreset;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using Il2CppSystem.Collections.Generic;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
@@ -65,7 +66,7 @@ public class ModdedPlayerOption : ModdedOption<int>
|
||||
playerOption.OnValueChanged = (Il2CppSystem.Action<OptionBehaviour>)ValueChanged;
|
||||
|
||||
playerOption.Title = StringName;
|
||||
playerOption.TitleText.text = TranslationController.Instance.GetString(StringName);
|
||||
playerOption.TitleText.text = Title.Translate();
|
||||
playerOption.Values = Values;
|
||||
playerOption.Value = Value;
|
||||
playerOption.playerIndex = filteredList.FindIndex(p => p.PlayerId == Value);
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Translation;
|
||||
using Reactor.Localization.Utilities;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
@@ -56,7 +57,7 @@ public class ModdedStringOption : ModdedOption<string>
|
||||
newVals.Insert(index, value);
|
||||
Values = newVals.ToArray();
|
||||
var newStrVals = StringNameValues.ToList();
|
||||
newStrVals.Insert(index, CustomStringName.CreateAndRegister(value));
|
||||
newStrVals.Insert(index, MiraLocaleManager.GetOrCreateLocaleString(value));
|
||||
StringNameValues = newStrVals.ToArray();
|
||||
}
|
||||
|
||||
@@ -108,7 +109,7 @@ public class ModdedStringOption : ModdedOption<string>
|
||||
|
||||
data.Title = StringName;
|
||||
data.Type = global::OptionTypes.String;
|
||||
StringNameValues = values.Select(CustomStringName.CreateAndRegister).ToArray();
|
||||
StringNameValues = values.Select(MiraLocaleManager.GetOrCreateLocaleString).ToArray();
|
||||
data.Values = StringNameValues;
|
||||
|
||||
data.Index = GetIndex(Value, 3);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Translation;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
@@ -35,7 +36,7 @@ public class ModdedToggleOption : ModdedOption<bool>
|
||||
toggleOption.SetUpFromData(Data, 20);
|
||||
|
||||
toggleOption.Title = StringName;
|
||||
toggleOption.TitleText.text = Title;
|
||||
toggleOption.TitleText.text = Title.Translate();
|
||||
toggleOption.CheckMark.enabled = Value;
|
||||
toggleOption.OnValueChanged = (Il2CppSystem.Action<OptionBehaviour>)ValueChanged;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using BepInEx.Unity.IL2CPP.Utils.Collections;
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.HnsReimplemented.Options;
|
||||
using MiraAPI.Utilities;
|
||||
@@ -245,6 +246,7 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
}
|
||||
|
||||
[HideFromIl2Cpp]
|
||||
private IEnumerator BeepAlmostEverySecond()
|
||||
{
|
||||
while (!IsFinalCountdown)
|
||||
|
||||
@@ -5,6 +5,7 @@ using MiraAPI.Events.Mira;
|
||||
using MiraAPI.Keybinds;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.Patches;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Rewired;
|
||||
@@ -150,7 +151,7 @@ public abstract class CustomActionButton
|
||||
|
||||
Button = Object.Instantiate(HudManager.Instance.AbilityButton, parent);
|
||||
Button.name = Name + "Button";
|
||||
Button.OverrideText(Name.ToUpperInvariant());
|
||||
Button.OverrideText(Name.Translate().ToUpperInvariant());
|
||||
|
||||
Button.graphic.sprite = Sprite.LoadAsset();
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ public sealed class MiraHudHelper(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
{
|
||||
ExtraUiTopRight = new GameObject("ExtraUiTopRight")
|
||||
{
|
||||
layer = UiTopRight.layer
|
||||
layer = UiTopRight.layer,
|
||||
};
|
||||
ExtraUiTopRight.transform.SetParent(instance.MapButton.transform.parent.parent, false);
|
||||
|
||||
|
||||
@@ -39,4 +39,9 @@ public interface ILocalSetting
|
||||
/// <param name="last">Whether it's the last on the row.</param>
|
||||
/// <returns>The created setting's <see cref="GameObject"/>.</returns>
|
||||
GameObject? CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last);
|
||||
|
||||
/// <summary>
|
||||
/// Used to refresh the setting's information, usually for localization.
|
||||
/// </summary>
|
||||
void RefreshOption();
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -28,6 +29,8 @@ public class LocalSettingsButton(string text, Action onClick)
|
||||
/// </summary>
|
||||
public LocalSettingsTab? Tab { get; internal set; }
|
||||
|
||||
private TextMeshPro _btnText { get; set; }
|
||||
|
||||
internal GameObject CreateButton(ToggleButtonBehaviour toggle, Transform parent, ref float offset, ref int order, bool last)
|
||||
{
|
||||
var button = Object.Instantiate(toggle, parent).GetComponent<PassiveButton>();
|
||||
@@ -51,7 +54,8 @@ public class LocalSettingsButton(string text, Action onClick)
|
||||
button.transform.localPosition = new Vector3(order == 1 ? -1.185f : 1.185f, 1.85f - offset, -7);
|
||||
}
|
||||
|
||||
tmp.text = Text;
|
||||
tmp.text = Text.Translate();
|
||||
_btnText = tmp;
|
||||
button.name = Text;
|
||||
button.OnClick = new UnityEngine.UI.Button.ButtonClickedEvent();
|
||||
rollover.OutColor = Tab!.TabAppearance.ButtonColor;
|
||||
@@ -74,4 +78,9 @@ public class LocalSettingsButton(string text, Action onClick)
|
||||
|
||||
return button.gameObject;
|
||||
}
|
||||
|
||||
public void RefreshButton()
|
||||
{
|
||||
_btnText.text = Text.Translate();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
using System.Collections.Generic;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.LocalSettings.SettingTypes;
|
||||
using MiraAPI.Patches.LocalSettings;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -47,11 +49,21 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
/// </summary>
|
||||
public TabGroup? TabButton { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of <see cref="TextMeshPro"/>s alongside the locale keys for them.
|
||||
/// </summary>
|
||||
public static Dictionary<TextMeshPro, string> TabGroups { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of <see cref="ILocalSetting"/>s.
|
||||
/// </summary>
|
||||
public List<ILocalSetting> Settings { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of <see cref="TextMeshPro"/>s alongside the locale keys for them.
|
||||
/// </summary>
|
||||
public Dictionary<TextMeshPro, string> Labels { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of <see cref="LocalSettingsButton"/>s.
|
||||
/// </summary>
|
||||
@@ -73,12 +85,25 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to open the tab.
|
||||
/// Refreshes setting names upon opening the tab.
|
||||
/// Override for custom behavior.
|
||||
/// </summary>
|
||||
public virtual void Open()
|
||||
{
|
||||
OptionsMenuPatches.Instance?.OpenTabGroup(TabIndex);
|
||||
foreach (var setting in Settings)
|
||||
{
|
||||
setting.RefreshOption();
|
||||
}
|
||||
foreach (var button in Buttons)
|
||||
{
|
||||
button.RefreshButton();
|
||||
}
|
||||
|
||||
foreach (var label in Labels)
|
||||
{
|
||||
label.Key.text =
|
||||
$"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\"><b>{label.Value.Translate()}</b></font>";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -216,7 +241,8 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
tabButtonText.transform.localPosition = new Vector3(0.078f, 0, 0);
|
||||
tabButtonText.transform.localScale = new Vector3(0.9f, 0.9f);
|
||||
tabButtonText.alignment = TextAlignmentOptions.Right;
|
||||
tabButtonText.text = $"<b>{GetShortName(TabName)}</b>";
|
||||
tabButtonText.text = $"<b>{GetShortName(TabName.Translate())}</b>";
|
||||
TabGroups.Add(tabButtonText, TabName);
|
||||
|
||||
var tabButton = tabButtonObject.GetComponent<PassiveButton>();
|
||||
var rollover = tabButtonObject.Rollover;
|
||||
@@ -244,7 +270,7 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
tabButtonText.gameObject.SetActive(true);
|
||||
tabButtonText.transform.localPosition = new Vector3(-0.024f, 0, 0);
|
||||
tabButtonText.maxVisibleCharacters = int.MaxValue;
|
||||
tabButtonText.text = TabName;
|
||||
tabButtonText.text = TabName.Translate();
|
||||
tabButtonText.alignment = TextAlignmentOptions.Left;
|
||||
tabButtonRend?.gameObject.SetActive(!TabAppearance.HideIconOnHover);
|
||||
}));
|
||||
@@ -266,13 +292,13 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
|
||||
tabButtonText.transform.localPosition = new Vector3(0.1f, 0, 0);
|
||||
tabButtonText.maxVisibleCharacters = 4;
|
||||
tabButtonText.text = $"<b>{GetShortName(TabName)}</b>";
|
||||
tabButtonText.text = $"<b>{GetShortName(TabName.Translate())}</b>";
|
||||
}));
|
||||
|
||||
return tabButtonObject.gameObject;
|
||||
}
|
||||
|
||||
private static void CreateLabel(GameObject template, Transform parent, string text, ref float offset)
|
||||
private void CreateLabel(GameObject template, Transform parent, string text, ref float offset)
|
||||
{
|
||||
var label = Object.Instantiate(template, parent);
|
||||
label.transform.localPosition = new Vector3(0, 1.85f - offset);
|
||||
@@ -280,7 +306,8 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
label.name = text;
|
||||
|
||||
var tmp = label.GetComponent<TextMeshPro>();
|
||||
tmp.text = $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\"><b>{text}</b></font>";
|
||||
Labels.Add(tmp, text);
|
||||
tmp.text = $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\"><b>{text.Translate()}</b></font>";
|
||||
tmp.alignment = TextAlignmentOptions.Center;
|
||||
|
||||
var meshRend = label.GetComponent<MeshRenderer>();
|
||||
@@ -290,7 +317,7 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
offset += 0.5f;
|
||||
}
|
||||
|
||||
private static string GetShortName(string name)
|
||||
internal static string GetShortName(string name)
|
||||
{
|
||||
var shortName = string.Empty;
|
||||
name.Split(' ').Do(x => shortName += x[0]);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -25,6 +26,10 @@ public class LocalEnumSetting : LocalSettingBase<int>
|
||||
/// </summary>
|
||||
public string[] Values { get; }
|
||||
|
||||
private SpriteRenderer _highlight { get; set; }
|
||||
|
||||
private TextMeshPro _btnText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LocalEnumSetting"/> class.
|
||||
/// </summary>
|
||||
@@ -53,6 +58,7 @@ public class LocalEnumSetting : LocalSettingBase<int>
|
||||
{
|
||||
var button = Object.Instantiate(toggle, parent).GetComponent<PassiveButton>();
|
||||
var tmp = button.transform.FindChild("Text_TMP").GetComponent<TextMeshPro>();
|
||||
_btnText = tmp;
|
||||
var rollover = button.GetComponent<ButtonRolloverHandler>();
|
||||
tmp.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
button.gameObject.SetActive(true);
|
||||
@@ -62,6 +68,7 @@ public class LocalEnumSetting : LocalSettingBase<int>
|
||||
var highlight = button.transform.FindChild("ButtonHighlight")?.GetComponent<SpriteRenderer>();
|
||||
if (highlight != null)
|
||||
{
|
||||
_highlight = highlight;
|
||||
highlight.color = Tab!.TabAppearance.EnumHoverColor;
|
||||
highlight.gameObject.SetActive(false);
|
||||
}
|
||||
@@ -124,9 +131,19 @@ public class LocalEnumSetting : LocalSettingBase<int>
|
||||
return button.gameObject;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void RefreshOption()
|
||||
{
|
||||
_btnText.text = GetValueText();
|
||||
if (_highlight)
|
||||
{
|
||||
_highlight.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetValueText()
|
||||
{
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name}: <b>{Values[GetValue()]}</font></b>";
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name.Translate()}: <b>{Values[GetValue()].Translate()}</font></b>";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -34,6 +35,10 @@ public class LocalNumberSetting : LocalSettingBase<float>
|
||||
/// </summary>
|
||||
public MiraNumberSuffixes SuffixType { get; }
|
||||
|
||||
private SpriteRenderer _highlight { get; set; }
|
||||
|
||||
private TextMeshPro _btnText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LocalNumberSetting"/> class.
|
||||
/// </summary>
|
||||
@@ -64,6 +69,7 @@ public class LocalNumberSetting : LocalSettingBase<float>
|
||||
{
|
||||
var button = Object.Instantiate(toggle, parent).GetComponent<PassiveButton>();
|
||||
var tmp = button.transform.FindChild("Text_TMP").GetComponent<TextMeshPro>();
|
||||
_btnText = tmp;
|
||||
var rollover = button.GetComponent<ButtonRolloverHandler>();
|
||||
tmp.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
button.gameObject.SetActive(true);
|
||||
@@ -73,6 +79,7 @@ public class LocalNumberSetting : LocalSettingBase<float>
|
||||
var highlight = button.transform.FindChild("ButtonHighlight")?.GetComponent<SpriteRenderer>();
|
||||
if (highlight != null)
|
||||
{
|
||||
_highlight = highlight;
|
||||
highlight.color = Tab!.TabAppearance.NumberHoverColor;
|
||||
highlight.gameObject.SetActive(false);
|
||||
}
|
||||
@@ -135,11 +142,21 @@ public class LocalNumberSetting : LocalSettingBase<float>
|
||||
return button.gameObject;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void RefreshOption()
|
||||
{
|
||||
_btnText.text = GetValueText();
|
||||
if (_highlight)
|
||||
{
|
||||
_highlight.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetValueText()
|
||||
{
|
||||
var value = GetValue();
|
||||
var formated = Helpers.FormatValue(value, SuffixType, FormatString);
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name}: <b>{formated}</font></b>";
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name.Translate()}: <b>{formated}</font></b>";
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,9 @@ public abstract class LocalSettingBase<T> : ILocalSetting
|
||||
/// <returns>The created setting.</returns>
|
||||
public abstract GameObject CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract void RefreshOption();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the formated string to use in the text of the setting.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -39,6 +40,8 @@ public class LocalSliderSetting : LocalSettingBase<float>
|
||||
/// </summary>
|
||||
public MiraNumberSuffixes SuffixType { get; }
|
||||
|
||||
private SlideBar _slider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LocalSliderSetting"/> class.
|
||||
/// </summary>
|
||||
@@ -70,6 +73,7 @@ public class LocalSliderSetting : LocalSettingBase<float>
|
||||
public override GameObject CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last)
|
||||
{
|
||||
var newSlider = Object.Instantiate(slider, parent).GetComponent<SlideBar>();
|
||||
_slider = newSlider;
|
||||
var rollover = newSlider.GetComponent<ButtonRolloverHandler>();
|
||||
newSlider.Title = newSlider.transform.FindChild("Text_TMP").GetComponent<TextMeshPro>(); // Why the hell slider has a title property that is not even assigned???
|
||||
newSlider.Title.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
@@ -104,6 +108,12 @@ public class LocalSliderSetting : LocalSettingBase<float>
|
||||
return newSlider.gameObject;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void RefreshOption()
|
||||
{
|
||||
_slider.Title.text = GetValueText();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetValueText()
|
||||
{
|
||||
@@ -112,9 +122,9 @@ public class LocalSliderSetting : LocalSettingBase<float>
|
||||
var value = GetValue();
|
||||
var formated = Helpers.FormatValue(value, SuffixType, FormatString);
|
||||
var maxFormated = Helpers.FormatValue(SliderRange.max, SuffixType, FormatString);
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name}: <b>{formated} / {maxFormated}</font></b>";
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name.Translate()}: <b>{formated} / {maxFormated}</font></b>";
|
||||
}
|
||||
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name}</font></b>";
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name.Translate()}</font></b>";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Localization.Utilities;
|
||||
using TMPro;
|
||||
@@ -14,6 +15,8 @@ namespace MiraAPI.LocalSettings.SettingTypes;
|
||||
/// </summary>
|
||||
public class LocalToggleSetting : LocalSettingBase<bool>
|
||||
{
|
||||
private ToggleButtonBehaviour _toggle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LocalToggleSetting"/> class.
|
||||
/// </summary>
|
||||
@@ -31,6 +34,7 @@ public class LocalToggleSetting : LocalSettingBase<bool>
|
||||
public override GameObject CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last)
|
||||
{
|
||||
var toggleObject = Object.Instantiate(toggle, parent).GetComponent<ToggleButtonBehaviour>();
|
||||
_toggle = toggleObject;
|
||||
var tmp = toggleObject.transform.FindChild("Text_TMP").GetComponent<TextMeshPro>();
|
||||
var passiveButton = toggleObject.GetComponent<PassiveButton>();
|
||||
var rollover = toggleObject.GetComponent<ButtonRolloverHandler>();
|
||||
@@ -46,9 +50,9 @@ public class LocalToggleSetting : LocalSettingBase<bool>
|
||||
toggleObject.transform.localPosition = new Vector3(order == 1 ? -1.185f : 1.185f, 1.85f - offset, -7);
|
||||
}
|
||||
|
||||
toggleObject.BaseText = CustomStringName.CreateAndRegister(Name);
|
||||
toggleObject.BaseText = MiraLocaleManager.GetOrCreateLocaleString(Name);
|
||||
toggleObject.UpdateText(GetValue());
|
||||
toggleObject.name = Name;
|
||||
toggleObject.name = Name.Translate();
|
||||
toggleObject.Background.color = GetValue() ? Tab!.TabAppearance.ToggleActiveColor : Tab!.TabAppearance.ToggleInactiveColor;
|
||||
passiveButton.OnClick = new UnityEngine.UI.Button.ButtonClickedEvent();
|
||||
rollover.OverColor = Tab!.TabAppearance.ToggleHoverColor;
|
||||
@@ -85,4 +89,11 @@ public class LocalToggleSetting : LocalSettingBase<bool>
|
||||
|
||||
return toggleObject.gameObject;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void RefreshOption()
|
||||
{
|
||||
_toggle.UpdateText(GetValue());
|
||||
_toggle.Background.color = GetValue() ? Tab!.TabAppearance.ToggleActiveColor : Tab!.TabAppearance.ToggleInactiveColor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.MeetingAbilities;
|
||||
|
||||
/// <summary>
|
||||
/// A component for handling targeted meeting buttons.
|
||||
/// </summary>
|
||||
[RegisterInIl2Cpp]
|
||||
public class MeetingAbilityBehaviour : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets whether the component has been initialized.
|
||||
/// </summary>
|
||||
private bool _init;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TargetedMeetingButton"/> attached to this component.
|
||||
/// </summary>
|
||||
private TargetedMeetingButton _button = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="PassiveButton"/> of this component.
|
||||
/// </summary>
|
||||
public PassiveButton Button;
|
||||
|
||||
/// <summary>
|
||||
/// The parent <see cref="PlayerVoteArea"/>.
|
||||
/// </summary>
|
||||
public PlayerVoteArea VoteArea;
|
||||
|
||||
/// <summary>
|
||||
/// The button's <see cref="SpriteRenderer"/> component.
|
||||
/// </summary>
|
||||
public SpriteRenderer Renderer;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TextMeshPro"/> label used for showing the ability's cooldown.
|
||||
/// </summary>
|
||||
public TextMeshPro CooldownText;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TextMeshPro"/> label used for showing the ability's remaining uses.
|
||||
/// </summary>
|
||||
public TextMeshPro UsesText;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the various properties of this component.
|
||||
/// </summary>
|
||||
/// <param name="button">The <see cref="TargetedMeetingButton"/> to initialize this component for.</param>
|
||||
/// <param name="voteArea">The parent <see cref="PlayerVoteArea"/>.</param>
|
||||
[HideFromIl2Cpp]
|
||||
public void Initialize(TargetedMeetingButton button, PlayerVoteArea voteArea)
|
||||
{
|
||||
if (_init) return;
|
||||
VoteArea = voteArea;
|
||||
_button = button;
|
||||
Renderer = GetComponent<SpriteRenderer>();
|
||||
SetFillUp(1, 1);
|
||||
if (!TryGetComponent(out Button))
|
||||
{
|
||||
Error($"Could not initialize MeetingButtonBehaviour for {Button.GetType().Name}, Destroying...");
|
||||
Destroy(this);
|
||||
}
|
||||
_init = true;
|
||||
CooldownText = Instantiate(HudManager.Instance.KillButton.cooldownTimerText, transform);
|
||||
CooldownText.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
CooldownText.transform.localPosition = new Vector3(0, 0, -10);
|
||||
CooldownText.m_maxFontSize = 3f;
|
||||
CooldownText.color = new Color(1, 1, 1, 0.7f);
|
||||
UsesText = Instantiate(CooldownText, transform);
|
||||
UsesText.transform.localPosition = new Vector3(0.25f, 0.25f, -10);
|
||||
UsesText.transform.localScale = Vector3.one * 0.7f;
|
||||
|
||||
CooldownText.gameObject.SetActive(true);
|
||||
UsesText.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!_init) return;
|
||||
Button.enabled = true;
|
||||
Renderer.enabled = true;
|
||||
UsesText.enabled = true;
|
||||
CooldownText.enabled = true;
|
||||
if (_button.Enabled(PlayerControl.LocalPlayer.Data.Role) && _button.IsTargetValid(VoteArea)) return;
|
||||
Button.enabled = false;
|
||||
Renderer.enabled = false;
|
||||
UsesText.enabled = false;
|
||||
CooldownText.enabled = false;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!_init) return;
|
||||
if (_button.Timer < 0.01f)
|
||||
{
|
||||
Renderer.material.SetFloat("_Desat", 0.0f);
|
||||
CooldownText.text = string.Empty;
|
||||
UsesText.text = _button.LimitedUses ? _button.UsesLeft.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
Renderer.material.SetFloat("_Desat", 0.5f);
|
||||
CooldownText.text = _button.Timer.ToString(_button.CooldownTimerFormatString, NumberFormatInfo.InvariantInfo);
|
||||
UsesText.text = string.Empty;
|
||||
}
|
||||
SetFillUp(_button.Timer, _button.InitialCooldown);
|
||||
}
|
||||
|
||||
public void SetFillUp(float timer, float maxTimer)
|
||||
{
|
||||
float percentCool = Mathf.Clamp(timer / maxTimer, 0.001f, 1f);
|
||||
if (percentCool <= 0) percentCool = 1f;
|
||||
Renderer.material.SetFloat("_Percent", percentCool);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
using System;
|
||||
using MiraAPI.Events;
|
||||
using MiraAPI.Events.Mira;
|
||||
using MiraAPI.Hud;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace MiraAPI.MeetingAbilities;
|
||||
|
||||
/// <summary>
|
||||
/// Class for making custom meeting action buttons.
|
||||
/// </summary>
|
||||
public abstract class MeetingActionButton
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name and text of the button.
|
||||
/// </summary>
|
||||
public abstract string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the initial cooldown duration in seconds.
|
||||
/// </summary>
|
||||
public virtual float InitialCooldown => Cooldown;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the button's cooldown duration in seconds.
|
||||
/// </summary>
|
||||
public abstract float Cooldown { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sprite of the button. Use <see cref="LoadableResourceAsset"/> to load a sprite from a resource path. Use <see cref="LoadableBundleAsset{T}"/> to load a sprite from an asset bundle.
|
||||
/// </summary>
|
||||
public abstract LoadableAsset<Sprite> Sprite { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the format string for the cooldown timer.
|
||||
/// </summary>
|
||||
public virtual string CooldownTimerFormatString => "0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the button has limited uses.
|
||||
/// </summary>
|
||||
public bool LimitedUses => ZeroIsInfinite ? MaxUses > 0 : MaxUses >= 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the maximum number of uses the button has. If the button has infinite uses, set to 0 or -1 based on what value that ZeroIsInfinite is set to.
|
||||
/// </summary>
|
||||
public virtual int MaxUses => ZeroIsInfinite ? 0 : -1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value indicating uses mode.
|
||||
/// </summary>
|
||||
public virtual MeetingButtonUsesMode UsesMode => MeetingButtonUsesMode.PerGame;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the button's text outline <see cref="Color"/>.
|
||||
/// </summary>
|
||||
public virtual Color TextOutlineColor => Color.clear;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether limited uses are determined via zero or a negative number of uses.
|
||||
/// </summary>
|
||||
public virtual bool ZeroIsInfinite { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the timer is currently active.
|
||||
/// </summary>
|
||||
public bool TimerPaused { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating how many times the ability was used in the current meeting.
|
||||
/// </summary>
|
||||
public int UsesSoFar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value determining if the abiity is disabled upon being used.
|
||||
/// </summary>
|
||||
public virtual bool DisableUponUse => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value determining if the abiity is disabled upon voting.
|
||||
/// </summary>
|
||||
public virtual bool DisableUponVoting => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value determining if the abiity is hidden when votes wrapping up.
|
||||
/// </summary>
|
||||
public virtual bool HideUponWrapUp => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of uses left.
|
||||
/// </summary>
|
||||
public int UsesLeft { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the timer variable to measure cooldowns and effects.
|
||||
/// </summary>
|
||||
public float Timer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="ActionButton"/> object in game. This is created by Mira API automatically.
|
||||
/// </summary>
|
||||
public ActionButton? Button { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The method used to create the button.
|
||||
/// </summary>
|
||||
/// <param name="parent">The parent of the button.</param>
|
||||
public virtual void CreateButton(Transform parent)
|
||||
{
|
||||
if (Button)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Timer = AmongUsClient.Instance?.NetworkMode == NetworkModes.FreePlay ? 0 : InitialCooldown;
|
||||
TimerPaused = false;
|
||||
|
||||
Button = Object.Instantiate(MeetingHud.Instance.MeetingAbilityButton, parent);
|
||||
Button.name = Name + "Button";
|
||||
Button.OverrideText(Name.ToUpperInvariant());
|
||||
|
||||
Button.graphic.sprite = Sprite.LoadAsset();
|
||||
|
||||
Button.SetUsesRemaining(UsesLeft);
|
||||
UsesSoFar = 0;
|
||||
if (MaxUses <= 0)
|
||||
{
|
||||
Button.SetInfiniteUses();
|
||||
}
|
||||
|
||||
if (TextOutlineColor != Color.clear)
|
||||
{
|
||||
SetTextOutline(TextOutlineColor);
|
||||
}
|
||||
|
||||
var pb = Button.GetComponent<PassiveButton>();
|
||||
pb.OnClick = new Button.ButtonClickedEvent();
|
||||
pb.OnClick.AddListener((UnityAction)(() =>
|
||||
{
|
||||
ClickHandler();
|
||||
}));
|
||||
Button.gameObject.SetActive(Enabled(PlayerControl.LocalPlayer.Data.Role));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A utility function to change the outline <see cref="Color"/> of the button's text.
|
||||
/// </summary>
|
||||
/// <param name="color">The new <see cref="Color"/>.</param>
|
||||
public virtual void SetTextOutline(Color color)
|
||||
{
|
||||
Button?.buttonLabelText.SetOutlineColor(color);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A utility function to override the <see cref="UnityEngine.Sprite"/> of the button.
|
||||
/// </summary>
|
||||
/// <param name="sprite">The new <see cref="UnityEngine.Sprite"/> to override with.</param>
|
||||
public virtual void OverrideSprite(Sprite sprite)
|
||||
{
|
||||
if (Button != null)
|
||||
{
|
||||
Button.graphic.sprite = sprite;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A utility function to override the name of the button.
|
||||
/// </summary>
|
||||
/// <param name="name">The new name to override with.</param>
|
||||
public virtual void OverrideName(string name)
|
||||
{
|
||||
Button?.OverrideText(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the button's timer.
|
||||
/// </summary>
|
||||
/// <param name="time">The time you want to set to.</param>
|
||||
public virtual void SetTimer(float time)
|
||||
{
|
||||
Timer = Mathf.Clamp(time, -1, float.MaxValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increase the button's timer.
|
||||
/// </summary>
|
||||
/// <param name="amount">The amount you want to increase by.</param>
|
||||
public virtual void IncreaseTimer(float amount)
|
||||
{
|
||||
SetTimer(Timer + amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decrease the button's timer.
|
||||
/// </summary>
|
||||
/// <param name="amount">The amount you want to decrease by.</param>
|
||||
public virtual void DecreaseTimer(float amount)
|
||||
{
|
||||
SetTimer(Timer - amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the timer is paused or not.
|
||||
/// </summary>
|
||||
/// <param name="val">Whether you want to pause/resume the timer.</param>
|
||||
public virtual void SetTimerPaused(bool val)
|
||||
{
|
||||
TimerPaused = val;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the amount of uses this button has left.
|
||||
/// </summary>
|
||||
/// <param name="amount">The amount you want to set to.</param>
|
||||
public virtual void SetUses(int amount)
|
||||
{
|
||||
UsesLeft = Mathf.Clamp(amount, 0, int.MaxValue);
|
||||
Button?.SetUsesRemaining(UsesLeft);
|
||||
|
||||
if (Button != null)
|
||||
{
|
||||
Button.usesRemainingSprite.color = UsesLeft == 0 ? Color.red : Color.white;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increase the amount of uses this button has left.
|
||||
/// </summary>
|
||||
/// <param name="amount">The amount you want to increase by. Default: 1.</param>
|
||||
public virtual void IncreaseUses(int amount = 1)
|
||||
{
|
||||
SetUses(UsesLeft + amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decrease the amount of uses this button has left.
|
||||
/// </summary>
|
||||
/// <param name="amount">The amount you want to decrease by. Default: 1.</param>
|
||||
public virtual void DecreaseUses(int amount = 1)
|
||||
{
|
||||
SetUses(UsesLeft - amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A utility function that runs with the local player's <see cref="MeetingHud.Update"/> if the button is enabled.
|
||||
/// </summary>
|
||||
/// <param name="hud">the <see cref="MeetingHud"/> instance.</param>
|
||||
protected virtual void FixedUpdate(MeetingHud hud)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback method for the button click event.
|
||||
/// </summary>
|
||||
protected abstract void OnClick();
|
||||
|
||||
/// <summary>
|
||||
/// This method determines if the button should be active or not.
|
||||
/// <see langword="true"/> means the button is active, <see langword="false"/> means the button is disabled.
|
||||
/// </summary>
|
||||
/// <param name="role">The <see cref="RoleBehaviour"/> of the local player.</param>
|
||||
/// <returns><see langword="true"/> if the button is enabled, <see langword="false"/> otherwise.</returns>
|
||||
public abstract bool Enabled(RoleBehaviour? role);
|
||||
|
||||
/// <summary>
|
||||
/// When the button is usable, this method is called to determine if the button can be clicked.
|
||||
/// By default, it takes into account the timer, effect, and uses.
|
||||
/// You can override it to change the behavior.
|
||||
/// </summary>
|
||||
/// <returns>A value that represents whether the button can be clicked or not.</returns>
|
||||
public virtual bool CanClick()
|
||||
{
|
||||
return Timer <= 0 && CanUse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the button should light up or not. This is also the base for CanClick.
|
||||
/// You can override it to change the behaviour. Do not include timer in here, that is for CanClick.
|
||||
/// </summary>
|
||||
/// <returns>A value that represents whether the button should light up or not.</returns>
|
||||
public virtual bool CanUse()
|
||||
{
|
||||
return (!DisableUponUse || UsesSoFar < 1) &&
|
||||
(!DisableUponVoting || MeetingHud.Instance.CurrentState is not MeetingHud.MeetingStates.Voted) &&
|
||||
(!LimitedUses || UsesLeft > 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method handles the button click event. It is a wrapper for the <see cref="OnClick"/> method.
|
||||
/// This method takes into account cooldowns, effects, and uses, before calling the <see cref="OnClick"/> method.
|
||||
/// It can be overridden for custom behavior.
|
||||
/// </summary>
|
||||
public virtual void ClickHandler()
|
||||
{
|
||||
if (!CanClick())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (LimitedUses)
|
||||
{
|
||||
UsesLeft--;
|
||||
Button?.SetUsesRemaining(UsesLeft);
|
||||
}
|
||||
|
||||
Timer = Cooldown;
|
||||
OnClick();
|
||||
UsesSoFar++;
|
||||
if (DisableUponUse && Button)
|
||||
{
|
||||
Button!.SetDisabled();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called on the <see cref="MeetingHud.Update"/> method. It is a wrapper for the <see cref="FixedUpdate"/> method.
|
||||
/// By default, it handles the cooldown and effect timers, and sets the button to enabled or disabled.
|
||||
/// It can be overridden for custom behavior.
|
||||
/// </summary>
|
||||
/// <param name="hud">The <see cref="MeetingHud"/> instance.</param>
|
||||
public virtual void UpdateHandler(MeetingHud hud)
|
||||
{
|
||||
if (Timer >= 0 && !TimerPaused)
|
||||
{
|
||||
Timer -= Time.deltaTime;
|
||||
}
|
||||
|
||||
if (Button)
|
||||
{
|
||||
if (CanUse())
|
||||
{
|
||||
Button!.SetEnabled();
|
||||
}
|
||||
else
|
||||
{
|
||||
Button!.SetDisabled();
|
||||
}
|
||||
Button.SetCooldownFormat(Timer, Cooldown, CooldownTimerFormatString);
|
||||
Button.SetCoolDown(Timer, Cooldown);
|
||||
}
|
||||
|
||||
FixedUpdate(hud);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Modifiers.Types;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using MiraAPI.Utilities.Components;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.MeetingAbilities;
|
||||
|
||||
/// <summary>
|
||||
/// Class for managing all registered meeting abilities.
|
||||
/// </summary>
|
||||
public static class MeetingButtonManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a list if==of all registered <see cref="TargetedMeetingButton"/>.
|
||||
/// </summary>
|
||||
public static List<TargetedMeetingButton> TargetedButtons { get; internal set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list if==of all registered <see cref="MeetingActionButton"/>.
|
||||
/// </summary>
|
||||
public static List<MeetingActionButton> UntargetedButtons { get; internal set; } = new();
|
||||
|
||||
internal static bool RegisterTargetedMeetingButton(Type type, MiraPluginInfo info)
|
||||
{
|
||||
if (!typeof(TargetedMeetingButton).IsAssignableFrom(type))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var button = Activator.CreateInstance(type) as TargetedMeetingButton;
|
||||
info.InternalTargetedMeetingButtons.Add(button);
|
||||
TargetedButtons.Add(button);
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static bool RegisterMeetingButton(Type type, MiraPluginInfo info)
|
||||
{
|
||||
if (!typeof(MeetingActionButton).IsAssignableFrom(type))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var button = Activator.CreateInstance(type) as MeetingActionButton;
|
||||
info.InternalMeetingButtons.Add(button);
|
||||
UntargetedButtons.Add(button);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static CenteredGridArrange? actionButtonsParent = null!;
|
||||
|
||||
public static void OnGameStart()
|
||||
{
|
||||
foreach (var ability in TargetedButtons.Where(x => x.UsesMode == MeetingButtonUsesMode.PerGame))
|
||||
{
|
||||
ability.UsesLeft = ability.MaxUses;
|
||||
}
|
||||
foreach (var ability in UntargetedButtons.Where(x => x.UsesMode == MeetingButtonUsesMode.PerGame))
|
||||
{
|
||||
ability.UsesLeft = ability.MaxUses;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called on <see cref="MeetingHud.Start"/>. Handles button creation, and ability uses.
|
||||
/// </summary>
|
||||
/// <param name="meetingHud">The <see cref="MeetingHud"/> instance.</param>
|
||||
public static void OnMeetingStart(MeetingHud meetingHud)
|
||||
{
|
||||
// Untargeted buttons parent.
|
||||
actionButtonsParent = new GameObject("ActionsButtonParent").AddComponent<CenteredGridArrange>();
|
||||
actionButtonsParent.transform.SetParent(meetingHud.MeetingAbilityButton.transform.parent, meetingHud.MeetingAbilityButton.transform.parent);
|
||||
actionButtonsParent.CellSize = new Vector2(0.7f, 0.7f);
|
||||
actionButtonsParent.transform.localPosition = new Vector3(0, -2.1f, -10);
|
||||
meetingHud.MeetingAbilityButton.transform.SetParent(actionButtonsParent.transform);
|
||||
|
||||
// Untargeted buttons creation.
|
||||
foreach (var ability in UntargetedButtons)
|
||||
{
|
||||
try
|
||||
{
|
||||
ability.CreateButton(actionButtonsParent.transform);
|
||||
if (ability.UsesMode == MeetingButtonUsesMode.PerMeeting) ability.UsesLeft = ability.MaxUses;
|
||||
ability.Timer = ability.InitialCooldown;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Failed to create meeting button {ability.Name}: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// Targeted buttons creation.
|
||||
foreach (var ability in TargetedButtons)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var playerVoteArea in meetingHud.playerStates)
|
||||
{
|
||||
var btn = ability.CreateButton(playerVoteArea);
|
||||
btn.transform.SetParent(playerVoteArea.Buttons.transform);
|
||||
}
|
||||
var btn2 = ability.CreateButton(meetingHud.SkipVoteButton);
|
||||
btn2.transform.SetParent(meetingHud.SkipVoteButton.Buttons.transform);
|
||||
|
||||
if (ability.UsesMode == MeetingButtonUsesMode.PerMeeting) ability.UsesLeft = ability.MaxUses;
|
||||
if (ability is MultiTargetMeetingButton multiAbility) multiAbility.Targets = new();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Failed to create targeted meeting button {ability.Name}: {e.Message}");
|
||||
}
|
||||
}
|
||||
foreach (var playerVoteArea in meetingHud.playerStates)
|
||||
{
|
||||
playerVoteArea.CancelButton.transform.SetAsFirstSibling();
|
||||
}
|
||||
meetingHud.SkipVoteButton.CancelButton.transform.SetAsFirstSibling();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace MiraAPI.MeetingAbilities;
|
||||
|
||||
public enum MeetingButtonUsesMode
|
||||
{
|
||||
PerGame,
|
||||
PerMeeting
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace MiraAPI.MeetingAbilities;
|
||||
|
||||
/// <summary>
|
||||
/// Abstract class for creating multi target meeting abilities
|
||||
/// </summary>
|
||||
public abstract class MultiTargetMeetingButton : TargetedMeetingButton
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="LoadableAsset{Sprite}"/> used for when the button is on.
|
||||
/// </summary>
|
||||
public abstract LoadableAsset<Sprite> SpriteActive { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the required targets count.
|
||||
/// </summary>
|
||||
public abstract int TargetsCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets all selected targets.
|
||||
/// </summary>
|
||||
public Dictionary<PlayerVoteArea, MeetingAbilityBehaviour> Targets { get; set; } = new();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ClickHandler(MeetingAbilityBehaviour button, PlayerVoteArea playerVoteArea)
|
||||
{
|
||||
if (UsesLeft <= 0 && LimitedUses) return;
|
||||
if (Timer > 0) return;
|
||||
var toggle = !Targets.Remove(playerVoteArea);
|
||||
if (toggle) Targets.Add(playerVoteArea, button);
|
||||
button.Renderer.sprite = toggle ? SpriteActive.LoadAsset() : Sprite.LoadAsset();
|
||||
if (Targets.Count >= TargetsCount)
|
||||
{
|
||||
playerVoteArea.Cancel();
|
||||
HandleFinish();
|
||||
return;
|
||||
}
|
||||
OnSelect(playerVoteArea, toggle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the finish logic, increasing timer, and decreasing uses.
|
||||
/// </summary>
|
||||
public virtual void HandleFinish()
|
||||
{
|
||||
Targets = Targets.Take(TargetsCount).ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||
foreach (var button in Targets.Values)
|
||||
{
|
||||
button.Renderer.sprite = Sprite.LoadAsset();
|
||||
}
|
||||
Timer = Cooldown;
|
||||
UsesLeft -= 1;
|
||||
OnFinish();
|
||||
Targets = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback method for when a player is selected.
|
||||
/// </summary>
|
||||
/// <param name="playerVoteArea">The target <see cref="PlayerVoteArea"/>.</param>
|
||||
/// <param name="toggle">Whether the button was toggled on/off.</param>
|
||||
protected abstract void OnSelect(PlayerVoteArea playerVoteArea, bool toggle);
|
||||
|
||||
/// <summary>
|
||||
/// Callback method for the button click.
|
||||
/// USE <see cref="OnSelect"/> INSTEAD!!!.
|
||||
/// </summary>
|
||||
/// <param name="playerVoteArea">The target <see cref="PlayerVoteArea"/>.</param>
|
||||
protected override void OnClick(PlayerVoteArea playerVoteArea)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback method for when enough targets are chosen.
|
||||
/// </summary>
|
||||
public abstract void OnFinish();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override MeetingAbilityBehaviour CreateButton(PlayerVoteArea playerVoteArea)
|
||||
{
|
||||
Targets = new();
|
||||
var button = base.CreateButton(playerVoteArea);
|
||||
button.Button.OnClick = new Button.ButtonClickedEvent();
|
||||
button.Button.OnClick.AddListener(new System.Action(() => { ClickHandler(button, playerVoteArea); }));
|
||||
return button;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
using System.Collections.Generic;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace MiraAPI.MeetingAbilities;
|
||||
|
||||
/// <summary>
|
||||
/// Abstract class for creating targeted meeting abilities.
|
||||
/// </summary>
|
||||
public abstract class TargetedMeetingButton
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name of the <see cref="TargetedMeetingButton"/>.
|
||||
/// </summary>
|
||||
public abstract string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Max Uses of the button.
|
||||
/// Set it to 0 for Infinite uses.
|
||||
/// </summary>
|
||||
public abstract int MaxUses { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of uses left for this button.
|
||||
/// </summary>
|
||||
public int UsesLeft { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the <see cref="TargetedMeetingButton"/> has limited uses.
|
||||
/// </summary>
|
||||
public bool LimitedUses => MaxUses != 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cooldown time for this button upon meeting start.
|
||||
/// Defaults to <see cref="Cooldown"/> unless overridden.
|
||||
/// </summary>
|
||||
public virtual float InitialCooldown => Cooldown;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cooldown time for this button after being used.
|
||||
/// </summary>
|
||||
public abstract float Cooldown { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current cooldown timer for this button.
|
||||
/// </summary>
|
||||
public float Timer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cooldown time for this button.
|
||||
/// </summary>
|
||||
public virtual string CooldownTimerFormatString => "0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sprite used for this button.
|
||||
/// </summary>
|
||||
public abstract LoadableAsset<Sprite> Sprite { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the button's outline color.
|
||||
/// </summary>
|
||||
public abstract Color OutlineColor { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="MeetingButtonUsesMode"/> for this button.
|
||||
/// </summary>
|
||||
public virtual MeetingButtonUsesMode UsesMode { get; } = MeetingButtonUsesMode.PerGame;
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the button is enabled.
|
||||
/// </summary>
|
||||
/// <param name="r">The local player's <see cref="RoleBehaviour"/>.</param>
|
||||
/// <returns>Whether the button is enabled or not.</returns>
|
||||
public abstract bool Enabled(RoleBehaviour r);
|
||||
|
||||
/// <summary>
|
||||
/// Callback method for when the button is clicked.
|
||||
/// </summary>
|
||||
/// <param name="playerVoteArea">The target <see cref="PlayerVoteArea"/>.</param>
|
||||
protected abstract void OnClick(PlayerVoteArea playerVoteArea);
|
||||
|
||||
/// <summary>
|
||||
/// Handles the button creation.
|
||||
/// </summary>
|
||||
/// <param name="playerVoteArea">The target <see cref="PlayerVoteArea"/>.</param>
|
||||
/// <returns>The <see cref="MeetingAbilityBehaviour"/> instance.</returns>
|
||||
public virtual MeetingAbilityBehaviour CreateButton(PlayerVoteArea playerVoteArea)
|
||||
{
|
||||
if (MeetingHud.Instance == null) return null!;
|
||||
|
||||
var btn = Object.Instantiate(MeetingHud.Instance.PlayerButtonPrefab.ConfirmButton).GetComponent<PassiveButton>();
|
||||
btn.gameObject.name = Name + "Button";
|
||||
|
||||
var spriteRenderer = btn.GetComponent<SpriteRenderer>();
|
||||
spriteRenderer.sprite = Sprite.LoadAsset();
|
||||
spriteRenderer.material = new Material(HudManager.Instance.KillButton.graphic.material);
|
||||
spriteRenderer.SetCooldownNormalizedUvs();
|
||||
btn.gameObject.SetActive(true);
|
||||
|
||||
btn.transform.GetChild(0).GetComponent<SpriteRenderer>().color = OutlineColor;
|
||||
|
||||
btn.OnClick = new Button.ButtonClickedEvent();
|
||||
var abilityBehaviour = btn.gameObject.AddComponent<MeetingAbilityBehaviour>();
|
||||
abilityBehaviour.Initialize(this, playerVoteArea);
|
||||
btn.OnClick.AddListener(new System.Action(() => ClickHandler(abilityBehaviour, playerVoteArea)));
|
||||
Timer = InitialCooldown;
|
||||
|
||||
return abilityBehaviour;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called every <see cref="MeetingHud.Update"/>.
|
||||
/// Handles the timer logic.
|
||||
/// </summary>
|
||||
public virtual void UpdateHandler()
|
||||
{
|
||||
Timer -= Time.deltaTime;
|
||||
Timer = Mathf.Clamp(Timer, 0, int.MaxValue);
|
||||
FixedUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback method for handling logic every frame.
|
||||
/// </summary>
|
||||
public virtual void FixedUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the button is clicked
|
||||
/// Handles increasing cooldown and decreasing uses remaining.
|
||||
/// </summary>
|
||||
/// <param name="button">The <see cref="MeetingAbilityBehaviour"/> instance.</param>
|
||||
/// <param name="playerVoteArea">The target <see cref="PlayerVoteArea"/>.</param>
|
||||
public virtual void ClickHandler(MeetingAbilityBehaviour button, PlayerVoteArea playerVoteArea)
|
||||
{
|
||||
if (UsesLeft <= 0 && LimitedUses) return;
|
||||
if (Timer > 0) return;
|
||||
Timer = Cooldown;
|
||||
UsesLeft--;
|
||||
playerVoteArea.Cancel();
|
||||
OnClick(playerVoteArea);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the target is valid.
|
||||
/// </summary>
|
||||
/// <param name="playerVoteArea">The target <see cref="PlayerVoteArea"/>.</param>
|
||||
/// <returns>Whether the target is valid or not.</returns>
|
||||
public virtual bool IsTargetValid(PlayerVoteArea playerVoteArea)
|
||||
{
|
||||
return playerVoteArea != null && playerVoteArea.PlayerId.Value != PlayerControl.LocalPlayer.Data.PlayerId && playerVoteArea.PlayerId.Value != PlayerVoteArea.SkippedVote;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
|
||||
namespace MiraAPI.MeetingAbilities;
|
||||
|
||||
/// <summary>
|
||||
/// A utility class to get the instance of a <see cref="TargetedMeetingButton"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the button you are trying to access.</typeparam>
|
||||
public static class TargetedMeetingButtonSingleton<T> where T : TargetedMeetingButton
|
||||
{
|
||||
private static T? _instance;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of the <typeparamref name="T"/> button.
|
||||
/// </summary>
|
||||
[SuppressMessage("Design", "CA1000:Do not declare static members on generic types", Justification = "This is a utility class to get the instance of a targeted meeting button.")]
|
||||
public static T Instance => _instance ??= MeetingButtonManager.TargetedButtons.OfType<T>().Single();
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
global using static Reactor.Utilities.Logger<MiraAPI.MiraApiPlugin>;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.Unity.IL2CPP;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.VanillaEvents;
|
||||
using Reactor;
|
||||
using Reactor.Localization;
|
||||
using Reactor.Networking;
|
||||
using Reactor.Networking.Attributes;
|
||||
using Reactor.Utilities;
|
||||
@@ -29,6 +32,11 @@ public partial class MiraApiPlugin : BasePlugin, IMiraPlugin
|
||||
return Config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified Culture for string manipulations.
|
||||
/// </summary>
|
||||
public static CultureInfo Culture { get; internal set; } = new("en-US");
|
||||
|
||||
/// <inheritdoc />
|
||||
public string OptionsTitleText => "MiraAPI";
|
||||
|
||||
@@ -62,6 +70,7 @@ public partial class MiraApiPlugin : BasePlugin, IMiraPlugin
|
||||
public override void Load()
|
||||
{
|
||||
Harmony.PatchAll();
|
||||
UiResetEvents.Initialize();
|
||||
JudgeEvents.Initialize();
|
||||
|
||||
ReactorCredits.Register("Mira API", Version, IsDevBuild, ReactorCredits.AlwaysShow);
|
||||
@@ -69,6 +78,9 @@ public partial class MiraApiPlugin : BasePlugin, IMiraPlugin
|
||||
PluginManager = new MiraPluginManager();
|
||||
PluginManager.Initialize(this, this);
|
||||
|
||||
MiraLocaleManager.Register("mira.api");
|
||||
LocalizationManager.Register(new MiraLocalizationProvider());
|
||||
|
||||
IL2CPPChainloader.Instance.Finished +=
|
||||
ModCompatibility
|
||||
.Initialize; // Initialise AFTER the mods are loaded to ensure maximum parity (no need for the soft dependency either then)
|
||||
|
||||
+27
-66
@@ -1,9 +1,12 @@
|
||||
using System.Collections;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Events;
|
||||
using MiraAPI.Events.Mira;
|
||||
using MiraAPI.Hud;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.LocalSettings.Attributes;
|
||||
using MiraAPI.Patches;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
@@ -16,7 +19,7 @@ namespace MiraAPI;
|
||||
public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string TabName => "Mira API";
|
||||
public override string TabName => "MiraApi";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override LocalSettingTabAppearance TabAppearance => new()
|
||||
@@ -79,54 +82,18 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
{
|
||||
var topUi = MiraHudHelper.UiTopRight;
|
||||
var extraTopUi = MiraHudHelper.ExtraUiTopRight;
|
||||
var wikiButton = MiraHudHelper.VanillaMatchInfoButton;
|
||||
var subButton = MiraHudHelper.SubmergedFloorButton;
|
||||
var modDisplay = MiraHudHelper.ModifierDisplayOnRight ? MiraHudHelper.ModifierDisplayObject : null!;
|
||||
ResetButtonPositions();
|
||||
if (topUi && extraTopUi)
|
||||
{
|
||||
var opts = LocalSettingsTabSingleton<MiraApiSettings>.Instance;
|
||||
if (wikiButton)
|
||||
{
|
||||
wikiButton.transform.SetParent(opts.WikiOnBottomRow.Value ? extraTopUi.transform : topUi.transform);
|
||||
}
|
||||
if (subButton)
|
||||
{
|
||||
subButton.transform.SetParent(extraTopUi.transform);
|
||||
}
|
||||
if (modDisplay)
|
||||
{
|
||||
modDisplay.transform.SetParent(extraTopUi.transform);
|
||||
}
|
||||
var genericEvent = new UiButtonResetEvent();
|
||||
MiraEventManager.InvokeEvent(genericEvent);
|
||||
|
||||
var genericEvent2 = new UiButtonPostResetEvent(topUi, extraTopUi);
|
||||
MiraEventManager.InvokeEvent(genericEvent2);
|
||||
MiraHudHelper.UiGrid.ArrangeChilds();
|
||||
MiraHudHelper.ExtraUiGrid.ArrangeChilds();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ResetButtonPositions()
|
||||
{
|
||||
var topUi = MiraHudHelper.UiTopRight;
|
||||
var extraTopUi = MiraHudHelper.ExtraUiTopRight;
|
||||
var subButton = MiraHudHelper.SubmergedFloorButton;
|
||||
var modDisplay = MiraHudHelper.ModifierDisplayOnRight ? MiraHudHelper.ModifierDisplayObject : null!;
|
||||
if (topUi && extraTopUi)
|
||||
{
|
||||
var wikiButton = MiraHudHelper.VanillaMatchInfoButton;
|
||||
if (wikiButton)
|
||||
{
|
||||
wikiButton.transform.SetParent(null);
|
||||
}
|
||||
if (subButton)
|
||||
{
|
||||
subButton.transform.SetParent(null);
|
||||
}
|
||||
if (modDisplay)
|
||||
{
|
||||
modDisplay.transform.SetParent(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerator CoResizeSettingsUI()
|
||||
{
|
||||
while (!HudManager.Instance || !MiraHudHelper.UiGrid || !MiraHudHelper.ExtraUiGrid)
|
||||
@@ -204,58 +171,52 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the modifiers hud should be on the left side of the screen (under roles/task tab). Recommended for streamers.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ModifiersHudLeftSide { get; private set; } = config.Bind("Visuals/UI", "Show Modifiers HUD on Left Side", false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to show keybinds on buttons.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ShowKeybinds { get; private set; } = config.Bind("Visuals/UI", "Show Keybinds on Buttons", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scale of the ability buttons.
|
||||
/// </summary>
|
||||
[LocalSliderSetting(min: 0.5f, max: 1.5f, suffixType: MiraNumberSuffixes.Multiplier, formatString: "0.00", displayValue: true)]
|
||||
public ConfigEntry<float> ButtonUIFactorSlider { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Button Scale Factor", 0.75f);
|
||||
config.Bind("MiraApi.VisualsUi", "MiraApi.ButtonScaleFactor", 0.75f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scale of the UI buttons.
|
||||
/// </summary>
|
||||
[LocalSliderSetting(min: 0.3f, max: 2f, suffixType: MiraNumberSuffixes.Multiplier, formatString: "0.00", displayValue: true)]
|
||||
public ConfigEntry<float> TopRightButtonsFactorSlider { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Top-Right UI Scale Factor", 1f);
|
||||
config.Bind("MiraApi.VisualsUi", "MiraApi.TopRightButtonScaleFactor", 1f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the fps specified by the player.
|
||||
/// </summary>
|
||||
[LocalSliderSetting(min: 60f, max: 240f, suffixType: MiraNumberSuffixes.None, formatString: "0", displayValue: true, roundValue: true)]
|
||||
public ConfigEntry<float> SetFpsSlider { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Max FPS", 120f);
|
||||
config.Bind("MiraApi.VisualsUi", "Max FPS", 120f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the modifiers hud should be on the left side of the screen (under roles/task tab). Recommended for streamers.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ModifiersHudLeftSide { get; private set; } = config.Bind("MiraApi.VisualsUi", "MiraApi.ShowModifiersHudOnLeftSide", false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to show keybinds on buttons.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ShowKeybinds { get; private set; } = config.Bind("MiraApi.VisualsUi", "MiraApi.ShowKeybindsOnButtons", true);
|
||||
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> WikiOnBottomRow { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Display Wiki on Bottom Row", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to apply cosmetic changes to the TaskAdder.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> PrettyTaskAdder { get; private set; } = config.Bind("Freeplay", "Pretty Task Laptop", true);
|
||||
config.Bind("MiraApi.VisualsUi", "MiraApi.WikiOnBottomRow", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to show the red flash from sabotages.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> EnableSabotageFlashes { get; private set; } = config.Bind("Accessibility", "Enable Sabotage Flashes", true);
|
||||
public ConfigEntry<bool> EnableSabotageFlashes { get; private set; } = config.Bind("MiraApi.Accessibility", "MiraApi.EnableSabotageFlashes", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to enable the sabotage sound effects or not.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> EnableSabotageBlares { get; private set; } = config.Bind("Accessibility", "Enable Sabotage Blare", true);
|
||||
public ConfigEntry<bool> EnableSabotageBlares { get; private set; } = config.Bind("MiraApi.Accessibility", "MiraApi.EnableSabotageBlare", true);
|
||||
}
|
||||
@@ -8,6 +8,8 @@ using MiraAPI.LocalSettings;
|
||||
using MiraAPI.Modifiers.ModifierDisplay;
|
||||
using MiraAPI.Modifiers.Types;
|
||||
using MiraAPI.Patches.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using Reactor.Utilities;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using HarmonyLib;
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using Reactor.Utilities.Extensions;
|
||||
@@ -153,7 +154,7 @@ public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
private ModifierUiComponent CreateForModifier(BaseModifier modifier)
|
||||
{
|
||||
var newMod = Instantiate(_modTemplate, _children.transform);
|
||||
newMod.transform.name = modifier.ModifierName;
|
||||
newMod.transform.name = modifier.ModifierName.Translate();
|
||||
var comp = newMod.AddComponent<ModifierUiComponent>();
|
||||
comp.Modifier = modifier;
|
||||
return comp;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using MiraAPI.Translation;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using MiraAPI.Modifiers.Types;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
@@ -138,7 +139,7 @@ public static class ModifierManager
|
||||
{
|
||||
if (MiraApiPlugin.IsDevBuild)
|
||||
{
|
||||
Warning($"No valid players for modifier {modifier.ModifierName}");
|
||||
Warning($"No valid players for modifier {modifier.ModifierName.Translate()}");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -163,7 +164,7 @@ public static class ModifierManager
|
||||
if (MiraApiPlugin.IsDevBuild)
|
||||
{
|
||||
Warning(
|
||||
$"No available players for modifier {modifier.ModifierName} at assignment {i + 1}");
|
||||
$"No available players for modifier {modifier.ModifierName.Translate()} at assignment {i + 1}");
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -174,7 +175,7 @@ public static class ModifierManager
|
||||
{
|
||||
if (MiraApiPlugin.IsDevBuild)
|
||||
{
|
||||
Warning($"Valid player for modifier {modifier.ModifierName} disappeared");
|
||||
Warning($"Valid player for modifier {modifier.ModifierName.Translate()} disappeared");
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
@@ -7,7 +7,7 @@ using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Patches;
|
||||
|
||||
[HarmonyPatch(typeof(DetectiveNotesMinigame), nameof(DetectiveNotesMinigame.SetImpostorPopup))]
|
||||
/*[HarmonyPatch(typeof(DetectiveNotesMinigame), nameof(DetectiveNotesMinigame.SetImpostorPopup))]
|
||||
public static class DetectiveNotesMinigamePatch
|
||||
{
|
||||
public static void Prefix(DetectiveNotesMinigame __instance, bool active)
|
||||
@@ -39,4 +39,4 @@ public static class DetectiveNotesMinigamePatch
|
||||
}
|
||||
ControllerManager.Instance.OpenOverlayMenu(__instance.ImpostorOverlay, __instance.impostorTypePopup, __instance.ImpostorIconControllerSelectables[0], __instance.ImpostorIconControllerSelectables, false);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
@@ -1,7 +1,9 @@
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.Events;
|
||||
using MiraAPI.Events.Vanilla.Gameplay;
|
||||
using MiraAPI.MeetingAbilities;
|
||||
using MiraAPI.Utilities;
|
||||
|
||||
namespace MiraAPI.Patches.Events;
|
||||
@@ -18,6 +20,7 @@ public static class FreeplayRoundStartPatch
|
||||
{
|
||||
if (!__result)
|
||||
{
|
||||
MeetingButtonManager.OnGameStart();
|
||||
MiraEventManager.InvokeEvent(new RoundStartEvent(true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ using System.Text;
|
||||
using AmongUs.GameOptions;
|
||||
using HarmonyLib;
|
||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Modifiers.Types;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Extensions;
|
||||
@@ -268,13 +268,9 @@ public static class TaskAdderPatches
|
||||
stringBuilder.Append('\\');
|
||||
}
|
||||
__instance.PathText.text = stringBuilder.ToString();
|
||||
var prettyEnabled = LocalSettingsTabSingleton<MiraApiSettings>.Instance.PrettyTaskAdder.Value;
|
||||
if (prettyEnabled)
|
||||
{
|
||||
__instance.PathText.fontSizeMin = 3;
|
||||
__instance.PathText.fontSizeMax = 3;
|
||||
__instance.transform.FindChild("TitleText_TMP")?.gameObject.DestroyImmediate();
|
||||
}
|
||||
__instance.PathText.fontSizeMin = 3;
|
||||
__instance.PathText.fontSizeMax = 3;
|
||||
__instance.transform.FindChild("TitleText_TMP")?.gameObject.DestroyImmediate();
|
||||
|
||||
__instance.ActiveItems.ToArray().Do(x => x.gameObject.DeepDestroy(false));
|
||||
__instance.ActiveItems.Clear();
|
||||
@@ -354,15 +350,12 @@ public static class TaskAdderPatches
|
||||
{
|
||||
TaskAddButton roleAddButton = Object.Instantiate(__instance.RoleButton);
|
||||
roleAddButton.SafePositionWorld = __instance.SafePositionWorld;
|
||||
roleAddButton.Text.text = prettyEnabled ? role.GetRoleName() : "Be_" + role.GetRoleName() + ".exe";
|
||||
roleAddButton.Text.text = role.GetRoleName();
|
||||
roleAddButton.Role = role;
|
||||
if (prettyEnabled)
|
||||
{
|
||||
roleAddButton.Text.fontSizeMin = 1;
|
||||
roleAddButton.FileImage.sprite = role.IsImpostor
|
||||
? MiraAssets.ImpostorFile.LoadAsset()
|
||||
: MiraAssets.CrewmateFile.LoadAsset();
|
||||
}
|
||||
roleAddButton.Text.fontSizeMin = 1;
|
||||
roleAddButton.FileImage.sprite = role.IsImpostor
|
||||
? MiraAssets.ImpostorFile.LoadAsset()
|
||||
: MiraAssets.CrewmateFile.LoadAsset();
|
||||
|
||||
__instance.AddFileAsChildCustom(roleAddButton, ref num, ref num2, ref num3);
|
||||
if (roleAddButton != null && roleAddButton.Button != null)
|
||||
@@ -409,19 +402,16 @@ public static class TaskAdderPatches
|
||||
var roleAddButton = Object.Instantiate(__instance.RoleButton);
|
||||
roleAddButton.MyTask = null;
|
||||
roleAddButton.SafePositionWorld = __instance.SafePositionWorld;
|
||||
roleAddButton.Text.text = prettyEnabled ? roleBehaviour.GetRoleName() : "Be_" + roleBehaviour.GetRoleName() + ".exe";
|
||||
roleAddButton.Text.text = roleBehaviour.GetRoleName();
|
||||
roleAddButton.Text.EnableMasking();
|
||||
roleAddButton.role = roleBehaviour;
|
||||
if (prettyEnabled)
|
||||
{
|
||||
roleAddButton.Text.fontSizeMin = 1;
|
||||
roleAddButton.FileImage.sprite = roleBehaviour.IsImpostor
|
||||
? MiraAssets.ImpostorFile.LoadAsset()
|
||||
: MiraAssets.CrewmateFile.LoadAsset();
|
||||
}
|
||||
roleAddButton.Text.fontSizeMin = 1;
|
||||
roleAddButton.FileImage.sprite = roleBehaviour.IsImpostor
|
||||
? MiraAssets.ImpostorFile.LoadAsset()
|
||||
: MiraAssets.CrewmateFile.LoadAsset();
|
||||
if (roleBehaviour is ICustomRole custom)
|
||||
{
|
||||
if (prettyEnabled && custom.Team == ModdedRoleTeams.Custom) roleAddButton.FileImage.sprite = MiraAssets.CustomTeamFile.LoadAsset();
|
||||
if (custom.Team == ModdedRoleTeams.Custom) roleAddButton.FileImage.sprite = MiraAssets.CustomTeamFile.LoadAsset();
|
||||
var customColor = custom.IntroConfiguration?.IntroTeamColor ?? Color.gray;
|
||||
if (custom.Team is ModdedRoleTeams.Crewmate)
|
||||
{
|
||||
@@ -458,7 +448,7 @@ public static class TaskAdderPatches
|
||||
taskAddButton.role = null;
|
||||
taskAddButton.MyTask = null;
|
||||
taskAddButton.SafePositionWorld = __instance.SafePositionWorld;
|
||||
taskAddButton.Text.text = modifier.ModifierName;
|
||||
taskAddButton.Text.text = modifier.ModifierName.Translate();
|
||||
taskAddButton.Text.fontSizeMin = 1;
|
||||
taskAddButton.Text.EnableMasking();
|
||||
taskAddButton.FileImage.color = modifier.FreeplayFileColor;
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Collections;
|
||||
using HarmonyLib;
|
||||
using Il2CppSystem;
|
||||
using MiraAPI.GameModes;
|
||||
using MiraAPI.Translation;
|
||||
using Reactor.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -49,7 +50,7 @@ internal static class HudPatches
|
||||
gmText.SetActive(false);
|
||||
modelText.SetActive(false);
|
||||
_text = gmTextClone.GetComponent<TextMeshPro>();
|
||||
_text.text = CustomGameModeManager.ActiveMode != null ? $"<color=#{CustomGameModeManager.ActiveMode.Color.ToHtmlStringRGBA()}>{CustomGameModeManager.ActiveMode.Name}</color>" : "Classic";
|
||||
_text.text = CustomGameModeManager.ActiveMode != null ? CustomGameModeManager.ActiveMode.ColoredName : MiraLocaleManager.Get("MiraApi.Gamemode.Classic");
|
||||
CustomGameModeManager.ActiveMode?.HudStart(instance);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,12 +42,16 @@ public static class HudManagerPatches
|
||||
ResizeUI(LocalSettingsTabSingleton<MiraApiSettings>.Instance.ButtonUIFactorSlider.Value);
|
||||
}
|
||||
|
||||
private static Transform _storedButtonsParent;
|
||||
public static void ResizeUI(float scaleFactor)
|
||||
{
|
||||
var baseButtons = HudManager.Instance.transform.FindChild("Buttons");
|
||||
if (baseButtons != null)
|
||||
if (!_storedButtonsParent)
|
||||
{
|
||||
foreach (var aspect in baseButtons.GetComponentsInChildren<AspectPosition>(true))
|
||||
_storedButtonsParent = HudManager.Instance.transform.FindChild("Buttons");
|
||||
}
|
||||
if (_storedButtonsParent)
|
||||
{
|
||||
foreach (var aspect in _storedButtonsParent.GetComponentsInChildren<AspectPosition>(true))
|
||||
{
|
||||
if (!aspect.gameObject)
|
||||
{
|
||||
@@ -82,9 +86,9 @@ public static class HudManagerPatches
|
||||
button.gameObject.SetActive(!button.isActiveAndEnabled);
|
||||
}
|
||||
|
||||
if (baseButtons != null)
|
||||
if (_storedButtonsParent)
|
||||
{
|
||||
foreach (var arrange in baseButtons.GetComponentsInChildren<GridArrange>(true))
|
||||
foreach (var arrange in _storedButtonsParent.GetComponentsInChildren<GridArrange>(true))
|
||||
{
|
||||
if (!arrange.gameObject || !arrange.transform)
|
||||
{
|
||||
@@ -281,6 +285,8 @@ public static class HudManagerPatches
|
||||
}
|
||||
MiraApiSettings.OldButtonScaleFactor =
|
||||
LocalSettingsTabSingleton<MiraApiSettings>.Instance.ButtonUIFactorSlider.Value;
|
||||
MiraApiSettings.OldUiButtonScaleFactor =
|
||||
LocalSettingsTabSingleton<MiraApiSettings>.Instance.TopRightButtonsFactorSlider.Value;
|
||||
Coroutines.Start(CoResizeUI());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using Il2CppInterop.Runtime.InteropTypes;
|
||||
using MiraAPI.Events;
|
||||
using MiraAPI.Events.Vanilla.Gameplay;
|
||||
using MiraAPI.MeetingAbilities;
|
||||
using MiraAPI.GameModes;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
|
||||
namespace MiraAPI.Patches;
|
||||
@@ -84,8 +87,8 @@ public static class IntroCutscenePatches
|
||||
{
|
||||
__instance.BackgroundBar.material.SetColor(ShaderID.Color, introConfig.IntroTeamColor);
|
||||
__instance.TeamTitle.color = introConfig.IntroTeamColor;
|
||||
__instance.TeamTitle.text = introConfig.IntroTeamTitle;
|
||||
__instance.ImpostorText.text = introConfig.IntroTeamDescription;
|
||||
__instance.TeamTitle.text = introConfig.IntroTeamTitle.Translate();
|
||||
__instance.ImpostorText.text = introConfig.IntroTeamDescription.Translate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +129,9 @@ public static class IntroCutscenePatches
|
||||
{
|
||||
introCutscene = __instance.Cast<IntroCutscene>();
|
||||
}
|
||||
Info("IntroCutscene ended");
|
||||
|
||||
MeetingButtonManager.OnGameStart();
|
||||
MiraEventManager.InvokeEvent(new IntroEndEvent(introCutscene));
|
||||
|
||||
var @event = new BeforeRoundStartEvent(true);
|
||||
|
||||
@@ -69,6 +69,7 @@ public static class OptionsMenuPatches
|
||||
int i = 0;
|
||||
int tabIdx = 0;
|
||||
int page = 1;
|
||||
LocalSettingsTab.TabGroups.Clear();
|
||||
foreach (var settings in LocalSettingsManager.AvailableTabs)
|
||||
{
|
||||
var tab = settings.CreateTab(__instance);
|
||||
@@ -213,6 +214,8 @@ public static class OptionsMenuPatches
|
||||
|
||||
if (background != null)
|
||||
background.color = tab.TabAppearance.TabColor;
|
||||
|
||||
tab.Open();
|
||||
}
|
||||
private static void CustomClose(LocalSettingsTab tab)
|
||||
{
|
||||
|
||||
@@ -7,8 +7,6 @@ using Reactor.Utilities.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
@@ -9,6 +9,7 @@ using MiraAPI.GameModes;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Presets;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Localization.Utilities;
|
||||
@@ -113,7 +114,7 @@ internal static class GameOptionsMenuPatch
|
||||
_modIcon.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
_gamemodeDescription.text = gameMode.Description;
|
||||
_gamemodeDescription.text = MiraLocaleManager.Get(gameMode.Description);
|
||||
if (gameMode.ShowNormalGameSettings)
|
||||
{
|
||||
foreach (var opt in _vanillaHeaders)
|
||||
@@ -456,7 +457,7 @@ internal static class GameOptionsMenuPatch
|
||||
|
||||
num -= 0.58f;
|
||||
|
||||
categoryHeaderMasked.SetHeader(CustomStringName.CreateAndRegister(group.GroupName), 20);
|
||||
categoryHeaderMasked.SetHeader(MiraLocaleManager.GetOrCreateLocaleString(group.GroupName), 20);
|
||||
categoryHeaderMasked.Background.color = group.GroupColor;
|
||||
categoryHeaderMasked.Divider.color = group.GroupColor;
|
||||
categoryHeaderMasked.Title.color = group.GroupColor.Equals(MiraApiPlugin.DefaultHeaderColor)
|
||||
@@ -538,7 +539,7 @@ internal static class GameOptionsMenuPatch
|
||||
|
||||
internal static void UpdateGroup(AbstractOptionGroup? group, ref float num)
|
||||
{
|
||||
if (group is null || !group.Ready || group.Options.Count == 0 || group.Header is null)
|
||||
if (group is null || !group.Ready || group.Options.Count == 0 || group.Header == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -696,7 +697,7 @@ internal static class GameOptionsMenuPatch
|
||||
Quaternion.identity,
|
||||
container);
|
||||
|
||||
categoryHeaderMasked.SetHeader(CustomStringName.CreateAndRegister(group.GroupName), 20);
|
||||
categoryHeaderMasked.SetHeader(MiraLocaleManager.GetOrCreateLocaleString(group.GroupName), 20);
|
||||
categoryHeaderMasked.Background.color = group.GroupColor;
|
||||
categoryHeaderMasked.Divider.color = group.GroupColor;
|
||||
categoryHeaderMasked.Title.color = group.GroupColor.Equals(MiraApiPlugin.DefaultHeaderColor)
|
||||
@@ -715,7 +716,7 @@ internal static class GameOptionsMenuPatch
|
||||
categoryHeaderMasked.gameObject.SetActive(false);
|
||||
|
||||
var newText = Object.Instantiate(categoryHeaderMasked.Title, categoryHeaderMasked.transform);
|
||||
newText.text = "<size=70%>(Click to close)</size>";
|
||||
newText.text = $"<size=70%>({"MiraApi.GameSetting.Global.ClickToClose".Translate()})</size>";
|
||||
newText.transform.localPosition = new Vector3(2.6249f, -0.165f, 0f);
|
||||
newText.gameObject.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
|
||||
@@ -732,8 +733,8 @@ internal static class GameOptionsMenuPatch
|
||||
{
|
||||
group.AllOptionsHidden = !group.AllOptionsHidden;
|
||||
newText.text = group.AllOptionsHidden
|
||||
? "<size=70%>(Click to open)</size>"
|
||||
: "<size=70%>(Click to close)</size>";
|
||||
? $"<size=70%>({"MiraApi.GameSetting.Global.ClickToOpen".Translate()})</size>"
|
||||
: $"<size=70%>({"MiraApi.GameSetting.Global.ClickToClose".Translate()})</size>";
|
||||
}));
|
||||
headerBtn.SetButtonEnableState(true);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using MiraAPI.GameOptions;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Presets;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Extensions;
|
||||
@@ -45,7 +46,7 @@ internal static class GamePresetsTabPatches
|
||||
|
||||
if (MenuState.Instance.CurrentModIdx != 0)
|
||||
{
|
||||
__instance.PresetDescriptionText.text = "Select or create an options preset for this mod";
|
||||
__instance.PresetDescriptionText.text = "MiraApi.GameSetting.Preset.Hint".Translate();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -184,7 +185,7 @@ internal static class GamePresetsTabPatches
|
||||
|
||||
// set the button text and alignment
|
||||
var saveText = saveButton.buttonText;
|
||||
saveText.text = "Save";
|
||||
saveText.text = "MiraApi.GameSetting.Preset.Save".Translate();
|
||||
saveText.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
saveText.alignment = TextAlignmentOptions.Center;
|
||||
saveText.transform.parent.localPosition = new Vector3(
|
||||
|
||||
@@ -8,6 +8,7 @@ using MiraAPI.GameOptions;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Localization.Utilities;
|
||||
@@ -31,8 +32,7 @@ public static class LobbyViewPanePatches
|
||||
: Plugins[SelectedModIdx - 1];
|
||||
|
||||
private static PassiveButton? ModifiersTabButton { get; set; }
|
||||
|
||||
private static StringNames ModifiersTabName { get; } = CustomStringName.CreateAndRegister("ModifiersTab");
|
||||
internal static StringNames ModifiersTabName { get; } = MiraLocaleManager.GetOrCreateLocaleString("ModifiersTab");
|
||||
|
||||
private static AbstractGameMode? GetCustomGamemode()
|
||||
{
|
||||
@@ -83,7 +83,7 @@ public static class LobbyViewPanePatches
|
||||
var pos = ModifiersTabButton.transform.localPosition;
|
||||
pos.x = 2.1f;
|
||||
ModifiersTabButton.transform.localPosition = pos;
|
||||
ModifiersTabButton.buttonText.text = "Modifiers";
|
||||
ModifiersTabButton.buttonText.text = "Modifiers".Translate();
|
||||
ModifiersTabButton.OnClick = new Button.ButtonClickedEvent();
|
||||
ModifiersTabButton.OnClick.AddListener(
|
||||
(UnityAction)(() =>
|
||||
@@ -151,7 +151,7 @@ public static class LobbyViewPanePatches
|
||||
var cgm = GetCustomGamemode();
|
||||
ModifiersTabButton?.gameObject.SetActive(false);
|
||||
menu.rolesTabButton.gameObject.SetActive(cgm is null or { ShowNormalRoleSettings: true });
|
||||
menu.gameModeText.text = cgm is null ? "Main" : cgm.ColoredName;
|
||||
menu.gameModeText.text = cgm is null ? MiraLocaleManager.Get("MiraApi.Gamemode.Classic") : cgm.ColoredName;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -362,7 +362,7 @@ public static class LobbyViewPanePatches
|
||||
true);
|
||||
|
||||
categoryHeaderMasked.SetHeader(StringNames.Name, 61);
|
||||
categoryHeaderMasked.Title.text = group.GroupName;
|
||||
categoryHeaderMasked.Title.text = group.GroupName.Translate();
|
||||
categoryHeaderMasked.transform.localScale = Vector3.one;
|
||||
categoryHeaderMasked.transform.localPosition = new Vector3(-9.77f, num, -2f);
|
||||
menu.settingsInfo.Add(categoryHeaderMasked.gameObject);
|
||||
@@ -454,7 +454,7 @@ public static class LobbyViewPanePatches
|
||||
// sort the groups by priority
|
||||
var sortedRoleGroups = roleGroups
|
||||
.OrderBy(x => x.Key.Priority)
|
||||
.ThenBy(x => x.Key.Name);
|
||||
.ThenBy(x => x.Key.Name.Translate());
|
||||
|
||||
foreach (var grouping in sortedRoleGroups)
|
||||
{
|
||||
@@ -465,12 +465,7 @@ public static class LobbyViewPanePatches
|
||||
|
||||
var group = grouping.Key;
|
||||
|
||||
var name = group.Name switch
|
||||
{
|
||||
"Crewmate" => StringNames.CrewmateRolesHeader,
|
||||
"Impostor" => StringNames.ImpostorRolesHeader,
|
||||
_ => CustomStringName.CreateAndRegister(group.Name),
|
||||
};
|
||||
var name = MiraLocaleManager.GetOrCreateLocaleString(group.Name);
|
||||
|
||||
var categoryHeaderRoleVariant = Object.Instantiate(instance.categoryHeaderRoleOrigin, instance.settingsContainer, true);
|
||||
categoryHeaderRoleVariant.SetHeader(name, 61);
|
||||
|
||||
@@ -7,6 +7,7 @@ using MiraAPI.GameOptions;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Presets;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Attributes;
|
||||
@@ -149,7 +150,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
_largeButtons[MenuButton.Modifiers] = mBtn;
|
||||
mBtn.name = "ModifiersButton";
|
||||
mBtn.buttonText.gameObject.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
mBtn.buttonText.text = "Modifiers";
|
||||
mBtn.buttonText.text = "Modifiers".Translate();
|
||||
mBtn.OnClick = new Button.ButtonClickedEvent();
|
||||
mBtn.OnClick.AddListener(
|
||||
(UnityAction)(() =>
|
||||
@@ -218,7 +219,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}));
|
||||
|
||||
var roleText = smRolesBtn.buttonText;
|
||||
roleText.text = "Roles";
|
||||
roleText.text = "Roles".Translate();
|
||||
roleText.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
roleText.alignment = TextAlignmentOptions.Center;
|
||||
roleText.transform.parent.localPosition = new Vector3(
|
||||
@@ -243,7 +244,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
var smModBtn = Instantiate(smRolesBtn, smRolesBtn.transform.parent);
|
||||
_smallButtons[MenuButton.Modifiers] = smModBtn;
|
||||
smModBtn.name = "SmallModifiersButton";
|
||||
smModBtn.buttonText.text = "Modifiers";
|
||||
smModBtn.buttonText.text = "Modifiers".Translate();
|
||||
smModBtn.OnClick = new Button.ButtonClickedEvent();
|
||||
smModBtn.OnClick.AddListener(
|
||||
(UnityAction)(() =>
|
||||
@@ -388,7 +389,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
else
|
||||
{
|
||||
var modName = CurrentMod.MiraPlugin.OptionsTitleText;
|
||||
var modName = CurrentMod.MiraPlugin.OptionsTitleText.Translate();
|
||||
_text.text = $"<size=40%>(Page {CurrentModIdx + 1}/{ModCount + 1})</size>\n" +
|
||||
modName[..Math.Min(modName.Length, 25)];
|
||||
}
|
||||
@@ -492,12 +493,12 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
_smallButtons[MenuButton.CustomOne].gameObject.SetActive(true);
|
||||
_smallButtons[MenuButton.CustomOne].transform.localPosition =
|
||||
new Vector3(leftPos, position.y, position.z);
|
||||
_smallButtons[MenuButton.CustomOne].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameOne;
|
||||
_smallButtons[MenuButton.CustomOne].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameOne.Translate();
|
||||
|
||||
_smallButtons[MenuButton.CustomTwo].gameObject.SetActive(true);
|
||||
_smallButtons[MenuButton.CustomTwo].transform.localPosition =
|
||||
new Vector3(rightPos, position.y, position.z);
|
||||
_smallButtons[MenuButton.CustomTwo].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameTwo;
|
||||
_smallButtons[MenuButton.CustomTwo].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameTwo.Translate();
|
||||
position.y -= 0.637f;
|
||||
}
|
||||
|
||||
@@ -506,7 +507,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
{
|
||||
_largeButtons[MenuButton.CustomOne].gameObject.SetActive(true);
|
||||
_largeButtons[MenuButton.CustomOne].transform.localPosition = position;
|
||||
_largeButtons[MenuButton.CustomOne].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameOne;
|
||||
_largeButtons[MenuButton.CustomOne].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameOne.Translate();
|
||||
position.y -= 0.637f;
|
||||
}
|
||||
else
|
||||
@@ -519,7 +520,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
{
|
||||
_largeButtons[MenuButton.CustomTwo].gameObject.SetActive(true);
|
||||
_largeButtons[MenuButton.CustomTwo].transform.localPosition = position;
|
||||
_largeButtons[MenuButton.CustomTwo].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameTwo;
|
||||
_largeButtons[MenuButton.CustomTwo].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameTwo.Translate();
|
||||
position.y -= 0.637f;
|
||||
}
|
||||
else
|
||||
@@ -573,15 +574,15 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
|
||||
case MenuCategory.Modifiers:
|
||||
menu.GameSettingsTab.gameObject.SetActive(true);
|
||||
menu.MenuDescriptionText.text = CurrentMod.MiraPlugin.ModifierMenuDescription;
|
||||
menu.MenuDescriptionText.text = CurrentMod.MiraPlugin.ModifierMenuDescription.Translate();
|
||||
break;
|
||||
case MenuCategory.CustomOne:
|
||||
menu.GameSettingsTab.gameObject.SetActive(true);
|
||||
menu.MenuDescriptionText.text = CurrentMod.MiraPlugin.CustomOptionMenuOneDescription;
|
||||
menu.MenuDescriptionText.text = CurrentMod.MiraPlugin.CustomOptionMenuOneDescription.Translate();
|
||||
break;
|
||||
case MenuCategory.CustomTwo:
|
||||
menu.GameSettingsTab.gameObject.SetActive(true);
|
||||
menu.MenuDescriptionText.text = CurrentMod.MiraPlugin.CustomOptionMenuTwoDescription;
|
||||
menu.MenuDescriptionText.text = CurrentMod.MiraPlugin.CustomOptionMenuTwoDescription.Translate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Il2CppSystem;
|
||||
using MiraAPI.GameModes;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using UnityEngine;
|
||||
@@ -164,7 +165,7 @@ public static class OptionsPatches
|
||||
return true;
|
||||
}
|
||||
|
||||
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title, Array.Empty<Object>());
|
||||
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title, Array.Empty<Object>()).Translate();
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -201,8 +202,7 @@ public static class OptionsPatches
|
||||
{
|
||||
return true;
|
||||
}
|
||||
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title);
|
||||
|
||||
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title).Translate();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ public static class OptionsPatches
|
||||
return true;
|
||||
}
|
||||
|
||||
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title, Array.Empty<Object>());
|
||||
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title, Array.Empty<Object>()).Translate();
|
||||
__instance.ValueText.text = TranslationController.Instance.GetString(__instance.Values[__instance.Value], Array.Empty<Object>());
|
||||
|
||||
return false;
|
||||
|
||||
@@ -9,6 +9,7 @@ using MiraAPI.GameModes;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Localization.Utilities;
|
||||
@@ -195,7 +196,7 @@ public static class RoleSettingMenuPatches
|
||||
// sort the groups by priority
|
||||
var sortedRoleGroups = roleGroups
|
||||
.OrderBy(x => x.Key.Priority)
|
||||
.ThenBy(x => x.Key.Name);
|
||||
.ThenBy(x => x.Key.Name.Translate());
|
||||
|
||||
var quotaThing = roleMenu.categoryHeaderEditRoleOrigin.transform.FindChild("QuotaHeader");
|
||||
var usingNewQuota = false;
|
||||
@@ -214,12 +215,7 @@ public static class RoleSettingMenuPatches
|
||||
|
||||
RoleGroupHidden.TryAdd(group, false);
|
||||
|
||||
var name = group.Name switch
|
||||
{
|
||||
"Crewmate" => StringNames.CrewmateRolesHeader,
|
||||
"Impostor" => StringNames.ImpostorRolesHeader,
|
||||
_ => CustomStringName.CreateAndRegister(group.Name),
|
||||
};
|
||||
var name = MiraLocaleManager.GetOrCreateLocaleString(group.Name);
|
||||
|
||||
var categoryHeaderMasked = Object.Instantiate(
|
||||
template,
|
||||
@@ -293,8 +289,8 @@ public static class RoleSettingMenuPatches
|
||||
quotaInst.gameObject.SetActive(!RoleGroupHidden[group]);
|
||||
|
||||
var label = RoleGroupHidden[group]
|
||||
? "(Click to open)"
|
||||
: "(Click to close)";
|
||||
? $"({"MiraApi.GameSetting.Global.ClickToOpen".Translate()})"
|
||||
: $"({"MiraApi.GameSetting.Global.ClickToClose".Translate()})";
|
||||
var newText = Object.Instantiate(categoryHeaderMasked.Title, categoryHeaderMasked.transform);
|
||||
newText.text = $"<size=70%>{label}</size>";
|
||||
newText.transform.localPosition = new Vector3(2.6249f, -0.165f, 0f);
|
||||
@@ -575,7 +571,7 @@ public static class RoleSettingMenuPatches
|
||||
return;
|
||||
}
|
||||
|
||||
__instance.roleDescriptionText.text = customRole.RoleLongDescription;
|
||||
__instance.roleDescriptionText.text = customRole.RoleMedDescription;
|
||||
__instance.roleTitleText.text = role.GetRoleName();
|
||||
|
||||
var imgBg = __instance.AdvancedRolesSettings.transform.FindChild("Imagebackground");
|
||||
@@ -610,7 +606,7 @@ public static class RoleSettingMenuPatches
|
||||
comp.Destroy();
|
||||
}
|
||||
|
||||
categoryHeaderMasked.Title.text = "RETURN TO ROLE SETTINGS";
|
||||
categoryHeaderMasked.Title.text = "MiraApi.ReturnToRoleSettings".Translate();
|
||||
|
||||
if (!categoryHeaderMasked.gameObject.TryGetComponent<PassiveButton>(out _))
|
||||
{
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
using System.Globalization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using AmongUs.GameOptions;
|
||||
using HarmonyLib;
|
||||
using Innersloth.Assets;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Utilities;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace MiraAPI.Patches;
|
||||
|
||||
@@ -77,7 +81,29 @@ public static class RoleGuidePatches
|
||||
{
|
||||
__instance.numOfTabs = 3;
|
||||
__instance.TabButtons[0].SelectButton(true);
|
||||
__instance.CreateNormalModeSettings();
|
||||
DisplayNormalRoleSettings(__instance, true);
|
||||
__instance.MatchInfoRoleMaskArea.transform.localPosition = new Vector3(-0.0184f, 0.15f, -0.1f);
|
||||
|
||||
__instance.matchInfoPlayersMaskArea.transform.localPosition =
|
||||
__instance.matchInfoSettingsMaskArea.transform.localPosition = new Vector3(1.22f, -0.335f, -0.1f);
|
||||
|
||||
__instance.matchInfoPlayersMaskArea.size =
|
||||
__instance.matchInfoSettingsMaskArea.size =
|
||||
__instance.MatchInfoRoleMaskArea.size = new Vector2(-6, 1.8f);
|
||||
|
||||
__instance.matchInfoPlayersMaskArea.transform.parent.GetAllChildren().First(x => x.name.Contains("BG_Gradient"))
|
||||
.GetComponent<SpriteRenderer>()
|
||||
.maskInteraction =
|
||||
__instance.matchInfoSettingsMaskArea.transform.parent.GetAllChildren()
|
||||
.First(x => x.name.Contains("BG_Gradient")).GetComponent<SpriteRenderer>()
|
||||
.maskInteraction =
|
||||
__instance.MatchInfoRoleMaskArea.transform.parent.GetAllChildren()
|
||||
.First(x => x.name.Contains("BG_Gradient")).GetComponent<SpriteRenderer>()
|
||||
.maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayNormalRoleSettings(__instance, false);
|
||||
}
|
||||
}
|
||||
else if (__instance.HnSModeSettings.Count == 0)
|
||||
@@ -98,6 +124,90 @@ public static class RoleGuidePatches
|
||||
__instance.SetActiveTab(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Dictionary<RoleBehaviour, MatchInfoRolePanel> _rolePanels = [];
|
||||
|
||||
public static void DisplayNormalRoleSettings(MatchInfoGuide instance, bool reset)
|
||||
{
|
||||
if (reset)
|
||||
{
|
||||
_rolePanels.Clear();
|
||||
instance.CreateSettingsEntry(
|
||||
StringNames.GameNumImpostors,
|
||||
GameManager.Instance.AllGameSettingData[StringNames.GameNumImpostors]
|
||||
.GetValueString(GameManager.Instance.LogicOptions.NumImpostors));
|
||||
instance.CreateSettingsEntry(
|
||||
StringNames.GameKillCooldown,
|
||||
GameManager.Instance.AllGameSettingData[StringNames.GameKillCooldown]
|
||||
.GetValueString(GameManager.Instance.LogicOptions.GetKillCooldown()));
|
||||
instance.CreateSettingsEntry(
|
||||
StringNames.GameEmergencyCooldown,
|
||||
GameManager.Instance.AllGameSettingData[StringNames.GameEmergencyCooldown]
|
||||
.GetValueString((float)GameManager.Instance.LogicOptions.GetEmergencyCooldown()));
|
||||
instance.CreateSettingsEntry(
|
||||
StringNames.GameVisualTasks,
|
||||
instance.GetBoolString(GameManager.Instance.LogicOptions.GetVisualTasks()));
|
||||
instance.CreateSettingsEntry(
|
||||
StringNames.GameAnonymousVotes,
|
||||
instance.GetBoolString(GameManager.Instance.LogicOptions.GetAnonymousVotes()));
|
||||
instance.CreateSettingsEntry(
|
||||
StringNames.GameConfirmImpostor,
|
||||
instance.GetBoolString(GameManager.Instance.LogicOptions.GetConfirmImpostor()));
|
||||
instance.CreateSettingsEntry(
|
||||
StringNames.GameTaskBarMode,
|
||||
GameManager.Instance.LogicOptions.GetTaskBarMode().ToString());
|
||||
foreach (RoleBehaviour roleBehaviour in RoleManager.Instance.AllRoles)
|
||||
{
|
||||
if (roleBehaviour.Role != RoleTypes.Crewmate && roleBehaviour.Role != RoleTypes.Impostor &&
|
||||
roleBehaviour.Role is not RoleTypes.CrewmateGhost &&
|
||||
roleBehaviour.Role is not RoleTypes.ImpostorGhost)
|
||||
{
|
||||
var panel = Object.Instantiate(
|
||||
instance.MatchInfoRolePanelPrefab,
|
||||
instance.settingsTabs[2].GetComponent<Scroller>().Inner);
|
||||
_rolePanels.Add(roleBehaviour, panel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int num = 0;
|
||||
foreach (var pair in _rolePanels)
|
||||
{
|
||||
var role = pair.Key;
|
||||
var panel = pair.Value;
|
||||
var amount = GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetNumPerGame(role.Role);
|
||||
var chance = GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetChancePerGame(role.Role);
|
||||
var forciblyShow = role is ICustomRole custom ? custom.ForceShowRoleOnWiki : null;
|
||||
if (amount == 0 || chance == 0 || (Enum.IsDefined(role.Role) && role.IsRoleBlacklisted()) ||
|
||||
(role is ICustomRole custom2 && ((!custom2.CanSpawnOnCurrentMode() && forciblyShow == null) ||
|
||||
(forciblyShow.HasValue && !forciblyShow.Value))))
|
||||
{
|
||||
panel.gameObject.SetActive(false);
|
||||
continue;
|
||||
}
|
||||
|
||||
panel.gameObject.SetActive(true);
|
||||
panel.SetPanel(
|
||||
role,
|
||||
amount,
|
||||
chance);
|
||||
num++;
|
||||
}
|
||||
|
||||
if (num == 0)
|
||||
{
|
||||
instance.rolesEnabledMessage.SetActive(true);
|
||||
}
|
||||
|
||||
instance.MatchInfoRoleScroller.SetYBoundsMax(Mathf.Clamp(Mathf.Ceil((float)num / 2f) * 1.3f - 1.5f, 0f, 999f));
|
||||
instance.MatchInfoRoleMaskArea.material.SetInt(PlayerMaterial.MaskLayer, 50);
|
||||
instance.matchInfoSettingsMaskArea.material.SetInt(PlayerMaterial.MaskLayer, 50);
|
||||
if (reset)
|
||||
{
|
||||
instance.CreatePlayerEntries();
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPriority(Priority.First)]
|
||||
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.CreatePlayerEntries))]
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||
@@ -6,9 +8,12 @@ using InnerNet;
|
||||
using MiraAPI.Events;
|
||||
using MiraAPI.Events.Vanilla.Meeting;
|
||||
using MiraAPI.Events.Vanilla.Meeting.Voting;
|
||||
using MiraAPI.MeetingAbilities;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Components;
|
||||
using MiraAPI.Voting;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Patches.Voting;
|
||||
|
||||
@@ -34,10 +39,46 @@ internal static class MeetingHudPatches
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(PlayerVoteArea), nameof(PlayerVoteArea.Select))]
|
||||
public static bool VoteAreaSelectPatch(PlayerVoteArea __instance)
|
||||
{
|
||||
if (PlayerControl.LocalPlayer.Data.IsDead || __instance.AmDead || !(bool) (UnityEngine.Object) __instance.Parent)
|
||||
return false;
|
||||
JudgeRole? judgeRole = PlayerControl.LocalPlayer.Data.Role.TryCast<JudgeRole>();
|
||||
bool flag = judgeRole && PlayerControl.LocalPlayer.PlayerId != __instance.PlayerId;
|
||||
__instance.JudgeOverruleButton?.gameObject.SetActive(flag);
|
||||
if (__instance.VoteComplete || !__instance.Parent.Select((byte) __instance.PlayerId))
|
||||
return false;
|
||||
__instance.Buttons.SetActive(true);
|
||||
|
||||
float startPos = __instance.AnimateButtonsFromLeft ? 0.2f : 1.95f;
|
||||
|
||||
Il2CppSystem.Collections.Generic.List<UiElement> selectableElements = new Il2CppSystem.Collections.Generic.List<UiElement>();
|
||||
foreach (var btn in __instance.Buttons.GetComponentsInChildren<PassiveButton>())
|
||||
{
|
||||
selectableElements.Add(btn);
|
||||
}
|
||||
|
||||
for (int i = 0; i < selectableElements.Count; i++)
|
||||
{
|
||||
var button = selectableElements[i];
|
||||
float endPos = 1.3f - 0.65f * i;
|
||||
float duration = 0.25f + 0.1f * i;
|
||||
__instance.StartCoroutine(Effects.All(Effects.Lerp(duration, (Action<float>) (t =>
|
||||
button.transform.localPosition = Vector2.Lerp(Vector2.right * startPos, Vector2.right * endPos, Effects.ExpOut(t))))));
|
||||
}
|
||||
|
||||
ControllerManager.Instance.OpenOverlayMenu(__instance.name, __instance.CancelButton, selectableElements[1], selectableElements);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(nameof(MeetingHud.Start))]
|
||||
public static void MeetingHudStartPatch(MeetingHud __instance)
|
||||
{
|
||||
MeetingButtonManager.OnMeetingStart(__instance);
|
||||
foreach (var plr in PlayerControl.AllPlayerControls)
|
||||
{
|
||||
var voteData = plr.GetVoteData();
|
||||
@@ -70,6 +111,15 @@ internal static class MeetingHudPatches
|
||||
[HarmonyPatch(nameof(MeetingHud.VotingComplete))]
|
||||
public static void VotingCompletePatch(MeetingHud __instance)
|
||||
{
|
||||
foreach (var meetingAbility in MeetingButtonManager.UntargetedButtons.Where(x => x.Enabled(PlayerControl.LocalPlayer.Data.Role) &&
|
||||
(x.DisableUponVoting || x.HideUponWrapUp)))
|
||||
{
|
||||
meetingAbility.UpdateHandler(__instance);
|
||||
if (meetingAbility.Button)
|
||||
{
|
||||
meetingAbility.Button!.SetDisabled();
|
||||
}
|
||||
}
|
||||
MiraEventManager.InvokeEvent(new VotingCompleteEvent(__instance));
|
||||
}
|
||||
|
||||
@@ -78,6 +128,16 @@ internal static class MeetingHudPatches
|
||||
[HarmonyPatch(nameof(MeetingHud.Update))]
|
||||
public static void ForceSkipPatch(MeetingHud __instance)
|
||||
{
|
||||
foreach (var targetedMeetingAbility in MeetingButtonManager.TargetedButtons.Where(x => x.Enabled(PlayerControl.LocalPlayer.Data.Role)))
|
||||
{
|
||||
targetedMeetingAbility.UpdateHandler();
|
||||
}
|
||||
|
||||
foreach (var meetingAbility in MeetingButtonManager.UntargetedButtons.Where(x => x.Enabled(PlayerControl.LocalPlayer.Data.Role)))
|
||||
{
|
||||
meetingAbility.UpdateHandler(__instance);
|
||||
}
|
||||
|
||||
if (__instance.state is not (MeetingHud.MeetingStates.NotVoted or MeetingHud.MeetingStates.Voted))
|
||||
{
|
||||
return;
|
||||
@@ -106,7 +166,7 @@ internal static class MeetingHudPatches
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(MeetingHud.Select))]
|
||||
public static bool SelectPatch(MeetingHud __instance, int suspectStateIdx)
|
||||
public static bool MeetingHudSelectPatch(MeetingHud __instance, int suspectStateIdx)
|
||||
{
|
||||
var voteData = PlayerControl.LocalPlayer.GetVoteData();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.PluginLoading;
|
||||
|
||||
@@ -15,11 +14,16 @@ public interface IMiraPlugin
|
||||
/// </summary>
|
||||
public virtual bool DisplayOnOptionsMenu => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value for the localization id to use for anything registered under this mod.
|
||||
/// </summary>
|
||||
public virtual string ParentLocaleId => GetType().Name.ToLower(CultureInfo.InvariantCulture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to display on the options menu.
|
||||
/// </summary>
|
||||
string OptionsTitleText { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the abbreviated name to display for other mods to pick up.
|
||||
/// </summary>
|
||||
|
||||
@@ -5,6 +5,7 @@ using BepInEx.Configuration;
|
||||
using MiraAPI.GameModes;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Hud;
|
||||
using MiraAPI.MeetingAbilities;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Presets;
|
||||
|
||||
@@ -58,6 +59,16 @@ public class MiraPluginInfo
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<CustomActionButton> Buttons { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="IReadOnlyCollection{T}"/> of this <see cref="IMiraPlugin"/>'s <see cref="TargetedMeetingButton"/>.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<TargetedMeetingButton> TargetedMeetingButtons { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="IReadOnlyCollection{T}"/> of this <see cref="IMiraPlugin"/>'s <see cref="MeetingActionButton"/>.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<MeetingActionButton> MeetingButtons { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlyDictionary{TKey, TValue}"/> of this <see cref="IMiraPlugin"/>'s <see cref="OptionPreset"/>s.
|
||||
/// </summary>
|
||||
@@ -71,6 +82,8 @@ public class MiraPluginInfo
|
||||
Options = [..InternalOptions];
|
||||
Roles = new ReadOnlyDictionary<ushort, RoleBehaviour>(InternalRoles);
|
||||
Buttons = [..InternalButtons];
|
||||
MeetingButtons = [..InternalMeetingButtons];
|
||||
TargetedMeetingButtons = [..InternalTargetedMeetingButtons];
|
||||
}
|
||||
|
||||
internal List<OptionPreset> InternalPresets { get; } = [];
|
||||
@@ -86,6 +99,10 @@ public class MiraPluginInfo
|
||||
|
||||
internal List<CustomActionButton> InternalButtons { get; } = [];
|
||||
|
||||
internal List<TargetedMeetingButton> InternalTargetedMeetingButtons { get; } = [];
|
||||
|
||||
internal List<MeetingActionButton> InternalMeetingButtons { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin's ID, as defined in the plugin's BepInEx metadata.
|
||||
/// </summary>
|
||||
|
||||
@@ -18,10 +18,12 @@ using MiraAPI.Hud;
|
||||
using MiraAPI.Keybinds;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.LocalSettings.Attributes;
|
||||
using MiraAPI.MeetingAbilities;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Patches.Options;
|
||||
using MiraAPI.Presets;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Localization.Utilities;
|
||||
using Reactor.Networking;
|
||||
@@ -149,7 +151,7 @@ public sealed class MiraPluginManager
|
||||
|
||||
IL2CPPChainloader.Instance.PluginLoad += (pluginInfo, assembly, plugin) =>
|
||||
{
|
||||
if (plugin is not IMiraPlugin miraPlugin)
|
||||
if (plugin is not IMiraPlugin miraPlugin || pluginInfo.Metadata.GUID == MiraApiPlugin.Id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -223,6 +225,17 @@ public sealed class MiraPluginManager
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (RegisterMeetingAbility(type, info))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegisterTargetedMeetingAbility(type, info))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RegisterGameModeAttribute(type, info))
|
||||
{
|
||||
continue;
|
||||
@@ -259,21 +272,6 @@ public sealed class MiraPluginManager
|
||||
PluginsWithOptionsOrGameModes = [..RegisteredPlugins.Where(m => m.MiraPlugin.DisplayOnOptionsMenu || m.GameModes.Count > 0)];
|
||||
|
||||
ModifierManager.Modifiers = new ReadOnlyCollection<BaseModifier>(ModifierManager.InternalModifiers);
|
||||
|
||||
var dict = new Dictionary<string, object>();
|
||||
foreach (var (key, value) in CustomGameModeManager.IdToModeMap)
|
||||
{
|
||||
if (value is ClassicMode)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
dict.Add(value.Name, key);
|
||||
if (((AmongUs.GameOptions.GameModes) key) == AmongUs.GameOptions.GameModes.Normal)
|
||||
return;
|
||||
// 'Default' was still being registered twice and idk why
|
||||
GameModesHelpers.ModeToName.Add((AmongUs.GameOptions.GameModes)key, CustomStringName.CreateAndRegister(value.Name));
|
||||
}
|
||||
EnumInjector.InjectEnumValues<AmongUs.GameOptions.GameModes>(dict);
|
||||
};
|
||||
|
||||
RegisterKeybinds(typeof(MiraGlobalKeybinds), PluginSingleton<MiraApiPlugin>.Instance);
|
||||
@@ -565,7 +563,7 @@ public sealed class MiraPluginManager
|
||||
KeybindManager.Keybinds.Add(keybind);
|
||||
if (source is IMiraPlugin miraPlugin)
|
||||
{
|
||||
keybind.SourcePluginName = miraPlugin.OptionsTitleText;
|
||||
keybind.SourcePluginName = miraPlugin.OptionsTitleText.Translate();
|
||||
}
|
||||
else if (source is MiraApiPlugin)
|
||||
{
|
||||
@@ -583,4 +581,29 @@ public sealed class MiraPluginManager
|
||||
Error($"Failed to register keybind class {type.Name}: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
private static bool RegisterMeetingAbility(Type type, MiraPluginInfo info)
|
||||
{
|
||||
try
|
||||
{
|
||||
return MeetingButtonManager.RegisterMeetingButton(type, info);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Failed to register meeting ability {type.Name}: {e}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private static bool RegisterTargetedMeetingAbility(Type type, MiraPluginInfo info)
|
||||
{
|
||||
try
|
||||
{
|
||||
return MeetingButtonManager.RegisterTargetedMeetingButton(type, info);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Failed to register targeted meeting ability {type.Name}: {e}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="MiraApi.TopRightButtonScaleFactor">Knopfskalierungsfaktor</string>
|
||||
<string name="MiraApi.WikiOnBottomRow">Wiki Taste Unter Haupt UI</string>
|
||||
<string name="Roles">Rollen</string>
|
||||
<string name="Modifier">Modifikator</string>
|
||||
<string name="Modifiers">Modifikatoren</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate">Besatzung</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate.Short">Besatzung</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor">Verräter</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor.Short">Verräter</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral">Neutral</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral.Short">Neutral</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="MiraApi">Mira API</string>
|
||||
<string name="MiraApi.VisualsUi">Visuals/UI</string>
|
||||
<string name="MiraApi.Accessibility">Accessibility</string>
|
||||
<string name="MiraApi.MiraApiBrand">MiraAPI</string>
|
||||
<string name="MiraApi.ShowModifiersHudOnLeftSide">Show Modifiers HUD on Left Side</string>
|
||||
<string name="MiraApi.ShowKeybindsOnButtons">Show Keybinds on Buttons</string>
|
||||
<string name="MiraApi.ButtonScaleFactor">Button Scale Factor</string>
|
||||
<string name="MiraApi.TopRightButtonScaleFactor">Top-Right UI Scale Factor</string>
|
||||
<string name="MiraApi.MaxFps">Max FPS</string>
|
||||
<string name="MiraApi.WikiOnBottomRow">Display Wiki on Bottom Row</string>
|
||||
<string name="MiraApi.EnableSabotageFlashes">Enable Sabotage Flashes</string>
|
||||
<string name="MiraApi.EnableSabotageBlare">Enable Sabotage Blare</string>
|
||||
<string name="MiraApi.ReturnToRoleSettings">RETURN TO ROLE SETTINGS</string>
|
||||
<string name="MiraApi.CustomCategory1">Custom Category 1</string>
|
||||
<string name="MiraApi.CustomCategory2">Custom Category 2</string>
|
||||
<string name="MiraApi.ModifierMenuDescription">Configure modifiers and their settings here!</string>
|
||||
<string name="MiraApi.CustomOptionMenuDescription">Apply game settings for this mod!</string>
|
||||
<string name="MiraApi.Gamemode.Classic">Classic</string>
|
||||
<string name="MiraApi.Gamemode.Classic.Description">The classic Among Us experience!
|
||||
Find the Impostors or deceive the Crew.</string>
|
||||
<string name="MiraApi.Gamemode.HideAndSeek">Hide n Seek</string>
|
||||
<string name="MiraApi.Gamemode.HideAndSeek.Description">You can run, but you can't hide!
|
||||
Outlive the timer or eliminate the crew.</string>
|
||||
<string name="MiraApi.GameSetting.Global.ClickToClose">Click to close</string>
|
||||
<string name="MiraApi.GameSetting.Global.ClickToOpen">Click to open</string>
|
||||
<string name="MiraApi.GameSetting.Preset.Hint">Select or create a options preset for this game</string>
|
||||
<string name="MiraApi.GameSetting.Preset.Save">Save</string>
|
||||
<string name="Roles">Roles</string>
|
||||
<string name="Modifiers">Modifiers</string>
|
||||
<string name="Modifier">Modifier</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate">Crewmate</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate.Short">Crew</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate.Group">Crewmate Roles</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor">Impostor</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor.Short">Imp</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor.Group">Impostor Roles</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral">Neutral</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral.Short">Neut</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral.Group">Neutral Roles</string>
|
||||
<string name="MiraApi.RoleTeam.Other">Other</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="MiraApi.TopRightButtonScaleFactor">Factor de Escala de la IU superior derecha</string>
|
||||
<string name="MiraApi.WikiOnBottomRow">Botón de Wiki debajo de la IU principal</string>
|
||||
<string name="Roles">Roles</string>
|
||||
<string name="Modifier">Modificador</string>
|
||||
<string name="Modifiers">Modificadores</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate">Tripulante</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate.Short">Trip</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor">Impostor</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor.Short">Imp</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral">Neutral</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral.Short">Neut</string>
|
||||
<string name="MiraApi">API Mira</string>
|
||||
<string name="MiraApi.VisualsUi">Visuales/IU</string>
|
||||
<string name="MiraApi.Accessibility">Accesibilidad</string>
|
||||
<string name="MiraApi.MiraApiBrand">MiraAPI</string>
|
||||
<string name="MiraApi.ShowModifiersHudOnLeftSide">Mostrar Modificadores al Lado Izq</string>
|
||||
<string name="MiraApi.ShowKeybindsOnButtons">Mostrar Atajos en Botones</string>
|
||||
<string name="MiraApi.ButtonScaleFactor">Escala de Botón</string>
|
||||
<string name="MiraApi.MaxFps">FPS Máx</string>
|
||||
<string name="MiraApi.EnableSabotageFlashes">Activar Visuales de Sabotaje</string>
|
||||
<string name="MiraApi.EnableSabotageBlare">Activar Alarma de Sabotaje</string>
|
||||
<string name="MiraApi.ReturnToRoleSettings">REGRESAR A AJUSTES DE ROL</string>
|
||||
<string name="MiraApi.CustomCategory1">Categoría Personalizada 1</string>
|
||||
<string name="MiraApi.CustomCategory2">Categoría Personalizada 2</string>
|
||||
<string name="MiraApi.ModifierMenuDescription">¡Configura modificadores y sus ajustes aquí!</string>
|
||||
<string name="MiraApi.CustomOptionMenuDescription">¡Aplica opciones de partida para este mod!</string>
|
||||
<string name="MiraApi.Gamemode.Classic">Clásico</string>
|
||||
<string name="MiraApi.Gamemode.Classic.Description">La experiencia clásica de Among Us
|
||||
Encuentra a los Impostores o engaña a la Tripulación.</string>
|
||||
<string name="MiraApi.Gamemode.HideAndSeek">Escondidas</string>
|
||||
<string name="MiraApi.Gamemode.HideAndSeek.Description">¡Puedes correr, pero no esconderte!
|
||||
Sobrevive al temporizador o elimina a la Tripulación.</string>
|
||||
<string name="MiraApi.GameSetting.Global.ClickToClose">Click para cerrar</string>
|
||||
<string name="MiraApi.GameSetting.Global.ClickToOpen">Click para abrir</string>
|
||||
<string name="MiraApi.GameSetting.Preset.Hint">Selecciona o crea un ajuste predefinido para esta partida</string>
|
||||
<string name="MiraApi.GameSetting.Preset.Save">Guardar</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate.Group">Roles de Tripulante</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor.Group">Roles de Impostor</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral.Group">Roles Neutrales</string>
|
||||
<string name="MiraApi.RoleTeam.Other">Otros</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="Roles">Roles</string>
|
||||
<string name="Modifier">Modificador</string>
|
||||
<string name="Modifiers">Modificadores</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate">Tripulante</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate.Short">Tripulante</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor">Impostor</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor.Short">Impostor</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral">Neutro</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral.Short">Neutro</string>
|
||||
<string name="MiraApi">Mira API</string>
|
||||
<string name="MiraApi.Accessibility">Accesibilidad</string>
|
||||
<string name="MiraApi.MiraApiBrand">MiraAPI</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="MiraApi.TopRightButtonScaleFactor">Échelle de tailles de boutons</string>
|
||||
<string name="MiraApi.WikiOnBottomRow">Bouton pour le Wiki sous l'interface principale</string>
|
||||
<string name="Roles">Rôles</string>
|
||||
<string name="Modifier">Modificateur</string>
|
||||
<string name="Modifiers">Modificateurs</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate">Coéquipier</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate.Short">Équipage</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor">Imposteur</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor.Short">Impo</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral">Neutre</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral.Short">Neutre</string>
|
||||
</resources>
|
||||
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user