Search in sources :

Example 1 with Element

use of net.minecraft.client.gui.Element in project sodium-fabric by CaffeineMC.

the class SodiumOptionsGUI method rebuildGUI.

private void rebuildGUI() {
    this.controls.clear();
    this.children.clear();
    this.drawable.clear();
    if (this.currentPage == null) {
        if (this.pages.isEmpty()) {
            throw new IllegalStateException("No pages are available?!");
        }
        // Just use the first page for now
        this.currentPage = this.pages.get(0);
    }
    this.rebuildGUIPages();
    this.rebuildGUIOptions();
    this.applyButton = new FlatButtonWidget(new Rect2i(10, this.height - 30, 80, 20), "Apply", this::applyChanges);
    this.closeButton = new FlatButtonWidget(new Rect2i(96, this.height - 30, 80, 20), "Close", this::popScreen);
    this.children.add(this.applyButton);
    this.children.add(this.closeButton);
    this.resetButton = new FlatButtonWidget(new Rect2i(this.width - 96, this.height - 30, 80, 20), "Reset", this::resetChanges);
    this.children.add(this.resetButton);
    for (Element element : this.children) {
        if (element instanceof Drawable) {
            this.drawable.add((Drawable) element);
        }
    }
}
Also used : Rect2i(net.minecraft.client.util.Rect2i) ControlElement(me.jellysquid.mods.sodium.client.gui.options.control.ControlElement) Element(net.minecraft.client.gui.Element) Drawable(net.minecraft.client.gui.Drawable) FlatButtonWidget(me.jellysquid.mods.sodium.client.gui.widgets.FlatButtonWidget)

Example 2 with Element

use of net.minecraft.client.gui.Element in project SpeedRunIGT by RedLime.

the class SpeedRunOptionScreen method getToolTip.

public ArrayList<Text> getToolTip(int mouseX, int mouseY) {
    ArrayList<Text> tooltipList = new ArrayList<>();
    Optional<Element> e = buttonListWidget.hoveredElement(mouseX, mouseY);
    if (e.isPresent()) {
        Element element = e.get();
        if (element instanceof ButtonScrollListWidget.Entry) {
            ButtonScrollListWidget.Entry entry = (ButtonScrollListWidget.Entry) element;
            AbstractButtonWidget buttonWidget = entry.getButtonWidget();
            if (tooltips.containsKey(buttonWidget)) {
                String text = tooltips.get(buttonWidget).get();
                for (String s : text.split("\n")) {
                    tooltipList.add(new LiteralText(s));
                }
                return tooltipList;
            }
        }
    }
    if (SpeedRunIGTInfoScreen.UPDATE_STATUS == SpeedRunIGTInfoScreen.UpdateStatus.OUTDATED) {
        tooltipList.add(new TranslatableText("speedrunigt.message.update_found"));
    }
    return tooltipList;
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Element(net.minecraft.client.gui.Element) LiteralText(net.minecraft.text.LiteralText) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text) AbstractButtonWidget(net.minecraft.client.gui.widget.AbstractButtonWidget) LiteralText(net.minecraft.text.LiteralText)

Aggregations

Element (net.minecraft.client.gui.Element)2 ControlElement (me.jellysquid.mods.sodium.client.gui.options.control.ControlElement)1 FlatButtonWidget (me.jellysquid.mods.sodium.client.gui.widgets.FlatButtonWidget)1 Drawable (net.minecraft.client.gui.Drawable)1 AbstractButtonWidget (net.minecraft.client.gui.widget.AbstractButtonWidget)1 Rect2i (net.minecraft.client.util.Rect2i)1 LiteralText (net.minecraft.text.LiteralText)1 Text (net.minecraft.text.Text)1 TranslatableText (net.minecraft.text.TranslatableText)1