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

This commit is contained in:
winterflyt committed 2026-11-30 06:15:50 +02:00
1 parent 7f20024adb
commit 8186c1dd79
5 files changed
+1116

No files matched your search

+204
View File
@@ -0,0 +1,204 @@
package openonyx.ui.internal;
import java.util.function.Consumer;
import openonyx.connection.Account;
import openonyx.connection.ProfileSkinCache;
import openonyx.core.OnyxClient;
import openonyx.render.Render2D;
import openonyx.render.group_d.Animation;
import openonyx.render.group_d.ColorAnimation;
import openonyx.render.group_d.Easings;
import openonyx.theme.Fonts;
import openonyx.theme.Palette;
import openonyx.theme.ThemeManager;
import openonyx.ui.RenderContext;
import openonyx.ui.UiComponent;
import openonyx.ui.UiSupport_545;
public class AccountRow extends UiComponent {
private final Account account;
public static final float b = 56.0F;
private static final float E = 1.8F;
private static final float F = 14.0F;
private final Consumer<AccountRow> accountRowConsumer;
private boolean A;
private static final float K = 24.0F;
private static final float B = 20.0F;
private final Consumer<AccountRow> accountRowConsumer2;
private float J;
private static final float D = 3.0F;
private static final float c = 10.0F;
private final ColorAnimation colorAnimation;
private static final long k = 60000L;
private static final float g = 900.0F;
private static final float M = 6.0F;
private static final float L = 11.0F;
private static final float j = 8.0F;
private final UiSupport_545 uiSupport_545 = new UiSupport_545();
private static final float h = 32.0F;
private boolean l;
private static final long d = 600000L;
private final UiSupport_602 uiSupport_602;
private final Animation animation;
private static final float H = 12.0F;
private static final long e = 3600000L;
public AccountRow(Account account, Consumer<AccountRow> consumer, Consumer<AccountRow> consumer1) {
this.colorAnimation = new ColorAnimation(0);
this.animation = new Animation(0.0F);
this.account = accountx;
this.i = 56.0F;
this.accountRowConsumer = consumer;
this.accountRowConsumer2 = consumer1;
this.uiSupport_602 = new UiSupport_602("\ue5d4", () -> consumer1.accept(this));
this.uiComponents.add(this.uiSupport_602);
}
@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);
}
private int L(Palette palette) {
long lx;
if ((lx = this.account.d() - System.currentTimeMillis()) <= 600000L) {
return palette.error();
} else {
return lx <= 3600000L ? palette.secondary() : palette.tertiary();
}
}
private boolean i() {
return OnyxClient.accountManager.getAccount() == this.account;
}
@Override
public void render(RenderContext renderContext) {
AccountRow accountRow1 = this;
Render2D render2D = renderContext.render2D;
Render2D render2D1 = renderContext.render2D;
int i = accountRow1.i();
float gx = accountRow1.d + accountRow1.i / 2.0F;
render2D1.roundedRect(accountRow1.f, accountRow1.d, accountRow1.e, accountRow1.i, 16.0F, accountRow1.colorAnimation.L());
accountRow1.uiSupport_545.L(render2D, accountRow1.f, accountRow1.d, accountRow1.e, accountRow1.i, 16.0F, renderContext.palette().onSurface());
float f;
if ((f = accountRow1.animation.getValue()) > 0.01F) {
render2D.circle(accountRow1.f + 11.0F, gx, 3.0F * f, ThemeManager.withAlpha(renderContext.palette().primary(), f));
}
f = gx - 16.0F;
render2D.roundedRect(accountRow1.f + 20.0F, f, 32.0F, 32.0F, 4.0F, renderContext.palette().surfaceContainerHighest());
render2D.drawPlayerHead(ProfileSkinCache.L(accountRow1.account.getUuid(), accountRow1.account.D()), accountRow1.f + 20.0F, f, 32.0F);
int lx = i ? renderContext.palette().onSecondaryContainer() : renderContext.palette().onSurface();
i = i ? ThemeManager.withAlpha(renderContext.palette().onSecondaryContainer(), 0.72F) : renderContext.palette().onSurfaceVariant();
String string;
float hx = (string = accountRow1.L()) == null ? 0.0F : render2D.getTextWidth(Fonts.FONT_STYLE2, string) + 10.0F;
float jx = accountRow1.f + 20.0F + 32.0F + 12.0F;
hx = accountRow1.uiSupport_602.d() - 10.0F - hx;
String string1 = new StringBuilder().insert(0, "(").append(accountRow1.account.getAccountType().L()).append(")").toString();
float kx = render2D.getTextWidth(Fonts.FONT_STYLE2, string1);
String string2 = render2D.trimToWidth(Fonts.FONT_STYLE14, accountRow1.account.D(), Math.max(24.0F, hx - jx - kx - 6.0F));
render2D.drawTextVCentered(Fonts.FONT_STYLE14, string2, jx, gx, lx);
render2D.drawTextVCentered(Fonts.FONT_STYLE2, string1, jx + render2D.getTextWidth(Fonts.FONT_STYLE14, string2) + 6.0F, gx, i);
if (string != null) {
render2D.drawTextRightVCentered(Fonts.FONT_STYLE2, string, accountRow1.uiSupport_602.d() - 10.0F, gx, accountRow1.L(renderContext.palette()));
}
if (accountRow1.l) {
render2D.L(accountRow1.uiSupport_602.d() + 15.0F, gx, 7.0F, 1.8F, accountRow1.J / 900.0F, renderContext.palette().primary());
} else {
accountRow1.render(renderContext);
}
}
public Account getAccount() {
return this.account;
}
public UiComponent getUiSupport_602() {
return this.uiSupport_602;
}
@Override
public boolean mouseClicked(float f, float g, int i) {
if (this.l) {
return this.contains(f, gx);
} else if (this.uiSupport_602.mouseClicked(f, gx, i)) {
return true;
} else if (!this.contains(f, gx)) {
return false;
} else if (i == 0) {
boolean bl = this.H = true;
this.accountRowConsumer.accept(this);
return bl;
} else if (i == 1) {
this.accountRowConsumer2.accept(this);
return true;
} else {
return false;
}
}
private String L() {
long lx;
if ((lx = this.account.d()) <= 0L) {
return null;
} else if ((lx = lx - System.currentTimeMillis()) <= 0L) {
return "Expired";
} else {
long m = lx / 3600000L;
lx = lx % 3600000L / 60000L;
long n;
int i = (n = m - 0L) == 0L ? 0 : (n < 0L ? -1 : 1);
StringBuilder stringBuilder = new StringBuilder;
if (i > 0) {
stringBuilder./* $VF: Unable to resugar constructor */<init>();
return stringBuilder.append(m).append("h").append(lx).append("m").toString();
} else {
stringBuilder./* $VF: Unable to resugar constructor */<init>();
return stringBuilder.append(Math.max(1L, lx)).append("m").toString();
}
}
}
@Override
public boolean mouseReleased(float f, float g, int i) {
this.H = false;
return super.mouseReleased(f, gx, i);
}
public void d(boolean bl) {
this.l = bl;
}
@Override
public void update(RenderContext renderContext) {
super.update(renderContext);
boolean bl;
int i = (bl = this.i()) ? renderContext.palette().secondaryContainer() : renderContext.palette().surfaceContainerHigh();
if (!this.A) {
this.A = true;
this.colorAnimation.L(i);
this.animation.set(bl ? 1.0F : 0.0F);
}
this.colorAnimation.L(i, 250.0F, Easings.EASING6);
this.colorAnimation.L(renderContext.i);
this.animation.animateTo(bl ? 1.0F : 0.0F, 250.0F, Easings.EASING6);
this.animation.update(renderContext.i);
boolean bl1;
AccountRow accountRow1;
if (this.h && !this.l && !this.uiSupport_602.D()) {
bl1 = true;
accountRow1 = this;
} else {
bl1 = false;
accountRow1 = this;
}
this.uiSupport_545.L(renderContext.i, bl1, accountRow1.H);
if (this.l) {
this.J = (this.J + renderContext.i) % 900.0F;
}
}
}
@@ -0,0 +1,58 @@
package openonyx.ui.internal;
import openonyx.history.internal.ActionSetting;
import openonyx.render.Render2D;
import openonyx.theme.Fonts;
import openonyx.ui.RenderContext;
import openonyx.ui.UiSupport_545;
public class ActionControl extends SettingControl {
private static final float m = 30.0F;
private final ActionSetting actionSetting;
private final UiSupport_545 uiSupport_545 = new UiSupport_545();
@Override
protected float L(RenderContext renderContext) {
return 30.0F;
}
public ActionControl(ActionSetting actionSetting) {
super(actionSettingx);
this.actionSetting = actionSettingx;
}
@Override
public boolean mouseClicked(float f, float g, int i) {
if (this.i() && i == 0 && this.contains(f, g)) {
this.actionSetting.run();
return true;
} else {
return false;
}
}
@Override
public void update(RenderContext renderContext) {
super.update(renderContext);
this.uiSupport_545.L(renderContext.i, this.h, this.H);
}
@Override
protected void d(RenderContext renderContext, float f) {
ActionControl actionControl1 = this;
Render2D render2D;
Render2D render2D1 = render2D = renderContext.render2D;
Render2D render2D2 = renderContext.render2D;
int i = actionControl1.L(renderContext.palette().onSecondaryContainer());
render2D2.roundedRect(
actionControl1.f, actionControl1.d, actionControl1.e, 30.0F, Float.MAX_VALUE, actionControl1.L(renderContext.palette().secondaryContainer())
);
actionControl1.uiSupport_545.L(render2D, actionControl1.f, actionControl1.d, actionControl1.e, 30.0F, Float.MAX_VALUE, i);
render2D1.drawTextCenteredVCentered(
Fonts.FONT_STYLE14, actionControl1.actionSetting.getButtonLabel(), actionControl1.f + actionControl1.e / 2.0F, actionControl1.d + 15.0F, i
);
if (actionControl1.h && actionControl1.i()) {
render2D.usePointerCursor();
}
}
}
@@ -0,0 +1,534 @@
package openonyx.ui.internal;
import java.util.function.Consumer;
import net.minecraft.client.gui.GuiScreen;
import openonyx.connection.Account;
import openonyx.connection.MicrosoftAccount;
import openonyx.connection.OfflineAccount;
import openonyx.connection.TokenAccount;
import openonyx.connection.internal.AuthException;
import openonyx.connection.internal.MicrosoftLoginServer;
import openonyx.connection.internal.XboxLiveAuth;
import openonyx.core.OnyxClient;
import openonyx.input.CharInput;
import openonyx.input.KeyInput;
import openonyx.render.Render2D;
import openonyx.theme.Fonts;
import openonyx.theme.ThemeManager;
import openonyx.ui.RenderContext;
import openonyx.ui.UiComponent;
import openonyx.utilities.AsyncExecutor;
public class AddAccountPanel extends UiComponent {
private static final int p = 0;
private String t;
private static final int b = 1;
private Consumer<String> stringConsumer;
private static final float F = 8.0F;
private static final float G = 10.0F;
private MicrosoftLoginServer microsoftLoginServer;
private Consumer<String> stringConsumer2;
private final SegmentedControl segmentedControl;
private static final float C = 10.0F;
private final UiButton uiButton;
private final UiButton uiButton2;
private final ToggleSwitch toggleSwitch;
private boolean a;
private final UiButton uiButton3;
private static final float g = 16.0F;
private final SearchField searchField;
private static final int L = 3;
private final UiButton uiButton4;
private static final float m = 14.0F;
private final SearchField searchField2;
private static final float l = 96.0F;
private static final float I = 14.0F;
private final UiButton uiButton5;
private final SearchField searchField3;
private static final String[] f;
private Consumer<Account> accountConsumer;
private static final int e = 2;
static {
String[] strings = new String[4];
boolean bl = true;
strings[0] = "Offline";
strings[1] = "Access";
strings[2] = "Refresh";
strings[3] = "Microsoft";
f = strings;
}
@Override
public boolean mouseClicked(float f, float g, int i) {
if (this.segmentedControl.mouseClicked(fx, gx, i)) {
return true;
}
switch (this.L()) {
case 0:
while (false) {
}
return this.searchField3.mouseClicked(fx, gx, i) || this.toggleSwitch.mouseClicked(fx, gx, i) || this.uiButton3.mouseClicked(fx, gx, i);
case 1:
if (!this.searchField.mouseClicked(fx, gx, i) && !this.uiButton4.mouseClicked(fx, gx, i)) {
return false;
}
return true;
case 2:
if (!this.searchField2.mouseClicked(fx, gx, i) && !this.uiButton2.mouseClicked(fx, gx, i)) {
return false;
}
return true;
default:
return this.uiButton.mouseClicked(fx, gx, i) || this.uiButton5.mouseClicked(fx, gx, i);
}
}
@Override
public boolean keyTyped(KeyInput keyInput) {
switch (this.L()) {
case 0:
while (false) {
}
return this.searchField3.keyTyped(keyInput);
case 1:
return this.searchField.keyTyped(keyInput);
case 2:
return this.searchField2.keyTyped(keyInput);
default:
return false;
}
}
private void L(RenderContext renderContext, Render2D render2D, String string, float f) {
render2D.drawTextVCentered(
Fonts.FONT_STYLE15,
render2D.trimToWidth(Fonts.FONT_STYLE15, string, this.e),
this.f,
fx + 8.0F + 7.0F,
ThemeManager.withAlpha(renderContext.palette().onSurfaceVariant(), 0.9F)
);
}
private void i(String string) {
if (this.stringConsumer != null) {
this.stringConsumer.accept(string);
}
}
@Override
public void render(RenderContext renderContext) {
Render2D render2D = renderContext.render2D;
this.segmentedControl.render(renderContext);
switch (this.L()) {
case 0:
while (false) {
}
this.i(renderContext, render2D);
return;
case 1:
this.L(renderContext, render2D);
return;
case 2:
this.d(renderContext, render2D);
return;
default:
this.D(renderContext, render2D);
}
}
private void i(RenderContext renderContext, Render2D render2D) {
this.searchField3.render(renderContext);
this.toggleSwitch.render(renderContext);
this.uiButton3.render(renderContext);
render2D.drawTextVCentered(
Fonts.FONT_STYLE15, "Resolve premium UUID", this.toggleSwitch.d() + 38.0F + 10.0F, this.toggleSwitch.D() + 11.0F, renderContext.palette().onSurface()
);
this.L(renderContext, render2D, "Looks the name up on Mojang so the real skin and UUID are used.", this.uiButton3.D() + 30.0F);
}
@Override
public boolean mouseReleased(float f, float g, int i) {
switch (this.L()) {
case 0:
while (false) {
}
return this.toggleSwitch.mouseReleased(fx, gx, i) | this.uiButton3.mouseReleased(fx, gx, i);
case 1:
return this.uiButton4.mouseReleased(fx, gx, i);
case 2:
return this.uiButton2.mouseReleased(fx, gx, i);
default:
return this.uiButton.mouseReleased(fx, gx, i) | this.uiButton5.mouseReleased(fx, gx, i);
}
}
@Override
public boolean charTyped(CharInput charInput) {
switch (this.L()) {
case 0:
while (false) {
}
return this.searchField3.charTyped(charInput);
case 1:
return this.searchField.charTyped(charInput);
case 2:
return this.searchField2.charTyped(charInput);
default:
return false;
}
}
public void D(Consumer<Account> consumer) {
this.accountConsumer = consumer;
}
private void L(Account account) {
OnyxClient.accountManager.i(account);
if (this.accountConsumer != null) {
this.accountConsumer.accept(account);
}
}
public AddAccountPanel() {
this.segmentedControl = new SegmentedControl(f, i -> {
this.searchField3.D(false);
this.searchField.D(false);
this.searchField2.D(false);
if (i != 3) {
this.h();
}
});
this.searchField3 = new SearchField("Username");
this.searchField = new SearchField("Minecraft access token");
this.searchField2 = new SearchField("Microsoft OAuth refresh token");
this.toggleSwitch = new ToggleSwitch(() -> this.a, boolean_ -> this.a = boolean_);
this.uiButton3 = new UiButton(UiButtonMode.FILLED, "Add", () -> {
AddAccountPanel addAccountPanel2 = this;
String string;
if ((string = addAccountPanel2.searchField3.L().trim()).isEmpty()) {
addAccountPanel2.i("Enter a username");
} else {
OfflineAccount offlineAccount;
(offlineAccount = new OfflineAccount(string)).L(addAccountPanel2.a);
if (!addAccountPanel2.a) {
addAccountPanel2.L((Account)offlineAccount);
} else {
addAccountPanel2.uiButton3.d(true);
AsyncExecutor.L(() -> {
try {
offlineAccount.L();
} catch (AuthException authException) {
}
mc.addScheduledTask(() -> {
this.uiButton3.d(false);
this.L((Account)offlineAccount);
});
});
}
}
});
this.uiButton4 = new UiButton(UiButtonMode.FILLED, "Add", () -> {
AddAccountPanel addAccountPanel1 = this;
String string;
if ((string = addAccountPanel1.searchField.L().trim()).isEmpty()) {
addAccountPanel1.i("Paste an access token");
} else {
addAccountPanel1.uiButton4.d(true);
AsyncExecutor.L(() -> {
try {
tokenAccount = TokenAccount.L(string);
} catch (AuthException authException) {
mc.addScheduledTask(() -> {
this.uiButton4.d(false);
this.i(authException.getMessage());
});
return;
}
mc.addScheduledTask(() -> {
this.uiButton4.d(false);
this.L((Account)tokenAccount);
});
});
}
});
this.uiButton2 = new UiButton(UiButtonMode.FILLED, "Add", () -> {
AddAccountPanel addAccountPanel2 = this;
String string;
if ((string = addAccountPanel2.searchField2.L().trim()).isEmpty()) {
addAccountPanel2.i("Paste a refresh token");
} else {
addAccountPanel2.uiButton2.d(true);
AsyncExecutor.L(() -> {
try {
microsoftAccount = MicrosoftAccount.L(string);
} catch (AuthException authException) {
mc.addScheduledTask(() -> {
this.uiButton2.d(false);
this.i(authException.getMessage());
});
return;
}
mc.addScheduledTask(() -> {
this.uiButton2.d(false);
this.L((Account)microsoftAccount);
});
});
}
});
this.uiButton = new UiButton(UiButtonMode.FILLED, "Sign in with Microsoft", "\ue89e", () -> {
AddAccountPanel addAccountPanel1 = this;
if (addAccountPanel1.microsoftLoginServer != null) {
addAccountPanel1.h();
} else {
try {
addAccountPanel1.microsoftLoginServer = MicrosoftLoginServer.L(xboxLiveAuthData2 -> {
this.h();
this.L((Account)MicrosoftAccount.L(xboxLiveAuthData2));
}, string -> {
this.h();
this.i(string);
});
} catch (AuthException authException) {
addAccountPanel1.i(authException.getMessage());
return;
}
addAccountPanel1.microsoftLoginServer.d();
addAccountPanel1.uiButton.L("Cancel");
addAccountPanel1.uiButton.d("\ue5cd");
addAccountPanel1.t = "Waiting for the browser…";
}
});
this.uiButton5 = new UiButton(UiButtonMode.TEXT, "Copy link", () -> {
if (this.microsoftLoginServer == null) {
this.i("Start the sign-in first");
} else {
GuiScreen.setClipboardString(this.microsoftLoginServer.d());
if (this.stringConsumer2 != null) {
this.stringConsumer2.accept("Sign-in link copied");
}
}
});
this.searchField.d(true);
this.searchField2.d(true);
this.searchField3.L(() -> {
AddAccountPanel addAccountPanel2 = this;
String string;
if ((string = addAccountPanel2.searchField3.L().trim()).isEmpty()) {
addAccountPanel2.i("Enter a username");
} else {
OfflineAccount offlineAccount;
(offlineAccount = new OfflineAccount(string)).L(addAccountPanel2.a);
if (!addAccountPanel2.a) {
addAccountPanel2.L((Account)offlineAccount);
} else {
addAccountPanel2.uiButton3.d(true);
AsyncExecutor.L(() -> {
try {
offlineAccount.L();
} catch (AuthException authException) {
}
mc.addScheduledTask(() -> {
this.uiButton3.d(false);
this.L((Account)offlineAccount);
});
});
}
}
});
this.searchField.L(() -> {
AddAccountPanel addAccountPanel1 = this;
String string;
if ((string = addAccountPanel1.searchField.L().trim()).isEmpty()) {
addAccountPanel1.i("Paste an access token");
} else {
addAccountPanel1.uiButton4.d(true);
AsyncExecutor.L(() -> {
try {
tokenAccount = TokenAccount.L(string);
} catch (AuthException authException) {
mc.addScheduledTask(() -> {
this.uiButton4.d(false);
this.i(authException.getMessage());
});
return;
}
mc.addScheduledTask(() -> {
this.uiButton4.d(false);
this.L((Account)tokenAccount);
});
});
}
});
this.searchField2.L(() -> {
AddAccountPanel addAccountPanel2 = this;
String string;
if ((string = addAccountPanel2.searchField2.L().trim()).isEmpty()) {
addAccountPanel2.i("Paste a refresh token");
} else {
addAccountPanel2.uiButton2.d(true);
AsyncExecutor.L(() -> {
try {
microsoftAccount = MicrosoftAccount.L(string);
} catch (AuthException authException) {
mc.addScheduledTask(() -> {
this.uiButton2.d(false);
this.i(authException.getMessage());
});
return;
}
mc.addScheduledTask(() -> {
this.uiButton2.d(false);
this.L((Account)microsoftAccount);
});
});
}
});
this.uiComponents.add(this.segmentedControl);
this.uiComponents.add(this.searchField3);
this.uiComponents.add(this.toggleSwitch);
this.uiComponents.add(this.uiButton3);
this.uiComponents.add(this.searchField);
this.uiComponents.add(this.uiButton4);
this.uiComponents.add(this.searchField2);
this.uiComponents.add(this.uiButton2);
this.uiComponents.add(this.uiButton);
this.uiComponents.add(this.uiButton5);
}
private void D(RenderContext renderContext) {
float fx = this.d + 30.0F + 14.0F;
float gx = this.uiButton.L(renderContext.render2D);
float h = this.uiButton5.L(renderContext.render2D);
this.uiButton.setBounds(this.f, fx, gx, 30.0F);
this.uiButton5.setBounds(this.f + gx + 10.0F, fx, h, 30.0F);
this.uiButton5.L(this.microsoftLoginServer != null);
}
private void h() {
if (this.microsoftLoginServer != null) {
this.microsoftLoginServer.D();
}
this.microsoftLoginServer = null;
this.t = null;
this.uiButton.L("Sign in with Microsoft");
this.uiButton.d("\ue89e");
}
public boolean I() {
return this.searchField3.i() || this.searchField.i() || this.searchField2.i();
}
private void D(RenderContext renderContext, Render2D render2D) {
this.uiButton.render(renderContext);
this.uiButton5.render(renderContext);
float fx = this.uiButton.D() + 30.0F;
if (!XboxLiveAuth.L()) {
float gx = fx + 8.0F + 7.0F;
render2D.drawIcon("\ue001", this.f + 8.0F, gx, 16.0F, renderContext.palette().error());
render2D.drawTextVCentered(
Fonts.FONT_STYLE15, "No Azure client id is configured for this build.", this.f + 16.0F + 10.0F, gx, renderContext.palette().error()
);
} else {
if (this.t != null) {
render2D.drawTextVCentered(Fonts.FONT_STYLE15, this.t, this.f, fx + 8.0F + 7.0F, renderContext.palette().primary());
}
this.L(renderContext, render2D, "Opens your browser. Use Copy link if it does not open by itself.", fx + (this.t == null ? 0.0F : 14.0F));
}
}
public void d(Consumer<String> consumer) {
this.stringConsumer = consumer;
}
private int L() {
return this.segmentedControl.L();
}
private void d(RenderContext renderContext, Render2D render2D) {
this.searchField2.render(renderContext);
this.uiButton2.render(renderContext);
this.L(renderContext, render2D, "The msaartifacts refresh token from a launcher. Works without an Azure app.", this.uiButton2.D() + 30.0F);
}
@Override
public void update(RenderContext renderContext) {
this.D(renderContext);
this.h = this.contains(renderContext.H, renderContext.f);
this.segmentedControl.update(renderContext);
switch (this.L()) {
case 0:
while (false) {
}
this.searchField3.update(renderContext);
this.toggleSwitch.update(renderContext);
this.uiButton3.update(renderContext);
return;
case 1:
this.searchField.update(renderContext);
this.uiButton4.update(renderContext);
return;
case 2:
this.searchField2.update(renderContext);
this.uiButton2.update(renderContext);
return;
default:
this.uiButton.update(renderContext);
this.uiButton5.update(renderContext);
}
}
public void D() {
this.h();
this.searchField3.L("");
this.searchField.L("");
this.searchField2.L("");
this.searchField3.D(false);
this.searchField.D(false);
this.searchField2.D(false);
this.t = null;
}
public void L(Consumer<String> consumer) {
this.stringConsumer2 = consumer;
}
@Override
protected void L() {
AddAccountPanel addAccountPanel1 = this;
addAccountPanel1.segmentedControl.setBounds(addAccountPanel1.f, addAccountPanel1.d, addAccountPanel1.e, 30.0F);
float fx = addAccountPanel1.d + 30.0F + 14.0F;
addAccountPanel1.searchField3.setBounds(addAccountPanel1.f, fx, addAccountPanel1.e, 40.0F);
addAccountPanel1.searchField.setBounds(addAccountPanel1.f, fx, addAccountPanel1.e, 40.0F);
addAccountPanel1.searchField2.setBounds(addAccountPanel1.f, fx, addAccountPanel1.e, 40.0F);
float gx = fx + 40.0F + 10.0F;
addAccountPanel1.toggleSwitch.setBounds(addAccountPanel1.f, gx + 4.0F, 38.0F, 22.0F);
addAccountPanel1.uiButton3.setBounds(addAccountPanel1.f + addAccountPanel1.e - 96.0F, gx, 96.0F, 30.0F);
addAccountPanel1.uiButton4.setBounds(addAccountPanel1.f + addAccountPanel1.e - 96.0F, gx, 96.0F, 30.0F);
addAccountPanel1.uiButton2.setBounds(addAccountPanel1.f + addAccountPanel1.e - 96.0F, gx, 96.0F, 30.0F);
}
private void L(RenderContext renderContext, Render2D render2D) {
this.searchField.render(renderContext);
this.uiButton4.render(renderContext);
this.L(renderContext, render2D, "A Minecraft session token from a launcher. Expires in ~24h and cannot be renewed.", this.uiButton4.D() + 30.0F);
}
}
@@ -0,0 +1,227 @@
package openonyx.ui.internal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import net.minecraft.block.Block;
import openonyx.history.internal.BlockSetSetting;
import openonyx.render.Render2D;
import openonyx.theme.Fonts;
import openonyx.theme.ThemeManager;
import openonyx.ui.MaterialIcons;
import openonyx.ui.RenderContext;
public class BlockListControl extends SettingControl {
private final List<Block> blocks;
private static final int F = 6;
private final SearchField searchField = new SearchField("Search blocks");
private float A;
private int K;
private final List<float[]> list;
private static final float C = 22.0F;
private static final float J = 9.0F;
private int D;
private static final float c = 10.0F;
private float a;
private static final float k = 6.0F;
private final List<Block> blocks2;
private String M;
private static final float L = 5.0F;
private final BlockSetSetting blockSetSetting;
private static final float m = 22.0F;
@Override
public void update(RenderContext renderContext) {
BlockListControl blockListControl1 = this;
int l = 0;
blockListControl1.searchField.setBounds(blockListControl1.f, blockListControl1.l(), blockListControl1.e, 40.0F);
blockListControl1.A = blockListControl1.l() + 40.0F + 6.0F;
blockListControl1.K = -1;
for (int j = 0; l < blockListControl1.blocks.size(); l = ++j) {
float f = blockListControl1.A + j * 22.0F;
if (renderContext.H >= blockListControl1.f
&& renderContext.H < blockListControl1.f + blockListControl1.e
&& renderContext.f >= f
&& renderContext.f < f + 22.0F) {
blockListControl1.K = j;
}
}
blockListControl1.blocks2.clear();
blockListControl1.blocks2.addAll(blockListControl1.blockSetSetting.getValue());
blockListControl1.list.clear();
float h = blockListControl1.f;
float kx = blockListControl1.A + blockListControl1.blocks.size() * 22.0F + (blockListControl1.blocks.isEmpty() ? 0.0F : 6.0F);
l = 0;
blockListControl1.D = -1;
for (int i = 0; l < blockListControl1.blocks2.size(); l = i) {
float g = Math.min(blockListControl1.L(renderContext, blockListControl1.blocks2.get(i)), blockListControl1.e);
if (h > blockListControl1.f && h + g > blockListControl1.f + blockListControl1.e) {
h = blockListControl1.f;
kx += 27.0F;
}
float[] mx = new float[3];
boolean bl = true;
mx[0] = h;
mx[1] = kx;
mx[2] = g;
blockListControl1.list.add(mx);
if (renderContext.H >= h && renderContext.H < h + g && renderContext.f >= kx && renderContext.f < kx + 22.0F) {
blockListControl1.D = i;
}
i++;
h += g + 5.0F;
}
blockListControl1.a = (blockListControl1.blocks2.isEmpty() ? kx : kx + 22.0F) + 6.0F - blockListControl1.d;
blockListControl1.update(renderContext);
}
public BlockListControl(BlockSetSetting blockSetSetting) {
super(blockSetSettingx);
this.blocks = new ArrayList<>();
this.blocks2 = new ArrayList<>();
this.list = new ArrayList<>();
this.M = "";
this.a = 60.0F;
this.K = -1;
this.D = -1;
this.blockSetSetting = blockSetSettingx;
this.searchField
.L(
string -> {
this.M = string == null ? "" : string.trim().toLowerCase(Locale.ROOT);
this.blocks.clear();
if (!this.M.isEmpty()) {
Iterator iterator = Block.blockRegistry.iterator();
label34:
while (true) {
for (Iterator iterator1 = iterator; iterator1.hasNext(); iterator1 = iterator) {
Block block;
if (BlockSetSetting.L(block = (Block)iterator.next()).contains(this.M)
|| block.getLocalizedName().toLowerCase(Locale.ROOT).contains(this.M)) {
this.blocks.add(block);
if (this.blocks.size() >= 6) {
break label34;
}
continue label34;
}
}
return;
}
}
}
);
this.uiComponents.add(this.searchField);
}
@Override
public boolean mouseClicked(float f, float g, int i) {
if (!this.i() || i != 0) {
return false;
} else if (this.searchField.mouseClicked(f, g, i)) {
return true;
} else if (this.K >= 0) {
this.blockSetSetting.D(this.blocks.get(this.K));
return true;
} else if (this.D >= 0) {
this.blockSetSetting.d(this.blocks2.get(this.D));
return true;
} else {
return false;
}
}
@Override
protected float L(RenderContext renderContext) {
return this.a;
}
@Override
protected void d(RenderContext renderContext, float w) {
BlockListControl blockListControl1 = this;
Render2D render2D = renderContext.render2D;
String string = blockListControl1.blocks2.size() + " selected";
float f = render2D.getTextWidth(Fonts.FONT_STYLE2, string);
blockListControl1.L(renderContext, blockListControl1.e - f - 12.0F);
render2D.drawTextRightVCentered(
Fonts.FONT_STYLE2,
string,
blockListControl1.f + blockListControl1.e,
blockListControl1.I(),
blockListControl1.L(renderContext.palette().onSurfaceVariant())
);
blockListControl1.searchField.render(renderContext);
for (int r = l = 0; r < blockListControl1.blocks.size(); r = ++l) {
Block block = blockListControl1.blocks.get(l);
float g = blockListControl1.A + l * 22.0F;
boolean bl = blockListControl1.blockSetSetting.L(block);
if (blockListControl1.K == l) {
render2D.roundedRect(
blockListControl1.f,
g,
blockListControl1.e,
22.0F,
4.0F,
blockListControl1.L(ThemeManager.withAlpha(renderContext.palette().onSurface(), 0.08F))
);
}
render2D.drawTextVCentered(
Fonts.FONT_STYLE15,
render2D.trimToWidth(Fonts.FONT_STYLE15, L(block), blockListControl1.e - 30.0F),
blockListControl1.f + 8.0F,
g + 11.0F,
blockListControl1.L(bl ? renderContext.palette().primary() : renderContext.palette().onSurface())
);
if (bl) {
MaterialIcons.d(
render2D, blockListControl1.f + blockListControl1.e - 14.0F, g + 11.0F, 12.0F, blockListControl1.L(renderContext.palette().primary())
);
}
}
for (int q = mx = 0; q < blockListControl1.list.size(); q = mx) {
float[] n = blockListControl1.list.get(mx);
float o = n[0];
float p = n[1];
float h = n[2];
render2D.roundedRect(o, p, h, 22.0F, 8.0F, blockListControl1.L(renderContext.palette().secondaryContainer()));
if (blockListControl1.D == mx) {
render2D.roundedRect(o, p, h, 22.0F, 8.0F, blockListControl1.L(ThemeManager.withAlpha(renderContext.palette().onSurface(), 0.08F)));
}
int i = renderContext.palette().onSecondaryContainer();
float j = h - 18.0F - 10.0F - 5.0F;
render2D.drawTextVCentered(
Fonts.FONT_STYLE16, render2D.trimToWidth(Fonts.FONT_STYLE16, L(blockListControl1.blocks2.get(mx)), j), o + 9.0F, p + 11.0F, blockListControl1.L(i)
);
h = o + h - 9.0F - 5.0F;
j = p + 11.0F;
float kx = 4.0F;
render2D.I(h - kx, j - kx, h + kx, j + kx, 1.4F, blockListControl1.L(i));
float s = h - kx;
float t = j + kx;
float u = h + kx;
float v = j - kx;
mx++;
render2D.I(s, t, u, v, 1.4F, blockListControl1.L(i));
}
}
private float L(RenderContext renderContext, Block block) {
return 18.0F + renderContext.render2D.getTextWidth(Fonts.FONT_STYLE16, L(block)) + 10.0F + 5.0F;
}
private static String L(Block block) {
return block.getLocalizedName();
}
}
@@ -0,0 +1,93 @@
package openonyx.ui.internal;
import openonyx.history.internal.BooleanSetting;
import openonyx.render.Render2D;
import openonyx.render.group_d.Animation;
import openonyx.render.group_d.Easings;
import openonyx.theme.ThemeManager;
import openonyx.ui.MaterialIcons;
import openonyx.ui.RenderContext;
import openonyx.ui.UiSupport_545;
public class CheckboxControl extends SettingControl {
private static final float j = 13.0F;
private static final float m = 15.0F;
private final Animation animation;
private final BooleanSetting booleanSetting;
private boolean i;
private boolean f;
private final UiSupport_545 uiSupport_545 = new UiSupport_545();
@Override
protected float L(RenderContext renderContext) {
return this.A();
}
private float m() {
return this.f + this.e - 15.0F;
}
private float B() {
return this.I() - 7.5F;
}
@Override
public void update(RenderContext renderContext) {
super.update(renderContext);
if (!this.i) {
this.i = true;
this.f = this.booleanSetting.getValue();
this.animation.set(this.f ? 1.0F : 0.0F);
}
if (this.booleanSetting.getValue() != this.f) {
this.f = this.booleanSetting.getValue();
this.animation.animateTo(this.f ? 1.0F : 0.0F, 200.0F, Easings.EASING2);
}
this.animation.update(renderContext.i);
this.uiSupport_545.L(renderContext.i, this.h, this.H);
}
public CheckboxControl(BooleanSetting booleanSetting) {
super(booleanSettingx);
this.animation = new Animation(0.0F);
this.booleanSetting = booleanSettingx;
}
@Override
public boolean mouseClicked(float f, float g, int i) {
if (this.i() && ix == 0 && this.contains(fx, g)) {
this.booleanSetting.toggle();
return true;
} else {
return false;
}
}
@Override
protected void d(RenderContext renderContext, float k) {
CheckboxControl checkboxControl1 = this;
Render2D render2D = renderContext.render2D;
float h = checkboxControl1.m();
float fx = checkboxControl1.B();
float g = checkboxControl1.animation.getValue();
checkboxControl1.L(renderContext, h - 10.0F - checkboxControl1.f);
checkboxControl1.uiSupport_545.L(render2D, h - 6.0F, fx - 6.0F, 27.0F, 27.0F, Float.MAX_VALUE, checkboxControl1.L(renderContext.palette().onSurface()));
if (g > 0.01F) {
float ix = (1.0F - g) * 15.0F / 2.0F;
render2D.roundedRect(h + ix, fx + ix, 15.0F - ix * 2.0F, 15.0F - ix * 2.0F, 4.0F, checkboxControl1.L(renderContext.palette().primary()));
}
if (g < 0.99F) {
render2D.roundedOutline(h, fx, 15.0F, 15.0F, 4.0F, 1.5F, checkboxControl1.L(renderContext.palette().onSurfaceVariant()));
}
if (g > 0.15F) {
float jx = Math.clamp((g - 0.15F) / 0.85F, 0.0F, 1.0F);
MaterialIcons.d(
render2D, h + 7.5F, fx + 7.5F, 13.0F * (0.7F + 0.3F * jx), checkboxControl1.L(ThemeManager.withAlpha(renderContext.palette().onPrimary(), jx))
);
}
}
}