Search in sources :

Example 1 with GuiRemoteTexture

use of com.almuradev.almura.shared.client.texture.GuiRemoteTexture in project Almura by AlmuraDev.

the class SimpleAboutMenu method construct.

@SuppressWarnings({ "unchecked" })
@Override
public void construct() {
    super.construct();
    this.list = new BasicList<>(this, 125, UIComponent.INHERITED);
    this.list.setPosition(4, 0);
    this.list.setItemComponentSpacing(4);
    this.list.setCanDeselect(false);
    final List<AboutItemData> elementDataList = Lists.newArrayList();
    // Static entry
    elementDataList.add(new AboutItemData(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 (final String title : entry.titles) {
            titles = titles.toBuilder().append(Text.of("  • ", I18n.format(title)), Text.NEW_LINE).build();
        }
        elementDataList.add(new AboutItemData(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(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(BasicScreen.getPaddedX(this.list, 4), 0);
    this.textField.setEditable(false);
    this.textField.setFontOptions(FontOptions.builder().from(FontColors.WHITE_FO).shadow(false).build());
    this.list.setItemComponentFactory(AboutItemComponent::new);
    this.list.setItems(elementDataList);
    this.list.setSelectConsumer(i -> this.textField.setText(TextSerializers.LEGACY_FORMATTING_CODE.serialize(i.getContent())));
    this.list.setSelectedItem(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 3.1 - " + Almura.buildNumber);
    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) 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(net.malisis.core.client.gui.component.interaction.button.builder.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 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 UIButtonBuilder (net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 PluginContainer (org.spongepowered.api.plugin.PluginContainer)1 Text (org.spongepowered.api.text.Text)1