Search in sources :

Example 1 with UISimpleList

use of com.almuradev.almura.shared.client.ui.component.UISimpleList in project Almura by AlmuraDev.

the class SimpleAboutMenu method construct.

@SuppressWarnings({ "unchecked" })
@Override
public void construct() {
    super.construct();
    this.list = new UISimpleList(this, 125, UIComponent.INHERITED);
    this.list.setPosition(4, 0);
    this.list.setElementSpacing(4);
    this.list.setUnselect(false);
    final List<AboutListElementData> elementDataList = Lists.newArrayList();
    // Static entry
    elementDataList.add(new AboutListElementData(this.list, new UIImage(this, new GuiTexture(GuiConfig.Location.ALMURA_MAN), null), 5, 0, 23, 32, 8, AboutConfig.TITLE, AboutConfig.STORY));
    // Dynamic entry
    AboutConfig.ENTRIES.forEach(entry -> {
        Text titles = Text.EMPTY;
        for (String title : entry.titles) {
            titles = titles.toBuilder().append(Text.of("  • ", I18n.format(title)), Text.NEW_LINE).build();
        }
        elementDataList.add(new AboutListElementData(this.list, new UIImage(this, new GuiRemoteTexture(GuiConfig.Location.GENERIC_AVATAR, new ResourceLocation(Almura.ID, "textures/gui/skins/avatars/" + entry.uniqueId + ".png"), String.format(GuiConfig.Url.SKINS, entry.uniqueId, 32), 32, 32), null), 2, 0, 32, 32, 4, Text.of(entry.color, I18n.format(entry.name)), Text.of(TextColors.WHITE, I18n.format(entry.description), Text.NEW_LINE, Text.NEW_LINE, TextStyles.BOLD, I18n.format("almura.menu.about.titles"), TextStyles.RESET, TextColors.RESET, Text.NEW_LINE, titles)));
    });
    final UIButton doneButton = new UIButtonBuilder(this).text(Text.of(I18n.format("gui.done"))).size(98, 20).position(0, -15, 1).anchor(Anchor.BOTTOM | Anchor.CENTER).listener(this).build("button.done");
    this.textField = new UITextField(this, "", true);
    this.textField.setPosition(SimpleScreen.getPaddedX(this.list, 4), 0);
    this.textField.setEditable(false);
    this.textField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    this.list.setComponentFactory(AboutListElement::new);
    this.list.setElements(elementDataList);
    this.list.register(this);
    this.list.select(elementDataList.get(0));
    this.getContainer().add(this.list, this.textField);
    // SpongeForge
    final UILabel spongeForgeVersionLabel = new UILabel(this, TextFormatting.WHITE + "SpongeForge: " + ((Optional<String>) Sponge.getPlatform().asMap().get("ImplementationVersion")).orElse("dev"));
    spongeForgeVersionLabel.setPosition(4, -24, Anchor.LEFT | Anchor.BOTTOM);
    // Forge
    final PluginContainer forgeContainer = Sponge.getPluginManager().getPlugin("Forge").orElseThrow(NullPointerException::new);
    final UILabel forgeVersionLabel = new UILabel(this, TextFormatting.WHITE + "Forge: " + forgeContainer.getVersion().orElse("dev"));
    forgeVersionLabel.setPosition(4, -14, Anchor.LEFT | Anchor.BOTTOM);
    addToScreen(forgeVersionLabel);
    // Almura
    final PluginContainer almuraContainer = Sponge.getPluginManager().getPlugin("almura").orElseThrow(NullPointerException::new);
    final UILabel almuraVersionLabel = new UILabel(this, TextFormatting.WHITE + "Almura: " + almuraContainer.getVersion().orElse("dev"));
    almuraVersionLabel.setPosition(4, -4, Anchor.LEFT | Anchor.BOTTOM);
    addToScreen(almuraVersionLabel);
    addToScreen(doneButton);
    addToScreen(spongeForgeVersionLabel);
}
Also used : UILabel(net.malisis.core.client.gui.component.decoration.UILabel) PluginContainer(org.spongepowered.api.plugin.PluginContainer) Optional(java.util.Optional) UISimpleList(com.almuradev.almura.shared.client.ui.component.UISimpleList) Text(org.spongepowered.api.text.Text) UITextField(net.malisis.core.client.gui.component.interaction.UITextField) GuiRemoteTexture(com.almuradev.almura.shared.client.texture.GuiRemoteTexture) GuiTexture(net.malisis.core.client.gui.GuiTexture) UIButtonBuilder(com.almuradev.almura.shared.client.ui.component.button.UIButtonBuilder) ResourceLocation(net.minecraft.util.ResourceLocation) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) UIImage(net.malisis.core.client.gui.component.decoration.UIImage)

Aggregations

GuiRemoteTexture (com.almuradev.almura.shared.client.texture.GuiRemoteTexture)1 UISimpleList (com.almuradev.almura.shared.client.ui.component.UISimpleList)1 UIButtonBuilder (com.almuradev.almura.shared.client.ui.component.button.UIButtonBuilder)1 Optional (java.util.Optional)1 GuiTexture (net.malisis.core.client.gui.GuiTexture)1 UIImage (net.malisis.core.client.gui.component.decoration.UIImage)1 UILabel (net.malisis.core.client.gui.component.decoration.UILabel)1 UIButton (net.malisis.core.client.gui.component.interaction.UIButton)1 UITextField (net.malisis.core.client.gui.component.interaction.UITextField)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 PluginContainer (org.spongepowered.api.plugin.PluginContainer)1 Text (org.spongepowered.api.text.Text)1