Search in sources :

Example 11 with UIButtonBuilder

use of net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder in project Almura by AlmuraDev.

the class UIExchangeOfferContainer method createMiddleContainer.

@Override
protected BasicContainer<?> createMiddleContainer(final MalisisGui gui) {
    if (this.targetSide == null) {
        this.targetSide = SideType.RIGHT;
    }
    final BasicContainer<?> middleContainer = new BasicContainer<>(gui, 38, 111);
    middleContainer.setPosition(0, 0, Anchor.MIDDLE | Anchor.CENTER);
    middleContainer.setBorder(FontColors.WHITE, 1, 185);
    middleContainer.setBackgroundAlpha(0);
    this.buttonSingle = new UIButtonBuilder(gui).size(20).position(0, 3).anchor(Anchor.TOP | Anchor.CENTER).text("1").tooltip(I18n.format("almura.feature.exchange.tooltip.move_single", this.targetSide.toString().toLowerCase())).onClick(() -> TransferType.SINGLE.transfer(this, this.targetSide, this.getOpposingListFromSide(this.targetSide).getSelectedItem())).enabled(false).build("button.one");
    this.buttonStack = new UIButtonBuilder(gui).size(20).position(0, BasicScreen.getPaddedY(this.buttonSingle, 2)).anchor(Anchor.TOP | Anchor.CENTER).text("S").tooltip(I18n.format("almura.feature.exchange.tooltip.move_stack", this.targetSide.toString().toLowerCase())).onClick(() -> TransferType.STACK.transfer(this, this.targetSide, this.getOpposingListFromSide(this.targetSide).getSelectedItem())).enabled(false).build("button.stack");
    this.labelDirection = new UILabel(gui, "->");
    this.labelDirection.setFontOptions(FontColors.WHITE_FO);
    this.labelDirection.setPosition(0, BasicScreen.getPaddedY(this.buttonStack, 6), Anchor.TOP | Anchor.CENTER);
    this.buttonType = new UIButtonBuilder(gui).size(20).position(0, BasicScreen.getPaddedY(this.labelDirection, 6)).anchor(Anchor.TOP | Anchor.CENTER).text("T").tooltip(I18n.format("almura.feature.exchange.tooltip.move_type", this.targetSide.toString().toLowerCase())).onClick(() -> TransferType.TYPE.transfer(this, this.targetSide, this.getOpposingListFromSide(this.targetSide).getSelectedItem())).enabled(false).build("button.type");
    this.buttonAll = new UIButtonBuilder(gui).size(20).position(0, BasicScreen.getPaddedY(this.buttonType, 2)).anchor(Anchor.TOP | Anchor.CENTER).text("A").tooltip(I18n.format("almura.feature.exchange.tooltip.move_all", this.targetSide.toString().toLowerCase())).onClick(() -> TransferType.ALL.transfer(this, this.targetSide, null)).enabled(false).build("button.all");
    middleContainer.add(this.buttonSingle, this.buttonStack, this.labelDirection, this.buttonType, this.buttonAll);
    return middleContainer;
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) BasicContainer(net.malisis.core.client.gui.component.container.BasicContainer)

Example 12 with UIButtonBuilder

use of net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder in project Almura by AlmuraDev.

the class ExchangeScreen method construct.

@Override
public void construct() {
    guiscreenBackground = false;
    // Detect if screen area is large enough to display.
    if (minScreenWidth > this.resolution.getScaledWidth() || minScreenHeight > this.resolution.getScaledHeight()) {
        notificationManager.handlePopup(new PopupNotification("Exchange Error", "Screen area of: " + minScreenHeight + " x " + minScreenWidth + " required.", 5));
        this.close();
        return;
    }
    // Main Panel
    final BasicForm form = new BasicForm(this, minScreenWidth, minScreenHeight, this.getExchange().getName());
    // Search section
    final BasicContainer<?> searchContainer = new BasicContainer<>(this, 295, 322);
    searchContainer.setPosition(0, 0, Anchor.LEFT | Anchor.TOP);
    searchContainer.setColor(0);
    searchContainer.setBorder(FontColors.WHITE, 1, 185);
    searchContainer.setBackgroundAlpha(215);
    searchContainer.setPadding(3, 3);
    final UILabel itemSearchLabel = new UILabel(this, I18n.format("almura.feature.exchange.text.item_name") + ":");
    itemSearchLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).scale(1.1F).build());
    itemSearchLabel.setPosition(0, 4, Anchor.LEFT | Anchor.TOP);
    this.itemDisplayNameSearchBox = new BasicTextBox(this, "");
    this.itemDisplayNameSearchBox.setAcceptsReturn(false);
    this.itemDisplayNameSearchBox.setAcceptsTab(false);
    this.itemDisplayNameSearchBox.setTabIndex(0);
    this.itemDisplayNameSearchBox.setOnEnter((tb) -> this.search());
    this.itemDisplayNameSearchBox.setSize(145, 0);
    this.itemDisplayNameSearchBox.setPosition(itemSearchLabel.getWidth() + innerPadding, 2, Anchor.LEFT | Anchor.TOP);
    this.itemDisplayNameSearchBox.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    final UILabel sellerSearchLabel = new UILabel(this, I18n.format("almura.feature.exchange.text.seller") + ":");
    sellerSearchLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).scale(1.1F).build());
    sellerSearchLabel.setPosition(itemDisplayNameSearchBox.getX() - sellerSearchLabel.getWidth() - 1, getPaddedY(itemSearchLabel, 7), Anchor.LEFT | Anchor.TOP);
    this.sellerSearchTextBox = new BasicTextBox(this, "");
    this.sellerSearchTextBox.setAcceptsReturn(false);
    this.sellerSearchTextBox.setAcceptsTab(false);
    this.sellerSearchTextBox.setTabIndex(1);
    this.sellerSearchTextBox.setOnEnter(tb -> this.search());
    this.sellerSearchTextBox.setSize(145, 0);
    this.sellerSearchTextBox.setPosition(this.itemDisplayNameSearchBox.getX(), getPaddedY(this.itemDisplayNameSearchBox, 4), Anchor.LEFT | Anchor.TOP);
    this.sellerSearchTextBox.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    // Sort combobox
    // Sort combobox
    this.comboBoxSortType = new UISelect<>(this, 78);
    this.comboBoxSortType.setOptions(Arrays.asList(FeatureSortTypes.CREATED_ASC, FeatureSortTypes.CREATED_DESC, FeatureSortTypes.PRICE_ASC, FeatureSortTypes.PRICE_DESC, FeatureSortTypes.ITEM_DISPLAY_NAME_ASC, FeatureSortTypes.ITEM_DISPLAY_NAME_DESC, ExchangeSortTypes.SELLER_NAME_ASC, ExchangeSortTypes.SELLER_NAME_DESC));
    // Because that's reasonable.
    this.comboBoxSortType.setLabelFunction(type -> type == null ? "" : type.getName());
    this.comboBoxSortType.select(FeatureSortTypes.CREATED_ASC);
    this.comboBoxSortType.setPosition(-(innerPadding + 1), 2, Anchor.RIGHT | Anchor.TOP);
    // Search button
    final UIButton buttonSearch = new UIButtonBuilder(this).width(80).anchor(Anchor.RIGHT | Anchor.TOP).position(-innerPadding, this.sellerSearchTextBox.getY() - 1).text(I18n.format("almura.feature.common.button.search")).onClick(this::search).build("button.search");
    // Separator
    final BasicContainer<?> forSaleTopLine = new BasicContainer<>(this, searchContainer.getRawWidth() - 2, 1);
    forSaleTopLine.setColor(FontColors.WHITE);
    forSaleTopLine.setBackgroundAlpha(185);
    forSaleTopLine.setPosition(0, BasicScreen.getPaddedY(this.sellerSearchTextBox, 4), Anchor.CENTER | Anchor.TOP);
    this.forSaleList = new BasicList<>(this, UIComponent.INHERITED, 254);
    this.forSaleList.setPosition(0, BasicScreen.getPaddedY(forSaleTopLine, 2));
    this.forSaleList.setItemComponentFactory(ForSaleItemComponent::new);
    this.forSaleList.setItemComponentSpacing(1);
    this.forSaleList.setSelectConsumer((i) -> this.updateControls());
    // No results label
    this.noResultsLabel = new UILabel(this, "No results found.");
    this.noResultsLabel.setPosition(0, this.forSaleList.getY() + 8, Anchor.TOP | Anchor.CENTER);
    this.noResultsLabel.setFontOptions(FontColors.GRAY_FO);
    this.noResultsLabel.setVisible(false);
    // Bottom Page Control - first button
    this.buttonFirstPage = new UIButtonBuilder(this).size(20).anchor(Anchor.LEFT | Anchor.BOTTOM).position(0, 0).text("|<").enabled(false).onClick(() -> setPage(1)).build("button.first");
    // Bottom Page Control - previous button
    this.buttonPreviousPage = new UIButtonBuilder(this).size(20).anchor(Anchor.LEFT | Anchor.BOTTOM).position(getPaddedX(this.buttonFirstPage, innerPadding), 0).text("<").enabled(false).onClick(() -> setPage(--this.currentPage)).build("button.previous");
    // Search pages label
    this.labelSearchPage = new UILabel(this, "");
    this.labelSearchPage.setPosition(0, -4, Anchor.CENTER | Anchor.BOTTOM);
    // Bottom Page Control - last button
    this.buttonLastPage = new UIButtonBuilder(this).size(20).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(0, 0).text(">|").enabled(false).onClick(() -> setPage(this.pages)).build("button.last");
    // Bottom Page Control - next button
    this.buttonNextPage = new UIButtonBuilder(this).size(20).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(getPaddedX(this.buttonLastPage, innerPadding, Anchor.RIGHT), 0).text(">").enabled(false).onClick(() -> setPage(++this.currentPage)).build("button.next");
    // Separator
    final BasicLine forSaleBottomLine = new BasicLine(this, searchContainer.getRawWidth() - 2);
    forSaleBottomLine.setPosition(0, BasicScreen.getPaddedY(this.buttonFirstPage, 2, Anchor.BOTTOM), Anchor.CENTER | Anchor.BOTTOM);
    // Add Elements of Search Area
    searchContainer.add(itemSearchLabel, this.itemDisplayNameSearchBox, sellerSearchLabel, this.sellerSearchTextBox, buttonSearch, this.comboBoxSortType, this.buttonFirstPage, this.buttonPreviousPage, this.buttonNextPage, this.buttonLastPage, this.forSaleList, this.noResultsLabel, this.labelSearchPage, forSaleTopLine, forSaleBottomLine);
    // Buy container
    final BasicContainer<?> buyContainer = new BasicContainer(this, 295, 21);
    buyContainer.setPosition(0, getPaddedY(searchContainer, innerPadding), Anchor.LEFT | Anchor.TOP);
    buyContainer.setColor(0);
    buyContainer.setBorder(FontColors.WHITE, 1, 185);
    buyContainer.setBackgroundAlpha(215);
    buyContainer.setPadding(3, 0);
    this.buttonBuyOne = new UIButtonBuilder(this).width(60).anchor(Anchor.LEFT | Anchor.MIDDLE).position(0, 0).text(I18n.format("almura.feature.common.button.buy.one")).enabled(false).onClick(() -> this.buy(1)).build("button.buy.single");
    this.buttonBuyStack = new UIButtonBuilder(this).width(60).anchor(Anchor.LEFT | Anchor.MIDDLE).position(BasicScreen.getPaddedX(this.buttonBuyOne, 10), 0).text(I18n.format("almura.feature.common.button.buy.stack", 0)).enabled(false).onClick(() -> {
        final ForSaleItem forSaleItem = this.forSaleList.getSelectedItem();
        if (forSaleItem != null) {
            this.buy(forSaleItem.asRealStack().getMaxStackSize());
        }
    }).build("button.buy.stack");
    this.buttonBuyAll = new UIButtonBuilder(this).width(50).anchor(Anchor.RIGHT | Anchor.MIDDLE).position(0, 0).text(I18n.format("almura.feature.common.button.buy.all")).enabled(false).onClick(() -> {
        final ForSaleItem forSaleItem = this.forSaleList.getSelectedItem();
        if (forSaleItem != null) {
            this.buy(forSaleItem.getQuantity());
        }
    }).build("button.buy.all");
    this.buttonBuyQuantity = new UIButtonBuilder(this).width(60).anchor(Anchor.RIGHT | Anchor.MIDDLE).position(BasicScreen.getPaddedX(this.buttonBuyAll, 10, Anchor.RIGHT), 0).text(I18n.format("almura.feature.common.button.buy.quantity")).enabled(false).onClick(() -> {
        final ForSaleItem forSaleItem = this.forSaleList.getSelectedItem();
        if (forSaleItem != null) {
            new ExchangeBuyQuantityScreen(this, this.axs, forSaleItem).display();
        }
    }).build("button.buy.quantity");
    buyContainer.add(this.buttonBuyOne, this.buttonBuyStack, this.buttonBuyQuantity, this.buttonBuyAll);
    // Listable Items section
    final BasicContainer<?> listableItemsContainer = new BasicContainer(this, 295, 345);
    listableItemsContainer.setPosition(0, 0, Anchor.RIGHT | Anchor.TOP);
    listableItemsContainer.setBorder(FontColors.WHITE, 1, 185);
    listableItemsContainer.setColor(0);
    listableItemsContainer.setBackgroundAlpha(215);
    listableItemsContainer.setPadding(3, 3);
    final UILabel listableItemsLabel = new UILabel(this, I18n.format("almura.feature.exchange.title.listable_items"));
    listableItemsLabel.setPosition(0, 2, Anchor.CENTER | Anchor.TOP);
    listableItemsLabel.setFontOptions(FontColors.WHITE_FO);
    final BasicLine listTopLine = new BasicLine(this, listableItemsContainer.getRawWidth() - 2);
    listTopLine.setPosition(0, BasicScreen.getPaddedY(listableItemsLabel, 3), Anchor.TOP | Anchor.CENTER);
    this.listItemList = new BasicList<>(this, UIComponent.INHERITED, 302);
    this.listItemList.setPosition(0, BasicScreen.getPaddedY(listTopLine, 2));
    this.listItemList.setItemComponentFactory(ListItemComponent::new);
    this.listItemList.setItemComponentSpacing(1);
    this.listItemList.setSelectConsumer((i) -> this.updateControls());
    this.buttonList = new UIButtonBuilder(this).width(40).anchor(Anchor.LEFT | Anchor.BOTTOM).position(0, 0).text(I18n.format("almura.feature.common.button.list")).enabled(false).onClick(this::list).build("button.list");
    this.labelLimit = new UILabel(this, "");
    this.labelLimit.setPosition(0, -2, Anchor.CENTER | Anchor.BOTTOM);
    final UIButton buttonOffer = new UIButtonBuilder(this).width(30).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(0, 0).text(TextFormatting.DARK_GREEN + "+" + TextFormatting.GRAY + "/" + TextFormatting.RED + "-").enabled(true).onClick(() -> exchangeManager.requestExchangeSpecificOfferGui(this.axs.getId())).build("button.offer");
    // Separator
    final BasicLine listBottomLine = new BasicLine(this, searchContainer.getRawWidth() - 2);
    listBottomLine.setPosition(0, BasicScreen.getPaddedY(this.buttonList, 2, Anchor.BOTTOM), Anchor.CENTER | Anchor.BOTTOM);
    listableItemsContainer.add(listableItemsLabel, listTopLine, this.listItemList, this.buttonList, this.labelLimit, buttonOffer, listBottomLine);
    form.add(searchContainer, buyContainer, listableItemsContainer);
    addToScreen(form);
    this.itemDisplayNameSearchBox.focus();
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) BasicLine(net.malisis.core.client.gui.component.decoration.BasicLine) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) ForSaleItem(com.almuradev.almura.feature.exchange.listing.ForSaleItem) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) BasicContainer(net.malisis.core.client.gui.component.container.BasicContainer) BasicTextBox(net.malisis.core.client.gui.component.interaction.BasicTextBox) PopupNotification(com.almuradev.almura.feature.notification.type.PopupNotification)

Example 13 with UIButtonBuilder

use of net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder in project Almura by AlmuraDev.

the class GuidePageDetailsScreen method construct.

@Override
public void construct() {
    this.guiscreenBackground = true;
    Keyboard.enableRepeatEvents(true);
    this.validatePage();
    assert manager.getPage() != null;
    final BasicForm form = new BasicForm(this, 150, 225, I18n.format("almura.guide.details.form.title"));
    form.setZIndex(10);
    form.setBackgroundAlpha(255);
    // File name
    final UILabel labelId = new UILabel(this, I18n.format("almura.guide.label.id"));
    labelId.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelId.setFontOptions(FontColors.WHITE_FO);
    final BasicTextBox tbId = new BasicTextBox(this, manager.getPage().getId());
    tbId.setAnchor(Anchor.TOP | Anchor.LEFT);
    tbId.setPosition(0, BasicScreen.getPaddedY(labelId, 1));
    tbId.setSize(UIComponent.INHERITED, 0);
    tbId.setEditable(false);
    // Index
    final UILabel labelIndex = new UILabel(this, I18n.format("almura.guide.label.index"));
    labelIndex.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelIndex.setPosition(0, BasicScreen.getPaddedY(tbId, padding));
    labelIndex.setFontOptions(FontColors.WHITE_FO);
    this.tbIndex = new BasicTextBox(this, Integer.toString(manager.getPage().getIndex()));
    this.tbIndex.setAcceptsReturn(false);
    this.tbIndex.setAcceptsTab(false);
    this.tbIndex.setTabIndex(0);
    this.tbIndex.setOnEnter(tb -> this.save());
    this.tbIndex.setAnchor(Anchor.TOP | Anchor.LEFT);
    this.tbIndex.setPosition(0, BasicScreen.getPaddedY(labelIndex, 1));
    this.tbIndex.setSize(UIComponent.INHERITED, 0);
    this.tbIndex.setFilter(s -> s.replaceAll("[^\\d]", ""));
    // Title
    final UILabel labelName = new UILabel(this, I18n.format("almura.guide.label.name"));
    labelName.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelName.setPosition(0, BasicScreen.getPaddedY(this.tbIndex, padding));
    labelName.setFontOptions(FontColors.WHITE_FO);
    this.tbName = new BasicTextBox(this, manager.getPage().getName());
    this.tbName.setAcceptsReturn(false);
    this.tbName.setAcceptsTab(false);
    this.tbName.setTabIndex(0);
    this.tbName.setOnEnter(tb -> this.save());
    this.tbName.setAnchor(Anchor.TOP | Anchor.LEFT);
    this.tbName.setPosition(0, BasicScreen.getPaddedY(labelName, 1));
    this.tbName.setSize(UIComponent.INHERITED, 0);
    // Creator
    final UILabel labelCreator = new UILabel(this, I18n.format("almura.guide.label.creator"));
    labelCreator.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelCreator.setPosition(0, BasicScreen.getPaddedY(this.tbName, padding));
    labelCreator.setFontOptions(FontColors.WHITE_FO);
    final BasicTextBox tbCreator = new BasicTextBox(this, manager.getPage().getCreator().toString());
    tbCreator.setAnchor(Anchor.TOP | Anchor.LEFT);
    tbCreator.setPosition(0, BasicScreen.getPaddedY(labelCreator, 1));
    tbCreator.setSize(UIComponent.INHERITED, 0);
    tbCreator.setEditable(false);
    // Created
    final UILabel labelCreated = new UILabel(this, I18n.format("almura.guide.label.created"));
    labelCreated.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelCreated.setPosition(0, BasicScreen.getPaddedY(tbCreator, padding));
    labelCreated.setFontOptions(FontColors.WHITE_FO);
    final BasicTextBox tbCreated = new BasicTextBox(this, formatter.format(manager.getPage().getCreated()));
    tbCreated.setAnchor(Anchor.TOP | Anchor.LEFT);
    tbCreated.setPosition(0, BasicScreen.getPaddedY(labelCreated, 1));
    tbCreated.setSize(UIComponent.INHERITED, 0);
    tbCreated.setEditable(false);
    // Last Modifier
    final UILabel labelLastModifier = new UILabel(this, I18n.format("almura.guide.label.last_modifier"));
    labelLastModifier.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelLastModifier.setPosition(0, BasicScreen.getPaddedY(tbCreated, padding));
    labelLastModifier.setFontOptions(FontColors.WHITE_FO);
    final BasicTextBox tbLastModifier = new BasicTextBox(this, manager.getPage().getLastModifier().toString());
    tbLastModifier.setAnchor(Anchor.TOP | Anchor.LEFT);
    tbLastModifier.setPosition(0, BasicScreen.getPaddedY(labelLastModifier, 1));
    tbLastModifier.setSize(UIComponent.INHERITED, 0);
    tbLastModifier.setEditable(false);
    // Last Modified
    final UILabel labelLastModified = new UILabel(this, I18n.format("almura.guide.label.last_modified"));
    labelLastModified.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelLastModified.setPosition(0, BasicScreen.getPaddedY(tbLastModifier, padding));
    labelLastModified.setFontOptions(FontColors.WHITE_FO);
    final BasicTextBox tbLastModified = new BasicTextBox(this, formatter.format(manager.getPage().getLastModified()));
    tbLastModified.setAnchor(Anchor.TOP | Anchor.LEFT);
    tbLastModified.setPosition(0, BasicScreen.getPaddedY(labelLastModified, 1));
    tbLastModified.setSize(UIComponent.INHERITED, 0);
    tbLastModified.setEditable(false);
    // Save/Cancel
    final UIButton buttonSave = new UIButtonBuilder(this).text(I18n.format("almura.button.save")).anchor(Anchor.BOTTOM | Anchor.RIGHT).width(40).onClick(this::save).build("button.save");
    final UIButton buttonCancel = new UIButtonBuilder(this).text(I18n.format("almura.button.cancel")).anchor(Anchor.BOTTOM | Anchor.RIGHT).position(BasicScreen.getPaddedX(buttonSave, 2, Anchor.RIGHT), 0).width(40).onClick(this::close).build("button.cancel");
    form.add(labelId, tbId, labelIndex, this.tbIndex, labelName, this.tbName, labelCreator, tbCreator, labelCreated, tbCreated, labelLastModifier, tbLastModifier, labelLastModified, tbLastModified, buttonSave, buttonCancel);
    addToScreen(form);
    this.tbIndex.focus();
    this.tbIndex.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) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) BasicTextBox(net.malisis.core.client.gui.component.interaction.BasicTextBox)

Example 14 with UIButtonBuilder

use of net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder in project Almura by AlmuraDev.

the class GuidePageViewScreen method construct.

@Override
public void construct() {
    guiscreenBackground = false;
    Keyboard.enableRepeatEvents(true);
    final BasicForm form = new BasicForm(this, 582, 315, TextFormatting.WHITE + I18n.format("almura.guide.view.form.title"));
    // Page list
    this.pagesList = new BasicList<>(this, 156, BasicScreen.getPaddedHeight(form));
    this.pagesList.setBorder(0xFFFFFF, 1, 215);
    this.pagesList.setPadding(2, 2);
    this.pagesList.setPosition(1, 0);
    this.pagesList.setItemComponentSpacing(1);
    this.pagesList.setItemComponentFactory(PageListEntryItemComponent::new);
    this.pagesList.setItems(manager.getPageEntries());
    this.pagesList.setSelectConsumer(i -> {
        if (i == null) {
            this.tbContent.getTextBox().setText("");
        } else {
            if (manager.getPage() != null && !manager.getPage().getId().equalsIgnoreCase(i.getId())) {
                this.clearCursorSnapshot();
                this.restoreCursorSnapshot();
            }
            manager.requestPage(i.getId());
        }
    });
    if (this.canModify) {
        this.pagesList.setHeight(this.pagesList.getHeight() - 17);
        this.buttonAdd = new UIButtonBuilder(this).text(TextFormatting.GREEN + "+").onClick(() -> this.runScheduledTask("add")).anchor(Anchor.BOTTOM | Anchor.LEFT).position(0, 0).visible(this.canAdd).tooltip(I18n.format("almura.guide.view.button.add.tooltip")).build("button.add");
        this.buttonRemove = new UIButtonBuilder(this).text(TextFormatting.RED + "-").onClick(() -> this.runScheduledTask("remove")).anchor(Anchor.BOTTOM | Anchor.LEFT).position(BasicScreen.getPaddedX(this.buttonAdd, 2), 0).visible(this.canRemove).tooltip(I18n.format("almura.guide.view.button.remove.tooltip")).build("button.remove");
        this.buttonDetails = new UIButtonBuilder(this).text(TextFormatting.YELLOW + "?").onClick(() -> this.runScheduledTask("details")).anchor(Anchor.BOTTOM | Anchor.LEFT).position(BasicScreen.getPaddedX(this.buttonRemove, 2), 0).visible(this.canModify).tooltip(I18n.format("almura.guide.view.button.details.tooltip")).build("button.details");
    }
    this.tbContent = new WYSIWYGTextBox(this, BasicScreen.getPaddedHeight(form), "");
    this.tbContent.setPosition(BasicScreen.getPaddedX(this.pagesList, 2), 0);
    this.tbContent.getTextBox().setEditable(this.canModify);
    this.tbContent.getTextBox().setOptions(0x555555, 0xc8c8c8, 0x00000);
    if (!this.canModify) {
        this.tbContent.hideToolbar();
    }
    final UIButton buttonClose = new UIButtonBuilder(this).width(50).anchor(Anchor.BOTTOM | Anchor.RIGHT).text(I18n.format("almura.button.close")).onClick(this::close).build("button.close");
    form.add(this.pagesList, this.tbContent, this.buttonAdd, buttonRemove, buttonDetails, buttonClose);
    this.tbContent.setHeight(BasicScreen.getPaddedHeight(form) - 17);
    if (this.canModify) {
        this.buttonSave = new UIButtonBuilder(this).width(50).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(BasicScreen.getPaddedX(buttonClose, 2, Anchor.RIGHT), 0).text(I18n.format("almura.button.save")).onClick(() -> {
            if (manager.getPage() != null) {
                if (!manager.preSnapshot.equalsIgnoreCase(this.tbContent.getTextBox().getText())) {
                    manager.getPage().setContent(this.tbContent.getTextBox().getText());
                    manager.requestSavePage();
                }
            }
        }).build("button.save");
        form.add(buttonSave);
    }
    this.addToScreen(form);
}
Also used : WYSIWYGTextBox(com.almuradev.almura.shared.client.ui.component.WYSIWYGTextBox) 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)

Example 15 with UIButtonBuilder

use of net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder in project Almura by AlmuraDev.

the class PlayerDiedGUI method construct.

@Override
public void construct() {
    this.guiscreenBackground = true;
    Keyboard.enableRepeatEvents(true);
    this.form = new BasicForm(this, 50, 200, "You have died.");
    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(99, 99);
    almuraHeader.setPosition(0, 0, Anchor.TOP | Anchor.CENTER);
    this.messageLabel = new UILabel(this, getMessage(this.player.getName()));
    this.messageLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.messageLabel.setPosition(0, 102, Anchor.CENTER | Anchor.TOP);
    final DecimalFormat dFormat = new DecimalFormat("###,###,###,###.00");
    this.droppedLabel = new UILabel(this, "You dropped: " + TextFormatting.GOLD + "$" + dFormat.format(this.droppedAmount) + TextFormatting.RESET + ".");
    this.droppedLabel.setVisible(this.dropCoins);
    this.droppedLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.droppedLabel.setPosition(0, -40, Anchor.CENTER | Anchor.BOTTOM);
    this.deathTaxLabel = new UILabel(this, "You lost: " + TextFormatting.RED + "$" + dFormat.format(this.deathTaxAmount) + TextFormatting.RESET + " to death taxes.");
    this.deathTaxLabel.setVisible(this.dropCoins);
    this.deathTaxLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    this.deathTaxLabel.setPosition(0, -26, Anchor.CENTER | Anchor.BOTTOM);
    this.form.setSize(this.messageLabel.getWidth() + 30, this.form.getHeight());
    if (this.form.getWidth() < this.droppedLabel.getWidth() + 30) {
        // Account for the width possibly being too small.
        this.form.setSize(this.droppedLabel.getWidth() + 20, this.form.getHeight());
    }
    if (this.form.getWidth() < this.deathTaxLabel.getWidth() + 30) {
        // Account for the width possibly being too small.
        this.form.setSize(this.deathTaxLabel.getWidth() + 20, this.form.getHeight());
    }
    if (!this.dropCoins) {
        this.form.setSize(this.form.getWidth(), 160);
    }
    final UISeparator topWindowTitleSeparator = new UISeparator(this);
    topWindowTitleSeparator.setSize(this.form.getWidth() - 5, 1);
    topWindowTitleSeparator.setPosition(0, -5, Anchor.TOP | Anchor.CENTER);
    this.form.add(topWindowTitleSeparator);
    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);
    final UISeparator belowMessageSeparator = new UISeparator(this);
    belowMessageSeparator.setSize(form.getWidth() - 5, 1);
    belowMessageSeparator.setPosition(0, 40, Anchor.CENTER | Anchor.MIDDLE);
    belowMessageSeparator.setVisible(this.dropCoins);
    this.form.add(belowMessageSeparator);
    // Revive button
    this.buttonRevive = new UIButtonBuilder(this).width(40).anchor(Anchor.BOTTOM | Anchor.LEFT).text("Revive").listener(this).enabled(this.canRevive).build("button.revive");
    // Respawn button
    this.buttonRespawn = new UIButtonBuilder(this).width(40).anchor(Anchor.BOTTOM | Anchor.CENTER).position(0, 0).text("Respawn").listener(this).build("button.respawn");
    // Rage Quit button
    this.buttonRagequit = new UIButtonBuilder(this).width(40).anchor(Anchor.BOTTOM | Anchor.RIGHT).text(I18n.format("almura.menu_button.quit")).fontOptions(FontOptions.builder().from(FontColors.RED_FO).shadow(true).build()).listener(this).build("button.ragequit");
    this.form.add(almuraHeader, this.messageLabel, this.droppedLabel, this.deathTaxLabel, this.buttonRespawn, this.buttonRevive, this.buttonRagequit);
    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) DecimalFormat(java.text.DecimalFormat) UISeparator(net.malisis.core.client.gui.component.decoration.UISeparator) UIImage(net.malisis.core.client.gui.component.decoration.UIImage)

Aggregations

UIButtonBuilder (net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder)31 UILabel (net.malisis.core.client.gui.component.decoration.UILabel)27 BasicForm (net.malisis.core.client.gui.component.container.BasicForm)25 UIButton (net.malisis.core.client.gui.component.interaction.UIButton)21 UISeparator (net.malisis.core.client.gui.component.decoration.UISeparator)11 UIImage (net.malisis.core.client.gui.component.decoration.UIImage)10 BasicTextBox (net.malisis.core.client.gui.component.interaction.BasicTextBox)10 GuiTexture (net.malisis.core.client.gui.GuiTexture)8 BasicContainer (net.malisis.core.client.gui.component.container.BasicContainer)8 UICheckBox (net.malisis.core.client.gui.component.interaction.UICheckBox)5 UITextField (net.malisis.core.client.gui.component.interaction.UITextField)5 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