Esempio n. 1
0
        public static GlassPreset LoadFromXML(string path, bool showDebug = true, bool secondAttempt = false)
        {
            if (path.Contains("/.xml") || path.Contains("GlassManagerSettings"))
            {
                if (showDebug)
                {
                    Debug.Log("GlassPreset: Skipping file:" + path);
                }
                return(null);
            }

            if (!File.Exists(path))
            {
                if (showDebug)
                {
                    Debug.Log("GlassPreset: File does not exists:" + path);
                }
                return(null);
            }

            XmlSerializer xmlserialiser = new XmlSerializer(typeof(GlassPreset));

            FileStream filestream = new FileStream(path, FileMode.Open);

            GlassPreset loadedPreset = null;

            try
            {
                loadedPreset = xmlserialiser.Deserialize(filestream) as GlassPreset;
            }
            catch (Exception e)
            {
                if (secondAttempt)
                {
                    if (showDebug)
                    {
                        Debug.Log("GlassPreset: Unable to fix & load preset from XML '" + path + "': " + e.Message);
                        filestream.Close();
                        return(loadedPreset);
                    }
                }
                else
                {
                    filestream.Close();
                    AttemptFix(path, showDebug);
                    return(LoadFromXML(path, showDebug, true));
                }
                loadedPreset = null;
            }

            if (showDebug && secondAttempt)
            {
                Debug.Log("GlassPreset: Successfully fixed / converted preset xml: '" + path + "!");
            }

            filestream.Close();
            return(loadedPreset);
        }
Esempio n. 2
0
        public static List <GlassPreset> LoadAllPresets()
        {
            List <string>      presetNames = Glass_Editor.GetPresetList();
            List <GlassPreset> presets     = new List <GlassPreset>();

            foreach (string presetName in presetNames)
            {
                GlassPreset preset = GlassPreset.LoadFromName(presetName);
                presets.Add(preset);
            }
            return(presets);
        }
Esempio n. 3
0
 public static void CleanUpPresetList(ref List <GlassPreset> presetList)
 {
     for (int i = presetList.Count - 1; i >= 0; i--)
     {
         GlassPreset testPreset = presetList[i];
         //
         if (testPreset == null)
         {
             presetList.RemoveAt(i);
         }
     }
 }
Esempio n. 4
0
        public static void RunSetup_FirstTime_ThisVersion()
        {
            List <GlassPreset> presets = LoadAllPresets();

            CleanUpPresetList(ref presets);
            for (int i = 0; i < presets.Count; i++)
            {
                GlassPreset preset = presets[i];
                Setup_Preset_ThisVersion(ref preset);
                if (preset != null)
                {
                    preset.Save();
                }
            }
        }
Esempio n. 5
0
 public static void Setup_Preset_ThisVersion(ref GlassPreset preset)
 {
     //  TODO: handle changes that should occur for this version of Glass's presets that didn't previously
 }
 public static Glass_GlassManager_Settings Load(string xmlPath, GlassPreset glassPreset, bool showDebug = false)
 {
     return(Load(xmlPath, glassPreset.name, showDebug));
 }