mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 07:01:32 +01:00
(fix) implement color pickers in lite menus
This commit is contained in:
parent
f1b642c88d
commit
d2bba6f5f1
@ -8,6 +8,7 @@ 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.elements.HSBPicker;
|
||||
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;
|
||||
@ -38,12 +39,16 @@ public class GuiColorPicker extends SilentScreen {
|
||||
private final String value;
|
||||
private long initTime;
|
||||
|
||||
public GuiColorPicker(Mod mod, String value, GuiScreen parent) {
|
||||
private HSBPicker hsb;
|
||||
|
||||
public GuiColorPicker(Mod mod, String value, GuiScreen parentScreen) {
|
||||
if (mod == null) throw new IllegalArgumentException("Mod is null");
|
||||
|
||||
this.mod = mod;
|
||||
this.parentScreen = parent;
|
||||
this.parentScreen = parentScreen;
|
||||
this.value = value;
|
||||
float colorY = 80;
|
||||
int colorX = 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,21 +56,6 @@ public class GuiColorPicker extends SilentScreen {
|
||||
defaultCursor = false;
|
||||
this.initTime = System.currentTimeMillis();
|
||||
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));
|
||||
MenuBlurUtils.loadBlur();
|
||||
int addX = 190;
|
||||
int addY = 110;
|
||||
@ -74,6 +64,8 @@ public class GuiColorPicker extends SilentScreen {
|
||||
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"));
|
||||
hsb = new HSBPicker(x + 100, y + 70, 120, 70, true, value);
|
||||
hsb.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,33 +103,13 @@ public class GuiColorPicker extends SilentScreen {
|
||||
int spacing = 100;
|
||||
|
||||
Setting setting = Client.getInstance().getSettingsManager().getSettingByName(mod, this.value);
|
||||
|
||||
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(), setting.getOpacity()).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;
|
||||
}
|
||||
}
|
||||
|
||||
hsb.render(mouseX, mouseY);
|
||||
|
||||
setting.setValColor(hsb.getSelectedColorFinal());
|
||||
setting.setOpacity(hsb.getSelectedColorFinal().getAlpha());
|
||||
|
||||
int settingHeight = 10 + 5;
|
||||
settingY += settingHeight;
|
||||
if(setting.isCanChangeOpacity()) {
|
||||
settingY += settingHeight;
|
||||
Slider.render(x, settingY - 1, width, "Opacity", 255, setting.getOpacity());
|
||||
if (Slider.isDrag(mouseX, mouseY, x, settingY - 1, width) && (System.currentTimeMillis() - initTime) > 500) {
|
||||
double diff = 255 - 0;
|
||||
double mouse = MathHelper.clamp_double((mouseX - Slider.getLeft(x, width)) / 90D, 0, 1);
|
||||
double newVal = 0 + mouse * diff;
|
||||
setting.setOpacity((int) newVal);
|
||||
}
|
||||
}
|
||||
|
||||
settingY += settingHeight;
|
||||
|
||||
@ -196,19 +168,7 @@ public class GuiColorPicker extends SilentScreen {
|
||||
|
||||
Setting setting = Client.getInstance().getSettingsManager().getSettingByName(mod, this.value);
|
||||
|
||||
for(Color color : colors) {
|
||||
if(MouseUtils.isInside(mouseX, mouseY, x + spacing, settingY - 1, 22, 22) && mouseButton == 0) {
|
||||
Sounds.playButtonSound();
|
||||
Client.getInstance().getSettingsManager().getSettingByName(mod, this.value).setValColor(color);
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
}
|
||||
spacing += 25;
|
||||
colorIndex += 1;
|
||||
if(colorIndex == 5 || colorIndex == 10) {
|
||||
spacing = 100;
|
||||
settingY += 30;
|
||||
}
|
||||
}
|
||||
hsb.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
int settingHeight = 10 + 5;
|
||||
|
||||
@ -219,7 +179,13 @@ public class GuiColorPicker extends SilentScreen {
|
||||
setting.setChroma(!setting.isChroma());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
hsb.mouseReleased(mouseX, mouseY, state);
|
||||
super.mouseReleased(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
|
@ -16,6 +16,7 @@ import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils.Scroll;
|
||||
import net.silentclient.client.gui.elements.*;
|
||||
import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||
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.RenderUtil;
|
||||
@ -198,6 +199,10 @@ public class ModSettings extends SilentScreen {
|
||||
cursorType = MouseCursorHandler.CursorType.POINTER;
|
||||
}
|
||||
}
|
||||
if(setting.isCellGrid()) {
|
||||
CellGrid.render(mouseX, mouseY, x + 100, settingY, setting);
|
||||
settingY += 135;
|
||||
}
|
||||
if (setting.isSlider()) {
|
||||
Slider.render(x, settingY - 1, width, setting.getName(), setting.getMax(), setting.getValDouble());
|
||||
|
||||
@ -354,7 +359,9 @@ public class ModSettings extends SilentScreen {
|
||||
settingY += 5;
|
||||
inputIndex++;
|
||||
}
|
||||
|
||||
if(setting.isCellGrid()) {
|
||||
CellGrid.click(mouseX, mouseY, mouseButton, setting);
|
||||
}
|
||||
if(setting.isCombo()) {
|
||||
int index = 0;
|
||||
String curr = setting.getValString();
|
||||
@ -436,7 +443,17 @@ public class ModSettings extends SilentScreen {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
for (Setting setting : Client.getInstance().getSettingsManager().getSettingByMod(mod)) {
|
||||
if(setting.isCellGrid()) {
|
||||
CellGrid.release();
|
||||
}
|
||||
}
|
||||
super.mouseReleased(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
return !(this.mod instanceof TimeChangerMod);
|
||||
|
@ -73,6 +73,7 @@ public class ColorPicker extends SilentScreen {
|
||||
|
||||
float colorY = 66;
|
||||
hsb.render(mouseX, mouseY);
|
||||
setting.setOpacity(hsb.getSelectedColorFinal().getAlpha());
|
||||
|
||||
Client.getInstance().getSettingsManager().getSettingByName(mod, this.value).setValColor(hsb.getSelectedColorFinal());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user