public void Save()
    {
        try
        {
            EnsureProfileDirectory();

            NewJSON jsonStructure = new NewJSON()
            {
                DisabledList = DisabledList, Operation = Operation
            };

            string jsonOutput = JsonConvert.SerializeObject(jsonStructure);
            File.WriteAllText(FullPath, jsonOutput);
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
        }
    }
Beispiel #2
0
    public void Reload()
    {
        try
        {
            EnsureProfileDirectory();

            string jsonInput = File.ReadAllText(FullPath);

            try
            {
                NewJSON newJSON = JsonConvert.DeserializeObject <NewJSON>(jsonInput);
                if (newJSON != null)
                {
                    DisabledList = new HashSet <string>(newJSON.DisabledList);
                    if (newJSON.EnabledList != null)
                    {
                        EnabledList = new HashSet <string>(newJSON.EnabledList);
                    }
                    Operation = newJSON.Operation;
                    UpdateExpertProfile();
                    return;
                }
            }
            catch (Exception ex2)
            {
                try
                {
                    DisabledList = new HashSet <string>(JsonConvert.DeserializeObject <List <string> >(jsonInput));
                    Operation    = SetOperation.Expert;
                    UpdateExpertProfile();
                }
                catch (Exception ex3)
                {
                    Debug.LogException(ex3);
                }
            }
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
        }
    }
Beispiel #3
0
    public void Save()
    {
        try
        {
            EnsureProfileDirectory();

            NewJSON jsonStructure = new NewJSON()
            {
                DisabledList = new List <string>(DisabledList), Operation = Operation
            };

            if (Operation == SetOperation.Expert)
            {
                // Update the EnabledList based on currently installed mods.
                if (EnabledList == null)
                {
                    EnabledList = new HashSet <string>();
                }
                foreach (string name in ModSelectorService.Instance._allExpertMods)
                {
                    if (DisabledList.Contains(name))
                    {
                        EnabledList.Remove(name);
                    }
                    else
                    {
                        EnabledList.Add(name);
                    }
                }
                jsonStructure.EnabledList = new List <string>(EnabledList);
            }

            string jsonOutput = JsonConvert.SerializeObject(jsonStructure, Formatting.Indented);
            File.WriteAllText(FullPath, jsonOutput);
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
        }
    }