Ejemplo n.º 1
0
        internal static SettingsPSI LoadPSISettings([NotNull] string path = "ColonistBar_PSIKF.xml")
        {
            string      configFolder = Path.GetDirectoryName(GenFilePaths.ModsConfigFilePath);
            SettingsPSI __result     = DirectXmlLoader.ItemFromXmlFile <SettingsPSI>(configFolder + "/" + path);

            return(__result);
        }
Ejemplo n.º 2
0
        public static void Init()
        {
            var flag = !new FileInfo(prefsFilePath).Exists;

            data = new BadPeoplePerfsData();
            data = DirectXmlLoader.ItemFromXmlFile <BadPeoplePerfsData>(prefsFilePath, true);
        }
 private void Load()
 {
     if (File.Exists(filepath))
     {
         this.modSettings = DirectXmlLoader.ItemFromXmlFile <SaveableSettings>(filepath, true);
     }
 }
Ejemplo n.º 4
0
        public static void Init()
        {
            var flag = !new FileInfo(prefsFilePath).Exists;

            data = new PrisonLaborPrefsData();
            data = DirectXmlLoader.ItemFromXmlFile <PrisonLaborPrefsData>(prefsFilePath, true);
            Apply();
        }
Ejemplo n.º 5
0
 public static void ReloadAndRebind()
 {
     data = DirectXmlLoader.ItemFromXmlFile <ConceptKnowledge>(GenFilePaths.ConceptKnowledgeFilePath);
     foreach (ConceptDef allDef in DefDatabase <ConceptDef> .AllDefs)
     {
         if (!data.knowledge.ContainsKey(allDef.defName))
         {
             Log.Warning("Knowledge data was missing key " + allDef + ". Adding it...");
             data.knowledge.Add(allDef.defName, 0f);
         }
     }
 }
Ejemplo n.º 6
0
 public static void ReloadAndRebind()
 {
     PlayerKnowledgeDatabase.data = DirectXmlLoader.ItemFromXmlFile <PlayerKnowledgeDatabase.ConceptKnowledge>(GenFilePaths.ConceptKnowledgeFilePath, true);
     foreach (ConceptDef current in DefDatabase <ConceptDef> .AllDefs)
     {
         if (!PlayerKnowledgeDatabase.data.knowledge.ContainsKey(current))
         {
             Log.Warning("Knowledge data was missing key " + current + ". Adding it...", false);
             PlayerKnowledgeDatabase.data.knowledge.Add(current, 0f);
         }
     }
 }
Ejemplo n.º 7
0
        public static Manifest For(ModMetaData mod)
        {
            Manifest manifest;

            if (_manifestCache.TryGetValue(mod, out manifest))
            {
                return(manifest);
            }

            manifest     = new Manifest();
            manifest.mod = mod;

            // get from file.
            var manifestPath = Path.Combine(mod.AboutDir(), ManifestFileName);
            var modsyncPath  = Path.Combine(mod.AboutDir(), ModSyncFileName);

            // manifest is first choice
            if (File.Exists(manifestPath))
            {
                try
                {
                    manifest     = DirectXmlLoader.ItemFromXmlFile <Manifest>(manifestPath);
                    manifest.mod = mod;
                    manifest.dependencies.ForEach(d => d.Owner = manifest);
                    manifest.loadBefore.ForEach(d => d.Owner   = manifest);
                    manifest.loadAfter.ForEach(d => d.Owner    = manifest);
                    if (!manifest.manifestUri.NullOrEmpty())
                    {
                        try
                        {
                            manifest.ManifestUri = new Uri(manifest.manifestUri);
                        }
                        catch (Exception e)
                        {
                            Log.Warning($"Error parsing manifestUri: {e.Message}\n\n{e.StackTrace}");
                        }
                    }
                    if (!manifest.targetVersions.NullOrEmpty())
                    {
                        manifest.TargetVersions = new List <Version>();
                        foreach (var targetVersion in manifest.targetVersions)
                        {
                            manifest.TargetVersions.Add(manifest.ParseVersion(targetVersion));
                        }
                    }
                }
                catch (Exception e)
                {
                    manifest = new Manifest(mod);
                    Log.Error($"Error loading manifest for '{mod.Name}':\n{e.Message}\n\n{e.StackTrace}");
                }
            }

            // modsync manifest can provide some info
            else if (File.Exists(modsyncPath))
            {
                try
                {
                    ModSync modsync = DirectXmlLoader.ItemFromXmlFile <ModSync>(modsyncPath);
                    manifest = modsync.Manifest(mod);
                }
                catch (Exception e)
                {
                    manifest = new Manifest(mod);
                    Log.Error($"Error loading ModSync into manifest for '{mod.Name}': {e.Message}\n\n{e.StackTrace}");
                }
            }

            // resolve version - if set in manifest or modsync that takes priority,
            // otherwise try to read version from assemblies.
            manifest.SetVersion();
            _manifestCache.Add(mod, manifest);
            return(manifest);
        }
Ejemplo n.º 8
0
 internal static ModsConfigData ReadModList(string filepath)
 {
     return(DirectXmlLoader.ItemFromXmlFile <ModsConfigData>(filepath, true));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Gets an object from an xml file
 /// </summary>
 /// <typeparam name="T">The object type</typeparam>
 /// <param name="filepath">The xml file path</param>
 /// <param name="resolveCrossRefs">Set true to resolve cross refs[Optional](Default:false)</param>
 /// <returns></returns>
 public static T ItemFromXmlFile <T>(string filepath, bool resolveCrossRefs = false) where T : new()
 {
     return(DirectXmlLoader.ItemFromXmlFile <T>(filepath, resolveCrossRefs));
 }