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();
}
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();
}
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");
}
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);
}
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()));
}
Aggregations