Search in sources :

Example 1 with BindsConfig

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();
}
Also used : BindsConfigAdapter(org.terasology.engine.subsystem.config.BindsSubsystem.BindsConfigAdapter) BindsConfig(org.terasology.config.BindsConfig) ContextImpl(org.terasology.context.internal.ContextImpl) Before(org.junit.Before)

Example 2 with BindsConfig

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

Example 3 with BindsConfig

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

Example 4 with BindsConfig

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

Aggregations

BindsConfig (org.terasology.config.BindsConfig)4 Input (org.terasology.input.Input)2 UIButton (org.terasology.rendering.nui.widgets.UIButton)2 UILabel (org.terasology.rendering.nui.widgets.UILabel)2 Before (org.junit.Before)1 ContextImpl (org.terasology.context.internal.ContextImpl)1 BindsConfigAdapter (org.terasology.engine.subsystem.config.BindsSubsystem.BindsConfigAdapter)1 RowLayout (org.terasology.rendering.nui.layouts.RowLayout)1