Search in sources :

Example 1 with ITabInfo

use of gregtech.api.gui.widgets.tab.ITabInfo in project GregTech by GregTechCE.

the class TabGroup method mouseClicked.

@Override
public boolean mouseClicked(int mouseX, int mouseY, int button) {
    super.mouseClicked(mouseX, mouseY, button);
    Tuple<ITabInfo, int[]> tabOnMouse = getTabOnMouse(mouseX, mouseY);
    if (tabOnMouse != null) {
        ITabInfo tabInfo = tabOnMouse.getFirst();
        int tabIndex = tabInfos.indexOf(tabInfo);
        if (selectedTabIndex != tabIndex) {
            setSelectedTab(tabIndex);
            playButtonClickSound();
            writeClientAction(2, buf -> buf.writeVarInt(tabIndex));
            return true;
        }
    }
    return false;
}
Also used : ITabInfo(gregtech.api.gui.widgets.tab.ITabInfo)

Example 2 with ITabInfo

use of gregtech.api.gui.widgets.tab.ITabInfo in project GregTech by GregTechCE.

the class TabGroup method drawInForeground.

@Override
public void drawInForeground(int mouseX, int mouseY) {
    super.drawInForeground(mouseX, mouseY);
    Tuple<ITabInfo, int[]> tabOnMouse = getTabOnMouse(mouseX, mouseY);
    if (tabOnMouse != null) {
        int[] tabSizes = tabOnMouse.getSecond();
        ITabInfo tabInfo = tabOnMouse.getFirst();
        boolean isSelected = tabInfos.get(selectedTabIndex) == tabInfo;
        tabInfo.renderHoverText(tabSizes[0], tabSizes[1], tabSizes[2], tabSizes[3], sizes.getWidth(), sizes.getHeight(), isSelected, mouseX, mouseY);
    }
}
Also used : ITabInfo(gregtech.api.gui.widgets.tab.ITabInfo)

Example 3 with ITabInfo

use of gregtech.api.gui.widgets.tab.ITabInfo in project GregTech by GregTechCE.

the class TabGroup method getTabOnMouse.

private Tuple<ITabInfo, int[]> getTabOnMouse(int mouseX, int mouseY) {
    for (int tabIndex = 0; tabIndex < tabInfos.size(); tabIndex++) {
        ITabInfo tabInfo = tabInfos.get(tabIndex);
        int[] tabSizes = tabListRenderer.getTabPos(tabIndex, sizes.getWidth(), sizes.getHeight());
        tabSizes[0] += getPosition().x;
        tabSizes[1] += getPosition().y;
        if (isMouseOverTab(mouseX, mouseY, tabSizes)) {
            return new Tuple<>(tabInfo, tabSizes);
        }
    }
    return null;
}
Also used : ITabInfo(gregtech.api.gui.widgets.tab.ITabInfo) Tuple(net.minecraft.util.Tuple)

Aggregations

ITabInfo (gregtech.api.gui.widgets.tab.ITabInfo)3 Tuple (net.minecraft.util.Tuple)1