Search in sources :

Example 1 with Label

use of com.simibubi.create.foundation.gui.widget.Label 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);
    }
}
Also used : SelectionScrollInput(com.simibubi.create.foundation.gui.widget.SelectionScrollInput) ScrollInput(com.simibubi.create.foundation.gui.widget.ScrollInput) IconButton(com.simibubi.create.foundation.gui.widget.IconButton) Label(com.simibubi.create.foundation.gui.widget.Label) Indicator(com.simibubi.create.foundation.gui.widget.Indicator)

Example 2 with Label

use of com.simibubi.create.foundation.gui.widget.Label in project Create by Creators-of-Create.

the class AttributeFilterScreen method init.

@Override
protected void init() {
    setWindowOffset(-11, 7);
    super.init();
    int x = leftPos;
    int y = topPos;
    whitelistDis = new IconButton(x + 47, y + 59, AllIcons.I_WHITELIST_OR);
    whitelistDis.withCallback(() -> {
        menu.whitelistMode = WhitelistMode.WHITELIST_DISJ;
        sendOptionUpdate(Option.WHITELIST);
    });
    whitelistDis.setToolTip(allowDisN);
    whitelistCon = new IconButton(x + 65, y + 59, AllIcons.I_WHITELIST_AND);
    whitelistCon.withCallback(() -> {
        menu.whitelistMode = WhitelistMode.WHITELIST_CONJ;
        sendOptionUpdate(Option.WHITELIST2);
    });
    whitelistCon.setToolTip(allowConN);
    blacklist = new IconButton(x + 83, y + 59, AllIcons.I_WHITELIST_NOT);
    blacklist.withCallback(() -> {
        menu.whitelistMode = WhitelistMode.BLACKLIST;
        sendOptionUpdate(Option.BLACKLIST);
    });
    blacklist.setToolTip(denyN);
    whitelistDisIndicator = new Indicator(x + 47, y + 53, TextComponent.EMPTY);
    whitelistConIndicator = new Indicator(x + 65, y + 53, TextComponent.EMPTY);
    blacklistIndicator = new Indicator(x + 83, y + 53, TextComponent.EMPTY);
    addRenderableWidgets(blacklist, whitelistCon, whitelistDis, blacklistIndicator, whitelistConIndicator, whitelistDisIndicator);
    addRenderableWidget(add = new IconButton(x + 182, y + 21, AllIcons.I_ADD));
    addRenderableWidget(addInverted = new IconButton(x + 200, y + 21, AllIcons.I_ADD_INVERTED_ATTRIBUTE));
    add.withCallback(() -> {
        handleAddedAttibute(false);
    });
    add.setToolTip(addDESC);
    addInverted.withCallback(() -> {
        handleAddedAttibute(true);
    });
    addInverted.setToolTip(addInvertedDESC);
    handleIndicators();
    attributeSelectorLabel = new Label(x + 43, y + 26, TextComponent.EMPTY).colored(0xF3EBDE).withShadow();
    attributeSelector = new SelectionScrollInput(x + 39, y + 21, 137, 18);
    attributeSelector.forOptions(Arrays.asList(TextComponent.EMPTY));
    attributeSelector.removeCallback();
    referenceItemChanged(menu.ghostInventory.getStackInSlot(0));
    addRenderableWidget(attributeSelector);
    addRenderableWidget(attributeSelectorLabel);
    selectedAttributes.clear();
    selectedAttributes.add((menu.selectedAttributes.isEmpty() ? noSelectedT : selectedT).plainCopy().withStyle(ChatFormatting.YELLOW));
    menu.selectedAttributes.forEach(at -> selectedAttributes.add(new TextComponent("- ").append(at.getFirst().format(at.getSecond())).withStyle(ChatFormatting.GRAY)));
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) IconButton(com.simibubi.create.foundation.gui.widget.IconButton) Label(com.simibubi.create.foundation.gui.widget.Label) Indicator(com.simibubi.create.foundation.gui.widget.Indicator) SelectionScrollInput(com.simibubi.create.foundation.gui.widget.SelectionScrollInput)

Example 3 with Label

use of com.simibubi.create.foundation.gui.widget.Label in project Create by Creators-of-Create.

the class SymmetryWandScreen method init.

@Override
public void init() {
    setWindowSize(background.width, background.height);
    setWindowOffset(-20, 0);
    super.init();
    int x = guiLeft;
    int y = guiTop;
    labelType = new Label(x + 49, y + 28, TextComponent.EMPTY).colored(0xFFFFFFFF).withShadow();
    labelAlign = new Label(x + 49, y + 50, TextComponent.EMPTY).colored(0xFFFFFFFF).withShadow();
    int state = currentElement instanceof TriplePlaneMirror ? 2 : currentElement instanceof CrossPlaneMirror ? 1 : 0;
    areaType = new SelectionScrollInput(x + 45, y + 21, 109, 18).forOptions(SymmetryMirror.getMirrors()).titled(mirrorType.plainCopy()).writingTo(labelType).setState(state);
    areaType.calling(position -> {
        switch(position) {
            case 0:
                currentElement = new PlaneMirror(currentElement.getPosition());
                break;
            case 1:
                currentElement = new CrossPlaneMirror(currentElement.getPosition());
                break;
            case 2:
                currentElement = new TriplePlaneMirror(currentElement.getPosition());
                break;
            default:
                break;
        }
        initAlign(currentElement, x, y);
    });
    initAlign(currentElement, x, y);
    addRenderableWidget(labelAlign);
    addRenderableWidget(areaType);
    addRenderableWidget(labelType);
    confirmButton = new IconButton(x + background.width - 33, y + background.height - 24, AllIcons.I_CONFIRM);
    confirmButton.withCallback(() -> {
        onClose();
    });
    addRenderableWidget(confirmButton);
}
Also used : TriplePlaneMirror(com.simibubi.create.content.curiosities.symmetry.mirror.TriplePlaneMirror) CrossPlaneMirror(com.simibubi.create.content.curiosities.symmetry.mirror.CrossPlaneMirror) PlaneMirror(com.simibubi.create.content.curiosities.symmetry.mirror.PlaneMirror) IconButton(com.simibubi.create.foundation.gui.widget.IconButton) Label(com.simibubi.create.foundation.gui.widget.Label) CrossPlaneMirror(com.simibubi.create.content.curiosities.symmetry.mirror.CrossPlaneMirror) TriplePlaneMirror(com.simibubi.create.content.curiosities.symmetry.mirror.TriplePlaneMirror) SelectionScrollInput(com.simibubi.create.foundation.gui.widget.SelectionScrollInput)

Example 4 with Label

use of com.simibubi.create.foundation.gui.widget.Label in project Create by Creators-of-Create.

the class SchematicTableScreen method init.

@Override
protected void init() {
    setWindowSize(background.width, background.height + 4 + AllGuiTextures.PLAYER_INVENTORY.height);
    setWindowOffset(-11, 8);
    super.init();
    CreateClient.SCHEMATIC_SENDER.refresh();
    List<Component> availableSchematics = CreateClient.SCHEMATIC_SENDER.getAvailableSchematics();
    int x = leftPos;
    int y = topPos;
    schematicsLabel = new Label(x + 49, y + 26, TextComponent.EMPTY).withShadow();
    schematicsLabel.text = TextComponent.EMPTY;
    if (!availableSchematics.isEmpty()) {
        schematicsArea = new SelectionScrollInput(x + 45, y + 21, 139, 18).forOptions(availableSchematics).titled(availableSchematicsTitle.plainCopy()).writingTo(schematicsLabel);
        addRenderableWidget(schematicsArea);
        addRenderableWidget(schematicsLabel);
    }
    confirmButton = new IconButton(x + 44, y + 56, AllIcons.I_CONFIRM);
    confirmButton.withCallback(() -> {
        if (menu.canWrite() && schematicsArea != null) {
            ClientSchematicLoader schematicSender = CreateClient.SCHEMATIC_SENDER;
            lastChasingProgress = chasingProgress = progress = 0;
            List<Component> availableSchematics1 = schematicSender.getAvailableSchematics();
            Component schematic = availableSchematics1.get(schematicsArea.getState());
            schematicSender.startNewUpload(schematic.getContents());
        }
    });
    folderButton = new IconButton(x + 21, y + 21, AllIcons.I_OPEN_FOLDER);
    folderButton.withCallback(() -> {
        Util.getPlatform().openFile(Paths.get("schematics/").toFile());
    });
    folderButton.setToolTip(folder);
    refreshButton = new IconButton(x + 207, y + 21, AllIcons.I_REFRESH);
    refreshButton.withCallback(() -> {
        ClientSchematicLoader schematicSender = CreateClient.SCHEMATIC_SENDER;
        schematicSender.refresh();
        List<Component> availableSchematics1 = schematicSender.getAvailableSchematics();
        removeWidget(schematicsArea);
        if (!availableSchematics1.isEmpty()) {
            schematicsArea = new SelectionScrollInput(leftPos + 45, topPos + 21, 139, 18).forOptions(availableSchematics1).titled(availableSchematicsTitle.plainCopy()).writingTo(schematicsLabel);
            schematicsArea.onChanged();
            addRenderableWidget(schematicsArea);
        } else {
            schematicsArea = null;
            schematicsLabel.text = TextComponent.EMPTY;
        }
    });
    refreshButton.setToolTip(refresh);
    addRenderableWidget(confirmButton);
    addRenderableWidget(folderButton);
    addRenderableWidget(refreshButton);
    extraAreas = ImmutableList.of(new Rect2i(x + background.width, y + background.height - 40, 48, 48), new Rect2i(refreshButton.x, refreshButton.y, refreshButton.getWidth(), refreshButton.getHeight()));
}
Also used : Rect2i(net.minecraft.client.renderer.Rect2i) IconButton(com.simibubi.create.foundation.gui.widget.IconButton) ClientSchematicLoader(com.simibubi.create.content.schematics.ClientSchematicLoader) Label(com.simibubi.create.foundation.gui.widget.Label) Component(net.minecraft.network.chat.Component) TextComponent(net.minecraft.network.chat.TextComponent) SelectionScrollInput(com.simibubi.create.foundation.gui.widget.SelectionScrollInput)

Example 5 with Label

use of com.simibubi.create.foundation.gui.widget.Label in project Create by Creators-of-Create.

the class WorldshaperScreen method init.

@Override
protected void init() {
    super.init();
    int x = guiLeft;
    int y = guiTop;
    brushLabel = new Label(x + 61, y + 25, TextComponent.EMPTY).withShadow();
    brushInput = new SelectionScrollInput(x + 56, y + 20, 77, 18).forOptions(brushOptions).titled(Lang.translate("gui.terrainzapper.brush")).writingTo(brushLabel).calling(brushIndex -> {
        currentBrush = TerrainBrushes.values()[brushIndex];
        initBrushParams(x, y);
    });
    brushInput.setState(currentBrush.ordinal());
    addRenderableWidget(brushLabel);
    addRenderableWidget(brushInput);
    initBrushParams(x, y);
}
Also used : SelectionScrollInput(com.simibubi.create.foundation.gui.widget.SelectionScrollInput) NbtUtils(net.minecraft.nbt.NbtUtils) Tag(net.minecraft.nbt.Tag) Component(net.minecraft.network.chat.Component) Label(com.simibubi.create.foundation.gui.widget.Label) IconButton(com.simibubi.create.foundation.gui.widget.IconButton) AllIcons(com.simibubi.create.foundation.gui.AllIcons) State(com.simibubi.create.foundation.gui.widget.Indicator.State) AllGuiTextures(com.simibubi.create.foundation.gui.AllGuiTextures) PoseStack(com.mojang.blaze3d.vertex.PoseStack) ConfigureZapperPacket(com.simibubi.create.content.curiosities.zapper.ConfigureZapperPacket) List(java.util.List) TextComponent(net.minecraft.network.chat.TextComponent) Vector(java.util.Vector) CompoundTag(net.minecraft.nbt.CompoundTag) BlockPos(net.minecraft.core.BlockPos) NBTHelper(com.simibubi.create.foundation.utility.NBTHelper) Lang(com.simibubi.create.foundation.utility.Lang) InteractionHand(net.minecraft.world.InteractionHand) ItemStack(net.minecraft.world.item.ItemStack) ZapperScreen(com.simibubi.create.content.curiosities.zapper.ZapperScreen) Indicator(com.simibubi.create.foundation.gui.widget.Indicator) ScrollInput(com.simibubi.create.foundation.gui.widget.ScrollInput) Label(com.simibubi.create.foundation.gui.widget.Label) SelectionScrollInput(com.simibubi.create.foundation.gui.widget.SelectionScrollInput)

Aggregations

IconButton (com.simibubi.create.foundation.gui.widget.IconButton)6 Label (com.simibubi.create.foundation.gui.widget.Label)6 SelectionScrollInput (com.simibubi.create.foundation.gui.widget.SelectionScrollInput)6 Indicator (com.simibubi.create.foundation.gui.widget.Indicator)3 TextComponent (net.minecraft.network.chat.TextComponent)3 ScrollInput (com.simibubi.create.foundation.gui.widget.ScrollInput)2 BlockPos (net.minecraft.core.BlockPos)2 Component (net.minecraft.network.chat.Component)2 PoseStack (com.mojang.blaze3d.vertex.PoseStack)1 CrossPlaneMirror (com.simibubi.create.content.curiosities.symmetry.mirror.CrossPlaneMirror)1 PlaneMirror (com.simibubi.create.content.curiosities.symmetry.mirror.PlaneMirror)1 TriplePlaneMirror (com.simibubi.create.content.curiosities.symmetry.mirror.TriplePlaneMirror)1 ConfigureZapperPacket (com.simibubi.create.content.curiosities.zapper.ConfigureZapperPacket)1 ZapperScreen (com.simibubi.create.content.curiosities.zapper.ZapperScreen)1 ClientSchematicLoader (com.simibubi.create.content.schematics.ClientSchematicLoader)1 AllGuiTextures (com.simibubi.create.foundation.gui.AllGuiTextures)1 AllIcons (com.simibubi.create.foundation.gui.AllIcons)1 State (com.simibubi.create.foundation.gui.widget.Indicator.State)1 Lang (com.simibubi.create.foundation.utility.Lang)1 NBTHelper (com.simibubi.create.foundation.utility.NBTHelper)1