private static void Prefix(MainMenuManager __instance) { if (TheOtherRolesPlugin.DebugMode.Value) { DestroyableSingleton <EOSManager> .Instance.PlayOffline(); } AssetLoader.LoadAssets(); CustomHatLoader.LaunchHatFetcher(); var template = GameObject.Find("ExitGameButton"); // Discrodボタン var buttonDiscord = UnityEngine.Object.Instantiate(template, null); buttonDiscord.transform.localPosition = new Vector3(buttonDiscord.transform.localPosition.x, buttonDiscord.transform.localPosition.y + 0.6f, buttonDiscord.transform.localPosition.z); var textDiscord = buttonDiscord.transform.GetChild(0).GetComponent <TMPro.TMP_Text>(); __instance.StartCoroutine(Effects.Lerp(0.1f, new System.Action <float>((p) => { textDiscord.SetText("Discord"); }))); PassiveButton passiveButtonDiscord = buttonDiscord.GetComponent <PassiveButton>(); SpriteRenderer buttonSpriteDiscord = buttonDiscord.GetComponent <SpriteRenderer>(); passiveButtonDiscord.OnClick = new Button.ButtonClickedEvent(); passiveButtonDiscord.OnClick.AddListener((System.Action)(() => Application.OpenURL("https://discord.gg/sTt8EzEpHP"))); Color discordColor = new Color32(88, 101, 242, byte.MaxValue); buttonSpriteDiscord.color = textDiscord.color = discordColor; passiveButtonDiscord.OnMouseOut.AddListener((System.Action) delegate { buttonSpriteDiscord.color = textDiscord.color = discordColor; }); // Twitterボタン var buttonTwitter = UnityEngine.Object.Instantiate(template, null); buttonTwitter.transform.localPosition = new Vector3(buttonTwitter.transform.localPosition.x, buttonTwitter.transform.localPosition.y + 1.2f, buttonTwitter.transform.localPosition.z); var textTwitter = buttonTwitter.transform.GetChild(0).GetComponent <TMPro.TMP_Text>(); __instance.StartCoroutine(Effects.Lerp(0.1f, new System.Action <float>((p) => { textTwitter.SetText("Twitter"); }))); PassiveButton passiveButtonTwitter = buttonTwitter.GetComponent <PassiveButton>(); SpriteRenderer buttonSpriteTwitter = buttonTwitter.GetComponent <SpriteRenderer>(); passiveButtonTwitter.OnClick = new Button.ButtonClickedEvent(); passiveButtonTwitter.OnClick.AddListener((System.Action)(() => Application.OpenURL("https://twitter.com/haoming_dev"))); Color twitterColor = new Color32(29, 161, 242, byte.MaxValue); buttonSpriteTwitter.color = textTwitter.color = twitterColor; passiveButtonTwitter.OnMouseOut.AddListener((System.Action) delegate { buttonSpriteTwitter.color = textTwitter.color = twitterColor; }); // アップデートボタン ModUpdater.LaunchUpdater(); if (!ModUpdater.hasUpdate) { return; } if (template == null) { return; } var button = UnityEngine.Object.Instantiate(template, null); button.transform.localPosition = new Vector3(button.transform.localPosition.x, button.transform.localPosition.y + 0.6f, button.transform.localPosition.z); PassiveButton passiveButton = button.GetComponent <PassiveButton>(); passiveButton.OnClick = new Button.ButtonClickedEvent(); passiveButton.OnClick.AddListener((UnityEngine.Events.UnityAction)onClick); var text = button.transform.GetChild(0).GetComponent <TMPro.TMP_Text>(); __instance.StartCoroutine(Effects.Lerp(0.1f, new System.Action <float>((p) => { text.SetText(ModTranslation.getString("updateButton")); }))); TwitchManager man = DestroyableSingleton <TwitchManager> .Instance; ModUpdater.InfoPopup = UnityEngine.Object.Instantiate <GenericPopup>(man.TwitchPopup); ModUpdater.InfoPopup.TextAreaTMP.fontSize *= 0.7f; ModUpdater.InfoPopup.TextAreaTMP.enableAutoSizing = false; // Discordボタンを上にずらす buttonDiscord.transform.localPosition = new Vector3(buttonDiscord.transform.localPosition.x, buttonDiscord.transform.localPosition.y + 0.6f, buttonDiscord.transform.localPosition.z); buttonTwitter.transform.localPosition = new Vector3(buttonTwitter.transform.localPosition.x, buttonTwitter.transform.localPosition.y + 0.6f, buttonTwitter.transform.localPosition.z); void onClick() { ModUpdater.ExecuteUpdate(); button.SetActive(false); } }
public static async Task <bool> checkForUpdate() { try { HttpClient http = new HttpClient(); http.DefaultRequestHeaders.Add("User-Agent", "TheOtherRoles Updater"); var response = await http.GetAsync(new System.Uri("https://api.github.com/repos/haoming37/TheOtherRoles-GM-Haoming/releases/latest"), HttpCompletionOption.ResponseContentRead); if (response.StatusCode != HttpStatusCode.OK || response.Content == null) { System.Console.WriteLine("Server returned no data: " + response.StatusCode.ToString()); return(false); } string json = await response.Content.ReadAsStringAsync(); JObject data = JObject.Parse(json); string tagname = data["tag_name"]?.ToString(); if (tagname == null) { return(false); // Something went wrong } string changeLog = data["body"]?.ToString(); if (changeLog != null) { announcement = changeLog; } // check version System.Version ver = System.Version.Parse(tagname.Replace("v", "")); int diff = TheOtherRolesPlugin.Version.CompareTo(ver); if (diff < 0) // Update required { hasUpdate = true; announcement = string.Format(ModTranslation.getString("announcementUpdate"), ver, announcement); JToken assets = data["assets"]; if (!assets.HasValues) { return(false); } for (JToken current = assets.First; current != null; current = current.Next) { string browser_download_url = current["browser_download_url"]?.ToString(); if (browser_download_url != null && current["content_type"] != null) { if ((current["content_type"].ToString().Equals("application/x-msdownload") || current["content_type"].ToString().Equals("application/x-dosexec")) && browser_download_url.EndsWith(".dll")) { updateURI = browser_download_url; return(true); } } } } else { announcement = string.Format(ModTranslation.getString("announcementChangelog"), ver, announcement); } } catch (System.Exception ex) { TheOtherRolesPlugin.Instance.Log.LogError(ex.ToString()); System.Console.WriteLine(ex); } return(false); }
static void setNameTags() { // Mafia if (PlayerControl.LocalPlayer != null && PlayerControl.LocalPlayer.Data.Role.IsImpostor) { foreach (PlayerControl player in PlayerControl.AllPlayerControls) { if (player.nameText.text == "") { continue; } if (Godfather.godfather != null && Godfather.godfather == player) { player.nameText.text = player.Data.PlayerName + $" ({ModTranslation.getString("mafiaG")})"; } else if (Mafioso.mafioso != null && Mafioso.mafioso == player) { player.nameText.text = player.Data.PlayerName + $" ({ModTranslation.getString("mafiaM")})"; } else if (Janitor.janitor != null && Janitor.janitor == player) { player.nameText.text = player.Data.PlayerName + $" ({ModTranslation.getString("mafiaJ")})"; } } if (MeetingHud.Instance != null) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { if (Godfather.godfather != null && Godfather.godfather.PlayerId == player.TargetPlayerId) { player.NameText.text = Godfather.godfather.Data.PlayerName + $" ({ModTranslation.getString("mafiaG")})"; } else if (Mafioso.mafioso != null && Mafioso.mafioso.PlayerId == player.TargetPlayerId) { player.NameText.text = Mafioso.mafioso.Data.PlayerName + $" ({ModTranslation.getString("mafiaM")})"; } else if (Janitor.janitor != null && Janitor.janitor.PlayerId == player.TargetPlayerId) { player.NameText.text = Janitor.janitor.Data.PlayerName + $" ({ModTranslation.getString("mafiaJ")})"; } } } } bool meetingShow = MeetingHud.Instance != null && (MeetingHud.Instance.state == MeetingHud.VoteStates.Voted || MeetingHud.Instance.state == MeetingHud.VoteStates.NotVoted || MeetingHud.Instance.state == MeetingHud.VoteStates.Discussion); // Lovers if (PlayerControl.LocalPlayer.isLovers() && PlayerControl.LocalPlayer.isAlive()) { string suffix = Lovers.getIcon(PlayerControl.LocalPlayer); var lover1 = PlayerControl.LocalPlayer; var lover2 = PlayerControl.LocalPlayer.getPartner(); lover1.nameText.text += suffix; if (!Helpers.hidePlayerName(lover2)) { lover2.nameText.text += suffix; } if (meetingShow) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { if (lover1.PlayerId == player.TargetPlayerId || lover2.PlayerId == player.TargetPlayerId) { player.NameText.text += suffix; } } } } else if (MapOptions.ghostsSeeRoles && PlayerControl.LocalPlayer.isDead()) { foreach (var couple in Lovers.couples) { string suffix = Lovers.getIcon(couple.lover1); couple.lover1.nameText.text += suffix; couple.lover2.nameText.text += suffix; if (meetingShow) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { if (couple.lover1.PlayerId == player.TargetPlayerId || couple.lover2.PlayerId == player.TargetPlayerId) { player.NameText.text += suffix; } } } } } // Lawyer bool localIsLawyer = Lawyer.lawyer != null && Lawyer.target != null && Lawyer.lawyer == PlayerControl.LocalPlayer; bool localIsKnowingTarget = Lawyer.lawyer != null && Lawyer.target != null && Lawyer.targetKnows && Lawyer.target == PlayerControl.LocalPlayer; if (localIsLawyer || (localIsKnowingTarget && !Lawyer.lawyer.Data.IsDead)) { string suffix = Helpers.cs(Lawyer.color, " §"); if (!Helpers.hidePlayerName(Lawyer.target)) { Lawyer.target.nameText.text += suffix; } if (meetingShow) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { if (player.TargetPlayerId == Lawyer.target.PlayerId) { player.NameText.text += suffix; } } } } // Hacker and Detective if (PlayerControl.LocalPlayer != null && MapOptions.showLighterDarker) { if (meetingShow) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { var target = Helpers.playerById(player.TargetPlayerId); if (target != null) { player.NameText.text += $" ({(Helpers.isLighterColor(target.Data.DefaultOutfit.ColorId) ? ModTranslation.getString("detectiveLightLabel") : ModTranslation.getString("detectiveDarkLabel"))})"; } } } } }