void onLoadButtonClicked() { new Generic2ButtonDialogue(ModBotLocalizationManager.FormatLocalizedStringFromID("mod_load_confirm_message", _nameDisplay.text), LocalizationManager.Instance.GetTranslatedString("mod_load_confirm_no"), null, LocalizationManager.Instance.GetTranslatedString("mod_load_confirm_yes"), delegate { StartCoroutine(downloadModBytesAndLoadAsync(_modDownloadUrl)); }); }
/// <summary> /// Clears all mod cache (including the AssetLoader cache) /// </summary> public static void ClearCache() { AssetLoader.ClearCache(); if (Caching.ClearCache()) { ModBotLocalizationManager.LogLocalizedStringOnceLocalizationManagerInitialized("clear_cache_success"); return; } ModBotLocalizationManager.LogLocalizedStringOnceLocalizationManagerInitialized("clear_cache_fail"); }
/* New mod loading system * void addModToList(LoadedModInfo mod, GameObject parent) * { * bool isModActive = mod.IsEnabled; * * GameObject modItem = InternalAssetBundleReferences.ModsWindow.InstantiateObject("ModItemPrefab"); * modItem.transform.parent = parent.transform; * * string modName = mod.OwnerModInfo.DisplayName; * string imageFilePath = mod.OwnerModInfo.FolderPath + mod.OwnerModInfo.ImageFileName; * * _modItems.Add(modItem); * * ModdedObject modItemModdedObject = modItem.GetComponent<ModdedObject>(); * * modItemModdedObject.GetObject<Text>(0).text = modName; // Set title * modItemModdedObject.GetObject<Text>(1).text = mod.OwnerModInfo.Description; // Set description * modItemModdedObject.GetObject<Text>(5).text = ModBotLocalizationManager.FormatLocalizedStringFromID("mods_menu_mod_id", mod.OwnerModInfo.UniqueID); * * if(File.Exists(imageFilePath) && !string.IsNullOrWhiteSpace(mod.OwnerModInfo.ImageFileName)) * { * byte[] imgData = File.ReadAllBytes(imageFilePath); * * Texture2D texture = new Texture2D(1, 1); * texture.LoadImage(imgData); * * modItemModdedObject.GetObject<RawImage>(2).texture = texture; * } * * Button enableOrDisableButton = modItem.GetComponent<ModdedObject>().GetObject<Button>(3); * * if (!isModActive) * { * modItem.GetComponent<Image>().color = Color.red; * LocalizedTextField localizedTextField = enableOrDisableButton.transform.GetChild(0).GetComponent<LocalizedTextField>(); * localizedTextField.LocalizationID = "mods_menu_enable_mod"; * Accessor.CallPrivateMethod("tryLocalizeTextField", localizedTextField); * * enableOrDisableButton.colors = new ColorBlock() { normalColor = Color.green * 1.2f, highlightedColor = Color.green, pressedColor = Color.green * 0.8f, colorMultiplier = 1 }; * } * * Button BroadcastButton = modItemModdedObject.GetObject<Button>(6); * BroadcastButton.onClick.AddListener( delegate { onBroadcastButtonClicked(mod.ModReference); } ); * BroadcastButton.gameObject.SetActive(GameModeManager.IsMultiplayer()); * * Button DownloadButton = modItemModdedObject.GetObject<Button>(7); * //DownloadButton.onClick.AddListener(delegate { onDownloadButtonClicked(mod); }); * //bool hasNoFile = ModsManager.Instance.GetIsModOnlyLoadedInMemory(mod); * DownloadButton.gameObject.SetActive(false); * * modItemModdedObject.GetObject<Button>(3).onClick.AddListener(delegate { toggleIsModDisabled(mod); }); // Add disable button callback * //modItemModdedObject.GetObject<Button>(4).GetComponentInChildren<Text>().gameObject.AddComponent<LocalizedTextField>().LocalizationID = "mods_menu_mod_options"; * modItemModdedObject.GetObject<Button>(4).onClick.AddListener(delegate { openModsOptionsWindowForMod(mod); }); // Add Mod Options button callback * modItemModdedObject.GetObject<Button>(4).interactable = mod.ModReference != null ? mod.ModReference.ImplementsSettingsWindow() : false; * } */ static void onBroadcastButtonClicked(Mod mod) { // Old mod loading system new Generic2ButtonDialogue(ModBotLocalizationManager.FormatLocalizedStringFromID("mods_menu_broadcast_confirm_message", mod.GetModName()), LocalizationManager.Instance.GetTranslatedString("mods_menu_broadcast_confirm_no"), null, LocalizationManager.Instance.GetTranslatedString("mods_menu_broadcast_confirm_yes"), delegate { ModSharingManager.SendModToAllModBotClients(ModsManager.Instance.GetModData(mod), mod.GetModName()); }); }
void onDownloadButtonClicked(Mod mod) { // Old mod loading system new Generic2ButtonDialogue(ModBotLocalizationManager.FormatLocalizedStringFromID("mods_menu_download_confirm_message", mod.GetModName()), LocalizationManager.Instance.GetTranslatedString("mods_menu_download_confirm_no"), null, LocalizationManager.Instance.GetTranslatedString("mods_menu_download_confirm_yes"), delegate { ModsManager.Instance.WriteDllFileToModFolder(mod); ReloadModItems(); }); }
void Update() { if (Input.GetKeyDown(KeyCode.F3)) { Counter.gameObject.SetActive(!Counter.gameObject.activeSelf); } float FPS = 1f / Time.unscaledDeltaTime; int FPSInt = Convert.ToInt32(FPS); Counter.text = ModBotLocalizationManager.FormatLocalizedStringFromID("fps_label", FPSInt); }
/// <summary> /// Gets called when the user types in a command into the input field and presses enter /// </summary> /// <param name="command"></param> public void RunCommand(string command) { try { ConsoleInputManager.OnCommandRan(command); ModsManager.Instance.PassOnMod.OnCommandRan(command); } catch (Exception ex) { Log(ModBotLocalizationManager.FormatLocalizedStringFromID("command_failed_message", command, ex.Message), Color.red); Log(ex.StackTrace, Color.red); } }
IEnumerator checkVersion() { string installedModBotVersion = ModLibrary.Properties.Resources.ModBotVersion; if (installedModBotVersion.ToLower().Contains("beta")) { yield break; } UnityWebRequest modBotVersionRequest = UnityWebRequest.Get("https://modbot-d8a58.firebaseio.com/ModBotVer/.json"); yield return(modBotVersionRequest.SendWebRequest()); if (modBotVersionRequest.isNetworkError || modBotVersionRequest.isHttpError) { yield break; } string newestModBotVersion = modBotVersionRequest.downloadHandler.text.Replace("\"", ""); // Latest ModBot version string modBotVersionLabel = ModBotLocalizationManager.FormatLocalizedStringFromID("modbotversion", installedModBotVersion); GameUIRoot.Instance.TitleScreenUI.VersionLabel.text += "\n" + modBotVersionLabel; if (!isCloudVersionNewer(installedModBotVersion, newestModBotVersion)) { string modBotUpToDateMessage = ModBotLocalizationManager.FormatLocalizedStringFromID("modbotuptodate", installedModBotVersion); debug.Log(modBotUpToDateMessage, Color.green); yield break; } string message = ModBotLocalizationManager.FormatLocalizedStringFromID("newversion_message", newestModBotVersion, installedModBotVersion); string dismissButtonText = LocalizationManager.Instance.GetTranslatedString("newversion_dismiss"); string installButtonText = LocalizationManager.Instance.GetTranslatedString("newversion_install"); Generic2ButtonDialogue generic = new Generic2ButtonDialogue(message, dismissButtonText, null, installButtonText, onInstallButtonClicked); generic.SetColorOfFirstButton(Color.red); generic.SetColorOfSecondButton(Color.green); }
IEnumerator suggestModMultiplayerCoroutine(string suggesterPlayfabID, string modName, byte[] data) { string displayName = null; bool hasDisplayName = false; MultiplayerPlayerInfoManager.Instance.TryGetDisplayName(suggesterPlayfabID, delegate(string receivedDisplayName) { displayName = receivedDisplayName; hasDisplayName = true; }); yield return(new WaitUntil(() => hasDisplayName)); if (displayName == null) { displayName = ""; } DisplayText.text = ModBotLocalizationManager.FormatLocalizedStringFromID("mod_suggested_multiplayer", displayName, modName); ModSuggestionAnimator.Play("suggestMod"); KeyCode clickedKey; while (true) { if (Input.GetKeyDown(KeyCode.PageDown)) { clickedKey = KeyCode.PageDown; break; } if (Input.GetKeyDown(KeyCode.PageUp)) { clickedKey = KeyCode.PageUp; break; } yield return(0); } // Old mod loading system, re-introduced to revert back to it if (clickedKey == KeyCode.PageUp) { ModSuggestionAnimator.Play("AcceptMod"); if (!ModsManager.Instance.LoadMod(data, false, out string error)) { debug.Log(LocalizationManager.Instance.GetTranslatedString("mod_suggested_multiplayer_load_fail"), Color.red); } else { debug.Log(LocalizationManager.Instance.GetTranslatedString("mod_suggested_multiplayer_load_success"), Color.green); } } else if (clickedKey == KeyCode.PageDown) { ModSuggestionAnimator.Play("DenyMod"); } //TODO: Update this to work with the new mod loading system /* * if (clickedKey == KeyCode.PageUp) * { * ModSuggestionAnimator.Play("AcceptMod"); * * if (!ModsManager.Instance.LoadMod(data, modName, false, out string error)) * { * debug.Log(LocalizationManager.Instance.GetTranslatedString("mod_suggested_multiplayer_load_fail"), Color.red); * } * else * { * debug.Log(LocalizationManager.Instance.GetTranslatedString("mod_suggested_multiplayer_load_success"), Color.green); * } * } * else if (clickedKey == KeyCode.PageDown) * { * ModSuggestionAnimator.Play("DenyMod"); * } */ }
IEnumerator suggestMod(ModSuggestion mod) { DisplayText.text = ModBotLocalizationManager.FormatLocalizedStringFromID("mod_suggested_twitch", mod.ModName, mod.SuggesterName); ModSuggestionAnimator.Play("suggestMod"); KeyCode clickedKey; while (true) { if (Input.GetKeyDown(KeyCode.PageDown)) { clickedKey = KeyCode.PageDown; break; } if (Input.GetKeyDown(KeyCode.PageUp)) { clickedKey = KeyCode.PageUp; break; } yield return(0); } // Reverted code if (clickedKey == KeyCode.PageUp) { ModSuggestionAnimator.Play("AcceptMod"); TwitchManager.Instance.EnqueueChatMessage("Mod accepted :)"); UnityWebRequest webRequest = UnityWebRequest.Get(mod.Url); yield return(webRequest.SendWebRequest()); byte[] data = webRequest.downloadHandler.data; if (!ModsManager.Instance.LoadMod(data, false, out string error)) { debug.Log(LocalizationManager.Instance.GetTranslatedString("mod_suggested_twitch_load_fail"), Color.red); TwitchManager.Instance.EnqueueChatMessage("Suggested mod \"" + mod.ModName + "\" failed to load, the link may be incorrect or the mod could be outdated."); } } if (clickedKey == KeyCode.PageDown) { ModSuggestionAnimator.Play("DenyMod"); TwitchManager.Instance.EnqueueChatMessage("Mod denied :("); } // TODO: Make this work with the new mod loading system /* * if (clickedKey == KeyCode.PageUp) * { * ModSuggestionAnimator.Play("AcceptMod"); * TwitchManager.Instance.EnqueueChatMessage("Mod accepted :)"); * UnityWebRequest webRequest = UnityWebRequest.Get(mod.Url); * * yield return webRequest.SendWebRequest(); * * byte[] data = webRequest.downloadHandler.data; * if (!ModsManager.Instance.LoadMod(data, mod.ModName, false, out string error)) * { * debug.Log(LocalizationManager.Instance.GetTranslatedString("mod_suggested_twitch_load_fail"), Color.red); * TwitchManager.Instance.EnqueueChatMessage("Suggested mod \"" + mod.ModName + "\" failed to load, the link may be incorrect or the mod could be outdated."); * } * } * if (clickedKey == KeyCode.PageDown) * { * ModSuggestionAnimator.Play("DenyMod"); * TwitchManager.Instance.EnqueueChatMessage("Mod denied :("); * } */ }
public static void LocalizationManager_populateDictionaryForCurrentLanguage_Postfix(ref Dictionary <string, string> ____translatedStringsDictionary) { ModBotLocalizationManager.AddAllLocalizationStringsToDictionary(____translatedStringsDictionary); ModsManager.Instance.PassOnMod.OnLanguageChanged(SettingsManager.Instance.GetCurrentLanguageID(), ____translatedStringsDictionary); }
// Old mod loading system ModdedObject findModItemWithName(string id) { foreach (GameObject moddedObject in _modItems) { if (moddedObject.GetComponent <ModdedObject>().GetObject <Text>(5).text == ModBotLocalizationManager.FormatLocalizedStringFromID("mods_menu_mod_id", id)) { return(moddedObject.GetComponent <ModdedObject>()); } } return(null); }
/* New mod loading system * void toggleIsModDisabled(LoadedModInfo mod) * { * if (mod == null) * return; * mod.IsEnabled = !mod.IsEnabled; * * ReloadModItems(); * } */ // Old mod loading system void addModToList(Mod mod, GameObject parent) { bool?isModNotActive = ModsManager.Instance.IsModDeactivated(mod); if (!isModNotActive.HasValue) { return; } GameObject modItemPrefab = AssetLoader.GetObjectFromFile("modswindow", "ModItemPrefab", "Clone Drone in the Danger Zone_Data/"); GameObject modItem = Instantiate(modItemPrefab, parent.transform); string modName = mod.GetModName(); string url = mod.GetModImageURL(); _modItems.Add(modItem); if (!string.IsNullOrEmpty(url)) { setImageFromURL(url, mod); } ModdedObject modItemModdedObject = modItem.GetComponent <ModdedObject>(); modItemModdedObject.GetObject <Text>(0).text = modName; // Set title modItemModdedObject.GetObject <Text>(1).text = mod.GetModDescription(); // Set description modItemModdedObject.GetObject <Text>(5).text = ModBotLocalizationManager.FormatLocalizedStringFromID("mods_menu_mod_id", mod.GetUniqueID()); Button enableOrDisableButton = modItem.GetComponent <ModdedObject>().GetObject <Button>(3); if (isModNotActive.Value) { modItem.GetComponent <Image>().color = Color.red; LocalizedTextField localizedTextField = enableOrDisableButton.transform.GetChild(0).GetComponent <LocalizedTextField>(); localizedTextField.LocalizationID = "mods_menu_enable_mod"; Accessor.CallPrivateMethod("tryLocalizeTextField", localizedTextField); enableOrDisableButton.colors = new ColorBlock() { normalColor = Color.green * 1.2f, highlightedColor = Color.green, pressedColor = Color.green * 0.8f, colorMultiplier = 1 }; } Button BroadcastButton = modItemModdedObject.GetObject <Button>(6); BroadcastButton.onClick.AddListener(delegate { onBroadcastButtonClicked(mod); }); BroadcastButton.gameObject.SetActive(GameModeManager.IsMultiplayer()); Button DownloadButton = modItemModdedObject.GetObject <Button>(7); DownloadButton.onClick.AddListener(delegate { onDownloadButtonClicked(mod); }); bool hasNoFile = ModsManager.Instance.GetIsModOnlyLoadedInMemory(mod); DownloadButton.gameObject.SetActive(hasNoFile); int modId = ModsManager.Instance.GetAllMods().IndexOf(mod); modItemModdedObject.GetObject <Button>(3).onClick.AddListener(delegate { toggleIsModDisabled(modId); }); // Add disable button callback modItemModdedObject.GetObject <Button>(4).onClick.AddListener(delegate { openModsOptionsWindowForMod(mod); }); // Add Mod Options button callback modItemModdedObject.GetObject <Button>(4).interactable = mod.ImplementsSettingsWindow(); }