Search in sources :

Example 11 with UIButton

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

the class PanoramicMainMenu method construct.

@SuppressWarnings("deprecation")
@Override
public void construct() {
    final UIBackgroundContainer container = new UIBackgroundContainer(this);
    container.setBackgroundAlpha(0);
    container.setPosition(0, -10, Anchor.MIDDLE | Anchor.CENTER);
    container.setSize(GuiConfig.Button.WIDTH_LONG, 205);
    // Almura header
    final UIImage almuraHeader = new UIImage(this, new GuiTexture(GuiConfig.Location.ALMURA_LOGO), null);
    almuraHeader.setSize(60, 99);
    almuraHeader.setPosition(0, 0, Anchor.TOP | Anchor.CENTER);
    this.buttonContainer = new UIBackgroundContainer(this, GuiConfig.Button.WIDTH_LONG + PADDING, (GuiConfig.Button.HEIGHT * 4) + (PADDING * 3));
    this.buttonContainer.setPosition(0, SimpleScreen.getPaddedY(almuraHeader, 10), Anchor.TOP | Anchor.CENTER);
    this.buttonContainer.setBackgroundAlpha(0);
    final UIButton singleplayerButton = new UIButtonBuilder(this).container(this.buttonContainer).text(Text.of(I18n.format("menu.singleplayer"))).size(GuiConfig.Button.WIDTH_LONG, GuiConfig.Button.HEIGHT).position(0, 0).anchor(Anchor.TOP | Anchor.CENTER).listener(this).build("button.singleplayer");
    final UIButton multiplayerButton = new UIButtonBuilder(this).container(this.buttonContainer).text(Text.of(I18n.format("menu.multiplayer"))).size(GuiConfig.Button.WIDTH_LONG, GuiConfig.Button.HEIGHT).position(0, SimpleScreen.getPaddedY(singleplayerButton, PADDING)).anchor(Anchor.TOP | Anchor.CENTER).listener(this).build("button.multiplayer");
    final UIButton optionsButton = new UIButtonBuilder(this).container(this.buttonContainer).text(Text.of(I18n.format("options.title"))).size(GuiConfig.Button.WIDTH_TINY, GuiConfig.Button.HEIGHT).position(-68, SimpleScreen.getPaddedY(multiplayerButton, PADDING)).anchor(Anchor.TOP | Anchor.CENTER).listener(this).build("button.options");
    final UIButton modsButton = new UIButtonBuilder(this).container(this.buttonContainer).text(Text.of(I18n.format("almura.menu_button.mods"))).size(GuiConfig.Button.WIDTH_TINY, GuiConfig.Button.HEIGHT).position(SimpleScreen.getPaddedX(optionsButton, PADDING), SimpleScreen.getPaddedY(multiplayerButton, PADDING)).anchor(Anchor.TOP | Anchor.CENTER).listener(this).build("button.mods");
    final UIButton aboutButton = new UIButtonBuilder(this).container(this.buttonContainer).text(Text.of(I18n.format("almura.menu_button.about"))).size(GuiConfig.Button.WIDTH_TINY, GuiConfig.Button.HEIGHT).position(SimpleScreen.getPaddedX(modsButton, PADDING), SimpleScreen.getPaddedY(multiplayerButton, PADDING)).anchor(Anchor.TOP | Anchor.CENTER).listener(this).build("button.about");
    final UIButton quitButton = new UIButtonBuilder(this).container(this.buttonContainer).text(Text.of(I18n.format("almura.menu_button.quit"))).fro(FontOptions.builder().from(FontColors.RED_FO).shadow(true).build()).hoverFro(FontOptions.builder().color(Color.ofRgb(255, 89, 89).getRgb()).shadow(true).build()).size(GuiConfig.Button.WIDTH_LONG, GuiConfig.Button.HEIGHT).position(singleplayerButton.getX(), SimpleScreen.getPaddedY(optionsButton, PADDING)).anchor(Anchor.TOP | Anchor.CENTER).listener(this).build("button.quit");
    final UIButton forumsButton = new UIButtonBuilder(this).container(this.buttonContainer).icon(GuiConfig.Icon.ENJIN).size(GuiConfig.Button.WIDTH_ICON, GuiConfig.Button.HEIGHT_ICON).position(-PADDING, -PADDING).anchor(Anchor.BOTTOM | Anchor.RIGHT).listener(this).tooltip(Text.of(I18n.format("almura.menu_button.forums"))).build("button.forums");
    final UIButton issuesButton = new UIButtonBuilder(this).container(this.buttonContainer).icon(GuiConfig.Icon.FA_GITHUB).size(GuiConfig.Button.WIDTH_ICON, GuiConfig.Button.HEIGHT_ICON).position(SimpleScreen.getPaddedX(forumsButton, PADDING, Anchor.RIGHT), forumsButton.getY()).anchor(Anchor.BOTTOM | Anchor.RIGHT).listener(this).tooltip(Text.of(I18n.format(I18n.format("almura.menu_button.issues")))).build("button.issues");
    final UIButton shopButton = new UIButtonBuilder(this).container(this.buttonContainer).icon(GuiConfig.Icon.FA_SHOPPING_BAG).size(GuiConfig.Button.WIDTH_ICON, GuiConfig.Button.HEIGHT_ICON).position(SimpleScreen.getPaddedX(issuesButton, PADDING, Anchor.RIGHT), issuesButton.getY()).anchor(Anchor.BOTTOM | Anchor.RIGHT).listener(this).tooltip(Text.of(I18n.format("almura.menu_button.shop"))).build("button.shop");
    final UILabel trademarkLabel = new UILabel(this, TextFormatting.YELLOW + I18n.format("almura.menu.main.trademark"));
    trademarkLabel.setPosition(PADDING, -PADDING, Anchor.BOTTOM | Anchor.LEFT);
    final UILabel copyrightLabel = new UILabel(this, TextFormatting.YELLOW + I18n.format("almura.menu.main.copyright"));
    copyrightLabel.setPosition(trademarkLabel.getX(), SimpleScreen.getPaddedY(trademarkLabel, PADDING, Anchor.BOTTOM), trademarkLabel.getAnchor());
    container.add(almuraHeader, this.buttonContainer);
    // Disable escape key press
    registerKeyListener((keyChar, keyCode) -> keyCode == Keyboard.KEY_ESCAPE);
    // Add content to screen
    addToScreen(container);
    addToScreen(trademarkLabel);
    addToScreen(copyrightLabel);
    addToScreen(shopButton);
    addToScreen(forumsButton);
    addToScreen(issuesButton);
    // OpenGL Warning
    if (!GLContext.getCapabilities().OpenGL20 && !OpenGlHelper.areShadersSupported()) {
        final UILabel glWarning1 = new UILabel(this, TextSerializers.LEGACY_FORMATTING_CODE.serialize(Text.of(TextStyles.BOLD, TextColors.DARK_RED, I18n.format("almura.menu.main.opengl.0"))));
        glWarning1.setPosition(2, 2, Anchor.TOP | Anchor.LEFT);
        final UILabel glWarning2 = new UILabel(this, TextSerializers.LEGACY_FORMATTING_CODE.serialize(Text.of(TextStyles.BOLD, TextColors.DARK_RED, I18n.format("almura.menu.main.opengl.1"))));
        glWarning2.setPosition(2, SimpleScreen.getPaddedY(glWarning1, 2), Anchor.TOP | Anchor.LEFT);
        addToScreen(glWarning1);
        addToScreen(glWarning2);
    }
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) GuiTexture(net.malisis.core.client.gui.GuiTexture) UIButtonBuilder(com.almuradev.almura.shared.client.ui.component.button.UIButtonBuilder) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) UIImage(net.malisis.core.client.gui.component.decoration.UIImage) UIBackgroundContainer(net.malisis.core.client.gui.component.container.UIBackgroundContainer)

Example 12 with UIButton

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

the class UIButtonBuilder method build.

@SuppressWarnings({ "deprecation", "unchecked" })
public UIButton build(String id) {
    checkNotNull(id);
    final UIButton button = new UIButton(this.gui);
    button.setPosition(this.x, this.y);
    button.setName(id);
    if (this.text != null) {
        button.setText(TextSerializers.LEGACY_FORMATTING_CODE.serialize(this.text));
    }
    if (this.image != null) {
        button.setImage(this.image);
    }
    if (this.tooltip != null) {
        button.setTooltip(this.tooltip);
    }
    if (this.width != 0) {
        button.setSize(this.width, button.getHeight());
    }
    if (this.height != 0) {
        button.setSize(button.getWidth(), this.height);
    }
    if (this.anchor != 0) {
        button.setAnchor(this.anchor);
    }
    if (this.object != null) {
        button.register(this.object);
    }
    if (this.fro != null) {
        button.setFontOptions(this.fro);
    }
    if (this.hoverFro != null) {
        button.setHoveredFontOptions(this.hoverFro);
    }
    if (this.font != null) {
        button.setFont(this.font);
    }
    if (this.container != null) {
        this.container.add(button);
    }
    if (this.onClickRunnable != null) {
        button.onClick(this.onClickRunnable);
    }
    button.setEnabled(this.enabled);
    button.setVisible(this.visible);
    button.setZIndex(this.z);
    return button;
}
Also used : UIButton(net.malisis.core.client.gui.component.interaction.UIButton)

Example 13 with UIButton

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

the class UIMessageBox method construct.

private void construct(MalisisGui gui) {
    setTopPadding(topPadding);
    setBottomPadding(bottomPadding);
    if (!this.message.isEmpty()) {
        final UILabel messageLabel = new UILabel(gui, this.message, true);
        messageLabel.setSize(UIComponent.INHERITED, UIComponent.INHERITED);
        final UISlimScrollbar scrollbar = new UISlimScrollbar(gui, messageLabel, UIScrollBar.Type.VERTICAL);
        scrollbar.setAutoHide(true);
        add(messageLabel.setAnchor(Anchor.CENTER | Anchor.MIDDLE));
    }
    final UIBackgroundContainer buttonContainer = new UIBackgroundContainer(gui);
    final List<UIButton> buttons = new ArrayList<>();
    switch(this.messageBoxButtons) {
        case OK:
            buttons.add(buildButton(gui, "button.ok"));
            break;
        case OK_CANCEL:
            buttons.add(buildButton(gui, "button.ok"));
            buttons.add(buildButton(gui, "button.cancel"));
            break;
        case YES_NO:
            buttons.add(buildButton(gui, "button.yes"));
            buttons.add(buildButton(gui, "button.no"));
            break;
        case YES_NO_CANCEL:
            buttons.add(buildButton(gui, "button.yes"));
            buttons.add(buildButton(gui, "button.no"));
            buttons.add(buildButton(gui, "button.cancel"));
            break;
        case CLOSE:
            buttons.add(buildButton(gui, "button.close"));
    }
    int width = 0;
    int x = 0;
    for (UIButton button : buttons) {
        buttonContainer.add(button.setPosition(x, 0));
        x += button.getWidth() + buttonPadding;
        width += button.getWidth();
    }
    width += buttonPadding * (buttons.size() - 1);
    buttonContainer.setSize(width, GuiConfig.Button.HEIGHT);
    buttonContainer.setPosition(0, 5, Anchor.BOTTOM | Anchor.RIGHT);
    buttonContainer.setBackgroundAlpha(0);
    add(buttonContainer);
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) UISlimScrollbar(net.malisis.core.client.gui.component.control.UISlimScrollbar) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) ArrayList(java.util.ArrayList) UIBackgroundContainer(net.malisis.core.client.gui.component.container.UIBackgroundContainer)

Aggregations

UIButton (net.malisis.core.client.gui.component.interaction.UIButton)13 UIButtonBuilder (com.almuradev.almura.shared.client.ui.component.button.UIButtonBuilder)10 UILabel (net.malisis.core.client.gui.component.decoration.UILabel)10 UIBackgroundContainer (net.malisis.core.client.gui.component.container.UIBackgroundContainer)6 UIImage (net.malisis.core.client.gui.component.decoration.UIImage)5 UITextField (net.malisis.core.client.gui.component.interaction.UITextField)5 GuiTexture (net.malisis.core.client.gui.GuiTexture)4 UIForm (com.almuradev.almura.shared.client.ui.component.UIForm)3 UIFormContainer (com.almuradev.almura.shared.client.ui.component.UIFormContainer)3 UISlimScrollbar (net.malisis.core.client.gui.component.control.UISlimScrollbar)2 ClientCategory (com.almuradev.almura.core.client.config.ClientCategory)1 PageListEntry (com.almuradev.almura.feature.guide.PageListEntry)1 GuiRemoteTexture (com.almuradev.almura.shared.client.texture.GuiRemoteTexture)1 UISimpleList (com.almuradev.almura.shared.client.ui.component.UISimpleList)1 UISliderBuilder (com.almuradev.almura.shared.client.ui.component.slider.UISliderBuilder)1 ArrayList (java.util.ArrayList)1 Optional (java.util.Optional)1 UISlot (net.malisis.core.client.gui.component.UISlot)1 UISeparator (net.malisis.core.client.gui.component.decoration.UISeparator)1 UICheckBox (net.malisis.core.client.gui.component.interaction.UICheckBox)1