Custom Resource Packs GUI

This commit is contained in:
kirillsaint 2023-11-05 14:12:22 +06:00
parent b0f4fef5f4
commit df9897f0f7
8 changed files with 565 additions and 22 deletions

View File

@ -1,21 +1,443 @@
package net.silentclient.client.gui.resourcepacks;
import com.google.common.collect.Lists;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.ResourcePackListEntry;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.ResourcePackRepository;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.silentclient.client.Client;
import net.silentclient.client.gui.SilentScreen;
import net.silentclient.client.gui.elements.Button;
import net.silentclient.client.gui.elements.IconButton;
import net.silentclient.client.gui.elements.Input;
import net.silentclient.client.gui.elements.TooltipIconButton;
import net.silentclient.client.gui.font.SilentFontRenderer;
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.util.RenderUtil;
import net.silentclient.client.utils.*;
import org.apache.commons.io.FilenameUtils;
import org.lwjgl.Sys;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.Collections;
import java.util.List;
public class SilentResourcePacksGui extends SilentScreen {
private final GuiScreen parentScreen;
private List<ResourcePackListEntry> availableResourcePacks;
private List<ResourcePackListEntry> selectedResourcePacks;
private List<ResourcePackRepository.Entry> availableResourcePacks;
private List<ResourcePackRepository.Entry> selectedResourcePacks;
private boolean changed = false;
private int blockX = 0;
private int blockY = 0;
private int blockWidth = 0;
private int blockHeight = 0;
private ScrollHelper scrollHelper = new ScrollHelper();
private ScrollHelper scrollHelper2 = new ScrollHelper();
public SilentResourcePacksGui(GuiScreen parentScreenIn)
{
this.parentScreen = parentScreenIn;
}
@Override
public void initGui() {
super.initGui();
this.defaultCursor = false;
Client.backgroundPanorama.updateWidthHeight(this.width, this.height);
this.buttonList.clear();
this.silentInputs.clear();
blockWidth = 400;
blockHeight = height - 20;
blockX = (width / 2) - (blockWidth / 2);
blockY = 10;
this.buttonList.add(new IconButton(1, blockX + blockWidth - 14 - 5, blockY + 5, 14, 14, 8, 8, new ResourceLocation("silentclient/icons/exit.png")));
if(mc.thePlayer != null) {
this.buttonList.add(new TooltipIconButton(2, blockX + blockWidth - 14 - 5, blockY + blockHeight - 5 - 14, 14, 14, 8, 8, new ResourceLocation("silentclient/icons/lightoverlay.png"), "Toggle Background Panorama"));
}
this.buttonList.add(new Button(3, blockX + 40, blockY + blockHeight - 5 - 14, 100, 14, "Open Pack Folder"));
this.buttonList.add(new Button(4, blockX + 40 + 100 + 5, blockY + blockHeight - 5 - 14, 100, 14, "Apply"));
this.buttonList.add(new Button(5, blockX + 40 + 100 + 5 + 100 + 5, blockY + blockHeight - 5 - 14, 100, 14, "Done"));
this.silentInputs.add(new Input("Search"));
if(!this.changed) {
this.availableResourcePacks = Lists.newArrayList();
this.selectedResourcePacks = Lists.newArrayList();
ResourcePackRepository resourcepackrepository = this.mc.getResourcePackRepository();
resourcepackrepository.updateRepositoryEntriesAll();
List<ResourcePackRepository.Entry> list = Lists.newArrayList(resourcepackrepository.getRepositoryEntriesAll());
list.removeAll(resourcepackrepository.getRepositoryEntries());
for (ResourcePackRepository.Entry resourcepackrepository$entry : list)
{
this.availableResourcePacks.add(resourcepackrepository$entry);
}
for (ResourcePackRepository.Entry resourcepackrepository$entry1 : Lists.reverse(resourcepackrepository.getRepositoryEntries()))
{
this.selectedResourcePacks.add(resourcepackrepository$entry1);
}
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList);
if(mc.thePlayer == null || Client.getInstance().getGlobalSettings().isPacksPanoramaEnabled()) {
GlStateManager.disableAlpha();
Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks);
GlStateManager.enableAlpha();
if(Client.getInstance().getGlobalSettings().isLite()) {
this.drawGradientRect(0, 0, this.width, this.height, new Color(0, 0, 0, 127).getRGB(), new Color(0, 0, 0, 200).getRGB());
} else {
this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE);
}
} else {
MenuBlurUtils.renderBackground(this);
}
RenderUtils.drawRect(blockX, blockY, blockWidth, blockHeight, Theme.backgroundColor().getRGB());
Client.getInstance().getSilentFontRenderer().drawString("Resource Packs", blockX + 5, blockY + 5, 14, SilentFontRenderer.FontType.TITLE);
MouseCursorHandler.CursorType cursorType1 = this.drawAvailableResourcePacks(blockX + 5, blockY + 14 + 5 + 2, mouseX, mouseY);
if(cursorType1 != null) {
cursorType = cursorType1;
}
MouseCursorHandler.CursorType cursorType2 = this.drawActiveResourcePacks(blockX + blockWidth - 193 - 5, blockY + 14 + 5 + 2, mouseX, mouseY);
if(cursorType2 != null) {
cursorType = cursorType2;
}
super.drawScreen(mouseX, mouseY, partialTicks);
Client.getInstance().getMouseCursorHandler().enableCursor(cursorType);
}
private MouseCursorHandler.CursorType drawAvailableResourcePacks(float x, float y, int mouseX, int mouseY) {
MouseCursorHandler.CursorType cursorType = null;
RenderUtil.drawRoundedOutline(x, y, 193, blockHeight - 45, 3, 1, Theme.borderColor().getRGB());
scrollHelper.setStep(5);
scrollHelper.setElementsHeight(availableResourcePacks.size() * 37 + 19);
scrollHelper.setMaxScroll(blockHeight - 45);
scrollHelper.setSpeed(100);
if(MouseUtils.isInside(mouseX, mouseY, x, y, 193, blockHeight - 45)) {
scrollHelper.setFlag(true);
} else {
scrollHelper.setFlag(false);
}
float itemY = y + 19 + scrollHelper.getScroll();
Scissor.start((int) x, (int) y, 193, blockHeight - 45);
Client.getInstance().getSilentFontRenderer().drawString("Available", x + 3, y + 3 + scrollHelper.getScroll(), 14, SilentFontRenderer.FontType.TITLE);
this.silentInputs.get(0).render(mouseX, mouseY, x + 193 - 3 - 100, y + 2 + scrollHelper.getScroll(), 100, true);
for(ResourcePackRepository.Entry entry : availableResourcePacks) {
if((!this.silentInputs.get(0).getValue().trim().equals("") && !entry.getResourcePackName().toLowerCase().contains(this.silentInputs.get(0).getValue().trim().toLowerCase()))) {
continue;
}
if(GuiUtils.blockInOtherBlock(x + 3, itemY, 187, 35, x, y, 193, blockHeight - 45)) {
int i = entry.func_183027_f();
boolean isHovered = MouseUtils.isInside(mouseX, mouseY, x, itemY, 187, 35);
RenderUtil.drawRoundedOutline(x + 3, itemY, 187, 35, 3, 1, i != 1 ? Color.RED.getRGB() : Theme.borderColor().getRGB());
if(isHovered) {
RenderUtil.drawRoundedRect(x + 3, itemY, 187, 35, 3, new Color(255, 255, 255, 30).getRGB());
cursorType = MouseCursorHandler.CursorType.POINTER;
}
entry.bindTexturePackIcon(mc.getTextureManager());
RenderUtil.drawImage(null, x + 5, itemY + 2, 31, 31, false);
String s = FilenameUtils.getBaseName(entry.getResourcePackName());
int i1 = this.mc.fontRendererObj.getStringWidth(s);
if (i1 > 153)
{
s = this.mc.fontRendererObj.trimStringToWidth(s, 153 - this.mc.fontRendererObj.getStringWidth("...")) + "...";
}
this.mc.fontRendererObj.drawStringWithShadow(s, x + 5 + 31 + 3, itemY + 3, 16777215);
List<String> list = this.mc.fontRendererObj.listFormattedStringToWidth(entry.getTexturePackDescription(), 153);
for (int l = 0; l < 2 && l < list.size(); ++l)
{
this.mc.fontRendererObj.drawStringWithShadow(list.get(l), x + 5 + 31 + 3, itemY + 3 + 12 + 10 * l, 8421504);
}
}
itemY += 37;
}
Scissor.end();
return cursorType;
}
private void availableResourcePacksClick(float x, float y, int mouseX, int mouseY) {
float itemY = y + 19 + scrollHelper.getScroll();
for(ResourcePackRepository.Entry entry : availableResourcePacks) {
if((!this.silentInputs.get(0).getValue().trim().equals("") && !entry.getResourcePackName().toLowerCase().contains(this.silentInputs.get(0).getValue().trim().toLowerCase()))) {
continue;
}
if(GuiUtils.blockInOtherBlock(x + 3, itemY, 187, 35, x, y, 193, blockHeight - 45)) {
boolean isHovered = MouseUtils.isInside(mouseX, mouseY, x, itemY, 187, 35);
if(isHovered) {
availableResourcePacks.remove(entry);
selectedResourcePacks.add(0, entry);
this.markChanged();
break;
}
}
itemY += 37;
}
}
private MouseCursorHandler.CursorType drawActiveResourcePacks(float x, float y, int mouseX, int mouseY) {
MouseCursorHandler.CursorType cursorType = null;
RenderUtil.drawRoundedOutline(x, y, 193, blockHeight - 45, 3, 1, Theme.borderColor().getRGB());
Scissor.start((int) x, (int) y, 193, blockHeight - 45);
scrollHelper2.setStep(5);
scrollHelper2.setElementsHeight(selectedResourcePacks.size() * 37 + 19);
scrollHelper2.setMaxScroll(blockHeight - 45);
scrollHelper2.setSpeed(100);
Client.getInstance().getSilentFontRenderer().drawString("Active", x + 3, y + 3 + scrollHelper2.getScroll(), 14, SilentFontRenderer.FontType.TITLE);
float itemY = y + 19 + scrollHelper2.getScroll();
int packIndex = 0;
for(ResourcePackRepository.Entry entry : selectedResourcePacks) {
if(GuiUtils.blockInOtherBlock(x + 3, itemY, 187, 35, x, y, 193, blockHeight - 45)) {
int i = entry.func_183027_f();
RenderUtil.drawRoundedOutline(x + 3, itemY, 187, 35, 3, 1, i != 1 ? Color.RED.getRGB() : Theme.borderColor().getRGB());
boolean isHovered = MouseUtils.isInside(mouseX, mouseY, x, itemY, 187, 35);
if(isHovered) {
RenderUtil.drawRoundedRect(x + 3, itemY, 187, 35, 3, new Color(255, 255, 255, 30).getRGB());
cursorType = MouseCursorHandler.CursorType.POINTER;
}
entry.bindTexturePackIcon(mc.getTextureManager());
RenderUtil.drawImage(null, x + 5, itemY + 2, 31, 31, false);
if(MouseUtils.isInside(mouseX, mouseY, x + 5, itemY + 2, 31, 31)) {
if(this.canUpSwap(packIndex)) {
RenderUtil.drawImage(new ResourceLocation("silentclient/icons/page-up.png"), x + 5 + (31 / 2) - (15 / 2), itemY + 2, 15, 15, true, MouseUtils.isInside(mouseX, mouseY, x + 5 + (31 / 2) - (15 / 2), itemY + 2, 15, 15) ? new Color(255, 255, 255).getRGB() : Theme.borderColor().getRGB());
}
if(this.canDownSwap(packIndex)) {
RenderUtil.drawImage(new ResourceLocation("silentclient/icons/page-down.png"), x + 5 + (31 / 2) - (15 / 2), itemY + 2 + 31 - 16, 15, 15, true, MouseUtils.isInside(mouseX, mouseY, x + 5 + (31 / 2) - (15 / 2), itemY + 2 + 31 - 16, 15, 15) ? new Color(255, 255, 255).getRGB() : Theme.borderColor().getRGB());
}
}
String s = FilenameUtils.getBaseName(entry.getResourcePackName());
int i1 = this.mc.fontRendererObj.getStringWidth(s);
if (i1 > 153)
{
s = this.mc.fontRendererObj.trimStringToWidth(s, 153 - this.mc.fontRendererObj.getStringWidth("...")) + "...";
}
this.mc.fontRendererObj.drawStringWithShadow(s, x + 5 + 31 + 3, itemY + 3, 16777215);
List<String> list = this.mc.fontRendererObj.listFormattedStringToWidth(entry.getTexturePackDescription(), 153);
for (int l = 0; l < 2 && l < list.size(); ++l)
{
this.mc.fontRendererObj.drawStringWithShadow(list.get(l), x + 5 + 31 + 3, itemY + 3 + 12 + 10 * l, 8421504);
}
}
itemY += 37;
packIndex++;
}
Scissor.end();
return cursorType;
}
public void activeResourcePacksClick(float x, float y, int mouseX, int mouseY) {
float itemY = y + 19 + scrollHelper2.getScroll();
int packIndex = 0;
for(ResourcePackRepository.Entry entry : selectedResourcePacks) {
if(GuiUtils.blockInOtherBlock(x + 3, itemY, 187, 35, x, y, 193, blockHeight - 45)) {
int i = entry.func_183027_f();
RenderUtil.drawRoundedOutline(x + 3, itemY, 187, 35, 3, 1, i != 1 ? Color.RED.getRGB() : Theme.borderColor().getRGB());
boolean isHovered = MouseUtils.isInside(mouseX, mouseY, x, itemY, 187, 35);
if(isHovered) {
if(MouseUtils.isInside(mouseX, mouseY, x + 5, itemY + 2, 31, 31)) {
if(this.canUpSwap(packIndex) && MouseUtils.isInside(mouseX, mouseY, x + 5 + (31 / 2) - (15 / 2), itemY + 2, 15, 15)) {
List<ResourcePackRepository.Entry> list1 = this.selectedResourcePacks;
int k = list1.indexOf(entry);
list1.remove(entry);
list1.add(k - 1, entry);
this.markChanged();
break;
}
if(this.canDownSwap(packIndex) && MouseUtils.isInside(mouseX, mouseY, x + 5 + (31 / 2) - (15 / 2), itemY + 2 + 31 - 16, 15, 15)) {
List<ResourcePackRepository.Entry> list = this.selectedResourcePacks;
int i2 = list.indexOf(entry);
list.remove(entry);
list.add(i2 + 1, entry);
this.markChanged();
break;
}
}
selectedResourcePacks.remove(entry);
availableResourcePacks.add(0, entry);
this.markChanged();
break;
}
}
itemY += 37;
packIndex++;
}
}
public void apply() {
if (this.changed)
{
this.scrollHelper2.resetScroll();
this.scrollHelper.resetScroll();
List<ResourcePackRepository.Entry> list = Lists.<ResourcePackRepository.Entry>newArrayList();
for (ResourcePackRepository.Entry resourcepacklistentry : this.selectedResourcePacks)
{
list.add(resourcepacklistentry);
}
Collections.reverse(list);
this.mc.getResourcePackRepository().setRepositories(list);
this.mc.gameSettings.resourcePacks.clear();
this.mc.gameSettings.incompatibleResourcePacks.clear();
for (ResourcePackRepository.Entry resourcepackrepository$entry : list)
{
this.mc.gameSettings.resourcePacks.add(resourcepackrepository$entry.getResourcePackName());
if (resourcepackrepository$entry.func_183027_f() != 1)
{
this.mc.gameSettings.incompatibleResourcePacks.add(resourcepackrepository$entry.getResourcePackName());
}
}
this.mc.gameSettings.saveOptions();
this.mc.refreshResources();
this.initGui();
this.scrollHelper2.resetScroll();
this.scrollHelper.resetScroll();
}
}
@Override
protected void actionPerformed(GuiButton button) throws IOException {
super.actionPerformed(button);
switch (button.id) {
case 1:
mc.displayGuiScreen(parentScreen);
break;
case 2:
Client.getInstance().getGlobalSettings().setPacksPanoramaEnabled(!Client.getInstance().getGlobalSettings().isPacksPanoramaEnabled());
Client.getInstance().getGlobalSettings().save();
break;
case 3:
File file1 = this.mc.getResourcePackRepository().getDirResourcepacks();
String s = file1.getAbsolutePath();
if (Util.getOSType() == Util.EnumOS.OSX)
{
try
{
Client.logger.info(s);
Runtime.getRuntime().exec(new String[] {"/usr/bin/open", s});
return;
}
catch (IOException ioexception1)
{
Client.logger.error("Couldn't open file", ioexception1);
}
}
else if (Util.getOSType() == Util.EnumOS.WINDOWS)
{
String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", s);
try
{
Runtime.getRuntime().exec(s1);
return;
}
catch (IOException ioexception)
{
Client.logger.error("Couldn't open file", ioexception);
}
}
boolean flag = false;
try
{
Class<?> oclass = Class.forName("java.awt.Desktop");
Object object = oclass.getMethod("getDesktop", new Class[0]).invoke(null);
oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, file1.toURI());
}
catch (Throwable throwable)
{
Client.logger.error("Couldn't open link", throwable);
flag = true;
}
if (flag)
{
Client.logger.info("Opening via system class!");
Sys.openURL("file://" + s);
}
break;
case 4:
this.apply();
break;
case 5:
this.apply();
mc.displayGuiScreen(parentScreen);
break;
}
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
this.silentInputs.get(0).onClick(mouseX, mouseY, blockX + 5 + 193 - 3 - 100, blockY + 14 + 5 + 2 + 2, 100, true);
this.availableResourcePacksClick(blockX + 5, blockY + 14 + 5 + 2, mouseX, mouseY);
this.activeResourcePacksClick(blockX + blockWidth - 193 - 5, blockY + 14 + 5 + 2, mouseX, mouseY);
}
@Override
public void handleMouseInput() throws IOException {
super.handleMouseInput();
}
@Override
public void updateScreen() {
super.updateScreen();
Client.backgroundPanorama.tickPanorama();
}
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
this.silentInputs.get(0).onKeyTyped(typedChar, keyCode);
if(this.silentInputs.get(0).isFocused()) {
this.scrollHelper.resetScroll();
}
}
public void markChanged()
{
this.changed = true;
}
public boolean canUpSwap(int index)
{
return index > 0;
}
public boolean canDownSwap(int index)
{
return index < this.selectedResourcePacks.size() - 1;
}
}

View File

@ -183,10 +183,12 @@ public class RenderUtil {
OpenGlHelper.glBlendFunc((int) 770, (int) 771, (int) 1, (int) 0);
GL11.glColor4f((float) 1.0f, (float) 1.0f, (float) 1.0f, 1f);
ColorUtils.setColor(color);
if(mip) {
Client.getInstance().getTextureManager().bindTextureMipmapped(image);
} else {
Minecraft.getMinecraft().getTextureManager().bindTexture(image);
if(image != null) {
if(mip) {
Client.getInstance().getTextureManager().bindTextureMipmapped(image);
} else {
Minecraft.getMinecraft().getTextureManager().bindTexture(image);
}
}
drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, width, height);
GL11.glDepthMask((boolean) true);
@ -221,10 +223,12 @@ public class RenderUtil {
GL11.glDepthMask((boolean) false);
OpenGlHelper.glBlendFunc((int) 770, (int) 771, (int) 1, (int) 0);
GL11.glColor4f((float) 1.0f, (float) 1.0f, (float) 1.0f, 1f);
if(mip) {
Client.getInstance().getTextureManager().bindTextureMipmapped(image);
} else {
((TextureManagerExt) Minecraft.getMinecraft().getTextureManager()).waitBindTexture(new StaticResourceLocation(image), new StaticResourceLocation("silentclient/transparent.png"));
if(image != null) {
if(mip) {
Client.getInstance().getTextureManager().bindTextureMipmapped(image);
} else {
((TextureManagerExt) Minecraft.getMinecraft().getTextureManager()).waitBindTexture(new StaticResourceLocation(image), new StaticResourceLocation("silentclient/transparent.png"));
}
}
Gui.drawModalRectWithCustomSizedTexture((int) x, (int) y, (float) 0.0f, (float) 0.0f, (int) width, (int) height, (float) width, (float) height);
GL11.glDepthMask((boolean) true);

View File

@ -23,6 +23,7 @@ import net.silentclient.client.event.impl.*;
import net.silentclient.client.gui.SilentScreen;
import net.silentclient.client.gui.lite.LiteMainMenu;
import net.silentclient.client.gui.multiplayer.SilentMultiplayerGui;
import net.silentclient.client.gui.resourcepacks.SilentResourcePacksGui;
import net.silentclient.client.gui.silentmainmenu.MainMenuConcept;
import net.silentclient.client.gui.util.BackgroundPanorama;
import net.silentclient.client.hooks.MinecraftHook;
@ -65,9 +66,6 @@ public abstract class MinecraftMixin implements MinecraftExt {
if(Client.backgroundPanorama == null) {
Client.backgroundPanorama = new BackgroundPanorama(Minecraft.getMinecraft());
}
// if(Client.getInstance().getGlobalSettings() != null) {
// displayGuiScreen(Client.getInstance().getGlobalSettings().isLite() ? new GuiNews() : new MainMenuConcept());
// }
}
@Override
@ -134,27 +132,34 @@ public abstract class MinecraftMixin implements MinecraftExt {
@Shadow private Timer timer;
@Inject(method = "displayGuiScreen", at = @At("RETURN"), cancellable = true)
@Inject(method = "displayGuiScreen", at = @At("HEAD"), cancellable = true)
public void displayGuiScreenInject(GuiScreen guiScreenIn, CallbackInfo ci) {
if(guiScreenIn instanceof SilentScreen) {
Client.logger.info("Opening menu: " + guiScreenIn.getClass().toString());
}
if(Client.backgroundPanorama == null) {
Client.backgroundPanorama = new BackgroundPanorama(Minecraft.getMinecraft());
}
if(guiScreenIn instanceof GuiMainMenu) {
if(Client.getInstance().getGlobalSettings() != null) {
displayGuiScreen(Client.getInstance().getGlobalSettings().isLite() ? new LiteMainMenu() : new MainMenuConcept());
}
if((guiScreenIn instanceof GuiMainMenu || (guiScreenIn == null && this.theWorld == null)) && Client.getInstance().getGlobalSettings() != null) {
displayGuiScreen(Client.getInstance().getGlobalSettings().isLite() ? new LiteMainMenu() : new MainMenuConcept());
ci.cancel();
return;
}
if(guiScreenIn instanceof GuiScreenResourcePacks) {
displayGuiScreen(new SilentResourcePacksGui(this.currentScreen));
ci.cancel();
return;
}
if(guiScreenIn instanceof GuiMultiplayer) {
displayGuiScreen(new SilentMultiplayerGui((GuiScreen) ((GuiMultiplayerExt) guiScreenIn).silent$getParentScreen()));
ci.cancel();
return;
}
if(guiScreenIn instanceof GuiIngameMenu) {
displayGuiScreen(new net.silentclient.client.gui.minecraft.GuiIngameMenu());
ci.cancel();
return;
}
if(guiScreenIn != null && guiScreenIn instanceof SilentScreen) {
Client.logger.info("Opening menu: " + guiScreenIn.getClass().toString());
}
}
/**

View File

@ -0,0 +1,9 @@
package net.silentclient.client.utils;
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
public class GuiUtils {
public static boolean blockInOtherBlock(float blockX, float blockY, int blockWidth, int blockHeight, float parentX, float parentY, int parentWidth, int parentHeight) {
return MouseUtils.isInside((int) blockX, (int) blockY, parentX, parentY, parentWidth, parentHeight) || MouseUtils.isInside((int) blockX, (int) blockY + blockHeight, parentX, parentY, parentWidth, parentHeight);
}
}

View File

@ -0,0 +1,22 @@
package net.silentclient.client.utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import org.lwjgl.opengl.GL11;
public class Scissor {
public static void start(int x, int y, int width, int height) {
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor(
x * sr.getScaleFactor(),
(sr.getScaledHeight() - y) * sr.getScaleFactor() - height * sr.getScaleFactor(),
width * sr.getScaleFactor(),
height * sr.getScaleFactor()
);
}
public static void end() {
GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
}

View File

@ -0,0 +1,71 @@
package net.silentclient.client.utils;
import net.minecraft.util.MathHelper;
import org.lwjgl.input.Mouse;
import net.minecraft.client.Minecraft;
public class ScrollHelper {
private float step = 0,real = 0,scroll = 0,elementsHeight = 0,maxScroll = 0,speed = 300F;
private boolean flag = true;
/**
Returns the smoothed scroll value, only call this once after you set all the setters
*/
public float getScroll() {
int wheel = Mouse.getDWheel();
float delta = 1f/Minecraft.getDebugFPS();
if(flag)
real -= wheel / 120f * step;
float divider = delta*2*Math.min(speed, elementsHeight);
if(scroll > real) {
scroll -= ((scroll - real) / 50) * divider;
}
if(scroll < real) {
scroll += ((real - scroll) / 50) * divider;
}
real = MathHelper.clamp_float(real, 0, elementsHeight > maxScroll ? elementsHeight - maxScroll : 0);
real = ((int)(real*100))/100f;
return -scroll;
}
public void resetScroll() {
this.scroll = 0;
this.real = 0;
}
/**
How much to increment each scroll
*/
public void setStep(float step) {
this.step = step;
}
/**
Height and gaps of all elements to be scrolled combined
*/
public void setElementsHeight(float elementsHeight) {
this.elementsHeight = elementsHeight;
}
/**
Maximum scroll, for example height of your scrollable panel
*/
public void setMaxScroll(float maxScroll) {
this.maxScroll = maxScroll;
}
/**
Speed of the scrolling
*/
public void setSpeed(float speed) {
this.speed = speed;
}
/**
Scrolling will only happen when this flag is true (be default its always true)
*/
public void setFlag(boolean flag) {
this.flag = flag;
}
}

View File

@ -9,11 +9,13 @@ public class GlobalSettings {
public boolean lite;
public boolean displayedTutorial;
public boolean configsMigrated;
public boolean packsPanoramaEnabled;
public GlobalSettings() {
this.config = "Default.txt";
this.lite = false;
this.displayedTutorial = false;
this.packsPanoramaEnabled = true;
}
public String getConfig() {
@ -45,6 +47,14 @@ public class GlobalSettings {
this.configsMigrated = configsMigrated;
}
public boolean isPacksPanoramaEnabled() {
return packsPanoramaEnabled;
}
public void setPacksPanoramaEnabled(boolean packsPanoramaEnabled) {
this.packsPanoramaEnabled = packsPanoramaEnabled;
}
public void save() {
try {
FileOutputStream outputStream = new FileOutputStream(Client.getInstance().getGlobalSettingsFile());

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB