コード例 #1
0
 public static bool DetectConfigDefaultsReset(Mod mod)
 {
     if (ModFeaturesHelpers.GetConfigDefaultsResetMethod(mod) == null)
     {
         return(false);
     }
     return(true);
 }
コード例 #2
0
 public static bool DetectConfig(Mod mod)
 {
     if (ModFeaturesHelpers.GetConfigFilePathProp(mod) == null)
     {
         return(false);
     }
     if (ModFeaturesHelpers.GetConfigFileLoadMethod(mod) == null)
     {
         return(false);
     }
     return(true);
 }
コード例 #3
0
        ////////////////

        public static bool DetectGithub(Mod mod)
        {
            if (ModFeaturesHelpers.GetGithubUserNameProp(mod) == null)
            {
                return(false);
            }
            if (ModFeaturesHelpers.GetGitubProjectNameProp(mod) == null)
            {
                return(false);
            }
            return(true);
        }
コード例 #4
0
        ////////////////

        public static string GetConfigRelativePath(Mod mod)
        {
            var self = ModHelpersMod.Instance.ModFeaturesHelpers;

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

            PropertyInfo configPathField = ModFeaturesHelpers.GetConfigFilePathProp(mod);

            return((string)configPathField.GetValue(null));
        }
コード例 #5
0
        public static string GetGithubProjectName(Mod mod)
        {
            var self = ModHelpersMod.Instance.ModFeaturesHelpers;

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

            PropertyInfo gitProjProp = ModFeaturesHelpers.GetGitubProjectNameProp(mod);

            return((string)gitProjProp.GetValue(null));
        }
コード例 #6
0
        public static void ResetDefaultsConfig(Mod mod)
        {
            var self = ModHelpersMod.Instance.ModFeaturesHelpers;

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

            MethodInfo configDefaultsMethod = ModFeaturesHelpers.GetConfigDefaultsResetMethod(mod);

            configDefaultsMethod.Invoke(null, new object[] { });
        }
コード例 #7
0
        /*public static void SetConfigRelativePath( Mod mod, string path ) {
         *      if( !ExtendedModManager.ConfigMods.ContainsKey( mod.Name ) ) {
         *              throw new HamstarException( "Not a recognized configurable mod." );
         *      }
         *
         *      FieldInfo configPathField = mod.GetType().GetField( "ConfigFileRelativePath", BindingFlags.Static | BindingFlags.Public );
         *      configPathField.SetValue( null, path );
         * }*/

        public static void ReloadConfigFromFile(Mod mod)
        {
            var self = ModHelpersMod.Instance.ModFeaturesHelpers;

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

            MethodInfo configReloadMethod = ModFeaturesHelpers.GetConfigFileLoadMethod(mod);

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

        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 (ModFeaturesHelpers.DetectGithub(mod))
                {
                    this.GithubMods[mod.Name] = mod;
                }
                if (ModFeaturesHelpers.DetectConfig(mod))
                {
                    this.ConfigMods[mod.Name] = mod;
                }
                if (ModFeaturesHelpers.DetectConfigDefaultsReset(mod))
                {
                    this.ConfigDefaultsResetMods[mod.Name] = mod;
                }
            }
        }