Search in sources :

Example 6 with IconButton

use of com.simibubi.create.foundation.gui.widget.IconButton 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 7 with IconButton

use of com.simibubi.create.foundation.gui.widget.IconButton 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 8 with IconButton

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

the class ToolboxScreen method init.

@Override
protected void init() {
    setWindowSize(30 + BG.width, BG.height + PLAYER.height - 24);
    setWindowOffset(-11, 0);
    super.init();
    color = menu.contentHolder.getColor();
    confirmButton = new IconButton(leftPos + 30 + BG.width - 33, topPos + BG.height - 24, AllIcons.I_CONFIRM);
    confirmButton.withCallback(() -> {
        minecraft.player.closeContainer();
    });
    addRenderableWidget(confirmButton);
    disposeButton = new IconButton(leftPos + 30 + 81, topPos + 69, AllIcons.I_TOOLBOX);
    disposeButton.withCallback(() -> {
        AllPackets.channel.sendToServer(new ToolboxDisposeAllPacket(menu.contentHolder.getBlockPos()));
    });
    disposeButton.setToolTip(Lang.translate("toolbox.depositBox"));
    addRenderableWidget(disposeButton);
    extraAreas = ImmutableList.of(new Rect2i(leftPos + 30 + BG.width, topPos + BG.height - 15 - 34 - 6, 72, 68));
}
Also used : Rect2i(net.minecraft.client.renderer.Rect2i) IconButton(com.simibubi.create.foundation.gui.widget.IconButton)

Example 9 with IconButton

use of com.simibubi.create.foundation.gui.widget.IconButton 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 10 with IconButton

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

the class SchematicannonScreen method initPlacementSettings.

private void initPlacementSettings() {
    removeWidgets(placementSettingWidgets);
    placementSettingWidgets.clear();
    if (placementSettingsHidden())
        return;
    int x = leftPos;
    int y = topPos;
    // Replace settings
    replaceLevelButtons = new Vector<>(4);
    replaceLevelIndicators = new Vector<>(4);
    List<AllIcons> icons = ImmutableList.of(AllIcons.I_DONT_REPLACE, AllIcons.I_REPLACE_SOLID, AllIcons.I_REPLACE_ANY, AllIcons.I_REPLACE_EMPTY);
    List<Component> toolTips = ImmutableList.of(Lang.translate("gui.schematicannon.option.dontReplaceSolid"), Lang.translate("gui.schematicannon.option.replaceWithSolid"), Lang.translate("gui.schematicannon.option.replaceWithAny"), Lang.translate("gui.schematicannon.option.replaceWithEmpty"));
    for (int i = 0; i < 4; i++) {
        replaceLevelIndicators.add(new Indicator(x + 33 + i * 18, y + 111, TextComponent.EMPTY));
        IconButton replaceLevelButton = new IconButton(x + 33 + i * 18, y + 117, icons.get(i));
        int replaceMode = i;
        replaceLevelButton.withCallback(() -> {
            if (menu.contentHolder.replaceMode != replaceMode)
                sendOptionUpdate(Option.values()[replaceMode], true);
        });
        replaceLevelButton.setToolTip(toolTips.get(i));
        replaceLevelButtons.add(replaceLevelButton);
    }
    placementSettingWidgets.addAll(replaceLevelButtons);
    placementSettingWidgets.addAll(replaceLevelIndicators);
    // Other Settings
    skipMissingButton = new IconButton(x + 111, y + 117, AllIcons.I_SKIP_MISSING);
    skipMissingButton.withCallback(() -> {
        sendOptionUpdate(Option.SKIP_MISSING, !menu.contentHolder.skipMissing);
    });
    skipMissingButton.setToolTip(Lang.translate("gui.schematicannon.option.skipMissing"));
    skipMissingIndicator = new Indicator(x + 111, y + 111, TextComponent.EMPTY);
    Collections.addAll(placementSettingWidgets, skipMissingButton, skipMissingIndicator);
    skipTilesButton = new IconButton(x + 129, y + 117, AllIcons.I_SKIP_TILES);
    skipTilesButton.withCallback(() -> {
        sendOptionUpdate(Option.SKIP_TILES, !menu.contentHolder.replaceTileEntities);
    });
    skipTilesButton.setToolTip(Lang.translate("gui.schematicannon.option.skipTileEntities"));
    skipTilesIndicator = new Indicator(x + 129, y + 111, TextComponent.EMPTY);
    Collections.addAll(placementSettingWidgets, skipTilesButton, skipTilesIndicator);
    addRenderableWidgets(placementSettingWidgets);
}
Also used : IconButton(com.simibubi.create.foundation.gui.widget.IconButton) AllIcons(com.simibubi.create.foundation.gui.AllIcons) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Component(net.minecraft.network.chat.Component) TextComponent(net.minecraft.network.chat.TextComponent) Indicator(com.simibubi.create.foundation.gui.widget.Indicator)

Aggregations

IconButton (com.simibubi.create.foundation.gui.widget.IconButton)18 Rect2i (net.minecraft.client.renderer.Rect2i)6 Indicator (com.simibubi.create.foundation.gui.widget.Indicator)5 Label (com.simibubi.create.foundation.gui.widget.Label)5 SelectionScrollInput (com.simibubi.create.foundation.gui.widget.SelectionScrollInput)5 TextComponent (net.minecraft.network.chat.TextComponent)3 ScrollInput (com.simibubi.create.foundation.gui.widget.ScrollInput)2 EditBox (net.minecraft.client.gui.components.EditBox)2 Component (net.minecraft.network.chat.Component)2 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 ClientSchematicLoader (com.simibubi.create.content.schematics.ClientSchematicLoader)1 AllIcons (com.simibubi.create.foundation.gui.AllIcons)1 Vector (java.util.Vector)1 AbstractWidget (net.minecraft.client.gui.components.AbstractWidget)1 BlockPos (net.minecraft.core.BlockPos)1 MutableComponent (net.minecraft.network.chat.MutableComponent)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1 StructurePlaceSettings (net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings)1