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