Search in sources :

Example 26 with HorizontalLayout

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

the class MachineInformationClientScreenModule method addMonitorPanel.

private void addMonitorPanel(Minecraft mc, Gui gui, final NBTTagCompound currentData, Panel panel) {
    Panel monitorPanel = new Panel(mc, gui).setLayout(new HorizontalLayout()).setDesiredHeight(16);
    String monitoring;
    if (currentData.hasKey("monitorx")) {
        if (currentData.hasKey("monitordim")) {
            this.dim = currentData.getInteger("monitordim");
        } else {
            // Compatibility reasons
            this.dim = currentData.getInteger("dim");
        }
        World world = mc.player.getEntityWorld();
        if (dim == world.provider.getDimension()) {
            int x = currentData.getInteger("monitorx");
            int y = currentData.getInteger("monitory");
            int z = currentData.getInteger("monitorz");
            monitoring = currentData.getString("monitorname");
            Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock();
            monitorPanel.addChild(new BlockRender(mc, gui).setRenderItem(block)).setDesiredWidth(20);
            monitorPanel.addChild(new Label(mc, gui).setText(x + "," + y + "," + z).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setDesiredWidth(150));
        } else {
            monitoring = "<unreachable>";
        }
    } else {
        monitoring = "<not set>";
    }
    panel.addChild(monitorPanel);
    panel.addChild(new Label(mc, gui).setText(monitoring));
}
Also used : Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) IModuleDataString(mcjty.rftools.api.screens.data.IModuleDataString) World(net.minecraft.world.World) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 27 with HorizontalLayout

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

the class MachineInformationClientScreenModule method addOptionPanel.

private void addOptionPanel(Minecraft mc, Gui gui, final NBTTagCompound currentData, final IModuleGuiChanged moduleGuiChanged, Panel panel) {
    Panel optionPanel = new Panel(mc, gui).setLayout(new HorizontalLayout()).setDesiredHeight(16);
    final Map<String, Integer> choiceToIndex = new HashMap<>();
    final ChoiceLabel tagButton = new ChoiceLabel(mc, gui).setDesiredHeight(16).setDesiredWidth(80);
    optionPanel.addChild(tagButton);
    // int dim = currentData.getInteger("monitordim");
    int x = currentData.getInteger("monitorx");
    int y = currentData.getInteger("monitory");
    int z = currentData.getInteger("monitorz");
    TileEntity tileEntity = mc.world.getTileEntity(new BlockPos(x, y, z));
    if (tileEntity instanceof MachineInformation) {
        int current = currentData.getInteger("monitorTag");
        MachineInformation information = (MachineInformation) tileEntity;
        String currentTag = null;
        for (int i = 0; i < information.getTagCount(); i++) {
            String tag = information.getTagName(i);
            choiceToIndex.put(tag, i);
            tagButton.addChoices(tag);
            tagButton.setChoiceTooltip(tag, information.getTagDescription(i));
            if (current == i) {
                currentTag = tag;
            }
        }
        if (currentTag != null) {
            tagButton.setChoice(currentTag);
        }
    }
    tagButton.addChoiceEvent((parent, newChoice) -> {
        String choice = tagButton.getCurrentChoice();
        Integer index = choiceToIndex.get(choice);
        if (index != null) {
            currentData.setInteger("monitorTag", index);
        }
        moduleGuiChanged.updateData();
    });
    panel.addChild(optionPanel);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) MachineInformation(mcjty.lib.api.MachineInformation) HashMap(java.util.HashMap) BlockPos(net.minecraft.util.math.BlockPos) IModuleDataString(mcjty.rftools.api.screens.data.IModuleDataString) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 28 with HorizontalLayout

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

the class GuiSecurityManager method initGui.

@Override
public void initGui() {
    super.initGui();
    players = new WidgetList(mc, this);
    Slider allowedPlayerSlider = new Slider(mc, this).setDesiredWidth(10).setVertical().setScrollable(players);
    Panel allowedPlayersPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(3).setSpacing(1)).addChild(players).addChild(allowedPlayerSlider).setLayoutHint(new PositionalLayout.PositionalHint(72, 5, SECURITYMANAGER_WIDTH - 76, 96));
    nameField = new TextField(mc, this).setDesiredHeight(15);
    addButton = new Button(mc, this).setText("Add").setDesiredHeight(14).setDesiredWidth(34).setTooltips("Add a player to the access list").addButtonEvent(parent -> addPlayer());
    delButton = new Button(mc, this).setText("Del").setDesiredHeight(14).setDesiredWidth(34).setTooltips("Remove the selected player", "from the access list").addButtonEvent(parent -> delPlayer());
    Panel buttonPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(3).setSpacing(1)).addChild(nameField).addChild(addButton).addChild(delButton).setDesiredHeight(16).setLayoutHint(new PositionalLayout.PositionalHint(72, 100, SECURITYMANAGER_WIDTH - 76, 14));
    channelNameField = new TextField(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(8, 27, 60, 14)).addTextEvent((parent, newText) -> updateChannelName());
    blacklistMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(10, 44, 16, 16)).setTooltips("Black or whitelist mode").addChoiceEvent((parent, newChoice) -> updateSettings());
    blacklistMode.addChoice("White", "Whitelist players", guiElements, 15 * 16, 32);
    blacklistMode.addChoice("Black", "Blacklist players", guiElements, 14 * 16, 32);
    Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout()).addChild(allowedPlayersPanel).addChild(buttonPanel).addChild(channelNameField).addChild(blacklistMode);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    window = new Window(this, toplevel);
    Keyboard.enableRepeatEvents(true);
    channelFromServer = null;
}
Also used : GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) RFToolsMessages(mcjty.rftools.network.RFToolsMessages) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Rectangle(java.awt.Rectangle) mcjty.lib.gui.widgets(mcjty.lib.gui.widgets) HorizontalAlignment(mcjty.lib.gui.layout.HorizontalAlignment) Keyboard(org.lwjgl.input.Keyboard) Arguments(mcjty.lib.network.Arguments) StyleConfig(mcjty.lib.base.StyleConfig) Window(mcjty.lib.gui.Window) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Argument(mcjty.lib.network.Argument) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Slot(net.minecraft.inventory.Slot) ResourceLocation(net.minecraft.util.ResourceLocation) CommandHandler(mcjty.rftools.CommandHandler) RFTools(mcjty.rftools.RFTools) Window(mcjty.lib.gui.Window) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Rectangle(java.awt.Rectangle) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 29 with HorizontalLayout

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

the class GuiShield method populateFilters.

private void populateFilters() {
    List<ShieldFilter> newFilters = new ArrayList<>(fromServer_filters);
    if (newFilters.equals(filters)) {
        return;
    }
    filters = new ArrayList<>(newFilters);
    filterList.removeChildren();
    for (ShieldFilter filter : filters) {
        String n;
        if ("player".equals(filter.getFilterName())) {
            PlayerFilter playerFilter = (PlayerFilter) filter;
            if (playerFilter.getName() == null || playerFilter.getName().isEmpty()) {
                n = "players";
            } else {
                n = "player " + playerFilter.getName();
            }
        } else {
            n = filter.getFilterName();
        }
        Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout());
        panel.addChild(new Label(mc, this).setText(n).setColor(StyleConfig.colorTextInListNormal).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setDesiredWidth(85));
        String actionName;
        boolean solid = (filter.getAction() & ShieldFilter.ACTION_SOLID) != 0;
        boolean damage = (filter.getAction() & ShieldFilter.ACTION_DAMAGE) != 0;
        if (solid && damage) {
            actionName = ACTION_SOLIDDAMAGE;
        } else if (solid) {
            actionName = ACTION_SOLID;
        } else if (damage) {
            actionName = ACTION_DAMAGE;
        } else {
            actionName = ACTION_PASS;
        }
        panel.addChild(new Label(mc, this).setText(actionName).setColor(StyleConfig.colorTextInListNormal).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT));
        filterList.addChild(panel);
    }
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) ArrayList(java.util.ArrayList) Label(mcjty.lib.gui.widgets.Label) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 30 with HorizontalLayout

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

the class GuiChamberDetails method populateLists.

private void populateLists() {
    blockList.removeChildren();
    if (items == null) {
        return;
    }
    int totalCost = 0;
    for (Map.Entry<IBlockState, Integer> entry : items.entrySet()) {
        IBlockState bm = entry.getKey();
        int count = entry.getValue();
        int cost = costs.get(bm);
        Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout()).setDesiredHeight(16);
        ItemStack stack;
        if (stacks.containsKey(bm)) {
            stack = stacks.get(bm);
        } else {
            // @todo uses meta
            stack = new ItemStack(bm.getBlock(), 0, bm.getBlock().getMetaFromState(bm));
        }
        BlockRender blockRender = new BlockRender(mc, this).setRenderItem(stack).setOffsetX(-1).setOffsetY(-1);
        Label nameLabel = new Label(mc, this).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setColor(StyleConfig.colorTextInListNormal);
        if (stack.getItem() == null) {
            nameLabel.setText("?").setDesiredWidth(160);
        } else {
            nameLabel.setText(stack.getDisplayName()).setDesiredWidth(160);
        }
        Label countLabel = new Label(mc, this).setText(String.valueOf(count)).setColor(StyleConfig.colorTextInListNormal);
        countLabel.setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setDesiredWidth(50);
        Label costLabel = new Label(mc, this).setColor(StyleConfig.colorTextInListNormal);
        costLabel.setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT);
        if (cost == -1) {
            costLabel.setText("NOT MOVABLE!");
        } else {
            costLabel.setText("Move Cost " + cost + " RF");
            totalCost += cost;
        }
        panel.addChild(blockRender).addChild(nameLabel).addChild(countLabel).addChild(costLabel);
        blockList.addChild(panel);
    }
    int totalCostEntities = 0;
    RenderHelper.rot += .5f;
    for (Map.Entry<String, Integer> entry : entities.entrySet()) {
        String className = entry.getKey();
        int count = entry.getValue();
        int cost = entityCosts.get(className);
        Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout()).setDesiredHeight(16);
        String entityName = "<?>";
        Entity entity = null;
        if (realEntities.containsKey(className)) {
            entity = realEntities.get(className);
            entityName = EntityList.getEntityString(entity);
            if (entity instanceof EntityItem) {
                EntityItem entityItem = (EntityItem) entity;
                if (!entityItem.getItem().isEmpty()) {
                    String displayName = entityItem.getItem().getDisplayName();
                    entityName += " (" + displayName + ")";
                }
            }
        } else {
            try {
                Class<?> aClass = Class.forName(className);
                entity = (Entity) aClass.getConstructor(World.class).newInstance(mc.world);
                entityName = aClass.getSimpleName();
            } catch (ClassNotFoundException e) {
            } catch (InstantiationException e) {
            } catch (IllegalAccessException e) {
            } catch (InvocationTargetException e) {
            } catch (NoSuchMethodException e) {
            }
        }
        if (playerNames.containsKey(className)) {
            entityName = playerNames.get(className);
        }
        BlockRender blockRender = new BlockRender(mc, this).setRenderItem(entity).setOffsetX(-1).setOffsetY(-1);
        Label nameLabel = new Label(mc, this).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT);
        nameLabel.setText(entityName).setDesiredWidth(160);
        Label countLabel = new Label(mc, this).setText(String.valueOf(count));
        countLabel.setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setDesiredWidth(50);
        Label costLabel = new Label(mc, this);
        costLabel.setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT);
        if (cost == -1) {
            costLabel.setText("NOT MOVABLE!");
        } else {
            costLabel.setText("Move Cost " + cost + " RF");
            totalCostEntities += cost;
        }
        panel.addChild(blockRender).addChild(nameLabel).addChild(countLabel).addChild(costLabel);
        blockList.addChild(panel);
    }
    infoLabel.setText("Total cost blocks: " + totalCost + " RF");
    info2Label.setText("Total cost entities: " + totalCostEntities + " RF");
}
Also used : Entity(net.minecraft.entity.Entity) IBlockState(net.minecraft.block.state.IBlockState) World(net.minecraft.world.World) InvocationTargetException(java.lang.reflect.InvocationTargetException) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) ItemStack(net.minecraft.item.ItemStack) HashMap(java.util.HashMap) Map(java.util.Map) EntityItem(net.minecraft.entity.item.EntityItem)

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