use of net.malisis.core.client.gui.component.container.BasicContainer in project Almura by AlmuraDev.
the class MultiplayerScreen method construct.
@Override
public void construct() {
this.renderer.setDefaultTexture(GuiConfig.SpriteSheet.ALMURA);
// Container to cover the screen (fixes issues with stuck button highlighting)
final BasicContainer<?> screenContainer = new BasicContainer(this);
screenContainer.setBackgroundAlpha(0);
// Primary content
final BasicContainer<?> contentContainer = new BasicContainer(this, UIConstants.Button.WIDTH_LONG, 206);
contentContainer.setPosition(0, -10, Anchor.MIDDLE | Anchor.CENTER);
contentContainer.setBackgroundAlpha(0);
// Create logo
final UIImage logoImage = new UIImage(this, new GuiTexture(GuiConfig.Location.ALMURA_LOGO), null);
logoImage.setSize(60, 99);
logoImage.setPosition(0, 0, Anchor.TOP | Anchor.CENTER);
// Container for server entries
this.serverList = new BasicList<>(this, UIConstants.Button.WIDTH_LONG - 2, 26);
this.serverList.setPosition(0, BasicScreen.getPaddedY(logoImage, 10), Anchor.TOP | Anchor.CENTER);
this.serverList.setColor(0x000000);
this.serverList.setBackgroundAlpha(185);
this.serverList.setItemComponentSpacing(1);
this.serverList.setBorder(0xFFFFFF, 1, 185);
this.serverList.setPadding(2);
this.serverList.setItemComponentFactory(ServerEntryItemComponent::new);
this.serverList.setSelectConsumer(i -> this.updateButtons());
this.serverList.setItems(serverEntries);
this.serverList.createItemComponents();
// Join button
this.joinButton = new UIButtonBuilder(this).text(I18n.format("almura.menu_button.join")).enabled(false).width(UIConstants.Button.WIDTH_LONG).height(UIConstants.Button.HEIGHT).position(0, BasicScreen.getPaddedY(this.serverList, 2)).anchor(Anchor.TOP | Anchor.LEFT).onClick(this::join).build("button.join");
// Back button
this.backButton = new UIButtonBuilder(this).text(I18n.format("gui.back")).width(UIConstants.Button.WIDTH_SHORT).height(UIConstants.Button.HEIGHT).position(0, BasicScreen.getPaddedY(this.joinButton, 2)).anchor(Anchor.TOP | Anchor.LEFT).onClick(this::close).build("button.back");
// Other button
this.otherButton = new UIButtonBuilder(this).text(I18n.format("almura.menu_button.other")).width(UIConstants.Button.WIDTH_SHORT).height(UIConstants.Button.HEIGHT).position(0, BasicScreen.getPaddedY(this.joinButton, 2)).anchor(Anchor.TOP | Anchor.RIGHT).onClick(() -> Minecraft.getMinecraft().displayGuiScreen(new GuiMultiplayer(this))).build("button.other");
// Add everything to the bowl
contentContainer.add(logoImage, this.serverList, this.joinButton, backButton, otherButton);
screenContainer.add(contentContainer);
// Bake that cake
this.addToScreen(screenContainer);
// Select the first entry
this.serverList.setSelectedItem(serverEntries.stream().findFirst().orElse(null));
updateButtons();
}
use of net.malisis.core.client.gui.component.container.BasicContainer 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;
}
use of net.malisis.core.client.gui.component.container.BasicContainer 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();
}
use of net.malisis.core.client.gui.component.container.BasicContainer 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.container.BasicContainer in project Almura by AlmuraDev.
the class PanoramicMainMenu method construct.
@SuppressWarnings("deprecation")
@Override
public void construct() {
final UIBackgroundContainer contentContainer = new UIBackgroundContainer(this);
contentContainer.setBackgroundAlpha(0);
contentContainer.setPosition(0, -10, Anchor.MIDDLE | Anchor.CENTER);
contentContainer.setSize(UIConstants.Button.WIDTH_LONG, 205);
// Almura header
final UIImage almuraHeader = new UIImage(this, new GuiTexture(GuiConfig.Location.ALMURA_LOGO), null);
almuraHeader.setSize(60, 99);
almuraHeader.setPosition(0, 0, Anchor.TOP | Anchor.CENTER);
this.buttonContainer = new UIBackgroundContainer(this, UIConstants.Button.WIDTH_LONG + PADDING, (UIConstants.Button.HEIGHT * 4) + (PADDING * 3));
this.buttonContainer.setPosition(0, BasicScreen.getPaddedY(almuraHeader, 10), Anchor.TOP | Anchor.CENTER);
this.buttonContainer.setBackgroundAlpha(0);
final UIButton singleplayerButton = new UIButtonBuilder(this).container(this.buttonContainer).text(I18n.format("menu.singleplayer")).size(UIConstants.Button.WIDTH_LONG, UIConstants.Button.HEIGHT).position(0, 0).anchor(Anchor.TOP | Anchor.CENTER).listener(this).build("button.singleplayer");
final UIButton multiplayerButton = new UIButtonBuilder(this).container(this.buttonContainer).text(I18n.format("menu.multiplayer")).size(UIConstants.Button.WIDTH_LONG, UIConstants.Button.HEIGHT).position(0, BasicScreen.getPaddedY(singleplayerButton, PADDING)).anchor(Anchor.TOP | Anchor.CENTER).listener(this).build("button.multiplayer");
final UIButton optionsButton = new UIButtonBuilder(this).container(this.buttonContainer).text(I18n.format("options.title")).size(UIConstants.Button.WIDTH_TINY, UIConstants.Button.HEIGHT).position(-68, BasicScreen.getPaddedY(multiplayerButton, PADDING)).anchor(Anchor.TOP | Anchor.CENTER).listener(this).build("button.options");
final UIButton modsButton = new UIButtonBuilder(this).container(this.buttonContainer).text(I18n.format("almura.menu_button.mods")).size(UIConstants.Button.WIDTH_TINY, UIConstants.Button.HEIGHT).position(BasicScreen.getPaddedX(optionsButton, PADDING), BasicScreen.getPaddedY(multiplayerButton, PADDING)).anchor(Anchor.TOP | Anchor.CENTER).listener(this).build("button.mods");
final UIButton aboutButton = new UIButtonBuilder(this).container(this.buttonContainer).text(I18n.format("almura.menu_button.about")).size(UIConstants.Button.WIDTH_TINY, UIConstants.Button.HEIGHT).position(BasicScreen.getPaddedX(modsButton, PADDING), BasicScreen.getPaddedY(multiplayerButton, PADDING)).anchor(Anchor.TOP | Anchor.CENTER).listener(this).build("button.about");
final UIButton quitButton = new UIButtonBuilder(this).container(this.buttonContainer).text(I18n.format("almura.menu_button.quit")).fontOptions(FontOptions.builder().from(FontColors.RED_FO).shadow(true).build()).hoverFontOptions(FontOptions.builder().color(Color.ofRgb(255, 89, 89).getRgb()).shadow(true).build()).size(UIConstants.Button.WIDTH_LONG, UIConstants.Button.HEIGHT).position(singleplayerButton.getX(), BasicScreen.getPaddedY(optionsButton, PADDING)).anchor(Anchor.TOP | Anchor.CENTER).listener(this).build("button.quit");
final UIButton forumsButton = new UIButtonBuilder(this).container(this.buttonContainer).icon(GuiConfig.Icon.ENJIN).size(UIConstants.Button.WIDTH_ICON, UIConstants.Button.HEIGHT_ICON).position(-PADDING, -PADDING).anchor(Anchor.BOTTOM | Anchor.RIGHT).listener(this).tooltip(I18n.format("almura.menu_button.forums")).build("button.forums");
final UIButton issuesButton = new UIButtonBuilder(this).container(this.buttonContainer).icon(GuiConfig.Icon.FA_GITHUB).size(UIConstants.Button.WIDTH_ICON, UIConstants.Button.HEIGHT_ICON).position(BasicScreen.getPaddedX(forumsButton, PADDING, Anchor.RIGHT), forumsButton.getY()).anchor(Anchor.BOTTOM | Anchor.RIGHT).listener(this).tooltip(I18n.format(I18n.format("almura.menu_button.issues"))).build("button.issues");
final UIButton shopButton = new UIButtonBuilder(this).container(this.buttonContainer).icon(GuiConfig.Icon.FA_SHOPPING_BAG).size(UIConstants.Button.WIDTH_ICON, UIConstants.Button.HEIGHT_ICON).position(BasicScreen.getPaddedX(issuesButton, PADDING, Anchor.RIGHT), issuesButton.getY()).anchor(Anchor.BOTTOM | Anchor.RIGHT).listener(this).tooltip(I18n.format("almura.menu_button.shop")).build("button.shop");
final UILabel trademarkLabel = new UILabel(this, TextFormatting.YELLOW + I18n.format("almura.menu.main.trademark"));
trademarkLabel.setPosition(PADDING, -PADDING, Anchor.BOTTOM | Anchor.LEFT);
final UILabel copyrightLabel = new UILabel(this, TextFormatting.YELLOW + I18n.format("almura.menu.main.copyright"));
copyrightLabel.setPosition(trademarkLabel.getX(), BasicScreen.getPaddedY(trademarkLabel, PADDING, Anchor.BOTTOM), trademarkLabel.getAnchor());
contentContainer.add(almuraHeader, this.buttonContainer);
// Disable escape key press
registerKeyListener((keyChar, keyCode) -> keyCode == Keyboard.KEY_ESCAPE);
final BasicContainer<?> container = new BasicContainer(this, UIComponent.INHERITED, UIComponent.INHERITED);
container.setBackgroundAlpha(0);
container.add(contentContainer);
container.add(trademarkLabel);
container.add(copyrightLabel);
container.add(shopButton);
container.add(forumsButton);
container.add(issuesButton);
// Add content to screen
addToScreen(container);
// OpenGL Warning
if (!GLContext.getCapabilities().OpenGL20 && !OpenGlHelper.areShadersSupported()) {
final UILabel glWarning1 = new UILabel(this, TextFormatting.BOLD + "" + TextFormatting.DARK_RED + I18n.format("almura.menu.main.opengl.0"));
glWarning1.setPosition(2, 2, Anchor.TOP | Anchor.LEFT);
final UILabel glWarning2 = new UILabel(this, TextFormatting.BOLD + "" + TextFormatting.DARK_RED + I18n.format("almura.menu.main.opengl.1"));
glWarning2.setPosition(2, BasicScreen.getPaddedY(glWarning1, 2), Anchor.TOP | Anchor.LEFT);
addToScreen(glWarning1);
addToScreen(glWarning2);
}
}
Aggregations