Example #1
0
 /**
  * Updates a config with any binds that it may be missing, through reflection over
  * RegisterBindButton annotations
  */
 public void updateForChangedMods(Context context) {
   ModuleManager moduleManager = context.get(ModuleManager.class);
   DependencyResolver resolver = new DependencyResolver(moduleManager.getRegistry());
   for (Name moduleId : moduleManager.getRegistry().getModuleIds()) {
     if (moduleManager.getRegistry().getLatestModuleVersion(moduleId).isCodeModule()) {
       ResolutionResult result = resolver.resolve(moduleId);
       if (result.isSuccess()) {
         try (ModuleEnvironment environment =
             moduleManager.loadEnvironment(result.getModules(), false)) {
           updateInputsFor(
               moduleId,
               environment.getTypesAnnotatedWith(
                   RegisterBindButton.class, new FromModule(environment, moduleId)));
         }
       }
     }
   }
 }
Example #2
0
 /**
  * @return A new BindsConfig, with inputs set from the DefaultBinding annotations on bind classes
  */
 public static BindsConfig createDefault(Context context) {
   ModuleManager moduleManager = context.get(ModuleManager.class);
   BindsConfig config = new BindsConfig();
   DependencyResolver resolver = new DependencyResolver(moduleManager.getRegistry());
   for (Name moduleId : moduleManager.getRegistry().getModuleIds()) {
     if (moduleManager.getRegistry().getLatestModuleVersion(moduleId).isCodeModule()) {
       ResolutionResult result = resolver.resolve(moduleId);
       if (result.isSuccess()) {
         try (ModuleEnvironment environment =
             moduleManager.loadEnvironment(result.getModules(), false)) {
           config.addDefaultsFor(
               moduleId,
               environment.getTypesAnnotatedWith(
                   RegisterBindButton.class, new FromModule(environment, moduleId)));
         }
       }
     }
   }
   return config;
 }
Example #3
0
 /**
  * Updates a config with any binds that it may be missing, through reflection over
  * RegisterBindButton annotations
  */
 public void updateForChangedMods(Context context) {
   ModuleManager moduleManager = context.get(ModuleManager.class);
   DependencyResolver resolver = new DependencyResolver(moduleManager.getRegistry());
   for (Name moduleId : moduleManager.getRegistry().getModuleIds()) {
     if (moduleManager.getRegistry().getLatestModuleVersion(moduleId).isCodeModule()) {
       ResolutionResult result = resolver.resolve(moduleId);
       if (result.isSuccess()) {
         try (ModuleEnvironment environment =
             moduleManager.loadEnvironment(result.getModules(), false)) {
           FromModule filter = new FromModule(environment, moduleId);
           Iterable<Class<?>> buttons =
               environment.getTypesAnnotatedWith(RegisterBindButton.class, filter);
           Iterable<Class<?>> axes =
               environment.getTypesAnnotatedWith(RegisterRealBindAxis.class, filter);
           updateButtonInputsFor(moduleId, buttons);
           updateAxisInputsFor(moduleId, axes);
         }
       }
     }
   }
 }