diff --git a/src/openonyx/ui/UiComponent.java b/src/openonyx/ui/UiComponent.java new file mode 100644 index 0000000..1682bfa --- /dev/null +++ b/src/openonyx/ui/UiComponent.java @@ -0,0 +1,177 @@ +package openonyx.ui; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import openonyx.core.MinecraftAccess; +import openonyx.input.CharInput; +import openonyx.input.KeyInput; + +public abstract class UiComponent implements MinecraftAccess { + protected boolean h; + protected final List uiComponents; + protected boolean I; + protected float d; + protected float i; + protected float f; + protected boolean H; + protected float e; + + public boolean mouseReleased(float f, float g, int i) { + UiComponent uiComponent1 = this; + boolean bl = false; + + Iterator iterator; + for (Iterator iterator1 = iterator = uiComponent1.uiComponents.iterator(); iterator1.hasNext(); iterator1 = iterator) { + UiComponent uiComponent2 = (UiComponent)iterator.next(); + bl |= uiComponent2.mouseReleased(fx, g, ix); + } + + return bl; + } + + public boolean mouseScrolled(float f, float g, double d) { + UiComponent uiComponent1 = this; + Iterator iterator = uiComponent1.uiComponents.iterator(); + + while (iterator.hasNext()) { + if (((UiComponent)iterator.next()).mouseScrolled(fx, g, dx)) { + return true; + } + } + + return false; + } + + public float i() { + return this.e; + } + + public float D() { + return this.d; + } + + public boolean D() { + return this.h; + } + + public boolean d() { + return this.I; + } + + public float L(float f) { + return this.i; + } + + public boolean keyTyped(KeyInput keyInput) { + UiComponent uiComponent1 = this; + Iterator iterator = uiComponent1.uiComponents.iterator(); + + while (iterator.hasNext()) { + if (((UiComponent)iterator.next()).keyTyped(keyInput)) { + return true; + } + } + + return false; + } + + public void update(RenderContext renderContext) { + UiComponent uiComponent1 = this; + uiComponent1.h = uiComponent1.I && uiComponent1.contains(renderContext.H, renderContext.f); + + for (Iterator iterator1 = iterator = uiComponent1.uiComponents.iterator(); iterator1.hasNext(); iterator1 = iterator) { + ((UiComponent)iterator.next()).update(renderContext); + } + } + + public void setBounds(float f, float g, float h, float i) { + this.f = fx; + this.d = g; + this.e = hx; + this.i = ix; + this.L(); + } + + public boolean L() { + return this.H; + } + + public UiComponent() { + int ix = --1; + super(); + this.uiComponents = new ArrayList<>(); + this.I = (boolean)ix; + } + + public List getUiComponents() { + return this.uiComponents; + } + + public boolean charTyped(CharInput charInput) { + UiComponent uiComponent1 = this; + Iterator iterator = uiComponent1.uiComponents.iterator(); + + while (iterator.hasNext()) { + if (((UiComponent)iterator.next()).charTyped(charInput)) { + return true; + } + } + + return false; + } + + public float d() { + return this.f; + } + + public void render(RenderContext renderContext) { + UiComponent uiComponent1 = this; + + for (Iterator iterator1 = iterator = uiComponent1.uiComponents.iterator(); iterator1.hasNext(); iterator1 = iterator) { + ((UiComponent)iterator.next()).render(renderContext); + } + } + + public boolean mouseDragged(float f, float g, int i, float h, float j) { + UiComponent uiComponent1 = this; + Iterator iterator = uiComponent1.uiComponents.iterator(); + + while (iterator.hasNext()) { + if (((UiComponent)iterator.next()).mouseDragged(fx, g, ix, hx, j)) { + return true; + } + } + + return false; + } + + public float L() { + return this.i; + } + + protected void L() { + } + + public boolean mouseClicked(float f, float g, int i) { + UiComponent uiComponent1 = this; + Iterator iterator = uiComponent1.uiComponents.iterator(); + + while (iterator.hasNext()) { + UiComponent uiComponent2; + if ((uiComponent2 = (UiComponent)iterator.next()).I && uiComponent2.mouseClicked(fx, g, ix)) { + return true; + } + } + + return false; + } + + public boolean contains(float f, float g) { + return fx >= this.f && fx < this.f + this.e && g >= this.d && g < this.d + this.i; + } + + public void L(boolean bl) { + this.I = bl; + } +} diff --git a/src/openonyx/ui/UiSupport_544.java b/src/openonyx/ui/UiSupport_544.java new file mode 100644 index 0000000..3e046d3 --- /dev/null +++ b/src/openonyx/ui/UiSupport_544.java @@ -0,0 +1,199 @@ +package openonyx.ui; + +import java.io.IOException; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import openonyx.input.CharInput; +import openonyx.input.KeyInput; +import openonyx.render.BoxBlurShader; +import openonyx.render.Render2D; +import openonyx.render.RenderSupport_120; +import openonyx.render.group_d.Animation; +import openonyx.render.group_d.Easings; +import openonyx.theme.ThemeManager; +import org.lwjgl.input.Mouse; + +public class UiSupport_544 extends GuiScreen { + private boolean J; + private float D; + private static final float c = 16.0F; + private final Render2D render2D; + private static final float k = 0.92F; + private long g; + private final Animation animation; + private final Animation animation2; + private static final float j = 0.62F; + private float m; + private float h; + private final AccountsPanel accountsPanel = new AccountsPanel(); + private static final int I = 120; + private static final float d = 0.32F; + private float i; + private static final float f = 0.72F; + private final GuiScreen guiScreen; + private static final float e = 100.0F; + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + private void d() { + UiSupport_544 uiSupport_5441 = this; + float fx = Math.min(uiSupport_5441.width * 0.62F / uiSupport_5441.accountsPanel.i(), uiSupport_5441.height * 0.72F / uiSupport_5441.accountsPanel.L()); + uiSupport_5441.D = Math.min(ThemeManager.getUiScale(), fx); + uiSupport_5441.m = ThemeManager.getUiScale(); + uiSupport_5441.accountsPanel.L(uiSupport_5441.width / uiSupport_5441.D, uiSupport_5441.height / uiSupport_5441.D); + } + + @Override + protected void mouseClicked(int i, int j, int k) throws IOException { + this.L(); + if (!this.accountsPanel.mouseClicked(this.h, this.i, kx)) { + super.mouseClicked(ix, jx, kx); + } + } + + private float L(double d) { + return (float)(dx / this.D); + } + + public UiSupport_544(GuiScreen guiScreen) { + this.render2D = new Render2D(); + this.animation = new Animation(0.0F); + this.animation2 = new Animation(0.0F); + this.D = 1.0F; + this.guiScreen = guiScreenx; + } + + @Override + public void setWorldAndResolution(Minecraft minecraft, int i, int j) { + super.setWorldAndResolution(minecraft, ix, jx); + if (this.guiScreen != null && minecraft.theWorld == null) { + this.guiScreen.setWorldAndResolution(minecraft, ix, jx); + } + + this.d(); + } + + @Override + public void drawScreen(int i, int j, float f) { + float gx = this.L(); + this.animation.update(gx); + this.animation2.update(gx); + if (this.m != ThemeManager.getUiScale()) { + this.d(); + } + + this.L(); + if (this.mc.theWorld == null && this.guiScreen != null) { + this.guiScreen.drawScreen(-1, -1, fx); + } + + this.render2D.beginFrame(); + if (this.mc.theWorld == null) { + if (this.guiScreen == null) { + this.render2D.L(0.0F, 0.0F, this.width, this.height); + this.render2D.clearScissors(); + BoxBlurShader.d(); + BoxBlurShader.l(); + this.render2D.beginFrame(); + } + } else { + RenderSupport_120.d(); + this.render2D.rect(0.0F, 0.0F, this.width, this.height, ThemeManager.scrim(0.32F * this.animation2.getValue())); + } + + RenderContext renderContext = new RenderContext(this.render2D, gx, this.h, this.i); + float hx = this.animation.getValue(); + this.render2D.pushMatrix(); + this.render2D.transforms().L(this.D, this.D); + this.render2D.scaleAround(0.92F + 0.07999998F * hx, this.accountsPanel.l(), this.accountsPanel.I()); + this.accountsPanel.L(hx); + this.accountsPanel.update(renderContext); + this.accountsPanel.render(renderContext); + this.render2D.popMatrix(); + this.render2D.clearScissors(); + } + + private float L() { + long l = System.nanoTime(); + if (this.g == 0L) { + this.g = l; + return 16.0F; + } else { + float fx = (float)(l - this.g) / 1000000.0F; + this.g = l; + return Math.min(fx, 100.0F); + } + } + + @Override + public void handleMouseInput() throws IOException { + UiSupport_544 uiSupport_5441 = this; + int ix; + if ((ix = Mouse.getEventDWheel()) != 0) { + uiSupport_5441.L(); + if (uiSupport_5441.accountsPanel.mouseScrolled(uiSupport_5441.h, uiSupport_5441.i, ix / 120.0)) { + return; + } + } + + uiSupport_5441.handleMouseInput(); + } + + @Override + protected void mouseReleased(int i, int j, int k) { + this.L(); + if (!this.accountsPanel.mouseReleased(this.h, this.i, kx)) { + super.mouseReleased(ix, jx, kx); + } + } + + private void L() { + UiSupport_544 uiSupport_5441 = this; + int ix = new ScaledResolution(uiSupport_5441.mc).getScaleFactor(); + uiSupport_5441.h = uiSupport_5441.L((float)Minecraft.getScaledMouseX() / ix); + uiSupport_5441.i = uiSupport_5441.L((float)(uiSupport_5441.mc.displayHeight - Minecraft.getScaledMouseY()) / ix); + } + + @Override + protected void mouseClickMove(int i, int j, int k, long l) { + UiSupport_544 uiSupport_5441 = this; + float fx = uiSupport_5441.h; + float gx = uiSupport_5441.i; + uiSupport_5441.L(); + if (!uiSupport_5441.accountsPanel.mouseDragged(uiSupport_5441.h, uiSupport_5441.i, kx, uiSupport_5441.h - fx, uiSupport_5441.i - gx)) { + uiSupport_5441.mouseClickMove(ix, jx, kx, l); + } + } + + @Override + protected void keyTyped(char c, int i) throws IOException { + KeyInput keyInput = new KeyInput(ix, 0, 0, cx); + if (!this.accountsPanel.keyTyped(keyInput)) { + if (ix != 1 || !this.accountsPanel.i()) { + if (cx < ' ' || !this.accountsPanel.charTyped(new CharInput(cx, 0))) { + if (ix == 1) { + this.mc.displayGuiScreen(this.guiScreen); + } else { + super.keyTyped(cx, ix); + } + } + } + } + } + + @Override + public void initGui() { + if (!this.J) { + this.J = true; + this.animation.set(0.0F).animateTo(1.0F, 400.0F, Easings.EASING7); + this.animation2.set(0.0F).animateTo(1.0F, 250.0F, Easings.EASING5); + } + + this.g = 0L; + this.d(); + } +} diff --git a/src/openonyx/ui/UiSupport_545.java b/src/openonyx/ui/UiSupport_545.java new file mode 100644 index 0000000..5f24a56 --- /dev/null +++ b/src/openonyx/ui/UiSupport_545.java @@ -0,0 +1,28 @@ +package openonyx.ui; + +import openonyx.render.Render2D; +import openonyx.render.group_d.Animation; +import openonyx.render.group_d.Easings; +import openonyx.theme.ThemeManager; + +public final class UiSupport_545 { + private final Animation animation = new Animation(0.0F); + + public void L(Render2D render2D, float f, float g, float h, float i, float j, int k) { + UiSupport_545 uiSupport_5451 = this; + float l; + if (!((l = uiSupport_5451.animation.getValue()) <= 0.001F)) { + render2D.roundedRect(f, g, h, i, j, ThemeManager.withAlpha(k, l)); + } + } + + public void L(float f, boolean bl, boolean bl1) { + UiSupport_545 uiSupport_5451 = this; + float g = bl1 ? 0.1F : (bl ? 0.08F : 0.0F); + if (uiSupport_5451.animation.getTarget() != g) { + uiSupport_5451.animation.animateTo(g, bl1 ? 100.0F : 150.0F, Easings.EASING6); + } + + uiSupport_5451.animation.update(f); + } +} diff --git a/src/openonyx/ui/UiSupport_550.java b/src/openonyx/ui/UiSupport_550.java new file mode 100644 index 0000000..2ae0ced --- /dev/null +++ b/src/openonyx/ui/UiSupport_550.java @@ -0,0 +1,182 @@ +package openonyx.ui; + +import java.io.IOException; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import openonyx.input.CharInput; +import openonyx.input.KeyInput; +import openonyx.render.BoxBlurShader; +import openonyx.render.Render2D; +import openonyx.render.RenderSupport_120; +import openonyx.render.group_d.Animation; +import openonyx.render.group_d.Easings; +import openonyx.theme.ThemeManager; + +public class UiSupport_550 extends GuiScreen { + private final Render2D render2D; + private final Animation animation; + private static final float a = 0.92F; + private static final float k = 100.0F; + private float g; + private boolean M; + private static final float L = 0.5F; + private final GuiScreen guiScreen; + private static final float m = 0.32F; + private long h; + private static final float l = 16.0F; + private float I; + private final Animation animation2; + private float i; + private float f; + private final ProxyPanel proxyPanel = new ProxyPanel(() -> this.mc.displayGuiScreen(this.guiScreen)); + private static final float e = 0.72F; + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + private void D() { + UiSupport_550 uiSupport_5501 = this; + float fx = Math.min(uiSupport_5501.width * 0.5F / uiSupport_5501.proxyPanel.i(), uiSupport_5501.height * 0.72F / uiSupport_5501.proxyPanel.L()); + uiSupport_5501.f = Math.min(ThemeManager.getUiScale(), fx); + uiSupport_5501.I = ThemeManager.getUiScale(); + uiSupport_5501.proxyPanel.L(uiSupport_5501.width / uiSupport_5501.f, uiSupport_5501.height / uiSupport_5501.f); + } + + @Override + protected void mouseClicked(int i, int j, int k) throws IOException { + this.d(); + if (!this.proxyPanel.mouseClicked(this.g, this.i, kx)) { + super.mouseClicked(ix, j, kx); + } + } + + public UiSupport_550(GuiScreen guiScreen) { + this.render2D = new Render2D(); + this.animation = new Animation(0.0F); + this.animation2 = new Animation(0.0F); + this.f = 1.0F; + this.guiScreen = guiScreenx; + } + + private void d() { + UiSupport_550 uiSupport_5501 = this; + int ix = new ScaledResolution(uiSupport_5501.mc).getScaleFactor(); + uiSupport_5501.g = uiSupport_5501.L((float)Minecraft.getScaledMouseX() / ix); + uiSupport_5501.i = uiSupport_5501.L((float)(uiSupport_5501.mc.displayHeight - Minecraft.getScaledMouseY()) / ix); + } + + @Override + protected void mouseClickMove(int i, int j, int k, long l) { + UiSupport_550 uiSupport_5501 = this; + float fx = uiSupport_5501.g; + float gx = uiSupport_5501.i; + uiSupport_5501.d(); + if (!uiSupport_5501.proxyPanel.mouseDragged(uiSupport_5501.g, uiSupport_5501.i, kx, uiSupport_5501.g - fx, uiSupport_5501.i - gx)) { + uiSupport_5501.mouseClickMove(ix, j, kx, lx); + } + } + + @Override + protected void keyTyped(char c, int i) throws IOException { + KeyInput keyInput = new KeyInput(ix, 0, 0, c); + if (!this.proxyPanel.keyTyped(keyInput)) { + if (c < ' ' || !this.proxyPanel.charTyped(new CharInput(c, 0))) { + if (ix == 1) { + this.L(); + } else { + super.keyTyped(c, ix); + } + } + } + } + + @Override + protected void mouseReleased(int i, int j, int k) { + this.d(); + if (!this.proxyPanel.mouseReleased(this.g, this.i, kx)) { + super.mouseReleased(ix, j, kx); + } + } + + @Override + public void drawScreen(int i, int j, float f) { + float gx = this.L(); + this.animation.update(gx); + this.animation2.update(gx); + if (this.I != ThemeManager.getUiScale()) { + this.D(); + } + + this.d(); + if (this.mc.theWorld == null && this.guiScreen != null) { + this.guiScreen.drawScreen(-1, -1, fx); + } + + this.render2D.beginFrame(); + if (this.mc.theWorld == null) { + if (this.guiScreen == null) { + this.render2D.L(0.0F, 0.0F, this.width, this.height); + this.render2D.clearScissors(); + BoxBlurShader.d(); + BoxBlurShader.l(); + this.render2D.beginFrame(); + } + } else { + RenderSupport_120.d(); + this.render2D.rect(0.0F, 0.0F, this.width, this.height, ThemeManager.scrim(0.32F * this.animation2.getValue())); + } + + RenderContext renderContext = new RenderContext(this.render2D, gx, this.g, this.i); + float hx = this.animation.getValue(); + this.render2D.pushMatrix(); + this.render2D.transforms().L(this.f, this.f); + this.render2D.scaleAround(0.92F + 0.07999998F * hx, this.proxyPanel.I(), this.proxyPanel.h()); + this.proxyPanel.L(hx); + this.proxyPanel.update(renderContext); + this.proxyPanel.render(renderContext); + this.render2D.popMatrix(); + this.render2D.clearScissors(); + } + + private float L() { + long lx = System.nanoTime(); + if (this.h == 0L) { + this.h = lx; + return 16.0F; + } else { + float fx = (float)(lx - this.h) / 1000000.0F; + this.h = lx; + return Math.min(fx, 100.0F); + } + } + + private float L(double d) { + return (float)(d / this.f); + } + + @Override + public void initGui() { + if (!this.M) { + this.M = true; + this.proxyPanel.d(); + this.animation.set(0.0F).animateTo(1.0F, 400.0F, Easings.EASING7); + this.animation2.set(0.0F).animateTo(1.0F, 250.0F, Easings.EASING5); + } + + this.h = 0L; + this.D(); + } + + @Override + public void setWorldAndResolution(Minecraft minecraft, int i, int j) { + super.setWorldAndResolution(minecraft, ix, j); + if (this.guiScreen != null && minecraft.theWorld == null) { + this.guiScreen.setWorldAndResolution(minecraft, ix, j); + } + + this.D(); + } +} diff --git a/src/openonyx/ui/UiSupport_554.java b/src/openonyx/ui/UiSupport_554.java new file mode 100644 index 0000000..c9ee855 --- /dev/null +++ b/src/openonyx/ui/UiSupport_554.java @@ -0,0 +1,29 @@ +package openonyx.ui; + +import openonyx.render.group_d.Animation; +import openonyx.render.group_d.Easings; + +public final class UiSupport_554 { + private static final Animation ANIMATION = new Animation(1.0F); + private static long e; + + public static void L(boolean bl) { + boolean bl1 = bl; + long l = System.nanoTime(); + float f = e == 0L ? 16.0F : Math.min((float)(l - e) / 1000000.0F, 100.0F); + e = l; + float g = bl1 ? 1.0F : 0.0F; + if (ANIMATION.getTarget() != g) { + ANIMATION.animateTo(g, 300.0F, Easings.EASING2); + } + + ANIMATION.update(f); + } + + public static float L() { + return ANIMATION.getValue(); + } + + private UiSupport_554() { + } +}