Search in sources :

Example 1 with PopupNotification

use of com.almuradev.almura.feature.notification.type.PopupNotification in project Almura by AlmuraDev.

the class ExchangeScreen method construct.

@Override
public void construct() {
    guiscreenBackground = false;
    // Detect if screen area is large enough to display.
    if (minScreenWidth > this.resolution.getScaledWidth() || minScreenHeight > this.resolution.getScaledHeight()) {
        notificationManager.handlePopup(new PopupNotification("Exchange Error", "Screen area of: " + minScreenHeight + " x " + minScreenWidth + " required.", 5));
        this.close();
        return;
    }
    // Main Panel
    final BasicForm form = new BasicForm(this, minScreenWidth, minScreenHeight, this.getExchange().getName());
    // Search section
    final BasicContainer<?> searchContainer = new BasicContainer<>(this, 295, 322);
    searchContainer.setPosition(0, 0, Anchor.LEFT | Anchor.TOP);
    searchContainer.setColor(0);
    searchContainer.setBorder(FontColors.WHITE, 1, 185);
    searchContainer.setBackgroundAlpha(215);
    searchContainer.setPadding(3, 3);
    final UILabel itemSearchLabel = new UILabel(this, I18n.format("almura.feature.exchange.text.item_name") + ":");
    itemSearchLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).scale(1.1F).build());
    itemSearchLabel.setPosition(0, 4, Anchor.LEFT | Anchor.TOP);
    this.itemDisplayNameSearchBox = new BasicTextBox(this, "");
    this.itemDisplayNameSearchBox.setAcceptsReturn(false);
    this.itemDisplayNameSearchBox.setAcceptsTab(false);
    this.itemDisplayNameSearchBox.setTabIndex(0);
    this.itemDisplayNameSearchBox.setOnEnter((tb) -> this.search());
    this.itemDisplayNameSearchBox.setSize(145, 0);
    this.itemDisplayNameSearchBox.setPosition(itemSearchLabel.getWidth() + innerPadding, 2, Anchor.LEFT | Anchor.TOP);
    this.itemDisplayNameSearchBox.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    final UILabel sellerSearchLabel = new UILabel(this, I18n.format("almura.feature.exchange.text.seller") + ":");
    sellerSearchLabel.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).scale(1.1F).build());
    sellerSearchLabel.setPosition(itemDisplayNameSearchBox.getX() - sellerSearchLabel.getWidth() - 1, getPaddedY(itemSearchLabel, 7), Anchor.LEFT | Anchor.TOP);
    this.sellerSearchTextBox = new BasicTextBox(this, "");
    this.sellerSearchTextBox.setAcceptsReturn(false);
    this.sellerSearchTextBox.setAcceptsTab(false);
    this.sellerSearchTextBox.setTabIndex(1);
    this.sellerSearchTextBox.setOnEnter(tb -> this.search());
    this.sellerSearchTextBox.setSize(145, 0);
    this.sellerSearchTextBox.setPosition(this.itemDisplayNameSearchBox.getX(), getPaddedY(this.itemDisplayNameSearchBox, 4), Anchor.LEFT | Anchor.TOP);
    this.sellerSearchTextBox.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    // Sort combobox
    // Sort combobox
    this.comboBoxSortType = new UISelect<>(this, 78);
    this.comboBoxSortType.setOptions(Arrays.asList(FeatureSortTypes.CREATED_ASC, FeatureSortTypes.CREATED_DESC, FeatureSortTypes.PRICE_ASC, FeatureSortTypes.PRICE_DESC, FeatureSortTypes.ITEM_DISPLAY_NAME_ASC, FeatureSortTypes.ITEM_DISPLAY_NAME_DESC, ExchangeSortTypes.SELLER_NAME_ASC, ExchangeSortTypes.SELLER_NAME_DESC));
    // Because that's reasonable.
    this.comboBoxSortType.setLabelFunction(type -> type == null ? "" : type.getName());
    this.comboBoxSortType.select(FeatureSortTypes.CREATED_ASC);
    this.comboBoxSortType.setPosition(-(innerPadding + 1), 2, Anchor.RIGHT | Anchor.TOP);
    // Search button
    final UIButton buttonSearch = new UIButtonBuilder(this).width(80).anchor(Anchor.RIGHT | Anchor.TOP).position(-innerPadding, this.sellerSearchTextBox.getY() - 1).text(I18n.format("almura.feature.common.button.search")).onClick(this::search).build("button.search");
    // Separator
    final BasicContainer<?> forSaleTopLine = new BasicContainer<>(this, searchContainer.getRawWidth() - 2, 1);
    forSaleTopLine.setColor(FontColors.WHITE);
    forSaleTopLine.setBackgroundAlpha(185);
    forSaleTopLine.setPosition(0, BasicScreen.getPaddedY(this.sellerSearchTextBox, 4), Anchor.CENTER | Anchor.TOP);
    this.forSaleList = new BasicList<>(this, UIComponent.INHERITED, 254);
    this.forSaleList.setPosition(0, BasicScreen.getPaddedY(forSaleTopLine, 2));
    this.forSaleList.setItemComponentFactory(ForSaleItemComponent::new);
    this.forSaleList.setItemComponentSpacing(1);
    this.forSaleList.setSelectConsumer((i) -> this.updateControls());
    // No results label
    this.noResultsLabel = new UILabel(this, "No results found.");
    this.noResultsLabel.setPosition(0, this.forSaleList.getY() + 8, Anchor.TOP | Anchor.CENTER);
    this.noResultsLabel.setFontOptions(FontColors.GRAY_FO);
    this.noResultsLabel.setVisible(false);
    // Bottom Page Control - first button
    this.buttonFirstPage = new UIButtonBuilder(this).size(20).anchor(Anchor.LEFT | Anchor.BOTTOM).position(0, 0).text("|<").enabled(false).onClick(() -> setPage(1)).build("button.first");
    // Bottom Page Control - previous button
    this.buttonPreviousPage = new UIButtonBuilder(this).size(20).anchor(Anchor.LEFT | Anchor.BOTTOM).position(getPaddedX(this.buttonFirstPage, innerPadding), 0).text("<").enabled(false).onClick(() -> setPage(--this.currentPage)).build("button.previous");
    // Search pages label
    this.labelSearchPage = new UILabel(this, "");
    this.labelSearchPage.setPosition(0, -4, Anchor.CENTER | Anchor.BOTTOM);
    // Bottom Page Control - last button
    this.buttonLastPage = new UIButtonBuilder(this).size(20).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(0, 0).text(">|").enabled(false).onClick(() -> setPage(this.pages)).build("button.last");
    // Bottom Page Control - next button
    this.buttonNextPage = new UIButtonBuilder(this).size(20).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(getPaddedX(this.buttonLastPage, innerPadding, Anchor.RIGHT), 0).text(">").enabled(false).onClick(() -> setPage(++this.currentPage)).build("button.next");
    // Separator
    final BasicLine forSaleBottomLine = new BasicLine(this, searchContainer.getRawWidth() - 2);
    forSaleBottomLine.setPosition(0, BasicScreen.getPaddedY(this.buttonFirstPage, 2, Anchor.BOTTOM), Anchor.CENTER | Anchor.BOTTOM);
    // Add Elements of Search Area
    searchContainer.add(itemSearchLabel, this.itemDisplayNameSearchBox, sellerSearchLabel, this.sellerSearchTextBox, buttonSearch, this.comboBoxSortType, this.buttonFirstPage, this.buttonPreviousPage, this.buttonNextPage, this.buttonLastPage, this.forSaleList, this.noResultsLabel, this.labelSearchPage, forSaleTopLine, forSaleBottomLine);
    // Buy container
    final BasicContainer<?> buyContainer = new BasicContainer(this, 295, 21);
    buyContainer.setPosition(0, getPaddedY(searchContainer, innerPadding), Anchor.LEFT | Anchor.TOP);
    buyContainer.setColor(0);
    buyContainer.setBorder(FontColors.WHITE, 1, 185);
    buyContainer.setBackgroundAlpha(215);
    buyContainer.setPadding(3, 0);
    this.buttonBuyOne = new UIButtonBuilder(this).width(60).anchor(Anchor.LEFT | Anchor.MIDDLE).position(0, 0).text(I18n.format("almura.feature.common.button.buy.one")).enabled(false).onClick(() -> this.buy(1)).build("button.buy.single");
    this.buttonBuyStack = new UIButtonBuilder(this).width(60).anchor(Anchor.LEFT | Anchor.MIDDLE).position(BasicScreen.getPaddedX(this.buttonBuyOne, 10), 0).text(I18n.format("almura.feature.common.button.buy.stack", 0)).enabled(false).onClick(() -> {
        final ForSaleItem forSaleItem = this.forSaleList.getSelectedItem();
        if (forSaleItem != null) {
            this.buy(forSaleItem.asRealStack().getMaxStackSize());
        }
    }).build("button.buy.stack");
    this.buttonBuyAll = new UIButtonBuilder(this).width(50).anchor(Anchor.RIGHT | Anchor.MIDDLE).position(0, 0).text(I18n.format("almura.feature.common.button.buy.all")).enabled(false).onClick(() -> {
        final ForSaleItem forSaleItem = this.forSaleList.getSelectedItem();
        if (forSaleItem != null) {
            this.buy(forSaleItem.getQuantity());
        }
    }).build("button.buy.all");
    this.buttonBuyQuantity = new UIButtonBuilder(this).width(60).anchor(Anchor.RIGHT | Anchor.MIDDLE).position(BasicScreen.getPaddedX(this.buttonBuyAll, 10, Anchor.RIGHT), 0).text(I18n.format("almura.feature.common.button.buy.quantity")).enabled(false).onClick(() -> {
        final ForSaleItem forSaleItem = this.forSaleList.getSelectedItem();
        if (forSaleItem != null) {
            new ExchangeBuyQuantityScreen(this, this.axs, forSaleItem).display();
        }
    }).build("button.buy.quantity");
    buyContainer.add(this.buttonBuyOne, this.buttonBuyStack, this.buttonBuyQuantity, this.buttonBuyAll);
    // Listable Items section
    final BasicContainer<?> listableItemsContainer = new BasicContainer(this, 295, 345);
    listableItemsContainer.setPosition(0, 0, Anchor.RIGHT | Anchor.TOP);
    listableItemsContainer.setBorder(FontColors.WHITE, 1, 185);
    listableItemsContainer.setColor(0);
    listableItemsContainer.setBackgroundAlpha(215);
    listableItemsContainer.setPadding(3, 3);
    final UILabel listableItemsLabel = new UILabel(this, I18n.format("almura.feature.exchange.title.listable_items"));
    listableItemsLabel.setPosition(0, 2, Anchor.CENTER | Anchor.TOP);
    listableItemsLabel.setFontOptions(FontColors.WHITE_FO);
    final BasicLine listTopLine = new BasicLine(this, listableItemsContainer.getRawWidth() - 2);
    listTopLine.setPosition(0, BasicScreen.getPaddedY(listableItemsLabel, 3), Anchor.TOP | Anchor.CENTER);
    this.listItemList = new BasicList<>(this, UIComponent.INHERITED, 302);
    this.listItemList.setPosition(0, BasicScreen.getPaddedY(listTopLine, 2));
    this.listItemList.setItemComponentFactory(ListItemComponent::new);
    this.listItemList.setItemComponentSpacing(1);
    this.listItemList.setSelectConsumer((i) -> this.updateControls());
    this.buttonList = new UIButtonBuilder(this).width(40).anchor(Anchor.LEFT | Anchor.BOTTOM).position(0, 0).text(I18n.format("almura.feature.common.button.list")).enabled(false).onClick(this::list).build("button.list");
    this.labelLimit = new UILabel(this, "");
    this.labelLimit.setPosition(0, -2, Anchor.CENTER | Anchor.BOTTOM);
    final UIButton buttonOffer = new UIButtonBuilder(this).width(30).anchor(Anchor.RIGHT | Anchor.BOTTOM).position(0, 0).text(TextFormatting.DARK_GREEN + "+" + TextFormatting.GRAY + "/" + TextFormatting.RED + "-").enabled(true).onClick(() -> exchangeManager.requestExchangeSpecificOfferGui(this.axs.getId())).build("button.offer");
    // Separator
    final BasicLine listBottomLine = new BasicLine(this, searchContainer.getRawWidth() - 2);
    listBottomLine.setPosition(0, BasicScreen.getPaddedY(this.buttonList, 2, Anchor.BOTTOM), Anchor.CENTER | Anchor.BOTTOM);
    listableItemsContainer.add(listableItemsLabel, listTopLine, this.listItemList, this.buttonList, this.labelLimit, buttonOffer, listBottomLine);
    form.add(searchContainer, buyContainer, listableItemsContainer);
    addToScreen(form);
    this.itemDisplayNameSearchBox.focus();
}
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) ForSaleItem(com.almuradev.almura.feature.exchange.listing.ForSaleItem) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) BasicContainer(net.malisis.core.client.gui.component.container.BasicContainer) BasicTextBox(net.malisis.core.client.gui.component.interaction.BasicTextBox) PopupNotification(com.almuradev.almura.feature.notification.type.PopupNotification)

Example 2 with PopupNotification

use of com.almuradev.almura.feature.notification.type.PopupNotification in project Almura by AlmuraDev.

the class UINotificationPanel method displayPopup.

public void displayPopup() {
    final PopupNotification notification = manager.getCurrent();
    if (notification != null) {
        this.notificationTitle.setText(this.manager.getCurrent().getTitle());
        this.notificationLabel.setText(this.manager.getCurrent().getMessage());
    }
}
Also used : PopupNotification(com.almuradev.almura.feature.notification.type.PopupNotification)

Example 3 with PopupNotification

use of com.almuradev.almura.feature.notification.type.PopupNotification in project Almura by AlmuraDev.

the class ManageTitlesGUI method onUIButtonClickEvent.

@Subscribe
public void onUIButtonClickEvent(UIButton.ClickEvent event) {
    final String colorCode = this.colorSelector.getSelectedOption().getLabel().substring(0, 2);
    final UITextField.CursorPosition cursorPos = this.contentField.getCursorPosition();
    switch(event.getComponent().getName().toLowerCase()) {
        case "button.color":
            this.contentField.addText(colorCode);
            this.formatContent(this.formattedCheckbox.isChecked());
            this.contentField.setCursorPosition(cursorPos.getXOffset(), cursorPos.getYOffset());
            this.contentField.setFocused(true);
            break;
        case "button.apply":
            notificationManager.handlePopup(new PopupNotification("Title", "Setting Title on server...", 2));
            titleManager.setTitleContentForDisplay(null);
            titleManager.requestSelectedTitle(this.titleList.getSelectedItem());
            this.close();
            break;
        case "button.remove":
            notificationManager.handlePopup(new PopupNotification("Title", "Removing Title on server...", 2));
            titleManager.setTitleContentForDisplay(null);
            titleManager.requestSelectedTitle(null);
            this.close();
            break;
        case "button.add":
            this.modeNameLabel.setText("Add New Title");
            // Clear Fields & Unlock
            this.idField.setText("");
            this.idField.setEditable(true);
            this.idField.setEnabled(true);
            this.permissionField.setText("almura.title.");
            this.permissionField.setEditable(true);
            this.permissionField.setEnabled(true);
            this.contentField.setText("");
            this.contentField.setEditable(true);
            this.contentField.setEnabled(true);
            this.buttonColor.setEnabled(true);
            this.colorSelector.setEnabled(true);
            this.formattedCheckbox.setEnabled(true);
            this.hiddenCheckbox.setEnabled(true);
            this.hiddenCheckbox.setChecked(false);
            this.mode = TitleModifyType.ADD;
            this.modeNameLabel.setVisible(true);
            this.buttonDelete.setEnabled(false);
            break;
        case "button.delete":
            this.mode = TitleModifyType.DELETE;
            notificationManager.handlePopup(new PopupNotification("Title Manager", "Removing selected title", 2));
            if (this.idField.getText().toLowerCase().trim().equalsIgnoreCase(titleManager.getSelectedTitleFor(this.mc.player.getUniqueID()).getId())) {
                // remove the title as the selected title from the user if its the one begin deleted.
                titleManager.requestSelectedTitle(null);
            }
            titleManager.setTitleContentForDisplay(null);
            titleManager.deleteTitle(this.idField.getText().toLowerCase().trim());
            this.lockForm();
            break;
        case "button.save":
            switch(this.mode) {
                case ADD:
                    notificationManager.handlePopup(new PopupNotification("Title Manager", "Adding new Title", 2));
                    titleManager.addTitle(this.idField.getText().toLowerCase().trim(), this.permissionField.getText().toLowerCase().trim(), this.contentField.getText().trim(), this.hiddenCheckbox.isChecked());
                    break;
                case MODIFY:
                    notificationManager.handlePopup(new PopupNotification("Title Manager", "Saving Title Changes", 2));
                    titleManager.modifyTitle(this.idField.getText().toLowerCase().trim(), this.permissionField.getText().toLowerCase().trim(), this.contentField.getText().trim(), this.hiddenCheckbox.isChecked());
                    break;
            }
            this.lockForm();
            break;
        case "button.close":
            titleManager.setTitleContentForDisplay(null);
            this.close();
            break;
    }
}
Also used : UITextField(net.malisis.core.client.gui.component.interaction.UITextField) PopupNotification(com.almuradev.almura.feature.notification.type.PopupNotification) Subscribe(com.google.common.eventbus.Subscribe)

Example 4 with PopupNotification

use of com.almuradev.almura.feature.notification.type.PopupNotification in project Almura by AlmuraDev.

the class NicknameGUI method onUIButtonClickEvent.

@Subscribe
public void onUIButtonClickEvent(UIButton.ClickEvent event) {
    switch(event.getComponent().getName().toLowerCase()) {
        case "button.color":
            final String colorCode = this.colorSelector.getSelectedOption().getLabel().substring(0, 2);
            this.nicknameTextbox.addText(colorCode);
            break;
        case "button.reset":
            this.nicknameTextbox.setText(this.originalNickname);
            break;
        case "button.remove":
            // Stop automatic update of name based on textbox
            this.update = false;
            notificationManager.handlePopup(new PopupNotification("Nickname", "Removing Nickname from server....", 2));
            nickManager.requestNicknameChange(null);
            this.close();
            break;
        case "button.apply":
            final Text validateText = Text.of(this.nicknameTextbox.getText());
            if (this.nicknameTextbox.getText().isEmpty()) {
                notificationManager.handlePopup(new PopupNotification("Error", "Cannot have blank title!", 5));
                break;
            }
            if (validateText.toPlain().length() <= 1) {
                notificationManager.handlePopup(new PopupNotification("Error", "Cannot have nickname < 3 characters!", 5));
                break;
            }
            if (validateText.toPlain().length() > 20) {
                notificationManager.handlePopup(new PopupNotification("Error", "Cannot have nickname > 20 characters!", 5));
                break;
            }
            if (!NickUtil.nickNameRegex.matcher(validateText.toPlain()).matches()) {
                notificationManager.handlePopup(new PopupNotification("Error", "Invalid Character in Nickname!", 5));
                break;
            }
            // Stop automatic update of name based on textbox
            this.update = false;
            notificationManager.handlePopup(new PopupNotification("Nickname", "Updating Nickname on server....", 2));
            nickManager.requestNicknameChange(this.nicknameTextbox.getText().trim());
            this.close();
            break;
        case "button.close":
            // Stop automatic update of name based on textbox
            this.update = false;
            // Revert nickname unless player hits apply
            this.setRendererName(this.entityPlayer, this.originalNickname);
            this.close();
            break;
    }
}
Also used : Text(org.spongepowered.api.text.Text) PopupNotification(com.almuradev.almura.feature.notification.type.PopupNotification) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

PopupNotification (com.almuradev.almura.feature.notification.type.PopupNotification)4 Subscribe (com.google.common.eventbus.Subscribe)2 ForSaleItem (com.almuradev.almura.feature.exchange.listing.ForSaleItem)1 BasicContainer (net.malisis.core.client.gui.component.container.BasicContainer)1 BasicForm (net.malisis.core.client.gui.component.container.BasicForm)1 BasicLine (net.malisis.core.client.gui.component.decoration.BasicLine)1 UILabel (net.malisis.core.client.gui.component.decoration.UILabel)1 BasicTextBox (net.malisis.core.client.gui.component.interaction.BasicTextBox)1 UIButton (net.malisis.core.client.gui.component.interaction.UIButton)1 UITextField (net.malisis.core.client.gui.component.interaction.UITextField)1 UIButtonBuilder (net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder)1 Text (org.spongepowered.api.text.Text)1