Search in sources :

Example 1 with ScreenModuleGuiBuilder

use of mcjty.rftools.blocks.screens.modulesclient.helper.ScreenModuleGuiBuilder in project RFTools by McJty.

the class GuiScreen method installModuleGui.

private void installModuleGui(int i, final ItemStack slot, IModuleProvider moduleProvider, Class<? extends IClientScreenModule> clientScreenModuleClass) {
    buttons[i].setEnabled(true);
    toplevel.removeChild(modulePanels[i]);
    try {
        IClientScreenModule<?> clientScreenModule = clientScreenModuleClass.newInstance();
        clientScreenModules[i] = clientScreenModule;
    } catch (InstantiationException e) {
        throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    }
    NBTTagCompound tagCompound = slot.getTagCompound();
    if (tagCompound == null) {
        tagCompound = new NBTTagCompound();
    }
    final NBTTagCompound finalTagCompound = tagCompound;
    final int finalI = i;
    ScreenModuleGuiBuilder guiBuilder = new ScreenModuleGuiBuilder(mc, this, tagCompound, () -> {
        slot.setTagCompound(finalTagCompound);
        tileEntity.setInventorySlotContents(finalI, slot);
        RFToolsMessages.INSTANCE.sendToServer(new PacketModuleUpdate(tileEntity.getPos(), finalI, finalTagCompound));
    });
    clientScreenModules[i].createGui(guiBuilder);
    modulePanels[i] = guiBuilder.build();
    modulePanels[i].setLayoutHint(new PositionalLayout.PositionalHint(80, 8, 170, 114));
    modulePanels[i].setFilledRectThickness(-2).setFilledBackground(0xff8b8b8b);
    toplevel.addChild(modulePanels[i]);
    buttons[i].setText(moduleProvider.getName());
}
Also used : ScreenModuleGuiBuilder(mcjty.rftools.blocks.screens.modulesclient.helper.ScreenModuleGuiBuilder) PacketModuleUpdate(mcjty.rftools.blocks.screens.network.PacketModuleUpdate) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout)

Example 2 with ScreenModuleGuiBuilder

use of mcjty.rftools.blocks.screens.modulesclient.helper.ScreenModuleGuiBuilder in project RFTools by McJty.

the class MachineInformationClientScreenModule method createGui.

@Override
public void createGui(IModuleGuiBuilder guiBuilder) {
    // @todo Hacky, solve this better
    ScreenModuleGuiBuilder screenModuleGuiBuilder = (ScreenModuleGuiBuilder) guiBuilder;
    Minecraft mc = Minecraft.getMinecraft();
    Gui gui = screenModuleGuiBuilder.getGui();
    NBTTagCompound currentData = screenModuleGuiBuilder.getCurrentData();
    IModuleGuiChanged moduleGuiChanged = screenModuleGuiBuilder.getModuleGuiChanged();
    Panel panel = new Panel(mc, gui).setLayout(new VerticalLayout());
    TextField textField = new TextField(mc, gui).setDesiredHeight(16).setTooltips("Text to use as label").addTextEvent((parent, newText) -> {
        currentData.setString("text", newText);
        moduleGuiChanged.updateData();
    });
    panel.addChild(textField);
    addColorPanel(mc, gui, currentData, moduleGuiChanged, panel);
    addOptionPanel(mc, gui, currentData, moduleGuiChanged, panel);
    addMonitorPanel(mc, gui, currentData, panel);
    if (currentData != null) {
        textField.setText(currentData.getString("text"));
    }
    screenModuleGuiBuilder.overridePanel(panel);
}
Also used : ScreenModuleGuiBuilder(mcjty.rftools.blocks.screens.modulesclient.helper.ScreenModuleGuiBuilder) IModuleGuiChanged(mcjty.rftools.blocks.screens.IModuleGuiChanged) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) Gui(net.minecraft.client.gui.Gui) Minecraft(net.minecraft.client.Minecraft)

Aggregations

ScreenModuleGuiBuilder (mcjty.rftools.blocks.screens.modulesclient.helper.ScreenModuleGuiBuilder)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)1 VerticalLayout (mcjty.lib.gui.layout.VerticalLayout)1 IModuleGuiChanged (mcjty.rftools.blocks.screens.IModuleGuiChanged)1 PacketModuleUpdate (mcjty.rftools.blocks.screens.network.PacketModuleUpdate)1 Minecraft (net.minecraft.client.Minecraft)1 Gui (net.minecraft.client.gui.Gui)1