use of org.terasology.engine.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.engine.config.BindsConfig in project Terasology by MovingBlocks.
the class InputSettingsScreen method onClosed.
@Override
public void onClosed() {
super.onClosed();
bindsManager.registerBinds();
// TODO: Find a better place to do this in.
BindsConfig bindsConf = bindsManager.getBindsConfig();
if (bindsConf != null) {
bindsConf.getBinds(new SimpleUri("engine:tabbingUI")).stream().findFirst().ifPresent(input -> {
TabbingManager.tabForwardInput = input;
});
bindsConf.getBinds(new SimpleUri("engine:tabbingModifier")).stream().findFirst().ifPresent(input -> {
TabbingManager.tabBackInputModifier = input;
});
bindsConf.getBinds(new SimpleUri("engine:activate")).stream().findFirst().ifPresent(input -> {
TabbingManager.activateInput = input;
});
}
}
use of org.terasology.engine.config.BindsConfig in project Terasology by MovingBlocks.
the class InputSettingsScreen method setPrimaryBind.
/**
* Binds button to key while ensuring visual feedback on the user interface
*
* @param key one constant from the {@link KeyId}s.
* @param bindId the uri for the binding, e.g. <code>engine:forwards</code>.
*/
private void setPrimaryBind(int key, SimpleUri bindId) {
final BindsConfig bindConfig = bindsManager.getBindsConfig();
new InputConfigBinding(bindConfig, bindId, PRIMARY_BIND_INDEX).set(InputType.KEY.getInput(key));
}
use of org.terasology.engine.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 = makeInputBindButton(uri, bind, binds, PRIMARY_BIND_INDEX);
UIButton secondaryInputBind = makeInputBindButton(uri, bind, binds, SECONDARY_BIND_INDEX);
layout.addWidget(new RowLayout(new UILabel(translationSystem.translate(bind.description())), primaryInputBind, secondaryInputBind).setColumnRatios(0.4f).setHorizontalSpacing(horizontalSpacing));
}
use of org.terasology.engine.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