Upload files to "src/openonyx/ui"

This commit is contained in:
winterflyt committed 2026-11-30 06:17:19 +02:00
1 parent c5cf9b7531
commit 71261547e6
5 files changed
+1583

No files matched your search

+484
View File
@@ -0,0 +1,484 @@
package openonyx.ui;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import openonyx.connection.Account;
import openonyx.connection.AccountManager;
import openonyx.connection.AccountType;
import openonyx.connection.ProfileSkinCache;
import openonyx.core.OnyxClient;
import openonyx.input.CharInput;
import openonyx.input.KeyInput;
import openonyx.render.Render2D;
import openonyx.render.RenderSupport_120;
import openonyx.render.group_d.Animation;
import openonyx.render.group_d.Easings;
import openonyx.theme.AlphaLevels;
import openonyx.theme.Fonts;
import openonyx.theme.ThemeManager;
import openonyx.ui.internal.AccountRow;
import openonyx.ui.internal.AddAccountPanel;
import openonyx.ui.internal.ProxyEditor;
import openonyx.ui.internal.UiButton;
import openonyx.ui.internal.UiButtonMode;
import openonyx.ui.internal.UiSupport_566;
import openonyx.ui.internal.UiSupport_571;
import openonyx.ui.internal.UiSupport_578;
import openonyx.ui.internal.UiSupport_602;
public class AccountsPanel extends UiComponent {
private final UiSupport_571 y;
private float n;
private static final float Y = 34.0F;
private boolean r;
private final UiSupport_578 uiSupport_578;
private static final float P = 36.0F;
private float V;
private final Animation animation;
private final AccountList accountList;
private float t;
private static float b;
private static final float E = 12.0F;
private float F;
private static float G;
private final UiSupport_602 uiSupport_602;
private static final float K = 82.0F;
private boolean B;
private final AddAccountPanel addAccountPanel = new AddAccountPanel();
private static final float J = 12.0F;
private float D;
private float c;
private final UiButton uiButton;
private float k;
private static final float g = 400.0F;
private boolean M;
private static final float L = 4.0F;
private final ProxyEditor proxyEditor = new ProxyEditor();
private static final float m = 96.0F;
private static final String h = "Accounts";
private final UiButton uiButton2;
private static final float I = 46.0F;
private final UiButton uiButton3;
private AccountRow accountRow;
private static final float H = 560.0F;
@Override
public boolean mouseReleased(float f, float g, int i) {
this.M = false;
if (this.B) {
return this.addAccountPanel.mouseReleased(f, gx, i);
} else {
return this.r
? this.proxyEditor.mouseReleased(f, gx, i)
: this.uiButton2.mouseReleased(f, gx, i)
| this.uiButton.mouseReleased(f, gx, i)
| this.uiButton3.mouseReleased(f, gx, i)
| this.accountList.mouseReleased(f, gx, i);
}
}
private void L(RenderContext renderContext, Render2D render2D) {
float f = this.d + this.i - 17.0F;
render2D.rect(this.f + 12.0F, this.d + this.i - 34.0F, this.e - 24.0F, 1.0F, renderContext.palette().outlineVariant());
render2D.drawTextVCentered(
Fonts.FONT_STYLE2,
render2D.trimToWidth(Fonts.FONT_STYLE2, this.L(), this.uiButton.d() - this.f - 24.0F),
this.f + 12.0F + 4.0F,
f,
renderContext.palette().onSurfaceVariant()
);
this.uiButton.render(renderContext);
this.uiButton3.render(renderContext);
}
private void d(float f, float g) {
this.setBounds(Math.round(Math.clamp(f, 96.0F - this.e, this.k - 96.0F)), Math.round(Math.clamp(gx, 0.0F, this.F - 46.0F)), this.e, this.i);
b = this.f - this.c;
G = this.d - this.t;
}
private static String L(Throwable throwable) {
Throwable throwable1 = throwable;
throwable = throwable1.getCause() == null ? throwable1 : throwable1.getCause();
return throwable.getMessage() == null ? throwable.toString() : throwable.getMessage();
}
private void L(String string, String string1) {
if (string1 != null && !string1.isBlank()) {
GuiScreen.setClipboardString(string1);
this.y.L(new StringBuilder().insert(0, string).append(" copied").toString());
} else {
this.L("Nothing to copy");
}
}
@Override
public boolean mouseClicked(float f, float g, int i) {
if (this.uiSupport_578.mouseClicked(f, gx, i)) {
return true;
}
if (this.B) {
if (this.uiSupport_602.mouseClicked(f, gx, i)) {
return true;
}
if (this.addAccountPanel.mouseClicked(f, gx, i)) {
return true;
}
} else if (this.r) {
if (this.uiSupport_602.mouseClicked(f, gx, i)) {
return true;
}
if (this.proxyEditor.mouseClicked(f, gx, i)) {
return true;
}
} else {
if (this.uiButton2.mouseClicked(f, gx, i)) {
return true;
}
if (this.uiButton.mouseClicked(f, gx, i)) {
return true;
}
if (this.uiButton3.mouseClicked(f, gx, i)) {
return true;
}
if (this.accountList.mouseClicked(f, gx, i)) {
return true;
}
}
if (i == 0 && f >= this.f && f < this.f + this.e && gx >= this.d && gx < this.d + 46.0F) {
this.M = true;
this.D = f - this.f;
this.n = gx - this.d;
return true;
} else {
return this.contains(f, gx);
}
}
public float l() {
return this.f + this.e / 2.0F;
}
private AccountManager L() {
return OnyxClient.accountManager;
}
@Override
public boolean mouseScrolled(float f, float g, double d) {
return this.uiSupport_578.mouseScrolled(f, gx, d) ? true : !this.B && !this.r && this.accountList.mouseScrolled(f, gx, d);
}
private List<UiSupport_566> L(AccountRow accountRow) {
AccountsPanel accountsPanel1 = this;
Account account = accountRowx.getAccount();
ArrayList arrayList;
(arrayList = new ArrayList()).add(UiSupport_566.D("\ue7fd", "Copy username", () -> this.L("Username", account.D())));
arrayList.add(UiSupport_566.D("\ue14d", "Copy UUID", () -> this.L("UUID", account.getUuid() == null ? null : account.getUuid().toString())));
if (account.getAccountType() != AccountType.OFFLINE) {
arrayList.add(UiSupport_566.D("\ue73c", "Copy access token", () -> this.L("Access token", account.d())));
if (account.L() != null) {
arrayList.add(UiSupport_566.D("\ue73c", "Copy OAuth refresh token", () -> this.L("Refresh token", account.L())));
}
arrayList.add(UiSupport_566.L());
arrayList.add(UiSupport_566.D("\ue5d5", "Refresh tokens", () -> this.d(accountRowx)));
}
arrayList.add(UiSupport_566.L());
arrayList.add(UiSupport_566.L("\ue872", "Delete", () -> this.L(account)));
return arrayList;
}
private void d(AccountRow accountRow) {
accountRowx.d(true);
this.L().L(accountRowx.getAccount()).whenComplete((void_, throwable) -> mc.addScheduledTask(() -> {
accountRowx.d(false);
if (throwable == null) {
this.y.L(new StringBuilder().insert(0, "Refreshed ").append(accountRowx.getAccount().D()).toString());
} else {
this.L(L(throwable));
}
}));
}
@Override
public boolean keyTyped(KeyInput keyInput) {
if (this.uiSupport_578.keyTyped(keyInput)) {
return true;
} else {
return this.B ? this.addAccountPanel.keyTyped(keyInput) : this.r && this.proxyEditor.keyTyped(keyInput);
}
}
private String L() {
AccountsPanel accountsPanel1 = this;
Account account = accountsPanel1.L().getAccount();
return new StringBuilder().insert(0, "Session: ").append(account == null ? mc.getSession().getUsername() : account.D()).toString();
}
public void L(float f) {
this.V = f;
}
public AccountsPanel() {
this.uiSupport_578 = new UiSupport_578();
this.y = new UiSupport_571();
this.animation = new Animation(0.0F);
this.V = 1.0F;
this.e = 560.0F;
this.i = 400.0F;
this.accountList = new AccountList(accountRow -> {
if (accountRowx.getAccount() != this.L().getAccount()) {
accountRowx.d(true);
this.L().d(accountRowx.getAccount()).whenComplete((void_, throwable) -> mc.addScheduledTask(() -> {
accountRowx.d(false);
if (throwable == null) {
this.y.L(new StringBuilder().insert(0, "Logged in as ").append(accountRowx.getAccount().D()).toString());
} else {
this.L(L(throwable));
}
}));
}
}, accountRow -> this.accountRow = accountRowx);
this.uiButton2 = new UiButton(UiButtonMode.FILLED, "Add", "\ue145", this::D);
this.uiButton = new UiButton(UiButtonMode.TEXT, "Proxy settings", "\ue8b8", () -> {
if (!this.B && !this.r) {
this.uiSupport_578.d();
this.proxyEditor.I();
this.r = true;
this.animation.animateTo(1.0F, 300.0F, Easings.EASING2);
}
});
this.uiButton3 = new UiButton(UiButtonMode.TEXT, "Restore launcher", () -> {
this.L().L();
this.y.L("Restored the launcher account");
});
this.uiSupport_602 = new UiSupport_602("\ue5c4", this::i);
this.addAccountPanel.D(account -> {
this.accountList.d();
this.i();
this.y.L(new StringBuilder().insert(0, "Added ").append(account.D()).toString());
});
this.addAccountPanel.d(string -> this.y.L(string, "\ue001"));
this.addAccountPanel.L(this.y::L);
this.proxyEditor.d(this.y::L);
this.proxyEditor.L(string -> this.y.L(string, "\ue001"));
this.uiComponents.add(this.uiButton2);
this.uiComponents.add(this.accountList);
this.uiComponents.add(this.uiButton);
this.uiComponents.add(this.uiButton3);
this.uiComponents.add(this.uiSupport_602);
this.uiComponents.add(this.addAccountPanel);
this.uiComponents.add(this.proxyEditor);
}
public void D() {
if (!this.B && !this.r) {
this.uiSupport_578.d();
this.addAccountPanel.D();
this.B = true;
this.animation.animateTo(1.0F, 300.0F, Easings.EASING2);
}
}
@Override
protected void L() {
AccountsPanel accountsPanel1 = this;
float f = accountsPanel1.d + 46.0F;
float gx = accountsPanel1.e - 24.0F;
accountsPanel1.uiSupport_602.setBounds(accountsPanel1.f + 12.0F, accountsPanel1.h() - 15.0F, 30.0F, 30.0F);
accountsPanel1.uiButton2.setBounds(accountsPanel1.f + accountsPanel1.e - 12.0F - 82.0F, accountsPanel1.h() - 15.0F, 82.0F, 30.0F);
accountsPanel1.accountList.setBounds(accountsPanel1.f + 12.0F, f, gx, accountsPanel1.i - 46.0F - 34.0F);
accountsPanel1.addAccountPanel.setBounds(accountsPanel1.f + 12.0F, f, gx, accountsPanel1.i - 46.0F - 12.0F);
accountsPanel1.proxyEditor.setBounds(accountsPanel1.f + 12.0F, f, gx, accountsPanel1.i - 46.0F - 12.0F);
accountsPanel1.y.setBounds(accountsPanel1.f, accountsPanel1.d, accountsPanel1.e, accountsPanel1.i);
}
private void D(RenderContext renderContext) {
Render2D render2D = renderContext.render2D;
float f = this.d + this.i - 17.0F;
float gx = this.uiButton3.L(render2D);
this.uiButton3.setBounds(this.f + this.e - 12.0F - gx, f - 15.0F, gx, 30.0F);
this.uiButton3.L(this.L().getAccount() != null);
float hx = this.uiButton.L(render2D);
this.uiButton.setBounds(this.uiButton3.d() - hx, f - 15.0F, hx, 30.0F);
}
@Override
public void update(RenderContext renderContext) {
this.D(renderContext);
this.animation.update(renderContext.i);
this.h = this.contains(renderContext.H, renderContext.f);
float f;
if ((f = this.animation.getValue()) < 0.999F) {
this.uiButton2.update(renderContext);
this.accountList.update(renderContext);
this.uiButton.update(renderContext);
this.uiButton3.update(renderContext);
}
AccountsPanel accountsPanel1;
label21: {
if (f > 0.001F) {
this.uiSupport_602.update(renderContext);
if (this.B) {
this.addAccountPanel.update(renderContext);
accountsPanel1 = this;
break label21;
}
this.proxyEditor.update(renderContext);
}
accountsPanel1 = this;
}
if (accountsPanel1.accountRow != null) {
this.uiSupport_578.d(this.L(this.accountRow), this.accountRow.getUiSupport_602(), this, renderContext.render2D);
this.accountRow = null;
}
this.uiSupport_578.update(renderContext);
this.y.update(renderContext);
}
private float h() {
return this.d + 23.0F;
}
@Override
public boolean charTyped(CharInput charInput) {
return this.B ? this.addAccountPanel.charTyped(charInput) : this.r && this.proxyEditor.charTyped(charInput);
}
@Override
public void render(RenderContext renderContext) {
AccountsPanel accountsPanel1 = this;
Render2D render2D = renderContext.render2D;
Render2D render2D1 = renderContext.render2D;
Render2D render2D3 = renderContext.render2D;
Render2D render2D2 = renderContext.render2D;
render2D.pushAlpha(accountsPanel1.V);
render2D3.shadow(accountsPanel1.f, accountsPanel1.d, accountsPanel1.e, accountsPanel1.i, 28.0F, 3);
render2D2.popAlpha();
RenderSupport_120.L(
render2D1,
accountsPanel1.f,
accountsPanel1.d,
accountsPanel1.e,
accountsPanel1.i,
28.0F,
ThemeManager.withAlpha(AlphaLevels.L(2, renderContext.palette()), accountsPanel1.V)
);
float f;
if ((f = accountsPanel1.animation.getValue()) < 0.999F) {
float gx;
float i = gx = accountsPanel1.V * (1.0F - f);
render2D.drawTextVCentered(
Fonts.FONT_STYLE18,
"Accounts",
accountsPanel1.f + 12.0F + 4.0F,
accountsPanel1.h(),
ThemeManager.withAlpha(renderContext.palette().onSurface(), gx)
);
render2D.pushAlpha(i);
accountsPanel1.uiButton2.render(renderContext);
render2D.popAlpha();
render2D.pushAlpha(gx);
render2D.pushMatrix();
render2D.translate(-36.0F * f, 0.0F);
accountsPanel1.accountList.render(renderContext);
accountsPanel1.L(renderContext, render2D);
render2D.popMatrix();
render2D.popAlpha();
}
if (f > 0.001F) {
float hx;
render2D.pushAlpha(hx = accountsPanel1.V * f);
accountsPanel1.uiSupport_602.render(renderContext);
String string;
AccountsPanel accountsPanel2;
if (accountsPanel1.B) {
string = "Add account";
accountsPanel2 = accountsPanel1;
} else {
string = "Proxy settings";
accountsPanel2 = accountsPanel1;
}
render2D.drawTextVCentered(
Fonts.FONT_STYLE18, string, accountsPanel2.uiSupport_602.d() + 30.0F + 6.0F, accountsPanel1.h(), renderContext.palette().onSurface()
);
render2D.popAlpha();
render2D.pushAlpha(hx);
render2D.pushMatrix();
render2D.translate(36.0F * (1.0F - f), 0.0F);
if (accountsPanel1.B) {
accountsPanel1.addAccountPanel.render(renderContext);
render2D1 = render2D;
} else {
accountsPanel1.proxyEditor.render(renderContext);
render2D1 = render2D;
}
render2D1.popMatrix();
render2D.popAlpha();
}
accountsPanel1.uiSupport_578.render(renderContext);
accountsPanel1.y.render(renderContext);
}
public void L(float f, float g) {
this.k = f;
this.F = gx;
this.c = (f - this.e) / 2.0F;
this.t = (gx - this.i) / 2.0F;
this.d(this.c + b, this.t + G);
}
@Override
public boolean mouseDragged(float f, float g, int i, float h, float j) {
if (!this.M) {
return false;
}
this.d(f - this.D, gx - this.n);
return true;
}
public float I() {
return this.d + this.i / 2.0F;
}
private void L(Account account) {
ProfileSkinCache.L(account.getUuid());
this.L().L(account);
this.accountList.d();
this.y.L(new StringBuilder().insert(0, "Removed ").append(account.D()).toString());
}
public boolean i() {
if (!this.B && !this.r) {
return false;
}
if (this.B) {
this.addAccountPanel.D();
}
this.B = false;
this.r = false;
this.animation.animateTo(0.0F, 300.0F, Easings.EASING2);
return true;
}
}