Ejemplo n.º 1
0
        private bool LoadMods()
        {
            m_modReader.Mods.Clear();
            m_modReader.Errors.Clear();

            m_modReader.ParseFolder(Path.Combine(InstallDir.FullName, @"mod").Replace('\\', '/'), ModReader.Folder.CKDir);
            m_modReader.ParseFolder(Path.Combine(MyDocsDir.FullName, @"mod").Replace('\\', '/'), ModReader.Folder.MyDocs);

            if (m_modReader.Errors.Count != 0)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Errors encountered during mod loading: ");
                sb.AppendLine();

                foreach (string err in m_modReader.Errors)
                {
                    sb.AppendLine(err);
                }

                Error    = sb.ToString();
                HadError = true;

                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public List <Mod> LoadMods(string modDir)
        {
            List <Mod> mods = new List <Mod>();

            if (Directory.Exists(modDir))
            {
                logger.LogInformation("Loading mods from " + modDir);
                mods = ModReader.ParseFolder(modDir);
                foreach (Mod mod in mods)
                {
                    if (Directory.Exists(mod.AbsolutePath))
                    {
                        logger.LogInformation("Loading portraits from mod: " + mod.Name);
                        var reader = new PortraitReader(mod.AbsolutePath);
                        mod.PortraitData = reader.Parse();

                        if (!mod.HasPortraitData)
                        {
                            mod.Enabled        = false;
                            mod.DisabledReason = "No portrait data found";
                        }
                    }
                    else if (mod.AbsolutePath.EndsWith(".zip"))
                    {
                        mod.Enabled        = false;
                        mod.DisabledReason = "Archive format is not supported by PortraitBuilder";
                        logger.LogWarning("Mod " + mod.Name + " is using archive format, which is not supported by PortraitBuilder");
                    }
                    else
                    {
                        mod.Enabled        = false;
                        mod.DisabledReason = "Mod path does not not exist";
                        logger.LogError("Mod path " + mod.AbsolutePath + " does not exist");
                    }
                }
            }
            else
            {
                logger.LogError("Mod directory {0} doesn't exist", modDir);
            }

            return(mods);
        }