use of net.malisis.core.client.gui.component.decoration.UISeparator in project Almura by AlmuraDev.
the class IngameFarmersAlmanac method construct.
// TODO: Translation support
@SuppressWarnings("deprecation")
@Override
public void construct() {
guiscreenBackground = false;
final UIFormContainer form = new UIFormContainer(this, formWidth, formHeight, formTitle);
form.setAnchor(Anchor.CENTER | Anchor.MIDDLE);
form.setMovable(true);
form.setClosable(false);
form.setBorder(FontColors.WHITE, 1, formAlpha);
form.setBackgroundAlpha(formAlpha);
final WorldClient world = this.client.world;
final RayTraceResult omo = this.client.objectMouseOver;
final BlockPos blockPos = omo.getBlockPos();
final IBlockState blockState = getState(world, blockPos);
final Block block = blockState.getBlock();
// Block image
final ItemStack pickStack = blockState.getBlock().getPickBlock(blockState, omo, this.client.world, omo.getBlockPos(), this.client.player);
final UIImage blockImage = new UIImage(this, pickStack);
blockImage.setPosition(leftPad / 2, 0, Anchor.LEFT | Anchor.TOP);
form.add(blockImage);
// Localized name
final UILabel labelLocalizedName = new UILabel(this, block.getLocalizedName());
labelLocalizedName.setFontOptions(FontColors.WHITE_FO);
labelLocalizedName.setPosition(SimpleScreen.getPaddedX(blockImage, 4), 0);
form.add(labelLocalizedName);
// Registry name
final String registryName = block.getRegistryName() == null ? "unknown" : block.getRegistryName().toString();
final UILabel labelRegistryName = new UILabel(this, registryName);
labelRegistryName.setFontOptions(FontColors.GRAY_FO);
labelRegistryName.setPosition(labelLocalizedName.getX(), SimpleScreen.getPaddedY(labelLocalizedName, 2));
form.add(labelRegistryName);
// Line separator
final UISeparator separator = new UISeparator(this);
separator.setSize(form.getWidth() - 15, 1);
separator.setPosition(0, SimpleScreen.getPaddedY(labelRegistryName, 3), Anchor.TOP | Anchor.CENTER);
form.add(separator);
// Property container
this.propertyContainer = new UIBackgroundContainer(this);
new UISlimScrollbar(this, this.propertyContainer, UIScrollBar.Type.VERTICAL).setAutoHide(true);
this.propertyContainer.setBackgroundAlpha(50);
this.propertyContainer.setPosition(0, SimpleScreen.getPaddedY(separator, 5));
form.add(this.propertyContainer);
// Get all displayed properties
loadProperties(world, blockState, blockPos);
// Adjust the size of the container to reach at most the specified max height
propertyContainer.setSize(UIComponent.INHERITED, Math.min(propertyContainerMaxHeight, propertyContainer.getContentHeight()));
final UIButton closeButton = new UIButtonBuilder(this).text("Close").anchor(Anchor.BOTTOM | Anchor.RIGHT).position(-4, -4).onClick(this::close).build("button.close");
form.add(closeButton);
// Adjust the size of the form to better fit content
form.setSize(form.getContentWidth() + leftPad, form.getContentHeight() + closeButton.getHeight() + 10);
// Readjust size for width because MalisisCore doesn't account for the scrollbar with UIComponent.INHERITED
propertyContainer.setSize(propertyContainer.getWidth() - 1, propertyContainer.getHeight());
addToScreen(form);
Mouse.setGrabbed(false);
}
Aggregations