コード例 #1
0
ファイル: SingularSettings.cs プロジェクト: aash/Singular
 public static void Initialize()
 {
     if (_instance == null)
         _instance = new SingularSettings();
 }
コード例 #2
0
ファイル: SingularSettings.cs プロジェクト: aash/Singular
        public SingularSettings()
            : base(Path.Combine(CharacterSettingsPath, "SingularSettings.xml"))
        {
            // changing how we are initialize the _instance pointer
            entrycount++;
            if (entrycount != 1)
            {
                Logger.WriteFile("Settings: unexpected reentrant call in Settings: {0}", entrycount );
            }

            if (_instance != null)
            {
                if (_instance != this)
                {
                    Logger.WriteFile("Settings: unexpected singleton error");
                }
            }
            else
            {
                _instance = this;

                bool fileExists = ConfigVersion != null;
                bool weSetPullMoreValues = false;
                Version verSourceCode = SingularRoutine.GetSingularVersion();
                Version verConfigFile = null;

                // if version is null, set to current value
                if (ConfigVersion == null)
                {
                    verConfigFile = verSourceCode;
                    ConfigVersion = verConfigFile.ToString();
                }

                try
                {
                    verConfigFile = new Version(ConfigVersion);
                }
                catch
                {
                    verConfigFile = verSourceCode;
                }

                if (verConfigFile < verSourceCode)
                {
                    Logger.WriteDiagnostic(LogColor.Init, "Settings: config file from verion {0}", verConfigFile.ToString());
                    if (verConfigFile < new Version("3.0.0.3080"))
                    {
                        Logger.Write(LogColor.Init, "Settings: applying {0} related changes", new Version("3.0.0.3080").ToString());
                        UseFrameLock = true;
                        DisableInQuestVehicle = false;
                    }

                    if (verConfigFile < new Version("3.0.0.3173"))
                    {
                        Logger.WriteDiagnostic(LogColor.Init, "Settings: applying {0} related changes", new Version("3.0.0.3173").ToString());
                        if ( MinHealth == 65)
                            MinHealth = 60;
                        if (MinMana == 65)
                            MinMana = 50;
                    }

                    if (verConfigFile < new Version("4.0.0.4000"))
                    {
                        weSetPullMoreValues = true;
                        SetDefaultPullMoreSettingValues();
                    }

                    Version ver_4_0_0_4631 = new Version("4.0.0.4631");
                    if (verConfigFile <= ver_4_0_0_4631)
                    {
                        if (StyxWoW.Me.Class == WoWClass.Mage && this.KiteAllow == false)
                        {
                            this.KiteAllow = true;
                            Logger.Write(LogColor.Init, "Settings: set Kiting Allowed to 'true' for Mages upgrading from {0} or earlier", ver_4_0_0_4631);
                        }
                    }

                    ConfigVersion = verSourceCode.ToString();
                    Logger.WriteDiagnostic(LogColor.Init, "Settings: config settings upgrade to {0} complete", ConfigVersion.ToString());
                }

                // Pull More settings should be overwritten if !fileExist or last config saved was before selecting Specialization
                if (!weSetPullMoreValues)
                    SetDefaultPullMoreSettingValues();

                // set calculated default values if file did not exist
                if (!fileExists)
                {
                    if (StyxWoW.Me.Class == WoWClass.DeathKnight)
                    {
                        this.MinHealth = 50;
                        Logger.Write(LogColor.Init, "Settings: default Min Health to {0}% since Death Knight", this.MinHealth);
                    }

                    if (StyxWoW.Me.Class == WoWClass.Mage)
                    {
                        if (this.KiteAllow == false)
                        {
                            this.KiteAllow = true;
                            Logger.Write(LogColor.Init, "Settings: default Allow Kiting to true since Mage");
                        }
                    }
                }
            }

            // Validate settings
            //===================================================================================
            StayNearTankRangeCombat = Validate.IntValue("StayNearTankRangeCombat", 5, 100, StayNearTankRangeCombat );
            StayNearTankRangeRest = Validate.IntValue("StayNearTankRangeRest", 5, 100, StayNearTankRangeRest);

            entrycount--;
        }