use of org.terasology.config.BindsConfig in project Terasology by MovingBlocks.
the class BindsSubsystemTest method setUp.
@Before
public void setUp() {
bindsSubsystem = new BindsSubsystem();
bindsConfiguration = new BindsConfigAdapter(new BindsConfig());
context = new ContextImpl();
context.put(BindsConfiguration.class, bindsConfiguration);
bindsSubsystem.preInitialise(context);
setUpMockModuleEnvironment();
}
use of org.terasology.config.BindsConfig in project Terasology by MovingBlocks.
the class ChangeBindingPopup method setBindingData.
public void setBindingData(SimpleUri uri, RegisterBindButton bind, int index) {
find("title", UILabel.class).setText(translationSystem.translate(bind.description()));
BindsConfig bindConfig = bindsManager.getBindsConfig();
bindButton.bindInput(new InputConfigBinding(bindConfig, uri, index));
List<Input> defaults = defaultBinds.getBinds(uri);
find("default-binding", UILabel.class).setText(defaults.size() > index ? defaults.get(index).getDisplayName() : "<" + translationSystem.translate("${engine:menu#none}" + ">"));
find("default", UIButton.class).subscribe(e -> bindButton.setNewInput(defaults.size() > index ? defaults.get(index) : null));
}
use of org.terasology.config.BindsConfig in project Terasology by MovingBlocks.
the class InputSettingsScreen method addInputBindRow.
private void addInputBindRow(SimpleUri uri, RegisterBindButton bind, ColumnLayout layout) {
BindsConfig bindConfig = bindsManager.getBindsConfig();
List<Input> binds = bindConfig.getBinds(uri);
UIButton primaryInputBind = new UIButton();
primaryInputBind.bindText(new BindingText(binds, 0));
primaryInputBind.subscribe(event -> {
ChangeBindingPopup popup = getManager().pushScreen(ChangeBindingPopup.ASSET_URI, ChangeBindingPopup.class);
popup.setBindingData(uri, bind, 0);
});
UIButton secondaryInputBind = new UIButton();
secondaryInputBind.bindText(new BindingText(binds, 1));
secondaryInputBind.subscribe(event -> {
ChangeBindingPopup popup = getManager().pushScreen(ChangeBindingPopup.ASSET_URI, ChangeBindingPopup.class);
popup.setBindingData(uri, bind, 1);
});
layout.addWidget(new RowLayout(new UILabel(translationSystem.translate(bind.description())), primaryInputBind, secondaryInputBind).setColumnRatios(0.4f).setHorizontalSpacing(horizontalSpacing));
}
use of org.terasology.config.BindsConfig in project Terasology by MovingBlocks.
the class BindsSubsystem method getDefaultBindsConfig.
@Override
public BindsConfig getDefaultBindsConfig() {
BindsConfig copy = new BindsConfig();
// SimpleUri and Input are immutable, no need for a deep copy
copy.setBinds(defaultBindsConfig.getBindsConfig());
return copy;
}
Aggregations