Jump to content

FC - Settings bug


arkhan

Recommended Posts

Hi,

I'm making a FC in c# with the exemple there

Everythink is ok except for settings

when i click on settings, the box show settings but without default settings an when i try to save settings it only save the last data.

[Serializable]
public class ShamanSettings : Settings
{
    [Setting]
    [DefaultValue(true)]
    [Category("GHOST WOLF SETTINGS")]
    [DisplayName("Ghost Wolf")]
    [Description("Use Ghost Wolf")]
    public bool UGW { get; set; }

    [Setting]
    [DefaultValue(4)]
    [Category("GHOST WOLF SETTINGS")]
    [DisplayName("Use after X secondes")]
    [Description("Use Ghost Wolf after X secondes out of combat")]
    public int TGW { get; set; }

    [Setting]
    [DefaultValue(50)]
    [Category("GHOST WOLF SETTINGS")]
    [DisplayName("Mana required")]
    [Description("Use Ghost Wolf only if mana is superior or equal")]
    public int MGW { get; set; }

    private ShamanSettings()
    {
        ConfigWinForm(new System.Drawing.Point(400, 400), "Shaman " + Translate.Get("Settings"));
    }

    public static ShamanSettings CurrentSetting { get; set; }

    public bool Save()
    {
        try
        {
            return Save(AdviserFilePathAndName("CustomClass-Shaman", ObjectManager.Me.Name + "." + Usefuls.RealmName));
        }
        catch (Exception e)
        {
            Logging.WriteError("ShamanSettings > Save(): " + e);
            return false;
        }
    }

    public static bool Load()
    {
        try
        {
            if (File.Exists(AdviserFilePathAndName("CustomClass-Shaman", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
            {
                CurrentSetting =
                    Load<ShamanSettings>(AdviserFilePathAndName("CustomClass-Shaman",
                                                                 ObjectManager.Me.Name + "." + Usefuls.RealmName));
                return true;
            }
            CurrentSetting = new ShamanSettings();
        }
        catch (Exception e)
        {
            Logging.WriteError("ShamanSettings > Load(): " + e);
        }
        return false;
    }
}

there is the full c# file

if somoene can help me to figure this out

 

Arkhan-ShamEnh.cs

Link to comment
Share on other sites

Hello @arkhan, i've re-created it:



    public void ShowConfiguration()
    {
        CustomClass_ShamanSettings.Load();
        CustomClass_ShamanSettings.CurrentSetting.ToForm();
        CustomClass_ShamanSettings.CurrentSetting.Save();
    }





	public class CustomClass_ShamanSettings : Settings
    {
        public static CustomClass_ShamanSettings CurrentSetting { get; set; }
        public bool Save()
        {
            try
            {
                return Save(AdviserFilePathAndName("CustomClass_Shaman", ObjectManager.Me.Name + "." + Usefuls.RealmName));
            }
            catch (Exception e)
            {
                Logging.WriteError("CustomClass_ShamanSettings > Save(): " + e);
                return false;
            }
        }
        public static bool Load()
        {
            try
            {
                if (File.Exists(AdviserFilePathAndName("CustomClass_Shaman", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
                {
                    CurrentSetting =
                        Load<CustomClass_ShamanSettings>(AdviserFilePathAndName("CustomClass_Shaman",
                                                                     ObjectManager.Me.Name + "." + Usefuls.RealmName));
                    return true;
                }
                CurrentSetting = new CustomClass_ShamanSettings
                {
                    UGW = true,
                    TGW = 4,
                    MGW = 50
                };
            }
            catch (Exception e)
            {
                Logging.WriteError("CustomClass_ShamanSettings > Load(): " + e);
            }
            return false;
        }

        [Setting]
        [Category("GHOST WOLF SETTINGS")]
        [DisplayName("Ghost Wolf")]
        [Description("Use Ghost Wolf")]
        public bool UGW { get; set; }

        [Setting]
        [Category("GHOST WOLF SETTINGS")]
        [DisplayName("Use after X secondes")]
        [Description("Use Ghost Wolf after X secondes out of combat")]
        public int TGW { get; set; }

        [Setting]
        [Category("GHOST WOLF SETTINGS")]
        [DisplayName("Mana required")]
        [Description("Use Ghost Wolf only if mana is superior or equal")]
        public int MGW { get; set; }

    }

 

Link to comment
Share on other sites

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...