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);
}
}
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;
}
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);
}
Aggregations