Beispiel #1
0
 public ModEnvironmentConfiguration(ModEnvironmentConfiguration from)
 {
     mHashes            = new HashData(from.Hashes);
     ModReferences      = from.ModReferences;
     ClearLogsOnRebuild = from.ClearLogsOnRebuild;
     GraphicsProfile    = from.GraphicsProfile;
 }
Beispiel #2
0
        protected static void Save(ModEnvironmentConfiguration self, System.IO.FileInfo xmlConfigFile)
        {
            // http://stackoverflow.com/questions/2129414/how-to-insert-xml-comments-in-xml-serialization


            var dcserializer = new System.Runtime.Serialization.DataContractSerializer(typeof(ModEnvironmentConfiguration));

            //var serializer = new System.Xml.Serialization.XmlSerializer(typeof(ModEnvironmentConfiguration));
            using (var wstream = xmlConfigFile.Open(System.IO.FileMode.Create))
                using (var writer = System.Xml.XmlWriter.Create(wstream, new System.Xml.XmlWriterSettings()
                {
                    Indent = true
                }))
                {
                    writer.WriteStartDocument();
                    writer.WriteComment("DO NOT CHANGE ANYTHING IN THIS FILE WITHOUT DELETING GnomoriaModded.exe!");//\nThis will make the EXE be recreated, since otherwise the game will crash.
                    //serializer.Serialize(writer, self);
                    dcserializer.WriteObject(writer, self);
                    writer.WriteEndDocument();
                    writer.Flush();
                    writer.Close();
                }
        }
Beispiel #3
0
        public static void Initialize(string[] args)
        {
            ModEnvironment.Status = ModEnvironment.EnvironmentStatus.InGame;
            //System.Diagnostics.Debugger.Break();
            //System.Diagnostics.Debug.Assert(false);

            Log.WriteText(
                Environment.NewLine
                + "________________________________________________" + Environment.NewLine
                + "Gnomoria with mod support startet." + Environment.NewLine
                + "Game version: " + typeof(Game.GnomanEmpire).Assembly.GetName().Version + Environment.NewLine
                + Environment.NewLine,
                Log.LogLevel.Normal,
                Log.TargetModes.File
                );

            //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            var loadAssemblys = !args.Contains("-noassemblyloading");

            try
            {
                active_mods = new List <IMod>();
                var loaded_modfiles = new List <string>();
                var config          = ModEnvironmentConfiguration.Load(new System.IO.FileInfo("GnomoriaModConfig.xml"));
                foreach (var modRef in config.ModReferences)
                {
                    if (!loaded_modfiles.Contains(modRef.AssemblyFile.FullName))
                    {
                        if (loadAssemblys)
                        {
                            Assembly.LoadFrom(modRef.AssemblyFile.FullName);
                        }
                        else
                        {
                            Type.GetType(modRef.TypeName);
                        }
                        loaded_modfiles.Add(modRef.AssemblyFile.FullName);
                    }
                }
                foreach (var modRef in config.ModReferences)
                {
                    var mod = ModEnvironment.Mods[modRef];
                    if (modRef.SetupData != null)
                    {
                        mod.SetupData = modRef.SetupData;
                    }
                    mod.Initialize_PreGame();
                    active_mods.Add(mod);
                }
            }
            catch (Exception err)
            {
                Log.Write(err);
                throw;
            }


            //System.IO.File.WriteAllLines("c:\\programme\\gnomoria\\modding.xml", new string[] { "IT", "DOES", "F*****G", "WORK", "", ":D" });

            //throw new Exception("injecting mod-init successful");

            /*
             * RuntimeModsConfig modsConfig;
             * var serializer = new System.Xml.Serialization.XmlSerializer(typeof(RuntimeModsConfig));
             * using (var fstream = System.IO.File.OpenRead("ModRuntimeData.xml"))
             * {
             *  modsConfig = (RuntimeModsConfig)serializer.Deserialize(fstream);
             *  fstream.Close();
             * }
             */
            //LoadMod(new DemoMod().GetConfig());
        }
 private void DoStuff_InitAndLoadConfig()
 {
     try
     {
         current_config = ModdingEnvironmentConfiguration.LoadOrCreate(ModManager.GameDirectory.ContainingFile(ModManager.config_file_name));
     }
     catch (Exception err)
     {
         MessageBox.Show(err.ToString());
     }
 }
        protected static void Save(ModEnvironmentConfiguration self, System.IO.FileInfo xmlConfigFile)
        {
            // http://stackoverflow.com/questions/2129414/how-to-insert-xml-comments-in-xml-serialization


            var dcserializer = new System.Runtime.Serialization.DataContractSerializer(typeof(ModEnvironmentConfiguration));
            //var serializer = new System.Xml.Serialization.XmlSerializer(typeof(ModEnvironmentConfiguration));
            using (var wstream = xmlConfigFile.Open(System.IO.FileMode.Create))
            using (var writer = System.Xml.XmlWriter.Create(wstream, new System.Xml.XmlWriterSettings() { Indent = true }))
            {
                writer.WriteStartDocument();
                writer.WriteComment("DO NOT CHANGE ANYTHING IN THIS FILE WITHOUT DELETING GnomoriaModded.exe!");//\nThis will make the EXE be recreated, since otherwise the game will crash.
                //serializer.Serialize(writer, self);
                dcserializer.WriteObject(writer, self);
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
 public ModEnvironmentConfiguration(ModEnvironmentConfiguration from)
 {
     mHashes = new HashData(from.Hashes);
     ModReferences = from.ModReferences;
     ClearLogsOnRebuild = from.ClearLogsOnRebuild;
     GraphicsProfile = from.GraphicsProfile;
 }