Search in sources :

Example 6 with ColorRectTexture

use of gregtech.api.gui.resources.ColorRectTexture in project GregTech by GregTechCEu.

the class GuideConfigEditor method createPageConfig.

private DraggableScrollableWidgetGroup createPageConfig() {
    DraggableScrollableWidgetGroup group = new DraggableScrollableWidgetGroup(0, 0, getSize().width, getSize().height - 10).setBackground(TerminalTheme.COLOR_B_3).setYScrollBarWidth(4).setYBarStyle(null, TerminalTheme.COLOR_F_1);
    group.addWidget(new LabelWidget(5, 5, "section", -1).setShadow(true));
    group.addWidget(new TextFieldWidget(5, 15, 116, 20, new ColorRectTexture(0x9f000000), null, null).setTextResponder(s -> {
        if (pageEditor != null) {
            pageEditor.setSection(s);
        }
    }, true).setTextSupplier(() -> getPageEditor().getSection(), true).setMaxStringLength(Integer.MAX_VALUE).setValidator(s -> true));
    group.addWidget(new ImageWidget(5, 40, 116, 1, new ColorRectTexture(-1)));
    group.addWidget(new LabelWidget(5, 45, "type", -1).setShadow(true));
    group.addWidget(new SelectorWidget(30, 55, 91, 20, candidates, -1, () -> type, true).setIsUp(true).setOnChanged(type -> this.type = type).setColors(TerminalTheme.COLOR_B_2.getColor(), TerminalTheme.COLOR_F_1.getColor(), TerminalTheme.COLOR_B_2.getColor()).setBackground(TerminalTheme.COLOR_6));
    group.addWidget(new PhantomSlotWidget(handler, 0, 6, 56).setBackgroundTexture(TerminalTheme.COLOR_B_2));
    group.addWidget(new ImageWidget(5, 80, 116, 1, new ColorRectTexture(-1)));
    group.addWidget(new LabelWidget(5, 85, "title", -1).setShadow(true));
    titleEditor = new TextEditorWidget(5, 95, 116, 70, s -> {
        if (pageEditor != null) {
            pageEditor.setTitle(s);
        }
    }, true).setContent("Template").setBackground(new ColorRectTexture(0xA3FFFFFF));
    group.addWidget(titleEditor);
    return group;
}
Also used : JsonObject(com.google.gson.JsonObject) Size(gregtech.api.util.Size) MultiBlockGuideApp(gregtech.common.terminal.app.guide.MultiBlockGuideApp) Item(net.minecraft.item.Item) IGuiTextureTabInfo(gregtech.api.gui.widgets.tab.IGuiTextureTabInfo) SimpleMachineGuideApp(gregtech.common.terminal.app.guide.SimpleMachineGuideApp) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) TerminalDialogWidget(gregtech.api.terminal.os.TerminalDialogWidget) TextTexture(gregtech.api.gui.resources.TextTexture) TerminalRegistry(gregtech.api.terminal.TerminalRegistry) ItemStack(net.minecraft.item.ItemStack) Widget(gregtech.api.gui.Widget) GregTechAPI(gregtech.api.GregTechAPI) gregtech.api.gui.widgets(gregtech.api.gui.widgets) Map(java.util.Map) FileUtility(gregtech.api.util.FileUtility) IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) IGuideWidget(gregtech.common.terminal.app.guide.widget.IGuideWidget) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) SelectorWidget(gregtech.api.terminal.gui.widgets.SelectorWidget) CustomTabListRenderer(gregtech.api.terminal.gui.CustomTabListRenderer) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) GuideApp(gregtech.common.terminal.app.guide.GuideApp) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) Collectors(java.util.stream.Collectors) GuiTextures(gregtech.api.gui.GuiTextures) File(java.io.File) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) java.awt(java.awt) Objects(java.util.Objects) Position(gregtech.api.util.Position) ItemGuideApp(gregtech.common.terminal.app.guide.ItemGuideApp) List(java.util.List) TextEditorWidget(gregtech.api.terminal.gui.widgets.TextEditorWidget) GuideEditorApp(gregtech.common.terminal.app.guideeditor.GuideEditorApp) SingleItemStackHandler(gregtech.common.inventory.handlers.SingleItemStackHandler) GuidePageWidget(gregtech.common.terminal.app.guide.widget.GuidePageWidget) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) SelectorWidget(gregtech.api.terminal.gui.widgets.SelectorWidget) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) TextEditorWidget(gregtech.api.terminal.gui.widgets.TextEditorWidget)

Example 7 with ColorRectTexture

use of gregtech.api.gui.resources.ColorRectTexture in project GregTech by GregTechCEu.

the class WorldProspectorARApp method initApp.

@Override
public AbstractApplication initApp() {
    addWidget(new ImageWidget(10, 10, 313, 212, new ColorRectTexture(TerminalTheme.COLOR_B_2.getColor())));
    addWidget(new LabelWidget(15 + 150 / 2, 232 / 2, "terminal.world_prospector.radius", -1, new Object[] { getMaxRadius() }).setShadow(true).setYCentered(true).setXCentered(true));
    int slotSize = (int) Math.pow(2, getAppTier());
    int x = 250 - slotSize * 12;
    int y = 232 / 2 - 18;
    handlers = new SingleItemStackHandler[slotSize];
    colors = new int[slotSize];
    for (int i = 0; i < slotSize; i++) {
        int index = i;
        Tuple<ItemStack, Integer> stack = getSlotStack(i);
        if (stack == null) {
            handlers[i] = new SingleItemStackHandler(ItemStack.EMPTY);
            colors[i] = 0;
        } else {
            handlers[i] = new SingleItemStackHandler(stack.getFirst());
            colors[i] = stack.getSecond();
        }
        RectButtonWidget buttonWidget = new RectButtonWidget(x + i * 24, y + 18, 18, 18, 1);
        addWidget(new PhantomSlotWidget(handlers[i], 0, x + i * 24, y) {

            @Override
            public boolean mouseClicked(int mouseX, int mouseY, int button) {
                if (handlers[index].getStackInSlot(0).isEmpty() && isMouseOverElement(mouseX, mouseY)) {
                    writeClientAction(-1, buffer -> {
                    });
                    selectReference(index, buttonWidget);
                    return true;
                }
                return super.mouseClicked(mouseX, mouseY, button);
            }

            @Override
            public void handleClientAction(int id, PacketBuffer buffer) {
                if (id == -1) {
                    selectReference(index, buttonWidget);
                } else {
                    super.handleClientAction(id, buffer);
                }
            }
        }.setBackgroundTexture(new ColorRectTexture(0x4fffffff)));
        addWidget(buttonWidget.setHoverText("terminal.world_prospector.color").setColors(0x4fffffff, -1, colors[i]).setClickListener(cd -> TerminalDialogWidget.showColorDialog(getOs(), "terminal.world_prospector.color", res -> {
            if (res != null) {
                buttonWidget.setFill(res | 0xff000000);
                colors[index] = res | 0xff000000;
            }
        }, colors[index]).open()));
    }
    addWidget(new CircleButtonWidget(333 / 2, 200).setClickListener(cd -> openAR()).setHoverText("terminal.ar.open").setColors(0, -1, TerminalTheme.COLOR_B_3.getColor()).setIcon(new ItemStackTexture(MetaItems.CAMERA.getStackForm())));
    return this;
}
Also used : java.util(java.util) IRenderContext(gregtech.api.gui.IRenderContext) Blocks(net.minecraft.init.Blocks) MetaItems(gregtech.common.items.MetaItems) BlockStateMatcher(gregtech.common.terminal.app.worldprospector.matcher.BlockStateMatcher) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) TerminalDialogWidget(gregtech.api.terminal.os.TerminalDialogWidget) RenderWorldLastEvent(net.minecraftforge.client.event.RenderWorldLastEvent) ItemStackTexture(gregtech.api.gui.resources.ItemStackTexture) ImageWidget(gregtech.api.gui.widgets.ImageWidget) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) ItemStack(net.minecraft.item.ItemStack) ShaderTexture(gregtech.api.gui.resources.ShaderTexture) Block(net.minecraft.block.Block) Vec3d(net.minecraft.util.math.Vec3d) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) RenderBufferHelper(gregtech.client.utils.RenderBufferHelper) GL11(org.lwjgl.opengl.GL11) Shaders(gregtech.client.shader.Shaders) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) PhantomSlotWidget(gregtech.api.gui.widgets.PhantomSlotWidget) IMatcher(gregtech.common.terminal.app.worldprospector.matcher.IMatcher) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DepthTextureUtil(gregtech.client.utils.DepthTextureUtil) Entity(net.minecraft.entity.Entity) BlockFalling(net.minecraft.block.BlockFalling) World(net.minecraft.world.World) GlStateManager(net.minecraft.client.renderer.GlStateManager) Tuple(net.minecraft.util.Tuple) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) BlockPos(net.minecraft.util.math.BlockPos) LabelWidget(gregtech.api.gui.widgets.LabelWidget) ARApplication(gregtech.api.terminal.app.ARApplication) Framebuffer(net.minecraft.client.shader.Framebuffer) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget) Tessellator(net.minecraft.client.renderer.Tessellator) SingleItemStackHandler(gregtech.common.inventory.handlers.SingleItemStackHandler) EntityPlayer(net.minecraft.entity.player.EntityPlayer) MathHelper(net.minecraft.util.math.MathHelper) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) ItemBlock(net.minecraft.item.ItemBlock) PacketBuffer(net.minecraft.network.PacketBuffer) ItemStackTexture(gregtech.api.gui.resources.ItemStackTexture) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) SingleItemStackHandler(gregtech.common.inventory.handlers.SingleItemStackHandler) PhantomSlotWidget(gregtech.api.gui.widgets.PhantomSlotWidget) LabelWidget(gregtech.api.gui.widgets.LabelWidget) ImageWidget(gregtech.api.gui.widgets.ImageWidget) ItemStack(net.minecraft.item.ItemStack) PacketBuffer(net.minecraft.network.PacketBuffer) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget)

Example 8 with ColorRectTexture

use of gregtech.api.gui.resources.ColorRectTexture in project GregTech by GregTechCEu.

the class TextListConfigurator method init.

protected void init(int height) {
    JsonElement element = config.get(name);
    String initValue = "";
    if (!element.isJsonNull()) {
        List init = new Gson().fromJson(element, List.class);
        initValue = String.join("\n", init);
    }
    editor = new TextEditorWidget(0, 15, 116, height, this::updateTextList, true).setContent(initValue).setBackground(new ColorRectTexture(0xA3FFFFFF));
    this.addWidget(editor);
}
Also used : ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) List(java.util.List) TextEditorWidget(gregtech.api.terminal.gui.widgets.TextEditorWidget)

Example 9 with ColorRectTexture

use of gregtech.api.gui.resources.ColorRectTexture in project GregTech by GregTechCEu.

the class SlotListWidget method initFixed.

@Override
public Widget initFixed() {
    this.clearAllWidgets();
    ItemStackHandler itemStackHandler = new ItemStackHandler(item_list.size());
    IGuiTexture background = new ColorRectTexture(0x4f000000);
    int size = item_list.size();
    int maxXSize = getSize().width / 18;
    int xPos;
    if (maxXSize < 1) {
        maxXSize = 1;
        xPos = 0;
    } else {
        xPos = (getSize().width - (Math.min(size, maxXSize)) * 18) / 2;
    }
    int maxYSize = size / maxXSize + ((size % maxXSize) == 0 ? 0 : 1);
    for (int y = 0; y <= size / maxXSize; y++) {
        for (int x = 0; x < maxXSize; x++) {
            int i = x + y * maxXSize;
            if (i < size) {
                itemStackHandler.setStackInSlot(i, item_list.get(i).getInstance());
                SlotWidget widget = new SlotWidget(itemStackHandler, i, xPos + x * 18, y * 18, false, false);
                widget.setBackgroundTexture(background);
                this.addWidget(widget);
            }
        }
    }
    setSize(new Size(getSize().width / 18 > 0 ? getSize().width : 18, maxYSize * 18));
    return this;
}
Also used : ItemStackHandler(net.minecraftforge.items.ItemStackHandler) SlotWidget(gregtech.api.gui.widgets.SlotWidget) IGuiTexture(gregtech.api.gui.resources.IGuiTexture) Size(gregtech.api.util.Size) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture)

Example 10 with ColorRectTexture

use of gregtech.api.gui.resources.ColorRectTexture in project GregTech by GregTechCEu.

the class TankListWidget method initFixed.

@Override
public Widget initFixed() {
    this.clearAllWidgets();
    IGuiTexture background = new ColorRectTexture(0x4f000000);
    int size = fluid_list.size();
    int maxXSize = getSize().width / 18;
    int xPos;
    if (maxXSize < 1) {
        maxXSize = 1;
        xPos = 0;
    } else {
        xPos = (getSize().width - (Math.min(size, maxXSize)) * 18) / 2;
    }
    int maxYSize = size / maxXSize + ((size % maxXSize) == 0 ? 0 : 1);
    for (int y = 0; y <= size / maxXSize; y++) {
        for (int x = 0; x < maxXSize; x++) {
            int i = x + y * maxXSize;
            if (i < size) {
                FluidStack fluidStack = fluid_list.get(i).getInstance();
                TankWidget widget = new TankWidget(new FluidTank(fluidStack, fluid_list.get(i).amount), xPos + x * 18, y * 18, 18, 18);
                widget.setBackgroundTexture(background).setAlwaysShowFull(true).setClient();
                this.addWidget(widget);
            }
        }
    }
    setSize(new Size(getSize().width / 18 > 0 ? getSize().width : 18, maxYSize * 18));
    return this;
}
Also used : FluidTank(net.minecraftforge.fluids.FluidTank) TankWidget(gregtech.api.gui.widgets.TankWidget) IGuiTexture(gregtech.api.gui.resources.IGuiTexture) FluidStack(net.minecraftforge.fluids.FluidStack) Size(gregtech.api.util.Size) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture)

Aggregations

ColorRectTexture (gregtech.api.gui.resources.ColorRectTexture)13 ImageWidget (gregtech.api.gui.widgets.ImageWidget)7 AbstractApplication (gregtech.api.terminal.app.AbstractApplication)5 TerminalTheme (gregtech.api.terminal.os.TerminalTheme)5 Size (gregtech.api.util.Size)5 IRenderContext (gregtech.api.gui.IRenderContext)4 IGuiTexture (gregtech.api.gui.resources.IGuiTexture)4 LabelWidget (gregtech.api.gui.widgets.LabelWidget)4 List (java.util.List)4 GuiTextures (gregtech.api.gui.GuiTextures)3 Widget (gregtech.api.gui.Widget)3 TextureArea (gregtech.api.gui.resources.TextureArea)3 CircleButtonWidget (gregtech.api.terminal.gui.widgets.CircleButtonWidget)3 TerminalDialogWidget (gregtech.api.terminal.os.TerminalDialogWidget)3 Position (gregtech.api.util.Position)3 ItemStack (net.minecraft.item.ItemStack)3 ShaderTexture (gregtech.api.gui.resources.ShaderTexture)2 TextTexture (gregtech.api.gui.resources.TextTexture)2 gregtech.api.gui.widgets (gregtech.api.gui.widgets)2 SimpleTextWidget (gregtech.api.gui.widgets.SimpleTextWidget)2