use of net.minecraft.client.font.RenderableGlyph in project SpeedRunIGT by RedLime.
the class TimerDrawer method draw.
public void draw() {
if (!toggle)
return;
client.getProfiler().push("create");
MutableText igtText = getIGTText();
MutableText rtaText = getRTAText();
client.getProfiler().swap("font");
// 폰트 조정
float fontHeight = 8;
FontManagerAccessor fontManager = (FontManagerAccessor) ((MinecraftClientAccessor) client).getFontManager();
if (getTimerFont() != MinecraftClient.DEFAULT_FONT_ID && fontManager.getFontStorages().containsKey(getTimerFont())) {
rtaText.setStyle(rtaText.getStyle().withFont(getTimerFont()));
igtText.setStyle(igtText.getStyle().withFont(getTimerFont()));
fontHeight = fontHeightMap.computeIfAbsent(getTimerFont().toString(), key -> {
RenderableGlyph glyph = ((FontStorageAccessor) fontManager.getFontStorages().get(getTimerFont())).invokeRenderableGlyph('I');
return glyph.getHeight() / glyph.getOversample();
});
}
// 초기 값 조정
client.getProfiler().swap("init");
TimerElement igtTimerElement = new TimerElement();
TimerElement rtaTimerElement = new TimerElement();
rtaTimerElement.init(rtaXPos, rtaYPos, rtaScale, rtaText, rtaColor, rtaDecoration, fontHeight);
igtTimerElement.init(igtXPos, igtYPos, igtScale, igtText, igtColor, igtDecoration, fontHeight);
MatrixStack matrixStack = new MatrixStack();
// 배경 렌더
client.getProfiler().swap("background");
if (bgOpacity > 0.01f) {
Position rtaMin = new Position(rtaTimerElement.getPosition().getX() - rtaPadding, rtaTimerElement.getPosition().getY() - rtaPadding);
Position rtaMax = new Position(rtaMin.getX() + rtaTimerElement.getScaledTextWidth() + ((rtaPadding - 1) + rtaPadding), rtaMin.getY() + rtaTimerElement.getScaledTextHeight() + ((rtaPadding - 1) + rtaPadding));
Position igtMin = new Position(igtTimerElement.getPosition().getX() - igtPadding, igtTimerElement.getPosition().getY() - igtPadding);
Position igtMax = new Position(igtMin.getX() + igtTimerElement.getScaledTextWidth() + ((igtPadding - 1) + igtPadding), igtMin.getY() + igtTimerElement.getScaledTextHeight() + ((igtPadding - 1) + igtPadding));
int opacity = BackgroundHelper.ColorMixer.getArgb((int) (bgOpacity * 255), 0, 0, 0);
if (rtaMin.getX() < igtMax.getX() && rtaMin.getY() < igtMax.getY() && igtMin.getX() < rtaMax.getX() && igtMin.getY() < rtaMax.getY()) {
DrawableHelper.fill(matrixStack, Math.min(rtaMin.getX(), igtMin.getX()), Math.min(rtaMin.getY(), igtMin.getY()), Math.max(rtaMax.getX(), igtMax.getX()), Math.max(rtaMax.getY(), igtMax.getY()), opacity);
} else {
if (rtaScale != 0)
DrawableHelper.fill(matrixStack, rtaMin.getX(), rtaMin.getY(), rtaMax.getX(), rtaMax.getY(), opacity);
if (igtScale != 0)
DrawableHelper.fill(matrixStack, igtMin.getX(), igtMin.getY(), igtMax.getX(), igtMax.getY(), opacity);
}
}
// 렌더
client.getProfiler().swap("draw");
if (igtScale != 0)
igtTimerElement.draw(matrixStack, translateZ);
if (rtaScale != 0)
rtaTimerElement.draw(matrixStack, translateZ);
client.getProfiler().pop();
}
Aggregations