Search in sources :

Example 1 with UnitDisplay

use of com.builtbroken.jlib.data.science.units.UnitDisplay in project Engine by VoltzEngine-Project.

the class GuiContainerBase method renderUniversalDisplay.

// TODO update and docs
public void renderUniversalDisplay(int x, int y, double energy, double maxEnergy, int mouseX, int mouseY, Unit unit, boolean symbol) {
    String displaySuffix = "";
    if (unit == Unit.WATT) {
        displaySuffix = "/s";
    }
    String display = new UnitDisplay(unit, energy).symbol(symbol) + "/" + new UnitDisplay(unit, maxEnergy).symbol(symbol);
    // TODO: Check if this rect works.
    if (new Rectangle(x, y, x + display.length() * 5, y + 9).isWithin(new Point(mouseX, mouseY))) {
        if (Mouse.isButtonDown(0) && this.lastChangeFrameTime <= 0) {
            energyType = (energyType + 1) % 4;
            this.lastChangeFrameTime = 60;
        } else {
            this.drawTooltip(mouseX - this.guiLeft, mouseY - this.guiTop + 10, "Click to change unit.");
        }
    }
    this.lastChangeFrameTime--;
    fontRendererObj.drawString(display, x, y, 4210752);
}
Also used : Rectangle(com.builtbroken.mc.lib.transform.region.Rectangle) UnitDisplay(com.builtbroken.jlib.data.science.units.UnitDisplay) Point(com.builtbroken.mc.lib.transform.vector.Point)

Aggregations

UnitDisplay (com.builtbroken.jlib.data.science.units.UnitDisplay)1 Rectangle (com.builtbroken.mc.lib.transform.region.Rectangle)1 Point (com.builtbroken.mc.lib.transform.vector.Point)1