use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.
the class GuiNetworkMonitor method populateList.
private void populateList() {
requestConnectedBlocksFromServer();
if (serverConnectedBlocks == null) {
return;
}
boolean rftick = showRfPerTick.isPressed();
long millis = System.currentTimeMillis();
boolean recalcPerTick = previousRfMillis == 0 || (millis - previousRfMillis) > 1000;
if (serverConnectedBlocks.equals(connectedBlocks)) {
refreshList(recalcPerTick);
} else {
connectedBlocks = new HashMap<>(serverConnectedBlocks);
Map<BlockPos, EnergyBar> oldLabelMap = labelMap;
labelMap = new HashMap<>();
indexToCoordinate = new HashMap<>();
list.removeChildren();
int index = 0;
for (Map.Entry<BlockPos, BlockInfo> me : connectedBlocks.entrySet()) {
BlockInfo blockInfo = me.getValue();
BlockPos coordinate = me.getKey();
if (mc.world.isAirBlock(coordinate)) {
continue;
}
int energy = blockInfo.getEnergyStored();
int maxEnergy = blockInfo.getMaxEnergyStored();
int color = getTextColor(blockInfo);
IBlockState state = mc.world.getBlockState(coordinate);
String displayName = BlockTools.getReadableName(mc.world, coordinate);
if (filter != null) {
if (!displayName.toLowerCase().contains(filter)) {
continue;
}
}
Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout());
panel.addChild(new BlockRender(mc, this).setRenderItem(state.getBlock()));
panel.addChild(new Label(mc, this).setColor(StyleConfig.colorTextInListNormal).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setText(displayName).setColor(color).setDesiredWidth(100));
panel.addChild(new Label(mc, this).setColor(StyleConfig.colorTextInListNormal).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setText(BlockPosTools.toString(coordinate)).setColor(color).setDesiredWidth(75));
EnergyBar energyLabel = oldLabelMap == null ? null : oldLabelMap.get(coordinate);
if (energyLabel == null) {
energyLabel = new EnergyBar(mc, this).setHorizontal();
}
setEnergyLabel(millis, rftick, recalcPerTick, me, energy, maxEnergy, energyLabel);
panel.addChild(energyLabel);
list.addChild(panel);
labelMap.put(coordinate, energyLabel);
indexToCoordinate.put(index, coordinate);
index++;
}
}
if (rftick && recalcPerTick) {
previousRfMillis = millis;
previousRf = new HashMap<>(connectedBlocks.size());
for (Map.Entry<BlockPos, BlockInfo> me : connectedBlocks.entrySet()) {
previousRf.put(me.getKey(), me.getValue().getEnergyStored());
}
}
}
use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.
the class GuiDialingDevice method setupTransmitterPanel.
private Panel setupTransmitterPanel() {
transmitterList = new WidgetList(mc, this).setRowheight(18).setDesiredHeight(58).addSelectionEvent(new DefaultSelectionEvent() {
@Override
public void select(Widget parent, int index) {
clearSelectedStatus();
selectReceiverFromTransmitter();
}
@Override
public void doubleClick(Widget parent, int index) {
hilightSelectedTransmitter(index);
}
});
Slider transmitterSlider = new Slider(mc, this).setDesiredWidth(11).setDesiredHeight(58).setVertical().setScrollable(transmitterList);
return new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(1).setHorizontalMargin(3)).addChild(transmitterList).addChild(transmitterSlider).setDesiredHeight(64).setFilledBackground(0xff9e9e9e);
}
use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.
the class GuiDialingDevice method initGui.
@Override
public void initGui() {
super.initGui();
int maxEnergyStored = tileEntity.getMaxEnergyStored();
energyBar = new EnergyBar(mc, this).setFilledRectThickness(1).setHorizontal().setDesiredWidth(80).setDesiredHeight(12).setMaxValue(maxEnergyStored).setShowText(false);
energyBar.setValue(GenericEnergyStorageTileEntity.getCurrentRF());
Panel transmitterPanel = setupTransmitterPanel();
Panel receiverPanel = setupReceiverPanel();
dialButton = new Button(mc, this).setText("Dial").setTooltips("Start a connection between", "the selected transmitter", "and the selected receiver").setDesiredHeight(14).setDesiredWidth(65).addButtonEvent(parent -> dial(false));
dialOnceButton = new Button(mc, this).setText("Dial Once").setTooltips("Dial a connection for a", "single teleport").setDesiredHeight(14).setDesiredWidth(65).addButtonEvent(parent -> dial(true));
interruptButton = new Button(mc, this).setText("Interrupt").setTooltips("Interrupt a connection", "for the selected transmitter").setDesiredHeight(14).setDesiredWidth(65).addButtonEvent(parent -> interruptDial());
favoriteButton = new ImageChoiceLabel(mc, this).addChoiceEvent((parent, newChoice) -> changeShowFavorite()).setDesiredWidth(10).setDesiredHeight(10);
favoriteButton.addChoice("No", "Unfavorited receiver", guielements, 131, 19);
favoriteButton.addChoice("Yes", "Favorited receiver", guielements, 115, 19);
favoriteButton.setCurrentChoice(tileEntity.isShowOnlyFavorites() ? 1 : 0);
Panel buttonPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(dialButton).addChild(dialOnceButton).addChild(interruptButton).addChild(favoriteButton).setDesiredHeight(16);
analyzerAvailable = DialingDeviceTileEntity.isDestinationAnalyzerAvailable(mc.world, tileEntity.getPos());
statusButton = new Button(mc, this).setText("Check").setDesiredHeight(14).setDesiredWidth(65).setEnabled(analyzerAvailable).addButtonEvent(parent -> checkStatus());
if (analyzerAvailable) {
statusButton.setTooltips("Check the status of", "the selected receiver");
} else {
statusButton.setTooltips("Check the status of", "the selected receiver", "(needs an adjacent analyzer!)");
}
statusLabel = new Label(mc, this);
statusLabel.setDesiredWidth(170).setDesiredHeight(14).setFilledRectThickness(1);
Panel statusPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(statusButton).addChild(statusLabel).setDesiredHeight(16);
Panel toplevel = new Panel(mc, this).setFilledRectThickness(2).setLayout(new VerticalLayout().setVerticalMargin(3).setSpacing(1)).addChild(energyBar).addChild(transmitterPanel).addChild(receiverPanel).addChild(buttonPanel).addChild(statusPanel);
toplevel.setBounds(new Rectangle(guiLeft, guiTop, DIALER_WIDTH, DIALER_HEIGHT));
window = new mcjty.lib.gui.Window(this, toplevel);
Keyboard.enableRepeatEvents(true);
fromServer_receivers = null;
fromServer_transmitters = null;
listDirty = 0;
clearSelectedStatus();
requestReceivers();
requestTransmitters();
tileEntity.requestRfFromServer(RFTools.MODID);
}
use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.
the class GuiMatterReceiver method initGui.
@Override
public void initGui() {
super.initGui();
int maxEnergyStored = tileEntity.getMaxEnergyStored();
energyBar = new EnergyBar(mc, this).setFilledRectThickness(1).setHorizontal().setDesiredHeight(12).setDesiredWidth(80).setMaxValue(maxEnergyStored).setShowText(false);
energyBar.setValue(GenericEnergyStorageTileEntity.getCurrentRF());
TextField textField = new TextField(mc, this).setTooltips("Use this name to", "identify this receiver", "in the dialer").addTextEvent((parent, newText) -> setReceiverName(newText));
textField.setText(tileEntity.getName());
Panel namePanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(new Label(mc, this).setText("Name:")).addChild(textField).setDesiredHeight(16);
privateSetting = new ChoiceLabel(mc, this).addChoices(ACCESS_PUBLIC, ACCESS_PRIVATE).setDesiredHeight(14).setDesiredWidth(60).setChoiceTooltip(ACCESS_PUBLIC, "Everyone can dial to this receiver").setChoiceTooltip(ACCESS_PRIVATE, "Only people in the access list below", "can dial to this receiver").addChoiceEvent((parent, newChoice) -> changeAccessMode(newChoice));
if (tileEntity.isPrivateAccess()) {
privateSetting.setChoice(ACCESS_PRIVATE);
} else {
privateSetting.setChoice(ACCESS_PUBLIC);
}
Panel privatePanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(new Label(mc, this).setText("Access:")).addChild(privateSetting).setDesiredHeight(16);
allowedPlayers = new WidgetList(mc, this);
Slider allowedPlayerSlider = new Slider(mc, this).setDesiredWidth(10).setVertical().setScrollable(allowedPlayers);
Panel allowedPlayersPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(3).setSpacing(1)).addChild(allowedPlayers).addChild(allowedPlayerSlider).setFilledBackground(0xff9e9e9e);
nameField = new TextField(mc, this);
addButton = new Button(mc, this).setText("Add").setDesiredHeight(13).setDesiredWidth(34).setTooltips("Add a player to the access list").addButtonEvent(parent -> addPlayer());
delButton = new Button(mc, this).setText("Del").setDesiredHeight(13).setDesiredWidth(34).setTooltips("Remove the selected player", "from the access list").addButtonEvent(parent -> delPlayer());
Panel buttonPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(nameField).addChild(addButton).addChild(delButton).setDesiredHeight(16);
Panel toplevel = new Panel(mc, this).setFilledRectThickness(2).setLayout(new VerticalLayout().setHorizontalMargin(3).setVerticalMargin(3).setSpacing(1)).addChild(energyBar).addChild(namePanel).addChild(privatePanel).addChild(allowedPlayersPanel).addChild(buttonPanel);
toplevel.setBounds(new Rectangle(guiLeft, guiTop, MATTER_WIDTH, MATTER_HEIGHT));
window = new Window(this, toplevel);
Keyboard.enableRepeatEvents(true);
listDirty = 0;
requestPlayers();
tileEntity.requestRfFromServer(RFTools.MODID);
}
use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.
the class GuiRelay method createSubPanel.
private Panel createSubPanel(int side, String redstoneState) {
String labelText = String.valueOf(RelayTileEntity.DUNSWE.charAt(side));
int rf;
boolean input;
if ("Off".equals(redstoneState)) {
rf = tileEntity.getRfOff(side);
input = tileEntity.isInputModeOff(side);
} else {
rf = tileEntity.getRfOn(side);
input = tileEntity.isInputModeOn(side);
}
ImageChoiceLabel inputOutput = new ImageChoiceLabel(mc, this).setDesiredWidth(14).setDesiredHeight(14).addChoice("Output", "Side set to output mode", iconGuiElements, 80, 16).addChoice("Input", "Side set to input mode", iconGuiElements, 96, 16).addChoiceEvent((parent, newChoice) -> changeSettings());
String key = labelText + redstoneState;
if (input) {
inputOutput.setCurrentChoice("Input");
} else {
inputOutput.setCurrentChoice("Output");
}
inputOutputs.put(key, inputOutput);
TextField energyField = new TextField(mc, this).setTooltips("Amount of RF to input/output", "when redstone is " + redstoneState).setDesiredWidth(42).setDesiredHeight(14).addTextEvent((parent, newText) -> adjustEnergy((TextField) parent, 0));
energyField.setText(String.valueOf(rf));
Button sub100 = createEnergyOffsetButton(energyField, "-", -500);
Button add100 = createEnergyOffsetButton(energyField, "+", 500);
Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(1)).addChild(inputOutput).addChild(sub100).addChild(energyField).addChild(add100);
energyValues.put(key, energyField);
return panel;
}
Aggregations