示例#1
0
            public virtual T Load <T, U>(IExposedMod mod) where T : U, new()
            {
                ModEntry modEntry = mod as ModEntry;
                var      t        = new T();
                var      filepath = GetSettingsPath(modEntry);

                if (File.Exists(filepath))
                {
                    try
                    {
                        using (var stream = File.OpenRead(filepath))
                        {
                            var serializer = new XmlSerializer(typeof(T));
                            var result     = (T)serializer.Deserialize(stream);
                            return(result);
                        }
                    }
                    catch (Exception e)
                    {
                        LoggerDelegates.LogError($"Can't read {filepath}.", e);
                    }
                }

                return(t);
            }
示例#2
0
        public bool ParseManifest(string strManifestPath)
        {
            string dirPath  = Path.GetDirectoryName(strManifestPath);
            string fileName = Path.GetFileName(strManifestPath);

            try
            {
                if (!File.Exists(strManifestPath))
                {
                    fileName        = fileName.ToLower();
                    strManifestPath = Path.Combine(dirPath, fileName);
                }
                string  json    = File.ReadAllText(strManifestPath);
                UMMData modData = JsonConvert.DeserializeObject <UMMData>(json);
                if (modData.Base_Id != null)
                {
                    AssignBaseData(modData);
                    m_strAssemblyName = modData.AssemblyName;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception exc) {
                bool isParserError = (exc is JsonException) ? true : false;
                if (!isParserError)
                {
                    LoggerDelegates.LogError("Failed to parse mod data", exc);
                }

                return(false);
            }
        }
示例#3
0
 public static void LoadVortexUI(List <IExposedMod> exposedMods)
 {
     try
     {
         VortexUI.Load(exposedMods);
     }
     catch (Exception exc)
     {
         LoggerDelegates.LogError(exc);
     }
 }
示例#4
0
        public static ModEntry FindMod(string id)
        {
            IExposedMod mod = BaseModType.ExposedMods
                              .Where(entry => ((entry as ModEntry) != null) && (entry.GetModName() == id))
                              .SingleOrDefault();

            if (mod == null)
            {
                LoggerDelegates.LogError($"Unable to find mod: {id}");
            }

            return(mod as ModEntry);
        }
 static public void TryDelete(string strFilePath)
 {
     if (!File.Exists(strFilePath))
     {
         return; // No file, no problems.
     }
     try
     {
         File.Delete(strFilePath);
     }
     catch (Exception e)
     {
         LoggerDelegates.LogError("Unable to delete file", e);
         return;
     }
 }
示例#6
0
            public static void Save <T>(T data, ModEntry mod) where T : ModSettings, new()
            {
                var filepath = data.GetSettingsPath(mod);

                try
                {
                    using (var writer = new StreamWriter(filepath))
                    {
                        var serializer = new XmlSerializer(typeof(T));
                        serializer.Serialize(writer, data);
                    }
                }
                catch (Exception e)
                {
                    LoggerDelegates.LogError($"Can't save {filepath}.", e);
                }
            }
示例#7
0
        public T Load <T, U>(IExposedMod mod) where T : U, new()
        {
            string strSettingsPath = GetSettingsPath(mod);

            if (File.Exists(strSettingsPath))
            {
                try
                {
                    T deserialized = JsonConvert.DeserializeObject <T>(strSettingsPath);
                    return(deserialized);
                }
                catch (Exception e)
                {
                    LoggerDelegates.LogError($"Can't read {strSettingsPath}.", e);
                }
            }

            return(new T());
        }
示例#8
0
        private void ToggleWindow(bool isOpen)
        {
            if (isOpen == IsOpen)
            {
                return;
            }

            m_bIsOpen = isOpen;

            try
            {
                if (null != m_UIAssetBundle)
                {
                    LoadVortexOverlay(isOpen);
                }
            }
            catch (Exception e)
            {
                // We didn't manage to load the Overlay.
                //  That's fine, keep going.
                LoggerDelegates.LogInfo(e);
            }

            if (isOpen)
            {
                // Keep track of the initial cursor settings.
                m_CursorStatus.IsCursorActive = Cursor.visible;
                m_CursorStatus.LockState      = Cursor.lockState;

                // Stop time and ensure that the cursor is enabled.
                Time.timeScale   = 0f;
                Cursor.visible   = true;
                Cursor.lockState = CursorLockMode.None;
            }
            else
            {
                // Re-instate the original cursort settings and resume time.
                Time.timeScale   = 1f;
                Cursor.visible   = m_CursorStatus.IsCursorActive;
                Cursor.lockState = m_CursorStatus.LockState;
            }
        }
示例#9
0
        public static T Load <T>(VortexMod mod) where T : VortexModSettings, new()
        {
            T      t = new T();
            string strSettingsPath = t.GetSettingsPath(mod);

            if (File.Exists(strSettingsPath))
            {
                try
                {
                    string fileContents = File.ReadAllText(strSettingsPath);
                    T      deserialized = JsonConvert.DeserializeObject <T>(fileContents);
                    return(deserialized);
                }
                catch (Exception e)
                {
                    LoggerDelegates.LogError($"Can't read {strSettingsPath}.", e);
                }
            }

            return(t);
        }
示例#10
0
            public static T Load <T>(ModEntry modEntry) where T : ModSettings, new()
            {
                var t        = new T();
                var filepath = t.GetSettingsPath(modEntry);

                if (File.Exists(filepath))
                {
                    try
                    {
                        using (var stream = File.OpenRead(filepath))
                        {
                            var serializer = new XmlSerializer(typeof(T));
                            var result     = (T)serializer.Deserialize(stream);
                            return(result);
                        }
                    }
                    catch (Exception e)
                    {
                        LoggerDelegates.LogError($"Can't read {filepath}.", e);
                    }
                }

                return(t);
            }
示例#11
0
 public void Critical(string str)
 {
     LoggerDelegates.LogError(m_modId + str);
 }
示例#12
0
 public void Log(string str)
 {
     LoggerDelegates.LogInfo(m_modId + str);
 }
示例#13
0
 public void LogException(Exception e)
 {
     LoggerDelegates.LogError(m_modId, e);
 }
示例#14
0
 public void LogException(string key, Exception e)
 {
     LoggerDelegates.LogError(m_modId + key, e);
 }