Search in sources :

Example 21 with ColorRectTexture

use of com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture in project Multiblocked by Low-Drag-MC.

the class ProgressCapabilityTrait method refreshSlots.

protected void refreshSlots(DraggableScrollableWidgetGroup dragGroup) {
    dragGroup.widgets.forEach(dragGroup::waitToRemoved);
    ButtonWidget setting = (ButtonWidget) new ButtonWidget(width - 8, 0, 8, 8, new ResourceTexture("multiblocked:textures/gui/option.png"), null).setHoverBorderTexture(1, -1).setHoverTooltips("multiblocked.gui.tips.settings");
    ImageWidget imageWidget = new ImageWidget(0, 0, width, height, new GuiTextureGroup(new ResourceTexture(texture).getSubTexture(0, 0, 1, 0.5), new ColorBorderTexture(1, getColorByIO(capabilityIO))));
    setting.setVisible(false);
    DraggableWidgetGroup slot = new DraggableWidgetGroup(x, y, width, height);
    slot.setOnSelected(w -> setting.setVisible(true));
    slot.setOnUnSelected(w -> setting.setVisible(false));
    slot.addWidget(imageWidget);
    slot.addWidget(setting);
    slot.setOnEndDrag(b -> {
        x = b.getSelfPosition().x;
        y = b.getSelfPosition().y;
    });
    dragGroup.addWidget(slot);
    setting.setOnPressCallback(cd2 -> {
        DialogWidget dialog = new DialogWidget(dragGroup, true);
        dialog.addWidget(new ImageWidget(0, 0, 176, 256, new ColorRectTexture(0xaf000000)));
        initSettingDialog(dialog, slot);
    });
}
Also used : ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) DraggableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup) DialogWidget(com.lowdragmc.lowdraglib.gui.widget.DialogWidget) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup)

Example 22 with ColorRectTexture

use of com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture in project Multiblocked by Low-Drag-MC.

the class ProgressCapabilityTrait method initSettingDialog.

@Override
protected void initSettingDialog(DialogWidget dialog, DraggableWidgetGroup slot) {
    ImageWidget imageWidget = (ImageWidget) slot.widgets.get(0);
    ButtonWidget setting = (ButtonWidget) slot.widgets.get(1);
    ButtonWidget imageSelector = (ButtonWidget) new ButtonWidget(5, 65, width, height, new GuiTextureGroup(new ColorBorderTexture(1, -1), new ResourceTexture(texture).getSubTexture(0, 0, 1, 0.5)), null).setHoverTooltips("multiblocked.gui.tips.select_image");
    dialog.addWidget(new TextFieldWidget(5, 25, 50, 15, null, s -> {
        width = Integer.parseInt(s);
        Size size = new Size(width, height);
        slot.setSize(size);
        imageWidget.setSize(size);
        imageSelector.setSize(size);
        setting.setSelfPosition(new Position(width - 8, 0));
    }).setCurrentString(width + "").setNumbersOnly(1, 180).setHoverTooltips("multiblocked.gui.trait.set_width"));
    dialog.addWidget(new TextFieldWidget(5, 45, 50, 15, null, s -> {
        height = Integer.parseInt(s);
        Size size = new Size(width, height);
        slot.setSize(size);
        imageWidget.setSize(size);
        imageSelector.setSize(size);
        setting.setSelfPosition(new Position(width - 8, 0));
    }).setCurrentString(height + "").setNumbersOnly(1, 180).setHoverTooltips("multiblocked.gui.trait.set_height"));
    dialog.addWidget(new SelectorWidget(5, 5, 50, 15, Arrays.stream(IO.VALUES).map(Enum::name).collect(Collectors.toList()), -1).setValue(capabilityIO.name()).setOnChanged(io -> {
        capabilityIO = IO.valueOf(io);
        imageWidget.setImage(new GuiTextureGroup(new ResourceTexture(texture).getSubTexture(0, 0, 1, 0.5), new ColorBorderTexture(1, getColorByIO(capabilityIO))));
    }).setButtonBackground(ResourceBorderTexture.BUTTON_COMMON).setBackground(new ColorRectTexture(0xffaaaaaa)).setHoverTooltips("multiblocked.gui.trait.capability_io"));
    dialog.addWidget(imageSelector);
    imageSelector.setOnPressCallback(cd -> new ResourceTextureWidget(dialog.getParent().getGui().mainGroup, texture1 -> {
        if (texture1 != null) {
            texture = texture1.imageLocation.toString();
            ResourceTexture resourceTexture = new ResourceTexture(texture).getSubTexture(0, 0, 1, 0.5);
            imageSelector.setButtonTexture(new GuiTextureGroup(new ColorBorderTexture(1, -1), resourceTexture));
            imageWidget.setImage(new GuiTextureGroup(resourceTexture, new ColorBorderTexture(1, getColorByIO(capabilityIO))));
        }
    }));
}
Also used : JSONUtils(net.minecraft.util.JSONUtils) JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) ComponentTileEntity(com.lowdragmc.multiblocked.api.tile.ComponentTileEntity) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) MultiblockCapability(com.lowdragmc.multiblocked.api.capability.MultiblockCapability) ResourceBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture) JsonElement(com.google.gson.JsonElement) SelectorWidget(com.lowdragmc.lowdraglib.gui.widget.SelectorWidget) IO(com.lowdragmc.multiblocked.api.capability.IO) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) Nullable(javax.annotation.Nullable) ResourceTextureWidget(com.lowdragmc.multiblocked.api.gui.dialogs.ResourceTextureWidget) Position(com.lowdragmc.lowdraglib.utils.Position) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) Size(com.lowdragmc.lowdraglib.utils.Size) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup) ProgressWidget(com.lowdragmc.multiblocked.api.gui.recipe.ProgressWidget) Collectors(java.util.stream.Collectors) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) DialogWidget(com.lowdragmc.lowdraglib.gui.widget.DialogWidget) DraggableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceTextureWidget(com.lowdragmc.multiblocked.api.gui.dialogs.ResourceTextureWidget) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) Position(com.lowdragmc.lowdraglib.utils.Position) Size(com.lowdragmc.lowdraglib.utils.Size) SelectorWidget(com.lowdragmc.lowdraglib.gui.widget.SelectorWidget) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget)

Example 23 with ColorRectTexture

use of com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture in project Multiblocked by Low-Drag-MC.

the class SingleCapabilityTrait method refreshSlots.

protected void refreshSlots(DraggableScrollableWidgetGroup dragGroup) {
    dragGroup.widgets.forEach(dragGroup::waitToRemoved);
    ButtonWidget setting = (ButtonWidget) new ButtonWidget(10, 0, 8, 8, new ResourceTexture("multiblocked:textures/gui/option.png"), null).setHoverBorderTexture(1, -1).setHoverTooltips("multiblocked.gui.tips.settings");
    ImageWidget imageWidget = new ImageWidget(1, 1, 16, 16, new GuiTextureGroup(new ColorRectTexture(getColorByIO(guiIO)), new ColorBorderTexture(1, getColorByIO(capabilityIO))));
    setting.setVisible(false);
    DraggableWidgetGroup slot = new DraggableWidgetGroup(x, y, 18, 18);
    slot.setOnSelected(w -> setting.setVisible(true));
    slot.setOnUnSelected(w -> setting.setVisible(false));
    slot.addWidget(imageWidget);
    slot.addWidget(setting);
    slot.setOnEndDrag(b -> {
        x = b.getSelfPosition().x;
        y = b.getSelfPosition().y;
    });
    dragGroup.addWidget(slot);
    setting.setOnPressCallback(cd2 -> {
        DialogWidget dialog = new DialogWidget(dragGroup, true);
        dialog.addWidget(new ImageWidget(0, 0, 176, 256, new ColorRectTexture(0xaf000000)));
        initSettingDialog(dialog, slot);
    });
}
Also used : ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) DraggableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup) DialogWidget(com.lowdragmc.lowdraglib.gui.widget.DialogWidget) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup)

Example 24 with ColorRectTexture

use of com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture in project Multiblocked by Low-Drag-MC.

the class SingleCapabilityTrait method initSettingDialog.

protected void initSettingDialog(DialogWidget dialog, DraggableWidgetGroup slot) {
    ImageWidget imageWidget = (ImageWidget) slot.widgets.get(0);
    dialog.addWidget(new SelectorWidget(5, 5, 40, 15, Arrays.stream(IO.VALUES).map(Enum::name).collect(Collectors.toList()), -1).setValue(capabilityIO.name()).setOnChanged(io -> {
        capabilityIO = IO.valueOf(io);
        imageWidget.setImage(new GuiTextureGroup(new ColorRectTexture(getColorByIO(guiIO)), new ColorBorderTexture(1, getColorByIO(capabilityIO))));
    }).setButtonBackground(ResourceBorderTexture.BUTTON_COMMON).setBackground(new ColorRectTexture(0xffaaaaaa)).setHoverTooltips("multiblocked.gui.trait.capability_io"));
    dialog.addWidget(new SelectorWidget(50, 5, 40, 15, Arrays.stream(IO.VALUES).map(Enum::name).collect(Collectors.toList()), -1).setValue(guiIO.name()).setOnChanged(io -> {
        guiIO = IO.valueOf(io);
        imageWidget.setImage(new GuiTextureGroup(new ColorRectTexture(getColorByIO(guiIO)), new ColorBorderTexture(1, getColorByIO(capabilityIO))));
    }).setButtonBackground(ResourceBorderTexture.BUTTON_COMMON).setBackground(new ColorRectTexture(0xffaaaaaa)).setHoverTooltips("multiblocked.gui.trait.gui_io"));
}
Also used : ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) SelectorWidget(com.lowdragmc.lowdraglib.gui.widget.SelectorWidget) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup)

Aggregations

ColorRectTexture (com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture)24 ImageWidget (com.lowdragmc.lowdraglib.gui.widget.ImageWidget)18 ResourceTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceTexture)17 ButtonWidget (com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)17 TextTexture (com.lowdragmc.lowdraglib.gui.texture.TextTexture)13 WidgetGroup (com.lowdragmc.lowdraglib.gui.widget.WidgetGroup)10 ColorBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture)9 DraggableScrollableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup)9 GuiTextureGroup (com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup)8 SelectorWidget (com.lowdragmc.lowdraglib.gui.widget.SelectorWidget)7 JsonElement (com.google.gson.JsonElement)6 ResourceBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture)6 SelectableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.SelectableWidgetGroup)6 Multiblocked (com.lowdragmc.multiblocked.Multiblocked)6 ItemStack (net.minecraft.item.ItemStack)6 ResourceLocation (net.minecraft.util.ResourceLocation)6 DialogWidget (com.lowdragmc.lowdraglib.gui.widget.DialogWidget)5 DraggableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup)5 LabelWidget (com.lowdragmc.lowdraglib.gui.widget.LabelWidget)5 List (java.util.List)5