Search in sources :

Example 1 with PageListEntry

use of com.almuradev.almura.feature.guide.PageListEntry in project Almura by AlmuraDev.

the class SimplePageView method construct.

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

Example 2 with PageListEntry

use of com.almuradev.almura.feature.guide.PageListEntry in project Almura by AlmuraDev.

the class ClientboundPageListingsPacket method readFrom.

@Override
public void readFrom(ChannelBuf buf) {
    final int count = buf.readInteger();
    for (int i = 0; i < count; i++) {
        final String id = buf.readString();
        final String name = buf.readString();
        this.pageEntries.add(new PageListEntry(id, name));
    }
    this.shouldSwitchToPage = buf.readBoolean();
    if (this.shouldSwitchToPage) {
        this.switchToPageId = buf.readString();
    }
}
Also used : PageListEntry(com.almuradev.almura.feature.guide.PageListEntry)

Aggregations

PageListEntry (com.almuradev.almura.feature.guide.PageListEntry)2 UIFormContainer (com.almuradev.almura.shared.client.ui.component.UIFormContainer)1 UIButtonBuilder (com.almuradev.almura.shared.client.ui.component.button.UIButtonBuilder)1 UIButton (net.malisis.core.client.gui.component.interaction.UIButton)1 UITextField (net.malisis.core.client.gui.component.interaction.UITextField)1