Search in sources :

Example 1 with BindsConfig

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));
}
Also used : UILabel(org.terasology.nui.widgets.UILabel) Input(org.terasology.input.Input) UIButton(org.terasology.nui.widgets.UIButton) BindsConfig(org.terasology.engine.config.BindsConfig)

Example 2 with BindsConfig

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;
        });
    }
}
Also used : SimpleUri(org.terasology.engine.core.SimpleUri) BindsConfig(org.terasology.engine.config.BindsConfig)

Example 3 with BindsConfig

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));
}
Also used : BindsConfig(org.terasology.engine.config.BindsConfig)

Example 4 with BindsConfig

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));
}
Also used : UILabel(org.terasology.nui.widgets.UILabel) Input(org.terasology.input.Input) UIButton(org.terasology.nui.widgets.UIButton) RowLayout(org.terasology.nui.layouts.RowLayout) BindsConfig(org.terasology.engine.config.BindsConfig)

Example 5 with BindsConfig

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;
}
Also used : BindsConfig(org.terasology.engine.config.BindsConfig)

Aggregations

BindsConfig (org.terasology.engine.config.BindsConfig)6 Input (org.terasology.input.Input)2 UIButton (org.terasology.nui.widgets.UIButton)2 UILabel (org.terasology.nui.widgets.UILabel)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1 ContextImpl (org.terasology.engine.context.internal.ContextImpl)1 SimpleUri (org.terasology.engine.core.SimpleUri)1 BindsConfigAdapter (org.terasology.engine.core.subsystem.config.BindsSubsystem.BindsConfigAdapter)1 RowLayout (org.terasology.nui.layouts.RowLayout)1