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

This commit is contained in:
winterflyt committed 2026-11-30 06:16:11 +02:00
1 parent 3a145fea8f
commit c4daafb043
5 files changed
+600

No files matched your search

+129
View File
@@ -0,0 +1,129 @@
package openonyx.ui.internal;
import java.util.function.Consumer;
import openonyx.input.CharInput;
import openonyx.render.Render2D;
import openonyx.render.group_e.FontStyle;
import openonyx.theme.Fonts;
import openonyx.theme.ThemeManager;
import openonyx.ui.MaterialIcons;
import openonyx.ui.RenderContext;
import openonyx.ui.UiSupport_545;
public class ModuleSearch extends TextInput {
private final UiSupport_545 uiSupport_545 = new UiSupport_545();
public static final float M = 26.0F;
private static final float L = 9.0F;
private static final float j = 16.0F;
private static final float m = 12.0F;
private static final float h = 7.0F;
private final UiSupport_545 uiSupport_5452 = new UiSupport_545();
private static final float I = 2.0F;
private static final String f = "Search modules";
private static final float H = 22.0F;
public ModuleSearch(Consumer<String> consumer) {
this.i = 26.0F;
this.textEditor.L(consumer);
this.textEditor.d(() -> this.D(false));
this.textEditor.L(() -> {
if (!this.l()) {
this.D(false);
}
});
}
private boolean d(float f, float g) {
return !this.textEditor.L() && Math.abs(fx - this.F()) <= 11.0F && this.contains(fx, g);
}
public boolean l() {
return this.textEditor.d();
}
@Override
protected float h() {
return this.textEditor.L() ? this.f + this.e - 9.0F : this.F() - 16.0F;
}
@Override
public void update(RenderContext renderContext) {
super.update(renderContext);
boolean bl = this.d(renderContext.H, renderContext.f);
this.uiSupport_545.L(renderContext.i, this.h && !bl, false);
this.uiSupport_5452.L(renderContext.i, bl, false);
}
@Override
protected float l() {
return this.e() + 16.0F - 2.0F + 7.0F;
}
private float e() {
return this.f + 9.0F - 2.0F;
}
public boolean d(CharInput charInput) {
this.D(true);
return this.textEditor.L(charInput);
}
public String d() {
return this.textEditor.L();
}
@Override
public boolean mouseClicked(float f, float g, int i) {
if (i == 0 && this.d(fx, g)) {
this.l();
this.D(true);
return true;
} else {
return super.mouseClicked(fx, g, i);
}
}
public static float k() {
return 26.0F;
}
@Override
protected FontStyle L() {
return Fonts.getFontstylE15();
}
private float F() {
return this.f + this.e - 9.0F + 2.0F - 8.0F;
}
@Override
public void render(RenderContext renderContext) {
Render2D render2D = renderContext.render2D;
renderContext.render2D.roundedRect(this.f, this.d, this.e, this.i, Float.MAX_VALUE, renderContext.palette().surfaceContainerHigh());
this.uiSupport_545.L(render2D, this.f, this.d, this.e, this.i, Float.MAX_VALUE, renderContext.palette().onSurface());
float fx;
if ((fx = this.animation.getValue()) > 0.01F) {
render2D.roundedOutline(this.f, this.d, this.e, this.i, Float.MAX_VALUE, 1.5F, ThemeManager.withAlpha(renderContext.palette().primary(), fx));
}
fx = this.d + this.i / 2.0F;
MaterialIcons.L(render2D, this.e() + 8.0F, fx, 16.0F, renderContext.palette().onSurfaceVariant());
if (this.textEditor.L() && !this.i()) {
render2D.drawTextVCentered(this.L(), "Search modules", this.l(), fx, ThemeManager.withAlpha(renderContext.palette().onSurfaceVariant(), 0.7F));
}
this.L(renderContext, fx, 12.0F, renderContext.palette().onSurface());
if (!this.textEditor.L()) {
this.uiSupport_5452.L(render2D, this.F() - 11.0F, fx - 11.0F, 22.0F, 22.0F, Float.MAX_VALUE, renderContext.palette().onSurface());
MaterialIcons.D(render2D, this.F(), fx, 16.0F, renderContext.palette().onSurfaceVariant());
}
if (this.d(renderContext.H, renderContext.f)) {
render2D.usePointerCursor();
} else {
if (this.h) {
render2D.useTextCursor();
}
}
}
}