internal bool UndoLastAction() { Main.DebugMessage("Undoing last action type {1} for state {0}", State, LastAction.ToString()); switch (LastAction) { case LastActionType.restore: Main.DebugMessage("Restoring {0} active mods", ModData.activeMods.Count); SetActiveMods(ModData.activeMods); return(true); case LastActionType.backup: if (ModData != null) { Main.DebugMessage("Restored {0}'s last state", State); XmlSaverAPI.SaveDataObject((object)ModData, PathHandler.GenBackupStateFile(State)); } else { PathHandler.FileDelete(PathHandler.GenBackupStateFile(State)); } return(true); case LastActionType.none: default: Main.Log.Warning("Last Undo Action was not set with a type, cannot undo last action"); return(false); } }
/// <summary> /// Sets all state files to use steam sync or not, depending on what setting is selected /// </summary> internal static void UpdateAllStates() { if (SYNC_TO_STEAM) { foreach (string stateFilepath in PathHandler.GetFiles(PathHandler.DIR_BACKUPS, "*" + PathHandler.XML_FILE_PREFIX)) { if (PathHandler.GetFileName(stateFilepath) != PathHandler.FILE_MODSCONFIG_NAME) { string newFilepath = stateFilepath + GenFilePathsAPI.SavedGameExtension; if (PathHandler.FileExists(newFilepath)) { if (PathHandler.GetFileName(stateFilepath).Length != PathHandler.GetFileName(newFilepath).Length) { PathHandler.FileCopy(stateFilepath, newFilepath, true); PathHandler.FileDelete(stateFilepath); } } else { PathHandler.FileCopy(stateFilepath, newFilepath, true); } } } } else { foreach (string syncFilepath in PathHandler.GetFiles(PathHandler.DIR_BACKUPS, "*" + GenFilePathsAPI.SavedGameExtension)) { string newFilepath = syncFilepath.Replace(GenFilePathsAPI.SavedGameExtension, ""); PathHandler.FileCopy(syncFilepath, newFilepath, true); if (PathHandler.FileExists(syncFilepath)) { PathHandler.FileDelete(syncFilepath); } } } }