use of com.simibubi.create.foundation.gui.widget.IconButton in project Create by Creators-of-Create.
the class BlueprintScreen method init.
@Override
protected void init() {
setWindowSize(background.width, background.height + 4 + PLAYER_INVENTORY.height);
setWindowOffset(1, 0);
super.init();
int x = leftPos;
int y = topPos;
resetButton = new IconButton(x + background.width - 62, y + background.height - 24, AllIcons.I_TRASH);
resetButton.withCallback(() -> {
menu.clearContents();
contentsCleared();
menu.sendClearPacket();
});
confirmButton = new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM);
confirmButton.withCallback(() -> {
minecraft.player.closeContainer();
});
addRenderableWidget(resetButton);
addRenderableWidget(confirmButton);
extraAreas = ImmutableList.of(new Rect2i(x + background.width, y + background.height - 36, 56, 44));
}
use of com.simibubi.create.foundation.gui.widget.IconButton 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.IconButton 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.IconButton in project Create by Creators-of-Create.
the class LinkedControllerScreen method init.
@Override
protected void init() {
setWindowSize(background.width, background.height + 4 + PLAYER_INVENTORY.height);
setWindowOffset(1, 0);
super.init();
int x = leftPos;
int y = topPos;
resetButton = new IconButton(x + background.width - 62, y + background.height - 24, AllIcons.I_TRASH);
resetButton.withCallback(() -> {
menu.clearContents();
menu.sendClearPacket();
});
confirmButton = new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM);
confirmButton.withCallback(() -> {
minecraft.player.closeContainer();
});
addRenderableWidget(resetButton);
addRenderableWidget(confirmButton);
extraAreas = ImmutableList.of(new Rect2i(x + background.width + 4, y + background.height - 44, 64, 56));
}
use of com.simibubi.create.foundation.gui.widget.IconButton in project Create by Creators-of-Create.
the class AbstractFilterScreen method init.
@Override
protected void init() {
setWindowSize(Math.max(background.width, PLAYER_INVENTORY.width), background.height + 4 + PLAYER_INVENTORY.height);
super.init();
int x = leftPos;
int y = topPos;
resetButton = new IconButton(x + background.width - 62, y + background.height - 24, AllIcons.I_TRASH);
resetButton.withCallback(() -> {
menu.clearContents();
contentsCleared();
menu.sendClearPacket();
});
confirmButton = new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM);
confirmButton.withCallback(() -> {
minecraft.player.closeContainer();
});
addRenderableWidget(resetButton);
addRenderableWidget(confirmButton);
extraAreas = ImmutableList.of(new Rect2i(x + background.width, y + background.height - 40, 80, 48));
}
Aggregations