Add option for whether to draw a shadow of string to GuiRenderer
This commit is contained in:
@@ -58,4 +58,12 @@ public interface GuiRenderer {
|
||||
|
||||
int drawCenteredString(int x, int y, ReadableColor color, String text);
|
||||
|
||||
int drawString(int x, int y, int color, String text, boolean shadow);
|
||||
|
||||
int drawString(int x, int y, ReadableColor color, String text, boolean shadow);
|
||||
|
||||
int drawCenteredString(int x, int y, int color, String text, boolean shadow);
|
||||
|
||||
int drawCenteredString(int x, int y, ReadableColor color, String text, boolean shadow);
|
||||
|
||||
}
|
||||
|
||||
@@ -121,8 +121,7 @@ public class MinecraftGuiRenderer implements GuiRenderer {
|
||||
|
||||
@Override
|
||||
public int drawString(int x, int y, int color, String text) {
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
|
||||
return fontRenderer.drawStringWithShadow(text, x, y, color);
|
||||
return drawString(x, y, color, text, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,8 +131,7 @@ public class MinecraftGuiRenderer implements GuiRenderer {
|
||||
|
||||
@Override
|
||||
public int drawCenteredString(int x, int y, int color, String text) {
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
|
||||
return fontRenderer.drawStringWithShadow(text, x - fontRenderer.getStringWidth(text) / 2, y, color);
|
||||
return drawCenteredString(x, y, color, text, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,6 +139,29 @@ public class MinecraftGuiRenderer implements GuiRenderer {
|
||||
return drawCenteredString(x, y, color(color), text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drawString(int x, int y, int color, String text, boolean shadow) {
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
|
||||
return shadow ? fontRenderer.drawStringWithShadow(text, x, y, color) : fontRenderer.drawString(text, x, y, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drawString(int x, int y, ReadableColor color, String text, boolean shadow) {
|
||||
return drawString(x, y, color(color), text, shadow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drawCenteredString(int x, int y, int color, String text, boolean shadow) {
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
|
||||
x-=fontRenderer.getStringWidth(text) / 2;
|
||||
return drawString(x, y, color, text, shadow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drawCenteredString(int x, int y, ReadableColor color, String text, boolean shadow) {
|
||||
return drawCenteredString(x, y, color(color), text, shadow);
|
||||
}
|
||||
|
||||
private int color(ReadableColor color) {
|
||||
return color.getAlpha() << 24
|
||||
| color.getRed() << 16
|
||||
|
||||
@@ -117,4 +117,24 @@ public class OffsetGuiRenderer implements GuiRenderer {
|
||||
public int drawCenteredString(int x, int y, ReadableColor color, String text) {
|
||||
return renderer.drawCenteredString(x + position.getX(), y + position.getY(), color, text) - position.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drawString(int x, int y, int color, String text, boolean shadow) {
|
||||
return renderer.drawString(x + position.getX(), y + position.getY(), color, text) - position.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drawString(int x, int y, ReadableColor color, String text, boolean shadow) {
|
||||
return renderer.drawString(x + position.getX(), y + position.getY(), color, text) - position.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drawCenteredString(int x, int y, int color, String text, boolean shadow) {
|
||||
return renderer.drawCenteredString(x + position.getX(), y + position.getY(), color, text) - position.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drawCenteredString(int x, int y, ReadableColor color, String text, boolean shadow) {
|
||||
return renderer.drawCenteredString(x + position.getX(), y + position.getY(), color, text) - position.getX();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public abstract class AbstractGuiTooltip<T extends AbstractGuiTooltip<T>> extend
|
||||
FontRenderer fontRenderer = getMinecraft().fontRendererObj;
|
||||
int y = LINE_SPACING + 1;
|
||||
for (String line : text) {
|
||||
renderer.drawString(LINE_SPACING + 1, y, color, line);
|
||||
renderer.drawString(LINE_SPACING + 1, y, color, line, true);
|
||||
y += fontRenderer.FONT_HEIGHT + LINE_SPACING;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@ public abstract class AbstractGuiTextArea<T extends AbstractGuiTextArea<T>>
|
||||
|
||||
// Draw line
|
||||
int posY = BORDER + i * lineHeight;
|
||||
int lineEnd = renderer.drawString(BORDER, posY, textColor, line);
|
||||
int lineEnd = renderer.drawString(BORDER, posY, textColor, line, true);
|
||||
|
||||
// Draw selection
|
||||
int fromX = getSelectionFromX();
|
||||
@@ -503,7 +503,7 @@ public abstract class AbstractGuiTextArea<T extends AbstractGuiTextArea<T>>
|
||||
String beforeCursor = line.substring(0, cursorX - leftTrimmed);
|
||||
int posX = BORDER + fontRenderer.getStringWidth(beforeCursor);
|
||||
if (cursorX == text[lineY].length()) {
|
||||
renderer.drawString(posX, posY, CURSOR_COLOR, "_");
|
||||
renderer.drawString(posX, posY, CURSOR_COLOR, "_", true);
|
||||
} else {
|
||||
renderer.drawRect(posX, posY - 1, 1, 1 + fontRenderer.FONT_HEIGHT, CURSOR_COLOR);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user