コード例 #1
0
ファイル: BindsConfig.java プロジェクト: frankpunx/Terasology
 /**
  * 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)));
         }
       }
     }
   }
 }
コード例 #2
0
ファイル: BindsConfig.java プロジェクト: frankpunx/Terasology
 /**
  * @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;
 }
コード例 #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);
         }
       }
     }
   }
 }