Search in sources :

Example 6 with BasicTextBox

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

the class GuidePageDetailsScreen method construct.

@Override
public void construct() {
    this.guiscreenBackground = true;
    Keyboard.enableRepeatEvents(true);
    this.validatePage();
    assert manager.getPage() != null;
    final BasicForm form = new BasicForm(this, 150, 225, I18n.format("almura.guide.details.form.title"));
    form.setZIndex(10);
    form.setBackgroundAlpha(255);
    // File name
    final UILabel labelId = new UILabel(this, I18n.format("almura.guide.label.id"));
    labelId.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelId.setFontOptions(FontColors.WHITE_FO);
    final BasicTextBox tbId = new BasicTextBox(this, manager.getPage().getId());
    tbId.setAnchor(Anchor.TOP | Anchor.LEFT);
    tbId.setPosition(0, BasicScreen.getPaddedY(labelId, 1));
    tbId.setSize(UIComponent.INHERITED, 0);
    tbId.setEditable(false);
    // Index
    final UILabel labelIndex = new UILabel(this, I18n.format("almura.guide.label.index"));
    labelIndex.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelIndex.setPosition(0, BasicScreen.getPaddedY(tbId, padding));
    labelIndex.setFontOptions(FontColors.WHITE_FO);
    this.tbIndex = new BasicTextBox(this, Integer.toString(manager.getPage().getIndex()));
    this.tbIndex.setAcceptsReturn(false);
    this.tbIndex.setAcceptsTab(false);
    this.tbIndex.setTabIndex(0);
    this.tbIndex.setOnEnter(tb -> this.save());
    this.tbIndex.setAnchor(Anchor.TOP | Anchor.LEFT);
    this.tbIndex.setPosition(0, BasicScreen.getPaddedY(labelIndex, 1));
    this.tbIndex.setSize(UIComponent.INHERITED, 0);
    this.tbIndex.setFilter(s -> s.replaceAll("[^\\d]", ""));
    // Title
    final UILabel labelName = new UILabel(this, I18n.format("almura.guide.label.name"));
    labelName.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelName.setPosition(0, BasicScreen.getPaddedY(this.tbIndex, padding));
    labelName.setFontOptions(FontColors.WHITE_FO);
    this.tbName = new BasicTextBox(this, manager.getPage().getName());
    this.tbName.setAcceptsReturn(false);
    this.tbName.setAcceptsTab(false);
    this.tbName.setTabIndex(0);
    this.tbName.setOnEnter(tb -> this.save());
    this.tbName.setAnchor(Anchor.TOP | Anchor.LEFT);
    this.tbName.setPosition(0, BasicScreen.getPaddedY(labelName, 1));
    this.tbName.setSize(UIComponent.INHERITED, 0);
    // Creator
    final UILabel labelCreator = new UILabel(this, I18n.format("almura.guide.label.creator"));
    labelCreator.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelCreator.setPosition(0, BasicScreen.getPaddedY(this.tbName, padding));
    labelCreator.setFontOptions(FontColors.WHITE_FO);
    final BasicTextBox tbCreator = new BasicTextBox(this, manager.getPage().getCreator().toString());
    tbCreator.setAnchor(Anchor.TOP | Anchor.LEFT);
    tbCreator.setPosition(0, BasicScreen.getPaddedY(labelCreator, 1));
    tbCreator.setSize(UIComponent.INHERITED, 0);
    tbCreator.setEditable(false);
    // Created
    final UILabel labelCreated = new UILabel(this, I18n.format("almura.guide.label.created"));
    labelCreated.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelCreated.setPosition(0, BasicScreen.getPaddedY(tbCreator, padding));
    labelCreated.setFontOptions(FontColors.WHITE_FO);
    final BasicTextBox tbCreated = new BasicTextBox(this, formatter.format(manager.getPage().getCreated()));
    tbCreated.setAnchor(Anchor.TOP | Anchor.LEFT);
    tbCreated.setPosition(0, BasicScreen.getPaddedY(labelCreated, 1));
    tbCreated.setSize(UIComponent.INHERITED, 0);
    tbCreated.setEditable(false);
    // Last Modifier
    final UILabel labelLastModifier = new UILabel(this, I18n.format("almura.guide.label.last_modifier"));
    labelLastModifier.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelLastModifier.setPosition(0, BasicScreen.getPaddedY(tbCreated, padding));
    labelLastModifier.setFontOptions(FontColors.WHITE_FO);
    final BasicTextBox tbLastModifier = new BasicTextBox(this, manager.getPage().getLastModifier().toString());
    tbLastModifier.setAnchor(Anchor.TOP | Anchor.LEFT);
    tbLastModifier.setPosition(0, BasicScreen.getPaddedY(labelLastModifier, 1));
    tbLastModifier.setSize(UIComponent.INHERITED, 0);
    tbLastModifier.setEditable(false);
    // Last Modified
    final UILabel labelLastModified = new UILabel(this, I18n.format("almura.guide.label.last_modified"));
    labelLastModified.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelLastModified.setPosition(0, BasicScreen.getPaddedY(tbLastModifier, padding));
    labelLastModified.setFontOptions(FontColors.WHITE_FO);
    final BasicTextBox tbLastModified = new BasicTextBox(this, formatter.format(manager.getPage().getLastModified()));
    tbLastModified.setAnchor(Anchor.TOP | Anchor.LEFT);
    tbLastModified.setPosition(0, BasicScreen.getPaddedY(labelLastModified, 1));
    tbLastModified.setSize(UIComponent.INHERITED, 0);
    tbLastModified.setEditable(false);
    // Save/Cancel
    final UIButton buttonSave = new UIButtonBuilder(this).text(I18n.format("almura.button.save")).anchor(Anchor.BOTTOM | Anchor.RIGHT).width(40).onClick(this::save).build("button.save");
    final UIButton buttonCancel = new UIButtonBuilder(this).text(I18n.format("almura.button.cancel")).anchor(Anchor.BOTTOM | Anchor.RIGHT).position(BasicScreen.getPaddedX(buttonSave, 2, Anchor.RIGHT), 0).width(40).onClick(this::close).build("button.cancel");
    form.add(labelId, tbId, labelIndex, this.tbIndex, labelName, this.tbName, labelCreator, tbCreator, labelCreated, tbCreated, labelLastModifier, tbLastModifier, labelLastModified, tbLastModified, buttonSave, buttonCancel);
    addToScreen(form);
    this.tbIndex.focus();
    this.tbIndex.selectAll();
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) BasicTextBox(net.malisis.core.client.gui.component.interaction.BasicTextBox)

Example 7 with BasicTextBox

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

the class ExchangeBuyQuantityScreen 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.buy());
    this.quantityTextBox.setSize(45, 0);
    this.quantityTextBox.setPosition(0, 0, Anchor.TOP | Anchor.RIGHT);
    this.quantityTextBox.setFilter(s -> s = String.valueOf(MathUtil.squashi(Integer.valueOf(s.replaceAll("[^\\d]", "")), 1, toBuyItem.getQuantity())));
    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.buttonBuy = new UIButtonBuilder(this).text(I18n.format("almura.feature.common.button.buy")).width(40).position(-2, -2).anchor(Anchor.RIGHT | Anchor.BOTTOM).onClick(this::buy).build("button.buy");
    this.buttonCancel = new UIButtonBuilder(this).text(I18n.format("almura.button.cancel")).width(40).position(BasicScreen.getPaddedX(this.buttonBuy, 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.buttonBuy);
    this.updateControls(this.quantityTextBox.getText());
    this.addToScreen(this.form);
    this.quantityTextBox.focus();
    this.quantityTextBox.selectAll();
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) BasicTextBox(net.malisis.core.client.gui.component.interaction.BasicTextBox)

Example 8 with BasicTextBox

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

the class GuidePageCreateScreen method construct.

@Override
public void construct() {
    this.guiscreenBackground = true;
    Keyboard.enableRepeatEvents(true);
    final BasicForm form = new BasicForm(this, 150, 125, I18n.format("almura.guide.create.form.title"));
    form.setZIndex(10);
    form.setBackgroundAlpha(255);
    // File name
    final UILabel labelId = new UILabel(this, I18n.format("almura.guide.label.id"));
    labelId.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelId.setFontOptions(FontColors.WHITE_FO);
    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.setAnchor(Anchor.TOP | Anchor.LEFT);
    this.tbId.setPosition(0, BasicScreen.getPaddedY(labelId, 1));
    this.tbId.setSize(UIComponent.INHERITED, 0);
    this.tbId.setFocused(true);
    this.tbId.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.tbId.isVisible() ? BasicScreen.getPaddedY(this.tbId, padding) : padding);
    labelIndex.setFontOptions(FontColors.WHITE_FO);
    this.tbIndex = new BasicTextBox(this, Integer.toString(0));
    this.tbIndex.setAcceptsReturn(false);
    this.tbIndex.setAcceptsTab(false);
    this.tbIndex.setTabIndex(1);
    this.tbIndex.setOnEnter(tb -> this.save());
    this.tbIndex.setAnchor(Anchor.TOP | Anchor.LEFT);
    this.tbIndex.setPosition(0, BasicScreen.getPaddedY(labelIndex, 1));
    this.tbIndex.setSize(UIComponent.INHERITED, 0);
    this.tbIndex.setFilter(s -> s.replaceAll("[^\\d]", ""));
    // Title
    final UILabel labelName = new UILabel(this, I18n.format("almura.guide.label.name"));
    labelName.setAnchor(Anchor.TOP | Anchor.LEFT);
    labelName.setPosition(0, this.tbIndex.isVisible() ? BasicScreen.getPaddedY(this.tbIndex, padding) : padding);
    labelName.setFontOptions(FontColors.WHITE_FO);
    this.tbName = new BasicTextBox(this, "");
    this.tbName.setAcceptsReturn(false);
    this.tbName.setAcceptsTab(false);
    this.tbName.setTabIndex(2);
    this.tbName.setOnEnter(tb -> this.save());
    this.tbName.setAnchor(Anchor.TOP | Anchor.LEFT);
    this.tbName.setPosition(0, BasicScreen.getPaddedY(labelName, 1));
    this.tbName.setSize(UIComponent.INHERITED, 0);
    this.tbName.setFilter(s -> s.substring(0, Math.min(s.length(), 50)));
    // Save/Cancel
    final UIButton buttonSave = new UIButtonBuilder(this).text(I18n.format("almura.button.save")).anchor(Anchor.BOTTOM | Anchor.RIGHT).width(40).onClick(this::save).build("button.save");
    final UIButton buttonCancel = new UIButtonBuilder(this).text(I18n.format("almura.button.cancel")).anchor(Anchor.BOTTOM | Anchor.RIGHT).position(BasicScreen.getPaddedX(buttonSave, 2, Anchor.RIGHT), 0).width(40).onClick(this::close).build("button.cancel");
    form.add(labelId, this.tbId, labelIndex, this.tbIndex, labelName, this.tbName, buttonCancel, buttonSave);
    addToScreen(form);
    this.tbId.focus();
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) BasicTextBox(net.malisis.core.client.gui.component.interaction.BasicTextBox)

Example 9 with BasicTextBox

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

the class StoreScreen method construct.

@Override
public void construct() {
    guiscreenBackground = false;
    final BasicForm form = new BasicForm(this, 257, 300, this.store.getName());
    form.setBackgroundAlpha(255);
    final BasicContainer<?> storeContainer = new BasicContainer<>(this, 251, UIComponent.INHERITED);
    storeContainer.setBorder(FontColors.WHITE, 1, 185);
    storeContainer.setPadding(3);
    storeContainer.setColor(0);
    // Buy tab
    final int leftOffset = storeContainer.getLeftPadding() - storeContainer.getLeftBorderSize();
    this.buyTabContainer = new BasicContainer<>(this, this.tabWidth, this.tabHeight);
    this.buyTabContainer.setBorders(FontColors.WHITE, 185, 1, 1, 1, 0);
    this.buyTabContainer.setPosition(2, 2);
    this.buyTabContainer.setColor(defaultTabColor);
    this.buyTabContainer.attachData(SideType.BUY);
    // Buy tab label
    this.buyTabLabel = new UILabel(this, I18n.format("almura.feature.common.button.buy"));
    this.buyTabLabel.setPosition(0, 1, Anchor.MIDDLE | Anchor.CENTER);
    // Always use the same data as their parent
    this.buyTabLabel.attachData(this.buyTabContainer.getData());
    this.buyTabContainer.add(this.buyTabLabel);
    // Sell tab
    this.sellTabContainer = new BasicContainer<>(this, this.tabWidth, this.tabHeight);
    this.sellTabContainer.setBorders(FontColors.WHITE, 185, 1, 1, 1, 0);
    this.sellTabContainer.setColor(defaultTabColor);
    this.sellTabContainer.setPosition(-2, 2, Anchor.TOP | Anchor.RIGHT);
    this.sellTabContainer.attachData(SideType.SELL);
    // Sell tab label
    this.sellTabLabel = new UILabel(this, I18n.format("almura.feature.common.button.sell"));
    this.sellTabLabel.setPosition(0, 1, Anchor.MIDDLE | Anchor.CENTER);
    // Always use the same data as their parent
    this.sellTabLabel.attachData(this.sellTabContainer.getData());
    this.sellTabContainer.add(this.sellTabLabel);
    // Doesn't exist.
    this.thisDoesNotExistLine = new BasicLine(this, this.tabWidth - 2);
    this.thisDoesNotExistLine.setBackgroundAlpha(255);
    this.thisDoesNotExistLine.setColor(selectedTabColor);
    // Bottom tab line
    final BasicLine tabContainerLineBottom = new BasicLine(this, storeContainer.getWidth() - (storeContainer.getLeftBorderSize() + storeContainer.getRightBorderSize()), 1);
    tabContainerLineBottom.setPosition(-leftOffset, BasicScreen.getPaddedY(this.buyTabContainer, 0));
    // Search Y
    final int searchY = BasicScreen.getPaddedY(tabContainerLineBottom, 2);
    // Item Display Name Search Label
    final UILabel itemSearchLabel = new UILabel(this, I18n.format("almura.feature.exchange.text.item_name") + ":");
    itemSearchLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).build());
    itemSearchLabel.setPosition(1, searchY + 3, Anchor.LEFT | Anchor.TOP);
    // Item Display Name Search Text Box
    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(60, 0);
    this.itemDisplayNameSearchBox.setPosition(BasicScreen.getPaddedX(itemSearchLabel, innerPadding), searchY + 1, Anchor.LEFT | Anchor.TOP);
    this.itemDisplayNameSearchBox.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    // Sort combobox
    this.comboBoxSortType = new UISelect<>(this, 78);
    this.comboBoxSortType.setPosition(BasicScreen.getPaddedX(this.itemDisplayNameSearchBox, innerPadding), searchY + 1);
    this.comboBoxSortType.setOptions(Arrays.asList(FeatureSortTypes.ITEM_DISPLAY_NAME_ASC, FeatureSortTypes.ITEM_DISPLAY_NAME_DESC, FeatureSortTypes.PRICE_ASC, FeatureSortTypes.PRICE_DESC));
    this.comboBoxSortType.setOptionsWidth(UISelect.LONGEST_OPTION);
    // Because that's reasonable.
    this.comboBoxSortType.setLabelFunction(type -> type == null ? "" : type.getName());
    this.comboBoxSortType.select(FeatureSortTypes.ITEM_DISPLAY_NAME_ASC);
    // Search button
    final UIButton buttonSearch = new UIButtonBuilder(this).width(50).anchor(Anchor.RIGHT | Anchor.TOP).position(0, searchY).text(I18n.format("almura.feature.common.button.search")).onClick(this::search).build("button.search");
    // List
    this.itemList = new BasicList<>(this, UIComponent.INHERITED, BasicScreen.getPaddedHeight(form) - this.buyTabContainer.getHeight() - tabContainerLineBottom.getHeight() - buttonSearch.getHeight() - 30);
    this.itemList.setPosition(0, BasicScreen.getPaddedY(buttonSearch, 2));
    this.itemList.setSelectConsumer(i -> this.updateStoreControls());
    this.itemList.setItemComponentSpacing(1);
    this.itemList.setBorder(FontColors.WHITE, 1, 185);
    this.itemList.setPadding(2);
    this.itemList.setItemComponentFactory(StoreItemComponent::new);
    this.buttonTransactOne = new UIButtonBuilder(this).width(60).anchor(Anchor.BOTTOM | Anchor.LEFT).enabled(false).onClick(() -> this.transact(1)).build("button.transact.single");
    this.buttonTransactStack = new UIButtonBuilder(this).width(60).x(BasicScreen.getPaddedX(this.buttonTransactOne, 2)).anchor(Anchor.BOTTOM | Anchor.LEFT).enabled(false).onClick(() -> {
        if (this.itemList.getSelectedItem() == null) {
            return;
        }
        final int value = this.itemList.getSelectedItem().asRealStack().getMaxStackSize();
        this.transact(value);
    }).build("button.transact.stack");
    this.buttonTransactAll = new UIButtonBuilder(this).width(60).anchor(Anchor.BOTTOM | Anchor.RIGHT).enabled(false).onClick(() -> {
        final StoreItem selectedItem = this.itemList.getSelectedItem();
        if (selectedItem == null) {
            return;
        }
        // Determine the value to transact
        final int value;
        if (this.currentSide == SideType.BUY) {
            // If we are buying then base the value on the quantity remaining for the item to purchase
            value = this.itemList.getSelectedItem().getQuantity();
        } else {
            // If we're selling then base it on how many we have in our main inventory
            value = Minecraft.getMinecraft().player.inventory.mainInventory.stream().filter(i -> ItemStack.areItemsEqual(i, selectedItem.asRealStack())).mapToInt(ItemStack::getCount).sum();
        }
        this.transact(value);
    }).build("button.transact.all");
    this.buttonTransactQuantity = new UIButtonBuilder(this).width(60).x(BasicScreen.getPaddedX(this.buttonTransactAll, 2, Anchor.RIGHT)).anchor(Anchor.BOTTOM | Anchor.RIGHT).enabled(false).onClick(() -> {
        final StoreItem selectedItem = this.itemList.getSelectedItem();
        if (selectedItem == null) {
            return;
        }
        new StoreTransactQuantityScreen(this, this.store, selectedItem, this.currentSide).display();
    }).build("button.transact.quantity");
    storeContainer.add(this.buyTabContainer, this.sellTabContainer, tabContainerLineBottom, this.thisDoesNotExistLine, itemSearchLabel, this.itemDisplayNameSearchBox, this.comboBoxSortType, buttonSearch, this.itemList, this.buttonTransactOne, this.buttonTransactStack, this.buttonTransactQuantity, this.buttonTransactAll);
    form.add(storeContainer);
    // Logic for admin pane
    if (this.isAdmin) {
        // Adjust form width
        form.setWidth(form.getWidth() + 224);
        // Create admin pane
        final BasicContainer<?> adminContainer = new BasicContainer(this, 220, UIComponent.INHERITED);
        adminContainer.setPosition(BasicScreen.getPaddedX(storeContainer, 4), 0);
        adminContainer.setBorder(FontColors.WHITE, 1, 185);
        adminContainer.setPadding(3);
        adminContainer.setColor(0);
        // Buy tab label
        this.typeLabel = new UILabel(this, TextFormatting.WHITE + "Type: ");
        this.typeLabel.setPosition(0, 2, Anchor.TOP | Anchor.LEFT);
        // Item location selection
        this.locationSelect = new UISelect<>(this, UIComponent.INHERITED);
        this.locationSelect.setOptions(itemFinderRelationshipMap.keySet());
        this.locationSelect.setLabelFunction(o -> I18n.format(o.translationKey));
        this.locationSelect.setPosition(30, 0);
        this.locationSelect.setSize(184, 12);
        this.locationSelect.maxDisplayedOptions(24);
        this.locationSelect.register(this);
        // Search text box
        this.adminSearchTextBox = new BasicTextBox(this, "");
        this.adminSearchTextBox.setSize(UIComponent.INHERITED, this.locationSelect.getHeight());
        this.adminSearchTextBox.setPosition(0, BasicScreen.getPaddedY(this.locationSelect, 2));
        this.adminSearchTextBox.register(this);
        // Item list
        this.adminItemList = new BasicList<>(this, UIComponent.INHERITED, BasicScreen.getPaddedHeight(form) - this.locationSelect.getHeight() - this.adminSearchTextBox.getHeight() - 28);
        this.adminItemList.setItemComponentFactory(AdminItemComponent::new);
        this.adminItemList.setItemComponentSpacing(1);
        this.adminItemList.setPosition(0, BasicScreen.getPaddedY(this.adminSearchTextBox, 2));
        this.adminItemList.setPadding(2);
        this.adminItemList.setBorder(FontColors.WHITE, 1, 185);
        this.adminItemList.setSelectConsumer(i -> this.updateAdminControls());
        this.buttonAdminList = new UIButtonBuilder(this).width(50).anchor(Anchor.BOTTOM | Anchor.LEFT).enabled(false).onClick(this::listOrModify).text(I18n.format("almura.feature.common.button.list")).build("button.list");
        this.buttonAdminUnlist = new UIButtonBuilder(this).width(50).anchor(Anchor.BOTTOM | Anchor.LEFT).position(BasicScreen.getPaddedX(this.buttonAdminList, 2), 0).enabled(false).onClick(this::unlist).text(I18n.format("almura.feature.common.button.unlist")).build("button.unlist");
        this.adminListTotalLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.total") + ": ");
        this.adminListTotalLabel.setPosition(0, -2, Anchor.BOTTOM | Anchor.RIGHT);
        adminContainer.add(this.typeLabel, this.locationSelect, this.adminSearchTextBox, this.adminItemList, this.buttonAdminList, this.buttonAdminUnlist, this.adminListTotalLabel);
        form.add(adminContainer);
        // Select the first item
        this.locationSelect.selectFirst();
    }
    addToScreen(form);
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) Arrays(java.util.Arrays) UIComponent(net.malisis.core.client.gui.component.UIComponent) BuyingItem(com.almuradev.almura.feature.store.listing.BuyingItem) I18n(net.minecraft.client.resources.I18n) BigDecimal(java.math.BigDecimal) UISaneTooltip(com.almuradev.almura.shared.client.ui.component.UISaneTooltip) MalisisGui(net.malisis.core.client.gui.MalisisGui) BasicTextBox(net.malisis.core.client.gui.component.interaction.BasicTextBox) Side(net.minecraftforge.fml.relauncher.Side) Map(java.util.Map) BasicList(net.malisis.core.client.gui.component.container.BasicList) BasicContainer(net.malisis.core.client.gui.component.container.BasicContainer) NonNullList(net.minecraft.util.NonNullList) FontColors(net.malisis.core.util.FontColors) FeatureConstants(com.almuradev.almura.shared.feature.FeatureConstants) StoreModule(com.almuradev.almura.feature.store.StoreModule) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) ClientStoreManager(com.almuradev.almura.feature.store.client.ClientStoreManager) UITooltip(net.malisis.core.client.gui.component.decoration.UITooltip) Collectors(java.util.stream.Collectors) List(java.util.List) EntityPlayer(net.minecraft.entity.player.EntityPlayer) UIImage(net.malisis.core.client.gui.component.decoration.UIImage) Optional(java.util.Optional) SortType(com.almuradev.almura.feature.SortType) BasicLine(net.malisis.core.client.gui.component.decoration.BasicLine) HashMap(java.util.HashMap) ITooltipFlag(net.minecraft.client.util.ITooltipFlag) FeatureSortTypes(com.almuradev.almura.FeatureSortTypes) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Inject(javax.inject.Inject) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) Anchor(net.malisis.core.client.gui.Anchor) SellingItem(com.almuradev.almura.feature.store.listing.SellingItem) StoreItem(com.almuradev.almura.feature.store.listing.StoreItem) Subscribe(com.google.common.eventbus.Subscribe) BasicScreen(net.malisis.core.client.gui.BasicScreen) UIExpandingLabel(com.almuradev.almura.shared.client.ui.component.UIExpandingLabel) CreativeTabs(net.minecraft.creativetab.CreativeTabs) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) UISelect(net.malisis.core.client.gui.component.interaction.UISelect) ComponentEvent(net.malisis.core.client.gui.event.ComponentEvent) Nullable(javax.annotation.Nullable) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) UITextField(net.malisis.core.client.gui.component.interaction.UITextField) UILabel(net.malisis.core.client.gui.component.decoration.UILabel) TextFormatting(net.minecraft.util.text.TextFormatting) Store(com.almuradev.almura.feature.store.Store) SideType(com.almuradev.almura.feature.store.SideType) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) FontRenderer(net.minecraft.client.gui.FontRenderer) ForgeRegistries(net.minecraftforge.fml.common.registry.ForgeRegistries) Comparator(java.util.Comparator) FontOptions(net.malisis.core.renderer.font.FontOptions) BasicLine(net.malisis.core.client.gui.component.decoration.BasicLine) StoreItem(com.almuradev.almura.feature.store.listing.StoreItem) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) BasicContainer(net.malisis.core.client.gui.component.container.BasicContainer) ItemStack(net.minecraft.item.ItemStack) BasicTextBox(net.malisis.core.client.gui.component.interaction.BasicTextBox)

Example 10 with BasicTextBox

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

the class StoreListScreen method construct.

@Override
public void construct() {
    this.guiscreenBackground = false;
    this.form = new BasicForm(this, 250, 130, I18n.format("almura.feature.common.text.list"));
    // Fixes issue overlapping draws from parent
    this.form.setZIndex(10);
    this.form.setBackgroundAlpha(255);
    final int containerWidth = getPaddedWidth(this.form) / 2 - 1;
    // Buy container
    this.buyContainer = new BasicContainer<>(this, containerWidth, -18);
    this.buyContainer.setColor(FontColors.BLACK);
    this.buyContainer.setBorder(FontColors.WHITE, 1, 185);
    this.buyContainer.setPadding(2);
    this.buyTitleLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.button.buy"));
    this.buyTitleLabel.setPosition(0, 2, Anchor.TOP | Anchor.CENTER);
    final BasicLine buyLine = new BasicLine(this, getPaddedWidth(this.buyContainer) + 2);
    buyLine.setPosition(-1, getPaddedY(this.buyTitleLabel, 2));
    this.buyPricePerTextBox = new BasicTextBox(this, this.toModifyBuy != null ? this.toModifyBuy.getPrice().toString() : "");
    this.buyPricePerTextBox.setPosition(-2, getPaddedY(buyLine, 2), Anchor.TOP | Anchor.RIGHT);
    this.buyPricePerTextBox.setSize(50, 0);
    this.buyPricePerTextBox.setAcceptsTab(false);
    this.buyPricePerTextBox.setTabIndex(1);
    this.buyPricePerTextBox.setFilter(s -> this.filterAndLimit(s, 2, true));
    this.buyPricePerTextBox.register(this);
    this.buyPerLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.price_per") + ":");
    this.buyPerLabel.setPosition(getPaddedX(this.buyPricePerTextBox, 2, Anchor.RIGHT), this.buyPricePerTextBox.getY() + 2, Anchor.TOP | Anchor.RIGHT);
    this.buyQtyTextBox = new BasicTextBox(this, "");
    this.buyQtyTextBox.setPosition(-2, getPaddedY(this.buyPricePerTextBox, 2), Anchor.TOP | Anchor.RIGHT);
    this.buyQtyTextBox.setSize(50, 0);
    this.buyQtyTextBox.setAcceptsTab(false);
    this.buyQtyTextBox.setTabIndex(2);
    this.buyQtyTextBox.setFilter(s -> this.filterAndLimit(s, 0, false));
    this.buyQtyTextBox.register(this);
    this.buyQtyLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.quantity") + ":");
    this.buyQtyLabel.setPosition(getPaddedX(this.buyQtyTextBox, 2, Anchor.RIGHT), this.buyQtyTextBox.getY() + 2, Anchor.TOP | Anchor.RIGHT);
    this.buyInfiniteCheckBox = new UICheckBox(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.infinite"));
    this.buyInfiniteCheckBox.setPosition(this.buyContainer.componentX(this.buyQtyTextBox) - this.buyContainer.getRightPadding() - this.buyContainer.getRightBorderSize(), getPaddedY(this.buyQtyTextBox, 2));
    this.buyInfiniteCheckBox.register(this);
    final int column2X = this.buyContainer.componentX(this.buyQtyTextBox) - this.buyContainer.getRightPadding() - this.buyContainer.getRightBorderSize();
    this.buyTotalPriceLabel = new UILabel(this);
    this.buyTotalPriceLabel.setFontOptions(FontOptions.builder().shadow(false).color(0x999999).build());
    this.buyTotalPriceLabel.setPosition(column2X + 2, 0, Anchor.BOTTOM | Anchor.LEFT);
    buyTotalLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.total") + ":");
    buyTotalLabel.setPosition(this.buyTotalPriceLabel.getX() - buyTotalLabel.getWidth() - 3, 0, Anchor.BOTTOM | Anchor.LEFT);
    this.buyContainer.add(this.buyTitleLabel, buyLine, this.buyPerLabel, this.buyPricePerTextBox, this.buyQtyLabel, this.buyQtyTextBox, this.buyInfiniteCheckBox, buyTotalLabel, this.buyTotalPriceLabel);
    // Sell container
    this.sellContainer = new BasicContainer<>(this, containerWidth, -18);
    this.sellContainer.setColor(FontColors.BLACK);
    this.sellContainer.setBorder(FontColors.WHITE, 1, 185);
    this.sellContainer.setPadding(2);
    this.sellContainer.setPosition(0, 0, Anchor.TOP | Anchor.RIGHT);
    this.sellTitleLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.button.sell"));
    this.sellTitleLabel.setPosition(0, 2, Anchor.TOP | Anchor.CENTER);
    final BasicLine sellLine = new BasicLine(this, getPaddedWidth(this.sellContainer) + 2);
    sellLine.setPosition(-1, getPaddedY(this.sellTitleLabel, 2));
    this.sellPricePerTextBox = new BasicTextBox(this, this.toModifySell != null ? this.toModifySell.getPrice().toString() : "");
    this.sellPricePerTextBox.setPosition(-2, getPaddedY(sellLine, 2), Anchor.TOP | Anchor.RIGHT);
    this.sellPricePerTextBox.setSize(50, 0);
    this.sellPricePerTextBox.setAcceptsTab(false);
    this.sellPricePerTextBox.setTabIndex(3);
    this.sellPricePerTextBox.setFilter(s -> this.filterAndLimit(s, 2, false));
    this.sellPricePerTextBox.register(this);
    this.sellPerLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.price_per") + ":");
    this.sellPerLabel.setPosition(getPaddedX(this.sellPricePerTextBox, 2, Anchor.RIGHT), this.sellPricePerTextBox.getY() + 2, Anchor.TOP | Anchor.RIGHT);
    this.sellQtyTextBox = new BasicTextBox(this, "");
    this.sellQtyTextBox.setPosition(-2, getPaddedY(this.sellPricePerTextBox, 2), Anchor.TOP | Anchor.RIGHT);
    this.sellQtyTextBox.setSize(50, 0);
    this.sellQtyTextBox.setAcceptsTab(false);
    this.sellQtyTextBox.setTabIndex(4);
    this.sellQtyTextBox.setFilter(s -> this.filterAndLimit(s, 0, false));
    this.sellQtyTextBox.register(this);
    this.sellQtyLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.quantity") + ":");
    this.sellQtyLabel.setPosition(getPaddedX(this.sellQtyTextBox, 2, Anchor.RIGHT), this.sellQtyTextBox.getY() + 2, Anchor.TOP | Anchor.RIGHT);
    this.sellInfiniteCheckBox = new UICheckBox(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.infinite"));
    this.sellInfiniteCheckBox.setPosition(column2X, getPaddedY(this.sellQtyTextBox, 2));
    this.sellInfiniteCheckBox.register(this);
    this.sellTotalPriceLabel = new UILabel(this, "");
    this.sellTotalPriceLabel.setFontOptions(FontOptions.builder().shadow(false).color(0x999999).build());
    this.sellTotalPriceLabel.setPosition(column2X + 2, 0, Anchor.BOTTOM | Anchor.LEFT);
    sellTotalLabel = new UILabel(this, TextFormatting.WHITE + I18n.format("almura.feature.common.text.price_per") + ":");
    sellTotalLabel.setPosition(this.sellTotalPriceLabel.getX() - sellTotalLabel.getWidth() - 3, 0, Anchor.BOTTOM | Anchor.LEFT);
    this.sellContainer.add(this.sellTitleLabel, sellLine, this.sellPerLabel, this.sellPricePerTextBox, this.sellQtyLabel, this.sellQtyTextBox, this.sellInfiniteCheckBox, sellTotalLabel, this.sellTotalPriceLabel);
    this.buttonList = new UIButtonBuilder(this).text(I18n.format(this.toModifyBuy != null || this.toModifySell != null ? "almura.feature.common.button.modify" : "almura.feature.common.text.list")).anchor(Anchor.BOTTOM | Anchor.RIGHT).onClick(this::listOrModify).width(50).enabled(false).build("button.list");
    this.buttonCancel = new UIButtonBuilder(this).text(I18n.format("almura.button.cancel")).anchor(Anchor.BOTTOM | Anchor.RIGHT).x(getPaddedX(this.buttonList, 2, Anchor.RIGHT)).onClick(this::close).width(50).build("button.cancel");
    this.form.add(this.buyContainer, this.sellContainer, this.buttonCancel, this.buttonList);
    this.addToScreen(this.form);
    // Update quantity
    if (this.toModifyBuy != null) {
        if (this.toModifyBuy.getQuantity() == -1) {
            this.buyInfiniteCheckBox.setChecked(true);
            this.buyInfiniteCheckBox.fireEvent(new ComponentEvent.ValueChange<>(this.buyInfiniteCheckBox, false, true));
        } else {
            this.buyQtyTextBox.setText(String.valueOf(this.toModifyBuy.getQuantity()));
        }
    }
    if (this.toModifySell != null) {
        if (this.toModifySell.getQuantity() == -1) {
            this.sellInfiniteCheckBox.setChecked(true);
            this.sellInfiniteCheckBox.fireEvent(new ComponentEvent.ValueChange<>(this.sellInfiniteCheckBox, false, true));
        } else {
            this.sellQtyTextBox.setText(String.valueOf(this.toModifySell.getQuantity()));
        }
    }
    this.buyPricePerTextBox.focus();
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) BasicLine(net.malisis.core.client.gui.component.decoration.BasicLine) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) ComponentEvent(net.malisis.core.client.gui.event.ComponentEvent) UICheckBox(net.malisis.core.client.gui.component.interaction.UICheckBox) BasicTextBox(net.malisis.core.client.gui.component.interaction.BasicTextBox)

Aggregations

BasicForm (net.malisis.core.client.gui.component.container.BasicForm)10 UILabel (net.malisis.core.client.gui.component.decoration.UILabel)10 BasicTextBox (net.malisis.core.client.gui.component.interaction.BasicTextBox)10 UIButtonBuilder (net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder)10 UIButton (net.malisis.core.client.gui.component.interaction.UIButton)5 BasicContainer (net.malisis.core.client.gui.component.container.BasicContainer)3 BasicLine (net.malisis.core.client.gui.component.decoration.BasicLine)3 UIImage (net.malisis.core.client.gui.component.decoration.UIImage)2 ComponentEvent (net.malisis.core.client.gui.event.ComponentEvent)2 FeatureSortTypes (com.almuradev.almura.FeatureSortTypes)1 SortType (com.almuradev.almura.feature.SortType)1 ForSaleItem (com.almuradev.almura.feature.exchange.listing.ForSaleItem)1 PopupNotification (com.almuradev.almura.feature.notification.type.PopupNotification)1 SideType (com.almuradev.almura.feature.store.SideType)1 Store (com.almuradev.almura.feature.store.Store)1 StoreModule (com.almuradev.almura.feature.store.StoreModule)1 ClientStoreManager (com.almuradev.almura.feature.store.client.ClientStoreManager)1 BuyingItem (com.almuradev.almura.feature.store.listing.BuyingItem)1 SellingItem (com.almuradev.almura.feature.store.listing.SellingItem)1 StoreItem (com.almuradev.almura.feature.store.listing.StoreItem)1