use of mcjty.lib.gui.layout.HorizontalLayout in project RFToolsControl by McJty.
the class GuiProgrammer method setupGridPanel.
private Panel setupGridPanel() {
Panel panel = new Panel(mc, this).setLayout(new PositionalLayout()).setLayoutHint(new PositionalLayout.PositionalHint(5, 5, 246, 130));
gridList = new WidgetList(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(0, 0, 236, 130)).setPropagateEventsToChildren(true).setInvisibleSelection(true).setDrawHorizontalLines(false).setRowheight(ICONSIZE + 1);
Slider slider = new Slider(mc, this).setVertical().setScrollable(gridList).setLayoutHint(new PositionalLayout.PositionalHint(237, 0, 9, 130));
for (int y = 0; y < GRID_HEIGHT; y++) {
Panel rowPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(-1).setHorizontalMargin(0).setVerticalMargin(0));
for (int x = 0; x < GRID_WIDTH; x++) {
int finalX = x;
int finalY = y;
IconHolder holder = new IconHolder(mc, this) {
@Override
public List<String> getTooltips() {
return getGridIconTooltips(finalX, finalY);
}
}.setDesiredWidth(ICONSIZE + 2).setDesiredHeight(ICONSIZE + 2).setBorder(1).setBorderColor(0xff777777).setSelectable(true).setUserObject(new GridPos(finalX, finalY)).addIconHoverEvent(((iconHolder, iIcon, dx, dy) -> {
handleConnectorHighlight(finalX, finalY, iIcon, dx, dy);
})).addIconLeavesEvent(((parent, icon) -> {
iconLeavesFromX = finalX;
iconLeavesFromY = finalY;
return true;
})).addIconArrivesEvent(((parent, icon) -> {
if (icon != null && !loading) {
handleNewIconOverlay(icon, finalX, finalY);
}
return true;
})).addIconClickedEvent((parent, icon, dx, dy) -> {
gridIconClicked(icon, finalX, finalY, dx, dy);
return true;
});
rowPanel.addChild(holder);
}
gridList.addChild(rowPanel);
}
panel.addChild(gridList).addChild(slider);
return panel;
}
use of mcjty.lib.gui.layout.HorizontalLayout in project RFToolsControl by McJty.
the class GuiProcessor method updateFluidList.
private void updateFluidList() {
fluidList.removeChildren();
for (int i = 0; i < fluidListMapping.length; i++) {
fluidListMapping[i] = -1;
}
int setupMode = getSetupMode();
int fluidAlloc = 0;
if (setupMode != -1) {
CardInfo cardInfo = tileEntity.getCardInfo(setupMode);
fluidAlloc = cardInfo.getFluidAllocation();
}
fluidList.setPropagateEventsToChildren(setupMode == -1);
int index = 0;
for (int i = 0; i < fromServer_fluids.size(); i++) {
PacketGetFluids.FluidEntry entry = fromServer_fluids.get(i);
if (entry.isAllocated()) {
fluidListMapping[fluidList.getChildCount()] = i;
EnumFacing side = EnumFacing.values()[i / TANKS];
String l = side.getName().substring(0, 1).toUpperCase() + (i % TANKS);
Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout()).setDesiredWidth(40);
AbstractWidget<?> label;
if (setupMode != -1) {
boolean allocated = ((fluidAlloc >> i) & 1) != 0;
int fill = allocated ? 0x7700ff00 : (tileEntity.isFluidAllocated(-1, i) ? 0x77660000 : 0x77444444);
panel.setFilledBackground(fill);
if (allocated) {
label = new Label(mc, this).setColor(0xffffffff).setText(String.valueOf(index)).setDesiredWidth(26).setUserObject("allowed");
index++;
} else {
label = new Label(mc, this).setText("/").setDesiredWidth(26).setUserObject("allowed");
}
} else {
label = new Label(mc, this).setText(l).setDesiredWidth(26).setUserObject("allowed");
}
label.setUserObject("allowed");
panel.addChild(label);
FluidStack fluidStack = entry.getFluidStack();
if (fluidStack != null) {
BlockRender fluid = new BlockRender(mc, this).setRenderItem(fluidStack);
fluid.setTooltips(TextFormatting.GREEN + "Fluid: " + TextFormatting.WHITE + fluidStack.getLocalizedName(), TextFormatting.GREEN + "Amount: " + TextFormatting.WHITE + fluidStack.amount + "mb");
fluid.setUserObject("allowed");
panel.addChild(fluid);
}
panel.setUserObject("allowed");
fluidList.addChild(panel);
}
}
}
use of mcjty.lib.gui.layout.HorizontalLayout in project RFToolsControl by McJty.
the class GuiProcessor method updateVariableList.
private void updateVariableList() {
variableList.removeChildren();
int setupMode = getSetupMode();
int varAlloc = 0;
if (setupMode != -1) {
CardInfo cardInfo = tileEntity.getCardInfo(setupMode);
varAlloc = cardInfo.getVarAllocation();
}
variableList.setPropagateEventsToChildren(setupMode == -1);
int index = 0;
for (int i = 0; i < tileEntity.getMaxvars(); i++) {
Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout()).setDesiredWidth(40);
if (setupMode != -1) {
boolean allocated = ((varAlloc >> i) & 1) != 0;
int fill = allocated ? 0x7700ff00 : (tileEntity.isVarAllocated(-1, i) ? 0x77660000 : 0x77444444);
panel.setFilledBackground(fill);
if (allocated) {
panel.addChild(new Label(mc, this).setColor(0xffffffff).setText(String.valueOf(index)).setDesiredWidth(26).setUserObject("allowed"));
index++;
} else {
panel.addChild(new Label(mc, this).setText("/").setDesiredWidth(26).setUserObject("allowed"));
}
} else {
panel.addChild(new Label(mc, this).setText(String.valueOf(i)).setDesiredWidth(26).setUserObject("allowed"));
}
int finalI = i;
panel.addChild(new Button(mc, this).addButtonEvent(w -> openValueEditor(finalI)).setText("...").setUserObject("allowed"));
panel.setUserObject("allowed");
variableList.addChild(panel);
}
}
use of mcjty.lib.gui.layout.HorizontalLayout in project RFToolsControl by McJty.
the class GuiCraftingStation method updateRecipeList.
private void updateRecipeList() {
String filterText = searchField.getText().toLowerCase().trim();
fromServer_craftables.sort((r1, r2) -> {
return r1.getDisplayName().compareTo(r2.getDisplayName());
});
recipeList.removeChildren();
Panel panel = null;
int index = 0;
for (ItemStack stack : fromServer_craftables) {
String displayName = stack.getDisplayName();
if ((!filterText.isEmpty()) && !displayName.toLowerCase().contains(filterText)) {
continue;
}
if (panel == null || panel.getChildCount() >= 6) {
panel = new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(3).setHorizontalMargin(1)).setDesiredHeight(16);
recipeList.addChild(panel);
}
BlockRender blockRender = new BlockRender(mc, this) {
@Override
public List<String> getTooltips() {
ITooltipFlag flag = this.mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
List<String> list = stack.getTooltip(this.mc.player, flag);
for (int i = 0; i < list.size(); ++i) {
if (i == 0) {
list.set(i, stack.getRarity().rarityColor + list.get(i));
} else {
list.set(i, TextFormatting.GRAY + list.get(i));
}
}
List<String> newlist = new ArrayList<>();
newlist.add(TextFormatting.GREEN + "Click: " + TextFormatting.WHITE + "craft single");
newlist.add(TextFormatting.GREEN + "Shift + click: " + TextFormatting.WHITE + "craft amount");
newlist.add("");
newlist.addAll(list);
return newlist;
}
}.setRenderItem(stack).setHilightOnHover(true).setOffsetX(-1).setOffsetY(-1).setUserObject(index);
index++;
blockRender.addSelectionEvent(new BlockRenderEvent() {
@Override
public void select(Widget widget) {
BlockRender br = (BlockRender) widget;
Object item = br.getRenderItem();
if (item != null) {
boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
Object index = br.getUserObject();
if (shift) {
askAmountToCraft(stack);
} else {
requestItem(stack, 1);
}
}
}
@Override
public void doubleClick(Widget widget) {
}
});
panel.addChild(blockRender);
}
}
use of mcjty.lib.gui.layout.HorizontalLayout in project RFToolsControl by McJty.
the class GuiRFToolsManual method initGui.
@Override
public void initGui() {
super.initGui();
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
textPage = new TextPage(RFToolsControl.instance, mc, this).setText(manualText).setArrowImage(iconGuiElements, 144, 0).setCraftingGridImage(iconGuiElements, 0, 192);
prevButton = new Button(mc, this).setText("<").addButtonEvent(parent -> {
textPage.prevPage();
window.setTextFocus(textPage);
});
pageLabel = new Label(mc, this).setText("0 / 0");
nextButton = new Button(mc, this).setText(">").addButtonEvent(parent -> {
textPage.nextPage();
window.setTextFocus(textPage);
});
Panel buttonPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).setDesiredHeight(16).addChild(prevButton).addChild(pageLabel).addChild(nextButton);
Widget<?> toplevel = new Panel(mc, this).setFilledRectThickness(2).setLayout(new VerticalLayout()).addChild(textPage).addChild(buttonPanel);
toplevel.setBounds(new Rectangle(k, l, xSize, ySize));
window = new Window(this, toplevel);
window.setTextFocus(textPage);
if (locatePage != null) {
textPage.gotoNode(locatePage);
locatePage = null;
}
}
Aggregations