From 7609876f3e0f406f0a628ad54d5d1e1063e96ed0 Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Fri, 21 Jun 2024 21:37:35 +0200 Subject: [PATCH] Whatever --- EHR.csproj | 3 + Modules/ClientOptionItem.cs | 6 +- Modules/CustomNetObject.cs | 2 +- Modules/CustomRolesHelper.cs | 1 + Modules/DisableDevice.cs | 1 - Modules/GuessManager.cs | 2 +- Modules/LoadingScreen.cs | 1 - Modules/ModUpdater.cs | 4 +- Modules/OptionHolder.cs | 2 + Modules/SimpleButton.cs | 17 +- Modules/Translator.cs | 3 +- Modules/Utils.cs | 2 +- Patches/AprilFoolsPatch.cs | 6 +- Patches/CredentialsPatch.cs | 2 +- Patches/GameOptionsMenuPatch.cs | 2 +- Patches/GameStartManagerPatch.cs | 2 +- Patches/HudPatch.cs | 2 +- Patches/IntroPatch.cs | 9 +- Patches/LogoAndStampPatch.cs | 3 +- Patches/MainMenuManagerPatch.cs | 45 ++-- Patches/MeetingHudPatch.cs | 2 +- Patches/OnGameStartedPatch.cs | 2 +- Patches/OutroPatch.cs | 2 +- Patches/PlayerControlPatch.cs | 41 ++- Patches/TaskAdderPatch.cs | 1 - Patches/TaskAssignPatch.cs | 17 +- Roles/Crewmate/Judge.cs | 2 +- Roles/Crewmate/NiceSwapper.cs | 2 +- Roles/Crewmate/ParityCop.cs | 2 +- Roles/Impostor/AntiAdminer.cs | 2 +- Roles/Impostor/Councillor.cs | 2 +- Roles/Impostor/Mafia.cs | 2 +- Roles/Neutral/Totocalcio.cs | 2 +- Roles/RoleBase.cs | 4 +- .../.idea/.idea.SettingsUI/.idea/.gitignore | 13 + .../.idea.SettingsUI/.idea/encodings.xml | 4 + .../.idea.SettingsUI/.idea/indexLayout.xml | 8 + .../.idea/.idea.SettingsUI/.idea/vcs.xml | 6 + SUI/SettingsUI/App.xaml | 9 + SUI/SettingsUI/App.xaml.cs | 12 + SUI/SettingsUI/AssemblyInfo.cs | 10 + SUI/SettingsUI/MainWindow.xaml | 91 +++++++ SUI/SettingsUI/MainWindow.xaml.cs | 236 ++++++++++++++++++ SUI/SettingsUI/SettingsUI.csproj | 36 +++ SUI/SettingsUI/SettingsUI.sln | 16 ++ main.cs | 4 +- 46 files changed, 569 insertions(+), 74 deletions(-) create mode 100644 SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/.gitignore create mode 100644 SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/encodings.xml create mode 100644 SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/indexLayout.xml create mode 100644 SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/vcs.xml create mode 100644 SUI/SettingsUI/App.xaml create mode 100644 SUI/SettingsUI/App.xaml.cs create mode 100644 SUI/SettingsUI/AssemblyInfo.cs create mode 100644 SUI/SettingsUI/MainWindow.xaml create mode 100644 SUI/SettingsUI/MainWindow.xaml.cs create mode 100644 SUI/SettingsUI/SettingsUI.csproj create mode 100644 SUI/SettingsUI/SettingsUI.sln diff --git a/EHR.csproj b/EHR.csproj index 12338f853..6ac69927a 100644 --- a/EHR.csproj +++ b/EHR.csproj @@ -15,12 +15,15 @@ + + + diff --git a/Modules/ClientOptionItem.cs b/Modules/ClientOptionItem.cs index 4405b56d6..3973b223b 100644 --- a/Modules/ClientOptionItem.cs +++ b/Modules/ClientOptionItem.cs @@ -1,18 +1,16 @@ using System; using BepInEx.Configuration; using UnityEngine; -using Object = UnityEngine.Object; namespace EHR; //来源:https://github.com/tukasa0001/TownOfHost/pull/1265 public class ClientOptionItem { - public ConfigEntry Config; - public ToggleButtonBehaviour ToggleButton; - public static SpriteRenderer CustomBackground; private static int numOptions; + public ConfigEntry Config; + public ToggleButtonBehaviour ToggleButton; private ClientOptionItem( string name, diff --git a/Modules/CustomNetObject.cs b/Modules/CustomNetObject.cs index 0f543b7b1..d398bf2d4 100644 --- a/Modules/CustomNetObject.cs +++ b/Modules/CustomNetObject.cs @@ -5,7 +5,7 @@ using EHR.Roles.Crewmate; using Hazel; using InnerNet; using UnityEngine; -using Object = UnityEngine.Object; + // Credit: https://github.com/Rabek009/MoreGamemodes/blob/e054eb498094dfca0a365fc6b6fea8d17f9974d7/Modules/CustomObjects // Huge thanks to Rabek009 for this code! diff --git a/Modules/CustomRolesHelper.cs b/Modules/CustomRolesHelper.cs index db5dc2e77..85c4bcd8b 100644 --- a/Modules/CustomRolesHelper.cs +++ b/Modules/CustomRolesHelper.cs @@ -8,6 +8,7 @@ using EHR.Roles.Crewmate; using EHR.Roles.Impostor; using EHR.Roles.Neutral; using UnityEngine; +using Monitor = EHR.Roles.Crewmate.Monitor; namespace EHR; diff --git a/Modules/DisableDevice.cs b/Modules/DisableDevice.cs index edc63b87d..2a3344612 100644 --- a/Modules/DisableDevice.cs +++ b/Modules/DisableDevice.cs @@ -4,7 +4,6 @@ using System.Linq; using EHR.Neutral; using HarmonyLib; using UnityEngine; -using Object = UnityEngine.Object; namespace EHR; diff --git a/Modules/GuessManager.cs b/Modules/GuessManager.cs index d497dca74..410909d83 100644 --- a/Modules/GuessManager.cs +++ b/Modules/GuessManager.cs @@ -13,7 +13,7 @@ using TMPro; using UnityEngine; using UnityEngine.Events; using static EHR.Translator; -using Object = UnityEngine.Object; + namespace EHR; diff --git a/Modules/LoadingScreen.cs b/Modules/LoadingScreen.cs index a23de09c3..3b85ebbae 100644 --- a/Modules/LoadingScreen.cs +++ b/Modules/LoadingScreen.cs @@ -2,7 +2,6 @@ using EHR.Patches; using Rewired.Utils; using UnityEngine; -using Object = UnityEngine.Object; namespace EHR.Modules { diff --git a/Modules/ModUpdater.cs b/Modules/ModUpdater.cs index 28483c829..1499973e1 100644 --- a/Modules/ModUpdater.cs +++ b/Modules/ModUpdater.cs @@ -9,7 +9,7 @@ using Newtonsoft.Json.Linq; using Twitch; using UnityEngine; using static EHR.Translator; -using Object = UnityEngine.Object; + namespace EHR; @@ -308,4 +308,4 @@ public class ModUpdater else button.GetComponent().OnClick.AddListener((Action)(() => InfoPopup.Close())); } } -} +} \ No newline at end of file diff --git a/Modules/OptionHolder.cs b/Modules/OptionHolder.cs index 7567a73d0..4673f8e06 100644 --- a/Modules/OptionHolder.cs +++ b/Modules/OptionHolder.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; @@ -778,6 +779,7 @@ public static class Options Logger.Info("Options.Load End", "Options"); GroupOptions(); GroupAddons(); + Process.Start(@".\EHR_DATA\SettingsUI.exe"); #if DEBUG // Used for generating the table of roles for the README diff --git a/Modules/SimpleButton.cs b/Modules/SimpleButton.cs index 46954293c..41f20ba30 100644 --- a/Modules/SimpleButton.cs +++ b/Modules/SimpleButton.cs @@ -1,12 +1,16 @@ using System; using TMPro; using UnityEngine; -using Object = UnityEngine.Object; namespace EHR; public class SimpleButton { + private static PassiveButton baseButton; + private readonly BoxCollider2D buttonCollider; + private float _fontSize; + private Vector2 _scale; + /// 新しいボタンを作成する /// 親オブジェクト /// オブジェクト名 @@ -52,31 +56,31 @@ public class SimpleButton Label.text = label; Button.gameObject.SetActive(isActive); } + public PassiveButton Button { get; } public TextMeshPro Label { get; } public SpriteRenderer NormalSprite { get; } public SpriteRenderer HoverSprite { get; } - private readonly BoxCollider2D buttonCollider; - private Vector2 _scale; + public Vector2 Scale { get => _scale; set => _scale = NormalSprite.size = HoverSprite.size = buttonCollider.size = value; } - private float _fontSize; + public float FontSize { get => _fontSize; set => _fontSize = Label.fontSize = Label.fontSizeMin = Label.fontSizeMax = value; } - private static PassiveButton baseButton; public static void SetBase(PassiveButton passiveButton) { if (baseButton != null || passiveButton == null) { return; } + // 複製 baseButton = Object.Instantiate(passiveButton); var label = baseButton.transform.Find("FontPlacer/Text_TMP").GetComponent(); @@ -95,5 +99,6 @@ public class SimpleButton buttonCollider.offset = new(0f, 0f); baseButton.OnClick = new(); } + public static bool IsNullOrDestroyed(SimpleButton button) => button == null || button.Button == null; -} +} \ No newline at end of file diff --git a/Modules/Translator.cs b/Modules/Translator.cs index 1a158903b..2761f7cc3 100644 --- a/Modules/Translator.cs +++ b/Modules/Translator.cs @@ -9,7 +9,6 @@ using System.Text.Json; using System.Text.RegularExpressions; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; -using Object = Il2CppSystem.Object; namespace EHR; @@ -164,7 +163,7 @@ public static class Translator } public static string GetString(StringNames stringName) - => DestroyableSingleton.Instance.GetString(stringName, new Il2CppReferenceArray(0)); + => DestroyableSingleton.Instance.GetString(stringName, new Il2CppReferenceArray(0)); public static string GetRoleString(string str, bool forUser = true) { diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 588fbf207..160151b61 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -27,7 +27,7 @@ using InnerNet; using Newtonsoft.Json; using UnityEngine; using static EHR.Translator; -using Object = UnityEngine.Object; + namespace EHR; diff --git a/Patches/AprilFoolsPatch.cs b/Patches/AprilFoolsPatch.cs index c8a853072..268aa7f92 100644 --- a/Patches/AprilFoolsPatch.cs +++ b/Patches/AprilFoolsPatch.cs @@ -1,6 +1,6 @@ using HarmonyLib; -using Il2CppSystem; using static CosmeticsLayer; +using Action = Il2CppSystem.Action; namespace EHR.Patches; @@ -104,8 +104,8 @@ public static class LongBoiPatches try { __instance.cosmeticLayer.OnSetBodyAsGhost += (Action)__instance.SetPoolableGhost; - __instance.cosmeticLayer.OnColorChange += (Action)__instance.SetHeightFromColor; - __instance.cosmeticLayer.OnCosmeticSet += (Action)__instance.OnCosmeticSet; + __instance.cosmeticLayer.OnColorChange += (Il2CppSystem.Action)__instance.SetHeightFromColor; + __instance.cosmeticLayer.OnCosmeticSet += (Il2CppSystem.Action)__instance.OnCosmeticSet; __instance.gameObject.layer = 8; } catch diff --git a/Patches/CredentialsPatch.cs b/Patches/CredentialsPatch.cs index 76e649204..7c4fc910a 100644 --- a/Patches/CredentialsPatch.cs +++ b/Patches/CredentialsPatch.cs @@ -7,7 +7,7 @@ using HarmonyLib; using TMPro; using UnityEngine; using static EHR.Translator; -using Object = UnityEngine.Object; + namespace EHR; diff --git a/Patches/GameOptionsMenuPatch.cs b/Patches/GameOptionsMenuPatch.cs index 48431ebef..76aeed3a8 100644 --- a/Patches/GameOptionsMenuPatch.cs +++ b/Patches/GameOptionsMenuPatch.cs @@ -6,7 +6,7 @@ using HarmonyLib; using TMPro; using UnityEngine; using static EHR.Translator; -using Object = UnityEngine.Object; + namespace EHR; diff --git a/Patches/GameStartManagerPatch.cs b/Patches/GameStartManagerPatch.cs index f50c118f4..60e95b1d7 100644 --- a/Patches/GameStartManagerPatch.cs +++ b/Patches/GameStartManagerPatch.cs @@ -10,7 +10,7 @@ using InnerNet; using TMPro; using UnityEngine; using static EHR.Translator; -using Object = UnityEngine.Object; + namespace EHR; diff --git a/Patches/HudPatch.cs b/Patches/HudPatch.cs index 4f0e6f88f..02b1b6396 100644 --- a/Patches/HudPatch.cs +++ b/Patches/HudPatch.cs @@ -11,7 +11,7 @@ using Il2CppSystem.Text; using TMPro; using UnityEngine; using static EHR.Translator; -using Object = UnityEngine.Object; + namespace EHR.Patches; diff --git a/Patches/IntroPatch.cs b/Patches/IntroPatch.cs index 0ff43197d..95b28a07f 100644 --- a/Patches/IntroPatch.cs +++ b/Patches/IntroPatch.cs @@ -5,7 +5,6 @@ using AmongUs.GameOptions; using EHR.Modules; using EHR.Roles.Neutral; using HarmonyLib; -using Il2CppSystem.Collections.Generic; using UnityEngine; using static EHR.Translator; @@ -159,7 +158,7 @@ class CoBeginPatch [HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.BeginCrewmate))] class BeginCrewmatePatch { - public static bool Prefix(IntroCutscene __instance, ref List teamToDisplay) + public static bool Prefix(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List teamToDisplay) { if (PlayerControl.LocalPlayer.Is(CustomRoleTypes.Neutral) && !PlayerControl.LocalPlayer.GetCustomRole().IsMadmate()) { @@ -228,7 +227,7 @@ class BeginCrewmatePatch return true; } - public static void Postfix(IntroCutscene __instance, ref List teamToDisplay) + public static void Postfix(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List teamToDisplay) { CustomRoles role = PlayerControl.LocalPlayer.GetCustomRole(); @@ -568,7 +567,7 @@ class BeginCrewmatePatch [HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.BeginImpostor))] class BeginImpostorPatch { - public static bool Prefix(IntroCutscene __instance, ref List yourTeam) + public static bool Prefix(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List yourTeam) { var role = PlayerControl.LocalPlayer.GetCustomRole(); if (PlayerControl.LocalPlayer.Is(CustomRoles.Madmate) || role.IsMadmate()) @@ -603,7 +602,7 @@ class BeginImpostorPatch return true; } - public static void Postfix(IntroCutscene __instance, ref List yourTeam) + public static void Postfix(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List yourTeam) { BeginCrewmatePatch.Postfix(__instance, ref yourTeam); } diff --git a/Patches/LogoAndStampPatch.cs b/Patches/LogoAndStampPatch.cs index 631a57628..074452788 100644 --- a/Patches/LogoAndStampPatch.cs +++ b/Patches/LogoAndStampPatch.cs @@ -1,7 +1,6 @@ using System.Collections; using BepInEx.Unity.IL2CPP.Utils; using HarmonyLib; -using TMPro; using UnityEngine; using static EHR.Translator; @@ -77,6 +76,7 @@ public static class CredentialsPatch SponsersData += $"\n\n({GetString("OnlyShowPart")})"; } +/* static void ViewBoosterPatch(MainMenuManager __instance) { var template = __instance.transform.FindChild("StatsPopup"); @@ -140,6 +140,7 @@ public static class CredentialsPatch obj.transform.FindChild("Background").localScale = new(1.5f, 1f, 1f); obj.transform.FindChild("CloseButton").localPosition = new(-3.75f, 2.65f, 0); } +*/ public static void Postfix(MainMenuManager __instance) { diff --git a/Patches/MainMenuManagerPatch.cs b/Patches/MainMenuManagerPatch.cs index 11c93d0b4..22cb93638 100644 --- a/Patches/MainMenuManagerPatch.cs +++ b/Patches/MainMenuManagerPatch.cs @@ -2,21 +2,24 @@ using System; using HarmonyLib; using TMPro; using UnityEngine; -using Object = UnityEngine.Object; namespace EHR; [HarmonyPatch] public class MainMenuManagerPatch { - public static MainMenuManager Instance { get; private set; } - public static PassiveButton Template; public static PassiveButton UpdateButton; private static PassiveButton gitHubButton; private static PassiveButton discordButton; private static PassiveButton websiteButton; + private static bool isOnline = false; + public static bool ShowedBak = false; + private static bool ShowingPanel = false; + public static SpriteRenderer MG_Logo; + public static MainMenuManager Instance { get; private set; } + [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.OpenGameModeMenu))] [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.OpenAccountMenu))] [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.OpenCredits))] @@ -40,11 +43,12 @@ public class MainMenuManagerPatch Instance.OpenGameModeMenu(); } - private static bool isOnline = false; - public static bool ShowedBak = false; - private static bool ShowingPanel = false; [HarmonyPatch(typeof(SignInStatusComponent), nameof(SignInStatusComponent.SetOnline)), HarmonyPostfix] - public static void SetOnline_Postfix() {LateTask.New(() => { isOnline = true; }, 0.1f, "Set Online Status"); } + public static void SetOnline_Postfix() + { + LateTask.New(() => { isOnline = true; }, 0.1f, "Set Online Status"); + } + [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start)), HarmonyPrefix] public static void Start_Prefix(MainMenuManager __instance) { @@ -62,14 +66,15 @@ public class MainMenuManagerPatch Translator.GetString("updateButton")); UpdateButton.transform.localScale = Vector3.one; } + UpdateButton.gameObject.SetActive(ModUpdater.hasUpdate); Application.targetFrameRate = Main.UnlockFps.Value ? 9999 : 60; } + [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.LateUpdate)), HarmonyPostfix] public static void MainMenuManager_LateUpdate() { - if (GameObject.Find("MainUI") == null) ShowingPanel = false; if (TitleLogoPatch.RightPanel != null) @@ -77,9 +82,9 @@ public class MainMenuManagerPatch var pos1 = TitleLogoPatch.RightPanel.transform.localPosition; Vector3 lerp1 = Vector3.Lerp(pos1, TitleLogoPatch.RightPanelOp + new Vector3(ShowingPanel ? 0f : 10f, 0f, 0f), Time.deltaTime * (ShowingPanel ? 3f : 2f)); if (ShowingPanel - ? TitleLogoPatch.RightPanel.transform.localPosition.x > TitleLogoPatch.RightPanelOp.x + 0.03f - : TitleLogoPatch.RightPanel.transform.localPosition.x < TitleLogoPatch.RightPanelOp.x + 9f - ) TitleLogoPatch.RightPanel.transform.localPosition = lerp1; + ? TitleLogoPatch.RightPanel.transform.localPosition.x > TitleLogoPatch.RightPanelOp.x + 0.03f + : TitleLogoPatch.RightPanel.transform.localPosition.x < TitleLogoPatch.RightPanelOp.x + 9f + ) TitleLogoPatch.RightPanel.transform.localPosition = lerp1; } if (ShowedBak || !isOnline) return; @@ -90,19 +95,19 @@ public class MainMenuManagerPatch bak.transform.position = lerp2; if (pos2.y > 7f) ShowedBak = true; } - public static SpriteRenderer MG_Logo; + [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start)), HarmonyPostfix, HarmonyPriority(Priority.VeryHigh)] public static void Start_Postfix(MainMenuManager __instance) { Instance = __instance; SimpleButton.SetBase(__instance.quitButton); - var logoObject = new GameObject("titleLogo_MG"); - var logoTransform = logoObject.transform; - MG_Logo = logoObject.AddComponent(); - logoTransform.localPosition = new(2f, -0.5f, 1f); - logoTransform.localScale *= 1.2f; - MG_Logo.sprite = Utils.LoadSprite("EHR.Resources.Images.EHR-Icon.png", 400f); + var logoObject = new GameObject("titleLogo_MG"); + var logoTransform = logoObject.transform; + MG_Logo = logoObject.AddComponent(); + logoTransform.localPosition = new(2f, -0.5f, 1f); + logoTransform.localScale *= 1.2f; + MG_Logo.sprite = Utils.LoadSprite("EHR.Resources.Images.EHR-Icon.png", 400f); // GitHub Button if (gitHubButton == null) @@ -115,6 +120,7 @@ public class MainMenuManagerPatch () => Application.OpenURL("https://github.com/Gurge44/EndlessHostRoles"), Translator.GetString("GitHub")); //"GitHub" } + gitHubButton.gameObject.SetActive(true); // Discord Button @@ -128,6 +134,7 @@ public class MainMenuManagerPatch () => Application.OpenURL("https://discord.com/invite/m3ayxfumC8"), Translator.GetString("Discord")); //"Discord" } + discordButton.gameObject.SetActive(true); // Website Button @@ -141,10 +148,12 @@ public class MainMenuManagerPatch () => Application.OpenURL("https://sites.google.com/view/ehr-au"), Translator.GetString("Website")); //"Website" } + websiteButton.gameObject.SetActive(true); Application.targetFrameRate = Main.UnlockFps.Value ? 9999 : 60; } + public static PassiveButton CreateButton(string name, Vector3 localPosition, Color32 normalColor, Color32 hoverColor, Action action, string label, Vector2? scale = null) { var button = Object.Instantiate(Template, Template.transform.parent); diff --git a/Patches/MeetingHudPatch.cs b/Patches/MeetingHudPatch.cs index 1657fbadd..851e403f9 100644 --- a/Patches/MeetingHudPatch.cs +++ b/Patches/MeetingHudPatch.cs @@ -10,7 +10,7 @@ using EHR.Roles.Neutral; using HarmonyLib; using UnityEngine; using static EHR.Translator; -using Object = UnityEngine.Object; + namespace EHR.Patches; diff --git a/Patches/OnGameStartedPatch.cs b/Patches/OnGameStartedPatch.cs index 9ce6deb87..de82eb53f 100644 --- a/Patches/OnGameStartedPatch.cs +++ b/Patches/OnGameStartedPatch.cs @@ -21,7 +21,7 @@ using UnityEngine; using static EHR.Modules.CustomRoleSelector; using static EHR.Translator; using DateTime = Il2CppSystem.DateTime; -using Object = UnityEngine.Object; + namespace EHR; diff --git a/Patches/OutroPatch.cs b/Patches/OutroPatch.cs index 2def091fa..d4c0970bb 100644 --- a/Patches/OutroPatch.cs +++ b/Patches/OutroPatch.cs @@ -10,7 +10,7 @@ using HarmonyLib; using TMPro; using UnityEngine; using static EHR.Translator; -using Object = UnityEngine.Object; + namespace EHR; diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index 3af0649a9..14d34974f 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -22,7 +22,7 @@ using TMPro; using UnityEngine; using static EHR.Translator; using static EHR.Utils; -using Object = UnityEngine.Object; + namespace EHR; @@ -2086,4 +2086,43 @@ class PlayerControlLocalSetRolePatch } } } +} + +[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CmdCheckVanish))] +class CmdCheckVanishPatch +{ + public static bool Prefix(PlayerControl __instance, float maxDuration) + { + if (AmongUsClient.Instance.AmHost) + { + __instance.CheckVanish(); + return false; + } + + __instance.SetRoleInvisibility(true); + MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckVanish, SendOption.Reliable, AmongUsClient.Instance.HostId); + messageWriter.Write(maxDuration); + AmongUsClient.Instance.FinishRpcImmediately(messageWriter); + + return false; + } +} + +[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CmdCheckAppear))] +class CmdCheckAppearPatch +{ + public static bool Prefix(PlayerControl __instance, bool shouldAnimate) + { + if (AmongUsClient.Instance.AmHost) + { + __instance.CheckAppear(shouldAnimate); + return false; + } + + MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckAppear, SendOption.Reliable, AmongUsClient.Instance.HostId); + messageWriter.Write(shouldAnimate); + AmongUsClient.Instance.FinishRpcImmediately(messageWriter); + + return false; + } } \ No newline at end of file diff --git a/Patches/TaskAdderPatch.cs b/Patches/TaskAdderPatch.cs index 2c9749d5a..f33e7bb01 100644 --- a/Patches/TaskAdderPatch.cs +++ b/Patches/TaskAdderPatch.cs @@ -1,7 +1,6 @@ using System; using AmongUs.GameOptions; using HarmonyLib; -using Object = UnityEngine.Object; namespace EHR; diff --git a/Patches/TaskAssignPatch.cs b/Patches/TaskAssignPatch.cs index 0ef9136dc..54f2b7009 100644 --- a/Patches/TaskAssignPatch.cs +++ b/Patches/TaskAssignPatch.cs @@ -5,8 +5,7 @@ using EHR.Roles.AddOns.GhostRoles; using EHR.Roles.Impostor; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; -using Il2CppSystem.Collections.Generic; -using UnityEngine; +using Random = UnityEngine.Random; namespace EHR; @@ -14,7 +13,7 @@ namespace EHR; class AddTasksFromListPatch { public static void Prefix( /*ShipStatus __instance,*/ - [HarmonyArgument(4)] List unusedTasks) + [HarmonyArgument(4)] Il2CppSystem.Collections.Generic.List unusedTasks) { if (!AmongUsClient.Instance.AmHost) return; @@ -168,7 +167,7 @@ class RpcSetTasksPatch NumLongTasks = 0; } - // Overtime maniac, work overtime~ + // Workhorse task assignment if (pc.Is(CustomRoles.Workhorse)) (hasCommonTasks, NumLongTasks, NumShortTasks) = Workhorse.TaskData; @@ -191,7 +190,7 @@ class RpcSetTasksPatch // List containing IDs of assignable tasks // Clone of the second argument of the original RpcSetTasks - List TasksList = new(); + Il2CppSystem.Collections.Generic.List TasksList = new(); foreach (var num in taskTypeIds) { TasksList.Add(num); @@ -207,18 +206,18 @@ class RpcSetTasksPatch // HashSet where assigned tasks will be placed // Prevent multiple assignments of the same task - HashSet usedTaskTypes = new(); + Il2CppSystem.Collections.Generic.HashSet usedTaskTypes = new(); int start2 = 0; int start3 = 0; // List of assignable long tasks - List LongTasks = new(); + Il2CppSystem.Collections.Generic.List LongTasks = new(); foreach (var task in ShipStatus.Instance.LongTasks) LongTasks.Add(task); Shuffle(LongTasks); // List of assignable short tasks - List ShortTasks = new(); + Il2CppSystem.Collections.Generic.List ShortTasks = new(); foreach (var task in ShipStatus.Instance.ShortTasks) ShortTasks.Add(task); Shuffle(ShortTasks); @@ -247,7 +246,7 @@ class RpcSetTasksPatch } } - private static void Shuffle(List list) + private static void Shuffle(Il2CppSystem.Collections.Generic.List list) { for (int i = 0; i < list.Count - 1; i++) { diff --git a/Roles/Crewmate/Judge.cs b/Roles/Crewmate/Judge.cs index b9da4cda1..e852f9b0d 100644 --- a/Roles/Crewmate/Judge.cs +++ b/Roles/Crewmate/Judge.cs @@ -7,7 +7,7 @@ using HarmonyLib; using Hazel; using UnityEngine; using static EHR.Translator; -using Object = UnityEngine.Object; + namespace EHR.Roles.Crewmate; diff --git a/Roles/Crewmate/NiceSwapper.cs b/Roles/Crewmate/NiceSwapper.cs index f98af07a1..dfcd98989 100644 --- a/Roles/Crewmate/NiceSwapper.cs +++ b/Roles/Crewmate/NiceSwapper.cs @@ -5,7 +5,7 @@ using HarmonyLib; using Hazel; using UnityEngine; using static EHR.Translator; -using Object = UnityEngine.Object; + namespace EHR.Roles.Crewmate; diff --git a/Roles/Crewmate/ParityCop.cs b/Roles/Crewmate/ParityCop.cs index 299eb0e32..b80d1b94f 100644 --- a/Roles/Crewmate/ParityCop.cs +++ b/Roles/Crewmate/ParityCop.cs @@ -6,7 +6,7 @@ using HarmonyLib; using UnityEngine; using static EHR.Options; using static EHR.Translator; -using Object = UnityEngine.Object; + namespace EHR.Roles.Crewmate; diff --git a/Roles/Impostor/AntiAdminer.cs b/Roles/Impostor/AntiAdminer.cs index 0dc76f58b..94577dee2 100644 --- a/Roles/Impostor/AntiAdminer.cs +++ b/Roles/Impostor/AntiAdminer.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.Linq; using AmongUs.GameOptions; -using EHR.Roles.Crewmate; using EHR.Roles.Neutral; using UnityEngine; +using Monitor = EHR.Roles.Crewmate.Monitor; namespace EHR.Roles.Impostor; diff --git a/Roles/Impostor/Councillor.cs b/Roles/Impostor/Councillor.cs index 53295550d..4f79ba177 100644 --- a/Roles/Impostor/Councillor.cs +++ b/Roles/Impostor/Councillor.cs @@ -8,7 +8,7 @@ using HarmonyLib; using Hazel; using UnityEngine; using static EHR.Translator; -using Object = UnityEngine.Object; + namespace EHR.Roles.Impostor; diff --git a/Roles/Impostor/Mafia.cs b/Roles/Impostor/Mafia.cs index 032b1c7b1..72c389ff5 100644 --- a/Roles/Impostor/Mafia.cs +++ b/Roles/Impostor/Mafia.cs @@ -8,7 +8,7 @@ using Hazel; using UnityEngine; using static EHR.Options; using static EHR.Translator; -using Object = UnityEngine.Object; + namespace EHR.Roles.Impostor { diff --git a/Roles/Neutral/Totocalcio.cs b/Roles/Neutral/Totocalcio.cs index 539754f31..d2e4c096d 100644 --- a/Roles/Neutral/Totocalcio.cs +++ b/Roles/Neutral/Totocalcio.cs @@ -2,10 +2,10 @@ using System.Collections.Generic; using System.Linq; using EHR.Modules; using Hazel; -using Il2CppSystem; using UnityEngine; using static EHR.Options; using static EHR.Translator; +using Math = System.Math; namespace EHR.Roles.Neutral; diff --git a/Roles/RoleBase.cs b/Roles/RoleBase.cs index a87eae98b..b165100a6 100644 --- a/Roles/RoleBase.cs +++ b/Roles/RoleBase.cs @@ -1,9 +1,11 @@ -using System; +global using Object = UnityEngine.Object; +using System; using System.Text; using AmongUs.GameOptions; using EHR.Roles.AddOns.Crewmate; using EHR.Roles.AddOns.Impostor; + namespace EHR { public abstract class RoleBase : IComparable diff --git a/SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/.gitignore b/SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/.gitignore new file mode 100644 index 000000000..a271ace82 --- /dev/null +++ b/SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/contentModel.xml +/.idea.SettingsUI.iml +/modules.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/encodings.xml b/SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/encodings.xml new file mode 100644 index 000000000..df87cf951 --- /dev/null +++ b/SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/indexLayout.xml b/SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/indexLayout.xml new file mode 100644 index 000000000..7b08163ce --- /dev/null +++ b/SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/vcs.xml b/SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/vcs.xml new file mode 100644 index 000000000..b2bdec2d7 --- /dev/null +++ b/SUI/SettingsUI/.idea/.idea.SettingsUI/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SUI/SettingsUI/App.xaml b/SUI/SettingsUI/App.xaml new file mode 100644 index 000000000..f13a54542 --- /dev/null +++ b/SUI/SettingsUI/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/SUI/SettingsUI/App.xaml.cs b/SUI/SettingsUI/App.xaml.cs new file mode 100644 index 000000000..1a12bda1b --- /dev/null +++ b/SUI/SettingsUI/App.xaml.cs @@ -0,0 +1,12 @@ +using System.Configuration; +using System.Data; +using System.Windows; + +namespace SettingsUI; + +/// +/// Interaction logic for App.xaml +/// +public partial class App : Application +{ +} \ No newline at end of file diff --git a/SUI/SettingsUI/AssemblyInfo.cs b/SUI/SettingsUI/AssemblyInfo.cs new file mode 100644 index 000000000..4a05c7d47 --- /dev/null +++ b/SUI/SettingsUI/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] \ No newline at end of file diff --git a/SUI/SettingsUI/MainWindow.xaml b/SUI/SettingsUI/MainWindow.xaml new file mode 100644 index 000000000..eea385331 --- /dev/null +++ b/SUI/SettingsUI/MainWindow.xaml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SUI/SettingsUI/MainWindow.xaml.cs b/SUI/SettingsUI/MainWindow.xaml.cs new file mode 100644 index 000000000..adbed7232 --- /dev/null +++ b/SUI/SettingsUI/MainWindow.xaml.cs @@ -0,0 +1,236 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Effects; +using System.Windows.Media.Imaging; +using EHR; +using EHR.Modules; + +namespace SettingsUI; + +public partial class MainWindow +{ + + private Dictionary Tabs = []; + + static int GetParentOffset(OptionItem item) + { + var offset = 0; + while (item.Parent != null) + { + offset += 10; + item = item.Parent; + } + + return offset; + } + + static StackPanel SetupOption(string name, string value, OptionItem tag) => new() + { + Orientation = Orientation.Horizontal, + Background = Brushes.DimGray, + Margin = new(GetParentOffset(tag), 5, 0, 5), + Children = + { + new TextBlock + { + Text = name, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Left, + Margin = new(5, 0, 0, 5), + Foreground = Brushes.LightGray, + TextWrapping = TextWrapping.NoWrap, + FontSize = name.Length > 30 ? 16 : 20 + }, + new Button + { + Content = "-", + Width = 20, + Height = 20, + Margin = new(5, 0, 0, 5), + Background = Brushes.Transparent, + Foreground = Brushes.LightGray, + BorderBrush = Brushes.LightGray, + BorderThickness = new(1), + HorizontalAlignment = HorizontalAlignment.Right, + VerticalAlignment = VerticalAlignment.Center, + Tag = new AdjustButtonData(false, tag) + }, + new TextBlock + { + Text = value, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Center, + Margin = new(5, 0, 0, 5), + Foreground = Brushes.LightGray, + TextWrapping = TextWrapping.NoWrap + }, + new Button + { + Content = "+", + Width = 20, + Height = 20, + Margin = new(5, 0, 0, 5), + Background = Brushes.Transparent, + Foreground = Brushes.LightGray, + BorderBrush = Brushes.LightGray, + BorderThickness = new(1), + HorizontalAlignment = HorizontalAlignment.Right, + VerticalAlignment = VerticalAlignment.Center, + Tag = new AdjustButtonData(true, tag) + } + }, + Tag = tag + }; + + static StackPanel SetupBooleanOption(string name, bool value, OptionItem tag) => new() + { + Orientation = Orientation.Horizontal, + Background = Brushes.DimGray, + Margin = new(GetParentOffset(tag), 5, 0, 5), + Children = + { + new TextBlock + { + Text = name, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Left, + Margin = new(5, 0, 0, 5), + Foreground = Brushes.LightGray, + TextWrapping = TextWrapping.NoWrap, + FontSize = name.Length > 30 ? 16 : 20 + }, + new Button + { + Content = value ? "✔" : "✘", + Width = 20, + Height = 20, + Margin = new(5, 0, 0, 5), + Background = Brushes.Transparent, + Foreground = value ? Brushes.Turquoise : Brushes.Red, + BorderBrush = Brushes.LightGray, + BorderThickness = new(1), + HorizontalAlignment = HorizontalAlignment.Right, + VerticalAlignment = VerticalAlignment.Center, + Tag = new AdjustButtonData(false, tag) + } + }, + Tag = tag + }; + + public MainWindow() + { + InitializeComponent(); + InitTabs(); + //LoadOptions(); + + //MainFrame.NavigationService.Navigate(Tabs[default]); + } + + void InitTabs() + { + var tabGroups = Enum.GetValues(); + + Tabs = tabGroups.ToDictionary(x => x, _ => new Page()); + + tabGroups.Do(x => + { + var image = new Image + { + Source = new BitmapImage(new($"TabIcon_{x}.png", UriKind.Relative)), + Stretch = Stretch.Fill, + Width = 50, + Height = 50, + Margin = new(0, 0, 10, 0), + Opacity = 0.5 + }; + TabsPanel.Children.Add(image); + image.MouseDown += (_, _) => + { + foreach (var child in TabsPanel.Children) + { + if (child is Image img) + { + img.Opacity = img == image ? 1 : 0.5; + } + } + MainFrame.Content = Tabs[x]; + }; + image.MouseEnter += (_, _) => + { + image.Cursor = Cursors.Hand; + image.Effect = new DropShadowEffect + { + Color = Colors.White, + ShadowDepth = 0, + BlurRadius = 10 + }; + }; + image.MouseLeave += (_, _) => + { + image.Cursor = Cursors.Arrow; + image.Effect = null; + }; + }); + } + + void LoadOptions() + { + foreach ((TabGroup tabGroup, Page page) in Tabs) + { + var pageContent = new StackPanel + { + Orientation = Orientation.Vertical, + Margin = new(10) + }; + + foreach (var optionItem in Options.GroupedOptions[tabGroup]) + { + var newItem = optionItem is BooleanOptionItem booleanOptionItem + ? SetupBooleanOption(optionItem.Name, booleanOptionItem.GetBool(), optionItem) + : SetupOption(optionItem.Name, optionItem.GetValue().ToString(), optionItem); + + newItem.Children.OfType