mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 07:51:32 +01:00
Crosshair Gui
This commit is contained in:
parent
bb851c0054
commit
9e052f1bd2
@ -80,7 +80,7 @@ public class ModSettings extends SilentScreen {
|
|||||||
GlStateManager.color(1, 1, 1, 1);
|
GlStateManager.color(1, 1, 1, 1);
|
||||||
mod.renderCustomComponent(3, (int) settingY, 144, height, mouseX, mouseY);
|
mod.renderCustomComponent(3, (int) settingY, 144, height, mouseX, mouseY);
|
||||||
|
|
||||||
settingY += mod.customComponentHeight() + 30;
|
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") {
|
||||||
@ -159,7 +159,6 @@ public class ModSettings extends SilentScreen {
|
|||||||
newScrollY += amountScrolled;
|
newScrollY += amountScrolled;
|
||||||
else
|
else
|
||||||
newScrollY = 0;
|
newScrollY = 0;
|
||||||
Client.logger.info(String.format("newscroll: %s, scrollheight: %s, height: %s", newScrollY, scrollHeight, height));
|
|
||||||
if((newScrollY < scrollHeight && scrollHeight > height) || amountScrolled < 0) {
|
if((newScrollY < scrollHeight && scrollHeight > height) || amountScrolled < 0) {
|
||||||
this.scrollY = (float) newScrollY;
|
this.scrollY = (float) newScrollY;
|
||||||
if(this.scrollY < 0) {
|
if(this.scrollY < 0) {
|
||||||
|
@ -1,35 +1,21 @@
|
|||||||
package net.silentclient.client.mods.render;
|
package net.silentclient.client.mods.render;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.passive.EntityBat;
|
import net.minecraft.entity.passive.*;
|
||||||
import net.minecraft.entity.passive.EntityChicken;
|
|
||||||
import net.minecraft.entity.passive.EntityCow;
|
|
||||||
import net.minecraft.entity.passive.EntityHorse;
|
|
||||||
import net.minecraft.entity.passive.EntityOcelot;
|
|
||||||
import net.minecraft.entity.passive.EntityPig;
|
|
||||||
import net.minecraft.entity.passive.EntitySheep;
|
|
||||||
import net.minecraft.entity.passive.EntitySquid;
|
|
||||||
import net.minecraft.entity.passive.EntityVillager;
|
|
||||||
import net.minecraft.entity.passive.EntityWolf;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import net.minecraft.util.ResourceLocation;
|
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.RenderEvent;
|
import net.silentclient.client.event.impl.RenderEvent;
|
||||||
|
import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||||
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.MouseUtils;
|
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
|
||||||
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
|
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
|
||||||
import net.silentclient.client.gui.font.SilentFontRenderer;
|
|
||||||
import net.silentclient.client.gui.util.RenderUtil;
|
import net.silentclient.client.gui.util.RenderUtil;
|
||||||
import net.silentclient.client.mods.CustomFontRenderer;
|
import net.silentclient.client.mods.CustomFontRenderer;
|
||||||
import net.silentclient.client.mods.Mod;
|
import net.silentclient.client.mods.Mod;
|
||||||
@ -37,6 +23,10 @@ import net.silentclient.client.mods.ModCategory;
|
|||||||
import net.silentclient.client.mods.settings.RenderMod;
|
import net.silentclient.client.mods.settings.RenderMod;
|
||||||
import net.silentclient.client.utils.DisplayUtil;
|
import net.silentclient.client.utils.DisplayUtil;
|
||||||
import net.silentclient.client.utils.Sounds;
|
import net.silentclient.client.utils.Sounds;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class CrosshairMod extends Mod {
|
public class CrosshairMod extends Mod {
|
||||||
|
|
||||||
@ -119,8 +109,28 @@ public class CrosshairMod extends Mod {
|
|||||||
this.addBooleanSetting("Crosshair Dot", this, false);
|
this.addBooleanSetting("Crosshair Dot", this, false);
|
||||||
this.addBooleanSetting("Vanilla Blendering", this, true);
|
this.addBooleanSetting("Vanilla Blendering", this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public int customComponentHeight() {
|
||||||
|
boolean preset = Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean();
|
||||||
|
int height = 30;
|
||||||
|
|
||||||
|
if(preset) {
|
||||||
|
height += 30;
|
||||||
|
int crossIndex = 1;
|
||||||
|
for(@SuppressWarnings("unused") String presetID : Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset ID").getOptions()) {
|
||||||
|
crossIndex++;
|
||||||
|
if(crossIndex / 6 == 1) {
|
||||||
|
crossIndex = 1;
|
||||||
|
height += 30;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int customComponentLiteHeight() {
|
public int customComponentLiteHeight() {
|
||||||
boolean preset = Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean();
|
boolean preset = Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean();
|
||||||
int height = 30;
|
int height = 30;
|
||||||
@ -137,7 +147,7 @@ public class CrosshairMod extends Mod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -145,6 +155,96 @@ public class CrosshairMod extends Mod {
|
|||||||
return componentWidth;
|
return componentWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int customComponentWidth() {
|
||||||
|
return customComponentLiteWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
int widthComponent = 144;
|
||||||
|
int buttonWidth = (widthComponent) / 2;
|
||||||
|
boolean preset = Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean();
|
||||||
|
RenderUtils.drawRect(x, y, buttonWidth, 20, preset ? new Color(0, 0, 0).getRGB() : -1);
|
||||||
|
font.drawString("Custom", x + ((buttonWidth / 2) - (font.getStringWidth("Custom", 14, SilentFontRenderer.FontType.TITLE) / 2)), y + 3, preset ? -1 : new Color(0, 0, 0).getRGB(), 14);
|
||||||
|
RenderUtils.drawRect(x + buttonWidth, y, buttonWidth, 20, preset ? -1 : new Color(0, 0, 0).getRGB());
|
||||||
|
font.drawString("Preset", x + buttonWidth + ((buttonWidth / 2) - (font.getStringWidth("Preset", 14, SilentFontRenderer.FontType.TITLE) / 2)), y + 3, preset ? new Color(0, 0, 0).getRGB() : -1, 14);
|
||||||
|
componentWidth = width;
|
||||||
|
if(preset) {
|
||||||
|
int crossIndex = 1;
|
||||||
|
int spacing = 10;
|
||||||
|
int crossY = y + 25;
|
||||||
|
String selected = Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset ID").getValString();
|
||||||
|
RenderUtil.drawRoundedRect(x + spacing, crossY, 22, 22, 5, new Color(0, 0, 0).getRGB());
|
||||||
|
RenderUtil.drawRoundedOutline(x + spacing, crossY, 22, 22, 5, 3, -1);
|
||||||
|
|
||||||
|
RenderUtil.waitDrawImage(new ResourceLocation("silentclient/mods/crosshair/crosshair" + selected + ".png"), x + spacing + ((22 / 2) - (15 / 2)), crossY - 1 + ((22 / 2) - (15 / 2)), 15, 15, false);
|
||||||
|
spacing += 25;
|
||||||
|
crossIndex += 1;
|
||||||
|
for(String presetID : Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset ID").getOptions()) {
|
||||||
|
if(selected.equals(presetID)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
RenderUtil.drawRoundedRect(x + spacing, crossY, 22, 22, 5, new Color(0, 0, 0).getRGB());
|
||||||
|
|
||||||
|
if(MouseUtils.isInside(mouseX, mouseY, x + spacing, crossY, 22, 22)) {
|
||||||
|
RenderUtil.drawRoundedOutline(x + spacing, crossY, 22, 22, 5, 3, new Color(255, 255, 255, 127).getRGB());
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderUtil.waitDrawImage(new ResourceLocation("silentclient/mods/crosshair/crosshair" + presetID + ".png"), x + spacing + ((22 / 2) - (15 / 2)), crossY - 1 + ((22 / 2) - (15 / 2)), 15, 15, false);
|
||||||
|
spacing += 25;
|
||||||
|
crossIndex += 1;
|
||||||
|
if(crossIndex / 6 == 1) {
|
||||||
|
crossIndex = 1;
|
||||||
|
spacing = 10;
|
||||||
|
crossY += 30;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void customComponentClick(int x, int y, int mouseX, int mouseY, int mouseButton, GuiScreen screen) {
|
||||||
|
int widthComponent = 144;
|
||||||
|
int buttonWidth = (widthComponent) / 2;
|
||||||
|
if(MouseUtils.isInside(mouseX, mouseY, x, y, buttonWidth, 20)) {
|
||||||
|
Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").setValBoolean(false);
|
||||||
|
Sounds.playButtonSound();
|
||||||
|
}
|
||||||
|
if(MouseUtils.isInside(mouseX, mouseY, x + buttonWidth, y, buttonWidth, 20)) {
|
||||||
|
Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").setValBoolean(true);
|
||||||
|
Sounds.playButtonSound();
|
||||||
|
}
|
||||||
|
boolean preset = Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean();
|
||||||
|
if(preset) {
|
||||||
|
int crossIndex = 1;
|
||||||
|
int spacing = 10;
|
||||||
|
int crossY = y + 35;
|
||||||
|
spacing += 25;
|
||||||
|
crossIndex += 1;
|
||||||
|
String selected = Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset ID").getValString();
|
||||||
|
for(String presetID : Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset ID").getOptions()) {
|
||||||
|
if(presetID.equals(selected)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(MouseUtils.isInside(mouseX, mouseY, x + spacing, crossY - 1, 22, 22)) {
|
||||||
|
Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset ID").setValString(presetID);
|
||||||
|
}
|
||||||
|
spacing += 25;
|
||||||
|
crossIndex += 1;
|
||||||
|
if(crossIndex / 6 == 1) {
|
||||||
|
crossIndex = 1;
|
||||||
|
spacing = 10;
|
||||||
|
crossY += 30;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderCustomLiteComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
|
public void renderCustomLiteComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
|
||||||
CustomFontRenderer font = new CustomFontRenderer();
|
CustomFontRenderer font = new CustomFontRenderer();
|
||||||
@ -173,7 +273,7 @@ public class CrosshairMod extends Mod {
|
|||||||
if(selected.equals(presetID)) {
|
if(selected.equals(presetID)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
RenderUtil.drawRoundedRect(x + spacing, crossY - 1, x + spacing + 22, crossY - 1 + 22, 5, new Color(0, 0, 0).getRGB());
|
RenderUtil.drawRoundedRect(x + spacing, crossY - 1, 22, 22, 5, new Color(0, 0, 0).getRGB());
|
||||||
|
|
||||||
if(MouseUtils.isInside(mouseX, mouseY, x + spacing, crossY - 1, 22, 22)) {
|
if(MouseUtils.isInside(mouseX, mouseY, x + spacing, crossY - 1, 22, 22)) {
|
||||||
RenderUtil.drawRoundedOutline(x + spacing, crossY - 1, 22, 22, 5, 3, new Color(255, 255, 255, 127).getRGB());
|
RenderUtil.drawRoundedOutline(x + spacing, crossY - 1, 22, 22, 5, 3, new Color(255, 255, 255, 127).getRGB());
|
||||||
|
Loading…
Reference in New Issue
Block a user