use of buildcraft.lib.gui.elem.GuiElementText in project BuildCraft by BuildCraft.
the class ElementHelpInfo method addGuiElements.
@SideOnly(Side.CLIENT)
public void addGuiElements(GuiElementContainerHelp container) {
BuildCraftGui gui = container.gui;
int y = 20;
for (String key : localeKeys) {
if (key == null) {
y += Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT + 5;
continue;
}
String localized = LocaleUtil.localize(key);
List<String> lines = StringUtilBC.splitIntoLines(localized);
for (String line : lines) {
GuiElementText elemText = new GuiElementText(gui, container.offset(0, y), line, 0);
container.add(elemText);
y += elemText.getHeight() + 5;
}
}
}
use of buildcraft.lib.gui.elem.GuiElementText in project BuildCraft by BuildCraft.
the class GuiAbstractButton method createTextElement.
public GuiElementText createTextElement(Supplier<String> text) {
FontRenderer fr = gui.mc.fontRenderer;
DoubleSupplier x = () -> -fr.getStringWidth(text.get()) / 2;
DoubleSupplier y = () -> -fr.FONT_HEIGHT / 2;
IGuiPosition pos = getCenter().offset(x, y);
return new GuiElementText(gui, pos, text, this::getColourForText);
}
use of buildcraft.lib.gui.elem.GuiElementText in project BuildCraft by BuildCraft.
the class ElementTypeText method deserialize0.
// pos: the position of the text
// text: The text to be drawn. Will be localised first, and used as a fallback
// expression: A replacement for text -- uses an expression rather than as a literal.
// colour: Default colour to be drawn
// centered: If true then the text will be centered around pos
@Override
public IGuiElement deserialize0(BuildCraftJsonGui gui, IGuiPosition parent, JsonGuiInfo info, JsonGuiElement json) {
FunctionContext ctx = createContext(json);
IGuiPosition pos = resolvePosition(json, "pos", parent, ctx);
INodeObject<String> text;
String prop;
if ((prop = json.properties.get("text")) != null) {
String localized = LocaleUtil.localize(prop);
text = new NodeConstantObject<>(String.class, localized);
} else if ((prop = json.properties.get("expression")) != null) {
try {
text = GenericExpressionCompiler.compileExpressionString(prop, ctx);
} catch (InvalidExpressionException e) {
throw new JsonSyntaxException("Invalid expression for '" + json.name + "'", e);
}
} else {
throw new JsonSyntaxException("Require either 'text' or 'expression'!");
}
int colour;
if (json.properties.containsKey("colour")) {
colour = resolveEquationInt(json, "colour", ctx);
} else {
colour = resolveEquationInt(json, "color", ctx);
}
GuiElementText element = new GuiElementText(gui, pos, text, colour);
element.setCentered("true".equals(json.properties.get("centered")));
element.setDropShadow("true".equals(json.properties.get("shadow")));
element.setForeground("true".equals(json.properties.get("foreground")));
return element;
}
Aggregations