auto text gui

This commit is contained in:
kirillsaint 2023-07-22 02:37:13 +06:00
parent 1024deac2f
commit bb851c0054
6 changed files with 95 additions and 27 deletions

View File

@ -16,7 +16,6 @@ import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils.Scroll;
import net.silentclient.client.gui.elements.*; import net.silentclient.client.gui.elements.*;
import net.silentclient.client.gui.font.SilentFontRenderer; import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.hud.HUDConfigScreen; import net.silentclient.client.gui.hud.HUDConfigScreen;
import net.silentclient.client.gui.notification.NotificationManager;
import net.silentclient.client.gui.theme.Theme; import net.silentclient.client.gui.theme.Theme;
import net.silentclient.client.gui.util.RenderUtil; import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.mods.Mod; import net.silentclient.client.mods.Mod;
@ -362,7 +361,7 @@ public class ModSettings extends SilentScreen {
settingY += settingHeight; settingY += settingHeight;
} }
mod.customComponentClick(x + 100, (int) (y + 30 + scrollY), mouseX, mouseY, mouseButton, this); mod.customLiteComponentClick(x + 100, (int) (y + 30 + scrollY), mouseX, mouseY, mouseButton, this);
} }
@Override @Override

View File

@ -257,8 +257,11 @@ public class ModMenu extends SilentScreen {
newScrollY += amountScrolled; newScrollY += amountScrolled;
else else
newScrollY = 0; newScrollY = 0;
if(newScrollY < scrollHeight && scrollHeight > height - 25) { if((newScrollY < scrollHeight && scrollHeight > height - 25) || amountScrolled < 0) {
this.scrollY = (float) newScrollY; this.scrollY = (float) newScrollY;
if(this.scrollY < 0) {
this.scrollY = 0;
}
} }
} }
} }

View File

@ -77,6 +77,10 @@ public class ModSettings extends SilentScreen {
ModMenu.trimContentStart(width, height); ModMenu.trimContentStart(width, height);
float settingY = 66 - scrollAnimation.getValue(); float settingY = 66 - scrollAnimation.getValue();
int inputIndex = 0; int inputIndex = 0;
GlStateManager.color(1, 1, 1, 1);
mod.renderCustomComponent(3, (int) settingY, 144, height, mouseX, mouseY);
settingY += mod.customComponentHeight() + 30;
for (Setting setting : Client.getInstance().getSettingsManager().getSettingByMod(mod)) { for (Setting setting : Client.getInstance().getSettingsManager().getSettingByMod(mod)) {
if(mod.getName() == "Crosshair" && Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean() && setting.getName() != "Scale" && setting.getName() != "Crosshair Color" && setting.getName() != "Vanilla Blendering") { if(mod.getName() == "Crosshair" && Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean() && setting.getName() != "Scale" && setting.getName() != "Crosshair Color" && setting.getName() != "Vanilla Blendering") {
@ -156,8 +160,11 @@ public class ModSettings extends SilentScreen {
else else
newScrollY = 0; newScrollY = 0;
Client.logger.info(String.format("newscroll: %s, scrollheight: %s, height: %s", newScrollY, scrollHeight, height)); Client.logger.info(String.format("newscroll: %s, scrollheight: %s, height: %s", newScrollY, scrollHeight, height));
if(newScrollY < scrollHeight && scrollHeight > height) { if((newScrollY < scrollHeight && scrollHeight > height) || amountScrolled < 0) {
this.scrollY = (float) newScrollY; this.scrollY = (float) newScrollY;
if(this.scrollY < 0) {
this.scrollY = 0;
}
} }
} }
} }
@ -169,6 +176,10 @@ public class ModSettings extends SilentScreen {
float settingY = 66 - scrollAnimation.getValue(); float settingY = 66 - scrollAnimation.getValue();
int inputIndex = 0; int inputIndex = 0;
mod.customComponentClick(0, (int) settingY, mouseX, mouseY, mouseButton, this);
settingY += mod.customComponentHeight();
for (Setting setting : Client.getInstance().getSettingsManager().getSettingByMod(mod)) { for (Setting setting : Client.getInstance().getSettingsManager().getSettingByMod(mod)) {
if(mod.getName() == "Crosshair" && Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean() && setting.getName() != "Scale" && setting.getName() != "Crosshair Color" && setting.getName() != "Vanilla Blendering") { if(mod.getName() == "Crosshair" && Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean() && setting.getName() != "Scale" && setting.getName() != "Crosshair Color" && setting.getName() != "Vanilla Blendering") {
continue; continue;

View File

@ -1,8 +1,5 @@
package net.silentclient.client.mods; package net.silentclient.client.mods;
import java.awt.Color;
import java.util.ArrayList;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
@ -13,6 +10,9 @@ import net.silentclient.client.gui.hud.ScreenPosition;
import net.silentclient.client.utils.MenuBlurUtils; import net.silentclient.client.utils.MenuBlurUtils;
import net.silentclient.client.utils.RawInputHandler; import net.silentclient.client.utils.RawInputHandler;
import java.awt.*;
import java.util.ArrayList;
public class Mod implements IMod { public class Mod implements IMod {
private boolean isEnabled; private boolean isEnabled;
@ -183,6 +183,10 @@ public class Mod implements IMod {
return 0; return 0;
} }
public void customLiteComponentClick(int x, int y, int mouseX, int mouseY, int mouseButton, GuiScreen screen) {
}
public void renderCustomComponent(int x, int y, int width, int height, int mouseX, int mouseY) { public void renderCustomComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
return; return;
} }

View File

@ -1,14 +1,5 @@
package net.silentclient.client.mods.player; package net.silentclient.client.mods.player;
import java.awt.Color;
import java.io.IOException;
import java.util.ArrayList;
import java.util.regex.Pattern;
import net.silentclient.client.gui.SilentScreen;
import net.silentclient.client.utils.MenuBlurUtils;
import org.lwjgl.input.Keyboard;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
@ -16,18 +7,25 @@ import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client; import net.silentclient.client.Client;
import net.silentclient.client.event.EventTarget; import net.silentclient.client.event.EventTarget;
import net.silentclient.client.event.impl.KeyEvent; import net.silentclient.client.event.impl.KeyEvent;
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; import net.silentclient.client.gui.SilentScreen;
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
import net.silentclient.client.gui.elements.Button; import net.silentclient.client.gui.elements.Button;
import net.silentclient.client.gui.elements.IconButton; import net.silentclient.client.gui.elements.IconButton;
import net.silentclient.client.gui.elements.Input; import net.silentclient.client.gui.elements.Input;
import net.silentclient.client.gui.font.SilentFontRenderer; import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.notification.NotificationManager; import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
import net.silentclient.client.gui.theme.Theme; import net.silentclient.client.gui.theme.Theme;
import net.silentclient.client.mods.CustomFontRenderer; import net.silentclient.client.mods.CustomFontRenderer;
import net.silentclient.client.mods.Mod; import net.silentclient.client.mods.Mod;
import net.silentclient.client.mods.ModCategory; import net.silentclient.client.mods.ModCategory;
import net.silentclient.client.utils.MenuBlurUtils;
import net.silentclient.client.utils.NotificationUtils; import net.silentclient.client.utils.NotificationUtils;
import org.lwjgl.input.Keyboard;
import java.awt.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.regex.Pattern;
public class AutoTextMod extends Mod { public class AutoTextMod extends Mod {
@ -60,18 +58,49 @@ public class AutoTextMod extends Mod {
componentHeight = spacing - 30; componentHeight = spacing - 30;
} }
@Override
public void renderCustomComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
CustomFontRenderer font = new CustomFontRenderer();
font.setRenderMode(CustomFontRenderer.RenderMode.CUSTOM);
font.drawString("Macros:", x, y, -1, 14);
font.drawString("Create Macro", x + customComponentWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), y, MouseUtils.isInside(mouseX, mouseY, x + customComponentWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), y, font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), 12) ? new Color(255, 255, 255, 127).getRGB() : -1, 12);
int spacing = y + 20;
for(AutoTextCommand command : commands) {
font.drawString("Command: " + command.getCommand(), x, spacing, -1, 12);
font.drawString("Key: " + Keyboard.getKeyName(command.getKey()), x, spacing + 10, -1, 12);
font.drawString("Remove", x, spacing + 20, MouseUtils.isInside(mouseX, mouseY, x, spacing + 20, font.getStringWidth("Remove"), 12) ? new Color(255, 255, 255, 127).getRGB() : -1, 12);
spacing += 40;
}
componentHeight = spacing - 30;
}
@Override @Override
public int customComponentLiteHeight() { public int customComponentLiteHeight() {
return componentHeight; return componentHeight;
} }
@Override
public int customComponentHeight() {
return customComponentLiteHeight();
}
@Override @Override
public int customComponentLiteWidth() { public int customComponentLiteWidth() {
return 290; return 290;
} }
@Override @Override
public void customComponentClick(int x, int y, int mouseX, int mouseY, int mouseButton, GuiScreen screen) { public int customComponentWidth() {
return 144;
}
@Override
public void customLiteComponentClick(int x, int y, int mouseX, int mouseY, int mouseButton, GuiScreen screen) {
CustomFontRenderer font = new CustomFontRenderer(); CustomFontRenderer font = new CustomFontRenderer();
font.setRenderMode(CustomFontRenderer.RenderMode.CUSTOM); font.setRenderMode(CustomFontRenderer.RenderMode.CUSTOM);
@ -92,6 +121,28 @@ public class AutoTextMod extends Mod {
} }
} }
@Override
public void customComponentClick(int x, int y, int mouseX, int mouseY, int mouseButton, GuiScreen screen) {
CustomFontRenderer font = new CustomFontRenderer();
font.setRenderMode(CustomFontRenderer.RenderMode.CUSTOM);
if(MouseUtils.isInside(mouseX, mouseY, x + customComponentWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), y, font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), 12)) {
mc.displayGuiScreen(new AutoTextAddCommandGui(screen));
}
int spacing = y + 20;
for(AutoTextCommand command : commands) {
if(MouseUtils.isInside(mouseX, mouseY, x, spacing + 20, font.getStringWidth("Remove", 12, SilentFontRenderer.FontType.TITLE), 12)) {
try {
this.removeCommand(command.getCommand(), command.getKey());
} catch(Exception err) {
err.printStackTrace();
}
}
spacing += 40;
}
}
public void removeCommand(String commandText, int key) { public void removeCommand(String commandText, int key) {
ArrayList<AutoTextCommand> newCommands = new ArrayList<AutoTextCommand>(); ArrayList<AutoTextCommand> newCommands = new ArrayList<AutoTextCommand>();

View File

@ -193,7 +193,7 @@ public class CrosshairMod extends Mod {
} }
@Override @Override
public void customComponentClick(int x, int y, int mouseX, int mouseY, int mouseButton, GuiScreen screen) { public void customLiteComponentClick(int x, int y, int mouseX, int mouseY, int mouseButton, GuiScreen screen) {
int widthComponent = 190 * 2; int widthComponent = 190 * 2;
int buttonWidth = (widthComponent - 108) / 2; int buttonWidth = (widthComponent - 108) / 2;
if(MouseUtils.isInside(mouseX, mouseY, x, y, buttonWidth, 20)) { if(MouseUtils.isInside(mouseX, mouseY, x, y, buttonWidth, 20)) {