public override void OnLoad()
        {
            // Project start date, 06.07.2018 | Modified 28.10.2020

            MoControlsSaveData.loadSettings();
            initialize();
            performModLoaderVersionCheck();
        }
Exemple #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);
        }
Exemple #3
0
 public OldSaveDataException(MoControlsSaveData inOldSaveData)
 {
     oldSaveData = inOldSaveData;
 }
Exemple #4
0
 private static void keepSaveFile()
 {
     loadedSaveData = oldSaveException.oldSaveData;
     loadedSaveData.oldNewVersionAccepted = loadedSaveData.moControlsVersion;
     loadedSaveData.saveSettings();
 }