use of com.simibubi.create.foundation.gui.widget.ScrollInput in project Create by Creators-of-Create.
the class WorldshaperScreen method initBrushParams.
protected void initBrushParams(int x, int y) {
Brush currentBrush = this.currentBrush.get();
// Brush Params
removeWidgets(brushParamLabels);
removeWidgets(brushParams);
brushParamLabels.clear();
brushParams.clear();
for (int index = 0; index < 3; index++) {
Label label = new Label(x + 65 + 20 * index, y + 45, TextComponent.EMPTY).withShadow();
final int finalIndex = index;
ScrollInput input = new ScrollInput(x + 56 + 20 * index, y + 40, 18, 18).withRange(currentBrush.getMin(index), currentBrush.getMax(index) + 1).writingTo(label).titled(currentBrush.getParamLabel(index).plainCopy()).calling(state -> {
currentBrushParams[finalIndex] = state;
label.x = x + 65 + 20 * finalIndex - font.width(label.text) / 2;
});
input.setState(currentBrushParams[index]);
input.onChanged();
if (index >= currentBrush.amtParams) {
input.visible = false;
label.visible = false;
input.active = false;
}
brushParamLabels.add(label);
brushParams.add(input);
}
addRenderableWidgets(brushParamLabels);
addRenderableWidgets(brushParams);
if (followDiagonals != null) {
removeWidget(followDiagonals);
removeWidget(followDiagonalsIndicator);
removeWidget(acrossMaterials);
removeWidget(acrossMaterialsIndicator);
followDiagonals = null;
followDiagonalsIndicator = null;
acrossMaterials = null;
acrossMaterialsIndicator = null;
}
if (currentBrush.hasConnectivityOptions()) {
int x1 = x + 7 + 4 * 18;
int y1 = y + 79;
followDiagonalsIndicator = new Indicator(x1, y1 - 6, TextComponent.EMPTY);
followDiagonals = new IconButton(x1, y1, AllIcons.I_FOLLOW_DIAGONAL);
x1 += 18;
acrossMaterialsIndicator = new Indicator(x1, y1 - 6, TextComponent.EMPTY);
acrossMaterials = new IconButton(x1, y1, AllIcons.I_FOLLOW_MATERIAL);
followDiagonals.withCallback(() -> {
followDiagonalsIndicator.state = followDiagonalsIndicator.state == State.OFF ? State.ON : State.OFF;
currentFollowDiagonals = !currentFollowDiagonals;
});
followDiagonals.setToolTip(Lang.translate("gui.terrainzapper.searchDiagonal"));
acrossMaterials.withCallback(() -> {
acrossMaterialsIndicator.state = acrossMaterialsIndicator.state == State.OFF ? State.ON : State.OFF;
currentAcrossMaterials = !currentAcrossMaterials;
});
acrossMaterials.setToolTip(Lang.translate("gui.terrainzapper.searchFuzzy"));
addRenderableWidget(followDiagonals);
addRenderableWidget(followDiagonalsIndicator);
addRenderableWidget(acrossMaterials);
addRenderableWidget(acrossMaterialsIndicator);
if (currentFollowDiagonals)
followDiagonalsIndicator.state = State.ON;
if (currentAcrossMaterials)
acrossMaterialsIndicator.state = State.ON;
}
if (toolButtons != null)
removeWidgets(toolButtons);
TerrainTools[] toolValues = currentBrush.getSupportedTools();
toolButtons = new Vector<>(toolValues.length);
for (int id = 0; id < toolValues.length; id++) {
TerrainTools tool = toolValues[id];
IconButton toolButton = new IconButton(x + 7 + id * 18, y + 79, tool.icon);
toolButton.withCallback(() -> {
toolButtons.forEach(b -> b.active = true);
toolButton.active = false;
currentTool = tool;
});
toolButton.setToolTip(Lang.translate("gui.terrainzapper.tool." + tool.translationKey));
toolButtons.add(toolButton);
}
int toolIndex = -1;
for (int i = 0; i < toolValues.length; i++) if (currentTool == toolValues[i])
toolIndex = i;
if (toolIndex == -1) {
currentTool = toolValues[0];
toolIndex = 0;
}
toolButtons.get(toolIndex).active = false;
addRenderableWidgets(toolButtons);
if (placementButtons != null)
removeWidgets(placementButtons);
if (currentBrush.hasPlacementOptions()) {
PlacementOptions[] placementValues = PlacementOptions.values();
placementButtons = new Vector<>(placementValues.length);
for (int id = 0; id < placementValues.length; id++) {
PlacementOptions option = placementValues[id];
IconButton placementButton = new IconButton(x + 136 + id * 18, y + 79, option.icon);
placementButton.withCallback(() -> {
placementButtons.forEach(b -> b.active = true);
placementButton.active = false;
currentPlacement = option;
});
placementButton.setToolTip(Lang.translate("gui.terrainzapper.placement." + option.translationKey));
placementButtons.add(placementButton);
}
placementButtons.get(currentPlacement.ordinal()).active = false;
addRenderableWidgets(placementButtons);
}
}
use of com.simibubi.create.foundation.gui.widget.ScrollInput in project Create by Creators-of-Create.
the class StockpileSwitchScreen method init.
@Override
protected void init() {
setWindowSize(background.width, background.height);
setWindowOffset(-20, 0);
super.init();
int x = guiLeft;
int y = guiTop;
cursor = LerpedFloat.linear().startWithValue(te.getLevelForDisplay());
cursorLane = LerpedFloat.linear().startWithValue(te.getState() ? 1 : 0);
offBelow = new ScrollInput(x + 36, y + 40, 102, 18).withRange(0, 100).titled(TextComponent.EMPTY.plainCopy()).calling(state -> {
lastModification = 0;
offBelow.titled(Lang.translate("gui.stockpile_switch.move_to_upper_at", state));
if (onAbove.getState() <= state) {
onAbove.setState(state + 1);
onAbove.onChanged();
}
}).setState((int) (te.offWhenBelow * 100));
onAbove = new ScrollInput(x + 36, y + 18, 102, 18).withRange(1, 101).titled(TextComponent.EMPTY.plainCopy()).calling(state -> {
lastModification = 0;
onAbove.titled(Lang.translate("gui.stockpile_switch.move_to_lower_at", state));
if (offBelow.getState() >= state) {
offBelow.setState(state - 1);
offBelow.onChanged();
}
}).setState((int) (te.onWhenAbove * 100));
onAbove.onChanged();
offBelow.onChanged();
addRenderableWidget(onAbove);
addRenderableWidget(offBelow);
confirmButton = new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM);
confirmButton.withCallback(() -> {
onClose();
});
addRenderableWidget(confirmButton);
flipSignals = new IconButton(x + 14, y + 40, AllIcons.I_FLIP);
flipSignals.withCallback(() -> {
send(!te.isInverted());
});
flipSignals.setToolTip(invertSignal);
addRenderableWidget(flipSignals);
}
use of com.simibubi.create.foundation.gui.widget.ScrollInput in project Create by Creators-of-Create.
the class SequencedGearshiftScreen method updateParamsOfRow.
public void updateParamsOfRow(int row) {
Instruction instruction = instructions.get(row);
Vector<ScrollInput> rowInputs = inputs.get(row);
SequencerInstructions def = instruction.instruction;
boolean hasValue = def.hasValueParameter;
boolean hasModifier = def.hasSpeedParameter;
ScrollInput value = rowInputs.get(1);
value.active = value.visible = hasValue;
if (hasValue)
value.withRange(1, def.maxValue + 1).titled(Lang.translate(def.parameterKey)).withShiftStep(def.shiftStep).setState(instruction.value).onChanged();
if (def == SequencerInstructions.DELAY) {
value.withStepFunction(context -> {
int v = context.currentValue;
if (!context.forward)
v--;
if (v < 20)
return context.shift ? 20 : 1;
return context.shift ? 100 : 20;
});
} else
value.withStepFunction(value.standardStep());
ScrollInput modifier = rowInputs.get(2);
modifier.active = modifier.visible = hasModifier;
if (hasModifier)
modifier.setState(instruction.speedModifier.ordinal());
}
use of com.simibubi.create.foundation.gui.widget.ScrollInput in project Create by Creators-of-Create.
the class SequencedGearshiftScreen method initInputsOfRow.
public void initInputsOfRow(int row, int backgroundX, int backgroundY) {
int x = backgroundX + 30;
int y = backgroundY + 18;
int rowHeight = 22;
Vector<ScrollInput> rowInputs = inputs.get(row);
removeWidgets(rowInputs);
rowInputs.clear();
int index = row;
Instruction instruction = instructions.get(row);
ScrollInput type = new SelectionScrollInput(x, y + rowHeight * row, 50, 18).forOptions(SequencerInstructions.getOptions()).calling(state -> instructionUpdated(index, state)).setState(instruction.instruction.ordinal()).titled(Lang.translate("gui.sequenced_gearshift.instruction"));
ScrollInput value = new ScrollInput(x + 58, y + rowHeight * row, 28, 18).calling(state -> instruction.value = state);
ScrollInput direction = new SelectionScrollInput(x + 88, y + rowHeight * row, 28, 18).forOptions(InstructionSpeedModifiers.getOptions()).calling(state -> instruction.speedModifier = InstructionSpeedModifiers.values()[state]).titled(Lang.translate("gui.sequenced_gearshift.speed"));
rowInputs.add(type);
rowInputs.add(value);
rowInputs.add(direction);
addRenderableWidgets(rowInputs);
updateParamsOfRow(row);
}
Aggregations