Exemplo n.º 1
0
        public static void SerializeToXML(Settings_Funky settings)
        {
            // Type[] Settings=new Type[] {typeof(SettingCluster),typeof(SettingFleeing),typeof(SettingGrouping),typeof(SettingItemRules),typeof(SettingLoot),typeof(SettingRanges) };
            XmlSerializer serializer = new XmlSerializer(typeof(Settings_Funky));
            TextWriter    textWriter = new StreamWriter(FolderPaths.sFunkySettingsCurrentPath);

            serializer.Serialize(textWriter, settings);
            textWriter.Close();
        }
Exemplo n.º 2
0
        public static void LoadFunkyConfiguration()
        {
            string sFunkyCharacterConfigFile = FolderPaths.sFunkySettingsCurrentPath;

            //Check for Config file
            if (!File.Exists(sFunkyCharacterConfigFile))
            {
                Logger.DBLog.InfoFormat("No config file found, now creating a new config from defaults at: " + sFunkyCharacterConfigFile);


                if (Bot.Character.Account.CurrentLevel < 60)
                {
                    Logger.DBLog.InfoFormat("Using Low Level Settings");
                    Bot.Settings = new Settings_Funky
                    {
                        Grouping = new SettingGrouping(false),
                        Cluster  = new SettingCluster(false),
                        Fleeing  = new SettingFleeing(false),
                    };
                }
                else
                {
                    if (Bot.Character.Account.ActorClass == ActorClass.Barbarian || Bot.Character.Account.ActorClass == ActorClass.Monk)
                    {
                        Logger.DBLog.InfoFormat("Using Melee Inferno Default Settings");
                        DeserializeFromXML(Path.Combine(FolderPaths.SettingsDefaultPath, "InfernoMelee.xml"));
                    }
                    else
                    {
                        Logger.DBLog.InfoFormat("Using Ranged Inferno Default Settings");
                        DeserializeFromXML(Path.Combine(FolderPaths.SettingsDefaultPath, "InfernoRanged.xml"));
                    }
                }

                SerializeToXML(Bot.Settings);
            }
            else
            {
                //When new properties are added to exisiting classes.. a check should be done here to append those new settings with old file.

                Settings_Funky testSettings = DeserializeFromXML();

                //Avoidance Check
                if (testSettings.Avoidance.Avoidances.Length != Cache.AvoidanceCache.AvoidancesDefault.Length)
                {
                    Logger.DBLog.Info("[Funky] Settings found missing Avoidances.. reseting avoidance settings to default!");
                    testSettings.Avoidance = new SettingAvoidance();
                    SerializeToXML(testSettings);
                }

                //LOS Check
                if (!testSettings.LOSMovement.EnableLOSMovementBehavior)
                {
                    Logger.DBLog.Info("[Funky] Settings found disabled LOS Movement -- reseting to default values!");
                    testSettings.LOSMovement = new SettingLOSMovement();
                    SerializeToXML(testSettings);
                }
            }



            Bot.Settings = DeserializeFromXML();
        }
Exemplo n.º 3
0
 public static void SerializeToXML(Settings_Funky settings)
 {
     // Type[] Settings=new Type[] {typeof(SettingCluster),typeof(SettingFleeing),typeof(SettingGrouping),typeof(SettingItemRules),typeof(SettingLoot),typeof(SettingRanges) };
     XmlSerializer serializer = new XmlSerializer(typeof(Settings_Funky));
     TextWriter textWriter = new StreamWriter(FolderPaths.sFunkySettingsCurrentPath);
     serializer.Serialize(textWriter, settings);
     textWriter.Close();
 }