private static void ExposeData(string filepath, bool useUndoAction = false)
        {
            try {
                if (CurrentMode == Mode.Saving)
                {
                    Data = new ModsConfigData {
                        buildNumber = RimWorld.VersionControl.CurrentBuild,
                        activeMods  = ModsConfigHandler.GetActiveMods()
                    };
                    DirectXmlSaver.SaveDataObject((object)Data, filepath);
                }
                else if (CurrentMode == Mode.Loading)
                {
                    List <string> current = new List <string>();

                    Data = ReadModList(filepath);

                    ModsConfigHandler.ClearLoadedMods(true);
                    foreach (string modID in Data.activeMods)
                    {
                        ModsConfig.SetActive(modID, true);
                    }
                }
            }
            catch (Exception e) {
                Main.Log.ReportException(e);
                ModsConfigHandler.ClearLoadedMods();
            }
        }
 static ModListController()
 {
     Data = new ModsConfigData {
         buildNumber = RimWorld.VersionControl.CurrentBuild,
         activeMods  = ModsConfigHandler.GetActiveMods()
     };
 }
Example #3
0
        public UndoActionType(int state, LastActionType lastAction = LastActionType.none)
        {
            Main.DebugMessage("Creating last action type {1} for state {0}", state, lastAction.ToString());
            State      = state;
            LastAction = lastAction;
            switch (LastAction)
            {
            case LastActionType.restore:
                ModData = new ModsConfigData {
                    buildNumber = RimWorld.VersionControl.CurrentBuild,
                    activeMods  = GetActiveMods()
                };
                break;

            case LastActionType.backup:
                if (!ModListController.ModListIsSet(state))
                {
                    ModData = null;
                }
                else
                {
                    ModData = ModListController.ReadModList(PathHandler.GenBackupModListFile(state));
                }
                break;

            case LastActionType.none:
            default:
                Main.Log.Warning("Last Undo Action was not set with a type");
                break;
            }
        }