Search in sources :

Example 21 with Argument

use of mcjty.lib.network.Argument in project XNet by McJty.

the class GuiController method removeChannel.

private void removeChannel() {
    sendServerCommand(XNetMessages.INSTANCE, TileEntityController.CMD_REMOVECHANNEL, new Argument("index", getSelectedChannel()));
    refresh();
}
Also used : Argument(mcjty.lib.network.Argument)

Example 22 with Argument

use of mcjty.lib.network.Argument in project XNet by McJty.

the class GuiController method createChannel.

private void createChannel(String typeId) {
    sendServerCommand(XNetMessages.INSTANCE, TileEntityController.CMD_CREATECHANNEL, new Argument("index", getSelectedChannel()), new Argument("type", typeId));
    refresh();
}
Also used : Argument(mcjty.lib.network.Argument)

Example 23 with Argument

use of mcjty.lib.network.Argument in project RFToolsControl by McJty.

the class GuiProcessor method setupVariableListPanel.

private Panel setupVariableListPanel() {
    fluidList = new WidgetList(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(0, 0, 62, 65)).setPropagateEventsToChildren(true).setInvisibleSelection(true).setDrawHorizontalLines(false).setUserObject("allowed");
    fluidList.addSelectionEvent(new SelectionEvent() {

        @Override
        public void select(Widget parent, int i) {
            int setupMode = getSetupMode();
            if (setupMode != -1) {
                CardInfo cardInfo = tileEntity.getCardInfo(setupMode);
                int varAlloc = cardInfo.getVarAllocation();
                int itemAlloc = cardInfo.getItemAllocation();
                int fluidAlloc = cardInfo.getFluidAllocation();
                int idx = fluidListMapping[i];
                boolean allocated = ((fluidAlloc >> idx) & 1) != 0;
                allocated = !allocated;
                if (allocated) {
                    fluidAlloc = fluidAlloc | (1 << idx);
                } else {
                    fluidAlloc = fluidAlloc & ~(1 << idx);
                }
                cardInfo.setFluidAllocation(fluidAlloc);
                sendServerCommand(RFToolsCtrlMessages.INSTANCE, ProcessorTileEntity.CMD_ALLOCATE, new Argument("card", setupMode), new Argument("items", itemAlloc), new Argument("vars", varAlloc), new Argument("fluids", fluidAlloc));
                updateFluidList();
                fluidList.setSelected(-1);
            }
        }

        @Override
        public void doubleClick(Widget parent, int index) {
        }
    });
    Slider fluidSlider = new Slider(mc, this).setVertical().setScrollable(fluidList).setLayoutHint(new PositionalLayout.PositionalHint(62, 0, 9, 65)).setUserObject("allowed");
    updateFluidList();
    variableList = new WidgetList(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(0, 67, 62, 161)).setPropagateEventsToChildren(true).setInvisibleSelection(true).setDrawHorizontalLines(false).setUserObject("allowed");
    variableList.addSelectionEvent(new SelectionEvent() {

        @Override
        public void select(Widget parent, int i) {
            int setupMode = getSetupMode();
            if (setupMode != -1) {
                CardInfo cardInfo = tileEntity.getCardInfo(setupMode);
                int varAlloc = cardInfo.getVarAllocation();
                int itemAlloc = cardInfo.getItemAllocation();
                int fluidAlloc = cardInfo.getFluidAllocation();
                boolean allocated = ((varAlloc >> i) & 1) != 0;
                allocated = !allocated;
                if (allocated) {
                    varAlloc = varAlloc | (1 << i);
                } else {
                    varAlloc = varAlloc & ~(1 << i);
                }
                cardInfo.setVarAllocation(varAlloc);
                sendServerCommand(RFToolsCtrlMessages.INSTANCE, ProcessorTileEntity.CMD_ALLOCATE, new Argument("card", setupMode), new Argument("items", itemAlloc), new Argument("vars", varAlloc), new Argument("fluids", fluidAlloc));
                updateVariableList();
                variableList.setSelected(-1);
            }
        }

        @Override
        public void doubleClick(Widget parent, int index) {
        }
    });
    Slider varSlider = new Slider(mc, this).setVertical().setScrollable(variableList).setLayoutHint(new PositionalLayout.PositionalHint(62, 67, 9, 161)).setUserObject("allowed");
    updateVariableList();
    return new Panel(mc, this).setLayout(new PositionalLayout()).setLayoutHint(new PositionalLayout.PositionalHint(5, 5, 72, 220)).addChild(variableList).addChild(varSlider).addChild(fluidList).addChild(fluidSlider).setUserObject("allowed");
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) Argument(mcjty.lib.network.Argument) SelectionEvent(mcjty.lib.gui.events.SelectionEvent) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout)

Example 24 with Argument

use of mcjty.lib.network.Argument in project RFToolsControl by McJty.

the class GuiProcessor method initGui.

@Override
public void initGui() {
    super.initGui();
    // --- Main window ---
    Panel toplevel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(mainBackground);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    int maxEnergyStored = tileEntity.getMaxEnergyStored();
    energyBar = new EnergyBar(mc, this).setVertical().setMaxValue(maxEnergyStored).setLayoutHint(new PositionalLayout.PositionalHint(122, 4, 70, 10)).setShowText(false).setHorizontal();
    energyBar.setValue(GenericEnergyStorageTileEntity.getCurrentRF());
    toplevel.addChild(energyBar);
    exclusive = new ToggleButton(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(122, 16, 40, 15)).setCheckMarker(true).setText("Excl.").setTooltips(TextFormatting.YELLOW + "Exclusive mode", "If pressed then programs on", "card X can only run on core X");
    exclusive.setPressed(tileEntity.isExclusive());
    exclusive.addButtonEvent(parent -> {
        tileEntity.setExclusive(exclusive.isPressed());
        sendServerCommand(RFToolsCtrlMessages.INSTANCE, ProcessorTileEntity.CMD_SETEXCLUSIVE, new Argument("v", exclusive.isPressed()));
    });
    toplevel.addChild(exclusive);
    hudMode = new ChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(122 + 40 + 1, 16, 28, 15)).addChoices("Off", "Log", "Db", "Gfx").setChoiceTooltip("Off", "No overhead log").setChoiceTooltip("Log", "Show the normal log").setChoiceTooltip("Db", "Show a debug display").setChoiceTooltip("Gfx", "Graphics display");
    switch(tileEntity.getShowHud()) {
        case HUD_OFF:
            hudMode.setChoice("Off");
            break;
        case HUD_LOG:
            hudMode.setChoice("Log");
            break;
        case HUD_DB:
            hudMode.setChoice("Db");
            break;
        case HUD_GFX:
            hudMode.setChoice("Gfx");
            break;
    }
    hudMode.addChoiceEvent((parent, newChoice) -> {
        String choice = hudMode.getCurrentChoice();
        int m = HUD_OFF;
        if ("Off".equals(choice)) {
            m = HUD_OFF;
        } else if ("Log".equals(choice)) {
            m = HUD_LOG;
        } else if ("Db".equals(choice)) {
            m = HUD_DB;
        } else {
            m = HUD_GFX;
        }
        sendServerCommand(RFToolsCtrlMessages.INSTANCE, ProcessorTileEntity.CMD_SETHUDMODE, new Argument("v", m));
    });
    toplevel.addChild(hudMode);
    setupLogWindow(toplevel);
    for (int i = 0; i < ProcessorTileEntity.CARD_SLOTS; i++) {
        setupButtons[i] = new ToggleButton(mc, this).addButtonEvent(this::setupMode).setTooltips(TextFormatting.YELLOW + "Resource allocation", "Setup item and variable", "allocation for this card").setLayoutHint(new PositionalLayout.PositionalHint(11 + i * 18, 6, 15, 7)).setUserObject("allowed");
        toplevel.addChild(setupButtons[i]);
    }
    window = new Window(this, toplevel);
    // --- Side window ---
    Panel listPanel = setupVariableListPanel();
    Panel sidePanel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(sideBackground).addChild(listPanel);
    sidePanel.setBounds(new Rectangle(guiLeft - SIDEWIDTH, guiTop, SIDEWIDTH, ySize));
    sideWindow = new Window(this, sidePanel);
}
Also used : Window(mcjty.lib.gui.Window) Panel(mcjty.lib.gui.widgets.Panel) Argument(mcjty.lib.network.Argument) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout)

Example 25 with Argument

use of mcjty.lib.network.Argument in project RFTools by McJty.

the class GuiSensor method setArea.

private void setArea() {
    AreaType areaType = NamedEnum.getEnumByName(areaLabel.getCurrentChoice(), AreaType.values());
    tileEntity.setAreaType(areaType);
    sendServerCommand(RFToolsMessages.INSTANCE, SensorTileEntity.CMD_SETAREA, new Argument("type", areaType.ordinal()));
}
Also used : Argument(mcjty.lib.network.Argument)

Aggregations

Argument (mcjty.lib.network.Argument)97 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)8 Window (mcjty.lib.gui.Window)7 Panel (mcjty.lib.gui.widgets.Panel)6 ItemStack (net.minecraft.item.ItemStack)6 PacketServerCommand (mcjty.lib.network.PacketServerCommand)4 ArrayList (java.util.ArrayList)3 GenericGuiContainer (mcjty.lib.container.GenericGuiContainer)3 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)3 Label (mcjty.lib.gui.widgets.Label)3 PacketRequestIntegerFromServer (mcjty.lib.network.PacketRequestIntegerFromServer)3 java.awt (java.awt)2 Rectangle (java.awt.Rectangle)2 StyleConfig (mcjty.lib.base.StyleConfig)2 GenericEnergyStorageTileEntity (mcjty.lib.entity.GenericEnergyStorageTileEntity)2 HorizontalAlignment (mcjty.lib.gui.layout.HorizontalAlignment)2 VerticalLayout (mcjty.lib.gui.layout.VerticalLayout)2 mcjty.lib.gui.widgets (mcjty.lib.gui.widgets)2 ChoiceLabel (mcjty.lib.gui.widgets.ChoiceLabel)2 TextField (mcjty.lib.gui.widgets.TextField)2