From a9cf6dd924e4f4acf15cbbfc3d81bb869be386f7 Mon Sep 17 00:00:00 2001 From: retuci0 Date: Sun, 28 Dec 2025 00:58:08 +0100 Subject: [PATCH] v1.9.1 --- cambios.md | 21 +--- .../module/settings/NumberSetting.java | 12 +- .../camtweaks/ui/frames/ColorPickerFrame.java | 106 ++++++++---------- .../camtweaks/util/render/DrawUtil.java | 28 +++++ 4 files changed, 89 insertions(+), 78 deletions(-) diff --git a/cambios.md b/cambios.md index 7deaabc..b0643f1 100644 --- a/cambios.md +++ b/cambios.md @@ -1,32 +1,15 @@ -# v1.9 +# v1.9.1 ## novedades +- ARREGLADO EL SELECTOR DE COLORES ### adiciones -- tipo de ajuste específico para colores (el selector está muy roto, ya lo arreglaré) -- comando para espectar a jugadores o entidades (`$spec`) - #### módulos nuevos: -- reconectar: añade un botón para reconectarse a un servidor tras ser desconectado -- superposición de luz: te muestra en qué bloques pueden spawnear bichos -- yunques con pluma: te permite utilizar tipografías distintas al renombrar items en un yunque (a falta de formato) - ### arreglos / mejoras -- aviso de baja dur. ya funciona en servers de paper -- ahora puedes filtrar módulos también mediante la barra de búsqueda, además de que esta ahora funciona y tal -- los ajustes cuya visibilidad dependía de otros ajustes ahora se muestran correctamente -- ahora la posición de la barra de búsqueda es guardada en el config -- ya no te sigues moviendo en el freecam al estar moviéndote, abrir una interfaz y soltar las teclas de movimiento -- elemento del hud que muestra el ping en milisegundos (a veces no va) -- ya no se dibujan los tooltips de ajustes del marco de ajustes del mod si no está extendido -- el problema donde se restablecían las teclas a las de por defecto en módulos cuyas teclas ya estaban establecidas tras cada relaunch se ha solucionado -- puntos de desconexión ahora funciona y todo (gracias Meteor) -- alguna que otra cosilla más, supongo - ## problemas reconocidos - muchos, pero repórtalos en la página de problemas si quieres para que queden bien registrados \ No newline at end of file diff --git a/src/main/java/me/retucio/camtweaks/module/settings/NumberSetting.java b/src/main/java/me/retucio/camtweaks/module/settings/NumberSetting.java index 82a095e..a0c6f04 100644 --- a/src/main/java/me/retucio/camtweaks/module/settings/NumberSetting.java +++ b/src/main/java/me/retucio/camtweaks/module/settings/NumberSetting.java @@ -10,6 +10,7 @@ public class NumberSetting extends AbstractSetting { private double value; private double defaultValue; + private boolean locked; private final double min; private final double max; @@ -33,6 +34,7 @@ public class NumberSetting extends AbstractSetting { // como decía, el valor crece o decrece por el "increment" definido public void increment(boolean positive) { + if (locked) return; if (positive) value += increment; else value -= increment; value = clamp(value, min, max); @@ -57,7 +59,7 @@ public class NumberSetting extends AbstractSetting { } public void setValue(double value) { - if (this.value == value) return; + if (this.value == value || this.locked) return; double clamped = clamp(value, min, max); this.value = Math.round(clamped / increment) * increment; fireUpdateEvent(); @@ -88,6 +90,14 @@ public class NumberSetting extends AbstractSetting { return increment; } + public boolean isLocked() { + return locked; + } + + public void setLocked(boolean locked) { + this.locked = locked; + } + public void onUpdate(Consumer listener) { this.updateListener = listener; if (updateListener != null) updateListener.accept(value); diff --git a/src/main/java/me/retucio/camtweaks/ui/frames/ColorPickerFrame.java b/src/main/java/me/retucio/camtweaks/ui/frames/ColorPickerFrame.java index 802d6df..36824b3 100644 --- a/src/main/java/me/retucio/camtweaks/ui/frames/ColorPickerFrame.java +++ b/src/main/java/me/retucio/camtweaks/ui/frames/ColorPickerFrame.java @@ -31,7 +31,7 @@ public class ColorPickerFrame extends SettingsFrame { private int alphaPickerX, alphaPickerY, alphaPickerWidth, alphaPickerHeight; // ajustes - NumberSetting redSetting, greenSetting, blueSetting, alphaSetting; + NumberSetting redSetting, greenSetting, blueSetting; BooleanSetting rainbowSetting; NumberSetting rainbowSpeedSetting; NumberSetting saturationSetting, brightnessSetting; @@ -60,8 +60,6 @@ public class ColorPickerFrame extends SettingsFrame { greenSetting.setDefaultValue(colorSetting.getDefaultG()); blueSetting = new NumberSetting("azul", "cantidad de azul", colorSetting.getB(), 0, 255, 1); blueSetting.setDefaultValue(colorSetting.getDefaultB()); - alphaSetting = new NumberSetting("opacidad", "transparencia inversa", colorSetting.getA(), 0, 255, 1); - alphaSetting.setDefaultValue(colorSetting.getDefaultA()); // ajustes de arcoíris rainbowSetting = new BooleanSetting("arcoíris", "gay.", colorSetting.isRainbow()); @@ -74,10 +72,19 @@ public class ColorPickerFrame extends SettingsFrame { brightnessSetting.setDefaultValue(colorSetting.getDefaultBrightness()); // añadir ajustes y tal - dummyModule.addSettings(redSetting, greenSetting, blueSetting, alphaSetting, rainbowSetting, rainbowSpeedSetting, saturationSetting, brightnessSetting); + dummyModule.addSettings(redSetting, greenSetting, blueSetting, rainbowSpeedSetting, saturationSetting, brightnessSetting, rainbowSetting); for (AbstractSetting setting : dummyModule.getSettings()) { if (setting instanceof NumberSetting n) n.onUpdate(v -> updateColorFromSettings()); if (setting instanceof BooleanSetting b) b.onUpdate(v -> updateColorFromSettings()); + rainbowSetting.onUpdate(v -> { + updateColorFromSettings(); + redSetting.setVisible(!v); + greenSetting.setVisible(!v); + blueSetting.setVisible(!v); + rainbowSpeedSetting.setVisible(v); + saturationSetting.setVisible(v); + brightnessSetting.setVisible(v); + }); } settingButtons.clear(); @@ -112,6 +119,11 @@ public class ColorPickerFrame extends SettingsFrame { if (colorSetting == null) return; updateWidth(); + // al parecer este era el problema :/ + for (AbstractSetting setting : dummyModule.getSettings()) + if (setting instanceof NumberSetting ns) ns.setLocked( + pickingAlpha || pickingHue || pickingSaturationBrightness); + currentColor = colorSetting.getColor(); int padding = 5; @@ -137,6 +149,7 @@ public class ColorPickerFrame extends SettingsFrame { int previewWidth = w - 2 * padding; int previewHeight = 30; + // dimensiones saturationBrightnessPickerX = x + padding; saturationBrightnessPickerY = previewY + previewHeight + padding; saturationBrightnessPickerWidth = w - 2 * padding - 20; @@ -155,7 +168,7 @@ public class ColorPickerFrame extends SettingsFrame { int buttonAreaHeight = visibleButtons.size() * h; int bgX1 = x; - int bgY1 = y + h + 1; + int bgY1 = renderY + h + 1; int bgX2 = x + w; int bgY2 = bgY1 + previewHeight + saturationBrightnessPickerHeight + alphaPickerHeight + buttonAreaHeight + (padding * 6) - 11; @@ -183,6 +196,7 @@ public class ColorPickerFrame extends SettingsFrame { int hexWidth = mc.textRenderer.getWidth(hexText); ctx.drawText(mc.textRenderer, hexText, x + w / 2 - hexWidth / 2, previewY + previewHeight / 2 - mc.textRenderer.fontHeight / 2, -1, true); + // utilizar un gradiente combinado, para mejorar la optimización renderSaturationBrightnessGradient(ctx); DrawUtil.drawBorder(ctx, saturationBrightnessPickerX, saturationBrightnessPickerY, saturationBrightnessPickerWidth, saturationBrightnessPickerHeight, -1); @@ -200,7 +214,7 @@ public class ColorPickerFrame extends SettingsFrame { int indicatorY = saturationBrightnessPickerY + (int)((1 - hsb1[2]) * saturationBrightnessPickerHeight); DrawUtil.drawCircle(ctx, indicatorX, indicatorY, 3, -1); - // gradiente del "hue" - optimized + // gradiente del "hue" (no sé cómo se dice en castellano) for (int hy = 0; hy < huePickerHeight; hy += 2) { float hue = 1.0f - (hy / (float) huePickerHeight); Color hueColor = Color.getHSBColor(hue, 1.0f, 1.0f); @@ -217,7 +231,7 @@ public class ColorPickerFrame extends SettingsFrame { } renderAlphaGradient(ctx); - DrawUtil.drawBorder(ctx, alphaPickerX, alphaPickerY, alphaPickerWidth, alphaPickerHeight + 2, -1); + DrawUtil.drawBorder(ctx, alphaPickerX, alphaPickerY, alphaPickerWidth, alphaPickerHeight, -1); int alphaIndicatorX = alphaPickerX + (int)((colorSetting.getA() / 255f) * alphaPickerWidth); DrawUtil.drawCircle(ctx, alphaIndicatorX, alphaPickerY + alphaPickerHeight / 2, 3, -1); @@ -242,61 +256,38 @@ public class ColorPickerFrame extends SettingsFrame { } private void renderSaturationBrightnessGradient(DrawContext ctx) { - // dibujar en bloques en vez de píxeles - int blockSize = 4; // 4x4 (TRAVESTI ESCOTE REFERENCIA?!?!?!?) + float hue; + if (colorSetting.isRainbow()) { + hue = (System.currentTimeMillis() % (colorSetting.getRainbowSpeed() * 1000L)) + / (float) (colorSetting.getRainbowSpeed() * 1000L); + } else { + float[] hsb = Color.RGBtoHSB(colorSetting.getR(), colorSetting.getG(), colorSetting.getB(), null); + hue = hsb[0]; + } - for (int sx = 0; sx < saturationBrightnessPickerWidth; sx += blockSize) { - for (int sy = 0; sy < saturationBrightnessPickerHeight; sy += blockSize) { - int blockEndX = Math.min(sx + blockSize, saturationBrightnessPickerWidth); - int blockEndY = Math.min(sy + blockSize, saturationBrightnessPickerHeight); + // gradiente horizontal + for (int sx = 0; sx < saturationBrightnessPickerWidth; sx++) { + float saturation = sx / (float) saturationBrightnessPickerWidth; + Color colorAtX = Color.getHSBColor(hue, saturation, 1); + ctx.fill(saturationBrightnessPickerX + sx, saturationBrightnessPickerY, + saturationBrightnessPickerX + sx + 1, saturationBrightnessPickerY + saturationBrightnessPickerHeight, + colorAtX.getRGB()); + } - float saturation = (sx + (float) blockSize / 2) / (float) saturationBrightnessPickerWidth; - float brightness = 1 - ((sy + (float) blockSize / 2) / (float) saturationBrightnessPickerHeight); - - Color color; - if (colorSetting != null && colorSetting.isRainbow()) { - color = Colors.rainbowColor(colorSetting.getRainbowSpeed(), colorSetting.getA(), colorSetting.getSaturation(), colorSetting.getBrightness()); - } else { - float[] hsb = Color.RGBtoHSB(currentColor.getRed(), currentColor.getGreen(), currentColor.getBlue(), null); - color = Color.getHSBColor(hsb[0], saturation, brightness); - } - - ctx.fill(saturationBrightnessPickerX + sx, saturationBrightnessPickerY + sy, - saturationBrightnessPickerX + blockEndX, saturationBrightnessPickerY + blockEndY, - (colorSetting != null ? colorSetting.getA() : 255) << 24 | color.getRGB()); - } + // gradiente vertical + for (int sy = 0; sy < saturationBrightnessPickerHeight; sy++) { + float brightness = 1 - (sy / (float) saturationBrightnessPickerHeight); + int alpha = (int)(brightness * 255); + Color overlay = new Color(0, 0, 0, alpha); + ctx.fill(saturationBrightnessPickerX, saturationBrightnessPickerY + sy, + saturationBrightnessPickerX + saturationBrightnessPickerWidth, saturationBrightnessPickerY + sy + 1, + overlay.getRGB()); } } private void renderAlphaGradient(DrawContext ctx) { - int checkerSize = 4; - // dibujar casilleros alternando el tono de gris para el slider de la opacidad - for (int ax = 0; ax < alphaPickerWidth - 4; ax += checkerSize * 2) { - for (int ay = 0; ay < alphaPickerHeight; ay += checkerSize * 2) { - ctx.fill(alphaPickerX + ax, alphaPickerY + ay, - alphaPickerX + ax + checkerSize, alphaPickerY + ay + checkerSize, 0xFF333333); - - if (ax + checkerSize < alphaPickerWidth - 4 && ay + checkerSize < alphaPickerHeight) { - ctx.fill(alphaPickerX + ax + checkerSize, alphaPickerY + ay + checkerSize, - alphaPickerX + ax + checkerSize * 2, alphaPickerY + ay + checkerSize * 2, 0xFF333333); - } - } - } - - for (int ax = checkerSize; ax < alphaPickerWidth - 4; ax += checkerSize * 2) { - for (int ay = 0; ay < alphaPickerHeight; ay += checkerSize * 2) { - ctx.fill(alphaPickerX + ax, alphaPickerY + ay, - alphaPickerX + ax + checkerSize, alphaPickerY + ay + checkerSize, 0xFF666666); - } - } - - for (int ax = 0; ax < alphaPickerWidth - 4; ax += checkerSize * 2) { - for (int ay = checkerSize; ay < alphaPickerHeight; ay += checkerSize * 2) { - ctx.fill(alphaPickerX + ax, alphaPickerY + ay, - alphaPickerX + ax + checkerSize, alphaPickerY + ay + checkerSize, 0xFF666666); - } - } + DrawUtil.drawCheckerBoard(ctx, alphaPickerX + 1, alphaPickerY, alphaPickerWidth, alphaPickerHeight, 3, 0xFF333333, 0xFF666666); if (colorSetting != null) { int alphaWidth = (int)(alphaPickerWidth * (colorSetting.getA() / 255f)); @@ -311,7 +302,7 @@ public class ColorPickerFrame extends SettingsFrame { int stripEndX = Math.min(ax + stripWidth, alphaWidth); ctx.fill(alphaPickerX + ax, alphaPickerY, - alphaPickerX + stripEndX, alphaPickerY + alphaPickerHeight + 2, overlayColor.getRGB()); + alphaPickerX + stripEndX, alphaPickerY + alphaPickerHeight, overlayColor.getRGB()); } } } @@ -452,7 +443,6 @@ public class ColorPickerFrame extends SettingsFrame { alpha = Math.max(0, Math.min(255, alpha)); colorSetting.setA(alpha); - alphaSetting.setValue(alpha); } } @@ -467,7 +457,7 @@ public class ColorPickerFrame extends SettingsFrame { red = redSetting.getIntValue(); green = greenSetting.getIntValue(); blue = blueSetting.getIntValue(); - alpha = alphaSetting.getIntValue(); + alpha = colorSetting.getA(); rainbow = rainbowSetting.isEnabled(); rainbowSpeed = rainbowSpeedSetting.getIntValue(); saturation = saturationSetting.getFloatValue(); diff --git a/src/main/java/me/retucio/camtweaks/util/render/DrawUtil.java b/src/main/java/me/retucio/camtweaks/util/render/DrawUtil.java index 09953cb..4e2a55f 100644 --- a/src/main/java/me/retucio/camtweaks/util/render/DrawUtil.java +++ b/src/main/java/me/retucio/camtweaks/util/render/DrawUtil.java @@ -17,4 +17,32 @@ public class DrawUtil { if (i * i + j * j <= radius * radius) ctx.fill(x + i, y + j, x + i + 1, y + j + 1, color); } + + public static void drawCheckerBoard(DrawContext ctx, int x, int y, int width, int height, int checkerSize, int color1, int color2) { + for (int ax = 0; ax < width - 4; ax += checkerSize * 2) { + for (int ay = 0; ay < height; ay += checkerSize * 2) { + ctx.fill(x + ax, y + ay, + x + ax + checkerSize, y + ay + checkerSize, color1); + + if (ax + checkerSize < width - 4 && ay + checkerSize < height) { + ctx.fill(x + ax + checkerSize, y + ay + checkerSize, + x + ax + checkerSize * 2, y + ay + checkerSize * 2, color1); + } + } + } + + for (int ax = checkerSize; ax < width - 4; ax += checkerSize * 2) { + for (int ay = 0; ay < height; ay += checkerSize * 2) { + ctx.fill(x + ax, y + ay, + x + ax + checkerSize, y + ay + checkerSize, color2); + } + } + + for (int ax = 0; ax < width - 4; ax += checkerSize * 2) { + for (int ay = checkerSize; ay < height; ay += checkerSize * 2) { + ctx.fill(x + ax, y + ay, + x + ax + checkerSize, y + ay + checkerSize, color2); + } + } + } } \ No newline at end of file