Search in sources :

Example 21 with BasicForm

use of net.malisis.core.client.gui.component.container.BasicForm 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 22 with BasicForm

use of net.malisis.core.client.gui.component.container.BasicForm in project Almura by AlmuraDev.

the class ManageTitlesGUI method construct.

@Override
public void construct() {
    this.guiscreenBackground = false;
    Keyboard.enableRepeatEvents(true);
    // Master Pane
    this.form = new BasicForm(this, this.screenWidth, this.screenHeight, "Title Manager");
    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);
    // Title List Area
    this.listArea = new BasicForm(this, 220, 260, "");
    this.listArea.setPosition(0, 0, Anchor.LEFT | Anchor.TOP);
    this.listArea.setMovable(false);
    this.listArea.setClosable(false);
    this.listArea.setBorder(FontColors.WHITE, 1, 185);
    this.listArea.setBackgroundAlpha(215);
    this.listArea.setBottomPadding(3);
    this.listArea.setRightPadding(3);
    this.listArea.setTopPadding(3);
    this.listArea.setLeftPadding(3);
    // Create left container
    final BasicContainer<?> titleContainer = new BasicContainer(this, 200, UIComponent.INHERITED);
    titleContainer.setBackgroundAlpha(0);
    titleContainer.setPosition(0, 0, Anchor.CENTER | Anchor.TOP);
    titleContainer.setPadding(4, 4);
    titleContainer.setTopPadding(20);
    this.titleList = new BasicList<>(this, UIComponent.INHERITED, UIComponent.INHERITED);
    this.titleList.setItemComponentFactory(TitleItemComponent::new);
    this.titleList.setItemComponentSpacing(1);
    this.titleList.setCanDeselect(false);
    this.titleList.setName("list.left");
    this.titleList.setItems(titleManager.getAvailableTitles());
    if (!titleManager.getAvailableTitles().isEmpty()) {
        if (titleManager.getSelectedTitleFor(this.mc.player.getUniqueID()) != null) {
            titleManager.setTitleContentForDisplay(titleManager.getSelectedTitleFor(this.mc.player.getUniqueID()));
            this.titleList.setSelectedItem(titleManager.getAvailableTitle(titleManager.getSelectedTitleFor(this.mc.player.getUniqueID()).getId()));
        } else {
            this.titleList.setSelectedItem(titleManager.getAvailableTitles().get(0));
            titleManager.setTitleContentForDisplay(titleManager.getAvailableTitles().get(0));
        }
    }
    this.titleList.register(this);
    titleContainer.add(this.titleList);
    this.listArea.add(titleContainer);
    // Edit Container
    this.editArea = new BasicForm(this, 220, 260, "");
    this.editArea.setPosition(0, 0, Anchor.RIGHT | Anchor.TOP);
    this.editArea.setMovable(false);
    this.editArea.setClosable(false);
    this.editArea.setBorder(FontColors.WHITE, 1, 185);
    this.editArea.setBackgroundAlpha(215);
    this.editArea.setBottomPadding(3);
    this.editArea.setRightPadding(3);
    this.editArea.setTopPadding(3);
    this.editArea.setLeftPadding(3);
    this.editArea.setVisible(false);
    this.modeNameLabel = new UILabel(this, "Modify Title").setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).underline(false).scale(1.2F).build()).setVisible(false).setPosition(0, 5, Anchor.CENTER | Anchor.TOP);
    final UILabel idLabel = new UILabel(this, "ID:").setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.0F).build()).setPosition(5, 17, Anchor.LEFT | Anchor.TOP);
    this.idField = new UITextField(this, "", false).setSize(200, 0).setPosition(10, 30, Anchor.LEFT | Anchor.TOP).setEditable(false).setEnabled(false).setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    final UILabel permissionNodeLabel = new UILabel(this, "Permission:").setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.0F).build()).setPosition(5, 57, Anchor.LEFT | Anchor.TOP);
    this.permissionField = new UITextField(this, "", false).setSize(200, 0).setPosition(10, 70, Anchor.LEFT | Anchor.TOP).setEditable(false).setEnabled(false).setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    final UILabel titleContextLabel = new UILabel(this, "Content:").setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.0F).build()).setPosition(5, 97, Anchor.LEFT | Anchor.TOP);
    this.contentField = new UITextField(this, "", false).setSize(200, 0).setPosition(10, 110, Anchor.LEFT | Anchor.TOP).setEditable(true).setEnabled(false).setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    // Color Selection dropdown
    this.colorSelector = new UISelect<>(this, 110, Arrays.asList("§1Dark Blue§f - &1", "§9Blue§f - &9", "§3Dark Aqua§f - &3", "§bAqua§f - &b", "§4Dark Red§f - &4", "§cRed§f - &c", "§eYellow§f - &e", "§6Gold§f - &6", "§2Dark Green§f - &2", "§aGreen§f - &a", "§5Dark Purple§f - &5", "§dLight Purple§f - &d", "§fWhite§f - &f", "§7Gray§f - &7", "§8Dark Gray§f - &8", "§0Black§f - &0,", "§lBold§f - &l", "§mStrikethrough§f - &m", "§nUnderline§f - &n", "§oItalic§f - &o"));
    this.colorSelector.setPosition(10, 126, Anchor.LEFT | Anchor.TOP);
    this.colorSelector.setOptionsWidth(UISelect.SELECT_WIDTH);
    this.colorSelector.setFontOptions(FontOptions.builder().shadow(false).build());
    this.colorSelector.select("§1Dark Blue§f - &1");
    this.colorSelector.setEnabled(false);
    this.colorSelector.maxDisplayedOptions(7);
    // Add Color character button
    this.buttonColor = new UIButtonBuilder(this).width(40).anchor(Anchor.TOP | Anchor.LEFT).position(130, 125).text("Add").listener(this).build("button.color");
    this.formattedCheckbox = new UICheckBox(this);
    this.formattedCheckbox.setText(TextFormatting.WHITE + "Formatted");
    this.formattedCheckbox.setPosition(9, 145, Anchor.LEFT | Anchor.TOP);
    this.formattedCheckbox.setChecked(false);
    this.formattedCheckbox.setName("checkbox.formatted");
    this.formattedCheckbox.register(this);
    this.hiddenCheckbox = new UICheckBox(this);
    this.hiddenCheckbox.setText(TextFormatting.WHITE + "Title Hidden from Players");
    this.hiddenCheckbox.setPosition(10, -7, Anchor.LEFT | Anchor.BOTTOM);
    this.hiddenCheckbox.setChecked(false);
    this.hiddenCheckbox.setName("checkbox.hidden");
    this.hiddenCheckbox.register(this);
    // Save Changes button
    final UIButton saveChangesButton = new UIButtonBuilder(this).width(30).text(I18n.format("almura.button.save")).position(0, -5).anchor(Anchor.BOTTOM | Anchor.RIGHT).listener(this).build("button.save");
    editArea.add(this.modeNameLabel, idLabel, permissionNodeLabel, this.permissionField, this.idField, titleContextLabel, this.contentField, this.colorSelector, this.buttonColor, this.formattedCheckbox, this.hiddenCheckbox, saveChangesButton);
    // Edit Container
    this.playerArea = new BasicForm(this, 220, 260, "");
    this.playerArea.setPosition(0, 0, Anchor.RIGHT | Anchor.TOP);
    this.playerArea.setMovable(false);
    this.playerArea.setClosable(false);
    this.playerArea.setBorder(FontColors.WHITE, 1, 185);
    this.playerArea.setBackgroundAlpha(215);
    this.playerArea.setBottomPadding(3);
    this.playerArea.setRightPadding(3);
    this.playerArea.setTopPadding(3);
    this.playerArea.setLeftPadding(3);
    this.playerArea.setVisible(true);
    final UILabel playerLabel = new UILabel(this, "Player Title").setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).underline(false).scale(1.2F).build()).setVisible(false).setPosition(0, 05, Anchor.CENTER | Anchor.TOP);
    this.buttonApply = new UIButtonBuilder(this).text("Apply").anchor(Anchor.BOTTOM | Anchor.RIGHT).tooltip("Apply Title and Exit").listener(this).enabled(this.canChangeTitle).visible(true).build("button.apply");
    this.buttonRemove = new UIButtonBuilder(this).text("Remove").anchor(Anchor.BOTTOM | Anchor.LEFT).tooltip("Remove Title and Exit").enabled(this.canChangeTitle).listener(this).visible(true).build("button.remove");
    this.playerArea.add(playerLabel, this.buttonApply, this.buttonRemove);
    this.titleSelectionLabel = new UILabel(this, "Available Titles:").setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.1F).build()).setPosition(5, 10, Anchor.LEFT | Anchor.TOP);
    // Add button
    this.buttonAdd = new UIButtonBuilder(this).width(15).x(5).text(TextFormatting.GREEN + "+").anchor(Anchor.BOTTOM | Anchor.LEFT).tooltip("Add New Title").listener(this).visible(false).build("button.add");
    // Remove button
    this.buttonDelete = new UIButtonBuilder(this).width(15).x(24).text(TextFormatting.RED + "-").anchor(Anchor.BOTTOM | Anchor.LEFT).tooltip("Remove Title").listener(this).visible(false).build("button.delete");
    this.editModeCheckbox = new UICheckBox(this);
    this.editModeCheckbox.setText(TextFormatting.WHITE + "Edit Mode");
    this.editModeCheckbox.setPosition(0, -3, Anchor.CENTER | Anchor.BOTTOM);
    this.editModeCheckbox.setChecked(false);
    this.editModeCheckbox.setName("checkbox.editmode");
    this.editModeCheckbox.setVisible(isAdmin);
    this.editModeCheckbox.register(this);
    // Close button
    final UIButton buttonClose = new UIButtonBuilder(this).width(40).anchor(Anchor.BOTTOM | Anchor.RIGHT).text(I18n.format("almura.button.close")).listener(this).build("button.close");
    this.form.add(this.listArea, this.editArea, this.playerArea, this.titleSelectionLabel, this.buttonAdd, this.buttonDelete, this.editModeCheckbox, buttonClose);
    this.addToScreen(this.form);
}
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) BasicContainer(net.malisis.core.client.gui.component.container.BasicContainer) UITextField(net.malisis.core.client.gui.component.interaction.UITextField) UICheckBox(net.malisis.core.client.gui.component.interaction.UICheckBox)

Example 23 with BasicForm

use of net.malisis.core.client.gui.component.container.BasicForm 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 24 with BasicForm

use of net.malisis.core.client.gui.component.container.BasicForm 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)

Example 25 with BasicForm

use of net.malisis.core.client.gui.component.container.BasicForm in project Almura by AlmuraDev.

the class ApplyTexturePackConfirmGui method construct.

@Override
public void construct() {
    this.guiscreenBackground = true;
    Keyboard.enableRepeatEvents(true);
    final BasicForm form = new BasicForm(this, 350, 125, "Almura Resource Loader");
    form.setZIndex(10);
    form.setClosable(false);
    form.setBackgroundAlpha(255);
    final UILabel label0 = new UILabel(this, "We noticed you're not using the preferred texture pack.");
    label0.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.0F).build());
    label0.setPosition(0, 10, Anchor.CENTER | Anchor.TOP);
    final UILabel label1 = new UILabel(this, "Do you want to apply the following texture pack?");
    label1.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(true).scale(1.0F).build());
    label1.setPosition(0, label0.getY() + 15, Anchor.CENTER | Anchor.TOP);
    final UILabel label2 = new UILabel(this, AlmuraSettings.getPreferredTexturePack());
    label2.setFontOptions(FontOptions.builder().from(FontColors.GREEN_FO).shadow(true).scale(1.0F).build());
    label2.setPosition(0, label1.getY() + 15, Anchor.CENTER | Anchor.TOP);
    final UISeparator belowAmountSeparator = new UISeparator(this);
    belowAmountSeparator.setSize(form.getWidth() - 5, 1);
    belowAmountSeparator.setPosition(0, -45, Anchor.BOTTOM | Anchor.CENTER);
    final UIButton buttonYes = new UIButtonBuilder(this).text("Yes").anchor(Anchor.BOTTOM | Anchor.CENTER).position(-20, -25).width(40).listener(this).build("button.yes");
    final UIButton buttonNo = new UIButtonBuilder(this).text("No").anchor(Anchor.BOTTOM | Anchor.CENTER).position(20, -25).width(40).listener(this).build("button.close");
    final UISeparator aboveCloseSeparator = new UISeparator(this);
    aboveCloseSeparator.setSize(form.getWidth() - 5, 1);
    aboveCloseSeparator.setPosition(0, -20, Anchor.BOTTOM | Anchor.CENTER);
    final UIButton buttonClose = new UIButtonBuilder(this).text(I18n.format("almura.button.close")).anchor(Anchor.BOTTOM | Anchor.RIGHT).position(0, 0).width(40).listener(this).build("button.close");
    form.add(buttonClose, label0, label1, label2, aboveCloseSeparator, buttonYes, buttonNo, belowAmountSeparator);
    addToScreen(form);
}
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) UISeparator(net.malisis.core.client.gui.component.decoration.UISeparator)

Aggregations

BasicForm (net.malisis.core.client.gui.component.container.BasicForm)25 UIButtonBuilder (net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder)25 UILabel (net.malisis.core.client.gui.component.decoration.UILabel)23 UIButton (net.malisis.core.client.gui.component.interaction.UIButton)17 UISeparator (net.malisis.core.client.gui.component.decoration.UISeparator)11 BasicTextBox (net.malisis.core.client.gui.component.interaction.BasicTextBox)10 UIImage (net.malisis.core.client.gui.component.decoration.UIImage)6 BasicContainer (net.malisis.core.client.gui.component.container.BasicContainer)4 UICheckBox (net.malisis.core.client.gui.component.interaction.UICheckBox)4 UITextField (net.malisis.core.client.gui.component.interaction.UITextField)4 GuiTexture (net.malisis.core.client.gui.GuiTexture)3 BasicLine (net.malisis.core.client.gui.component.decoration.BasicLine)3 ItemStack (net.minecraft.item.ItemStack)3 Subscribe (com.google.common.eventbus.Subscribe)2 DecimalFormat (java.text.DecimalFormat)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 Anchor (net.malisis.core.client.gui.Anchor)2