Search in sources :

Example 36 with HorizontalLayout

use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.

the class GuiNetworkMonitor method populateList.

private void populateList() {
    requestConnectedBlocksFromServer();
    if (serverConnectedBlocks == null) {
        return;
    }
    boolean rftick = showRfPerTick.isPressed();
    long millis = System.currentTimeMillis();
    boolean recalcPerTick = previousRfMillis == 0 || (millis - previousRfMillis) > 1000;
    if (serverConnectedBlocks.equals(connectedBlocks)) {
        refreshList(recalcPerTick);
    } else {
        connectedBlocks = new HashMap<>(serverConnectedBlocks);
        Map<BlockPos, EnergyBar> oldLabelMap = labelMap;
        labelMap = new HashMap<>();
        indexToCoordinate = new HashMap<>();
        list.removeChildren();
        int index = 0;
        for (Map.Entry<BlockPos, BlockInfo> me : connectedBlocks.entrySet()) {
            BlockInfo blockInfo = me.getValue();
            BlockPos coordinate = me.getKey();
            if (mc.world.isAirBlock(coordinate)) {
                continue;
            }
            int energy = blockInfo.getEnergyStored();
            int maxEnergy = blockInfo.getMaxEnergyStored();
            int color = getTextColor(blockInfo);
            IBlockState state = mc.world.getBlockState(coordinate);
            String displayName = BlockTools.getReadableName(mc.world, coordinate);
            if (filter != null) {
                if (!displayName.toLowerCase().contains(filter)) {
                    continue;
                }
            }
            Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout());
            panel.addChild(new BlockRender(mc, this).setRenderItem(state.getBlock()));
            panel.addChild(new Label(mc, this).setColor(StyleConfig.colorTextInListNormal).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setText(displayName).setColor(color).setDesiredWidth(100));
            panel.addChild(new Label(mc, this).setColor(StyleConfig.colorTextInListNormal).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setText(BlockPosTools.toString(coordinate)).setColor(color).setDesiredWidth(75));
            EnergyBar energyLabel = oldLabelMap == null ? null : oldLabelMap.get(coordinate);
            if (energyLabel == null) {
                energyLabel = new EnergyBar(mc, this).setHorizontal();
            }
            setEnergyLabel(millis, rftick, recalcPerTick, me, energy, maxEnergy, energyLabel);
            panel.addChild(energyLabel);
            list.addChild(panel);
            labelMap.put(coordinate, energyLabel);
            indexToCoordinate.put(index, coordinate);
            index++;
        }
    }
    if (rftick && recalcPerTick) {
        previousRfMillis = millis;
        previousRf = new HashMap<>(connectedBlocks.size());
        for (Map.Entry<BlockPos, BlockInfo> me : connectedBlocks.entrySet()) {
            previousRf.put(me.getKey(), me.getValue().getEnergyStored());
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) BlockInfo(mcjty.rftools.BlockInfo) BlockPos(net.minecraft.util.math.BlockPos) HashMap(java.util.HashMap) Map(java.util.Map)

Example 37 with HorizontalLayout

use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.

the class GuiDialingDevice method setupTransmitterPanel.

private Panel setupTransmitterPanel() {
    transmitterList = new WidgetList(mc, this).setRowheight(18).setDesiredHeight(58).addSelectionEvent(new DefaultSelectionEvent() {

        @Override
        public void select(Widget parent, int index) {
            clearSelectedStatus();
            selectReceiverFromTransmitter();
        }

        @Override
        public void doubleClick(Widget parent, int index) {
            hilightSelectedTransmitter(index);
        }
    });
    Slider transmitterSlider = new Slider(mc, this).setDesiredWidth(11).setDesiredHeight(58).setVertical().setScrollable(transmitterList);
    return new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(1).setHorizontalMargin(3)).addChild(transmitterList).addChild(transmitterSlider).setDesiredHeight(64).setFilledBackground(0xff9e9e9e);
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) DefaultSelectionEvent(mcjty.lib.gui.events.DefaultSelectionEvent) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 38 with HorizontalLayout

use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.

the class GuiDialingDevice method initGui.

@Override
public void initGui() {
    super.initGui();
    int maxEnergyStored = tileEntity.getMaxEnergyStored();
    energyBar = new EnergyBar(mc, this).setFilledRectThickness(1).setHorizontal().setDesiredWidth(80).setDesiredHeight(12).setMaxValue(maxEnergyStored).setShowText(false);
    energyBar.setValue(GenericEnergyStorageTileEntity.getCurrentRF());
    Panel transmitterPanel = setupTransmitterPanel();
    Panel receiverPanel = setupReceiverPanel();
    dialButton = new Button(mc, this).setText("Dial").setTooltips("Start a connection between", "the selected transmitter", "and the selected receiver").setDesiredHeight(14).setDesiredWidth(65).addButtonEvent(parent -> dial(false));
    dialOnceButton = new Button(mc, this).setText("Dial Once").setTooltips("Dial a connection for a", "single teleport").setDesiredHeight(14).setDesiredWidth(65).addButtonEvent(parent -> dial(true));
    interruptButton = new Button(mc, this).setText("Interrupt").setTooltips("Interrupt a connection", "for the selected transmitter").setDesiredHeight(14).setDesiredWidth(65).addButtonEvent(parent -> interruptDial());
    favoriteButton = new ImageChoiceLabel(mc, this).addChoiceEvent((parent, newChoice) -> changeShowFavorite()).setDesiredWidth(10).setDesiredHeight(10);
    favoriteButton.addChoice("No", "Unfavorited receiver", guielements, 131, 19);
    favoriteButton.addChoice("Yes", "Favorited receiver", guielements, 115, 19);
    favoriteButton.setCurrentChoice(tileEntity.isShowOnlyFavorites() ? 1 : 0);
    Panel buttonPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(dialButton).addChild(dialOnceButton).addChild(interruptButton).addChild(favoriteButton).setDesiredHeight(16);
    analyzerAvailable = DialingDeviceTileEntity.isDestinationAnalyzerAvailable(mc.world, tileEntity.getPos());
    statusButton = new Button(mc, this).setText("Check").setDesiredHeight(14).setDesiredWidth(65).setEnabled(analyzerAvailable).addButtonEvent(parent -> checkStatus());
    if (analyzerAvailable) {
        statusButton.setTooltips("Check the status of", "the selected receiver");
    } else {
        statusButton.setTooltips("Check the status of", "the selected receiver", "(needs an adjacent analyzer!)");
    }
    statusLabel = new Label(mc, this);
    statusLabel.setDesiredWidth(170).setDesiredHeight(14).setFilledRectThickness(1);
    Panel statusPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(statusButton).addChild(statusLabel).setDesiredHeight(16);
    Panel toplevel = new Panel(mc, this).setFilledRectThickness(2).setLayout(new VerticalLayout().setVerticalMargin(3).setSpacing(1)).addChild(energyBar).addChild(transmitterPanel).addChild(receiverPanel).addChild(buttonPanel).addChild(statusPanel);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, DIALER_WIDTH, DIALER_HEIGHT));
    window = new mcjty.lib.gui.Window(this, toplevel);
    Keyboard.enableRepeatEvents(true);
    fromServer_receivers = null;
    fromServer_transmitters = null;
    listDirty = 0;
    clearSelectedStatus();
    requestReceivers();
    requestTransmitters();
    tileEntity.requestRfFromServer(RFTools.MODID);
}
Also used : GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) RFToolsMessages(mcjty.rftools.network.RFToolsMessages) mcjty.lib.gui.widgets(mcjty.lib.gui.widgets) HorizontalAlignment(mcjty.lib.gui.layout.HorizontalAlignment) Keyboard(org.lwjgl.input.Keyboard) Label(mcjty.lib.gui.widgets.Label) ArrayList(java.util.ArrayList) StyleConfig(mcjty.lib.base.StyleConfig) BlockPosTools(mcjty.lib.varia.BlockPosTools) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) DefaultSelectionEvent(mcjty.lib.gui.events.DefaultSelectionEvent) Panel(mcjty.lib.gui.widgets.Panel) Vec3d(net.minecraft.util.math.Vec3d) PacketRequestIntegerFromServer(mcjty.lib.network.PacketRequestIntegerFromServer) Logging(mcjty.lib.varia.Logging) RFTools(mcjty.rftools.RFTools) GenericEnergyStorageTileEntity(mcjty.lib.entity.GenericEnergyStorageTileEntity) BlockPos(net.minecraft.util.math.BlockPos) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) EmptyContainer(mcjty.lib.container.EmptyContainer) java.awt(java.awt) Argument(mcjty.lib.network.Argument) List(java.util.List) Button(mcjty.lib.gui.widgets.Button) ResourceLocation(net.minecraft.util.ResourceLocation) Label(mcjty.lib.gui.widgets.Label) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout)

Example 39 with HorizontalLayout

use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.

the class GuiMatterReceiver method initGui.

@Override
public void initGui() {
    super.initGui();
    int maxEnergyStored = tileEntity.getMaxEnergyStored();
    energyBar = new EnergyBar(mc, this).setFilledRectThickness(1).setHorizontal().setDesiredHeight(12).setDesiredWidth(80).setMaxValue(maxEnergyStored).setShowText(false);
    energyBar.setValue(GenericEnergyStorageTileEntity.getCurrentRF());
    TextField textField = new TextField(mc, this).setTooltips("Use this name to", "identify this receiver", "in the dialer").addTextEvent((parent, newText) -> setReceiverName(newText));
    textField.setText(tileEntity.getName());
    Panel namePanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(new Label(mc, this).setText("Name:")).addChild(textField).setDesiredHeight(16);
    privateSetting = new ChoiceLabel(mc, this).addChoices(ACCESS_PUBLIC, ACCESS_PRIVATE).setDesiredHeight(14).setDesiredWidth(60).setChoiceTooltip(ACCESS_PUBLIC, "Everyone can dial to this receiver").setChoiceTooltip(ACCESS_PRIVATE, "Only people in the access list below", "can dial to this receiver").addChoiceEvent((parent, newChoice) -> changeAccessMode(newChoice));
    if (tileEntity.isPrivateAccess()) {
        privateSetting.setChoice(ACCESS_PRIVATE);
    } else {
        privateSetting.setChoice(ACCESS_PUBLIC);
    }
    Panel privatePanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(new Label(mc, this).setText("Access:")).addChild(privateSetting).setDesiredHeight(16);
    allowedPlayers = new WidgetList(mc, this);
    Slider allowedPlayerSlider = new Slider(mc, this).setDesiredWidth(10).setVertical().setScrollable(allowedPlayers);
    Panel allowedPlayersPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(3).setSpacing(1)).addChild(allowedPlayers).addChild(allowedPlayerSlider).setFilledBackground(0xff9e9e9e);
    nameField = new TextField(mc, this);
    addButton = new Button(mc, this).setText("Add").setDesiredHeight(13).setDesiredWidth(34).setTooltips("Add a player to the access list").addButtonEvent(parent -> addPlayer());
    delButton = new Button(mc, this).setText("Del").setDesiredHeight(13).setDesiredWidth(34).setTooltips("Remove the selected player", "from the access list").addButtonEvent(parent -> delPlayer());
    Panel buttonPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(nameField).addChild(addButton).addChild(delButton).setDesiredHeight(16);
    Panel toplevel = new Panel(mc, this).setFilledRectThickness(2).setLayout(new VerticalLayout().setHorizontalMargin(3).setVerticalMargin(3).setSpacing(1)).addChild(energyBar).addChild(namePanel).addChild(privatePanel).addChild(allowedPlayersPanel).addChild(buttonPanel);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, MATTER_WIDTH, MATTER_HEIGHT));
    window = new Window(this, toplevel);
    Keyboard.enableRepeatEvents(true);
    listDirty = 0;
    requestPlayers();
    tileEntity.requestRfFromServer(RFTools.MODID);
}
Also used : GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) RFToolsMessages(mcjty.rftools.network.RFToolsMessages) TextField(mcjty.lib.gui.widgets.TextField) java.util(java.util) mcjty.lib.gui.widgets(mcjty.lib.gui.widgets) HorizontalAlignment(mcjty.lib.gui.layout.HorizontalAlignment) PacketGetPlayers(mcjty.rftools.network.PacketGetPlayers) GenericEnergyStorageTileEntity(mcjty.lib.entity.GenericEnergyStorageTileEntity) Keyboard(org.lwjgl.input.Keyboard) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) Label(mcjty.lib.gui.widgets.Label) StyleConfig(mcjty.lib.base.StyleConfig) EmptyContainer(mcjty.lib.container.EmptyContainer) Window(mcjty.lib.gui.Window) java.awt(java.awt) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Argument(mcjty.lib.network.Argument) List(java.util.List) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) RFTools(mcjty.rftools.RFTools) Window(mcjty.lib.gui.Window) Label(mcjty.lib.gui.widgets.Label) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) TextField(mcjty.lib.gui.widgets.TextField) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout)

Example 40 with HorizontalLayout

use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.

the class GuiRelay method createSubPanel.

private Panel createSubPanel(int side, String redstoneState) {
    String labelText = String.valueOf(RelayTileEntity.DUNSWE.charAt(side));
    int rf;
    boolean input;
    if ("Off".equals(redstoneState)) {
        rf = tileEntity.getRfOff(side);
        input = tileEntity.isInputModeOff(side);
    } else {
        rf = tileEntity.getRfOn(side);
        input = tileEntity.isInputModeOn(side);
    }
    ImageChoiceLabel inputOutput = new ImageChoiceLabel(mc, this).setDesiredWidth(14).setDesiredHeight(14).addChoice("Output", "Side set to output mode", iconGuiElements, 80, 16).addChoice("Input", "Side set to input mode", iconGuiElements, 96, 16).addChoiceEvent((parent, newChoice) -> changeSettings());
    String key = labelText + redstoneState;
    if (input) {
        inputOutput.setCurrentChoice("Input");
    } else {
        inputOutput.setCurrentChoice("Output");
    }
    inputOutputs.put(key, inputOutput);
    TextField energyField = new TextField(mc, this).setTooltips("Amount of RF to input/output", "when redstone is " + redstoneState).setDesiredWidth(42).setDesiredHeight(14).addTextEvent((parent, newText) -> adjustEnergy((TextField) parent, 0));
    energyField.setText(String.valueOf(rf));
    Button sub100 = createEnergyOffsetButton(energyField, "-", -500);
    Button add100 = createEnergyOffsetButton(energyField, "+", 500);
    Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(1)).addChild(inputOutput).addChild(sub100).addChild(energyField).addChild(add100);
    energyValues.put(key, energyField);
    return panel;
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) TextField(mcjty.lib.gui.widgets.TextField) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Aggregations

HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)75 Panel (mcjty.lib.gui.widgets.Panel)55 Window (mcjty.lib.gui.Window)38 Label (mcjty.lib.gui.widgets.Label)36 VerticalLayout (mcjty.lib.gui.layout.VerticalLayout)32 TextField (mcjty.lib.gui.widgets.TextField)25 mcjty.lib.gui.widgets (mcjty.lib.gui.widgets)24 java.awt (java.awt)21 RFToolsMessages (mcjty.rftools.network.RFToolsMessages)21 List (java.util.List)20 GenericGuiContainer (mcjty.lib.container.GenericGuiContainer)20 Button (mcjty.lib.gui.widgets.Button)20 Argument (mcjty.lib.network.Argument)19 RFTools (mcjty.rftools.RFTools)19 BlockPos (net.minecraft.util.math.BlockPos)19 HorizontalAlignment (mcjty.lib.gui.layout.HorizontalAlignment)18 StyleConfig (mcjty.lib.base.StyleConfig)16 ResourceLocation (net.minecraft.util.ResourceLocation)15 Minecraft (net.minecraft.client.Minecraft)14 EmptyContainer (mcjty.lib.container.EmptyContainer)13