Search in sources :

Example 6 with DraggableScrollableWidgetGroup

use of gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup in project GregTech by GregTechCEu.

the class ItemStackConfigurator method addSlot.

private void addSlot(DraggableScrollableWidgetGroup container, SlotListWidget.ItemStackInfo itemStackInfo) {
    WidgetGroup group = new WidgetGroup(0, slots.size() * 20, 116, 20);
    slots.add(itemStackInfo);
    IItemHandlerModifiable handler = new SingleItemStackHandler(1);
    handler.setStackInSlot(0, itemStackInfo.getInstance());
    group.addWidget(new PhantomSlotWidget(handler, 0, 1, 1).setBackgroundTexture(TerminalTheme.COLOR_B_2).setChangeListener(() -> {
        itemStackInfo.update(handler.getStackInSlot(0));
        updateValue();
    }));
    group.addWidget(new RectButtonWidget(20, 0, 20, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> {
        itemStackInfo.count = Math.max(0, itemStackInfo.count - (data.isShiftClick ? 10 : 1));
        updateValue();
    }).setIcon(new TextTexture("-1", -1)));
    group.addWidget(new RectButtonWidget(76, 0, 20, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> {
        itemStackInfo.count = Math.max(0, itemStackInfo.count + (data.isShiftClick ? 10 : 1));
        updateValue();
    }).setIcon(new TextTexture("+1", -1)));
    group.addWidget(new ImageWidget(40, 0, 36, 20, TerminalTheme.COLOR_B_2));
    group.addWidget(new SimpleTextWidget(58, 10, "", 0xFFFFFF, () -> Integer.toString(itemStackInfo.count), true));
    group.addWidget(new RectButtonWidget(96, 0, 20, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> {
        container.waitToRemoved(group);
        slots.remove(itemStackInfo);
        int index = container.widgets.indexOf(group);
        for (int i = container.widgets.size() - 1; i > index; i--) {
            container.widgets.get(i).addSelfPosition(0, -20);
        }
        updateValue();
    }).setIcon(GuiTextures.ICON_REMOVE));
    container.addWidget(group);
}
Also used : IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) PhantomSlotWidget(gregtech.api.gui.widgets.PhantomSlotWidget) WidgetGroup(gregtech.api.gui.widgets.WidgetGroup) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) SingleItemStackHandler(gregtech.common.inventory.handlers.SingleItemStackHandler) TextTexture(gregtech.api.gui.resources.TextTexture) ImageWidget(gregtech.api.gui.widgets.ImageWidget) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget) SimpleTextWidget(gregtech.api.gui.widgets.SimpleTextWidget)

Example 7 with DraggableScrollableWidgetGroup

use of gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup in project GregTech by GregTechCEu.

the class ItemStackConfigurator method init.

protected void init() {
    container = new DraggableScrollableWidgetGroup(0, 27, 116, 100);
    this.addWidget(container);
    this.addWidget(new RectButtonWidget(0, 15, 116, 10, 1).setIcon(new TextTexture("terminal.guide_editor.add_slot", -1)).setClickListener(cd -> {
        addSlot(container, new SlotListWidget.ItemStackInfo("minecraft:air", 0, 0));
        updateValue();
    }).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()));
    slots = new ArrayList<>();
    if (!config.get(name).isJsonNull()) {
        Gson gson = new Gson();
        for (JsonElement o : config.get(name).getAsJsonArray()) {
            addSlot(container, gson.fromJson(o, SlotListWidget.ItemStackInfo.class));
        }
    }
}
Also used : DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) JsonElement(com.google.gson.JsonElement) TextTexture(gregtech.api.gui.resources.TextTexture) Gson(com.google.gson.Gson) SlotListWidget(gregtech.common.terminal.app.guide.widget.SlotListWidget) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget)

Example 8 with DraggableScrollableWidgetGroup

use of gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup in project GregTech by GregTechCEu.

the class VirtualTankApp method initApp.

@Override
public AbstractApplication initApp() {
    this.addWidget(new ImageWidget(5, 5, 333 - 10, 232 - 10, TerminalTheme.COLOR_B_2));
    this.addWidget(new LabelWidget(10, 10, "terminal.vtank_viewer.title", -1));
    this.addWidget(new RectButtonWidget(216, 7, 110, 18).setClickListener(cd -> {
        if (cd.isClient) {
            reloadWidgets(cacheClient);
        }
    }).setIcon(new TextTexture("terminal.vtank_viewer.refresh", -1)).setFill(TerminalTheme.COLOR_B_2.getColor()));
    widgetGroup = new DraggableScrollableWidgetGroup(10, 30, 313, 195).setDraggable(true).setYScrollBarWidth(3).setYBarStyle(null, TerminalTheme.COLOR_F_1);
    if (isClient) {
        cacheClient = new HashMap<>();
    } else {
        cacheServer = new HashMap<>();
    }
    this.addWidget(widgetGroup);
    if (!isRemote()) {
        refresh();
    }
    return this;
}
Also used : VirtualTankRegistry(gregtech.api.util.VirtualTankRegistry) java.util(java.util) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) TextTexture(gregtech.api.gui.resources.TextTexture) ImageWidget(gregtech.api.gui.widgets.ImageWidget) TankWidget(gregtech.api.gui.widgets.TankWidget) SearchComponent(gregtech.common.terminal.component.SearchComponent) Pair(org.apache.commons.lang3.tuple.Pair) Side(net.minecraftforge.fml.relauncher.Side) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GTLog(gregtech.api.util.GTLog) WidgetGroup(gregtech.api.gui.widgets.WidgetGroup) LabelWidget(gregtech.api.gui.widgets.LabelWidget) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) Collectors(java.util.stream.Collectors) GuiTextures(gregtech.api.gui.GuiTextures) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) Consumer(java.util.function.Consumer) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget) IMenuComponent(gregtech.api.terminal.os.menu.IMenuComponent) FluidStack(net.minecraftforge.fluids.FluidStack) FluidTank(net.minecraftforge.fluids.FluidTank) IFluidTank(net.minecraftforge.fluids.IFluidTank) PacketBuffer(net.minecraft.network.PacketBuffer) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) LabelWidget(gregtech.api.gui.widgets.LabelWidget) TextTexture(gregtech.api.gui.resources.TextTexture) ImageWidget(gregtech.api.gui.widgets.ImageWidget) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget)

Example 9 with DraggableScrollableWidgetGroup

use of gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup in project GregTech by GregTechCEu.

the class AppStoreApp method initApp.

@Override
public AbstractApplication initApp() {
    DraggableScrollableWidgetGroup group = new DraggableScrollableWidgetGroup(0, 0, 333, 232);
    this.addWidget(group);
    int index = 0;
    int yOffset = 50;
    group.addWidget(new ImageWidget(0, 0, 333, 30, GuiTextures.UI_FRAME_SIDE_UP));
    group.addWidget(new LabelWidget(333 / 2, 10, getUnlocalizedName(), -1).setShadow(true).setYCentered(true).setXCentered(true));
    for (AbstractApplication app : TerminalRegistry.getAllApps()) {
        group.addWidget(new AppCardWidget(5 + 110 * (index % 3), yOffset + 110 * (index / 3), app, this));
        index++;
    }
    int y = yOffset + 110 * ((index + 2) / 3);
    group.addWidget(new ImageWidget(0, y, 333, 30, new ColorRectTexture(TerminalTheme.COLOR_B_2.getColor())));
    group.addWidget(new ImageWidget(0, y, 333, 30, new TextTexture("Copyright @2021-xxxx Gregicality Team XD", -1)));
    loadLocalConfig(nbt -> this.darkMode = nbt.getBoolean("dark"));
    return this;
}
Also used : DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) LabelWidget(gregtech.api.gui.widgets.LabelWidget) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) TextTexture(gregtech.api.gui.resources.TextTexture) ImageWidget(gregtech.api.gui.widgets.ImageWidget)

Aggregations

DraggableScrollableWidgetGroup (gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup)9 TextTexture (gregtech.api.gui.resources.TextTexture)7 RectButtonWidget (gregtech.api.terminal.gui.widgets.RectButtonWidget)5 ImageWidget (gregtech.api.gui.widgets.ImageWidget)4 Gson (com.google.gson.Gson)3 JsonElement (com.google.gson.JsonElement)3 JsonObject (com.google.gson.JsonObject)3 GuiTextures (gregtech.api.gui.GuiTextures)3 Widget (gregtech.api.gui.Widget)3 LabelWidget (gregtech.api.gui.widgets.LabelWidget)3 AbstractApplication (gregtech.api.terminal.app.AbstractApplication)3 TerminalTheme (gregtech.api.terminal.os.TerminalTheme)3 ColorRectTexture (gregtech.api.gui.resources.ColorRectTexture)2 gregtech.api.gui.widgets (gregtech.api.gui.widgets)2 WidgetGroup (gregtech.api.gui.widgets.WidgetGroup)2 CircleButtonWidget (gregtech.api.terminal.gui.widgets.CircleButtonWidget)2 SelectorWidget (gregtech.api.terminal.gui.widgets.SelectorWidget)2 TextEditorWidget (gregtech.api.terminal.gui.widgets.TextEditorWidget)2 TerminalDialogWidget (gregtech.api.terminal.os.TerminalDialogWidget)2 Position (gregtech.api.util.Position)2