use of com.almuradev.almura.shared.client.ui.component.UIFormContainer 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);
}
use of com.almuradev.almura.shared.client.ui.component.UIFormContainer in project Almura by AlmuraDev.
the class ExchangeGUI method construct.
@Override
public void construct() {
guiscreenBackground = false;
Keyboard.enableRepeatEvents(true);
// Master Pane
final UIFormContainer form = new UIFormContainer(this, 600, 400, "");
form.setAnchor(Anchor.CENTER | Anchor.MIDDLE);
form.setMovable(true);
form.setClosable(true);
form.setBorder(FontColors.WHITE, 1, 185);
form.setBackgroundAlpha(215);
form.setBottomPadding(3);
form.setRightPadding(3);
form.setTopPadding(20);
form.setLeftPadding(3);
UILabel titleLabel = new UILabel(this, "Almura Grand Exchange");
titleLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
titleLabel.setPosition(0, -15, Anchor.CENTER | Anchor.TOP);
// Item Search Area
final UIFormContainer searchArea = new UIFormContainer(this, 295, 315, "");
searchArea.setPosition(0, 10, Anchor.LEFT | Anchor.TOP);
searchArea.setMovable(false);
searchArea.setClosable(false);
searchArea.setBorder(FontColors.WHITE, 1, 185);
searchArea.setBackgroundAlpha(215);
searchArea.setBottomPadding(3);
searchArea.setRightPadding(3);
searchArea.setTopPadding(3);
searchArea.setLeftPadding(3);
UILabel searchLabel = new UILabel(this, "Item Name:");
searchLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
searchLabel.setPosition(0, 0, Anchor.LEFT | Anchor.TOP);
this.itemSearchField = new UITextField(this, "", false);
this.itemSearchField.setSize(150, 0);
this.itemSearchField.setPosition(searchLabel.getWidth() + innerPadding, searchLabel.getY(), Anchor.LEFT | Anchor.TOP);
this.itemSearchField.setEditable(true);
this.itemSearchField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
// Seller Search Area
UILabel sellerLabel = new UILabel(this, "Seller:");
sellerLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
sellerLabel.setPosition(itemSearchField.getX() - sellerLabel.getWidth() + innerPadding, searchLabel.getY() + 15, Anchor.LEFT | Anchor.TOP);
this.sellerSearchField = new UITextField(this, "", false);
this.sellerSearchField.setSize(150, 0);
this.sellerSearchField.setPosition(itemSearchField.getX(), sellerLabel.getY(), Anchor.LEFT | Anchor.TOP);
this.sellerSearchField.setEditable(true);
this.sellerSearchField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
// Search button
final UIButton buttonSearch = new UIButtonBuilder(this).width(40).anchor(Anchor.LEFT | Anchor.TOP).position(sellerSearchField.getX() + sellerSearchField.getWidth() + 10, sellerLabel.getY() - 7).text("Search").listener(this).build("button.search");
// Bottom Page Control - first button
final UIButton buttonFirstPage = new UIButtonBuilder(this).width(40).anchor(Anchor.LEFT | Anchor.BOTTOM).position(0, 0).text("First").listener(this).build("button.first");
// Bottom Page Control - previous button
final UIButton buttonPreviousPage = new UIButtonBuilder(this).width(40).anchor(Anchor.LEFT | Anchor.BOTTOM).position(buttonFirstPage.getX() + buttonFirstPage.getWidth() + innerPadding, 0).text("Previous").listener(this).build("button.previous");
// Bottom Page Control - last button
final UIButton buttonLastPage = new UIButtonBuilder(this).width(40).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(0, 0).text("Last").listener(this).build("button.last");
// Bottom Page Control - next button
final UIButton buttonNextPage = new UIButtonBuilder(this).width(40).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(-(buttonLastPage.getX() + buttonLastPage.getWidth() + innerPadding), 0).text("Next").listener(this).build("button.next");
// Add Elements of Search Area
searchArea.add(searchLabel, itemSearchField, sellerLabel, sellerSearchField, buttonSearch, buttonFirstPage, buttonPreviousPage, buttonNextPage, buttonLastPage);
// Economy Pane
final UIFormContainer economyActionArea = new UIFormContainer(this, 295, 50, "");
economyActionArea.setPosition(0, searchArea.getY() + searchArea.getHeight() + innerPadding, Anchor.LEFT | Anchor.TOP);
economyActionArea.setMovable(false);
economyActionArea.setClosable(false);
economyActionArea.setBorder(FontColors.WHITE, 1, 185);
economyActionArea.setBackgroundAlpha(215);
economyActionArea.setBottomPadding(3);
economyActionArea.setRightPadding(3);
economyActionArea.setTopPadding(3);
economyActionArea.setLeftPadding(3);
// Bottom Economy Pane - buyStack button
final UIButton buttonBuyStack = new UIButtonBuilder(this).width(40).anchor(Anchor.LEFT | Anchor.BOTTOM).position(0, 0).text("Buy Stack").listener(this).build("button.buyStack");
// Bottom Economy Pane - buyStack button
final UIButton buttonBuySingle = new UIButtonBuilder(this).width(40).anchor(Anchor.CENTER | Anchor.BOTTOM).position(0, 0).text("Buy 1").listener(this).build("button.buySingle");
// Bottom Economy Pane - buyStack button
final UIButton buttonBuyQuantity = new UIButtonBuilder(this).width(40).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(0, 0).text("Buy Quantity").listener(this).build("button.buyQuantity");
economyActionArea.add(buttonBuyStack, buttonBuySingle, buttonBuyQuantity);
// Seller Inventory Area
final UIFormContainer sellerInventoryArea = new UIFormContainer(this, 295, 30, "");
sellerInventoryArea.setPosition(0, 10, Anchor.RIGHT | Anchor.TOP);
sellerInventoryArea.setMovable(false);
sellerInventoryArea.setClosable(false);
sellerInventoryArea.setBorder(FontColors.WHITE, 1, 185);
sellerInventoryArea.setBackgroundAlpha(215);
sellerInventoryArea.setBottomPadding(3);
sellerInventoryArea.setRightPadding(3);
sellerInventoryArea.setTopPadding(3);
sellerInventoryArea.setLeftPadding(3);
final UISlot exchangeSlot1 = new UISlot(this, new MalisisSlot());
exchangeSlot1.setPosition(0, 0, Anchor.LEFT | Anchor.MIDDLE);
exchangeSlot1.setTooltip("Exchange Slot 1");
final UISlot exchangeSlot2 = new UISlot(this, new MalisisSlot());
exchangeSlot2.setPosition(exchangeSlot1.getX() + exchangeSlot1.getWidth() + 10, 0, Anchor.LEFT | Anchor.MIDDLE);
exchangeSlot2.setTooltip("Exchange Slot 2");
final UISlot exchangeSlot3 = new UISlot(this, new MalisisSlot());
exchangeSlot3.setPosition(exchangeSlot2.getX() + exchangeSlot2.getWidth() + 10, 0, Anchor.LEFT | Anchor.MIDDLE);
exchangeSlot3.setTooltip("Exchange Slot 3");
final UISlot exchangeSlot4 = new UISlot(this, new MalisisSlot());
exchangeSlot4.setPosition(exchangeSlot3.getX() + exchangeSlot3.getWidth() + 10, 0, Anchor.LEFT | Anchor.MIDDLE);
exchangeSlot4.setTooltip("Exchange Slot 4");
final UISlot exchangeSlot5 = new UISlot(this, new MalisisSlot());
exchangeSlot5.setPosition(exchangeSlot4.getX() + exchangeSlot4.getWidth() + 10, 0, Anchor.LEFT | Anchor.MIDDLE);
exchangeSlot5.setTooltip("Exchange Slot 5");
final UISlot exchangeSlot6 = new UISlot(this, new MalisisSlot());
exchangeSlot6.setPosition(exchangeSlot5.getX() + exchangeSlot5.getWidth() + 10, 0, Anchor.LEFT | Anchor.MIDDLE);
exchangeSlot6.setTooltip("Exchange Slot 6");
sellerInventoryArea.add(exchangeSlot1, exchangeSlot2, exchangeSlot3, exchangeSlot4, exchangeSlot5, exchangeSlot6);
// Inventory Area Section (right pane)
final UIFormContainer inventoryArea = new UIFormContainer(this, 295, 315, "");
inventoryArea.setPosition(0, 45, Anchor.RIGHT | Anchor.TOP);
inventoryArea.setMovable(false);
inventoryArea.setClosable(false);
inventoryArea.setBorder(FontColors.WHITE, 1, 185);
inventoryArea.setBackgroundAlpha(215);
inventoryArea.setBottomPadding(3);
inventoryArea.setRightPadding(3);
inventoryArea.setTopPadding(3);
inventoryArea.setLeftPadding(3);
// Bottom Economy Pane - buyStack button
final UIButton buttonList = new UIButtonBuilder(this).width(40).anchor(Anchor.LEFT | Anchor.BOTTOM).position(0, 0).text("List for Sale").listener(this).build("button.listForSaleButton");
// Bottom Economy Pane - buyStack button
final UIButton buttonSetPrice = new UIButtonBuilder(this).width(40).anchor(Anchor.CENTER | Anchor.BOTTOM).position(0, 0).text("Set Price").listener(this).build("button.setPrice");
// Bottom Economy Pane - buyStack button
final UIButton buttonRemoveItem = new UIButtonBuilder(this).width(40).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(0, 0).text("Remove Item").listener(this).build("button.removeItem");
inventoryArea.add(buttonList, buttonSetPrice, buttonRemoveItem);
// Close button
final UIButton buttonClose = new UIButtonBuilder(this).width(40).anchor(Anchor.BOTTOM | Anchor.RIGHT).text(Text.of("almura.guide.button.close")).listener(this).build("button.close");
form.add(titleLabel, searchArea, economyActionArea, sellerInventoryArea, inventoryArea, buttonClose);
addToScreen(form);
}
use of com.almuradev.almura.shared.client.ui.component.UIFormContainer in project Almura by AlmuraDev.
the class SimplePageView method construct.
@Override
public void construct() {
guiscreenBackground = false;
Keyboard.enableRepeatEvents(true);
final UIFormContainer form = new UIFormContainer(this, 420, 225, TextFormatting.WHITE + I18n.format("almura.guide.view.form.title"));
form.setAnchor(Anchor.CENTER | Anchor.MIDDLE);
form.setMovable(true);
form.setClosable(true);
form.setBorder(FontColors.WHITE, 1, 185);
form.setBackgroundAlpha(185);
form.setBottomPadding(3);
form.setRightPadding(3);
form.setTopPadding(20);
form.setLeftPadding(3);
// Remove button
this.buttonRemove = new UIButtonBuilder(this).width(10).text(Text.of(TextColors.RED, "-")).tooltip(Text.of("almura.guide.view.button.remove.tooltip")).visible(hasAnyPermission()).enabled(hasRemovePermission()).listener(this).build("button.remove");
// Details button
this.buttonDetails = new UIButtonBuilder(this).width(10).text(Text.of(TextColors.YELLOW, "?")).tooltip(Text.of(I18n.format("almura.guide.view.button.details.tooltip"))).anchor(Anchor.TOP | Anchor.RIGHT).visible(hasAnyPermission()).listener(this).build("button.details");
// Add button
this.buttonAdd = new UIButtonBuilder(this).width(10).x(SimpleScreen.getPaddedX(this.buttonDetails, 2, Anchor.RIGHT)).text(Text.of(TextColors.GREEN, "+")).tooltip(Text.of("almura.guide.view.button.add.tooltip")).anchor(Anchor.TOP | Anchor.RIGHT).visible(hasAnyPermission()).enabled(hasAddPermission()).listener(this).build("button.add");
// Pages dropdown
this.pagesSelect = new UISelect<>(this, SimpleScreen.getPaddedWidth(form));
this.pagesSelect.setLabelFunction(PageListEntry::getName);
this.pagesSelect.setName("combobox.pages");
this.pagesSelect.setPosition(this.buttonRemove.isVisible() ? SimpleScreen.getPaddedX(this.buttonRemove, innerPadding) : 0, 0);
this.pagesSelect.register(this);
if (hasAnyPermission()) {
this.pagesSelect.setSize(this.pagesSelect.getWidth() - this.buttonDetails.getWidth() - this.buttonAdd.getWidth() - this.buttonRemove.getWidth() - (innerPadding * 4) + 2, 15);
}
// Formatted button
this.buttonFormat = new UIButtonBuilder(this).width(10).anchor(Anchor.BOTTOM | Anchor.LEFT).visible(this.hasAnyPermission()).listener(this).build("button.format");
// Content text field
contentField = new UITextField(this, "", true);
contentField.setSize(SimpleScreen.getPaddedWidth(form), SimpleScreen.getPaddedHeight(form) - this.pagesSelect.getHeight() - (innerPadding * 2) - this.buttonFormat.getHeight());
contentField.setPosition(0, SimpleScreen.getPaddedY(this.pagesSelect, innerPadding));
contentField.setEditable(this.hasModifyPermission());
contentField.setOptions(0x555555, 0xc8c8c8, 0x00000);
// Close button
final UIButton buttonClose = new UIButtonBuilder(this).width(40).anchor(Anchor.BOTTOM | Anchor.RIGHT).text(Text.of("almura.guide.button.close")).listener(this).build("button.close");
// Save button
this.buttonSave = new UIButtonBuilder(this).width(40).anchor(Anchor.BOTTOM | Anchor.RIGHT).x(SimpleScreen.getPaddedX(buttonClose, innerPadding, Anchor.RIGHT)).text(Text.of("almura.guide.button.save")).visible(hasAnyPermission()).enabled(hasModifyPermission()).listener(this).build("button.save");
form.add(this.buttonRemove, this.pagesSelect, this.buttonDetails, this.buttonAdd, this.buttonFormat, contentField, buttonClose, buttonSave);
addToScreen(form);
this.updateButtons();
}
Aggregations