Example #1
0
        public _7thWrapperLib.RuntimeMod GetRuntime(_7thWrapperLib.LoaderContext context)
        {
            var mod = Sys.Library.GetItem(ModID);

            if (mod == null)
            {
                return(null);
            }
            string location = System.IO.Path.Combine(Sys.Settings.LibraryLocation, mod.LatestInstalled.InstalledLocation);

            _7thWrapperLib.ModInfo modinfo = null;
            if (mod.LatestInstalled.InstalledLocation.EndsWith(".iro"))
            {
                using (var arc = new _7thWrapperLib.IrosArc(location)) {
                    if (arc.HasFile("mod.xml"))
                    {
                        var doc = new System.Xml.XmlDocument();
                        doc.Load(arc.GetData("mod.xml"));
                        modinfo = new _7thWrapperLib.ModInfo(doc, context);
                    }
                }
            }
            else
            {
                string mfile = System.IO.Path.Combine(location, "mod.xml");
                if (System.IO.File.Exists(mfile))
                {
                    modinfo = new _7thWrapperLib.ModInfo(mfile, context);
                }
            }
            modinfo = modinfo ?? new _7thWrapperLib.ModInfo();

            foreach (var opt in modinfo.Options)
            {
                if (!Settings.Any(s => s.ID.Equals(opt.ID, StringComparison.InvariantCultureIgnoreCase)))
                {
                    Settings.Add(new ProfileSetting()
                    {
                        ID = opt.ID, Value = opt.Default
                    });
                }
            }

            return(new _7thWrapperLib.RuntimeMod(
                       location,
                       modinfo.Conditionals.Where(f => IsActive(f.ActiveWhen)),
                       modinfo.ModFolders.Where(f => IsActive(f.ActiveWhen)).Select(f => f.Folder),
                       modinfo.LoadLibraries,
                       modinfo.LoadAssemblies,
                       modinfo.LoadPlugins
                       ));
        }
Example #2
0
File: Sys.cs Project: Erendel/7h
        public static void InitLoaderContext()
        {
            _context = new _7thWrapperLib.LoaderContext()
            {
                VarAliases = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase)
            };

            string varFile = Path.Combine(_7HFolder, "7thHeaven.var");


            if (File.Exists(varFile))
            {
                foreach (string line in File.ReadAllLines(varFile))
                {
                    string[] parts = line.Split(new[] { '=' }, 2);

                    if (parts.Length == 2)
                    {
                        _context.VarAliases[parts[0]] = parts[1];
                    }
                }
            }
        }