/// <summary>
        /// Changes the input for a control defined in <see cref="changeInputResult"/> to the provided input string, <paramref name="inInput"/>.
        /// </summary>
        /// <param name="inInput">The input to assign.</param>
        internal void changeInput(string inInput)
        {
            // Written, 09.07.2018

            if (!changeInputResult.isModKeybind)
            {
                // Treat as a game control.

                PlayerModeEnum?playerMode = changeInputResult?.mode;

                if (playerMode == null)
                {
                    bool mistake = true;
                    ModUI.ShowYesNoMessage("Player Mode was null, is that right?", "Mistake?", delegate()
                    {
                        mistake = false;
                    });
                    if (!mistake)
                    {
                        if (changeInputResult.index == 1)
                        {
                            cInput.ChangeKey(changeInputResult.controlName, inInput, cInput.GetText(changeInputResult.controlName, 2));
                        }
                        else
                        {
                            cInput.ChangeKey(changeInputResult.controlName, cInput.GetText(changeInputResult.controlName, 1), inInput);
                        }
                        currentControls = loadControlInputsFromCInput();
                    }
                    MoControlsMod.print("Player mode wasa null while attempting to change input..", DebugTypeEnum.full);
                }
                else
                {
                    setGameControl((PlayerModeEnum)playerMode, changeInputResult.controlName, changeInputResult.index, inInput);
                    MoControlsMod.print("Player mode was equal to <b>" + changeInputResult.mode + "</b> whiling setting '" + changeInputResult.controlName + "' to '" + inInput + "'.", DebugTypeEnum.full);
                    MoControlsSaveData.loadedSaveData.saveSettings();
                }
            }
            else
            {
                // Treat as a mod keybind.

                Keybind modKeybind = Keybind.Get(changeInputResult.mod).Where(kb => kb.ID == changeInputResult.controlName).First();
                if (changeInputResult.index == 1)
                {
                    modKeybind.Modifier = (KeyCode)Enum.Parse(typeof(KeyCode), inInput);
                }
                else
                {
                    modKeybind.Key = (KeyCode)Enum.Parse(typeof(KeyCode), inInput);
                }
                ModSettings_menu.SaveModBinds(changeInputResult.mod);
                MoControlsMod.print("saved <i>" + modKeybind.Mod.Name + "</i> mod keybinds.", DebugTypeEnum.full);
            }
            setChangeInput();
        }
Example #2
0
        internal static MoControlsSaveData loadSettings()
        {
            // Written, 17.10.2020

            bool createNewSaveFile  = false;
            MoControlsSaveData mcsd = null;

            try
            {
                mcsd = SaveLoad.DeserializeSaveFile <MoControlsSaveData>(MoControlsMod.instance, fileName + fileExtention);
                if (mcsd == null)
                {
                    throw new NullReferenceException();
                }

                if (mcsd.moControlsVersion != MoControlsMod.instance.Version)
                {
                    if (mcsd.oldNewVersionAccepted != mcsd.moControlsVersion)
                    {
                        oldSaveException = new OldSaveDataException(mcsd);
                        throw oldSaveException;
                    }
                }
            }
            catch (NullReferenceException)
            {
                createNewSaveFile = true;
                MoControlsMod.print("Save file does not exist, make any change to a setting to save.", Debugging.DebugTypeEnum.none);
            }
            catch (OldSaveDataException e)
            {
                createNewSaveFile = true;
                ModUI.ShowYesNoMessage(string.Format("A{1} save detected (v{0}).. Would you like to still load this save file? NOTE: you may need to change various settings",
                                                     e.oldSaveData.moControlsVersion,
                                                     MoControlsMod.determineIsVersionOldCurrentOrNew(mcsd.moControlsVersion) < 0 ? "n Older" : " Newer"),
                                       "[Mo'Controls] - Different save version detected", keepSaveFile);
            }
            catch (Exception e)
            {
                createNewSaveFile = true;
                MoControlsMod.print("An error occured while loading the save file..make any change to a setting to save.\nERROR: " + e.Message, Debugging.DebugTypeEnum.none);
            }
            if (createNewSaveFile)
            {
                mcsd = defaultSave;
                mcsd.saveSettings();
            }
            loadedSaveData = mcsd;
            MoControlsMod.print("loaded mo'controls data.", Debugging.DebugTypeEnum.full);
            return(mcsd);
        }
Example #3
0
 internal static AssetBundle LoadAssetBundle(Mod mod, string fileName)
 {
     try
     {
         return(LoadAssets.LoadBundle(mod, fileName));
     }
     catch (Exception ex)
     {
         string message = String.Format("AssetBundle file '{0}' could not be loaded", fileName);
         ModConsole.Error(message);
         ModUI.ShowYesNoMessage(message + "\n\nClose Game? - RECOMMENDED", ExitGame);
     }
     return(null);
 }
Example #4
0
 public static void ShowDialog(string newUrl)
 {
     url = newUrl;
     ModUI.ShowYesNoMessage(GetDialogMessage(), "MOP", OpenWebsite);
 }