Search in sources :

Example 1 with IndicatorIcon

use of mcjty.xnet.api.gui.IndicatorIcon in project RFTools by McJty.

the class StorageConnectorSettings method getIndicatorIcon.

@Nullable
@Override
public IndicatorIcon getIndicatorIcon() {
    switch(mode) {
        case INVENTORY:
            boolean inputBlocked = accessSettings.inputBlocked();
            boolean outputBlocked = accessSettings.outputBlocked();
            if (inputBlocked && outputBlocked) {
                return new IndicatorIcon(StorageChannelSettings.iconGuiElements, 13, 75, 13, 10);
            } else if (inputBlocked) {
                return new IndicatorIcon(StorageChannelSettings.iconGuiElements, 13, 48, 13, 10);
            } else if (outputBlocked) {
                return new IndicatorIcon(StorageChannelSettings.iconGuiElements, 0, 48, 13, 10);
            } else {
                return new IndicatorIcon(StorageChannelSettings.iconGuiElements, 13, 57, 13, 10);
            }
        case STORAGE:
            return new IndicatorIcon(StorageChannelSettings.iconGuiElements, 13, 66, 13, 10);
    }
    return null;
}
Also used : IndicatorIcon(mcjty.xnet.api.gui.IndicatorIcon) Nullable(javax.annotation.Nullable)

Example 2 with IndicatorIcon

use of mcjty.xnet.api.gui.IndicatorIcon in project XNet by McJty.

the class GuiController method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float v, int x1, int x2) {
    requestListsIfNeeded();
    populateList();
    refreshChannelEditor();
    refreshConnectorEditor();
    if (fromServer_channels != null) {
        for (int i = 0; i < MAX_CHANNELS; i++) {
            String channel = String.valueOf(i + 1);
            ChannelClientInfo info = fromServer_channels.get(i);
            if (info != null) {
                IndicatorIcon icon = info.getChannelSettings().getIndicatorIcon();
                if (icon != null) {
                    channelButtons[i].setImage(icon.getImage(), icon.getU(), icon.getV(), icon.getIw(), icon.getIh());
                }
                String indicator = info.getChannelSettings().getIndicator();
                if (indicator != null) {
                    channelButtons[i].setText(indicator + channel);
                } else {
                    channelButtons[i].setText(channel);
                }
            } else {
                channelButtons[i].setImage(null, 0, 0, 0, 0);
                channelButtons[i].setText(channel);
            }
        }
    }
    drawWindow();
    int channel = getSelectedChannel();
    if (channel != -1) {
        int x = (int) window.getToplevel().getBounds().getX();
        int y = (int) window.getToplevel().getBounds().getY();
        RenderHelper.drawVerticalGradientRect(x + channel * 14 + 41, y + 22, x + channel * 14 + 41 + 12, y + 230, 0x33aaffff, 0x33aaffff);
    }
    int currentRF = GenericEnergyStorageTileEntity.getCurrentRF();
    energyBar.setValue(currentRF);
    tileEntity.requestRfFromServer(XNet.MODID);
}
Also used : ChannelClientInfo(mcjty.xnet.clientinfo.ChannelClientInfo) IndicatorIcon(mcjty.xnet.api.gui.IndicatorIcon)

Example 3 with IndicatorIcon

use of mcjty.xnet.api.gui.IndicatorIcon in project XNet by McJty.

the class GuiController method populateList.

private void populateList() {
    if (!listsReady()) {
        return;
    }
    if (!needsRefresh) {
        return;
    }
    needsRefresh = false;
    connectorList.removeChildren();
    int sel = connectorList.getSelected();
    BlockPos prevPos = null;
    String selectedText = searchBar.getText().trim().toLowerCase();
    for (ConnectedBlockClientInfo connectedBlock : fromServer_connectedBlocks) {
        SidedPos sidedPos = connectedBlock.getPos();
        BlockPos coordinate = sidedPos.getPos();
        String name = connectedBlock.getName();
        String blockUnlocName = connectedBlock.getBlockUnlocName();
        String blockName = I18n.format(blockUnlocName).trim();
        int color = StyleConfig.colorTextInListNormal;
        Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0).setSpacing(0));
        if (!selectedText.isEmpty()) {
            if (blockName.toLowerCase().contains(selectedText)) {
                panel.setFilledBackground(0xffddeeaa);
            }
        }
        BlockRender br;
        if (coordinate.equals(prevPos)) {
            br = new BlockRender(mc, this);
        } else {
            br = new BlockRender(mc, this).setRenderItem(connectedBlock.getConnectedBlock());
            prevPos = coordinate;
        }
        br.setUserObject("block");
        panel.addChild(br);
        if (!name.isEmpty()) {
            br.setTooltips(TextFormatting.GREEN + "Connector: " + TextFormatting.WHITE + name, TextFormatting.GREEN + "Block: " + TextFormatting.WHITE + blockName, TextFormatting.GREEN + "Position: " + TextFormatting.WHITE + BlockPosTools.toString(coordinate), TextFormatting.WHITE + "(doubleclick to highlight)");
        } else {
            br.setTooltips(TextFormatting.GREEN + "Block: " + TextFormatting.WHITE + blockName, TextFormatting.GREEN + "Position: " + TextFormatting.WHITE + BlockPosTools.toString(coordinate), TextFormatting.WHITE + "(doubleclick to highlight)");
        }
        panel.addChild(new Label(mc, this).setText(sidedPos.getSide().getName().substring(0, 1).toUpperCase()).setColor(color).setDesiredWidth(18));
        for (int i = 0; i < MAX_CHANNELS; i++) {
            Button but = new Button(mc, this).setDesiredWidth(14);
            ChannelClientInfo info = fromServer_channels.get(i);
            if (info != null) {
                ConnectorClientInfo clientInfo = findClientInfo(info, sidedPos);
                if (clientInfo != null) {
                    IndicatorIcon icon = clientInfo.getConnectorSettings().getIndicatorIcon();
                    if (icon != null) {
                        but.setImage(icon.getImage(), icon.getU(), icon.getV(), icon.getIw(), icon.getIh());
                    }
                    String indicator = clientInfo.getConnectorSettings().getIndicator();
                    but.setText(indicator != null ? indicator : "");
                }
            }
            int finalI = i;
            but.addButtonEvent(parent -> {
                selectConnectorEditor(sidedPos, finalI);
            });
            panel.addChild(but);
        }
        connectorList.addChild(panel);
    }
    connectorList.setSelected(sel);
}
Also used : Label(mcjty.lib.gui.widgets.Label) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel) ConnectedBlockClientInfo(mcjty.xnet.clientinfo.ConnectedBlockClientInfo) ChannelClientInfo(mcjty.xnet.clientinfo.ChannelClientInfo) SidedPos(mcjty.xnet.api.keys.SidedPos) Button(mcjty.lib.gui.widgets.Button) BlockPos(net.minecraft.util.math.BlockPos) IndicatorIcon(mcjty.xnet.api.gui.IndicatorIcon) ConnectorClientInfo(mcjty.xnet.clientinfo.ConnectorClientInfo)

Aggregations

IndicatorIcon (mcjty.xnet.api.gui.IndicatorIcon)3 ChannelClientInfo (mcjty.xnet.clientinfo.ChannelClientInfo)2 Nullable (javax.annotation.Nullable)1 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)1 Button (mcjty.lib.gui.widgets.Button)1 Label (mcjty.lib.gui.widgets.Label)1 Panel (mcjty.lib.gui.widgets.Panel)1 SidedPos (mcjty.xnet.api.keys.SidedPos)1 ConnectedBlockClientInfo (mcjty.xnet.clientinfo.ConnectedBlockClientInfo)1 ConnectorClientInfo (mcjty.xnet.clientinfo.ConnectorClientInfo)1 BlockPos (net.minecraft.util.math.BlockPos)1