mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 10:21:32 +01:00
Text Width Fix
This commit is contained in:
parent
4a903509a8
commit
2d936e53f2
@ -1,10 +1,6 @@
|
|||||||
package net.silentclient.client.gui.font;
|
package net.silentclient.client.gui.font;
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.util.Map;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
@ -12,10 +8,14 @@ import net.minecraft.client.renderer.WorldRenderer;
|
|||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.silentclient.client.Client;
|
import net.silentclient.client.Client;
|
||||||
|
|
||||||
import org.apache.commons.io.Charsets;
|
import org.apache.commons.io.Charsets;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class SilentFontRenderer {
|
public class SilentFontRenderer {
|
||||||
private static final ResourceLocation silentFontHeader = new ResourceLocation("silentclient/fonts/silent-font-0.png");
|
private static final ResourceLocation silentFontHeader = new ResourceLocation("silentclient/fonts/silent-font-0.png");
|
||||||
private static final ResourceLocation silentFontTitle = new ResourceLocation("silentclient/fonts/silent-font-1.png");
|
private static final ResourceLocation silentFontTitle = new ResourceLocation("silentclient/fonts/silent-font-1.png");
|
||||||
@ -302,7 +302,7 @@ public class SilentFontRenderer {
|
|||||||
this.renderString(x, y, string, 128 / fontHeight, fontType, true);
|
this.renderString(x, y, string, 128 / fontHeight, fontType, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawString(String string, int x, int y, int fontHeight, FontType fontType, int maxWidth)
|
public void drawString(String string, float x, float y, int fontHeight, FontType fontType, int maxWidth)
|
||||||
{
|
{
|
||||||
this.getClass();
|
this.getClass();
|
||||||
if(this.getStringWidth(string, fontHeight, fontType) > maxWidth) {
|
if(this.getStringWidth(string, fontHeight, fontType) > maxWidth) {
|
||||||
|
@ -11,14 +11,15 @@ import java.text.DecimalFormat;
|
|||||||
|
|
||||||
public class RegularSlider {
|
public class RegularSlider {
|
||||||
public static void render(float x, float y, int width, String name, double max, double value) {
|
public static void render(float x, float y, int width, String name, double max, double value) {
|
||||||
Client.getInstance().getSilentFontRenderer().drawString(name, x, y, 12, SilentFontRenderer.FontType.TITLE);
|
int valueWidth = Client.getInstance().getSilentFontRenderer().getStringWidth(new DecimalFormat("0.00").format(value), 12, SilentFontRenderer.FontType.TITLE);
|
||||||
|
Client.getInstance().getSilentFontRenderer().drawString(name, x, y, 12, SilentFontRenderer.FontType.TITLE, 142 - valueWidth);
|
||||||
|
|
||||||
RenderUtil.drawRoundedRect(x, y + 15, width, 9, 3, Color.black.getRGB());
|
RenderUtil.drawRoundedRect(x, y + 15, width, 9, 3, Color.black.getRGB());
|
||||||
if(value != 0) {
|
if(value != 0) {
|
||||||
RenderUtil.drawRoundedRect(x, y + 15, width * (float) (value / max), 9, 3, -1);
|
RenderUtil.drawRoundedRect(x, y + 15, width * (float) (value / max), 9, 3, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
float textLeft = x + width - Client.getInstance().getSilentFontRenderer().getStringWidth(new DecimalFormat("0.00").format(value), 12, SilentFontRenderer.FontType.TITLE);
|
float textLeft = x + width - valueWidth;
|
||||||
Client.getInstance().getSilentFontRenderer().drawString(new DecimalFormat("0.00").format(value), textLeft, y, 12, SilentFontRenderer.FontType.TITLE);
|
Client.getInstance().getSilentFontRenderer().drawString(new DecimalFormat("0.00").format(value), textLeft, y, 12, SilentFontRenderer.FontType.TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user