Search in sources :

Example 1 with Rectangle

use of icbm.classic.lib.transform.region.Rectangle in project ICBM-Classic by BuiltBrokenModding.

the class GuiContainerBase method drawGuiContainerForegroundLayer.

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    super.drawGuiContainerForegroundLayer(mouseX, mouseY);
    for (Entry<Rectangle, String> entry : this.tooltips.entrySet()) {
        if (entry.getKey().isWithin(new Point(mouseX - this.guiLeft, mouseY - this.guiTop))) {
            this.tooltip = entry.getValue();
            break;
        }
    }
    if (this.tooltip != null && this.tooltip != "") {
        java.util.List<String> lines = LanguageUtility.splitByLine(tooltip);
        // TODO find a way to not have to convert to array to improve render time
        this.drawTooltip(mouseX - this.guiLeft, mouseY - this.guiTop, lines.toArray(new String[lines.size()]));
    }
    this.tooltip = "";
}
Also used : Rectangle(icbm.classic.lib.transform.region.Rectangle) Point(icbm.classic.lib.transform.vector.Point)

Example 2 with Rectangle

use of icbm.classic.lib.transform.region.Rectangle in project ICBM-Classic by BuiltBrokenModding.

the class GuiRadarStation method drawGuiContainerBackgroundLayer.

/**
 * Draw the background layer for the GuiContainer (everything behind the items)
 */
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
    drawDefaultBackground();
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    this.containerPosX = (this.width - this.xSize) / 2;
    this.containerPosY = (this.height - this.ySize) / 2;
    this.drawTexturedModalRect(containerPosX, containerPosY, 0, 0, this.xSize, this.ySize);
    this.radarCenter = new Point(this.containerPosX + this.xSize / 3 - 10, this.containerPosY + this.ySize / 2 + 4);
    this.radarMapRadius = TileRadarStation.MAX_DETECTION_RANGE / 71f;
    this.info = "";
    this.info2 = "";
    if (this.tileEntity.hasPower()) {
        int range = 4;
        for (Pos pos : tileEntity.guiDrawPoints) {
            final RadarObjectType type = RadarObjectType.get(pos.zi());
            final double x = pos.x();
            final double z = pos.y();
            Point position = new Point(radarCenter.x() + (x - this.tileEntity.getPos().getX()) / this.radarMapRadius, radarCenter.y() - (z - this.tileEntity.getPos().getZ()) / this.radarMapRadius);
            switch(type) {
                case MISSILE:
                    FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_YELLOW_DOT);
                    break;
                case MISSILE_IMPACT:
                    FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_RED_DOT);
                    break;
                case OTHER:
                default:
                    FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_WHITE_DOT);
                    break;
            }
            this.drawTexturedModalRect(position.xi(), position.yi(), 0, 0, 2, 2);
            // Hover Detection
            Point minPosition = position.add(-range);
            Point maxPosition = position.add(range);
            if (new Rectangle(minPosition, maxPosition).isWithin(this.mousePosition)) {
                if (type == RadarObjectType.OTHER) {
                    this.info = String.format(LanguageUtility.getLocal("gui.misc.object"), (int) x, (int) z);
                } else {
                    this.info = (type == RadarObjectType.MISSILE ? "\u00a76" : "\u00a74") + String.format(LanguageUtility.getLocal("gui.misc.missile"), (int) x, (int) z);
                }
            }
        }
    }
    // Draw energy bar
    if (tileEntity.getEnergy() > 0) {
        float energyScale = tileEntity.getEnergy() / (float) tileEntity.getEnergyBufferSize();
        final int textureWidth = 8;
        final int textureHeight = 142 / 2;
        final int height = (int) Math.min(textureHeight, Math.floor(textureHeight * energyScale));
        this.drawTexturedModalRect(containerPosX + 248, containerPosY + 65 + (textureHeight - height), 0, (332 / 2) + textureHeight - height, textureWidth, height);
    }
}
Also used : Pos(icbm.classic.lib.transform.vector.Pos) Rectangle(icbm.classic.lib.transform.region.Rectangle) Point(icbm.classic.lib.transform.vector.Point) Point(icbm.classic.lib.transform.vector.Point)

Aggregations

Rectangle (icbm.classic.lib.transform.region.Rectangle)2 Point (icbm.classic.lib.transform.vector.Point)2 Pos (icbm.classic.lib.transform.vector.Pos)1