Jump to content
  • Settings support for XML fight classes


    kergudu
    • Version: All Product: Fight Classes Type: Suggestion Status: Awaiting Feedback

    In current implementation i can add to XML fight class additional C# code like this and use settings window:

    [Serializable]
    public class ShadowPriestSettings : Settings{
    ...bla bla bla
    }

    this works with settings class name exactly equals [FightClass]Settings where [FightClass] is name, declared in "General Settings" -> "Fight Class Name". It would be nice to use any name, with additional C# code like this:

    public void ShowConfiguration() {
      InnerSettings.Load();
      InnerSettings.CurrentSetting.ToForm();
      InnerSettings.CurrentSetting.Save();
    }
    
    [Serializable]
    public class InnerSettings : Settings{
    ... bla bla bla
    }

    For now, it not works, robot says "Type 'Main' already defines a member called 'ShowConfiguration' with the same parameter types"

    Is there any legal option to use settings with XML fight class?



    User Feedback

    Recommended Comments

    It tricky but possible :wink:

    This is additional C#, nothing special, only proof (with egyptian brackets, because i am Java programmer :smile:)

    Spoiler
    
    [Serializable]
    public class TestSettings : Settings {
    
      [Setting, DefaultValue(0)]
      [Category("Test")]
      [DisplayName("Test Spell")]
      [Description("Print here any known spell")]
      public string testSpell { get; set; }
    
      private TestSettings(){
        ConfigWinForm(new System.Drawing.Point(400, 400), "Test " + Translate.Get("Settings"));
      }
    
      public static TestSettings CurrentSetting { get; set; }
    
      public bool Save() {
        try {
          return Save(AdviserFilePathAndName("CustomClass-Test", ObjectManager.Me.Name + "." + Usefuls.RealmName));
        } catch (Exception e) {
          Logging.WriteError("TestSettings > Save(): " + e);
          return false;
        }
      }
    
      public static bool Load() {
        try {
          if (File.Exists(AdviserFilePathAndName("CustomClass-Test", ObjectManager.Me.Name + "." + Usefuls.RealmName))) {
            CurrentSetting =
              Load<TestSettings>(AdviserFilePathAndName("CustomClass-Test",
                                     ObjectManager.Me.Name + "." + Usefuls.RealmName));
            return true;
          }
          CurrentSetting = new TestSettings();
        } catch (Exception e) {
          Logging.WriteError("TestSettings > Load(): " + e);
        }
        return false;
      }
    }
    
    public bool castSpell() {
      SpellManager.CastSpellByNameLUA(Main.TestSettings.CurrentSetting.testSpell);
      Usefuls.WaitIsCasting();
      return true;
    }

     

    And this is fight class: testClass.xml 

    Load it, open Settings and type any known spell. For example, "Steady Shot" for hunter. Then go to target dumy and check.

    Just want to use the same "legally", without special names for settings class. Maybe one more property in fight class

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