use of mcjty.lib.gui.layout.HorizontalLayout in project RFToolsControl by McJty.
the class TupleEditor method build.
@Override
public void build(Minecraft mc, Gui gui, Panel panel, ParameterEditorCallback callback) {
Panel constantPanel = new Panel(mc, gui).setLayout(new HorizontalLayout());
fieldX = new TextField(mc, gui).addTextEvent((parent, newText) -> callback.valueChanged(readValue())).addTextEnterEvent((parent, newText) -> closeWindow());
fieldY = new TextField(mc, gui).addTextEvent((parent, newText) -> callback.valueChanged(readValue())).addTextEnterEvent((parent, newText) -> closeWindow());
constantPanel.addChild(fieldX).addChild(fieldY);
createEditorPanel(mc, gui, panel, callback, constantPanel, ParameterType.PAR_TUPLE);
}
use of mcjty.lib.gui.layout.HorizontalLayout in project RFToolsControl by McJty.
the class FloatEditor method build.
@Override
public void build(Minecraft mc, Gui gui, Panel panel, ParameterEditorCallback callback) {
Panel constantPanel = new Panel(mc, gui).setLayout(new HorizontalLayout());
field = new TextField(mc, gui).addTextEvent((parent, newText) -> callback.valueChanged(readValue())).addTextEnterEvent((parent, newText) -> closeWindow());
constantPanel.addChild(field);
createEditorPanel(mc, gui, panel, callback, constantPanel, ParameterType.PAR_FLOAT);
}
use of mcjty.lib.gui.layout.HorizontalLayout in project RFToolsControl by McJty.
the class ItemEditor method build.
@Override
public void build(Minecraft mc, Gui gui, Panel panel, ParameterEditorCallback callback) {
Panel constantPanel = new Panel(mc, gui).setLayout(new HorizontalLayout());
Label<?> label = new Label(mc, gui).setText("Drop item:");
constantPanel.addChild(label);
blockRender = new BlockRender(mc, gui).setDesiredWidth(18 + 100).setDesiredHeight(18).setFilledRectThickness(1).setFilledBackground(0xff555555).setShowLabel(true);
constantPanel.addChild(blockRender);
blockRender.addSelectionEvent(new BlockRenderEvent() {
@Override
public void select(Widget widget) {
ItemStack holding = Minecraft.getMinecraft().player.inventory.getItemStack();
if (holding.isEmpty()) {
blockRender.setRenderItem(null);
} else {
ItemStack copy = holding.copy();
copy.setCount(1);
blockRender.setRenderItem(copy);
}
callback.valueChanged(readValue());
}
@Override
public void doubleClick(Widget widget) {
}
});
createEditorPanel(mc, gui, panel, callback, constantPanel, ParameterType.PAR_ITEM);
}
use of mcjty.lib.gui.layout.HorizontalLayout in project XNet by McJty.
the class GuiController method populateList.
private void populateList() {
if (!listsReady()) {
return;
}
if (!needsRefresh) {
return;
}
needsRefresh = false;
connectorList.removeChildren();
int sel = connectorList.getSelected();
BlockPos prevPos = null;
String selectedText = searchBar.getText().trim().toLowerCase();
for (ConnectedBlockClientInfo connectedBlock : fromServer_connectedBlocks) {
SidedPos sidedPos = connectedBlock.getPos();
BlockPos coordinate = sidedPos.getPos();
String name = connectedBlock.getName();
String blockUnlocName = connectedBlock.getBlockUnlocName();
String blockName = I18n.format(blockUnlocName).trim();
int color = StyleConfig.colorTextInListNormal;
Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0).setSpacing(0));
if (!selectedText.isEmpty()) {
if (blockName.toLowerCase().contains(selectedText)) {
panel.setFilledBackground(0xffddeeaa);
}
}
BlockRender br;
if (coordinate.equals(prevPos)) {
br = new BlockRender(mc, this);
} else {
br = new BlockRender(mc, this).setRenderItem(connectedBlock.getConnectedBlock());
prevPos = coordinate;
}
br.setUserObject("block");
panel.addChild(br);
if (!name.isEmpty()) {
br.setTooltips(TextFormatting.GREEN + "Connector: " + TextFormatting.WHITE + name, TextFormatting.GREEN + "Block: " + TextFormatting.WHITE + blockName, TextFormatting.GREEN + "Position: " + TextFormatting.WHITE + BlockPosTools.toString(coordinate), TextFormatting.WHITE + "(doubleclick to highlight)");
} else {
br.setTooltips(TextFormatting.GREEN + "Block: " + TextFormatting.WHITE + blockName, TextFormatting.GREEN + "Position: " + TextFormatting.WHITE + BlockPosTools.toString(coordinate), TextFormatting.WHITE + "(doubleclick to highlight)");
}
panel.addChild(new Label(mc, this).setText(sidedPos.getSide().getName().substring(0, 1).toUpperCase()).setColor(color).setDesiredWidth(18));
for (int i = 0; i < MAX_CHANNELS; i++) {
Button but = new Button(mc, this).setDesiredWidth(14);
ChannelClientInfo info = fromServer_channels.get(i);
if (info != null) {
ConnectorClientInfo clientInfo = findClientInfo(info, sidedPos);
if (clientInfo != null) {
IndicatorIcon icon = clientInfo.getConnectorSettings().getIndicatorIcon();
if (icon != null) {
but.setImage(icon.getImage(), icon.getU(), icon.getV(), icon.getIw(), icon.getIh());
}
String indicator = clientInfo.getConnectorSettings().getIndicator();
but.setText(indicator != null ? indicator : "");
}
}
int finalI = i;
but.addButtonEvent(parent -> {
selectConnectorEditor(sidedPos, finalI);
});
panel.addChild(but);
}
connectorList.addChild(panel);
}
connectorList.setSelected(sel);
}
use of mcjty.lib.gui.layout.HorizontalLayout in project XNet by McJty.
the class GuiController method initChannelSelectionPanel.
private Panel initChannelSelectionPanel() {
Panel channelSelectionPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0).setSpacing(0)).setLayoutHint(new PositionalLayout.PositionalHint(41, 1, 124, 24));
for (int i = 0; i < MAX_CHANNELS; i++) {
String channel = String.valueOf(i + 1);
channelButtons[i] = new ToggleButton(mc, this).setDesiredWidth(14).setText(channel).setTooltips("Edit channel " + channel);
int finalI = i;
channelButtons[i].addButtonEvent(parent -> {
selectChannelEditor(finalI);
});
channelSelectionPanel.addChild(channelButtons[i]);
}
return channelSelectionPanel;
}
Aggregations