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