Jump to content
  • [VANILLA] Custom settings not saved properly


    DonaldMacRonald
    • Version: All Product: WRobot General Type: Bug Status: Not a Bug

    Here is an example of class I use :

    public class PriestSettings : Settings
    {
        [Setting]
        [DefaultValue(true)]
        [Category("Movements")]
        [DisplayName("Follow Mode")]
        [Description("Follow the party Leader. Only working when in party")]
        public bool FollowMode { get; set; }
    
    
        [Setting]
        [DefaultValue(80)]
        [Category("Heal")]
        [DisplayName("Lesser Heal Treshold")]
        [Description("Limit of Life under which bot trigger LesserHeal.In percent")]
        public double LesserHealTreshold { get; set; }
    
    
        private PriestSettings()
        {
            ConfigWinForm(new System.Drawing.Point(400, 400), "Priest " + Translate.Get("Settings"));
        }
    
        public static PriestSettings CurrentSetting { get; set; }
    
        public bool Save()
        {
            try
            {
                return Save(AdviserFilePathAndName("McRo-Priest", ObjectManager.Me.Name + "." + Usefuls.RealmName));
            }
            catch (Exception e)
            {
                Logging.WriteError("PriestSettings > Save(): " + e);
                return false;
            }
        }
    
        public static bool Load()
        {
            try
            {
                if (File.Exists(AdviserFilePathAndName("McRo-Priest", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
                {
                    CurrentSetting =
                        Load<PriestSettings>(AdviserFilePathAndName("McRo-Priest",
                                                                     ObjectManager.Me.Name + "." + Usefuls.RealmName));
                    return true;
                }
                CurrentSetting = new PriestSettings();
            }
            catch (Exception e)
            {
                Logging.WriteError("PriestSettings > Load(): " + e);
            }
            return false;
        }
    }

    When trying to change a value, in the resulting XML: 

    • the value changed is never saved. If it existed in the file it is totaly deleted
    • the value non targeted by the change may be delete also (randomly)

     

     



    User Feedback

    Recommended Comments

    Droidz

    Posted

    Hello, do you call method "Save()" ? Do you get error in your log?

    DonaldMacRonald

    Posted

    Hello,

    Yes I do call Save(), at the end of the sowconfiguration, and no curiously I have no message, even in debug mode.

    DonaldMacRonald

    Posted

    Oddly, when the configuration Panels open, the current state of the file isn't correctly displayed too.
    Some variables are displayed false whereas they are set at true in  the saved file.

    No correlation between default values.

    Matenia

    Posted

    This works when making the Settings constructor public, for some reason.



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...