Example #1
0
        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");
             * }
             */
        }
Example #2
0
        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 :(");
             * }
             */
        }