Search in sources :

Example 1 with UITextField

use of net.malisis.core.client.gui.component.interaction.UITextField in project Almura by AlmuraDev.

the class SimpleAboutMenu method construct.

@SuppressWarnings({ "unchecked" })
@Override
public void construct() {
    super.construct();
    this.list = new UISimpleList(this, 125, UIComponent.INHERITED);
    this.list.setPosition(4, 0);
    this.list.setElementSpacing(4);
    this.list.setUnselect(false);
    final List<AboutListElementData> elementDataList = Lists.newArrayList();
    // Static entry
    elementDataList.add(new AboutListElementData(this.list, new UIImage(this, new GuiTexture(GuiConfig.Location.ALMURA_MAN), null), 5, 0, 23, 32, 8, AboutConfig.TITLE, AboutConfig.STORY));
    // Dynamic entry
    AboutConfig.ENTRIES.forEach(entry -> {
        Text titles = Text.EMPTY;
        for (String title : entry.titles) {
            titles = titles.toBuilder().append(Text.of("  • ", I18n.format(title)), Text.NEW_LINE).build();
        }
        elementDataList.add(new AboutListElementData(this.list, new UIImage(this, new GuiRemoteTexture(GuiConfig.Location.GENERIC_AVATAR, new ResourceLocation(Almura.ID, "textures/gui/skins/avatars/" + entry.uniqueId + ".png"), String.format(GuiConfig.Url.SKINS, entry.uniqueId, 32), 32, 32), null), 2, 0, 32, 32, 4, Text.of(entry.color, I18n.format(entry.name)), Text.of(TextColors.WHITE, I18n.format(entry.description), Text.NEW_LINE, Text.NEW_LINE, TextStyles.BOLD, I18n.format("almura.menu.about.titles"), TextStyles.RESET, TextColors.RESET, Text.NEW_LINE, titles)));
    });
    final UIButton doneButton = new UIButtonBuilder(this).text(Text.of(I18n.format("gui.done"))).size(98, 20).position(0, -15, 1).anchor(Anchor.BOTTOM | Anchor.CENTER).listener(this).build("button.done");
    this.textField = new UITextField(this, "", true);
    this.textField.setPosition(SimpleScreen.getPaddedX(this.list, 4), 0);
    this.textField.setEditable(false);
    this.textField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    this.list.setComponentFactory(AboutListElement::new);
    this.list.setElements(elementDataList);
    this.list.register(this);
    this.list.select(elementDataList.get(0));
    this.getContainer().add(this.list, this.textField);
    // SpongeForge
    final UILabel spongeForgeVersionLabel = new UILabel(this, TextFormatting.WHITE + "SpongeForge: " + ((Optional<String>) Sponge.getPlatform().asMap().get("ImplementationVersion")).orElse("dev"));
    spongeForgeVersionLabel.setPosition(4, -24, Anchor.LEFT | Anchor.BOTTOM);
    // Forge
    final PluginContainer forgeContainer = Sponge.getPluginManager().getPlugin("Forge").orElseThrow(NullPointerException::new);
    final UILabel forgeVersionLabel = new UILabel(this, TextFormatting.WHITE + "Forge: " + forgeContainer.getVersion().orElse("dev"));
    forgeVersionLabel.setPosition(4, -14, Anchor.LEFT | Anchor.BOTTOM);
    addToScreen(forgeVersionLabel);
    // Almura
    final PluginContainer almuraContainer = Sponge.getPluginManager().getPlugin("almura").orElseThrow(NullPointerException::new);
    final UILabel almuraVersionLabel = new UILabel(this, TextFormatting.WHITE + "Almura: " + almuraContainer.getVersion().orElse("dev"));
    almuraVersionLabel.setPosition(4, -4, Anchor.LEFT | Anchor.BOTTOM);
    addToScreen(almuraVersionLabel);
    addToScreen(doneButton);
    addToScreen(spongeForgeVersionLabel);
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) PluginContainer(org.spongepowered.api.plugin.PluginContainer) Optional(java.util.Optional) UISimpleList(com.almuradev.almura.shared.client.ui.component.UISimpleList) Text(org.spongepowered.api.text.Text) UITextField(net.malisis.core.client.gui.component.interaction.UITextField) GuiRemoteTexture(com.almuradev.almura.shared.client.texture.GuiRemoteTexture) GuiTexture(net.malisis.core.client.gui.GuiTexture) UIButtonBuilder(com.almuradev.almura.shared.client.ui.component.button.UIButtonBuilder) ResourceLocation(net.minecraft.util.ResourceLocation) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) UIImage(net.malisis.core.client.gui.component.decoration.UIImage)

Example 2 with UITextField

use of net.malisis.core.client.gui.component.interaction.UITextField in project Almura by AlmuraDev.

the class SimplePageCreate method construct.

@Override
public void construct() {
    this.guiscreenBackground = true;
    final UIForm form = new UIForm(this, 150, 125, I18n.format("almura.guide.create.form.title"));
    form.setAnchor(Anchor.CENTER | Anchor.MIDDLE);
    form.setMovable(true);
    form.setClosable(true);
    form.setZIndex(50);
    // File name
    final UILabel labelId = new UILabel(this, I18n.format("almura.guide.label.id"));
    labelId.setAnchor(Anchor.TOP | Anchor.LEFT);
    this.textFieldId = new UITextField(this, "");
    this.textFieldId.setAnchor(Anchor.TOP | Anchor.LEFT);
    this.textFieldId.setPosition(0, SimpleScreen.getPaddedY(labelId, 1));
    this.textFieldId.setSize(UIComponent.INHERITED, 0);
    this.textFieldId.setFocused(true);
    this.textFieldId.setFilter(String::toLowerCase);
    // Index
    final UILabel labelIndex = new UILabel(this, I18n.format("almura.guide.label.index"));
    labelIndex.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelIndex.setPosition(0, this.textFieldId.isVisible() ? SimpleScreen.getPaddedY(this.textFieldId, padding) : padding);
    this.textFieldIndex = new UITextField(this, Integer.toString(0));
    this.textFieldIndex.setAnchor(Anchor.TOP | Anchor.LEFT);
    this.textFieldIndex.setPosition(0, SimpleScreen.getPaddedY(labelIndex, 1));
    this.textFieldIndex.setSize(UIComponent.INHERITED, 0);
    this.textFieldIndex.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, this.textFieldIndex.isVisible() ? SimpleScreen.getPaddedY(this.textFieldIndex, padding) : padding);
    this.textFieldName = new UITextField(this, "");
    this.textFieldName.setAnchor(Anchor.TOP | Anchor.LEFT);
    this.textFieldName.setPosition(0, SimpleScreen.getPaddedY(labelName, 1));
    this.textFieldName.setSize(UIComponent.INHERITED, 0);
    this.textFieldName.setFilter(s -> s.substring(0, Math.min(s.length(), 50)));
    // Save/Cancel
    final UIButton buttonSave = new UIButtonBuilder(this).text(Text.of("almura.guide.button.save")).anchor(Anchor.BOTTOM | Anchor.RIGHT).width(40).listener(this).build("button.save");
    final UIButton buttonCancel = new UIButtonBuilder(this).text(Text.of("almura.guide.button.cancel")).anchor(Anchor.BOTTOM | Anchor.RIGHT).position(SimpleScreen.getPaddedX(buttonSave, 2, Anchor.RIGHT), 0).width(40).listener(this).build("button.cancel");
    form.add(labelId, this.textFieldId, labelIndex, this.textFieldIndex, labelName, this.textFieldName, buttonCancel, buttonSave);
    addToScreen(form);
    this.textFieldId.setFocused(true);
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) UIButtonBuilder(com.almuradev.almura.shared.client.ui.component.button.UIButtonBuilder) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) UIForm(com.almuradev.almura.shared.client.ui.component.UIForm) UITextField(net.malisis.core.client.gui.component.interaction.UITextField)

Example 3 with UITextField

use of net.malisis.core.client.gui.component.interaction.UITextField in project Almura by AlmuraDev.

the class ExchangeGUI method construct.

@Override
public void construct() {
    guiscreenBackground = false;
    Keyboard.enableRepeatEvents(true);
    // Master Pane
    final UIFormContainer form = new UIFormContainer(this, 600, 400, "");
    form.setAnchor(Anchor.CENTER | Anchor.MIDDLE);
    form.setMovable(true);
    form.setClosable(true);
    form.setBorder(FontColors.WHITE, 1, 185);
    form.setBackgroundAlpha(215);
    form.setBottomPadding(3);
    form.setRightPadding(3);
    form.setTopPadding(20);
    form.setLeftPadding(3);
    UILabel titleLabel = new UILabel(this, "Almura Grand Exchange");
    titleLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    titleLabel.setPosition(0, -15, Anchor.CENTER | Anchor.TOP);
    // Item Search Area
    final UIFormContainer searchArea = new UIFormContainer(this, 295, 315, "");
    searchArea.setPosition(0, 10, Anchor.LEFT | Anchor.TOP);
    searchArea.setMovable(false);
    searchArea.setClosable(false);
    searchArea.setBorder(FontColors.WHITE, 1, 185);
    searchArea.setBackgroundAlpha(215);
    searchArea.setBottomPadding(3);
    searchArea.setRightPadding(3);
    searchArea.setTopPadding(3);
    searchArea.setLeftPadding(3);
    UILabel searchLabel = new UILabel(this, "Item Name:");
    searchLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    searchLabel.setPosition(0, 0, Anchor.LEFT | Anchor.TOP);
    this.itemSearchField = new UITextField(this, "", false);
    this.itemSearchField.setSize(150, 0);
    this.itemSearchField.setPosition(searchLabel.getWidth() + innerPadding, searchLabel.getY(), Anchor.LEFT | Anchor.TOP);
    this.itemSearchField.setEditable(true);
    this.itemSearchField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    // Seller Search Area
    UILabel sellerLabel = new UILabel(this, "Seller:");
    sellerLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build());
    sellerLabel.setPosition(itemSearchField.getX() - sellerLabel.getWidth() + innerPadding, searchLabel.getY() + 15, Anchor.LEFT | Anchor.TOP);
    this.sellerSearchField = new UITextField(this, "", false);
    this.sellerSearchField.setSize(150, 0);
    this.sellerSearchField.setPosition(itemSearchField.getX(), sellerLabel.getY(), Anchor.LEFT | Anchor.TOP);
    this.sellerSearchField.setEditable(true);
    this.sellerSearchField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    // Search button
    final UIButton buttonSearch = new UIButtonBuilder(this).width(40).anchor(Anchor.LEFT | Anchor.TOP).position(sellerSearchField.getX() + sellerSearchField.getWidth() + 10, sellerLabel.getY() - 7).text("Search").listener(this).build("button.search");
    // Bottom Page Control - first button
    final UIButton buttonFirstPage = new UIButtonBuilder(this).width(40).anchor(Anchor.LEFT | Anchor.BOTTOM).position(0, 0).text("First").listener(this).build("button.first");
    // Bottom Page Control - previous button
    final UIButton buttonPreviousPage = new UIButtonBuilder(this).width(40).anchor(Anchor.LEFT | Anchor.BOTTOM).position(buttonFirstPage.getX() + buttonFirstPage.getWidth() + innerPadding, 0).text("Previous").listener(this).build("button.previous");
    // Bottom Page Control - last button
    final UIButton buttonLastPage = new UIButtonBuilder(this).width(40).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(0, 0).text("Last").listener(this).build("button.last");
    // Bottom Page Control - next button
    final UIButton buttonNextPage = new UIButtonBuilder(this).width(40).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(-(buttonLastPage.getX() + buttonLastPage.getWidth() + innerPadding), 0).text("Next").listener(this).build("button.next");
    // Add Elements of Search Area
    searchArea.add(searchLabel, itemSearchField, sellerLabel, sellerSearchField, buttonSearch, buttonFirstPage, buttonPreviousPage, buttonNextPage, buttonLastPage);
    // Economy Pane
    final UIFormContainer economyActionArea = new UIFormContainer(this, 295, 50, "");
    economyActionArea.setPosition(0, searchArea.getY() + searchArea.getHeight() + innerPadding, Anchor.LEFT | Anchor.TOP);
    economyActionArea.setMovable(false);
    economyActionArea.setClosable(false);
    economyActionArea.setBorder(FontColors.WHITE, 1, 185);
    economyActionArea.setBackgroundAlpha(215);
    economyActionArea.setBottomPadding(3);
    economyActionArea.setRightPadding(3);
    economyActionArea.setTopPadding(3);
    economyActionArea.setLeftPadding(3);
    // Bottom Economy Pane - buyStack button
    final UIButton buttonBuyStack = new UIButtonBuilder(this).width(40).anchor(Anchor.LEFT | Anchor.BOTTOM).position(0, 0).text("Buy Stack").listener(this).build("button.buyStack");
    // Bottom Economy Pane - buyStack button
    final UIButton buttonBuySingle = new UIButtonBuilder(this).width(40).anchor(Anchor.CENTER | Anchor.BOTTOM).position(0, 0).text("Buy 1").listener(this).build("button.buySingle");
    // Bottom Economy Pane - buyStack button
    final UIButton buttonBuyQuantity = new UIButtonBuilder(this).width(40).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(0, 0).text("Buy Quantity").listener(this).build("button.buyQuantity");
    economyActionArea.add(buttonBuyStack, buttonBuySingle, buttonBuyQuantity);
    // Seller Inventory Area
    final UIFormContainer sellerInventoryArea = new UIFormContainer(this, 295, 30, "");
    sellerInventoryArea.setPosition(0, 10, Anchor.RIGHT | Anchor.TOP);
    sellerInventoryArea.setMovable(false);
    sellerInventoryArea.setClosable(false);
    sellerInventoryArea.setBorder(FontColors.WHITE, 1, 185);
    sellerInventoryArea.setBackgroundAlpha(215);
    sellerInventoryArea.setBottomPadding(3);
    sellerInventoryArea.setRightPadding(3);
    sellerInventoryArea.setTopPadding(3);
    sellerInventoryArea.setLeftPadding(3);
    final UISlot exchangeSlot1 = new UISlot(this, new MalisisSlot());
    exchangeSlot1.setPosition(0, 0, Anchor.LEFT | Anchor.MIDDLE);
    exchangeSlot1.setTooltip("Exchange Slot 1");
    final UISlot exchangeSlot2 = new UISlot(this, new MalisisSlot());
    exchangeSlot2.setPosition(exchangeSlot1.getX() + exchangeSlot1.getWidth() + 10, 0, Anchor.LEFT | Anchor.MIDDLE);
    exchangeSlot2.setTooltip("Exchange Slot 2");
    final UISlot exchangeSlot3 = new UISlot(this, new MalisisSlot());
    exchangeSlot3.setPosition(exchangeSlot2.getX() + exchangeSlot2.getWidth() + 10, 0, Anchor.LEFT | Anchor.MIDDLE);
    exchangeSlot3.setTooltip("Exchange Slot 3");
    final UISlot exchangeSlot4 = new UISlot(this, new MalisisSlot());
    exchangeSlot4.setPosition(exchangeSlot3.getX() + exchangeSlot3.getWidth() + 10, 0, Anchor.LEFT | Anchor.MIDDLE);
    exchangeSlot4.setTooltip("Exchange Slot 4");
    final UISlot exchangeSlot5 = new UISlot(this, new MalisisSlot());
    exchangeSlot5.setPosition(exchangeSlot4.getX() + exchangeSlot4.getWidth() + 10, 0, Anchor.LEFT | Anchor.MIDDLE);
    exchangeSlot5.setTooltip("Exchange Slot 5");
    final UISlot exchangeSlot6 = new UISlot(this, new MalisisSlot());
    exchangeSlot6.setPosition(exchangeSlot5.getX() + exchangeSlot5.getWidth() + 10, 0, Anchor.LEFT | Anchor.MIDDLE);
    exchangeSlot6.setTooltip("Exchange Slot 6");
    sellerInventoryArea.add(exchangeSlot1, exchangeSlot2, exchangeSlot3, exchangeSlot4, exchangeSlot5, exchangeSlot6);
    // Inventory Area Section (right pane)
    final UIFormContainer inventoryArea = new UIFormContainer(this, 295, 315, "");
    inventoryArea.setPosition(0, 45, Anchor.RIGHT | Anchor.TOP);
    inventoryArea.setMovable(false);
    inventoryArea.setClosable(false);
    inventoryArea.setBorder(FontColors.WHITE, 1, 185);
    inventoryArea.setBackgroundAlpha(215);
    inventoryArea.setBottomPadding(3);
    inventoryArea.setRightPadding(3);
    inventoryArea.setTopPadding(3);
    inventoryArea.setLeftPadding(3);
    // Bottom Economy Pane - buyStack button
    final UIButton buttonList = new UIButtonBuilder(this).width(40).anchor(Anchor.LEFT | Anchor.BOTTOM).position(0, 0).text("List for Sale").listener(this).build("button.listForSaleButton");
    // Bottom Economy Pane - buyStack button
    final UIButton buttonSetPrice = new UIButtonBuilder(this).width(40).anchor(Anchor.CENTER | Anchor.BOTTOM).position(0, 0).text("Set Price").listener(this).build("button.setPrice");
    // Bottom Economy Pane - buyStack button
    final UIButton buttonRemoveItem = new UIButtonBuilder(this).width(40).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(0, 0).text("Remove Item").listener(this).build("button.removeItem");
    inventoryArea.add(buttonList, buttonSetPrice, buttonRemoveItem);
    // Close button
    final UIButton buttonClose = new UIButtonBuilder(this).width(40).anchor(Anchor.BOTTOM | Anchor.RIGHT).text(Text.of("almura.guide.button.close")).listener(this).build("button.close");
    form.add(titleLabel, searchArea, economyActionArea, sellerInventoryArea, inventoryArea, buttonClose);
    addToScreen(form);
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) UISlot(net.malisis.core.client.gui.component.UISlot) UIButtonBuilder(com.almuradev.almura.shared.client.ui.component.button.UIButtonBuilder) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) MalisisSlot(net.malisis.core.inventory.MalisisSlot) UIFormContainer(com.almuradev.almura.shared.client.ui.component.UIFormContainer) UITextField(net.malisis.core.client.gui.component.interaction.UITextField)

Example 4 with UITextField

use of net.malisis.core.client.gui.component.interaction.UITextField in project Almura by AlmuraDev.

the class SimplePageView method construct.

@Override
public void construct() {
    guiscreenBackground = false;
    Keyboard.enableRepeatEvents(true);
    final UIFormContainer form = new UIFormContainer(this, 420, 225, TextFormatting.WHITE + I18n.format("almura.guide.view.form.title"));
    form.setAnchor(Anchor.CENTER | Anchor.MIDDLE);
    form.setMovable(true);
    form.setClosable(true);
    form.setBorder(FontColors.WHITE, 1, 185);
    form.setBackgroundAlpha(185);
    form.setBottomPadding(3);
    form.setRightPadding(3);
    form.setTopPadding(20);
    form.setLeftPadding(3);
    // Remove button
    this.buttonRemove = new UIButtonBuilder(this).width(10).text(Text.of(TextColors.RED, "-")).tooltip(Text.of("almura.guide.view.button.remove.tooltip")).visible(hasAnyPermission()).enabled(hasRemovePermission()).listener(this).build("button.remove");
    // Details button
    this.buttonDetails = new UIButtonBuilder(this).width(10).text(Text.of(TextColors.YELLOW, "?")).tooltip(Text.of(I18n.format("almura.guide.view.button.details.tooltip"))).anchor(Anchor.TOP | Anchor.RIGHT).visible(hasAnyPermission()).listener(this).build("button.details");
    // Add button
    this.buttonAdd = new UIButtonBuilder(this).width(10).x(SimpleScreen.getPaddedX(this.buttonDetails, 2, Anchor.RIGHT)).text(Text.of(TextColors.GREEN, "+")).tooltip(Text.of("almura.guide.view.button.add.tooltip")).anchor(Anchor.TOP | Anchor.RIGHT).visible(hasAnyPermission()).enabled(hasAddPermission()).listener(this).build("button.add");
    // Pages dropdown
    this.pagesSelect = new UISelect<>(this, SimpleScreen.getPaddedWidth(form));
    this.pagesSelect.setLabelFunction(PageListEntry::getName);
    this.pagesSelect.setName("combobox.pages");
    this.pagesSelect.setPosition(this.buttonRemove.isVisible() ? SimpleScreen.getPaddedX(this.buttonRemove, innerPadding) : 0, 0);
    this.pagesSelect.register(this);
    if (hasAnyPermission()) {
        this.pagesSelect.setSize(this.pagesSelect.getWidth() - this.buttonDetails.getWidth() - this.buttonAdd.getWidth() - this.buttonRemove.getWidth() - (innerPadding * 4) + 2, 15);
    }
    // Formatted button
    this.buttonFormat = new UIButtonBuilder(this).width(10).anchor(Anchor.BOTTOM | Anchor.LEFT).visible(this.hasAnyPermission()).listener(this).build("button.format");
    // Content text field
    contentField = new UITextField(this, "", true);
    contentField.setSize(SimpleScreen.getPaddedWidth(form), SimpleScreen.getPaddedHeight(form) - this.pagesSelect.getHeight() - (innerPadding * 2) - this.buttonFormat.getHeight());
    contentField.setPosition(0, SimpleScreen.getPaddedY(this.pagesSelect, innerPadding));
    contentField.setEditable(this.hasModifyPermission());
    contentField.setOptions(0x555555, 0xc8c8c8, 0x00000);
    // Close button
    final UIButton buttonClose = new UIButtonBuilder(this).width(40).anchor(Anchor.BOTTOM | Anchor.RIGHT).text(Text.of("almura.guide.button.close")).listener(this).build("button.close");
    // Save button
    this.buttonSave = new UIButtonBuilder(this).width(40).anchor(Anchor.BOTTOM | Anchor.RIGHT).x(SimpleScreen.getPaddedX(buttonClose, innerPadding, Anchor.RIGHT)).text(Text.of("almura.guide.button.save")).visible(hasAnyPermission()).enabled(hasModifyPermission()).listener(this).build("button.save");
    form.add(this.buttonRemove, this.pagesSelect, this.buttonDetails, this.buttonAdd, this.buttonFormat, contentField, buttonClose, buttonSave);
    addToScreen(form);
    this.updateButtons();
}
Also used : UIButtonBuilder(com.almuradev.almura.shared.client.ui.component.button.UIButtonBuilder) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) UIFormContainer(com.almuradev.almura.shared.client.ui.component.UIFormContainer) UITextField(net.malisis.core.client.gui.component.interaction.UITextField) PageListEntry(com.almuradev.almura.feature.guide.PageListEntry)

Example 5 with UITextField

use of net.malisis.core.client.gui.component.interaction.UITextField in project Almura by AlmuraDev.

the class SimplePageDetails method construct.

@Override
public void construct() {
    this.guiscreenBackground = true;
    this.validatePage();
    assert manager.getPage() != null;
    final UIForm form = new UIForm(this, 150, 225, I18n.format("almura.guide.details.form.title"));
    form.setAnchor(Anchor.CENTER | Anchor.MIDDLE);
    form.setMovable(true);
    form.setClosable(true);
    form.setZIndex(50);
    // File name
    final UILabel labelId = new UILabel(this, I18n.format("almura.guide.label.id"));
    labelId.setAnchor(Anchor.TOP | Anchor.LEFT);
    final UITextField textFieldId = new UITextField(this, manager.getPage().getId());
    textFieldId.setAnchor(Anchor.TOP | Anchor.LEFT);
    textFieldId.setPosition(0, SimpleScreen.getPaddedY(labelId, 1));
    textFieldId.setSize(UIComponent.INHERITED, 0);
    textFieldId.setFontOptions(this.readOnlyFontOptions);
    textFieldId.setEditable(false);
    // Index
    final UILabel labelIndex = new UILabel(this, I18n.format("almura.guide.label.index"));
    labelIndex.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelIndex.setPosition(0, SimpleScreen.getPaddedY(textFieldId, padding));
    this.textFieldIndex = new UITextField(this, Integer.toString(manager.getPage().getIndex()));
    this.textFieldIndex.setAnchor(Anchor.TOP | Anchor.LEFT);
    this.textFieldIndex.setPosition(0, SimpleScreen.getPaddedY(labelIndex, 1));
    this.textFieldIndex.setSize(UIComponent.INHERITED, 0);
    this.textFieldIndex.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, SimpleScreen.getPaddedY(this.textFieldIndex, padding));
    this.textFieldName = new UITextField(this, manager.getPage().getName());
    this.textFieldName.setAnchor(Anchor.TOP | Anchor.LEFT);
    this.textFieldName.setPosition(0, SimpleScreen.getPaddedY(labelName, 1));
    this.textFieldName.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, SimpleScreen.getPaddedY(this.textFieldName, padding));
    // TODO: Show username in format of: Username (UUID)
    final UITextField textFieldCreator = new UITextField(this, manager.getPage().getCreator().toString());
    textFieldCreator.setAnchor(Anchor.TOP | Anchor.LEFT);
    textFieldCreator.setPosition(0, SimpleScreen.getPaddedY(labelCreator, 1));
    textFieldCreator.setSize(UIComponent.INHERITED, 0);
    textFieldCreator.setFontOptions(this.readOnlyFontOptions);
    textFieldCreator.setEditable(false);
    // Created
    final UILabel labelCreated = new UILabel(this, I18n.format("almura.guide.label.created"));
    labelCreated.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelCreated.setPosition(0, SimpleScreen.getPaddedY(textFieldCreator, padding));
    final UITextField textFieldCreated = new UITextField(this, formatter.format(manager.getPage().getCreated()));
    textFieldCreated.setAnchor(Anchor.TOP | Anchor.LEFT);
    textFieldCreated.setPosition(0, SimpleScreen.getPaddedY(labelCreated, 1));
    textFieldCreated.setSize(UIComponent.INHERITED, 0);
    textFieldCreated.setFontOptions(this.readOnlyFontOptions);
    textFieldCreated.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, SimpleScreen.getPaddedY(textFieldCreated, padding));
    // TODO: Show username in format of: Username (UUID)
    final UITextField textFieldLastModifier = new UITextField(this, manager.getPage().getLastModifier().toString());
    textFieldLastModifier.setAnchor(Anchor.TOP | Anchor.LEFT);
    textFieldLastModifier.setPosition(0, SimpleScreen.getPaddedY(labelLastModifier, 1));
    textFieldLastModifier.setSize(UIComponent.INHERITED, 0);
    textFieldLastModifier.setFontOptions(this.readOnlyFontOptions);
    textFieldLastModifier.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, SimpleScreen.getPaddedY(textFieldLastModifier, padding));
    final UITextField textFieldLastModified = new UITextField(this, formatter.format(manager.getPage().getLastModified()));
    textFieldLastModified.setAnchor(Anchor.TOP | Anchor.LEFT);
    textFieldLastModified.setPosition(0, SimpleScreen.getPaddedY(labelLastModified, 1));
    textFieldLastModified.setSize(UIComponent.INHERITED, 0);
    textFieldLastModified.setFontOptions(this.readOnlyFontOptions);
    textFieldLastModified.setEditable(false);
    // Save/Cancel
    final UIButton buttonSave = new UIButtonBuilder(this).text(Text.of("almura.guide.button.close")).anchor(Anchor.BOTTOM | Anchor.RIGHT).width(40).listener(this).build("button.close");
    final UIButton buttonCancel = new UIButtonBuilder(this).text(Text.of("almura.guide.button.save")).anchor(Anchor.BOTTOM | Anchor.RIGHT).position(SimpleScreen.getPaddedX(buttonSave, 2, Anchor.RIGHT), 0).width(40).listener(this).build("button.save");
    form.add(labelId, textFieldId, labelIndex, this.textFieldIndex, labelName, this.textFieldName, labelCreator, textFieldCreator, labelCreated, textFieldCreated, labelLastModifier, textFieldLastModifier, labelLastModified, textFieldLastModified, buttonSave, buttonCancel);
    addToScreen(form);
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) UIButtonBuilder(com.almuradev.almura.shared.client.ui.component.button.UIButtonBuilder) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) UIForm(com.almuradev.almura.shared.client.ui.component.UIForm) UITextField(net.malisis.core.client.gui.component.interaction.UITextField)

Aggregations

UIButtonBuilder (com.almuradev.almura.shared.client.ui.component.button.UIButtonBuilder)5 UIButton (net.malisis.core.client.gui.component.interaction.UIButton)5 UITextField (net.malisis.core.client.gui.component.interaction.UITextField)5 UILabel (net.malisis.core.client.gui.component.decoration.UILabel)4 UIForm (com.almuradev.almura.shared.client.ui.component.UIForm)2 UIFormContainer (com.almuradev.almura.shared.client.ui.component.UIFormContainer)2 PageListEntry (com.almuradev.almura.feature.guide.PageListEntry)1 GuiRemoteTexture (com.almuradev.almura.shared.client.texture.GuiRemoteTexture)1 UISimpleList (com.almuradev.almura.shared.client.ui.component.UISimpleList)1 Optional (java.util.Optional)1 GuiTexture (net.malisis.core.client.gui.GuiTexture)1 UISlot (net.malisis.core.client.gui.component.UISlot)1 UIImage (net.malisis.core.client.gui.component.decoration.UIImage)1 MalisisSlot (net.malisis.core.inventory.MalisisSlot)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 PluginContainer (org.spongepowered.api.plugin.PluginContainer)1 Text (org.spongepowered.api.text.Text)1