Search in sources :

Example 1 with BasicForm

use of net.malisis.core.client.gui.component.container.BasicForm in project Almura by AlmuraDev.

the class IngameFarmersAlmanac method construct.

// TODO: Translation support
@SuppressWarnings("deprecation, unchecked")
@Override
public void construct() {
    guiscreenBackground = false;
    final BasicForm form = new BasicForm(this, formWidth, formHeight, formTitle);
    form.setClosable(false);
    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(BasicScreen.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(), BasicScreen.getPaddedY(labelLocalizedName, 2));
    form.add(labelRegistryName);
    // Property container
    this.propertyContainer = new BasicContainer<>(this);
    new UISlimScrollbar(this, this.propertyContainer, UIScrollBar.Type.VERTICAL).setAutoHide(true);
    this.propertyContainer.setBackgroundAlpha(35);
    this.propertyContainer.setPosition(0, BasicScreen.getPaddedY(labelRegistryName, 5), Anchor.TOP | Anchor.CENTER);
    this.propertyContainer.setBorder(FontColors.WHITE, 1, 185);
    form.add(this.propertyContainer);
    // Init this early so we can load stuff to it later.
    this.cropStatusLabel = new UILabel(this);
    // Get all displayed properties
    loadProperties(world, blockState, blockPos);
    // Adjust the size of the container to reach at most the specified max height
    this.propertyContainer.setSize(UIComponent.INHERITED, Math.min(propertyContainerMaxHeight, propertyContainer.getContentHeight() + 2));
    // Localized name
    if (this.growing) {
        this.cropStatusLabel.setText(TextFormatting.DARK_GREEN + "Growing...");
    } else if (this.canDie) {
        this.cropStatusLabel.setText(TextFormatting.RED + "Dying!");
    } else {
        this.cropStatusLabel.setText(TextFormatting.YELLOW + "Not Growing...");
    }
    if (this.readyForHarvest) {
        this.cropStatusLabel.setText(TextFormatting.GREEN + "Ready for Harvest!");
    }
    this.cropStatusLabel.setFontOptions(FontColors.WHITE_FO);
    this.cropStatusLabel.setPosition(1, -3, Anchor.BOTTOM | Anchor.LEFT);
    form.add(cropStatusLabel);
    final UIButton closeButton = new UIButtonBuilder(this).text("Close").anchor(Anchor.BOTTOM | Anchor.RIGHT).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
    this.propertyContainer.setSize(propertyContainer.getWidth(), propertyContainer.getHeight());
    addToScreen(form);
    Mouse.setGrabbed(false);
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) IBlockState(net.minecraft.block.state.IBlockState) UISlimScrollbar(net.malisis.core.client.gui.component.control.UISlimScrollbar) RayTraceResult(net.minecraft.util.math.RayTraceResult) WorldClient(net.minecraft.client.multiplayer.WorldClient) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) UIImage(net.malisis.core.client.gui.component.decoration.UIImage)

Example 2 with BasicForm

use of net.malisis.core.client.gui.component.container.BasicForm in project Almura by AlmuraDev.

the class ClaimManageScreen method construct.

@SuppressWarnings("unchecked")
@Override
public void construct() {
    this.guiscreenBackground = false;
    Keyboard.enableRepeatEvents(true);
    final DecimalFormat dFormat = new DecimalFormat("###,###,##0.00");
    this.form = new BasicForm(this, 400, 260, "");
    this.form.setAnchor(Anchor.CENTER | Anchor.MIDDLE);
    this.form.setMovable(true);
    this.form.setClosable(true);
    this.form.setBorder(FontColors.WHITE, 1, 185);
    this.form.setBackgroundAlpha(215);
    this.form.setBottomPadding(3);
    this.form.setRightPadding(3);
    this.form.setTopPadding(20);
    this.form.setLeftPadding(3);
    final UILabel titleLabel = new UILabel(this, "Claim Manager");
    titleLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    titleLabel.setPosition(0, -15, Anchor.CENTER | Anchor.TOP);
    final UISeparator separator = new UISeparator(this);
    separator.setSize(form.getWidth() - 15, 1);
    separator.setPosition(0, 0, Anchor.TOP | Anchor.CENTER);
    this.wildernessLabel = new UILabel(this, "Wilderness");
    this.wildernessLabel.setFontOptions(FontOptions.builder().from(FontColors.GREEN_FO).shadow(true).scale(2.5F).build());
    this.wildernessLabel.setPosition(0, 30, Anchor.CENTER | Anchor.TOP);
    this.wildernessLabel.setVisible(false);
    this.claimNameLabel = new UILabel(this, "Name:");
    this.claimNameLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.claimNameLabel.setPosition(7, 8, Anchor.LEFT | Anchor.TOP);
    this.claimNameField = new UITextField(this, "", false);
    this.claimNameField.setSize(150, 0);
    this.claimNameField.setText(clientClaimManager.claimName);
    this.claimNameField.setEditable(this.isOwner || this.isAdmin);
    this.claimNameField.setPosition(60, claimNameLabel.getY() - 2, Anchor.LEFT | Anchor.TOP);
    this.claimNameField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    this.claimOwnerLabel = new UILabel(this, "Owner:");
    this.claimOwnerLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.claimOwnerLabel.setPosition(7, claimNameLabel.getY() + 15, Anchor.LEFT | Anchor.TOP);
    this.claimOwnerField = new UITextField(this, "", false);
    this.claimOwnerField.setSize(150, 0);
    this.claimOwnerField.setText(clientClaimManager.claimOwner);
    this.claimOwnerField.setEditable(false);
    this.claimOwnerField.setPosition(60, claimOwnerLabel.getY() - 2, Anchor.LEFT | Anchor.TOP);
    this.claimOwnerField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    this.claimGreetingLabel = new UILabel(this, "Greeting:");
    this.claimGreetingLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.claimGreetingLabel.setPosition(7, claimOwnerLabel.getY() + 15, Anchor.LEFT | Anchor.TOP);
    this.claimGreetingField = new UITextField(this, "", false);
    this.claimGreetingField.setSize(200, 0);
    this.claimGreetingField.setText(clientClaimManager.claimGreeting);
    this.claimGreetingField.setEditable(this.isOwner || this.isAdmin);
    this.claimGreetingField.setPosition(60, claimGreetingLabel.getY() - 2, Anchor.LEFT | Anchor.TOP);
    this.claimGreetingField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    this.claimFarewellLabel = new UILabel(this, "Farewell:");
    this.claimFarewellLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.claimFarewellLabel.setPosition(7, claimGreetingLabel.getY() + 15, Anchor.LEFT | Anchor.TOP);
    this.claimFarewellField = new UITextField(this, "", false);
    this.claimFarewellField.setSize(200, 0);
    this.claimFarewellField.setText(clientClaimManager.claimFarewell);
    this.claimFarewellField.setEditable(this.isOwner || this.isAdmin);
    this.claimFarewellField.setPosition(60, claimFarewellLabel.getY() - 2, Anchor.LEFT | Anchor.TOP);
    this.claimFarewellField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    this.dateCreatedLabel = new UILabel(this, "Created:");
    this.dateCreatedLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.dateCreatedLabel.setPosition(7, claimFarewellLabel.getY() + 15, Anchor.LEFT | Anchor.TOP);
    this.dateCreatedField = new UITextField(this, "", false);
    this.dateCreatedField.setSize(150, 0);
    this.dateCreatedField.setText(clientClaimManager.dateCreated);
    this.dateCreatedField.setEditable(false);
    this.dateCreatedField.setPosition(60, dateCreatedLabel.getY() - 2, Anchor.LEFT | Anchor.TOP);
    this.dateCreatedField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    this.claimTypeLabel = new UILabel(this, "Type:");
    this.claimTypeLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.claimTypeLabel.setPosition(7, dateCreatedLabel.getY() + 15, Anchor.LEFT | Anchor.TOP);
    this.claimTypeField = new UITextField(this, "", false);
    this.claimTypeField.setSize(150, 0);
    this.claimTypeField.setText(clientClaimManager.claimType);
    this.claimTypeField.setEditable(false);
    this.claimTypeField.setPosition(60, claimTypeLabel.getY() - 2, Anchor.LEFT | Anchor.TOP);
    this.claimTypeField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    // Economy Container
    this.econArea = new BasicForm(this, 252, 125, "");
    this.econArea.setPosition(7, claimTypeLabel.getY() + 15, Anchor.LEFT | Anchor.TOP);
    this.econArea.setMovable(false);
    this.econArea.setClosable(false);
    this.econArea.setBorder(FontColors.WHITE, 1, 185);
    this.econArea.setBackgroundAlpha(215);
    this.econArea.setBottomPadding(3);
    this.econArea.setRightPadding(3);
    this.econArea.setTopPadding(3);
    this.econArea.setLeftPadding(3);
    this.econArea.setVisible(!clientClaimManager.isWilderness);
    this.econTitleLabel = new UILabel(this, "Economy Functions");
    this.econTitleLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.econTitleLabel.setPosition(0, 2, Anchor.CENTER | Anchor.TOP);
    final UISeparator econSeparator = new UISeparator(this);
    econSeparator.setSize(econArea.getWidth() - 15, 1);
    econSeparator.setPosition(0, econTitleLabel.getY() + 13, Anchor.TOP | Anchor.CENTER);
    this.claimSizeLabel = new UILabel(this, "Claim Size: (Blocks)");
    this.claimSizeLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.claimSizeLabel.setPosition(15, econSeparator.getY() + 10, Anchor.LEFT | Anchor.TOP);
    this.claimSizeField = new UITextField(this, "", false);
    this.claimSizeField.setSize(95, 0);
    this.claimSizeField.setText("" + NumberFormat.getNumberInstance(Locale.US).format(clientClaimManager.claimSize));
    this.claimSizeField.setEditable(false);
    this.claimSizeField.setTooltip("Total blocks included in claim");
    this.claimSizeField.setPosition(125, this.claimSizeLabel.getY() - 2, Anchor.LEFT | Anchor.TOP);
    this.claimSizeField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    this.claimValueLabel = new UILabel(this, "Estimated Value:");
    this.claimValueLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.claimValueLabel.setPosition(15, claimSizeLabel.getY() + 15, Anchor.LEFT | Anchor.TOP);
    this.claimValueField = new UITextField(this, "", false);
    this.claimValueField.setSize(95, 0);
    this.claimValueField.setText("$ 1,456,434.00");
    this.claimValueField.setEditable(false);
    this.claimValueField.setPosition(125, claimValueLabel.getY() - 2, Anchor.LEFT | Anchor.TOP);
    this.claimValueField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    this.taxRateLabel = new UILabel(this, "Tax Rate per Block:");
    this.taxRateLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.taxRateLabel.setPosition(15, claimValueLabel.getY() + 15, Anchor.LEFT | Anchor.TOP);
    this.claimTaxRateField = new UITextField(this, "", false);
    this.claimTaxRateField.setSize(95, 0);
    this.claimTaxRateField.setText("" + NumberFormat.getNumberInstance(Locale.US).format(clientClaimManager.claimTaxRate));
    this.claimTaxRateField.setEditable(false);
    this.claimTaxRateField.setTooltip("Tax Rate per block");
    this.claimTaxRateField.setPosition(125, this.taxRateLabel.getY() - 2, Anchor.LEFT | Anchor.TOP);
    this.claimTaxRateField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    this.claimTaxLabel = new UILabel(this, "Estimated Taxes:");
    this.claimTaxLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.claimTaxLabel.setPosition(15, taxRateLabel.getY() + 15, Anchor.LEFT | Anchor.TOP);
    this.claimTaxField = new UITextField(this, "", false);
    this.claimTaxField.setSize(95, 0);
    this.claimTaxField.setText("$ 56,434.00");
    this.claimTaxField.setEditable(false);
    this.claimTaxField.setPosition(125, this.claimTaxLabel.getY() - 2, Anchor.LEFT | Anchor.TOP);
    this.claimTaxField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    this.claimTaxBalanceLabel = new UILabel(this, "Claim Tax Balance:");
    this.claimTaxBalanceLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.claimTaxBalanceLabel.setPosition(15, claimTaxLabel.getY() + 15, Anchor.LEFT | Anchor.TOP);
    this.claimTaxBalanceField = new UITextField(this, "", false);
    this.claimTaxBalanceField.setSize(95, 0);
    this.claimTaxBalanceField.setText("$ 56,434.00");
    this.claimTaxBalanceField.setEditable(false);
    this.claimTaxBalanceField.setPosition(125, this.claimTaxBalanceLabel.getY() - 2, Anchor.LEFT | Anchor.TOP);
    this.claimTaxBalanceField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    this.claimForSaleLabel = new UILabel(this, "<- Claim is For Sale ->");
    this.claimForSaleLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.claimForSaleLabel.setPosition(0, 0, Anchor.CENTER | Anchor.BOTTOM);
    this.claimForSaleLabel.setVisible(true);
    this.claimForSaleLabel.setFontOptions(FontOptions.builder().from(FontColors.GREEN_FO).shadow(false).scale(1.2F).build());
    this.forSaleLabel = new UILabel(this, "For Sale Price:");
    this.forSaleLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.forSaleLabel.setPosition(15, claimTaxBalanceLabel.getY() + 20, Anchor.LEFT | Anchor.TOP);
    this.forSalePriceField = new UITextField(this, "", false);
    this.forSalePriceField.setSize(95, 0);
    this.forSalePriceField.setText("" + NumberFormat.getNumberInstance(Locale.US).format(clientClaimManager.claimSalePrice));
    this.forSalePriceField.setTooltip("Sale Price of this Claim");
    this.forSalePriceField.setPosition(125, this.forSaleLabel.getY() - 2, Anchor.LEFT | Anchor.TOP);
    this.forSalePriceField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    this.econArea.add(econSeparator, econSeparator, econTitleLabel, claimValueLabel, this.claimValueField, this.claimTaxLabel, this.claimTaxField, this.claimForSaleLabel, this.claimTaxBalanceLabel, this.claimTaxBalanceField, this.claimSizeLabel, this.claimSizeField, this.forSaleLabel, this.forSalePriceField, this.taxRateLabel, this.claimTaxRateField);
    // Functions Container
    this.functionsArea = new BasicForm(this, 110, 200, "");
    this.functionsArea.setPosition(-10, 5, Anchor.RIGHT | Anchor.TOP);
    this.functionsArea.setMovable(false);
    this.functionsArea.setClosable(false);
    this.functionsArea.setBorder(FontColors.WHITE, 1, 185);
    this.functionsArea.setBackgroundAlpha(215);
    this.functionsArea.setBottomPadding(3);
    this.functionsArea.setRightPadding(3);
    this.functionsArea.setTopPadding(3);
    this.functionsArea.setLeftPadding(3);
    this.functionsArea.setVisible(!clientClaimManager.isWilderness);
    this.claimFunctionsLabel = new UILabel(this, "Claim Functions");
    this.claimFunctionsLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.claimFunctionsLabel.setPosition(0, 4, Anchor.CENTER | Anchor.TOP);
    final UISeparator functionsSeparator = new UISeparator(this);
    functionsSeparator.setSize(this.functionsArea.getWidth() - 15, 1);
    functionsSeparator.setPosition(0, 15, Anchor.TOP | Anchor.CENTER);
    this.buttonVisuals = new UIButton(this);
    this.buttonVisuals.setText(TextFormatting.WHITE + "Toggle Visuals");
    this.buttonVisuals.setPosition(0, 20, Anchor.CENTER | Anchor.TOP);
    this.buttonVisuals.setEnabled(this.isOwner || this.isAdmin);
    this.buttonVisuals.setName("button.visuals");
    // this.buttonVisuals.setVisible(this.clientClaimManager.hasWECUI);
    this.buttonVisuals.register(this);
    buttonAbandon = new UIButtonBuilder(this).width(40).y(buttonVisuals.getY() + 20).anchor(Anchor.CENTER | Anchor.TOP).text("Abandon Claim").listener(this).enabled(this.isOwner || this.isAdmin).build("button.abandon");
    buttonSetForSale = new UIButtonBuilder(this).width(40).y(buttonAbandon.getY() + 20).anchor(Anchor.CENTER | Anchor.TOP).text("For Sale").listener(this).enabled(this.isOwner || this.isAdmin).visible(true).build("button.toggleforsale");
    buttonSetSpawnLocation = new UIButtonBuilder(this).width(40).y(buttonSetForSale.getY() + 20).anchor(Anchor.CENTER | Anchor.TOP).text("Set Spawn").listener(this).enabled(this.isOwner || this.isAdmin).visible(true).build("button.setspawnlocation");
    this.functionsArea.add(claimFunctionsLabel, functionsSeparator, buttonAbandon, buttonSetForSale, buttonSetSpawnLocation, buttonVisuals);
    this.showWarningsCheckbox = new UICheckBox(this);
    this.showWarningsCheckbox.setText(TextFormatting.WHITE + "Show Permission Denied Messages");
    this.showWarningsCheckbox.setPosition(7, -1, Anchor.LEFT | Anchor.BOTTOM);
    this.showWarningsCheckbox.setChecked(clientClaimManager.showWarnings);
    this.showWarningsCheckbox.setEnabled(this.isOwner || this.isAdmin);
    this.showWarningsCheckbox.setName("checkbox.showwarnings");
    this.showWarningsCheckbox.setVisible(!clientClaimManager.isWilderness);
    this.showWarningsCheckbox.register(this);
    this.buttonHideVisuals = new UIButton(this);
    this.buttonHideVisuals.setText(TextFormatting.WHITE + "Hide Visuals");
    this.buttonHideVisuals.setPosition(0, 0, Anchor.LEFT | Anchor.BOTTOM);
    this.buttonHideVisuals.setEnabled(true);
    this.buttonHideVisuals.setName("button.visuals");
    this.buttonHideVisuals.register(this);
    final UIButton buttonSave = new UIButtonBuilder(this).width(40).x(-45).anchor(Anchor.RIGHT | Anchor.BOTTOM).text("Save").listener(this).enabled(this.isOwner || this.isAdmin).build("button.save");
    // Dont show save button for wilderness
    buttonSave.setVisible(!clientClaimManager.isWilderness);
    final UIButton buttonClose = new UIButtonBuilder(this).width(40).anchor(Anchor.RIGHT | Anchor.BOTTOM).text("almura.button.close").listener(this).build("button.close");
    this.form.add(titleLabel, separator, wildernessLabel, claimNameLabel, this.claimNameField, this.claimOwnerLabel, this.claimOwnerField, this.claimGreetingLabel, this.claimGreetingField, this.claimFarewellLabel, this.claimFarewellField, this.dateCreatedLabel, this.dateCreatedField, this.claimTypeLabel, this.claimTypeField, this.econArea, this.functionsArea, this.showWarningsCheckbox, buttonHideVisuals, buttonSave, buttonClose);
    updateValues();
    addToScreen(this.form);
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) DecimalFormat(java.text.DecimalFormat) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) UISeparator(net.malisis.core.client.gui.component.decoration.UISeparator) UITextField(net.malisis.core.client.gui.component.interaction.UITextField) UICheckBox(net.malisis.core.client.gui.component.interaction.UICheckBox)

Example 3 with BasicForm

use of net.malisis.core.client.gui.component.container.BasicForm in project Almura by AlmuraDev.

the class DisconnectedGui method construct.

@Override
public void construct() {
    this.guiscreenBackground = true;
    Keyboard.enableRepeatEvents(true);
    this.form = new BasicForm(this, 350, 140, "Server Status");
    this.form.setAnchor(Anchor.CENTER | Anchor.MIDDLE);
    this.form.setMovable(false);
    this.form.setClosable(false);
    this.form.setBorder(FontColors.WHITE, 1, 185);
    this.form.setBackgroundAlpha(215);
    this.form.setBottomPadding(3);
    this.form.setRightPadding(3);
    this.form.setTopPadding(20);
    this.form.setLeftPadding(3);
    // Almura header
    final UIImage almuraHeader = new UIImage(this, new GuiTexture(GuiConfig.Location.DEAD_STEVE), null);
    almuraHeader.setSize(59, 59);
    almuraHeader.setPosition(0, 5, Anchor.TOP | Anchor.CENTER);
    this.messageLabel = new UILabel(this, "Disconnected from Server");
    this.messageLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.messageLabel.setPosition(0, almuraHeader.getHeight() + 5, Anchor.CENTER | Anchor.TOP);
    final UISeparator belowLabelSeparator = new UISeparator(this);
    belowLabelSeparator.setSize(this.form.getWidth() - 5, 1);
    belowLabelSeparator.setPosition(0, this.messageLabel.getY() + 10, Anchor.CENTER | Anchor.TOP);
    this.form.add(belowLabelSeparator);
    this.reasonBox = new BasicTextBox(this, "Unknown Reason", true);
    this.reasonBox.setAlpha(0);
    this.reasonBox.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(0.7F).build());
    this.reasonBox.setPosition(0, this.messageLabel.getY() + 14, Anchor.CENTER | Anchor.TOP);
    this.reasonBox.setOptions(16238795, 0, 0);
    this.reasonBox.setSize(this.form.getWidth() - 5, 15);
    if (reason.length() > 0) {
        this.reasonBox.setText(reason);
    }
    for (int i = 0; i < 4; i++) {
        if (this.reasonBox.getScrollbar().isEnabled()) {
            this.reasonBox.setSize(this.reasonBox.getWidth(), this.reasonBox.getHeight() + 15);
            this.form.setSize(this.form.getWidth(), this.form.getHeight() + 15);
        }
    }
    this.reasonBox.getScrollbar().autoHide = true;
    final UISeparator aboveButtonsSeparator = new UISeparator(this);
    aboveButtonsSeparator.setSize(this.form.getWidth() - 5, 1);
    aboveButtonsSeparator.setPosition(0, -20, Anchor.BOTTOM | Anchor.CENTER);
    this.form.add(aboveButtonsSeparator);
    // Close button
    this.buttonClose = new UIButtonBuilder(this).width(40).anchor(Anchor.BOTTOM | Anchor.CENTER).position(0, -1).text("Return to Server Menu").fontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).build()).listener(this).build("button.return");
    this.form.add(almuraHeader, this.messageLabel, this.reasonBox, this.buttonClose);
    addToScreen(this.form);
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) GuiTexture(net.malisis.core.client.gui.GuiTexture) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) UISeparator(net.malisis.core.client.gui.component.decoration.UISeparator) UIImage(net.malisis.core.client.gui.component.decoration.UIImage) BasicTextBox(net.malisis.core.client.gui.component.interaction.BasicTextBox)

Example 4 with BasicForm

use of net.malisis.core.client.gui.component.container.BasicForm in project Almura by AlmuraDev.

the class NicknameGUI method construct.

@SuppressWarnings("unchecked")
@Override
public void construct() {
    this.guiscreenBackground = false;
    Keyboard.enableRepeatEvents(true);
    // Master Panel
    this.form = new BasicForm(this, 400, 225, "");
    this.form.setAnchor(Anchor.CENTER | Anchor.MIDDLE);
    this.form.setMovable(true);
    this.form.setClosable(true);
    this.form.setBorder(FontColors.WHITE, 1, 185);
    this.form.setBackgroundAlpha(215);
    this.form.setBottomPadding(3);
    this.form.setRightPadding(3);
    this.form.setTopPadding(20);
    this.form.setLeftPadding(3);
    final UILabel titleLabel = new UILabel(this, "Nicknames");
    titleLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    titleLabel.setPosition(0, -15, Anchor.CENTER | Anchor.TOP);
    // Player Render Area
    final BasicForm playerArea = new BasicForm(this, 175, 185, "");
    playerArea.setPosition(0, 0, Anchor.RIGHT | Anchor.MIDDLE);
    playerArea.setMovable(false);
    playerArea.setClosable(false);
    playerArea.setBorder(FontColors.WHITE, 1, 185);
    playerArea.setBackgroundAlpha(215);
    playerArea.setBottomPadding(3);
    playerArea.setRightPadding(3);
    playerArea.setTopPadding(3);
    playerArea.setLeftPadding(3);
    // Nickname List Area
    final BasicForm listArea = new BasicForm(this, 217, 85, "");
    listArea.setPosition(0, 0, Anchor.LEFT | Anchor.TOP);
    listArea.setMovable(false);
    listArea.setClosable(false);
    listArea.setBorder(FontColors.WHITE, 1, 185);
    listArea.setBackgroundAlpha(215);
    listArea.setBottomPadding(3);
    listArea.setRightPadding(3);
    listArea.setTopPadding(3);
    listArea.setLeftPadding(3);
    final UILabel nicknameLabel = new UILabel(this, "Enter desired nickname:");
    nicknameLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    nicknameLabel.setPosition(7, 10, Anchor.LEFT | Anchor.TOP);
    // Nickname Entry Textbox
    this.nicknameTextbox = new UITextField(this, "", false);
    this.nicknameTextbox.setSize(150, 0);
    this.nicknameTextbox.setText(this.originalNickname);
    this.nicknameTextbox.setPosition(7, 23, Anchor.LEFT | Anchor.TOP);
    this.nicknameTextbox.setEditable(true);
    this.nicknameTextbox.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    final UILabel colorLabel = new UILabel(this, "Add colors:");
    colorLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    colorLabel.setPosition(7, 40, Anchor.LEFT | Anchor.TOP);
    // Color Selection dropdown
    this.colorSelector = new UISelect<>(this, 100, Arrays.asList("§1Dark Blue", "§9Blue", "§3Dark Aqua", "§bAqua", "§4Dark Red", "§cRed", "§eYellow", "§6Gold", "§2Dark Green", "§aGreen", "§5Dark Purple", "§dLight Purple", "§fWhite", "§7Gray", "§8Dark Gray", "§0Black,"));
    this.colorSelector.setPosition(7, 50, Anchor.LEFT | Anchor.TOP);
    this.colorSelector.setOptionsWidth(UISelect.SELECT_WIDTH);
    this.colorSelector.setFontOptions(FontOptions.builder().shadow(false).build());
    this.colorSelector.select("§1Dark Blue");
    // Add Color character button
    final UIButton buttonColor = new UIButtonBuilder(this).width(40).position(110, 49, Anchor.LEFT | Anchor.TOP).text(I18n.format("almura.button.add")).listener(this).build("button.color");
    // Reset button
    final UIButton buttonReset = new UIButtonBuilder(this).width(40).position(150, 49, Anchor.LEFT | Anchor.TOP).text(I18n.format("almura.button.reset")).listener(this).build("button.reset");
    // Remove Nickname button
    final UIButton buttonRemove = new UIButtonBuilder(this).width(70).position(105, 65, Anchor.LEFT | Anchor.TOP).text(I18n.format("almura.button.nick.remove")).enabled(this.canChangeNickname).listener(this).build("button.remove");
    final UILabel nicknameRulesLabel = new UILabel(this, "Please follow nickname rules.");
    nicknameRulesLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    nicknameRulesLabel.setPosition(3, -2, Anchor.LEFT | Anchor.BOTTOM);
    // Close button
    final UIButton buttonClose = new UIButtonBuilder(this).width(40).anchor(Anchor.BOTTOM | Anchor.RIGHT).text("almura.button.close").listener(this).build("button.close");
    // Apply button
    final UIButton buttonApply = new UIButtonBuilder(this).width(40).anchor(Anchor.BOTTOM | Anchor.RIGHT).position(-40, 0).text("almura.button.apply").enabled(this.canChangeNickname).listener(this).build("button.apply");
    this.form.add(titleLabel, listArea, playerArea, nicknameLabel, this.nicknameTextbox, nicknameRulesLabel, colorLabel, this.colorSelector, buttonColor, buttonReset, buttonRemove, buttonClose, buttonApply);
    addToScreen(this.form);
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) UITextField(net.malisis.core.client.gui.component.interaction.UITextField)

Example 5 with BasicForm

use of net.malisis.core.client.gui.component.container.BasicForm in project Almura by AlmuraDev.

the class StoreTransactQuantityScreen method construct.

@Override
public void construct() {
    this.guiscreenBackground = false;
    this.form = new BasicForm(this, 130, 90, I18n.format("almura.feature.exchange.title.enter_a_quantity"));
    // Fixes issue overlapping draws from parent
    this.form.setZIndex(10);
    this.form.setBackgroundAlpha(255);
    this.quantityLabel = new UILabel(this, I18n.format("almura.feature.common.text.quantity") + ":");
    this.quantityLabel.setFontOptions(FontColors.WHITE_FO);
    this.quantityLabel.setPosition(0, 2);
    this.quantityTextBox = new BasicTextBox(this, "1");
    this.quantityTextBox.setAcceptsReturn(false);
    this.quantityTextBox.setOnEnter(tb -> this.transact());
    this.quantityTextBox.setSize(45, 0);
    this.quantityTextBox.setPosition(0, 0, Anchor.TOP | Anchor.RIGHT);
    this.quantityTextBox.setFilter(s -> String.valueOf(MathUtil.squashi(Integer.parseInt(s.replaceAll("[^\\d]", "")), 1, this.maxTransactable)));
    this.quantityTextBox.setPosition(0, 0);
    this.quantityTextBox.register(this);
    this.perItemLabel = new UILabel(this, "Per:");
    this.perItemLabel.setPosition(0, BasicScreen.getPaddedY(this.quantityTextBox, 8));
    this.perItemLabel.setFontOptions(FontColors.WHITE_FO);
    this.perItemValueLabel = new UILabel(this, "");
    this.perItemValueLabel.setPosition(0, this.perItemLabel.getY(), Anchor.TOP | Anchor.RIGHT);
    this.perItemValueLabel.setFontOptions(FontColors.WHITE_FO);
    this.totalLabel = new UILabel(this, I18n.format("almura.feature.common.text.total") + ":");
    this.totalLabel.setPosition(0, BasicScreen.getPaddedY(this.perItemLabel, 4));
    this.totalLabel.setFontOptions(FontColors.WHITE_FO);
    this.totalValueLabel = new UILabel(this, "");
    this.totalValueLabel.setPosition(0, this.totalLabel.getY(), Anchor.TOP | Anchor.RIGHT);
    this.totalValueLabel.setFontOptions(FontColors.WHITE_FO);
    this.buttonTransact = new UIButtonBuilder(this).text(I18n.format("almura.feature.common.button." + sideType.name().toLowerCase())).width(40).position(-2, -2).anchor(Anchor.RIGHT | Anchor.BOTTOM).onClick(this::transact).build("button.transact");
    this.buttonCancel = new UIButtonBuilder(this).text(I18n.format("almura.button.cancel")).width(40).position(BasicScreen.getPaddedX(this.buttonTransact, 2, Anchor.RIGHT), -2).anchor(Anchor.RIGHT | Anchor.BOTTOM).onClick(this::close).build("button.cancel");
    this.form.add(this.quantityLabel, this.quantityTextBox, this.perItemLabel, this.perItemValueLabel, this.totalLabel, this.totalValueLabel, this.buttonCancel, this.buttonTransact);
    this.updateControls(this.quantityTextBox.getText());
    this.addToScreen(this.form);
    this.quantityTextBox.focus();
    this.quantityTextBox.selectAll();
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) BasicTextBox(net.malisis.core.client.gui.component.interaction.BasicTextBox)

Aggregations

BasicForm (net.malisis.core.client.gui.component.container.BasicForm)25 UIButtonBuilder (net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder)25 UILabel (net.malisis.core.client.gui.component.decoration.UILabel)23 UIButton (net.malisis.core.client.gui.component.interaction.UIButton)17 UISeparator (net.malisis.core.client.gui.component.decoration.UISeparator)11 BasicTextBox (net.malisis.core.client.gui.component.interaction.BasicTextBox)10 UIImage (net.malisis.core.client.gui.component.decoration.UIImage)6 BasicContainer (net.malisis.core.client.gui.component.container.BasicContainer)4 UICheckBox (net.malisis.core.client.gui.component.interaction.UICheckBox)4 UITextField (net.malisis.core.client.gui.component.interaction.UITextField)4 GuiTexture (net.malisis.core.client.gui.GuiTexture)3 BasicLine (net.malisis.core.client.gui.component.decoration.BasicLine)3 ItemStack (net.minecraft.item.ItemStack)3 Subscribe (com.google.common.eventbus.Subscribe)2 DecimalFormat (java.text.DecimalFormat)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 Anchor (net.malisis.core.client.gui.Anchor)2