Search in sources :

Example 1 with Indicator

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

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

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

Example 4 with Indicator

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

the class FilterScreen method init.

@Override
protected void init() {
    setWindowOffset(-11, 5);
    super.init();
    int x = leftPos;
    int y = topPos;
    blacklist = new IconButton(x + 18, y + 73, AllIcons.I_BLACKLIST);
    blacklist.withCallback(() -> {
        menu.blacklist = true;
        sendOptionUpdate(Option.BLACKLIST);
    });
    blacklist.setToolTip(denyN);
    whitelist = new IconButton(x + 36, y + 73, AllIcons.I_WHITELIST);
    whitelist.withCallback(() -> {
        menu.blacklist = false;
        sendOptionUpdate(Option.WHITELIST);
    });
    whitelist.setToolTip(allowN);
    blacklistIndicator = new Indicator(x + 18, y + 67, TextComponent.EMPTY);
    whitelistIndicator = new Indicator(x + 36, y + 67, TextComponent.EMPTY);
    addRenderableWidgets(blacklist, whitelist, blacklistIndicator, whitelistIndicator);
    respectNBT = new IconButton(x + 60, y + 73, AllIcons.I_RESPECT_NBT);
    respectNBT.withCallback(() -> {
        menu.respectNBT = true;
        sendOptionUpdate(Option.RESPECT_DATA);
    });
    respectNBT.setToolTip(respectDataN);
    ignoreNBT = new IconButton(x + 78, y + 73, AllIcons.I_IGNORE_NBT);
    ignoreNBT.withCallback(() -> {
        menu.respectNBT = false;
        sendOptionUpdate(Option.IGNORE_DATA);
    });
    ignoreNBT.setToolTip(ignoreDataN);
    respectNBTIndicator = new Indicator(x + 60, y + 67, TextComponent.EMPTY);
    ignoreNBTIndicator = new Indicator(x + 78, y + 67, TextComponent.EMPTY);
    addRenderableWidgets(respectNBT, ignoreNBT, respectNBTIndicator, ignoreNBTIndicator);
    handleIndicators();
}
Also used : IconButton(com.simibubi.create.foundation.gui.widget.IconButton) Indicator(com.simibubi.create.foundation.gui.widget.Indicator)

Example 5 with Indicator

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

the class SchematicannonScreen method init.

@Override
protected void init() {
    setWindowSize(BG_TOP.width, BG_TOP.height + BG_BOTTOM.height + 2 + AllGuiTextures.PLAYER_INVENTORY.height);
    setWindowOffset(-11, 0);
    super.init();
    int x = leftPos;
    int y = topPos;
    // Play Pause Stop
    playButton = new IconButton(x + 75, y + 86, AllIcons.I_PLAY);
    playButton.withCallback(() -> {
        sendOptionUpdate(Option.PLAY, true);
    });
    playIndicator = new Indicator(x + 75, y + 79, TextComponent.EMPTY);
    pauseButton = new IconButton(x + 93, y + 86, AllIcons.I_PAUSE);
    pauseButton.withCallback(() -> {
        sendOptionUpdate(Option.PAUSE, true);
    });
    pauseIndicator = new Indicator(x + 93, y + 79, TextComponent.EMPTY);
    resetButton = new IconButton(x + 111, y + 86, AllIcons.I_STOP);
    resetButton.withCallback(() -> {
        sendOptionUpdate(Option.STOP, true);
    });
    resetIndicator = new Indicator(x + 111, y + 79, TextComponent.EMPTY);
    resetIndicator.state = State.RED;
    addRenderableWidgets(playButton, playIndicator, pauseButton, pauseIndicator, resetButton, resetIndicator);
    confirmButton = new IconButton(x + 180, y + 117, AllIcons.I_CONFIRM);
    confirmButton.withCallback(() -> {
        minecraft.player.closeContainer();
    });
    addRenderableWidget(confirmButton);
    showSettingsButton = new IconButton(x + 9, y + 117, AllIcons.I_PLACEMENT_SETTINGS);
    showSettingsButton.withCallback(() -> {
        showSettingsIndicator.state = placementSettingsHidden() ? State.GREEN : State.OFF;
        initPlacementSettings();
    });
    showSettingsButton.setToolTip(Lang.translate(_showSettings));
    addRenderableWidget(showSettingsButton);
    showSettingsIndicator = new Indicator(x + 9, y + 111, TextComponent.EMPTY);
    addRenderableWidget(showSettingsIndicator);
    extraAreas = ImmutableList.of(new Rect2i(x + BG_TOP.width, y + BG_TOP.height + BG_BOTTOM.height - 62, 84, 92));
    tick();
}
Also used : Rect2i(net.minecraft.client.renderer.Rect2i) IconButton(com.simibubi.create.foundation.gui.widget.IconButton) Indicator(com.simibubi.create.foundation.gui.widget.Indicator)

Aggregations

IconButton (com.simibubi.create.foundation.gui.widget.IconButton)5 Indicator (com.simibubi.create.foundation.gui.widget.Indicator)5 Label (com.simibubi.create.foundation.gui.widget.Label)2 SelectionScrollInput (com.simibubi.create.foundation.gui.widget.SelectionScrollInput)2 TextComponent (net.minecraft.network.chat.TextComponent)2 AllIcons (com.simibubi.create.foundation.gui.AllIcons)1 ScrollInput (com.simibubi.create.foundation.gui.widget.ScrollInput)1 Rect2i (net.minecraft.client.renderer.Rect2i)1 Component (net.minecraft.network.chat.Component)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1