Search in sources :

Example 6 with IChannelType

use of mcjty.xnet.api.channels.IChannelType in project XNet by McJty.

the class GuiController method refreshChannelEditor.

private void refreshChannelEditor() {
    if (!listsReady()) {
        return;
    }
    if (editingChannel != -1 && showingChannel != editingChannel) {
        showingChannel = editingChannel;
        channelButtons[editingChannel].setPressed(true);
        channelEditPanel.removeChildren();
        if (channelButtons[editingChannel].isPressed()) {
            ChannelClientInfo info = fromServer_channels.get(editingChannel);
            if (info != null) {
                ChannelEditorPanel editor = new ChannelEditorPanel(channelEditPanel, mc, this, editingChannel);
                editor.label("Channel " + (editingChannel + 1)).shift(5).toggle(TAG_ENABLED, "Enable processing on this channel", info.isEnabled()).shift(5).text(TAG_NAME, "Channel name", info.getChannelName(), 65);
                info.getChannelSettings().createGui(editor);
                Button remove = new Button(mc, this).setText("x").setTextOffset(0, -1).setTooltips("Remove this channel").setLayoutHint(new PositionalLayout.PositionalHint(151, 1, 9, 10)).addButtonEvent(parent -> removeChannel());
                channelEditPanel.addChild(remove);
                editor.setState(info.getChannelSettings());
            } else {
                ChoiceLabel type = new ChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(5, 12, 95, 14));
                for (IChannelType channelType : XNet.xNetApi.getChannels().values()) {
                    // Show names?
                    type.addChoices(channelType.getID());
                }
                Button create = new Button(mc, this).setText("Create").setLayoutHint(new PositionalLayout.PositionalHint(100, 12, 53, 14)).addButtonEvent(parent -> createChannel(type.getCurrentChoice()));
                channelEditPanel.addChild(type).addChild(create);
            }
        }
    } else if (showingChannel != -1 && editingChannel == -1) {
        showingChannel = -1;
        channelEditPanel.removeChildren();
    }
}
Also used : ChannelClientInfo(mcjty.xnet.clientinfo.ChannelClientInfo) Button(mcjty.lib.gui.widgets.Button) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) IChannelType(mcjty.xnet.api.channels.IChannelType)

Aggregations

IChannelType (mcjty.xnet.api.channels.IChannelType)6 ChannelInfo (mcjty.xnet.logic.ChannelInfo)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)2 SidedConsumer (mcjty.xnet.api.keys.SidedConsumer)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 EnumFacing (net.minecraft.util.EnumFacing)2 BlockPos (net.minecraft.util.math.BlockPos)2 java.util (java.util)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 GenericTileEntity (mcjty.lib.entity.GenericTileEntity)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 TextField (mcjty.lib.gui.widgets.TextField)1 Argument (mcjty.lib.network.Argument)1 BlockPosTools (mcjty.lib.varia.BlockPosTools)1 Type (mcjty.typed.Type)1