Search in sources :

Example 1 with GuiTextureGroup

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

the class PartBuilderWidget method initScene.

@OnlyIn(Dist.CLIENT)
private void initScene() {
    TrackedDummyWorld world = new TrackedDummyWorld();
    world.addBlock(BlockPos.ZERO, BlockInfo.fromBlockState(MbdComponents.DummyComponentBlock.defaultBlockState()));
    tileEntity = (DummyComponentTileEntity) world.getBlockEntity(BlockPos.ZERO);
    this.addWidget(new ImageWidget(30, 59, 138, 138, new GuiTextureGroup(new ColorBorderTexture(3, -1), new ColorRectTexture(0xaf444444))));
    this.addWidget(new SceneWidget(30, 59, 138, 138, world).setRenderedCore(Collections.singleton(BlockPos.ZERO), null).setRenderSelect(false).setRenderFacing(false));
    this.addWidget(new ImageWidget(30, 65, 138, 15, textTexture = new TextTexture("", 0xff00ff00).setDropShadow(true).setWidth(138).setType(TextTexture.TextType.ROLL)));
}
Also used : ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) TrackedDummyWorld(com.lowdragmc.lowdraglib.utils.TrackedDummyWorld) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup) SceneWidget(com.lowdragmc.lowdraglib.gui.widget.SceneWidget) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 2 with GuiTextureGroup

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

the class MultiCapabilityTrait method initSettingDialog.

protected void initSettingDialog(DialogWidget dialog, DraggableWidgetGroup slot, final int index) {
    ImageWidget imageWidget = (ImageWidget) slot.widgets.get(0);
    dialog.addWidget(new SelectorWidget(5, 30, 40, 15, Arrays.stream(IO.VALUES).map(Enum::name).collect(Collectors.toList()), -1).setValue(capabilityIO[index].name()).setOnChanged(io -> {
        capabilityIO[index] = IO.valueOf(io);
        imageWidget.setImage(new GuiTextureGroup(new ColorRectTexture(getColorByIO(guiIO[index])), new ColorBorderTexture(1, getColorByIO(capabilityIO[index]))));
    }).setButtonBackground(ResourceBorderTexture.BUTTON_COMMON).setBackground(new ColorRectTexture(0xffaaaaaa)).setHoverTooltips("multiblocked.gui.trait.capability_io"));
    dialog.addWidget(new SelectorWidget(50, 30, 40, 15, Arrays.stream(IO.VALUES).map(Enum::name).collect(Collectors.toList()), -1).setValue(guiIO[index].name()).setOnChanged(io -> {
        guiIO[index] = IO.valueOf(io);
        imageWidget.setImage(new GuiTextureGroup(new ColorRectTexture(getColorByIO(guiIO[index])), new ColorBorderTexture(1, getColorByIO(capabilityIO[index]))));
    }).setButtonBackground(ResourceBorderTexture.BUTTON_COMMON).setBackground(new ColorRectTexture(0xffaaaaaa)).setHoverTooltips("multiblocked.gui.trait.gui_io"));
    dialog.addWidget(new SelectorWidget(100, 30, 65, 15, Arrays.asList("multiblocked.gui.trait.auto_io", "multiblocked.gui.trait.passive_io"), -1).setValue(autoIO[index] ? "multiblocked.gui.trait.auto_io" : "multiblocked.gui.trait.passive_io").setOnChanged(auto -> autoIO[index] = auto.equals("multiblocked.gui.trait.auto_io")).setButtonBackground(ResourceBorderTexture.BUTTON_COMMON).setBackground(new ColorRectTexture(0xffaaaaaa)).setHoverTooltips("multiblocked.gui.trait.auto"));
}
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)

Example 3 with GuiTextureGroup

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

the class GTRenderer method addTextureSelector.

protected void addTextureSelector(int x, int y, int width, int height, String text, WidgetGroup parent, WidgetGroup group, ResourceLocation init, Consumer<ResourceLocation> newTexture) {
    ImageWidget imageWidget;
    if (init != null) {
        imageWidget = new ImageWidget(x, y, width, height, new GuiTextureGroup(new ColorBorderTexture(1, -1), new ResourceTexture(init.getNamespace() + ":textures/" + init.getPath() + ".png")));
    } else {
        imageWidget = new ImageWidget(x, y, width, height, new ColorBorderTexture(1, -1));
    }
    group.addWidget(imageWidget);
    group.addWidget(new ButtonWidget(x, y, width, height, null, cd -> new ResourceTextureWidget(parent, texture -> {
        if (texture != null) {
            imageWidget.setImage(new GuiTextureGroup(new ColorBorderTexture(1, -1), texture));
            newTexture.accept(new ResourceLocation(texture.imageLocation.toString().replace("textures/", "").replace(".png", "")));
        }
    })).setHoverTexture(new ColorRectTexture(0x4faaaaaa)).setHoverTooltips(String.format("select the %s texture", text)));
}
Also used : JsonObject(com.google.gson.JsonObject) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) CustomBakedModel(com.lowdragmc.lowdraglib.client.model.custommodel.CustomBakedModel) IBakedModel(net.minecraft.client.renderer.model.IBakedModel) Random(java.util.Random) Direction(net.minecraft.util.Direction) Supplier(java.util.function.Supplier) BlockModel(net.minecraft.client.renderer.model.BlockModel) Dist(net.minecraftforge.api.distmarker.Dist) Minecraft(net.minecraft.client.Minecraft) Gson(com.google.gson.Gson) IBlockDisplayReader(net.minecraft.world.IBlockDisplayReader) BlockState(net.minecraft.block.BlockState) ModelLoader(net.minecraftforge.client.model.ModelLoader) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) Nonnull(javax.annotation.Nonnull) IMultiblockedRenderer(com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ResourceTextureWidget(com.lowdragmc.multiblocked.api.gui.dialogs.ResourceTextureWidget) EnumMap(java.util.EnumMap) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) IPartComponent(com.lowdragmc.multiblocked.api.tile.part.IPartComponent) IModelData(net.minecraftforge.client.model.data.IModelData) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) AtlasTexture(net.minecraft.client.renderer.texture.AtlasTexture) ModelFactory(com.lowdragmc.lowdraglib.client.model.ModelFactory) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup) IControllerComponent(com.lowdragmc.multiblocked.api.tile.IControllerComponent) BlockPos(net.minecraft.util.math.BlockPos) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) BakedQuad(net.minecraft.client.renderer.model.BakedQuad) Consumer(java.util.function.Consumer) List(java.util.List) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) IUnbakedModel(net.minecraft.client.renderer.model.IUnbakedModel) TileEntity(net.minecraft.tileentity.TileEntity) Multiblocked(com.lowdragmc.multiblocked.Multiblocked) Collections(java.util.Collections) ResourceTextureWidget(com.lowdragmc.multiblocked.api.gui.dialogs.ResourceTextureWidget) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup)

Example 4 with GuiTextureGroup

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

the class MultiCapabilityTrait method refreshSlots.

protected void refreshSlots(DraggableScrollableWidgetGroup dragGroup) {
    dragGroup.widgets.forEach(dragGroup::waitToRemoved);
    for (int i = 0; i < guiIO.length; i++) {
        int finalI = i;
        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[finalI])), new ColorBorderTexture(1, getColorByIO(capabilityIO[finalI]))));
        setting.setVisible(false);
        DraggableWidgetGroup slot = new DraggableWidgetGroup(x[finalI], y[finalI], 18, 18);
        slot.setOnSelected(w -> setting.setVisible(true));
        slot.setOnUnSelected(w -> setting.setVisible(false));
        slot.addWidget(imageWidget);
        slot.addWidget(setting);
        slot.setOnEndDrag(b -> {
            x[finalI] = b.getSelfPosition().x;
            y[finalI] = 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)));
            dialog.addWidget(new ButtonWidget(5, 5, 85, 20, new GuiTextureGroup(ResourceBorderTexture.BUTTON_COMMON, new TextTexture("multiblocked.gui.trait.remove_slot")), cd3 -> {
                removeSlot(finalI);
                refreshSlots(dragGroup);
                dialog.close();
            }).setHoverBorderTexture(1, -1));
            initSettingDialog(dialog, slot, finalI);
        });
    }
}
Also used : ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) 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 5 with GuiTextureGroup

use of com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup 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)

Aggregations

ColorBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture)8 ColorRectTexture (com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture)8 GuiTextureGroup (com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup)8 ImageWidget (com.lowdragmc.lowdraglib.gui.widget.ImageWidget)8 ResourceTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceTexture)5 ButtonWidget (com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)5 DialogWidget (com.lowdragmc.lowdraglib.gui.widget.DialogWidget)4 DraggableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup)4 SelectorWidget (com.lowdragmc.lowdraglib.gui.widget.SelectorWidget)3 JsonObject (com.google.gson.JsonObject)2 TextTexture (com.lowdragmc.lowdraglib.gui.texture.TextTexture)2 DraggableScrollableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup)2 WidgetGroup (com.lowdragmc.lowdraglib.gui.widget.WidgetGroup)2 ResourceTextureWidget (com.lowdragmc.multiblocked.api.gui.dialogs.ResourceTextureWidget)2 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)2 Gson (com.google.gson.Gson)1 JsonElement (com.google.gson.JsonElement)1 ModelFactory (com.lowdragmc.lowdraglib.client.model.ModelFactory)1 CustomBakedModel (com.lowdragmc.lowdraglib.client.model.custommodel.CustomBakedModel)1 ResourceBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture)1