From: Mallöris <|||||@||.||> Date: Mon, 2 May 2022 20:32:30 +0000 (+0200) Subject: Update to version 4.1.1 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=93121a9d1c83ae84a531fb27adc7528c7ca8e8bb;p=rhonda%2Ftheotherroles.git Update to version 4.1.1 --- diff --git a/TheOtherRoles/Buttons.cs b/TheOtherRoles/Buttons.cs index 4ad84e9..deb34a1 100644 --- a/TheOtherRoles/Buttons.cs +++ b/TheOtherRoles/Buttons.cs @@ -768,7 +768,7 @@ namespace TheOtherRoles HudManager.Instance.StartCoroutine(Effects.Lerp(Portal.teleportDuration, new Action((p) => { // Delayed action PlayerControl.LocalPlayer.moveable = false; PlayerControl.LocalPlayer.NetTransform.Halt(); - if (p >= 0.5f && p <= 0.53f && !didTeleport) { + if (p >= 0.5f && p <= 0.53f && !didTeleport && !MeetingHud.Instance) { if (SubmergedCompatibility.isSubmerged()) { SubmergedCompatibility.ChangeFloor(exit.y > -7); } @@ -1242,7 +1242,7 @@ namespace TheOtherRoles if (Medium.target == null || Medium.target.player == null) return; string msg = ""; - int randomNumber = TheOtherRoles.rnd.Next(4); + int randomNumber = Medium.target.killerIfExisting?.PlayerId == Mini.mini?.PlayerId ? TheOtherRoles.rnd.Next(3) : TheOtherRoles.rnd.Next(4); string typeOfColor = Helpers.isLighterColor(Medium.target.killerIfExisting.Data.DefaultOutfit.ColorId) ? "lighter" : "darker"; float timeSinceDeath = ((float)(Medium.meetingStartTime - Medium.target.timeOfDeath).TotalMilliseconds); string name = " (" + Medium.target.player.Data.PlayerName + ")"; @@ -1251,7 +1251,7 @@ namespace TheOtherRoles if (randomNumber == 0) msg = "What is your role? My role is " + RoleInfo.GetRolesString(Medium.target.player, false) + name; else if (randomNumber == 1) msg = "What is your killer`s color type? My killer is a " + typeOfColor + " color" + name; else if (randomNumber == 2) msg = "When did you die? I have died " + Math.Round(timeSinceDeath / 1000) + "s before meeting started" + name; - else msg = "What is your killer`s role? My killer is " + RoleInfo.GetRolesString(Medium.target.killerIfExisting, false) + name; + else msg = "What is your killer`s role? My killer is " + RoleInfo.GetRolesString(Medium.target.killerIfExisting, true) + name; DestroyableSingleton.Instance.Chat.AddChat(PlayerControl.LocalPlayer, $"{msg}"); diff --git a/TheOtherRoles/Main.cs b/TheOtherRoles/Main.cs index 9aebb39..ee4de2b 100644 --- a/TheOtherRoles/Main.cs +++ b/TheOtherRoles/Main.cs @@ -22,7 +22,7 @@ namespace TheOtherRoles public class TheOtherRolesPlugin : BasePlugin { public const string Id = "me.eisbison.theotherroles"; - public const string VersionString = "4.1.0"; + public const string VersionString = "4.1.1"; public static Version Version = Version.Parse(VersionString); internal static BepInEx.Logging.ManualLogSource Logger; diff --git a/TheOtherRoles/Modules/CustomOptions.cs b/TheOtherRoles/Modules/CustomOptions.cs index 17b5c3f..bfbdbc0 100644 --- a/TheOtherRoles/Modules/CustomOptions.cs +++ b/TheOtherRoles/Modules/CustomOptions.cs @@ -635,6 +635,7 @@ namespace TheOtherRoles { LastPosition = new Vector3(MinX, MinY); lastAspect = aspect; setLastPosition = true; + if (Scroller != null) Scroller.ContentXBounds = new FloatRange(MinX, MinX); } CreateScroller(__instance); diff --git a/TheOtherRoles/Modules/ModUpdater.cs b/TheOtherRoles/Modules/ModUpdater.cs index 1d68ac8..e26c8f9 100644 --- a/TheOtherRoles/Modules/ModUpdater.cs +++ b/TheOtherRoles/Modules/ModUpdater.cs @@ -68,7 +68,10 @@ namespace TheOtherRoles.Modules private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (scene.name != "MainMenu") return; - if (RequiredUpdateData is null) return; + if (RequiredUpdateData is null) { + showPopUp = false; + return; + } var template = GameObject.Find("ExitGameButton"); if (!template) return; @@ -100,6 +103,7 @@ namespace TheOtherRoles.Modules var isSubmerged = TORUpdate == null; var announcement = $"A new {(isSubmerged ? "Submerged" : "THE OTHER ROLES")} update to {(isSubmerged ? SubmergedUpdate.Tag : TORUpdate.Tag)} is available\n{(isSubmerged ? SubmergedUpdate.Content : TORUpdate.Content)}"; var mgr = FindObjectOfType(true); + if (isSubmerged && !SubmergedCompatibility.Loaded) showPopUp = false; if (showPopUp) mgr.StartCoroutine(CoShowAnnouncement(announcement)); showPopUp = false; } @@ -140,6 +144,7 @@ namespace TheOtherRoles.Modules { var torUpdateCheck = Task.Run(() => Instance.GetGithubUpdate("Eisbison", "TheOtherRoles")); while (!torUpdateCheck.IsCompleted) yield return null; + Announcement.updateData = torUpdateCheck.Result; if (torUpdateCheck.Result != null && torUpdateCheck.Result.IsNewer(Version.Parse(TheOtherRolesPlugin.VersionString))) { Instance.TORUpdate = torUpdateCheck.Result; @@ -196,11 +201,20 @@ namespace TheOtherRoles.Modules if (downloadURI.Length == 0) return false; var res = await client.GetAsync(downloadURI, HttpCompletionOption.ResponseContentRead); - string codeBase = (isSubmerged ? SubmergedCompatibility.Assembly : Assembly.GetExecutingAssembly()).CodeBase; + string codeBase = ""; + if (!isSubmerged) + codeBase = Assembly.GetExecutingAssembly().CodeBase; + else if (SubmergedCompatibility.Loaded) + codeBase = SubmergedCompatibility.Assembly.CodeBase; + else { + Uri pluginsFolder = new Uri(new Uri(Assembly.GetExecutingAssembly().CodeBase), "."); + codeBase = pluginsFolder.OriginalString + "/Submerged.dll"; + } + UriBuilder uri = new UriBuilder(codeBase); string fullname = Uri.UnescapeDataString(uri.Path); if (File.Exists(fullname + ".old")) File.Delete(fullname + ".old"); - File.Move(fullname, fullname + ".old"); + if (File.Exists(fullname)) File.Move(fullname, fullname + ".old"); await using var responseStream = await res.Content.ReadAsStreamAsync(); await using var fileStream = File.Create(fullname); diff --git a/TheOtherRoles/Patches/MainMenuPatch.cs b/TheOtherRoles/Patches/MainMenuPatch.cs index 83c0fa0..7418c95 100644 --- a/TheOtherRoles/Patches/MainMenuPatch.cs +++ b/TheOtherRoles/Patches/MainMenuPatch.cs @@ -74,4 +74,19 @@ namespace TheOtherRoles.Modules { }); } } + + [HarmonyPatch(typeof(AnnouncementPopUp), nameof(AnnouncementPopUp.UpdateAnnounceText))] + public static class Announcement + { + public static ModUpdateBehaviour.UpdateData updateData = null; + public static bool Prefix(AnnouncementPopUp __instance) + { + if (ModUpdateBehaviour.showPopUp || updateData == null) return true; + + var text = __instance.AnnounceTextMeshPro; + text.text = $"THE OTHER ROLES {(updateData.Tag)}\n{(updateData.Content)}"; + + return false; + } + } } \ No newline at end of file diff --git a/TheOtherRoles/Patches/UpdatePatch.cs b/TheOtherRoles/Patches/UpdatePatch.cs index 7cf6801..4bb2ca2 100644 --- a/TheOtherRoles/Patches/UpdatePatch.cs +++ b/TheOtherRoles/Patches/UpdatePatch.cs @@ -245,7 +245,11 @@ namespace TheOtherRoles.Patches { } static void updateImpostorKillButton(HudManager __instance) { - if (!PlayerControl.LocalPlayer.Data.Role.IsImpostor || MeetingHud.Instance) return; + if (!PlayerControl.LocalPlayer.Data.Role.IsImpostor) return; + if (MeetingHud.Instance) { + __instance.KillButton.Hide(); + return; + } bool enabled = true; if (Vampire.vampire != null && Vampire.vampire == PlayerControl.LocalPlayer) enabled = false; @@ -272,6 +276,14 @@ namespace TheOtherRoles.Patches { } + static void updateUseButton(HudManager __instance) { + if (MeetingHud.Instance) __instance.UseButton.Hide(); + } + + static void updateSabotageButton(HudManager __instance) { + if (MeetingHud.Instance) __instance.SabotageButton.Hide(); + } + static void Postfix(HudManager __instance) { if (AmongUsClient.Instance.GameState != InnerNet.InnerNetClient.GameStates.Started) return; @@ -292,6 +304,9 @@ namespace TheOtherRoles.Patches { // Deputy Sabotage, Use and Vent Button Disabling updateReportButton(__instance); updateVentButton(__instance); + // Meeting hide buttons if needed (used for the map usage, because closing the map would show buttons) + updateSabotageButton(__instance); + updateUseButton(__instance); } } diff --git a/TheOtherRoles/Resources/CentralUpperBlocked.png b/TheOtherRoles/Resources/CentralUpperBlocked.png index 8752326..438a6ed 100644 Binary files a/TheOtherRoles/Resources/CentralUpperBlocked.png and b/TheOtherRoles/Resources/CentralUpperBlocked.png differ diff --git a/TheOtherRoles/TheOtherRoles.csproj b/TheOtherRoles/TheOtherRoles.csproj index 8e471d8..b978702 100644 --- a/TheOtherRoles/TheOtherRoles.csproj +++ b/TheOtherRoles/TheOtherRoles.csproj @@ -1,7 +1,7 @@  netstandard2.1 - 4.0.0 + 4.1.1 TheOtherRoles Eisbison latest @@ -24,12 +24,6 @@ - - - - - -