Upload files to "src/openonyx/ui/internal"

This commit is contained in:
winterflyt committed 2026-11-30 06:16:47 +02:00
1 parent 3794dae99d
commit 1385f8abb3
3 files changed
+644

No files matched your search

@@ -0,0 +1,134 @@
package openonyx.ui.internal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import openonyx.history.SettingGroup;
import openonyx.history.TabbedSettingGroup;
import openonyx.render.group_e.FontStyle;
import openonyx.theme.Fonts;
import openonyx.theme.ThemeManager;
import openonyx.ui.RenderContext;
import openonyx.ui.UiComponent;
public final class TabbedGroupControl extends SettingControl {
private static final float k = 8.0F;
private final SegmentedControl segmentedControl;
private SettingList settingList;
private float L;
private final List<SettingList> settingLists;
private static final float m = 13.0F;
public TabbedGroupControl(TabbedSettingGroup tabbedSettingGroup) {
TabbedGroupControl tabbedGroupControl1 = this;
tabbedGroupControl1./* $VF: Unable to resugar constructor */<init>(tabbedSettingGroup);
tabbedGroupControl1.settingLists = new ArrayList<>();
List list = tabbedSettingGroup.getSettings().stream().filter(SettingGroup.class::isInstance).map(SettingGroup.class::cast).toList();
List list1;
if ((list1 = tabbedSettingGroup.getStrings()).size() != list.size()) {
throw new IllegalArgumentException("Tabbed setting labels must match child groups");
}
for (Iterator iterator1 = iterator = list.iterator(); iterator1.hasNext(); iterator1 = iterator) {
SettingGroup settingGroup = (SettingGroup)iterator.next();
ArrayList arrayList = new ArrayList();
if (settingGroup.getEnabled() != null) {
arrayList.add(settingGroup.getEnabled());
}
arrayList.addAll(settingGroup.getSettings());
SettingList settingListx = new SettingList();
settingListx.setSettings(arrayList);
tabbedGroupControl1.settingLists.add(settingListx);
}
tabbedGroupControl1.segmentedControl = new SegmentedControl(list1.toArray(i -> {
String[] strings = new String[i];
boolean bl = true;
return strings;
}), i -> {
if (i >= 0 && i < this.settingLists.size()) {
if (this.settingList != null) {
this.uiComponents.removeAll(this.settingList.getSettingControls());
}
this.settingList = this.settingLists.get(i);
this.uiComponents.addAll(this.settingList.getSettingControls());
}
});
tabbedGroupControl1.uiComponents.add(tabbedGroupControl1.segmentedControl);
if (!tabbedGroupControl1.settingLists.isEmpty()) {
tabbedGroupControl1.L(0);
}
}
@Override
protected float L(RenderContext renderContext) {
return this.settingLists.isEmpty() ? this.A() : this.m() - this.d + this.L + (this.L > 0.5F ? 6.0F : 0.0F);
}
@Override
protected void d(RenderContext renderContext, float f) {
this.L(renderContext, this.e);
if (this.settingList != null && this.L > 0.5F) {
renderContext.render2D.rect(this.f + 3.0F, this.m(), 1.0F, this.L, ThemeManager.withAlpha(renderContext.palette().outlineVariant(), f * 0.7F));
this.settingList.drawDividers(renderContext.render2D, this.B(), this.C(), renderContext.palette().outlineVariant(), f);
}
for (Iterator iterator1 = iterator = this.uiComponents.iterator(); iterator1.hasNext(); iterator1 = iterator) {
((UiComponent)iterator.next()).render(renderContext);
}
}
@Override
protected FontStyle L() {
return Fonts.FONT_STYLE18;
}
private float C() {
return Math.max(0.0F, this.e - 13.0F);
}
@Override
public void update(RenderContext renderContext) {
this.segmentedControl.setBounds(this.B(), this.G(), this.C(), 30.0F);
this.L = this.settingList == null ? 0.0F : this.settingList.layout(this.B(), this.m(), this.C());
super.update(renderContext);
}
private float G() {
return this.d + this.A();
}
@Override
public boolean mouseClicked(float f, float g, int i) {
TabbedGroupControl tabbedGroupControl1 = this;
if (!tabbedGroupControl1.i()) {
return false;
}
if (tabbedGroupControl1.segmentedControl.mouseClicked(f, g, i)) {
return true;
}
if (tabbedGroupControl1.settingList != null) {
Iterator iterator = tabbedGroupControl1.settingList.getSettingControls().iterator();
while (iterator.hasNext()) {
if (((SettingControl)iterator.next()).mouseClicked(f, g, i)) {
return true;
}
}
}
return false;
}
private float m() {
return this.G() + 30.0F + 8.0F;
}
private float B() {
return this.f + 13.0F;
}
}
+62
View File
@@ -0,0 +1,62 @@
package openonyx.ui.internal;
import openonyx.history.internal.TextSetting;
import openonyx.theme.ThemeManager;
import openonyx.ui.RenderContext;
public class TextControl extends SettingControl {
private final SearchField searchField;
private final TextSetting textSetting;
private String j;
private static final float m = 6.0F;
@Override
protected void d(RenderContext renderContext, float f) {
this.searchField.render(renderContext);
if (this.I()) {
f = this.d + 6.0F + 40.0F + 6.0F;
renderContext.render2D
.drawTextTop(
FONT_STYLE2,
renderContext.render2D.trimToWidth(FONT_STYLE2, this.setting.getDescription(), this.e),
this.f,
f,
this.L(ThemeManager.withAlpha(renderContext.palette().onSurfaceVariant(), 0.85F))
);
}
}
@Override
public void update(RenderContext renderContext) {
super.update(renderContext);
if (!this.textSetting.getValue().equals(this.j)) {
this.j = this.textSetting.getValue();
this.searchField.L(this.j);
}
}
@Override
protected void L() {
this.searchField.setBounds(this.f, this.d + 6.0F, this.e, 40.0F);
}
public TextControl(TextSetting textSetting) {
super(textSettingx);
this.textSetting = textSettingx;
this.searchField = new SearchField(textSettingx.getName());
this.j = textSettingx.getValue();
this.searchField.L(this.j);
this.searchField.L(textSettingx::setValue);
this.uiComponents.add(this.searchField);
}
@Override
protected float L(RenderContext renderContext) {
float f = 46.0F;
if (this.I()) {
f += 6.0F + FONT_STYLE2.i();
}
return f + 6.0F;
}
}
+448
View File
@@ -0,0 +1,448 @@
package openonyx.ui.internal;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.function.Consumer;
import net.minecraft.client.gui.GuiScreen;
import openonyx.input.CharInput;
import openonyx.input.KeyInput;
import openonyx.ui.KeyShortcuts;
public class TextEditor {
private int c;
private static final char a = '•';
private Consumer<String> stringConsumer;
private String g;
private int M;
private TextEditorMode textEditorMode;
private final Deque<TextEditorData> textEditorDatas = new ArrayDeque<>();
private Runnable runnable;
private static final int h = 128;
public static final float l = 1000.0F;
private final Deque<TextEditorData> textEditorDatas2 = new ArrayDeque<>();
private Runnable runnable2;
private boolean i;
private float f;
private float H;
private static final float e = 550.0F;
public void L(Consumer<String> consumer) {
this.stringConsumer = consumer;
}
private TextEditorData L() {
return new TextEditorData(this.g, this.M, this.c);
}
public boolean F() {
if (this.textEditorDatas2.isEmpty()) {
return false;
}
this.textEditorDatas.push(this.L());
this.L(this.textEditorDatas2.pop());
return true;
}
private int d(int i) {
int j;
int k = j = Math.clamp(ix, 0, this.g.length());
while (k < this.g.length() && !Character.isLetterOrDigit(this.g.charAt(j))) {
k = ++j;
}
k = j;
while (k < this.g.length() && Character.isLetterOrDigit(this.g.charAt(j))) {
k = ++j;
}
return j;
}
public void D() {
this.H = 0.0F;
}
public void d() {
this.c = 0;
this.M = this.g.length();
this.D();
}
public boolean l() {
return this.H < 500.0F;
}
public int D() {
return this.M;
}
public boolean h() {
if (this.textEditorDatas.isEmpty()) {
return false;
}
this.textEditorDatas2.push(this.L());
this.L(this.textEditorDatas.pop());
return true;
}
public float L(int i, TextEditorListener textEditorListener) {
TextEditor textEditor1 = this;
String string = textEditor1.D();
return textEditorListener.L(string.substring(0, Math.clamp(ix, 0, string.length())));
}
public void L(boolean bl) {
this.i = bl;
}
public void L(int i) {
this.c = this.L(Math.clamp(ix, 0, this.g.length()));
this.M = this.d(Math.clamp(ix, 0, this.g.length()));
this.D();
}
public String D() {
return this.i ? String.valueOf('•').repeat(this.g.length()) : this.g;
}
public void L(int i, boolean bl) {
this.M = Math.clamp(ix, 0, this.g.length());
if (!bl) {
this.c = this.M;
}
this.D();
}
private int L(int i) {
int j;
int k = j = Math.clamp(ix, 0, this.g.length());
while (k > 0 && !Character.isLetterOrDigit(this.g.charAt(j - 1))) {
k = --j;
}
k = j;
while (k > 0 && Character.isLetterOrDigit(this.g.charAt(j - 1))) {
k = --j;
}
return j;
}
private void L(TextEditorMode textEditorMode) {
TextEditor textEditor1 = this;
boolean bl = textEditorModex == textEditor1.textEditorMode && textEditor1.f < 550.0F && !textEditor1.textEditorDatas.isEmpty();
if (!bl) {
TextEditor textEditor2 = textEditor1;
textEditor1.textEditorDatas.push(textEditor1.L());
while (textEditor2.textEditorDatas.size() > 128) {
textEditor2 = textEditor1;
textEditor1.textEditorDatas.removeLast();
}
}
textEditor1.textEditorDatas2.clear();
textEditor1.textEditorMode = textEditorModex;
textEditor1.f = 0.0F;
}
public void D(String string) {
this.d(string);
}
public boolean L(KeyInput keyInput) {
if (KeyShortcuts.d(keyInput, 30)) {
this.d();
return true;
}
if (KeyShortcuts.d(keyInput, 46)) {
this.I();
return true;
}
if (KeyShortcuts.d(keyInput, 45)) {
if (this.I()) {
this.L("", TextEditorMode.DELETE);
}
return true;
} else {
if (KeyShortcuts.d(keyInput, 47)) {
String string = GuiScreen.getClipboardString();
this.d(string == null ? "" : string.replaceAll("[\\r\\n]", " "));
return true;
}
if (KeyShortcuts.D(keyInput)) {
return this.h();
}
if (KeyShortcuts.L(keyInput)) {
return this.F();
}
boolean bl = keyInput.d();
switch (keyInput.key()) {
case 1:
while (false) {
}
if (this.runnable != null) {
this.runnable.run();
}
return true;
case 14:
if (this.D()) {
this.L("", TextEditorMode.DELETE);
} else if (this.M > 0) {
this.c = KeyShortcuts.h(keyInput) ? this.L(this.M) : this.M - 1;
this.L("", TextEditorMode.DELETE);
}
return true;
case 28:
case 156:
if (this.runnable2 != null) {
this.runnable2.run();
}
return true;
case 199:
this.L(0, bl);
return true;
case 203:
int ix;
boolean bl1;
if (KeyShortcuts.h(keyInput)) {
ix = this.L(this.M);
bl1 = bl;
} else {
ix = this.M - 1;
bl1 = bl;
}
this.L(ix, bl1);
return true;
case 205:
int j;
boolean bl2;
if (KeyShortcuts.h(keyInput)) {
j = this.d(this.M);
bl2 = bl;
} else {
j = this.M + 1;
bl2 = bl;
}
this.L(j, bl2);
return true;
case 207:
this.L(this.g.length(), bl);
return true;
case 211:
if (this.D()) {
this.L("", TextEditorMode.DELETE);
} else if (this.M < this.g.length()) {
this.c = KeyShortcuts.h(keyInput) ? this.d(this.M) : this.M + 1;
this.L("", TextEditorMode.DELETE);
}
return true;
default:
return false;
}
}
}
private boolean I() {
TextEditor textEditor1 = this;
String string = textEditor1.D() ? textEditor1.d() : textEditor1.g;
if (!textEditor1.i && !string.isEmpty()) {
GuiScreen.setClipboardString(string);
return true;
} else {
return false;
}
}
private void d(String string) {
if (!string.isEmpty()) {
this.L(string, TextEditorMode.INSERT);
}
}
public void L(String string) {
this.g = string == null ? "" : string;
this.M = this.g.length();
this.c = this.M;
this.H = 0.0F;
this.textEditorDatas.clear();
this.textEditorDatas2.clear();
this.textEditorMode = TextEditorMode.NONE;
}
public TextEditor() {
this.g = "";
this.f = Float.MAX_VALUE;
this.textEditorMode = TextEditorMode.NONE;
}
public String d() {
return this.D() ? this.g.substring(this.L(), this.d()) : "";
}
private void L(String string, TextEditorMode textEditorMode) {
TextEditor textEditor1 = this;
int j = textEditor1.L();
int ix = textEditor1.d();
if (j != ix || !string.isEmpty()) {
textEditor1.L(textEditorModex);
textEditor1.g = textEditor1.g.substring(0, j) + string + textEditor1.g.substring(ix);
textEditor1.M = j + string.length();
textEditor1.c = textEditor1.M;
textEditor1.H = 0.0F;
if (textEditor1.stringConsumer != null) {
textEditor1.stringConsumer.accept(textEditor1.g);
}
}
}
public void d(Runnable runnable) {
this.runnable2 = runnablex;
}
private void L(TextEditorData textEditorData) {
this.g = textEditorData.text();
this.M = Math.clamp(textEditorData.caret(), 0, this.g.length());
this.c = Math.clamp(textEditorData.anchor(), 0, this.g.length());
this.H = 0.0F;
this.textEditorMode = TextEditorMode.NONE;
this.f = Float.MAX_VALUE;
if (this.stringConsumer != null) {
this.stringConsumer.accept(this.g);
}
}
public static String decrypt(String string) {
String string1 = string;
int m = (--3 ^ 5) << 3 ^ 1;
int n = 3 << 3 ^ 7;
String string2;
int p = (string2 = string1).length();
char[] d = new char[p];
boolean bl = true;
int j;
int o = j = p - 1;
char[] cx = d;
byte b = 117;
int k = o;
int ix = m;
while (k >= 0) {
n = j;
int lx = string2.charAt(j);
j--;
cx[n] = (char)(lx ^ ix);
if (j < 0) {
break;
}
lx = j--;
cx[lx] = (char)(string2.charAt(lx) ^ b);
k = j;
}
return new String(cx);
}
public void L(Runnable runnable) {
this.runnable = runnablex;
}
public String L() {
return this.g;
}
public boolean i() {
return this.i;
}
public boolean D() {
return this.M != this.c;
}
public void L() {
this.c = this.M;
this.D();
}
public boolean d() {
if (this.g.isEmpty()) {
return false;
}
this.d();
this.L("", TextEditorMode.DELETE);
return true;
}
public int d() {
return Math.max(this.M, this.c);
}
public boolean L(CharInput charInput) {
if (!KeyShortcuts.L(charInput)) {
return false;
}
this.d(Character.toString(charInput.codepoint()));
return true;
}
public int L(float f, TextEditorListener textEditorListener) {
TextEditor textEditor1 = this;
String string = textEditor1.D();
int ix = 0;
float gx = Math.abs(fx);
for (int k = j = 1; k <= string.length(); k = ++j) {
float hx;
if ((hx = Math.abs(textEditorListener.L(string.substring(0, j)) - fx)) <= gx) {
gx = hx;
ix = j;
}
}
return ix;
}
public float L(TextEditorListener textEditorListener) {
TextEditor textEditor1 = this;
String string = textEditor1.D();
return textEditorListener.L(string.substring(0, Math.min(textEditor1.M, string.length())));
}
public boolean L() {
return this.g.isEmpty();
}
public int L() {
return Math.min(this.M, this.c);
}
public void L(float f) {
this.H = (this.H + fx) % 1000.0F;
if (this.f < Float.MAX_VALUE) {
this.f += fx;
}
}
}