Search in sources :

Example 6 with BasicForm

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

the class IngameFeatureManagementScreen method construct.

@SuppressWarnings("unchecked")
@Override
public void construct() {
    this.guiscreenBackground = false;
    this.form = new BasicForm(this, requiredScreenWidth, requiredScreenHeight, this.title);
    this.featureList = new BasicList<>(this, 120, requiredScreenHeight - 40);
    this.featureList.setSelectConsumer(this.onSelect());
    this.featureList.setItemComponentFactory((g, l, i) -> new IngameFeatureItemComponent(this, l, i));
    this.featureList.setItemComponentSpacing(1);
    this.featureList.setCanDeselect(false);
    this.featureList.setBorder(0xFFFFFF, 1, 215);
    this.featureList.setPadding(2, 2);
    this.featureList.setPosition(1, 0);
    this.featureList.register(this);
    this.form.add(this.featureList);
    final BasicContainer<?> container = new BasicContainer(this);
    container.setBorder(0xFFFFFF, 1, 215);
    container.setPadding(4, 4);
    container.setAnchor(Anchor.RIGHT | Anchor.TOP);
    container.setPosition(-1, 0);
    container.setSize(244, requiredScreenHeight - 40);
    container.setBackgroundAlpha(0);
    // ID
    this.tbId = new BasicTextBox(this, "");
    this.tbId.setAcceptsReturn(false);
    this.tbId.setAcceptsTab(false);
    this.tbId.setTabIndex(0);
    this.tbId.setOnEnter(tb -> this.save());
    this.tbId.setSize(140, 0);
    this.tbId.setPosition(0, 0, Anchor.RIGHT | Anchor.TOP);
    this.tbId.setEditable(false);
    this.tbId.register(this);
    this.tbId.setFilter(s -> s.replaceAll(filter, "").toLowerCase());
    final UILabel idLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.id") + ":").setPosition(0, this.tbId.getY() + 3, Anchor.LEFT | Anchor.TOP);
    // Title
    this.tbTitle = new BasicTextBox(this, "");
    this.tbTitle.setAcceptsReturn(false);
    this.tbTitle.setAcceptsTab(false);
    this.tbTitle.setTabIndex(1);
    this.tbTitle.setOnEnter(tb -> this.save());
    this.tbTitle.setSize(140, 0);
    this.tbTitle.setPosition(0, BasicScreen.getPaddedY(this.tbId, 2), Anchor.RIGHT | Anchor.TOP);
    this.tbTitle.register(this);
    final UILabel titleLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.title") + ":").setPosition(0, this.tbTitle.getY() + 3, Anchor.LEFT | Anchor.TOP);
    // Permission
    this.tbPermission = new BasicTextBox(this, "");
    this.tbPermission.setAcceptsReturn(false);
    this.tbPermission.setAcceptsTab(false);
    this.tbPermission.setTabIndex(2);
    this.tbPermission.setOnEnter(tb -> this.save());
    this.tbPermission.setSize(140, 0);
    this.tbPermission.setPosition(0, BasicScreen.getPaddedY(this.tbTitle, 2), Anchor.RIGHT | Anchor.TOP);
    this.tbPermission.register(this);
    this.tbPermission.setFilter(s -> s.replaceAll(filter, "").toLowerCase());
    final UILabel permissionLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.permission") + ":").setPosition(0, this.tbPermission.getY() + 3, Anchor.LEFT | Anchor.TOP);
    // Created by (name)
    this.tbCreatorName = new BasicTextBox(this, "");
    this.tbCreatorName.setSize(140, 0);
    this.tbCreatorName.setPosition(0, BasicScreen.getPaddedY(this.tbPermission, 2), Anchor.RIGHT | Anchor.TOP);
    this.tbCreatorName.setEditable(false);
    this.creatorNameLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.creator_name") + ":").setPosition(0, this.tbCreatorName.getY() + 3, Anchor.LEFT | Anchor.TOP);
    // Created by (Unique ID)
    this.tbCreatorUniqueId = new BasicTextBox(this, "");
    this.tbCreatorUniqueId.setSize(140, 0);
    this.tbCreatorUniqueId.setPosition(0, BasicScreen.getPaddedY(this.tbCreatorName, 2), Anchor.RIGHT | Anchor.TOP);
    this.tbCreatorUniqueId.setEditable(false);
    this.creatorUniqueIdLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.creator_uuid") + ":").setPosition(0, this.tbCreatorUniqueId.getY() + 3, Anchor.LEFT | Anchor.TOP);
    // Created on
    this.tbCreated = new BasicTextBox(this, "");
    this.tbCreated.setSize(140, 0);
    this.tbCreated.setPosition(0, BasicScreen.getPaddedY(this.tbCreatorUniqueId, 2), Anchor.RIGHT | Anchor.TOP);
    this.tbCreated.setEditable(false);
    this.createdLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.created") + ":").setPosition(0, this.tbCreated.getY() + 3, Anchor.LEFT | Anchor.TOP);
    this.hiddenCheckbox = new UICheckBox(this);
    this.hiddenCheckbox.setText(TextFormatting.WHITE + I18n.format("almura.feature.common.text.hidden"));
    this.hiddenCheckbox.setPosition(0, 0, Anchor.LEFT | Anchor.BOTTOM);
    this.hiddenCheckbox.setChecked(false);
    this.hiddenCheckbox.setName("checkbox.hidden");
    this.hiddenCheckbox.register(this);
    this.buttonSave = new UIButtonBuilder(this).width(40).text(I18n.format("almura.button.save")).anchor(Anchor.BOTTOM | Anchor.RIGHT).enabled(false).onClick(this::save).build("button.save");
    this.buttonOpen = new UIButtonBuilder(this).width(40).text(I18n.format("almura.button.open")).position(BasicScreen.getPaddedX(this.buttonSave, 2, Anchor.RIGHT), 0).anchor(Anchor.BOTTOM | Anchor.RIGHT).enabled(false).onClick(this::open).build("button.open");
    container.add(this.tbId, idLabel, this.tbTitle, titleLabel, this.tbPermission, permissionLabel, this.tbCreatorName, creatorNameLabel, this.tbCreatorUniqueId, creatorUniqueIdLabel, this.tbCreated, createdLabel, this.hiddenCheckbox, this.buttonOpen, this.buttonSave);
    // Add button
    this.buttonAdd = new UIButtonBuilder(this).text(TextFormatting.GREEN + "+").anchor(Anchor.BOTTOM | Anchor.LEFT).onClick(() -> {
        this.featureList.setSelectedItem(null);
        this.tbId.focus();
    }).build("button.add");
    // Remove button
    this.buttonDelete = new UIButtonBuilder(this).x(BasicScreen.getPaddedX(this.buttonAdd, 2)).text(TextFormatting.RED + "-").anchor(Anchor.BOTTOM | Anchor.LEFT).onClick(() -> {
        final IngameFeature selectedFeature = this.featureList.getSelectedItem();
        if (selectedFeature != null) {
            BasicMessageBox.showDialog(this, I18n.format("almura.feature.common.title.are_you_sure"), I18n.format("almura.feature.common.text.delete_feature", selectedFeature.getId(), name), MessageBoxButtons.YES_NO, (result) -> {
                if (result != MessageBoxResult.YES)
                    return;
                this.onDelete.accept(this, Optional.ofNullable(this.featureList.getSelectedItem()));
            });
        }
    }).build("button.delete");
    // Close button
    final UIButton buttonClose = new UIButtonBuilder(this).width(40).anchor(Anchor.BOTTOM | Anchor.RIGHT).text(I18n.format("almura.button.close")).onClick(this::close).build("button.close");
    this.form.add(this.featureList, container, this.buttonAdd, this.buttonDelete, buttonClose);
    this.addToScreen(this.form);
    this.refresh();
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) IngameFeature(com.almuradev.almura.shared.feature.IngameFeature) 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) BasicContainer(net.malisis.core.client.gui.component.container.BasicContainer) UICheckBox(net.malisis.core.client.gui.component.interaction.UICheckBox) BasicTextBox(net.malisis.core.client.gui.component.interaction.BasicTextBox)

Example 7 with BasicForm

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

the class ExchangeListPriceScreen method construct.

@Override
public void construct() {
    this.guiscreenBackground = false;
    this.form = new BasicForm(this, 120, 65, I18n.format("almura.feature.exchange.title.enter_a_price"));
    // Fixes issue overlapping draws from parent
    this.form.setZIndex(10);
    this.form.setBackgroundAlpha(255);
    this.pricePerTextBox = new BasicTextBox(this, this.toList.getLastKnownPrice().orElse(BigDecimal.ZERO).toString());
    this.pricePerTextBox.setSize(65, 0);
    this.pricePerTextBox.setFilter(s -> {
        // TODO: Maybe make a fancy regex for some of this
        // Get the current decimal separator
        final String decimalSeparator = String.valueOf(DecimalFormatSymbols.getInstance().getDecimalSeparator());
        // Filter out all non-digit and decimal separator characters
        final String filteredValue = s.replaceAll("[^\\d" + decimalSeparator + "]", "");
        // Return if empty
        if (filteredValue.isEmpty()) {
            return filteredValue;
        }
        // Don't allow multiple decimal separators if one is present
        if (filteredValue.indexOf(decimalSeparator) != filteredValue.lastIndexOf(decimalSeparator)) {
            return filteredValue.substring(0, filteredValue.length() - 1);
        }
        // Split against the decimal separator
        final String[] values = Iterables.toArray(Splitter.on(CharMatcher.anyOf(decimalSeparator)).split(filteredValue), String.class);
        // then return a value we expect to see.
        if (values.length > 2 || values.length > 1 && values[1].length() > maxTrailingDigits) {
            return values[0] + decimalSeparator + values[1].substring(0, maxTrailingDigits);
        }
        return filteredValue;
    });
    this.pricePerTextBox.setPosition(2, 0, Anchor.MIDDLE | Anchor.LEFT);
    this.pricePerTextBox.setAcceptsReturn(false);
    this.pricePerTextBox.setOnEnter(tb -> this.list());
    this.pricePerTextBox.register(this);
    this.eaLabel = new UILabel(this, "/ea");
    this.eaLabel.setFontOptions(FontColors.WHITE_FO);
    this.eaLabel.setPosition(BasicScreen.getPaddedX(this.pricePerTextBox, 2), 1, Anchor.MIDDLE | Anchor.LEFT);
    this.buttonList = new UIButtonBuilder(this).text(I18n.format("almura.feature.common.button.list")).width(40).position(-2, -2).anchor(Anchor.RIGHT | Anchor.BOTTOM).enabled(this.toList.getLastKnownPrice().isPresent()).onClick(this::list).build("button.list");
    this.buttonCancel = new UIButtonBuilder(this).text(I18n.format("almura.button.cancel")).width(40).position(BasicScreen.getPaddedX(this.buttonList, 2, Anchor.RIGHT), -2).anchor(Anchor.RIGHT | Anchor.BOTTOM).onClick(this::close).build("button.cancel");
    this.form.add(this.pricePerTextBox, this.eaLabel, this.buttonCancel, this.buttonList);
    this.addToScreen(this.form);
    this.pricePerTextBox.focus();
    this.pricePerTextBox.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)

Example 8 with BasicForm

use of net.malisis.core.client.gui.component.container.BasicForm 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 9 with BasicForm

use of net.malisis.core.client.gui.component.container.BasicForm 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 10 with BasicForm

use of net.malisis.core.client.gui.component.container.BasicForm 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)

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