diff --git a/src/openonyx/ui/internal/ColorControl.java b/src/openonyx/ui/internal/ColorControl.java new file mode 100644 index 0000000..95ce7d4 --- /dev/null +++ b/src/openonyx/ui/internal/ColorControl.java @@ -0,0 +1,354 @@ +package openonyx.ui.internal; + +import openonyx.history.internal.ColorSetting; +import openonyx.render.Render2D; +import openonyx.render.group_d.Animation; +import openonyx.render.group_d.Easings; +import openonyx.theme.Fonts; +import openonyx.theme.ThemeManager; +import openonyx.theme.internal.ColorUtils; +import openonyx.ui.MaterialIcons; +import openonyx.ui.RenderContext; +import openonyx.ui.UiSupport_545; + +public class ColorControl extends SettingControl { + private final UiSupport_545 uiSupport_545; + private static final float W = 6.0F; + private float P; + private final Animation animation = new Animation(0.0F); + private static final float R = 1.0F; + private boolean p; + private float t; + private final ColorSetting colorSetting; + private static final int[] E; + private static final float F = 3.0F; + private static final float G = 11.0F; + private final UiSupport_545 uiSupport_5452; + private static final float K = 15.0F; + private static final float B = 12.0F; + private static final float C = 120.0F; + private static final float J = 0.32F; + private float D; + private static final float c = 9.0F; + private static final float a = 13.0F; + private final Animation animation2; + private int g; + private static final float M = 15.0F; + private ColorControlMode colorControlMode; + private static final float j = 14.0F; + private static final float m = 18.0F; + + private boolean D(float f, float g) { + return f >= this.f && f < this.f + this.e && gx >= this.d && gx < this.d + this.A(); + } + + private float K() { + return this.e - 30.0F * this.B() - 3.0F; + } + + private float b() { + return this.m() + 18.0F + 12.0F; + } + + private float C() { + return this.f + this.e - 11.0F - 8.0F - 9.0F; + } + + @Override + protected float L(RenderContext renderContext) { + ColorControl colorControl1 = this; + float gx = colorControl1.A(); + float f = colorControl1.h() ? 29.0F : 0.0F; + return gx + (colorControl1.l() - colorControl1.d + 120.0F + f + 6.0F - gx) * colorControl1.animation.getValue(); + } + + private void D() { + ColorControl colorControl1 = this; + if (colorControl1.colorSetting.getRawValue() != colorControl1.g) { + float[] f; + if ((f = ColorUtils.toRgbFloats(colorControl1.colorSetting.getRawValue()))[1] > 0.001F) { + colorControl1.D = f[0]; + } + + colorControl1.P = f[1]; + colorControl1.t = f[2]; + colorControl1.g = colorControl1.colorSetting.getRawValue(); + } + } + + private boolean d(float f, float g) { + ColorControl colorControl1 = this; + float h = colorControl1.G(); + return f >= colorControl1.f && f < colorControl1.f + colorControl1.e && gx >= h && gx < h + 15.0F; + } + + private void l(RenderContext renderContext) { + ColorControl colorControl1 = this; + Render2D render2D = renderContext.render2D; + float gx = colorControl1.l(); + float f = colorControl1.b(); + render2D.roundedRect(f, gx, 18.0F, 120.0F, Float.MAX_VALUE, colorControl1.L(renderContext.palette().surfaceContainerHighest())); + render2D.L(f, gx, 18.0F, 120.0F, Float.MAX_VALUE, colorControl1.L(colorControl1.colorSetting.I()), colorControl1.L(colorControl1.colorSetting.I()), 0, 0); + colorControl1.L(renderContext, f, gx + (1.0F - ColorUtils.alpha(colorControl1.colorSetting.getRawValue()) / 255.0F) * 120.0F); + } + + private boolean h() { + return this.colorSetting.h(); + } + + private float G() { + return this.l() + 120.0F + 14.0F; + } + + private void h(RenderContext renderContext) { + float f = this.l(); + switch (this.colorControlMode) { + case NONE: + while (false) { + } + + this.P = Math.clamp((renderContext.H - this.f) / this.K(), 0.0F, 1.0F); + this.t = 1.0F - Math.clamp((renderContext.f - f) / 120.0F, 0.0F, 1.0F); + this.d(); + return; + case SHADE: + this.D = Math.clamp((renderContext.f - f) / 120.0F, 0.0F, 1.0F) * 360.0F; + this.d(); + return; + case HUE: + float gx = 1.0F - Math.clamp((renderContext.f - f) / 120.0F, 0.0F, 1.0F); + this.g = ColorUtils.withAlpha(this.colorSetting.getRawValue(), gx); + this.colorSetting.setValue(this.g); + return; + } + } + + @Override + public boolean mouseReleased(float f, float g, int i) { + boolean bl = this.colorControlMode != ColorControlMode.NONE; + this.colorControlMode = ColorControlMode.NONE; + return bl; + } + + private float m() { + return this.f + this.K() + 12.0F; + } + + private void d() { + ColorControl colorControl1 = this; + int i; + colorControl1.g = i = ColorUtils.hsvToArgb(colorControl1.D, colorControl1.P, colorControl1.t, ColorUtils.alpha(colorControl1.colorSetting.getRawValue())); + colorControl1.colorSetting.setValue(i); + } + + @Override + public boolean mouseClicked(float f, float g, int i) { + if (!this.i() || i != 0) { + return false; + } + + if (this.D(f, gx)) { + this.p = !this.p; + this.animation.animateTo(this.p ? 1.0F : 0.0F, 300.0F, Easings.EASING2); + return true; + } + + if (this.animation.getValue() < 0.5F) { + return false; + } + + if (this.h() && this.d(f, gx)) { + this.colorSetting.d(!this.colorSetting.d()); + return true; + } + + if (this.colorSetting.d()) { + return false; + } + + if (this.L(f, gx, this.f, this.K())) { + this.colorControlMode = ColorControlMode.SHADE; + } else if (this.L(f, gx, this.m(), 18.0F)) { + this.colorControlMode = ColorControlMode.HUE; + } else { + if (!this.colorSetting.D() || !this.L(f, gx, this.b(), 18.0F)) { + return false; + } + + this.colorControlMode = ColorControlMode.ALPHA; + } + + return true; + } + + private void I(RenderContext renderContext) { + ColorControl colorControl1 = this; + Render2D render2D = renderContext.render2D; + float jx = colorControl1.G(); + float gx = colorControl1.f + colorControl1.e - 15.0F; + float h = jx + 0.0F; + float i = jx + 7.5F; + float f = colorControl1.animation2.getValue(); + colorControl1.uiSupport_5452 + .L(render2D, colorControl1.f - 6.0F, jx - 6.0F, colorControl1.e + 12.0F, 27.0F, 8.0F, colorControl1.L(renderContext.palette().onSurface())); + render2D.drawTextVCentered(Fonts.FONT_STYLE15, "Use accent colour", colorControl1.f, i, colorControl1.L(renderContext.palette().onSurface())); + if (f > 0.01F) { + float k = (1.0F - f) * 15.0F / 2.0F; + render2D.roundedRect(gx + k, h + k, 15.0F - k * 2.0F, 15.0F - k * 2.0F, 4.0F, colorControl1.L(renderContext.palette().primary())); + } + + if (f < 0.99F) { + render2D.roundedOutline(gx, h, 15.0F, 15.0F, 4.0F, 1.5F, colorControl1.L(renderContext.palette().onSurfaceVariant())); + } + + if (f > 0.15F) { + float l = Math.clamp((f - 0.15F) / 0.85F, 0.0F, 1.0F); + MaterialIcons.d( + render2D, gx + 7.5F, h + 7.5F, 13.0F * (0.7F + 0.3F * l), colorControl1.L(ThemeManager.withAlpha(renderContext.palette().onPrimary(), l)) + ); + } + } + + static { + int[] i = new int[7]; + boolean bl = true; + i[0] = -65536; + i[1] = -256; + i[2] = -16711936; + i[3] = -16711681; + i[4] = -16776961; + i[5] = -65281; + i[6] = -65536; + E = i; + } + + private float B() { + return this.colorSetting.D() ? 2.0F : 1.0F; + } + + @Override + public void update(RenderContext renderContext) { + super.update(renderContext); + this.animation.update(renderContext.i); + this.uiSupport_545.L(renderContext.i, this.D(renderContext.H, renderContext.f), false); + boolean bl = this.h() && this.animation.getValue() > 0.5F && this.d(renderContext.H, renderContext.f); + this.uiSupport_5452.L(renderContext.i, bl, false); + if (this.animation2.getTarget() != (this.colorSetting.d() ? 1.0F : 0.0F)) { + this.animation2.animateTo(this.colorSetting.d() ? 1.0F : 0.0F, 200.0F, Easings.EASING2); + } + + this.animation2.update(renderContext.i); + if (this.colorControlMode == ColorControlMode.NONE) { + this.D(); + } else { + this.h(renderContext); + } + } + + private boolean L(float f, float g, float h, float i) { + ColorControl colorControl1 = this; + float jx = colorControl1.l(); + return f >= h && f < h + i && gx >= jx && gx < jx + 120.0F; + } + + @Override + protected void d(RenderContext renderContext, float h) { + Render2D render2D = renderContext.render2D; + this.uiSupport_545.L(render2D, this.f - 6.0F, this.d, this.e + 12.0F, this.A(), 8.0F, this.L(renderContext.palette().onSurface())); + String string = this.colorSetting.i(); + float f = this.C() - 9.0F - 8.0F; + this.L(renderContext, f - render2D.getTextWidth(Fonts.FONT_STYLE2, string) - 12.0F - this.f); + render2D.drawTextRightVCentered(Fonts.FONT_STYLE2, string, f, this.I(), this.L(renderContext.palette().onSurfaceVariant())); + render2D.circle(this.C(), this.I(), 9.0F, this.L(this.colorSetting.getOpaque())); + render2D.L(this.C(), this.I(), 9.0F, 1.0F, this.L(renderContext.palette().outline())); + render2D.pushMatrix(); + render2D.transforms().d(this.f + this.e - 5.5F, this.I()); + render2D.transforms().L((float) Math.PI * this.animation.getValue()); + MaterialIcons.i(render2D, 0.0F, 0.0F, 11.0F, this.L(renderContext.palette().onSurfaceVariant())); + render2D.popMatrix(); + float gx = this.animation.getValue(); + if (!(gx <= 0.01F)) { + render2D.pushScissor(this.f - 6.0F, this.d, this.e + 12.0F, this.i); + render2D.pushAlpha(gx); + render2D.pushAlpha(1.0F - 0.68F * this.animation2.getValue()); + this.D(renderContext); + this.i(renderContext); + if (this.colorSetting.D()) { + this.l(renderContext); + } + + render2D.popAlpha(); + if (this.h()) { + this.I(renderContext); + } + + render2D.popAlpha(); + render2D.popScissor(); + } + } + + private void i(RenderContext renderContext) { + ColorControl colorControl1 = this; + Render2D render2D = renderContext.render2D; + float f = colorControl1.l(); + float gx = colorControl1.m(); + float h = 20.0F; + float i = 9.0F; + + for (int q = px = 0; q < 6; q = px) { + float jx; + float k = (jx = f + px * h) + h + (px == 5 ? 0.0F : 1.0F); + float l = px == 0 ? i : 0.0F; + float mx = px == 5 ? i : 0.0F; + int n = E[px]; + int o = ColorUtils.hsvToArgb((k - f) / 120.0F * 360.0F, 1.0F, 1.0F, 255); + float r = k - jx; + int s = colorControl1.L(n); + int tx = colorControl1.L(n); + int u = colorControl1.L(o); + px++; + render2D.L(gx, jx, 18.0F, r, l, l, mx, mx, s, tx, u, colorControl1.L(o)); + } + + colorControl1.L(renderContext, gx, f + colorControl1.D / 360.0F * 120.0F); + } + + private void L(RenderContext renderContext, float f, float g) { + ColorControl colorControl1 = this; + Render2D render2D = renderContext.render2D; + render2D.roundedRect(f - 3.0F, gx - 3.0F, 24.0F, 6.0F, Float.MAX_VALUE, colorControl1.L(-1)); + render2D.roundedOutline( + f - 3.0F, gx - 3.0F, 24.0F, 6.0F, Float.MAX_VALUE, 1.0F, colorControl1.L(ThemeManager.withAlpha(renderContext.palette().scrim(), 0.35F)) + ); + } + + private void D(RenderContext renderContext) { + ColorControl colorControl1 = this; + Render2D render2D = renderContext.render2D; + float gx = colorControl1.l(); + float f = colorControl1.K(); + int i = ColorUtils.hsvToArgb(colorControl1.D, 1.0F, 1.0F, 255); + render2D.L(colorControl1.f, gx, f, 120.0F, 12.0F, colorControl1.L(-1), colorControl1.L(i), colorControl1.L(i), colorControl1.L(-1)); + render2D.L(colorControl1.f, gx, f, 120.0F, 12.0F, 0, 0, colorControl1.L(-16777216), colorControl1.L(-16777216)); + render2D.roundedOutline(colorControl1.f, gx, f, 120.0F, 12.0F, 1.0F, colorControl1.L(renderContext.palette().outlineVariant())); + float jx = colorControl1.f + colorControl1.P * f; + float h = gx + (1.0F - colorControl1.t) * 120.0F; + render2D.circle(jx, h, 6.0F, colorControl1.L(-1)); + render2D.circle(jx, h, 4.5F, colorControl1.L(colorControl1.colorSetting.I())); + } + + public ColorControl(ColorSetting colorSetting) { + super(colorSettingx); + this.uiSupport_545 = new UiSupport_545(); + this.uiSupport_5452 = new UiSupport_545(); + this.animation2 = new Animation(0.0F); + this.colorControlMode = ColorControlMode.NONE; + this.colorSetting = colorSettingx; + float[] f; + this.D = (f = ColorUtils.toRgbFloats(colorSettingx.getRawValue()))[0]; + this.P = f[1]; + this.t = f[2]; + this.g = colorSettingx.getRawValue(); + this.animation2.set(colorSettingx.d() ? 1.0F : 0.0F); + } +} diff --git a/src/openonyx/ui/internal/ColorControlMode.java b/src/openonyx/ui/internal/ColorControlMode.java new file mode 100644 index 0000000..1220407 --- /dev/null +++ b/src/openonyx/ui/internal/ColorControlMode.java @@ -0,0 +1,18 @@ +package openonyx.ui.internal; + +enum ColorControlMode { + ALPHA, + NONE, + SHADE, + HUE; + + private static ColorControlMode[] L() { + ColorControlMode[] colorControlModes = new ColorControlMode[4]; + boolean bl = true; + colorControlModes[0] = NONE; + colorControlModes[1] = SHADE; + colorControlModes[2] = HUE; + colorControlModes[3] = ALPHA; + return colorControlModes; + } +} diff --git a/src/openonyx/ui/internal/ConfigList.java b/src/openonyx/ui/internal/ConfigList.java new file mode 100644 index 0000000..230c1ef --- /dev/null +++ b/src/openonyx/ui/internal/ConfigList.java @@ -0,0 +1,81 @@ +package openonyx.ui.internal; + +import java.util.Iterator; +import java.util.function.Consumer; +import openonyx.core.OnyxClient; +import openonyx.theme.Fonts; +import openonyx.ui.RenderContext; +import openonyx.ui.ScrollList; +import openonyx.ui.UiComponent; + +public class ConfigList extends ScrollList { + private static final float j = 9.0F; + private final Consumer configRowConsumer; + private static final float l = 5.0F; + private final Consumer configRowConsumer2; + private final Consumer configRowConsumer3; + + @Override + public boolean mouseClicked(float f, float g, int i) { + return this.contains(f, g) && super.mouseClicked(f, g, i); + } + + public ConfigList(Consumer consumer, Consumer consumer1, Consumer consumer2) { + this.configRowConsumer2 = consumer; + this.configRowConsumer = consumer1; + this.configRowConsumer3 = consumer2; + this.d(); + } + + public ConfigRow L() { + ConfigList configList1 = this; + UiComponent uiComponent; + return (uiComponent = configList1.L()) instanceof ConfigRow ? (ConfigRow)uiComponent : null; + } + + @Override + protected void i(RenderContext renderContext) { + float f = this.d - this.animation.getValue(); + + Iterator iterator; + for (Iterator iterator1 = iterator = this.uiComponents.iterator(); iterator1.hasNext(); iterator1 = iterator) { + ((UiComponent)iterator.next()).setBounds(this.f, f, this.e - 9.0F, 50.0F); + f += 55.0F; + } + + this.I = this.uiComponents.isEmpty() ? 0.0F : this.uiComponents.size() * 55.0F - 5.0F; + } + + @Override + public void render(RenderContext renderContext) { + if (this.uiComponents.isEmpty()) { + renderContext.render2D + .drawTextCenteredVCentered( + Fonts.getFontstylE15(), "No configs saved yet", this.f + this.e / 2.0F, this.d + this.i / 2.0F, renderContext.palette().onSurfaceVariant() + ); + } else { + super.render(renderContext); + } + } + + @Override + public void d() { + ConfigList configList1 = this; + configList1.uiComponents.clear(); + configList1.D(); + configList1.m = 0.0F; + configList1.animation.set(0.0F); + Iterator iterator = OnyxClient.configManager.L().iterator(); + Iterator iterator1 = iterator; + + while (iterator1.hasNext()) { + String string = (String)iterator.next(); + iterator1 = iterator; + configList1.uiComponents.add(new ConfigRow(string, configList1.configRowConsumer2, configList1.configRowConsumer, configList1.configRowConsumer3)); + } + } + + public int D() { + return this.uiComponents.size(); + } +} diff --git a/src/openonyx/ui/internal/ConfigRow.java b/src/openonyx/ui/internal/ConfigRow.java new file mode 100644 index 0000000..2fc90c2 --- /dev/null +++ b/src/openonyx/ui/internal/ConfigRow.java @@ -0,0 +1,146 @@ +package openonyx.ui.internal; + +import java.util.function.Consumer; +import openonyx.core.OnyxClient; +import openonyx.render.Render2D; +import openonyx.render.group_d.ColorAnimation; +import openonyx.render.group_d.Easings; +import openonyx.theme.Fonts; +import openonyx.theme.ThemeManager; +import openonyx.ui.RenderContext; +import openonyx.ui.UiComponent; +import openonyx.ui.UiSupport_545; + +public class ConfigRow extends UiComponent { + private static final float g = 6.0F; + private final UiButton uiButton; + private final UiSupport_602 uiSupport_602; + private boolean j; + private final String m; + public static final float h = 50.0F; + private static final float l = 8.0F; + private static final float I = 76.0F; + private final Consumer configRowConsumer; + private final UiSupport_545 uiSupport_545 = new UiSupport_545(); + private final Consumer configRowConsumer2; + private final ColorAnimation colorAnimation = new ColorAnimation(0); + private final Consumer configRowConsumer3; + + @Override + public boolean mouseReleased(float f, float g, int i) { + this.H = false; + return super.mouseReleased(f, gx, i); + } + + public String L() { + return this.m; + } + + @Override + public void render(RenderContext renderContext) { + ConfigRow configRow1 = this; + Render2D render2D = renderContext.render2D; + boolean bl = configRow1.i(); + render2D.roundedRect(configRow1.f, configRow1.d, configRow1.e, configRow1.i, 12.0F, configRow1.colorAnimation.L()); + configRow1.uiSupport_545.L(render2D, configRow1.f, configRow1.d, configRow1.e, configRow1.i, 12.0F, renderContext.palette().onSurface()); + float f = configRow1.f + 12.0F; + float gx = configRow1.uiButton.d() - 6.0F - f; + String string = bl ? "Loaded" : "Saved config"; + int i = bl ? renderContext.palette().onSecondaryContainer() : renderContext.palette().onSurface(); + int jx = bl ? ThemeManager.withAlpha(renderContext.palette().onSecondaryContainer(), 0.72F) : renderContext.palette().onSurfaceVariant(); + render2D.drawTextVCentered( + Fonts.getFontstylE14(), render2D.trimToWidth(Fonts.getFontstylE14(), configRow1.m, gx), f, configRow1.d + configRow1.i * 0.33F, i + ); + render2D.drawTextVCentered(Fonts.getFontstylE2(), string, f, configRow1.d + configRow1.i * 0.7F, jx); + configRow1.render(renderContext); + } + + public ConfigRow(String string, Consumer consumer, Consumer consumer1, Consumer consumer2) { + this.m = string; + this.configRowConsumer = consumer; + this.configRowConsumer3 = consumer1; + this.configRowConsumer2 = consumer2; + this.uiButton = new UiButton(UiButtonMode.TEXT, "Load", "\ue2c4", () -> { + if (this.i()) { + this.configRowConsumer3.accept(this); + } else { + this.configRowConsumer.accept(this); + } + }); + this.uiSupport_602 = new UiSupport_602("\ue5d4", () -> consumer2.accept(this)); + this.i = 50.0F; + this.uiComponents.add(this.uiButton); + this.uiComponents.add(this.uiSupport_602); + } + + @Override + public boolean mouseClicked(float f, float g, int i) { + if (this.uiButton.mouseClicked(f, gx, i)) { + return true; + } + + if (this.uiSupport_602.mouseClicked(f, gx, i)) { + return true; + } + + if (!this.contains(f, gx)) { + return false; + } + + if (i == 0) { + this.H = true; + if (!this.i()) { + this.configRowConsumer.accept(this); + } + + return true; + } else if (i == 1) { + this.configRowConsumer2.accept(this); + return true; + } else { + return false; + } + } + + @Override + public void update(RenderContext renderContext) { + ConfigRow configRow1 = this; + boolean bl = configRow1.i(); + configRow1.uiButton.L(bl ? "Save" : "Load"); + configRow1.uiButton.d(bl ? "\ue161" : "\ue2c4"); + configRow1.update(renderContext); + int i = bl ? renderContext.palette().secondaryContainer() : renderContext.palette().surfaceContainerHigh(); + if (!configRow1.j) { + configRow1.j = true; + configRow1.colorAnimation.L(i); + } + + configRow1.colorAnimation.L(i, 250.0F, Easings.EASING6); + configRow1.colorAnimation.L(renderContext.i); + boolean bl1; + ConfigRow configRow2; + if (configRow1.h && !configRow1.uiButton.D() && !configRow1.uiSupport_602.D()) { + bl1 = true; + configRow2 = configRow1; + } else { + bl1 = false; + configRow2 = configRow1; + } + + configRow1.uiSupport_545.L(renderContext.i, bl1, configRow2.H); + } + + @Override + protected void L() { + this.uiSupport_602.setBounds(this.f + this.e - 30.0F - 8.0F, this.d + (this.i - 30.0F) / 2.0F, 30.0F, 30.0F); + this.uiButton.setBounds(this.uiSupport_602.d() - 6.0F - 76.0F, this.d + (this.i - 30.0F) / 2.0F, 76.0F, 30.0F); + } + + private boolean i() { + return OnyxClient.configManager.I(this.m); + } + + public UiComponent getUiSupport_602() { + return this.uiSupport_602; + } +} diff --git a/src/openonyx/ui/internal/ConfigsPanel.java b/src/openonyx/ui/internal/ConfigsPanel.java new file mode 100644 index 0000000..af79e51 --- /dev/null +++ b/src/openonyx/ui/internal/ConfigsPanel.java @@ -0,0 +1,380 @@ +package openonyx.ui.internal; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import openonyx.core.OnyxClient; +import openonyx.input.CharInput; +import openonyx.input.KeyInput; +import openonyx.misc.ConfigManager; +import openonyx.misc.ConfigManagerData; +import openonyx.render.Render2D; +import openonyx.ui.KeyShortcuts; +import openonyx.ui.RenderContext; +import openonyx.ui.UiComponent; + +public class ConfigsPanel extends UiComponent { + private final ConfigList configList; + private static final float J = 120.0F; + private final SearchField searchField = new SearchField("Config name"); + private static final float c = 10.0F; + private final UiSupport_571 uiSupport_571; + private final UiSupport_578 uiSupport_578; + private ConfigRow configRow; + private String M; + private boolean L; + private final UiButton uiButton = new UiButton(UiButtonMode.TONAL, "New", "\ue145", () -> { + ConfigsPanel configsPanel1 = this; + String string1; + if (!(string1 = configsPanel1.searchField.L().trim()).isEmpty() && !configsPanel1.L().h(string1)) { + configsPanel1.uiSupport_571.L("Use 1-64 letters, digits, - or _", "\ue001"); + } else if (!string1.isEmpty() && configsPanel1.L().i(string1)) { + configsPanel1.uiSupport_571.L("Config already exists; use its menu to overwrite", "\ue001"); + } else { + String string = string1.isEmpty() ? configsPanel1.L().D("new") : string1; + if (string != null && configsPanel1.L().l(string)) { + configsPanel1.configList.d(); + configsPanel1.searchField.L(""); + configsPanel1.searchField.D(false); + configsPanel1.uiSupport_571.L(new StringBuilder().insert(0, "Created ").append(string).toString()); + } else { + configsPanel1.uiSupport_571.L("Could not create a config", "\ue001"); + } + } + }); + private List strings; + private final UiButton uiButton2 = new UiButton(UiButtonMode.OUTLINED, "Save as", "\ue161", () -> { + ConfigsPanel configsPanel1 = this; + String string = configsPanel1.searchField.L().trim(); + if (!configsPanel1.L().h(string)) { + configsPanel1.uiSupport_571.L("Use 1-64 letters, digits, - or _", "\ue001"); + } else if (configsPanel1.L().i(string)) { + configsPanel1.uiSupport_571.L("Config already exists; use its menu to overwrite", "\ue001"); + } else if (!configsPanel1.L().F(string)) { + configsPanel1.uiSupport_571.L(new StringBuilder().insert(0, "Could not save ").append(string).toString(), "\ue001"); + } else { + configsPanel1.configList.d(); + configsPanel1.searchField.L(""); + configsPanel1.searchField.D(false); + configsPanel1.uiSupport_571.L(new StringBuilder().insert(0, "Saved ").append(string).toString()); + } + }); + private final Set strings2; + private static final float I = 8.0F; + private final UiSupport_578 uiSupport_5782; + private final UiButton uiButton3 = new UiButton(UiButtonMode.TEXT, "Open folder", "\ue2c8", () -> { + this.L().d(); + this.uiSupport_571.L("Opened config folder"); + }); + + @Override + public boolean mouseReleased(float f, float g, int i) { + return this.searchField.mouseReleased(f, g, i) + | this.uiButton.mouseReleased(f, g, i) + | this.uiButton2.mouseReleased(f, g, i) + | this.uiButton3.mouseReleased(f, g, i) + | this.configList.mouseReleased(f, g, i); + } + + private void H(ConfigRow configRow) { + ConfigsPanel configsPanel1 = this; + String string; + if ((string = configsPanel1.L().d(configRowx.L())) == null) { + configsPanel1.uiSupport_571.L(new StringBuilder().insert(0, "Could not duplicate ").append(configRowx.L()).toString(), "\ue001"); + } else { + configsPanel1.configList.d(); + configsPanel1.uiSupport_571.L(new StringBuilder().insert(0, "Duplicated as ").append(string).toString()); + } + } + + private void e(ConfigRow configRow) { + String string = configRowx.L(); + if (this.L().L(string)) { + this.configList.d(); + this.uiSupport_571.L(new StringBuilder().insert(0, "Deleted ").append(string).toString()); + } else { + this.uiSupport_571.L(new StringBuilder().insert(0, "Could not delete ").append(string).toString(), "\ue001"); + } + } + + private void k(ConfigRow configRow) { + this.strings = this.L().L().stream().filter(string -> !string.equals(configRowx.L())).toList(); + if (this.strings.isEmpty()) { + this.uiSupport_571.L("No other configs to copy visuals to", "\ue001"); + } else { + this.M = configRowx.L(); + this.strings2.clear(); + this.L = true; + } + } + + private ConfigManager L() { + return OnyxClient.configManager; + } + + @Override + public void render(RenderContext renderContext) { + this.searchField.render(renderContext); + this.uiButton.render(renderContext); + this.uiButton2.render(renderContext); + this.uiButton3.render(renderContext); + this.configList.render(renderContext); + this.uiSupport_5782.render(renderContext); + this.uiSupport_578.render(renderContext); + this.uiSupport_571.render(renderContext); + } + + private List L(ConfigRow configRow) { + ConfigsPanel configsPanel1 = this; + ArrayList arrayList; + (arrayList = new ArrayList()).add(UiSupport_566.D("\ue161", "Overwrite with current", () -> this.i(configRowx))); + arrayList.add(UiSupport_566.D("\ue14d", "Duplicate", () -> this.H(configRowx))); + arrayList.add(UiSupport_566.D("\ue14d", "Copy visuals to", () -> this.k(configRowx))); + arrayList.add(UiSupport_566.L()); + arrayList.add(UiSupport_566.L("\ue872", "Delete", () -> this.e(configRowx))); + return arrayList; + } + + @Override + public boolean keyTyped(KeyInput keyInput) { + if (this.uiSupport_578.keyTyped(keyInput)) { + return true; + } else if (this.uiSupport_5782.keyTyped(keyInput)) { + return true; + } else if (this.searchField.keyTyped(keyInput)) { + return true; + } else if (KeyShortcuts.k(keyInput)) { + this.searchField.D(true); + this.searchField.d(); + return true; + } else if (KeyShortcuts.i(keyInput) && !this.searchField.L().isBlank()) { + this.I(); + return true; + } else if (keyInput.key() == 200) { + return this.configList.L(0, -1); + } else if (keyInput.key() == 208) { + return this.configList.L(0, 1); + } else if (KeyShortcuts.d(keyInput) && this.configList.L() != null) { + this.L(this.configList.L()); + return true; + } else { + return false; + } + } + + @Override + public boolean mouseClicked(float f, float g, int i) { + if (this.uiSupport_578.mouseClicked(f, g, i)) { + return true; + } else if (this.uiSupport_5782.mouseClicked(f, g, i)) { + return true; + } else if (this.searchField.mouseClicked(f, g, i)) { + return true; + } else if (this.uiButton.mouseClicked(f, g, i)) { + return true; + } else if (this.uiButton2.mouseClicked(f, g, i)) { + return true; + } else { + return this.uiButton3.mouseClicked(f, g, i) ? true : this.configList.mouseClicked(f, g, i); + } + } + + public String L() { + ConfigsPanel configsPanel1 = this; + int i; + return (i = configsPanel1.configList.D()) == 1 ? "1 config" : i + " configs"; + } + + @Override + public boolean charTyped(CharInput charInput) { + return this.searchField.charTyped(charInput); + } + + private void D(RenderContext renderContext) { + Render2D render2D = renderContext.render2D; + float f = this.uiButton.L(render2D); + float i = this.uiButton2.L(render2D); + float j = this.uiButton3.L(render2D); + float h = Math.max(120.0F, this.e - f - i - j - 30.0F); + float g = this.d + 5.0F; + this.searchField.setBounds(this.f, this.d, h, 40.0F); + this.uiButton.setBounds(this.searchField.d() + this.searchField.i() + 10.0F, g, f, 30.0F); + this.uiButton2.setBounds(this.uiButton.d() + f + 10.0F, g, i, 30.0F); + this.uiButton3.setBounds(this.f + this.e - j, g, j, 30.0F); + this.configList.setBounds(this.f, this.d + 40.0F + 8.0F, this.e, this.i - 40.0F - 8.0F); + this.uiSupport_571.setBounds(this.f, this.d, this.e, this.i); + } + + private void d(String string) { + if (!this.strings2.add(string)) { + this.strings2.remove(string); + } + } + + public void i() { + this.configList.d(); + this.searchField.L(""); + this.searchField.D(false); + this.uiSupport_5782.d(); + this.uiSupport_578.d(); + this.strings2.clear(); + } + + public void D() { + this.searchField.D(false); + this.uiSupport_5782.d(); + this.uiSupport_578.d(); + this.uiSupport_571.d(); + } + + @Override + public boolean mouseScrolled(float f, float g, double d) { + if (this.uiSupport_578.mouseScrolled(f, g, d)) { + return true; + } else { + return this.uiSupport_5782.mouseScrolled(f, g, d) ? true : this.configList.mouseScrolled(f, g, d); + } + } + + @Override + public boolean mouseDragged(float f, float g, int i, float h, float j) { + return this.searchField.mouseDragged(f, g, i, h, j); + } + + public ConfigsPanel() { + this.configList = new ConfigList(configRow -> { + String string = configRowx.L(); + if (this.L().D(string)) { + this.uiSupport_571.L(new StringBuilder().insert(0, "Loaded ").append(string).toString()); + } else { + this.uiSupport_571.L(new StringBuilder().insert(0, "Could not load ").append(string).toString(), "\ue001"); + } + }, configRow -> { + String string = configRowx.L(); + if (this.L().F(string)) { + this.uiSupport_571.L(new StringBuilder().insert(0, "Saved ").append(string).toString()); + } else { + this.uiSupport_571.L(new StringBuilder().insert(0, "Could not save ").append(string).toString(), "\ue001"); + } + }, configRow -> { + this.uiSupport_578.d(); + this.configRow = configRowx; + }); + this.uiSupport_5782 = new UiSupport_578(); + this.uiSupport_578 = new UiSupport_578(); + this.uiSupport_571 = new UiSupport_571(); + this.strings2 = new LinkedHashSet<>(); + this.strings = List.of(); + this.searchField.L(() -> { + ConfigsPanel configsPanel1 = this; + String string = configsPanel1.searchField.L().trim(); + if (!configsPanel1.L().h(string)) { + configsPanel1.uiSupport_571.L("Use 1-64 letters, digits, - or _", "\ue001"); + } else if (configsPanel1.L().i(string)) { + configsPanel1.uiSupport_571.L("Config already exists; use its menu to overwrite", "\ue001"); + } else if (!configsPanel1.L().F(string)) { + configsPanel1.uiSupport_571.L(new StringBuilder().insert(0, "Could not save ").append(string).toString(), "\ue001"); + } else { + configsPanel1.configList.d(); + configsPanel1.searchField.L(""); + configsPanel1.searchField.D(false); + configsPanel1.uiSupport_571.L(new StringBuilder().insert(0, "Saved ").append(string).toString()); + } + }); + } + + private List d() { + ConfigsPanel configsPanel1 = this; + ArrayList arrayList; + (arrayList = new ArrayList()).add(UiSupport_566.L("Select all", () -> !this.strings.isEmpty() && this.strings2.containsAll(this.strings), () -> { + if (this.i()) { + this.strings2.clear(); + } else { + this.strings2.addAll(this.strings); + } + })); + arrayList.add(UiSupport_566.L()); + Iterator iterator = configsPanel1.strings.iterator(); + + for (Iterator iterator1 = iterator; iterator1.hasNext(); iterator1 = iterator) { + String string = (String)iterator.next(); + arrayList.add(UiSupport_566.L(string, () -> this.strings2.contains(string), () -> this.d(string))); + } + + arrayList.add(UiSupport_566.L()); + arrayList.add( + UiSupport_566.d( + "\ue14d", + "Copy to selected", + () -> { + ConfigsPanel configsPanel3 = this; + if (configsPanel3.strings2.isEmpty()) { + configsPanel3.uiSupport_571.L("Select at least one config", "\ue001"); + } else { + ConfigManagerData configManagerData; + if ((configManagerData = configsPanel3.L().L(configsPanel3.M, new ArrayList<>(configsPanel3.strings2))).copied() == 0) { + configsPanel3.uiSupport_571.L("Could not copy visuals", "\ue001"); + } else { + ConfigsPanel configsPanel4; + if (!configManagerData.failed().isEmpty()) { + configsPanel3.uiSupport_571 + .L( + new StringBuilder() + .insert(0, "Copied to ") + .append(configManagerData.copied()) + .append("; failed: ") + .append(String.join(", ", configManagerData.failed())) + .toString(), + "\ue001" + ); + configsPanel4 = configsPanel3; + } else { + configsPanel3.uiSupport_571 + .L(new StringBuilder().insert(0, "Copied visuals to ").append(configManagerData.copied()).append(" config(s)").toString()); + configsPanel4 = configsPanel3; + } + + configsPanel4.strings2.clear(); + configsPanel3.uiSupport_578.d(); + } + } + } + ) + ); + return arrayList; + } + + private void i(ConfigRow configRow) { + String string = configRowx.L(); + if (this.L().F(string)) { + this.uiSupport_571.L(new StringBuilder().insert(0, "Updated ").append(string).toString()); + } else { + this.uiSupport_571.L(new StringBuilder().insert(0, "Could not update ").append(string).toString(), "\ue001"); + } + } + + @Override + public void update(RenderContext renderContext) { + this.D(renderContext); + this.searchField.update(renderContext); + this.uiButton.update(renderContext); + this.uiButton2.update(renderContext); + this.uiButton3.update(renderContext); + this.configList.update(renderContext); + if (this.configRow != null) { + this.uiSupport_5782.d(this.L(this.configRow), this.configRow.getUiSupport_602(), this, renderContext.render2D); + this.configRow = null; + } + + if (this.L) { + this.uiSupport_578.L(this.d(), this.uiSupport_5782, this, renderContext.render2D); + this.L = false; + } + + this.uiSupport_5782.update(renderContext); + this.uiSupport_578.update(renderContext); + this.uiSupport_571.update(renderContext); + } +}