use of net.malisis.core.client.gui.component.interaction.BasicTextBox 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);
}
use of net.malisis.core.client.gui.component.interaction.BasicTextBox 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();
}
use of net.malisis.core.client.gui.component.interaction.BasicTextBox 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();
}
use of net.malisis.core.client.gui.component.interaction.BasicTextBox 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();
}
use of net.malisis.core.client.gui.component.interaction.BasicTextBox 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();
}
Aggregations