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