mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 07:41:31 +01:00
Cursors
This commit is contained in:
parent
94d0798a41
commit
104454503e
@ -20,6 +20,7 @@ import net.silentclient.client.gui.clickgui.ClickGUI;
|
|||||||
import net.silentclient.client.gui.font.SilentFontRenderer;
|
import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||||
import net.silentclient.client.gui.util.BackgroundPanorama;
|
import net.silentclient.client.gui.util.BackgroundPanorama;
|
||||||
import net.silentclient.client.keybinds.KeyBindManager;
|
import net.silentclient.client.keybinds.KeyBindManager;
|
||||||
|
import net.silentclient.client.mixin.SilentClientTweaker;
|
||||||
import net.silentclient.client.mods.ModInstances;
|
import net.silentclient.client.mods.ModInstances;
|
||||||
import net.silentclient.client.mods.SettingsManager;
|
import net.silentclient.client.mods.SettingsManager;
|
||||||
import net.silentclient.client.mods.settings.FPSBoostMod;
|
import net.silentclient.client.mods.settings.FPSBoostMod;
|
||||||
@ -55,7 +56,7 @@ public class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private BuildData buildData = new BuildData();
|
private BuildData buildData = new BuildData();
|
||||||
private UserData userData = new UserData();
|
private UserData userData = new UserData(SilentClientTweaker.TOKEN);
|
||||||
public File dir;
|
public File dir;
|
||||||
private SettingsManager settingsManager;
|
private SettingsManager settingsManager;
|
||||||
public ConfigManager configManager;
|
public ConfigManager configManager;
|
||||||
@ -81,6 +82,7 @@ public class Client {
|
|||||||
public static BackgroundPanorama backgroundPanorama;
|
public static BackgroundPanorama backgroundPanorama;
|
||||||
private KeyBindManager keyBindManager;
|
private KeyBindManager keyBindManager;
|
||||||
private IMetadataSerializer iMetadataSerializer;
|
private IMetadataSerializer iMetadataSerializer;
|
||||||
|
private MouseCursorHandler mouseCursorHandler;
|
||||||
|
|
||||||
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);
|
||||||
@ -109,22 +111,6 @@ public class Client {
|
|||||||
in.close();
|
in.close();
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
Client.logger.catching(e1);
|
Client.logger.catching(e1);
|
||||||
}
|
|
||||||
try {
|
|
||||||
InputStream in = new FileInputStream(new File(Minecraft.getMinecraft().mcDataDir, "silent_account.json"));
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
|
||||||
StringBuffer content = new StringBuffer();
|
|
||||||
String inputLine;
|
|
||||||
while ((inputLine = reader.readLine()) != null) {
|
|
||||||
content.append(inputLine);
|
|
||||||
}
|
|
||||||
GsonBuilder builder = new GsonBuilder();
|
|
||||||
Gson gson = builder.create();
|
|
||||||
|
|
||||||
userData = gson.fromJson(content.toString(), UserData.class);
|
|
||||||
in.close();
|
|
||||||
} catch (Exception err) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
logger.info("---------[ Silent Client Initialising ]---------");
|
logger.info("---------[ Silent Client Initialising ]---------");
|
||||||
logger.info("MC Version: 1.8.9");
|
logger.info("MC Version: 1.8.9");
|
||||||
@ -264,9 +250,8 @@ public class Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(account.getCustomSkin()) {
|
logger.info("STARTING > mouse-cursor-handler");
|
||||||
logger.info("STARTING > custom-skin");
|
this.mouseCursorHandler = new MouseCursorHandler();
|
||||||
}
|
|
||||||
} catch(Exception err) {
|
} catch(Exception err) {
|
||||||
logger.info("STARTING > ERROR: " + err.getMessage());
|
logger.info("STARTING > ERROR: " + err.getMessage());
|
||||||
throw err;
|
throw err;
|
||||||
@ -558,4 +543,8 @@ public class Client {
|
|||||||
public void setiMetadataSerializer(IMetadataSerializer iMetadataSerializer) {
|
public void setiMetadataSerializer(IMetadataSerializer iMetadataSerializer) {
|
||||||
this.iMetadataSerializer = iMetadataSerializer;
|
this.iMetadataSerializer = iMetadataSerializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MouseCursorHandler getMouseCursorHandler() {
|
||||||
|
return mouseCursorHandler;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,33 @@
|
|||||||
package net.silentclient.client.gui;
|
package net.silentclient.client.gui;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.silentclient.client.Client;
|
||||||
import net.silentclient.client.gui.elements.Input;
|
import net.silentclient.client.gui.elements.Input;
|
||||||
|
import net.silentclient.client.utils.MouseCursorHandler;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class SilentScreen extends GuiScreen {
|
public class SilentScreen extends GuiScreen {
|
||||||
protected ArrayList<Input> silentInputs = new ArrayList<>();
|
protected ArrayList<Input> silentInputs = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
MouseCursorHandler.CursorType cursorType = MouseCursorHandler.CursorType.NORMAL;
|
||||||
|
|
||||||
|
for(Input input : silentInputs) {
|
||||||
|
if(input.isHovered()) {
|
||||||
|
cursorType = MouseCursorHandler.CursorType.EDIT_TEXT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Client.getInstance().getMouseCursorHandler().enableCursor(cursorType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuiClosed() {
|
||||||
|
super.onGuiClosed();
|
||||||
|
Client.getInstance().getMouseCursorHandler().disableCursor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,10 +205,7 @@ public class ClickGUI extends SilentScreen {
|
|||||||
PremiumGui.drawScreen(x, y, width, height, mouseX, mouseY, partialTicks, nametagMessageInput);
|
PremiumGui.drawScreen(x, y, width, height, mouseX, mouseY, partialTicks, nametagMessageInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < this.buttonList.size(); ++i)
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
{
|
|
||||||
((GuiButton)this.buttonList.get(i)).drawButton(this.mc, mouseX, mouseY);
|
|
||||||
}
|
|
||||||
|
|
||||||
scrollAnimation.setAnimation((float) scrollY, 16);
|
scrollAnimation.setAnimation((float) scrollY, 16);
|
||||||
|
|
||||||
@ -442,6 +439,7 @@ public class ClickGUI extends SilentScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuiClosed() {
|
public void onGuiClosed() {
|
||||||
|
super.onGuiClosed();
|
||||||
Client.getInstance().configManager.save();
|
Client.getInstance().configManager.save();
|
||||||
MenuBlurUtils.unloadBlur();
|
MenuBlurUtils.unloadBlur();
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ public class Input {
|
|||||||
private int maxLength;
|
private int maxLength;
|
||||||
private boolean keyValue;
|
private boolean keyValue;
|
||||||
private int key;
|
private int key;
|
||||||
|
private boolean hovered = false;
|
||||||
|
|
||||||
public Input(String name, String value, int key, Pattern pattern, int maxLength, boolean keyValue) {
|
public Input(String name, String value, int key, Pattern pattern, int maxLength, boolean keyValue) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -63,6 +64,9 @@ public class Input {
|
|||||||
int borderColor = new Color(255, 255, 255, 41).getRGB();
|
int borderColor = new Color(255, 255, 255, 41).getRGB();
|
||||||
if(MouseUtils.isInside(mouseX, mouseY, x, y, width, 20)) {
|
if(MouseUtils.isInside(mouseX, mouseY, x, y, width, 20)) {
|
||||||
borderColor = new Color(255, 255, 255, 61).getRGB();
|
borderColor = new Color(255, 255, 255, 61).getRGB();
|
||||||
|
this.hovered = true;
|
||||||
|
} else {
|
||||||
|
this.hovered = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isFocused) {
|
if(isFocused) {
|
||||||
@ -88,7 +92,11 @@ public class Input {
|
|||||||
}
|
}
|
||||||
Client.getInstance().getSilentFontRenderer().drawString(EnumChatFormatting.getTextWithoutFormattingCodes(renderText), x + 2, y + (small ? 1 : 3), small ? 12 : 14, SilentFontRenderer.FontType.TITLE);
|
Client.getInstance().getSilentFontRenderer().drawString(EnumChatFormatting.getTextWithoutFormattingCodes(renderText), x + 2, y + (small ? 1 : 3), small ? 12 : 14, SilentFontRenderer.FontType.TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isHovered() {
|
||||||
|
return hovered;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isFocused() {
|
public boolean isFocused() {
|
||||||
return isFocused;
|
return isFocused;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import java.text.DecimalFormat;
|
|||||||
|
|
||||||
import net.silentclient.client.gui.elements.Button;
|
import net.silentclient.client.gui.elements.Button;
|
||||||
import net.silentclient.client.utils.MenuBlurUtils;
|
import net.silentclient.client.utils.MenuBlurUtils;
|
||||||
|
import net.silentclient.client.utils.MouseCursorHandler;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
@ -88,8 +89,13 @@ public class HUDConfigScreen extends GuiScreen {
|
|||||||
Client.getInstance().getSilentFontRenderer().drawString(0, 36, "selectedMod: " + (this.mod != null ? this.mod.getClass().getName() : "null"), 6, FontType.TITLE);
|
Client.getInstance().getSilentFontRenderer().drawString(0, 36, "selectedMod: " + (this.mod != null ? this.mod.getClass().getName() : "null"), 6, FontType.TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MouseCursorHandler.CursorType cursorType = MouseCursorHandler.CursorType.NORMAL;
|
||||||
|
|
||||||
for(Mod m : Client.getInstance().getModInstances().getMods()) {
|
for(Mod m : Client.getInstance().getModInstances().getMods()) {
|
||||||
if(m.isEnabled() && m instanceof ModDraggable) {
|
if(m.isEnabled() && m instanceof ModDraggable) {
|
||||||
|
if(((ModDraggable) m).isHovered(mouseX, mouseY, scaledresolution) || ((ModDraggable) m).isDragging()) {
|
||||||
|
cursorType = MouseCursorHandler.CursorType.MOVE;
|
||||||
|
}
|
||||||
((ModDraggable) m).renderEditing(mouseX, mouseY, scaledresolution, debug, this);
|
((ModDraggable) m).renderEditing(mouseX, mouseY, scaledresolution, debug, this);
|
||||||
|
|
||||||
if(((ModDraggable) m).isDragging()) {
|
if(((ModDraggable) m).isDragging()) {
|
||||||
@ -97,6 +103,8 @@ public class HUDConfigScreen extends GuiScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Client.getInstance().getMouseCursorHandler().enableCursor(cursorType);
|
||||||
|
|
||||||
if (this.buttonList != null && this.buttonList.size() != 0)
|
if (this.buttonList != null && this.buttonList.size() != 0)
|
||||||
{
|
{
|
||||||
@ -199,6 +207,7 @@ public class HUDConfigScreen extends GuiScreen {
|
|||||||
((ModDraggable) m).setDragging(false);
|
((ModDraggable) m).setDragging(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Client.getInstance().getMouseCursorHandler().disableCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,11 +13,19 @@ import java.util.List;
|
|||||||
public class SilentClientTweaker implements ITweaker {
|
public class SilentClientTweaker implements ITweaker {
|
||||||
private List<String> launchArgs = new ArrayList<>();
|
private List<String> launchArgs = new ArrayList<>();
|
||||||
public static boolean hasOptifine = false;
|
public static boolean hasOptifine = false;
|
||||||
|
public static String TOKEN = "";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
|
public final void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
|
||||||
{
|
{
|
||||||
Client.logger.info("Silent Client Tweak Loader: Options");
|
Client.logger.info("Silent Client Tweak Loader: Options");
|
||||||
|
if (args.contains("--sctoken")) {
|
||||||
|
final int index = args.indexOf("--sctoken");
|
||||||
|
try {
|
||||||
|
SilentClientTweaker.TOKEN = (String)args.get(index + 1);
|
||||||
|
}
|
||||||
|
catch (final Exception ex) {}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Class.forName("optifine.OptiFineTweaker");
|
Class.forName("optifine.OptiFineTweaker");
|
||||||
hasOptifine = true;
|
hasOptifine = true;
|
||||||
|
@ -0,0 +1,120 @@
|
|||||||
|
package net.silentclient.client.utils;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
|
import org.lwjgl.LWJGLException;
|
||||||
|
import org.lwjgl.input.Cursor;
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.nio.IntBuffer;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MouseCursorHandler {
|
||||||
|
private Map<CursorType, Cursor> cursors;
|
||||||
|
private CursorType currentCursor;
|
||||||
|
private boolean customCursorDisabled;
|
||||||
|
|
||||||
|
public MouseCursorHandler() {
|
||||||
|
this.cursors = new HashMap<CursorType, Cursor>();
|
||||||
|
this.currentCursor = CursorType.NORMAL;
|
||||||
|
this.customCursorDisabled = false;
|
||||||
|
final int minCursorSize = Cursor.getMinCursorSize();
|
||||||
|
final int maxCursorSize = Cursor.getMaxCursorSize();
|
||||||
|
LogManager.getLogger().info("Min Cursor Size: " + minCursorSize + " max: " + maxCursorSize);
|
||||||
|
if (maxCursorSize < 24) {
|
||||||
|
this.customCursorDisabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.loadCursorType(CursorType.MOVE);
|
||||||
|
this.loadCursorType(CursorType.NWSE_RESIZE);
|
||||||
|
this.loadCursorType(CursorType.NESW_RESIZE);
|
||||||
|
this.loadCursorType(CursorType.EDIT_TEXT);
|
||||||
|
this.loadCursorType(CursorType.POINTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadCursorType(final CursorType cursorType) {
|
||||||
|
try {
|
||||||
|
this.cursors.put(cursorType, this.loadCursor(ImageIO.read(this.getClass().getResourceAsStream("/assets/minecraft/silentclient/mouse/" + cursorType.name().toLowerCase(Locale.US) + ".png"))));
|
||||||
|
}
|
||||||
|
catch (final Exception ex) {
|
||||||
|
LogManager.getLogger().catching((Throwable)ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cursor loadCursor(final BufferedImage bufferedImage) throws LWJGLException {
|
||||||
|
final int width = bufferedImage.getWidth();
|
||||||
|
final int height = bufferedImage.getHeight();
|
||||||
|
final int min = Math.min(Math.max(width, Cursor.getMinCursorSize()), Cursor.getMaxCursorSize());
|
||||||
|
final int[] src = new int[min * min];
|
||||||
|
int n = 0;
|
||||||
|
for (int i = 0; i < min; ++i) {
|
||||||
|
for (int j = 0; j < min; ++j) {
|
||||||
|
int rgb = 0;
|
||||||
|
try {
|
||||||
|
rgb = bufferedImage.getRGB(i, j);
|
||||||
|
}
|
||||||
|
catch (final Exception ex) {}
|
||||||
|
src[n++] = rgb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final IntBuffer intBuffer = BufferUtils.createIntBuffer(min * min);
|
||||||
|
intBuffer.put(src);
|
||||||
|
intBuffer.rewind();
|
||||||
|
LogManager.getLogger().info("Loading cursor: w: " + width + " h: " + height);
|
||||||
|
return new Cursor(min, min, width / 2, height / 2, 1, intBuffer, (IntBuffer)null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean enableCursor(final CursorType cursorType) {
|
||||||
|
if (this.customCursorDisabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.currentCursor.equals(cursorType)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (cursorType.equals(CursorType.NORMAL)) {
|
||||||
|
this.disableCursor();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final Cursor nativeCursor = this.cursors.get(cursorType);
|
||||||
|
if (nativeCursor != null) {
|
||||||
|
Mouse.setNativeCursor(nativeCursor);
|
||||||
|
this.currentCursor = cursorType;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (final Exception ex) {
|
||||||
|
LogManager.getLogger().catching((Throwable)ex);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableCursor() {
|
||||||
|
if (this.customCursorDisabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.currentCursor != CursorType.NORMAL) {
|
||||||
|
try {
|
||||||
|
Mouse.setNativeCursor((Cursor)null);
|
||||||
|
this.currentCursor = CursorType.NORMAL;
|
||||||
|
}
|
||||||
|
catch (final Exception ex) {
|
||||||
|
LogManager.getLogger().catching((Throwable)ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CursorType
|
||||||
|
{
|
||||||
|
NORMAL,
|
||||||
|
NESW_RESIZE,
|
||||||
|
NWSE_RESIZE,
|
||||||
|
MOVE,
|
||||||
|
EDIT_TEXT,
|
||||||
|
POINTER;
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,10 @@ public class UserData {
|
|||||||
this.access_token = "";
|
this.access_token = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserData(String token) {
|
||||||
|
this.access_token = token;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAccessToken() {
|
public String getAccessToken() {
|
||||||
return access_token;
|
return access_token;
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 499 B |
BIN
src/main/resources/assets/minecraft/silentclient/mouse/move.png
Normal file
BIN
src/main/resources/assets/minecraft/silentclient/mouse/move.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 287 B |
Binary file not shown.
After Width: | Height: | Size: 354 B |
Binary file not shown.
After Width: | Height: | Size: 239 B |
Binary file not shown.
After Width: | Height: | Size: 653 B |
Loading…
Reference in New Issue
Block a user