public static bool DetectConfigDefaultsReset(Mod mod)
 {
     if (ModMetaDataManager.GetConfigDefaultsResetMethod(mod) == null)
     {
         return(false);
     }
     return(true);
 }
 public static bool DetectConfig(Mod mod)
 {
     if (ModMetaDataManager.GetConfigFilePathProp(mod) == null)
     {
         return(false);
     }
     if (ModMetaDataManager.GetConfigFileLoadMethod(mod) == null)
     {
         return(false);
     }
     return(true);
 }
        ////////////////

        public static bool DetectGithub(Mod mod)
        {
            if (ModMetaDataManager.GetGithubUserNameProp(mod) == null)
            {
                return(false);
            }
            if (ModMetaDataManager.GetGitubProjectNameProp(mod) == null)
            {
                return(false);
            }
            return(true);
        }
Exemple #4
0
        public override void Load()
        {
            HamstarHelpersMod.Instance = this;

            this.LoadConfigs();

            if (!this.HasUnhandledExceptionLogger && this.Config.DebugModeUnhandledExceptionLogging)
            {
                this.HasUnhandledExceptionLogger            = true;
                AppDomain.CurrentDomain.UnhandledException += HamstarHelpersMod.UnhandledLogger;
            }

            this.LoadHelpers = new TmlHelpers.LoadHelpers();
            this.Promises    = new Promises();

            this.Timers                    = new Timers();
            this.LogHelpers                = new DebugHelpers.LogHelpers();
            this.ModMetaDataManager        = new TmlHelpers.ModMetaDataManager();
            this.BuffHelpers               = new BuffHelpers.BuffHelpers();
            this.NetHelpers                = new NetHelpers.NetHelpers();
            this.ItemIdentityHelpers       = new ItemHelpers.ItemIdentityHelpers();
            this.NPCIdentityHelpers        = new NPCHelpers.NPCIdentityHelpers();
            this.ProjectileIdentityHelpers = new ProjectileHelpers.ProjectileIdentityHelpers();
            this.BuffIdentityHelpers       = new BuffHelpers.BuffIdentityHelpers();
            this.NPCBannerHelpers          = new NPCHelpers.NPCBannerHelpers();
            this.RecipeHelpers             = new RecipeHelpers.RecipeHelpers();
            this.TmlPlayerHelpers          = new TmlHelpers.TmlPlayerHelpers();
            this.WorldHelpers              = new WorldHelpers.WorldHelpers();
            this.ControlPanel              = new UIControlPanel();
            this.ModLockHelpers            = new TmlHelpers.ModHelpers.ModLockHelpers();
            this.EntityGroups              = new EntityGroups();
            this.PlayerMessages            = new PlayerMessages();
            this.Inbox           = new InboxControl();
            this.ModVersionGet   = new ModVersionGet();
            this.ServerBrowser   = new ServerBrowserReporter();
            this.MenuItemMngr    = new MenuItemManager();
            this.MenuUIMngr      = new MenuUIManager();
            this.OldMenuItemMngr = new Utilities.Menu.OldMenuItemManager();
            this.MusicHelpers    = new MusicHelpers();

#pragma warning disable 612, 618
            TmlHelpers.AltNPCInfo.DataInitialize();
            TmlHelpers.AltProjectileInfo.DataInitialize();
#pragma warning restore 612, 618

            if (!this.Config.DisableControlPanelHotkey)
            {
                this.ControlPanelHotkey = this.RegisterHotKey("Mod Helpers Control Panel", "O");
            }

            this.LoadModData();
        }
        public static string GetGithubProjectName(Mod mod)
        {
            var self = HamstarHelpersMod.Instance.ModMetaDataManager;

            if (!self.GithubMods.ContainsKey(mod.Name))
            {
                return(null);
            }

            PropertyInfo git_proj_prop = ModMetaDataManager.GetGitubProjectNameProp(mod);

            return((string)git_proj_prop.GetValue(null));
        }
        public static void ResetDefaultsConfig(Mod mod)
        {
            var self = HamstarHelpersMod.Instance.ModMetaDataManager;

            if (!self.ConfigDefaultsResetMods.ContainsKey(mod.Name))
            {
                throw new Exception("Not a recognized config resetable mod.");
            }

            MethodInfo config_defaults_method = ModMetaDataManager.GetConfigDefaultsResetMethod(mod);

            config_defaults_method.Invoke(null, new object[] { });
        }
        /*public static void SetConfigRelativePath( Mod mod, string path ) {
         *      if( !ExtendedModManager.ConfigMods.ContainsKey( mod.Name ) ) {
         *              throw new Exception( "Not a recognized configurable mod." );
         *      }
         *
         *      FieldInfo config_path_field = mod.GetType().GetField( "ConfigFileRelativePath", BindingFlags.Static | BindingFlags.Public );
         *      config_path_field.SetValue( null, path );
         * }*/

        public static void ReloadConfigFromFile(Mod mod)
        {
            var self = HamstarHelpersMod.Instance.ModMetaDataManager;

            if (!self.ConfigMods.ContainsKey(mod.Name))
            {
                throw new Exception("Not a recognized configurable mod.");
            }

            MethodInfo config_reload_method = ModMetaDataManager.GetConfigFileLoadMethod(mod);

            config_reload_method.Invoke(null, new object[] { });
        }
        ////////////////

        public static string GetConfigRelativePath(Mod mod)
        {
            var self = HamstarHelpersMod.Instance.ModMetaDataManager;

            if (!self.ConfigMods.ContainsKey(mod.Name))
            {
                return(null);
            }

            PropertyInfo config_path_field = ModMetaDataManager.GetConfigFilePathProp(mod);

            return((string)config_path_field.GetValue(null));
        }
Exemple #9
0
        public override void Unload()
        {
            this.UnloadModData();

            this.Promises.FulfillModUnloadPromises();

            try {
                if (this.HasUnhandledExceptionLogger)
                {
                    this.HasUnhandledExceptionLogger            = false;
                    AppDomain.CurrentDomain.UnhandledException -= HamstarHelpersMod.UnhandledLogger;
                }
            } catch { }

            this.ExceptionMngr             = null;
            this.Timers                    = null;
            this.ConfigJson                = null;
            this.PacketProtocols           = null;
            this.LogHelpers                = null;
            this.ModMetaDataManager        = null;
            this.BuffHelpers               = null;
            this.NetHelpers                = null;
            this.ItemIdentityHelpers       = null;
            this.NPCIdentityHelpers        = null;
            this.ProjectileIdentityHelpers = null;
            this.BuffIdentityHelpers       = null;
            this.NPCBannerHelpers          = null;
            this.RecipeHelpers             = null;
            this.TmlPlayerHelpers          = null;
            this.LoadHelpers               = null;
            this.ModVersionGet             = null;
            this.WorldHelpers              = null;
            this.ModLockHelpers            = null;
            this.EntityGroups              = null;
            this.AnimatedColors            = null;
            this.PlayerMessages            = null;
            this.Inbox = null;
            this.ControlPanelHotkey = null;
            this.ControlPanel       = null;
            this.ServerBrowser      = null;
            this.MenuItemMngr       = null;
            this.MenuUIMngr         = null;
            this.OldMenuItemMngr    = null;
            this.MusicHelpers       = null;
            this.Promises           = null;

            HamstarHelpersMod.Instance = null;
        }
        ////////////////

        internal void OnPostSetupContent()
        {
            this.GithubMods = new Dictionary <string, Mod>();
            this.ConfigMods = new Dictionary <string, Mod>();
            this.ConfigDefaultsResetMods = new Dictionary <string, Mod>();

            foreach (Mod mod in ModLoader.LoadedMods)
            {
                if (ModMetaDataManager.DetectGithub(mod))
                {
                    this.GithubMods[mod.Name] = mod;
                }
                if (ModMetaDataManager.DetectConfig(mod))
                {
                    this.ConfigMods[mod.Name] = mod;
                }
                if (ModMetaDataManager.DetectConfigDefaultsReset(mod))
                {
                    this.ConfigDefaultsResetMods[mod.Name] = mod;
                }
            }
        }