Search in sources :

Example 1 with GuiElementHelper

use of forestry.core.gui.elements.GuiElementHelper in project ForestryMC by ForestryMC.

the class WidgetDatabaseScreen method update.

private void update() {
    // reset list and layout helper
    scrollable.clear();
    scrollBar.setVisible(false);
    scrollable.updateVisibleElements(0);
    layoutHelper = new GuiElementHelper(scrollable);
    if (state == DatabaseScreenLogic.ScreenState.SUCCESS) {
        IDatabaseTab selectedTab = logic.selectedTab;
        selectedTab.createElements(layoutHelper, logic.individual, logic.itemStack);
        int invisibleElements = scrollable.getInvisibleElementCount();
        if (invisibleElements > 0) {
            scrollBar.setParameters(this, 0, invisibleElements, 1);
            scrollBar.setVisible(true);
        // scrollBar.setValue(0);
        } else {
            scrollBar.setValue(0);
        }
        scrollable.updateVisibleElements(scrollBar.getValue());
    } else {
        GuiElementHelper layoutHelper = new GuiElementHelper(scrollable);
        FontRenderer fontRenderer = manager.gui.getFontRenderer();
        String key = "for.gui.portablealyzer.help";
        if (state == DatabaseScreenLogic.ScreenState.NO_PLUGIN) {
            key = "for.gui.database.support";
        }
        List<String> lines = fontRenderer.listFormattedStringToWidth(Translator.translateToLocal(key), width - 10);
        for (String text : lines) {
            layoutHelper.addText(2, text, -1);
        }
        scrollable.updateVisibleElements(0);
    }
}
Also used : GuiElementHelper(forestry.core.gui.elements.GuiElementHelper) FontRenderer(net.minecraft.client.gui.FontRenderer) IDatabaseTab(forestry.api.genetics.IDatabaseTab)

Aggregations

IDatabaseTab (forestry.api.genetics.IDatabaseTab)1 GuiElementHelper (forestry.core.gui.elements.GuiElementHelper)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1