mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 07:21:32 +01:00
commit
48e4f72d39
@ -93,6 +93,7 @@ public class Client {
|
|||||||
private File globalSettingsFile;
|
private File globalSettingsFile;
|
||||||
private AccountManager accountManager;
|
private AccountManager accountManager;
|
||||||
public ServerData lastServerData;
|
public ServerData lastServerData;
|
||||||
|
public TextUtils textUtils;
|
||||||
|
|
||||||
public static void memoryDebug(String paramString) {
|
public static void memoryDebug(String paramString) {
|
||||||
LogManager.getLogger().info("-- Start Memory Debug -- " + paramString);
|
LogManager.getLogger().info("-- Start Memory Debug -- " + paramString);
|
||||||
@ -340,6 +341,8 @@ public class Client {
|
|||||||
logger.info("STARTING > ERROR: " + err.getMessage());
|
logger.info("STARTING > ERROR: " + err.getMessage());
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
Client.logger.info("STARTING > text-utils");
|
||||||
|
this.textUtils = new TextUtils(Minecraft.getMinecraft().fontRendererObj);
|
||||||
logger.info("-------------------------------------------------");
|
logger.info("-------------------------------------------------");
|
||||||
memoryDebug("CLIENT_POST_INIT");
|
memoryDebug("CLIENT_POST_INIT");
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,7 @@ public class SilentMultiplayerGui extends SilentScreen {
|
|||||||
newScrollY += amountScrolled;
|
newScrollY += amountScrolled;
|
||||||
else
|
else
|
||||||
newScrollY = 0;
|
newScrollY = 0;
|
||||||
if((newScrollY < blockHeight && ((servers.size() + 1) * 38) > blockHeight - 39) || amountScrolled < 0) {
|
if((newScrollY < blockHeight && ((servers.size() + 1) * 38) > blockHeight - 43 - 41) || amountScrolled < 0) {
|
||||||
this.scrollY = (float) newScrollY;
|
this.scrollY = (float) newScrollY;
|
||||||
if(this.scrollY < 0) {
|
if(this.scrollY < 0) {
|
||||||
this.scrollY = 0;
|
this.scrollY = 0;
|
||||||
|
@ -5,6 +5,9 @@ import net.minecraft.client.gui.FontRenderer;
|
|||||||
import net.minecraft.client.gui.Gui;
|
import net.minecraft.client.gui.Gui;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.client.renderer.WorldRenderer;
|
||||||
|
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 net.silentclient.client.cosmetics.StaticResourceLocation;
|
import net.silentclient.client.cosmetics.StaticResourceLocation;
|
||||||
@ -185,7 +188,7 @@ public class RenderUtil {
|
|||||||
} else {
|
} else {
|
||||||
Minecraft.getMinecraft().getTextureManager().bindTexture(image);
|
Minecraft.getMinecraft().getTextureManager().bindTexture(image);
|
||||||
}
|
}
|
||||||
Gui.drawModalRectWithCustomSizedTexture((int) x, (int) y, (float) 0.0f, (float) 0.0f, (int) width, (int) height, (float) width, (float) height);
|
drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, width, height);
|
||||||
GL11.glDepthMask((boolean) true);
|
GL11.glDepthMask((boolean) true);
|
||||||
GL11.glDisable((int) 3042);
|
GL11.glDisable((int) 3042);
|
||||||
GL11.glEnable((int) 2929);
|
GL11.glEnable((int) 2929);
|
||||||
@ -194,6 +197,20 @@ public class RenderUtil {
|
|||||||
GL11.glColor4f((float) 1.0f, (float) 1.0f, (float) 1.0f, 1f);
|
GL11.glColor4f((float) 1.0f, (float) 1.0f, (float) 1.0f, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void drawModalRectWithCustomSizedTexture(float x, float y, float u, float v, float width, float height, float textureWidth, float textureHeight)
|
||||||
|
{
|
||||||
|
float f = 1.0F / textureWidth;
|
||||||
|
float f1 = 1.0F / textureHeight;
|
||||||
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
|
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
||||||
|
worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||||
|
worldrenderer.pos((double)x, (double)(y + height), 0.0D).tex((double)(u * f), (double)((v + (float)height) * f1)).endVertex();
|
||||||
|
worldrenderer.pos((double)(x + width), (double)(y + height), 0.0D).tex((double)((u + (float)width) * f), (double)((v + (float)height) * f1)).endVertex();
|
||||||
|
worldrenderer.pos((double)(x + width), (double)y, 0.0D).tex((double)((u + (float)width) * f), (double)(v * f1)).endVertex();
|
||||||
|
worldrenderer.pos((double)x, (double)y, 0.0D).tex((double)(u * f), (double)(v * f1)).endVertex();
|
||||||
|
tessellator.draw();
|
||||||
|
}
|
||||||
|
|
||||||
public static void drawImage(ResourceLocation image, float x, float y, float width, float height, boolean mip) {
|
public static void drawImage(ResourceLocation image, float x, float y, float width, float height, boolean mip) {
|
||||||
drawImage(image, x, y, width, height, mip, -1);
|
drawImage(image, x, y, width, height, mip, -1);
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,24 @@
|
|||||||
package net.silentclient.client.mods.hud;
|
package net.silentclient.client.mods.hud;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
|
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
import org.lwjgl.input.Mouse;
|
|
||||||
|
|
||||||
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.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.util.EnumChatFormatting;
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
import net.silentclient.client.Client;
|
import net.silentclient.client.Client;
|
||||||
import net.silentclient.client.gui.animation.SimpleAnimation;
|
import net.silentclient.client.gui.animation.SimpleAnimation;
|
||||||
|
import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||||
|
import net.silentclient.client.gui.hud.ScreenPosition;
|
||||||
import net.silentclient.client.gui.lite.clickgui.utils.GlUtils;
|
import net.silentclient.client.gui.lite.clickgui.utils.GlUtils;
|
||||||
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
|
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
|
||||||
import net.silentclient.client.gui.hud.ScreenPosition;
|
|
||||||
import net.silentclient.client.mods.CustomFontRenderer;
|
import net.silentclient.client.mods.CustomFontRenderer;
|
||||||
import net.silentclient.client.mods.ModCategory;
|
import net.silentclient.client.mods.ModCategory;
|
||||||
import net.silentclient.client.mods.ModDraggable;
|
import net.silentclient.client.mods.ModDraggable;
|
||||||
import net.silentclient.client.utils.ColorUtils;
|
import net.silentclient.client.utils.ColorUtils;
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class KeystrokesMod extends ModDraggable {
|
public class KeystrokesMod extends ModDraggable {
|
||||||
|
|
||||||
@ -28,16 +29,21 @@ public class KeystrokesMod extends ModDraggable {
|
|||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
super.setup();
|
super.setup();
|
||||||
|
setUpdated(true);
|
||||||
|
ArrayList<String> cpsModes = new ArrayList<>();
|
||||||
|
cpsModes.add("None");
|
||||||
|
cpsModes.add("Small");
|
||||||
|
cpsModes.add("Large");
|
||||||
this.addBooleanSetting("Font Shadow", this, true);
|
this.addBooleanSetting("Font Shadow", this, true);
|
||||||
this.addBooleanSetting("Fancy Font", this, false);
|
this.addBooleanSetting("Fancy Font", this, false);
|
||||||
this.addBooleanSetting("Background", this, true);
|
this.addBooleanSetting("Background", this, true);
|
||||||
|
this.addModeSetting("CPS Mode", this, "Small", cpsModes);
|
||||||
this.addColorSetting("Color", this, new Color(255, 255, 255));
|
this.addColorSetting("Color", this, new Color(255, 255, 255));
|
||||||
this.addColorSetting("Background Color", this, new Color(0, 0, 0), 127);
|
this.addColorSetting("Background Color", this, new Color(0, 0, 0), 127);
|
||||||
this.addColorSetting("Clicked Color", this, new Color(0, 0, 0));
|
this.addColorSetting("Clicked Color", this, new Color(0, 0, 0));
|
||||||
this.addColorSetting("Clicked Background Color", this, new Color(255, 255, 255), 127);
|
this.addColorSetting("Clicked Background Color", this, new Color(255, 255, 255), 127);
|
||||||
this.addSliderSetting("Fade Delay", this, 100, 0, 1000, true);
|
this.addSliderSetting("Fade Delay", this, 100, 0, 1000, true);
|
||||||
this.addBooleanSetting("Show LMB/RMB", this, true);
|
this.addBooleanSetting("Show LMB/RMB", this, true);
|
||||||
this.addBooleanSetting("Show CPS", this, true);
|
|
||||||
this.addBooleanSetting("Show Space", this, true);
|
this.addBooleanSetting("Show Space", this, true);
|
||||||
this.addBooleanSetting("Replace Names With Arrow", this, false);
|
this.addBooleanSetting("Replace Names With Arrow", this, false);
|
||||||
}
|
}
|
||||||
@ -166,14 +172,26 @@ public class KeystrokesMod extends ModDraggable {
|
|||||||
boolean background = Client.getInstance().getSettingsManager().getSettingByName(this, "background").getValBoolean();
|
boolean background = Client.getInstance().getSettingsManager().getSettingByName(this, "background").getValBoolean();
|
||||||
Color backgroundColor = Client.getInstance().getSettingsManager().getSettingByName(this, "Background Color").getValColor();
|
Color backgroundColor = Client.getInstance().getSettingsManager().getSettingByName(this, "Background Color").getValColor();
|
||||||
Color clickedBackgroundColor = Client.getInstance().getSettingsManager().getSettingByName(this, "Clicked Background Color").getValColor();
|
Color clickedBackgroundColor = Client.getInstance().getSettingsManager().getSettingByName(this, "Clicked Background Color").getValColor();
|
||||||
boolean cps = Client.getInstance().getSettingsManager().getSettingByName(this, "Show CPS").getValBoolean();
|
boolean smallCps = Client.getInstance().getSettingsManager().getSettingByName(this, "CPS Mode").getValString().equalsIgnoreCase("small");
|
||||||
|
boolean largeCps = Client.getInstance().getSettingsManager().getSettingByName(this, "CPS Mode").getValString().equalsIgnoreCase("large");
|
||||||
boolean space = Client.getInstance().getSettingsManager().getSettingByName(this, "Show Space").getValBoolean();
|
boolean space = Client.getInstance().getSettingsManager().getSettingByName(this, "Show Space").getValBoolean();
|
||||||
Color color = Client.getInstance().getSettingsManager().getSettingByName(this, "Color").getValColor();
|
Color color = Client.getInstance().getSettingsManager().getSettingByName(this, "Color").getValColor();
|
||||||
Color clickedColor = Client.getInstance().getSettingsManager().getSettingByName(this, "Clicked Color").getValColor();
|
Color clickedColor = Client.getInstance().getSettingsManager().getSettingByName(this, "Clicked Color").getValColor();
|
||||||
int fadeDelay = Client.getInstance().getSettingsManager().getSettingByName(this, "Fade Delay").getValInt() != 0 ? 100000 / Client.getInstance().getSettingsManager().getSettingByName(this, "Fade Delay").getValInt() : 0;
|
int fadeDelay = Client.getInstance().getSettingsManager().getSettingByName(this, "Fade Delay").getValInt() != 0 ? 100000 / Client.getInstance().getSettingsManager().getSettingByName(this, "Fade Delay").getValInt() : 0;
|
||||||
|
|
||||||
for(Key key : mode.getKeys()) {
|
for(Key key : mode.getKeys()) {
|
||||||
int textWidth = font.getStringWidth(key.getName());
|
String renderString = key.getName();
|
||||||
|
|
||||||
|
if(largeCps) {
|
||||||
|
if (key == Key.LMB && Client.getInstance().getCPSTracker().getLCPS() != 0) {
|
||||||
|
renderString = Client.getInstance().getCPSTracker().getLCPS() + " CPS";
|
||||||
|
}
|
||||||
|
if (key == Key.RMB && Client.getInstance().getCPSTracker().getRCPS() != 0) {
|
||||||
|
renderString = "" + Client.getInstance().getCPSTracker().getRCPS() + " CPS";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int textWidth = font.getStringWidth(renderString);
|
||||||
|
|
||||||
if(background) {
|
if(background) {
|
||||||
setAnimation(key.red, key.isDown() ? clickedBackgroundColor.getRed() : backgroundColor.getRed(), fadeDelay);
|
setAnimation(key.red, key.isDown() ? clickedBackgroundColor.getRed() : backgroundColor.getRed(), fadeDelay);
|
||||||
@ -190,7 +208,7 @@ public class KeystrokesMod extends ModDraggable {
|
|||||||
ColorUtils.setColor(-1);
|
ColorUtils.setColor(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((key == Key.LMB || key == Key.RMB) && cps) {
|
if((key == Key.LMB || key == Key.RMB) && smallCps) {
|
||||||
font.drawString(
|
font.drawString(
|
||||||
key.getName(),
|
key.getName(),
|
||||||
0 + key.getX() + key.getWidth() / 2 - textWidth / 2 - (fancyFont && key == Key.LMB ? 1 : 0),
|
0 + key.getX() + key.getWidth() / 2 - textWidth / 2 - (fancyFont && key == Key.LMB ? 1 : 0),
|
||||||
@ -237,13 +255,27 @@ public class KeystrokesMod extends ModDraggable {
|
|||||||
shadow
|
shadow
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
font.drawString(
|
boolean needResize = textWidth + 4 >= key.getWidth();
|
||||||
key.getName(),
|
if(!needResize) {
|
||||||
0 + key.getX() + key.getWidth() / 2 - textWidth / 2,
|
font.drawString(
|
||||||
0 + key.getY() + key.getHeight() / 2 - 4,
|
renderString,
|
||||||
key.isDown() ? clickedColor.getRGB() : color.getRGB(),
|
0 + key.getX() + key.getWidth() / 2 - textWidth / 2,
|
||||||
shadow
|
0 + key.getY() + key.getHeight() / 2 - 4,
|
||||||
|
key.isDown() ? clickedColor.getRGB() : color.getRGB(),
|
||||||
|
shadow
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
if(fancyFont) {
|
||||||
|
textWidth = font.getStringWidth(renderString, 11, SilentFontRenderer.FontType.TITLE);
|
||||||
|
font.drawString(renderString,
|
||||||
|
0 + key.getX() + key.getWidth() / 2 - textWidth / 2,
|
||||||
|
0 + key.getY() + key.getHeight() / 2 - 7, 11, SilentFontRenderer.FontType.TITLE,
|
||||||
|
key.isDown() ? clickedColor.getRGB() : color.getRGB(),
|
||||||
|
shadow);
|
||||||
|
} else {
|
||||||
|
Client.getInstance().textUtils.drawScaledString(renderString, 0 + key.getX() + key.getWidth() / 2 - textWidth / 2 + 3 + (key == Key.RMB ? 8 : 0) + (renderString.length() >= 6 ? -0.5F : 0), 0 + key.getY() + key.getHeight() / 2 + 8, key.isDown() ? clickedColor.getRGB() : color.getRGB(), 0.8F, shadow);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(key.isDown() && clickedColor.getRGB() == -16777216) {
|
if(key.isDown() && clickedColor.getRGB() == -16777216) {
|
||||||
font.drawString("", 0, 0, -1, shadow);
|
font.drawString("", 0, 0, -1, shadow);
|
||||||
|
78
src/main/java/net/silentclient/client/utils/TextUtils.java
Normal file
78
src/main/java/net/silentclient/client/utils/TextUtils.java
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
package net.silentclient.client.utils;
|
||||||
|
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
|
import net.minecraft.client.gui.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TextUtils for drawing scaled string
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* I would like to get credited :)
|
||||||
|
* @author wcaleniekubaa#4196
|
||||||
|
* If there is any problem write to me :)
|
||||||
|
* or to the Eric Golde discord server
|
||||||
|
* you can also create issue on github
|
||||||
|
*
|
||||||
|
* @see FontRenderer#drawString(String, float, float, int, boolean)
|
||||||
|
* You can also set the methods static lol
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TextUtils {
|
||||||
|
private final FontRenderer font;
|
||||||
|
|
||||||
|
public TextUtils(FontRenderer font){
|
||||||
|
this.font = font;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates Scaled String
|
||||||
|
*/
|
||||||
|
public void drawScaledString(String text, float x,float y, int color, float scale, boolean shadow){
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.scale(scale,scale,scale);
|
||||||
|
font.drawString(text,x,y,color,shadow);
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates Centered Scaled String
|
||||||
|
*/
|
||||||
|
public void drawCenteredScaledString(String text, int x,int y, int color, float scale){
|
||||||
|
this.drawCenteredScaledString(text, x, y, color, scale, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawCenteredScaledString(String text, int x,int y, int color, float scale, boolean shadow){
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.scale(scale,scale,scale);
|
||||||
|
/* make draw centered string static after it you can delete this comment*/
|
||||||
|
this.drawCenteredString(text, (int) (x / scale), (int) (y / scale), color, shadow);
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawCenteredString(String text, int x, int y, int color, boolean shadow)
|
||||||
|
{
|
||||||
|
font.drawString(text, (float)(x - font.getStringWidth(text) / 2), (float)y, color, shadow);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates Scaled String <br>
|
||||||
|
* (you can desort it)
|
||||||
|
*/
|
||||||
|
public void drawScaledString(String text, int x,int y, int color, float scaleX, float scaleY, boolean shadow){
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.scale(scaleX,scaleY,scaleY); /* Text isn't 3d */
|
||||||
|
font.drawString(text,x,y,color,shadow);
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates Centered Scaled String <br>
|
||||||
|
* (you can disort it) :)
|
||||||
|
*/
|
||||||
|
public void drawCenteredScaledString(String text, int x,int y, int color, float scaleX, float scaleY){
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.scale(scaleX,scaleY,scaleY); /* Text isn't 3d */
|
||||||
|
/* make draw centered string static after it you can delete this comment*/
|
||||||
|
this.drawCenteredString(text, (int) (x / scaleX), (int) (y / scaleY), -1, false);
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user