mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 07:21:32 +01:00
(improve) better color picker
This commit is contained in:
parent
ef860979a3
commit
a57690e189
@ -3,7 +3,6 @@ package net.silentclient.client.gui.elements;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.silentclient.client.gui.animation.SimpleAnimation;
|
||||
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
|
||||
import net.silentclient.client.gui.util.RenderUtil;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
@ -24,11 +23,10 @@ public class HSBPicker extends Gui {
|
||||
public int cursorY;
|
||||
public boolean alphaSlider = true;
|
||||
|
||||
public String text;
|
||||
public SimpleAnimation sx = new SimpleAnimation(0f);
|
||||
public SimpleAnimation sy = new SimpleAnimation(0f);
|
||||
|
||||
public HSBPicker(int x, int y, int width, int height, boolean alphaSlider, String text) {
|
||||
public HSBPicker(int x, int y, int width, int height, boolean alphaSlider) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
@ -36,7 +34,6 @@ public class HSBPicker extends Gui {
|
||||
this.color = new float[]{0.4f, 1.0f, 1.0f, 1.0f};
|
||||
this.pickingColor = false;
|
||||
this.alphaSlider = alphaSlider;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
@ -16,9 +16,8 @@ import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||
import net.silentclient.client.gui.hud.HUDConfigScreen;
|
||||
import net.silentclient.client.gui.lite.clickgui.utils.GlUtils;
|
||||
import net.silentclient.client.gui.theme.Theme;
|
||||
import net.silentclient.client.gui.util.ColorPickerAction;
|
||||
import net.silentclient.client.gui.util.RenderUtil;
|
||||
import net.silentclient.client.mods.Mod;
|
||||
import net.silentclient.client.mods.Setting;
|
||||
import net.silentclient.client.utils.MenuBlurUtils;
|
||||
import net.silentclient.client.utils.MouseCursorHandler;
|
||||
import net.silentclient.client.utils.Sounds;
|
||||
@ -27,53 +26,47 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GuiColorPicker extends SilentScreen {
|
||||
private final Mod mod;
|
||||
private final GuiScreen parentScreen;
|
||||
|
||||
private ArrayList<Color> colors = new ArrayList<Color>();
|
||||
private final String value;
|
||||
private long initTime;
|
||||
|
||||
private HSBPicker hsb;
|
||||
private final Color defaultColor;
|
||||
private boolean chroma;
|
||||
private final boolean allowChangeOpacity;
|
||||
private int opacity;
|
||||
private ColorPickerAction action;
|
||||
|
||||
public GuiColorPicker(Mod mod, String value, GuiScreen parentScreen) {
|
||||
if (mod == null) throw new IllegalArgumentException("Mod is null");
|
||||
|
||||
this.mod = mod;
|
||||
public GuiColorPicker(Color defaultColor, boolean chroma, boolean allowChangeOpacity, int opacity, ColorPickerAction action, GuiScreen parentScreen) {
|
||||
this.parentScreen = parentScreen;
|
||||
this.value = value;
|
||||
float colorY = 80;
|
||||
int colorX = 3;
|
||||
this.defaultColor = defaultColor;
|
||||
this.allowChangeOpacity = allowChangeOpacity;
|
||||
this.chroma = chroma;
|
||||
this.opacity = opacity;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
defaultCursor = false;
|
||||
this.initTime = System.currentTimeMillis();
|
||||
colors.clear();
|
||||
MenuBlurUtils.loadBlur();
|
||||
int addX = 190;
|
||||
int addY = 110;
|
||||
int x = (width / 2) - addX;
|
||||
int y = (height / 2) - addY;
|
||||
int height = addY * 2;
|
||||
Setting setting = Client.getInstance().getSettingsManager().getSettingByName(mod, this.value);
|
||||
this.buttonList.add(new Button(1, x + 5, y + 25, 75, 20, "< Back"));
|
||||
this.buttonList.add(new Button(2, x + 5, (y + height) - 26, 75, 20, "Edit HUD"));
|
||||
hsb = new HSBPicker(x + 100, y + 40, 120, 70, false, value);
|
||||
float[] vals = Color.RGBtoHSB(setting.getValColor(true).getRed(),setting.getValColor(true).getGreen(), setting.getValColor(true).getBlue(), null);
|
||||
hsb.color = new float[] {vals[0],vals[1],vals[2], setting.getValColor(true).getAlpha() / 255.0f};
|
||||
hsb = new HSBPicker(x + 100, y + 40, 120, 70, false);
|
||||
float[] vals = Color.RGBtoHSB(defaultColor.getRed(), defaultColor.getGreen(), defaultColor.getBlue(), null);
|
||||
hsb.color = new float[] {vals[0],vals[1],vals[2], defaultColor.getAlpha() / 255.0f};
|
||||
hsb.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
if(mod.getName() == "Pack Tweaks" && mod.isEnabled()) {
|
||||
mc.renderGlobal.loadRenderers();
|
||||
}
|
||||
action.onClose(hsb.getSelectedColorFinal(), chroma, opacity);
|
||||
MenuBlurUtils.unloadBlur();
|
||||
super.onGuiClosed();
|
||||
}
|
||||
@ -92,24 +85,18 @@ public class GuiColorPicker extends SilentScreen {
|
||||
int width = addX * 2;
|
||||
int height = addY * 2;
|
||||
GlStateManager.pushMatrix();
|
||||
GlUtils.startScale(((x) + (x) + width) / 2, ((y) + (y + height)) / 2, (float) ClickGUI.introAnimation.getValue());
|
||||
GlUtils.startScale((float) ((x) + (x) + width) / 2, (float) ((y) + (y + height)) / 2, (float) ClickGUI.introAnimation.getValue());
|
||||
RenderUtil.drawRoundedRect(x, y, width, height, 10, Theme.backgroundColor().getRGB());
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
int settingY = y + 25;
|
||||
|
||||
int colorIndex = 0;
|
||||
int spacing = 100;
|
||||
|
||||
Setting setting = Client.getInstance().getSettingsManager().getSettingByName(mod, this.value);
|
||||
|
||||
setting.setValColor(hsb.getSelectedColorFinal());
|
||||
action.onChange(hsb.getSelectedColorFinal(), chroma, opacity);
|
||||
|
||||
int settingHeight = 10 + 5;
|
||||
|
||||
Checkbox.render(mouseX, mouseY, x + 100, settingY - 1, "Chroma", setting.isChroma());
|
||||
Checkbox.render(mouseX, mouseY, x + 100, settingY - 1, "Chroma", chroma);
|
||||
if(Checkbox.isHovered(mouseX, mouseY, x + 100, settingY - 1)) {
|
||||
cursorType = MouseCursorHandler.CursorType.POINTER;
|
||||
}
|
||||
@ -118,14 +105,14 @@ public class GuiColorPicker extends SilentScreen {
|
||||
|
||||
hsb.render(mouseX, mouseY);
|
||||
|
||||
if(setting.isCanChangeOpacity()) {
|
||||
if(allowChangeOpacity) {
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
Slider.render(x, settingY - 1, width, "Opacity", 255, setting.getOpacity());
|
||||
Slider.render(x, settingY - 1, width, "Opacity", 255, opacity);
|
||||
if (Slider.isDrag(mouseX, mouseY, x, settingY - 1, width) && (System.currentTimeMillis() - initTime) > 500) {
|
||||
double diff = 255;
|
||||
double mouse = MathHelper.clamp_double((double) (mouseX - Slider.getLeft(x, width)) / 90D, 0, 1);
|
||||
double newVal = 0 + mouse * diff;
|
||||
setting.setOpacity((int) newVal);
|
||||
opacity = (int) newVal;
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,7 +152,6 @@ public class GuiColorPicker extends SilentScreen {
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
int addX = 190;
|
||||
@ -174,16 +160,12 @@ public class GuiColorPicker extends SilentScreen {
|
||||
int x = (width / 2) - addX;
|
||||
int y = (height / 2) - addY;
|
||||
int settingY = y + 25;
|
||||
int colorIndex = 0;
|
||||
int spacing = 100;
|
||||
|
||||
Setting setting = Client.getInstance().getSettingsManager().getSettingByName(mod, this.value);
|
||||
|
||||
hsb.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
if(Checkbox.isHovered(mouseX, mouseY, x + 100, settingY - 1)) {
|
||||
Sounds.playButtonSound();
|
||||
setting.setChroma(!setting.isChroma());
|
||||
chroma = !chroma;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import net.silentclient.client.Client;
|
||||
import net.silentclient.client.gui.SilentScreen;
|
||||
import net.silentclient.client.gui.animation.SimpleAnimation;
|
||||
import net.silentclient.client.gui.animation.normal.Direction;
|
||||
import net.silentclient.client.gui.elements.Button;
|
||||
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.Scroll;
|
||||
@ -19,6 +20,7 @@ import net.silentclient.client.gui.hud.HUDConfigScreen;
|
||||
import net.silentclient.client.gui.modmenu.CellGrid;
|
||||
import net.silentclient.client.gui.theme.Theme;
|
||||
import net.silentclient.client.gui.theme.input.DefaultInputTheme;
|
||||
import net.silentclient.client.gui.util.ColorPickerAction;
|
||||
import net.silentclient.client.gui.util.RenderUtil;
|
||||
import net.silentclient.client.mods.Mod;
|
||||
import net.silentclient.client.mods.ModCategory;
|
||||
@ -32,6 +34,7 @@ import net.silentclient.client.utils.Sounds;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
@ -414,7 +417,16 @@ public class ModSettings extends SilentScreen {
|
||||
|
||||
if (setting.isColor() && ColorPicker.isHovered(mouseX, mouseY, x, settingY - 1, width)) {
|
||||
Sounds.playButtonSound();
|
||||
this.mc.displayGuiScreen(new GuiColorPicker(mod, setting.getName(), this));
|
||||
this.mc.displayGuiScreen(new GuiColorPicker(setting.getValColor(true), setting.isChroma(), setting.isCanChangeOpacity(), setting.getOpacity(), new ColorPickerAction() {
|
||||
@Override
|
||||
public void onChange(Color color, boolean chroma, int opacity) {
|
||||
setting.setValColor(color);
|
||||
setting.setChroma(chroma);
|
||||
if(setting.isCanChangeOpacity()) {
|
||||
setting.setOpacity(opacity);
|
||||
}
|
||||
}
|
||||
}, this));
|
||||
}
|
||||
|
||||
settingY += settingHeight;
|
||||
|
@ -9,39 +9,30 @@ import net.silentclient.client.gui.SilentScreen;
|
||||
import net.silentclient.client.gui.elements.Button;
|
||||
import net.silentclient.client.gui.elements.Checkbox;
|
||||
import net.silentclient.client.gui.elements.HSBPicker;
|
||||
import net.silentclient.client.gui.theme.button.DefaultButtonTheme;
|
||||
import net.silentclient.client.gui.theme.button.SelectedButtonTheme;
|
||||
import net.silentclient.client.mods.Mod;
|
||||
import net.silentclient.client.mods.ModCategory;
|
||||
import net.silentclient.client.mods.Setting;
|
||||
import net.silentclient.client.gui.util.ColorPickerAction;
|
||||
import net.silentclient.client.utils.MenuBlurUtils;
|
||||
import net.silentclient.client.utils.MouseCursorHandler;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ColorPicker extends SilentScreen {
|
||||
private long initTime;
|
||||
private final Mod mod;
|
||||
private final GuiScreen parentScreen;
|
||||
private ArrayList<Color> colors = new ArrayList<Color>();
|
||||
private final String value;
|
||||
private long initTime;
|
||||
private HSBPicker hsb;
|
||||
private final Color defaultColor;
|
||||
private boolean chroma;
|
||||
private final boolean allowChangeOpacity;
|
||||
private int opacity;
|
||||
private ColorPickerAction action;
|
||||
|
||||
public ColorPicker(Mod mod, String value, GuiScreen parentScreen) {
|
||||
if (mod == null) throw new IllegalArgumentException("Mod is null");
|
||||
|
||||
this.mod = mod;
|
||||
public ColorPicker(Color defaultColor, boolean chroma, boolean allowChangeOpacity, int opacity, ColorPickerAction action, GuiScreen parentScreen) {
|
||||
this.parentScreen = parentScreen;
|
||||
this.value = value;
|
||||
float colorY = 80;
|
||||
int colorX = 3;
|
||||
Setting setting = Client.getInstance().getSettingsManager().getSettingByName(mod, this.value);
|
||||
hsb = new HSBPicker((int)colorX, (int)colorY, 120, 70, false, value);
|
||||
float[] vals = Color.RGBtoHSB(setting.getValColor(true).getRed(),setting.getValColor(true).getGreen(), setting.getValColor(true).getBlue(), null);
|
||||
hsb.color = new float[] {vals[0],vals[1],vals[2], setting.getValColor(true).getAlpha() / 255.0f};
|
||||
hsb.init();
|
||||
this.defaultColor = defaultColor;
|
||||
this.allowChangeOpacity = allowChangeOpacity;
|
||||
this.chroma = chroma;
|
||||
this.opacity = opacity;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,22 +42,21 @@ public class ColorPicker extends SilentScreen {
|
||||
this.initTime = System.currentTimeMillis();
|
||||
this.buttonList.clear();
|
||||
this.silentInputs.clear();
|
||||
hsb = new HSBPicker(3, 80, 120, 70, false);
|
||||
float[] vals = Color.RGBtoHSB(defaultColor.getRed(), defaultColor.getGreen(), defaultColor.getBlue(), null);
|
||||
hsb.color = new float[] {vals[0],vals[1],vals[2], defaultColor.getAlpha() / 255.0f};
|
||||
hsb.init();
|
||||
|
||||
MenuBlurUtils.loadBlur();
|
||||
|
||||
ModMenu.initBaseButtons(this.buttonList);
|
||||
this.buttonList.add(new Button(1, 3, 26, 144, 15, "Back"));
|
||||
this.buttonList.add(new Button(2, 3, this.height - 18, mod.getCategory() == ModCategory.MODS ? 70 : 144, 15, "Reset"));
|
||||
if(mod.getCategory() == ModCategory.MODS) {
|
||||
this.buttonList.add(new Button(3, 76, this.height - 18, 70, 15, mod.isEnabled() ? "Enabled" : "Disabled", false, mod.isEnabled() ? new SelectedButtonTheme() : new DefaultButtonTheme()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
MenuBlurUtils.renderBackground(this);
|
||||
MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList);
|
||||
Setting setting = Client.getInstance().getSettingsManager().getSettingByName(mod, this.value);
|
||||
|
||||
ModMenu.drawOverlayListBase(height, "Choose a color");
|
||||
|
||||
@ -75,25 +65,25 @@ public class ColorPicker extends SilentScreen {
|
||||
ModMenu.trimContentStart(width, height);
|
||||
|
||||
float colorY = 66;
|
||||
Checkbox.render(mouseX, mouseY, 3, colorY, "Chroma", setting.isChroma());
|
||||
Checkbox.render(mouseX, mouseY, 3, colorY, "Chroma", chroma);
|
||||
if(Checkbox.isHovered(mouseX, mouseY, 3, colorY)) {
|
||||
cursorType = MouseCursorHandler.CursorType.POINTER;
|
||||
}
|
||||
|
||||
hsb.render(mouseX, mouseY);
|
||||
|
||||
action.onChange(hsb.getSelectedColorFinal(), chroma, opacity);
|
||||
|
||||
colorY += 100;
|
||||
|
||||
Client.getInstance().getSettingsManager().getSettingByName(mod, this.value).setValColor(hsb.getSelectedColorFinal());
|
||||
|
||||
if(setting.isCanChangeOpacity()) {
|
||||
if(allowChangeOpacity) {
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
RegularSlider.render(3, colorY, 144, "Opacity", 255, setting.getOpacity());
|
||||
RegularSlider.render(3, colorY, 144, "Opacity", 255, opacity);
|
||||
if (RegularSlider.isDrag(mouseX, mouseY, 3, colorY, 144) && (System.currentTimeMillis() - initTime) > 500) {
|
||||
double diff = 255;
|
||||
double mouse = MathHelper.clamp_double((mouseX - 3) / 144D, 0, 1);
|
||||
double newVal = 0 + mouse * diff;
|
||||
setting.setOpacity((int) newVal);
|
||||
opacity = (int) newVal;
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,30 +97,17 @@ public class ColorPicker extends SilentScreen {
|
||||
super.actionPerformed(button);
|
||||
ModMenu.clickBaseButtons(button, this);
|
||||
|
||||
switch (button.id) {
|
||||
case 1:
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
break;
|
||||
case 2:
|
||||
mod.reset(false);
|
||||
break;
|
||||
case 3:
|
||||
mod.toggle();
|
||||
button.displayString = mod.isEnabled() ? "Enabled" : "Disabled";
|
||||
if(button instanceof Button) {
|
||||
((Button) button).setTheme(mod.isEnabled() ? new SelectedButtonTheme() : new DefaultButtonTheme());
|
||||
}
|
||||
break;
|
||||
if (button.id == 1) {
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
Setting setting = Client.getInstance().getSettingsManager().getSettingByName(mod, this.value);
|
||||
float colorY = 66;
|
||||
if(Checkbox.isHovered(mouseX, mouseY, 3, colorY)) {
|
||||
setting.setChroma(!setting.isChroma());
|
||||
chroma = !chroma;
|
||||
}
|
||||
|
||||
hsb.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
@ -145,9 +122,7 @@ public class ColorPicker extends SilentScreen {
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
if(mod.getName() == "Pack Tweaks" && mod.isEnabled()) {
|
||||
mc.renderGlobal.loadRenderers();
|
||||
}
|
||||
action.onClose(hsb.getSelectedColorFinal(), chroma, opacity);
|
||||
MenuBlurUtils.unloadBlur();
|
||||
Client.getInstance().configManager.save();
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import net.silentclient.client.gui.theme.Theme;
|
||||
import net.silentclient.client.gui.theme.button.DefaultButtonTheme;
|
||||
import net.silentclient.client.gui.theme.button.SelectedButtonTheme;
|
||||
import net.silentclient.client.gui.theme.switches.DefaultSwitchTheme;
|
||||
import net.silentclient.client.gui.util.ColorPickerAction;
|
||||
import net.silentclient.client.gui.util.RenderUtil;
|
||||
import net.silentclient.client.mods.Mod;
|
||||
import net.silentclient.client.mods.ModCategory;
|
||||
@ -449,7 +450,24 @@ public class ModMenu extends SilentScreen {
|
||||
premiumY += 15;
|
||||
if(RegularColorPicker.isHovered(mouseX, mouseY, 3, (int) premiumY, 144)) {
|
||||
// Color Picker
|
||||
mc.displayGuiScreen(new PremiumColorPicker(this));
|
||||
mc.displayGuiScreen(new ColorPicker(Client.getInstance().getAccount().getBandanaColor() == 50 ? new Color(255, 255, 255) : new Color(Client.getInstance().getAccount().getBandanaColor()), Client.getInstance().getAccount().getBandanaColor() == 50, false, 255, new ColorPickerAction() {
|
||||
@Override
|
||||
public void onChange(Color color, boolean chroma, int opacity) {
|
||||
int colorInt = 0;
|
||||
colorInt = color.getRGB();
|
||||
if(chroma) {
|
||||
colorInt = 50;
|
||||
}
|
||||
if(Client.getInstance().getAccount().getBandanaColor() != colorInt) {
|
||||
Client.getInstance().getAccount().setBandanaColor(colorInt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(Color color, boolean chroma, int opacity) {
|
||||
Client.getInstance().getAccount().saveBandanaColor();
|
||||
}
|
||||
}, this));
|
||||
return;
|
||||
}
|
||||
premiumY += 15;
|
||||
|
@ -8,11 +8,13 @@ import net.silentclient.client.Client;
|
||||
import net.silentclient.client.gui.SilentScreen;
|
||||
import net.silentclient.client.gui.animation.SimpleAnimation;
|
||||
import net.silentclient.client.gui.elements.*;
|
||||
import net.silentclient.client.gui.elements.Button;
|
||||
import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||
import net.silentclient.client.gui.theme.button.DefaultButtonTheme;
|
||||
import net.silentclient.client.gui.theme.button.RedButtonTheme;
|
||||
import net.silentclient.client.gui.theme.button.SelectedButtonTheme;
|
||||
import net.silentclient.client.gui.theme.input.DefaultInputTheme;
|
||||
import net.silentclient.client.gui.util.ColorPickerAction;
|
||||
import net.silentclient.client.mods.Mod;
|
||||
import net.silentclient.client.mods.ModCategory;
|
||||
import net.silentclient.client.mods.Setting;
|
||||
@ -23,6 +25,7 @@ import net.silentclient.client.utils.MouseCursorHandler;
|
||||
import net.silentclient.client.utils.Sounds;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
@ -259,7 +262,16 @@ public class ModSettings extends SilentScreen {
|
||||
inputIndex++;
|
||||
}
|
||||
if (setting.isColor() && RegularColorPicker.isHovered(mouseX, mouseY, 3, (int) settingY, 144)) {
|
||||
mc.displayGuiScreen(new ColorPicker(mod, setting.getName(), this));
|
||||
mc.displayGuiScreen(new ColorPicker(setting.getValColor(true), setting.isChroma(), setting.isCanChangeOpacity(), setting.getOpacity(), new ColorPickerAction() {
|
||||
@Override
|
||||
public void onChange(Color color, boolean chroma, int opacity) {
|
||||
setting.setValColor(color);
|
||||
setting.setChroma(chroma);
|
||||
if(setting.isCanChangeOpacity()) {
|
||||
setting.setOpacity(opacity);
|
||||
}
|
||||
}
|
||||
}, this));
|
||||
}
|
||||
if (setting.isCheck()) {
|
||||
if(Switch.isHovered(mouseX, mouseY, 3, settingY)) {
|
||||
|
@ -1,149 +0,0 @@
|
||||
package net.silentclient.client.gui.modmenu;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.gui.SilentScreen;
|
||||
import net.silentclient.client.gui.elements.Button;
|
||||
import net.silentclient.client.gui.elements.Checkbox;
|
||||
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
|
||||
import net.silentclient.client.gui.util.RenderUtil;
|
||||
import net.silentclient.client.utils.MenuBlurUtils;
|
||||
import net.silentclient.client.utils.MouseCursorHandler;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PremiumColorPicker extends SilentScreen {
|
||||
private long initTime;
|
||||
private final GuiScreen parentScreen;
|
||||
private ArrayList<Color> colors = new ArrayList<Color>();
|
||||
|
||||
public PremiumColorPicker(GuiScreen parentScreen) {
|
||||
this.parentScreen = parentScreen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
defaultCursor = false;
|
||||
this.initTime = System.currentTimeMillis();
|
||||
this.buttonList.clear();
|
||||
this.silentInputs.clear();
|
||||
|
||||
MenuBlurUtils.loadBlur();
|
||||
|
||||
ModMenu.initBaseButtons(this.buttonList);
|
||||
this.buttonList.add(new Button(1, 3, 26, 144, 15, "Back"));
|
||||
|
||||
colors.clear();
|
||||
colors.add(new Color(255, 255, 255));
|
||||
colors.add(new Color(156, 157, 151));
|
||||
colors.add(new Color(71,79,82));
|
||||
colors.add(new Color(0, 0, 0));
|
||||
colors.add(new Color(255,216,61));
|
||||
colors.add(new Color(249,128,29));
|
||||
colors.add(new Color(176,46,38));
|
||||
colors.add(new Color(130,84,50));
|
||||
colors.add(new Color(128,199,31));
|
||||
colors.add(new Color(58,179,218));
|
||||
colors.add(new Color(22,156,157));
|
||||
colors.add(new Color(60,68,169));
|
||||
colors.add(new Color(243,140,170));
|
||||
colors.add(new Color(198,79,189));
|
||||
colors.add(new Color(137,50,183));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
MenuBlurUtils.renderBackground(this);
|
||||
|
||||
MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList);
|
||||
|
||||
ModMenu.drawOverlayListBase(height, "Choose a color");
|
||||
|
||||
ModMenu.trimContentStart(width, height);
|
||||
float colorY = 66;
|
||||
int colorX = 3;
|
||||
int colorIndex = 0;
|
||||
for(Color color : colors) {
|
||||
RenderUtil.drawRoundedRect(colorX, colorY, 20, 20, 3, new Color(color.getRed(), color.getGreen(), color.getBlue()).getRGB());
|
||||
RenderUtil.drawRoundedOutline(colorX, colorY, 20, 20, 3, 2, new Color(0, 0, 0).getRGB());
|
||||
if(MouseUtils.isInside(mouseX, mouseY, colorX, colorY, 20, 20)) {
|
||||
cursorType = MouseCursorHandler.CursorType.POINTER;
|
||||
}
|
||||
colorX += 25;
|
||||
colorIndex += 1;
|
||||
if(colorIndex == 6) {
|
||||
colorIndex = 0;
|
||||
colorX = 3;
|
||||
colorY += 25;
|
||||
}
|
||||
}
|
||||
|
||||
int settingHeight = 15;
|
||||
colorY += settingHeight;
|
||||
colorY += settingHeight;
|
||||
|
||||
Checkbox.render(mouseX, mouseY, 3, colorY, "Chroma", Client.getInstance().getAccount().getBandanaColor() == 50);
|
||||
|
||||
if(Checkbox.isHovered(mouseX, mouseY, 3, colorY)) {
|
||||
cursorType = MouseCursorHandler.CursorType.POINTER;
|
||||
}
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
|
||||
Client.getInstance().getMouseCursorHandler().enableCursor(cursorType);
|
||||
|
||||
ModMenu.trimContentEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
ModMenu.clickBaseButtons(button, this);
|
||||
|
||||
switch (button.id) {
|
||||
case 1:
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
float colorY = 66;
|
||||
int colorX = 3;
|
||||
int colorIndex = 0;
|
||||
for(Color color : colors) {
|
||||
if(MouseUtils.isInside(mouseX, mouseY, colorX, colorY, 20, 20)) {
|
||||
Client.getInstance().getAccount().setBandanaColor(color.getRGB());
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
}
|
||||
colorX += 25;
|
||||
colorIndex += 1;
|
||||
if(colorIndex == 6) {
|
||||
colorIndex = 0;
|
||||
colorX = 3;
|
||||
colorY += 25;
|
||||
}
|
||||
}
|
||||
|
||||
int settingHeight = 15;
|
||||
colorY += settingHeight;
|
||||
colorY += settingHeight;
|
||||
|
||||
if(Checkbox.isHovered(mouseX, mouseY, 3, colorY)) {
|
||||
Client.getInstance().getAccount().setBandanaColor(Client.getInstance().getAccount().getBandanaColor() == 50 ? -1 : 50);
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
MenuBlurUtils.unloadBlur();
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package net.silentclient.client.gui.util;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public interface ColorPickerAction {
|
||||
void onChange(Color color, boolean chroma, int opacity);
|
||||
default void onClose(Color color, boolean chroma, int opacity) {
|
||||
|
||||
}
|
||||
}
|
@ -1,35 +1,23 @@
|
||||
package net.silentclient.client.premium;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.gui.SilentScreen;
|
||||
import net.silentclient.client.gui.animation.normal.Direction;
|
||||
import net.silentclient.client.gui.lite.clickgui.ClickGUI;
|
||||
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.RenderUtils;
|
||||
import net.silentclient.client.gui.elements.Button;
|
||||
import net.silentclient.client.gui.elements.Checkbox;
|
||||
import net.silentclient.client.gui.elements.*;
|
||||
import net.silentclient.client.gui.elements.ColorPicker;
|
||||
import net.silentclient.client.gui.elements.Input;
|
||||
import net.silentclient.client.gui.elements.StaticButton;
|
||||
import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||
import net.silentclient.client.gui.hud.HUDConfigScreen;
|
||||
import net.silentclient.client.gui.theme.Theme;
|
||||
import net.silentclient.client.gui.lite.clickgui.GuiColorPicker;
|
||||
import net.silentclient.client.gui.util.ColorPickerAction;
|
||||
import net.silentclient.client.gui.util.RenderUtil;
|
||||
import net.silentclient.client.utils.ColorUtils;
|
||||
import net.silentclient.client.utils.MenuBlurUtils;
|
||||
import net.silentclient.client.utils.MouseCursorHandler;
|
||||
import net.silentclient.client.utils.Sounds;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PremiumGui {
|
||||
public static MouseCursorHandler.CursorType drawScreen(int x, int y, int width, int height, int mouseX, int mouseY, float partialTicks, Input input) {
|
||||
@ -105,7 +93,24 @@ public class PremiumGui {
|
||||
int settingY = y + 25;
|
||||
if(ColorPicker.isHovered(mouseX, mouseY, x, settingY, width)) {
|
||||
Sounds.playButtonSound();
|
||||
Minecraft.getMinecraft().displayGuiScreen(new PremiumGui.PremiumColorPicker(instance));
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiColorPicker(Client.getInstance().getAccount().getBandanaColor() == 50 ? new Color(255, 255, 255) : new Color(Client.getInstance().getAccount().getBandanaColor()), Client.getInstance().getAccount().getBandanaColor() == 50, false, 255, new ColorPickerAction() {
|
||||
@Override
|
||||
public void onChange(Color color, boolean chroma, int opacity) {
|
||||
int colorInt = 0;
|
||||
colorInt = color.getRGB();
|
||||
if(chroma) {
|
||||
colorInt = 50;
|
||||
}
|
||||
if(Client.getInstance().getAccount().getBandanaColor() != colorInt) {
|
||||
Client.getInstance().getAccount().setBandanaColor(colorInt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(Color color, boolean chroma, int opacity) {
|
||||
Client.getInstance().getAccount().saveBandanaColor();
|
||||
}
|
||||
}, instance));
|
||||
}
|
||||
settingY += 15;
|
||||
if(StaticButton.isHovered(mouseX, mouseY, x + 310, settingY, 65, 12)) {
|
||||
@ -132,176 +137,4 @@ public class PremiumGui {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PremiumColorPicker extends SilentScreen {
|
||||
private final GuiScreen parentScreen;
|
||||
|
||||
private ArrayList<Color> colors = new ArrayList<Color>();
|
||||
|
||||
public PremiumColorPicker(GuiScreen parent) {
|
||||
this.parentScreen = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
colors.clear();
|
||||
defaultCursor = false;
|
||||
colors.add(new Color(255, 255, 255));
|
||||
colors.add(new Color(156, 157, 151));
|
||||
colors.add(new Color(71,79,82));
|
||||
colors.add(new Color(0, 0, 0));
|
||||
colors.add(new Color(255,216,61));
|
||||
colors.add(new Color(249,128,29));
|
||||
colors.add(new Color(176,46,38));
|
||||
colors.add(new Color(130,84,50));
|
||||
colors.add(new Color(128,199,31));
|
||||
colors.add(new Color(58,179,218));
|
||||
colors.add(new Color(22,156,157));
|
||||
colors.add(new Color(60,68,169));
|
||||
colors.add(new Color(243,140,170));
|
||||
colors.add(new Color(198,79,189));
|
||||
colors.add(new Color(137,50,183));
|
||||
MenuBlurUtils.loadBlur();
|
||||
int addX = 190;
|
||||
int addY = 110;
|
||||
int x = (width / 2) - addX;
|
||||
int y = (height / 2) - addY;
|
||||
int height = addY * 2;
|
||||
this.buttonList.add(new Button(1, x + 5, y + 25, 75, 20, "< Back"));
|
||||
this.buttonList.add(new Button(2, x + 5, (y + height) - 26, 75, 20, "Edit HUD"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
MenuBlurUtils.unloadBlur();
|
||||
super.onGuiClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList);
|
||||
MenuBlurUtils.renderBackground(this);
|
||||
|
||||
int addX = 190;
|
||||
int addY = 110;
|
||||
|
||||
int x = (width / 2) - addX;
|
||||
int y = (height / 2) - addY;
|
||||
int width = addX * 2;
|
||||
int height = addY * 2;
|
||||
GlStateManager.pushMatrix();
|
||||
GlUtils.startScale(((x) + (x) + width) / 2, ((y) + (y + height)) / 2, (float) ClickGUI.introAnimation.getValue());
|
||||
RenderUtil.drawRoundedRect(x, y, width, height, 10, Theme.backgroundColor().getRGB());
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
int settingY = y + 25;
|
||||
|
||||
int colorIndex = 0;
|
||||
int spacing = 100;
|
||||
|
||||
for(Color color : colors) {
|
||||
RenderUtils.drawRect(x + spacing, settingY - 1, 22, 22, new Color(0, 0, 0).getRGB());
|
||||
RenderUtils.drawRect(x + spacing + 1, settingY - 1 + 1, 20, 20, new Color(color.getRed(), color.getGreen(), color.getBlue()).getRGB());
|
||||
if(MouseUtils.isInside(mouseX, mouseY, x + spacing, settingY - 1, 22, 22)) {
|
||||
cursorType = MouseCursorHandler.CursorType.POINTER;
|
||||
}
|
||||
spacing += 25;
|
||||
colorIndex += 1;
|
||||
if(colorIndex == 5 || colorIndex == 10) {
|
||||
spacing = 100;
|
||||
settingY += 30;
|
||||
}
|
||||
}
|
||||
|
||||
int settingHeight = 10 + 5;
|
||||
settingY += settingHeight;
|
||||
settingY += settingHeight;
|
||||
|
||||
Checkbox.render(mouseX, mouseY, x + 100, settingY - 1, "Chroma", Client.getInstance().getAccount().getBandanaColor() == 50);
|
||||
if(Checkbox.isHovered(mouseX, mouseY, x + 100, settingY - 1)) {
|
||||
cursorType = MouseCursorHandler.CursorType.POINTER;
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
RenderUtil.drawImage(new ResourceLocation("silentclient/logos/logo.png"), x + 5, y + 5, 77, 15);
|
||||
Client.getInstance().getSilentFontRenderer().drawString("Choose a color", x + 100, (int) (y + 5), 14, SilentFontRenderer.FontType.TITLE);
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
|
||||
if(ClickGUI.close) {
|
||||
ClickGUI.introAnimation.setDirection(Direction.BACKWARDS);
|
||||
if(ClickGUI.introAnimation.isDone(Direction.BACKWARDS)) {
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
}
|
||||
|
||||
Client.getInstance().getMouseCursorHandler().enableCursor(cursorType);
|
||||
|
||||
GlUtils.stopScale();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if(button.id == 1) {
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
}
|
||||
|
||||
if(button.id == 2) {
|
||||
mc.displayGuiScreen(new HUDConfigScreen(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
int addX = 190;
|
||||
int addY = 110;
|
||||
|
||||
int x = (width / 2) - addX;
|
||||
int y = (height / 2) - addY;
|
||||
|
||||
int settingY = y + 25;
|
||||
|
||||
int colorIndex = 0;
|
||||
int spacing = 100;
|
||||
|
||||
for(Color color : colors) {
|
||||
if(MouseUtils.isInside(mouseX, mouseY, x + spacing, settingY - 1, 22, 22) && mouseButton == 0) {
|
||||
Client.getInstance().getAccount().setBandanaColor(color.getRGB());
|
||||
Sounds.playButtonSound();
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
}
|
||||
spacing += 25;
|
||||
colorIndex += 1;
|
||||
if(colorIndex == 5 || colorIndex == 10) {
|
||||
spacing = 100;
|
||||
settingY += 30;
|
||||
}
|
||||
}
|
||||
|
||||
int settingHeight = 10 + 5;
|
||||
|
||||
settingY += settingHeight + settingHeight;
|
||||
|
||||
if(Checkbox.isHovered(mouseX, mouseY, x + 100, settingY - 1)) {
|
||||
Client.getInstance().getAccount().setBandanaColor(Client.getInstance().getAccount().getBandanaColor() == 50 ? -1 : 50);
|
||||
Sounds.playButtonSound();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
Sounds.playButtonSound();
|
||||
ClickGUI.close = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,12 +121,13 @@ public class PlayerResponse extends AbstractReply {
|
||||
if(Minecraft.getMinecraft().thePlayer != null) {
|
||||
Players.getPlayerStatus(false, ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getNameClear(), EntityPlayer.getUUID(Minecraft.getMinecraft().thePlayer.getGameProfile()), Minecraft.getMinecraft().thePlayer);
|
||||
}
|
||||
(new Thread() {
|
||||
public void run() {
|
||||
Requests.post("https://api.silentclient.net/plus/set_bandana_color", new JSONObject().put("color", color).toString());
|
||||
Client.getInstance().updateUserInformation();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void saveBandanaColor() {
|
||||
(new Thread(() -> {
|
||||
Requests.post("https://api.silentclient.net/plus/set_bandana_color", new JSONObject().put("color", bandana_color).toString());
|
||||
Client.getInstance().updateUserInformation();
|
||||
})).start();
|
||||
}
|
||||
|
||||
public int getSelectedHat() {
|
||||
|
Loading…
Reference in New Issue
Block a user