コード例 #1
0
 @Override
 public void set(Input value) {
   List<Input> binds = Lists.newArrayList(config.getBinds(bindUri));
   if (value == null) {
     if (position < binds.size()) {
       binds.remove(position);
     }
   } else {
     if (position < binds.size()) {
       binds.set(position, value);
     } else {
       binds.add(value);
     }
   }
   config.setBinds(bindUri, binds);
 }
コード例 #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
 @Override
 public Input get() {
   return Iterators.get(config.getBinds(bindUri).iterator(), position, null);
 }