Upload files to "src/openonyx/ui/internal"
This commit is contained in:
1 parent
c0c927c844
commit
3a145fea8f
5 files changed
+811
No files matched your search
@@ -0,0 +1,133 @@
|
|||||||
|
package openonyx.ui.internal;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import openonyx.history.internal.EnumSetting;
|
||||||
|
import openonyx.render.Render2D;
|
||||||
|
import openonyx.render.group_d.Animation;
|
||||||
|
import openonyx.render.group_d.Easings;
|
||||||
|
import openonyx.render.group_e.FontStyle;
|
||||||
|
import openonyx.theme.Fonts;
|
||||||
|
import openonyx.theme.Palette;
|
||||||
|
import openonyx.ui.RenderContext;
|
||||||
|
import openonyx.ui.UiSupport_545;
|
||||||
|
|
||||||
|
public class EnumControl<E extends Enum<E>> extends SettingControl {
|
||||||
|
private static final float D = 24.0F;
|
||||||
|
private static final float c = 8.0F;
|
||||||
|
private final List<Animation> animations;
|
||||||
|
private final List<UiSupport_545> uiSupport_545s;
|
||||||
|
private int g;
|
||||||
|
private final EnumSetting<E> enumSetting;
|
||||||
|
private boolean L;
|
||||||
|
private static final float j = 1.5F;
|
||||||
|
private static final float m = 4.0F;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float L(RenderContext renderContext) {
|
||||||
|
return this.B() - this.d + this.enumSetting.getValues().size() * 24.0F - 8.0F + 6.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(RenderContext renderContext) {
|
||||||
|
EnumControl enumControl1 = this;
|
||||||
|
int jx = 0;
|
||||||
|
enumControl1.update(renderContext);
|
||||||
|
enumControl1.g = -1;
|
||||||
|
|
||||||
|
for (int i = 0; jx < enumControl1.enumSetting.getValues().size(); jx = i) {
|
||||||
|
boolean bl1 = enumControl1.enumSetting.getValue() == enumControl1.enumSetting.getValues().get(i);
|
||||||
|
boolean bl = renderContext.H >= enumControl1.f
|
||||||
|
&& renderContext.H < enumControl1.f + enumControl1.e
|
||||||
|
&& renderContext.f >= enumControl1.L(i)
|
||||||
|
&& renderContext.f < enumControl1.L(i) + 24.0F;
|
||||||
|
if (bl) {
|
||||||
|
enumControl1.g = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
Animation animation = enumControl1.animations.get(i);
|
||||||
|
Animation animation1;
|
||||||
|
if (!enumControl1.L) {
|
||||||
|
animation.set(bl1 ? 1.0F : 0.0F);
|
||||||
|
animation1 = animation;
|
||||||
|
} else {
|
||||||
|
if (animation.getTarget() != (bl1 ? 1.0F : 0.0F)) {
|
||||||
|
animation.animateTo(bl1 ? 1.0F : 0.0F, 200.0F, Easings.EASING2);
|
||||||
|
}
|
||||||
|
|
||||||
|
animation1 = animation;
|
||||||
|
}
|
||||||
|
|
||||||
|
animation1.update(renderContext.i);
|
||||||
|
UiSupport_545 uiSupport_545 = enumControl1.uiSupport_545s.get(i);
|
||||||
|
i++;
|
||||||
|
uiSupport_545.L(renderContext.i, bl, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
enumControl1.L = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float B() {
|
||||||
|
return this.l() - 1.5F;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumControl(EnumSetting<E> enumSetting) {
|
||||||
|
int jx = 2 & 5;
|
||||||
|
super(enumSettingx);
|
||||||
|
this.animations = new ArrayList<>();
|
||||||
|
this.uiSupport_545s = new ArrayList<>();
|
||||||
|
this.g = -1;
|
||||||
|
this.enumSetting = enumSettingx;
|
||||||
|
|
||||||
|
for (int i = jx; jx < enumSettingx.getValues().size(); jx = i) {
|
||||||
|
this.animations.add(new Animation(0.0F));
|
||||||
|
i++;
|
||||||
|
this.uiSupport_545s.add(new UiSupport_545());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float L(int i) {
|
||||||
|
return this.B() - 4.0F + i * 24.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void d(RenderContext renderContext, float m) {
|
||||||
|
EnumControl enumControl1 = this;
|
||||||
|
Render2D render2D = renderContext.render2D;
|
||||||
|
int k = 0;
|
||||||
|
enumControl1.L(renderContext, enumControl1.e);
|
||||||
|
|
||||||
|
for (int i = 0; k < enumControl1.enumSetting.getValues().size(); k = i) {
|
||||||
|
Enum enum_ = enumControl1.enumSetting.getValues().get(i);
|
||||||
|
float gx;
|
||||||
|
float f = (gx = enumControl1.L(i)) + 12.0F;
|
||||||
|
boolean bl = enumControl1.enumSetting.getValue() == enum_;
|
||||||
|
enumControl1.uiSupport_545s
|
||||||
|
.get(i)
|
||||||
|
.L(render2D, enumControl1.f - 4.0F, gx, enumControl1.e + 8.0F, 24.0F, 8.0F, enumControl1.L(renderContext.palette().onSurface()));
|
||||||
|
int jx = bl ? renderContext.palette().primary() : renderContext.palette().onSurfaceVariant();
|
||||||
|
render2D.L(enumControl1.f + 8.0F, f, 8.0F, 1.5F, enumControl1.L(jx));
|
||||||
|
float h;
|
||||||
|
if ((h = enumControl1.animations.get(i).getValue()) > 0.01F) {
|
||||||
|
render2D.circle(enumControl1.f + 8.0F, f, 4.0F * h, enumControl1.L(renderContext.palette().primary()));
|
||||||
|
}
|
||||||
|
|
||||||
|
FontStyle fontStyle = Fonts.FONT_STYLE15;
|
||||||
|
String string = EnumSetting.displayName(enum_);
|
||||||
|
float l = enumControl1.f + 16.0F + 9.0F;
|
||||||
|
Palette palette = renderContext.palette();
|
||||||
|
i++;
|
||||||
|
render2D.drawTextVCentered(fontStyle, string, l, f, enumControl1.L(palette.onSurface()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseClicked(float f, float g, int i) {
|
||||||
|
if (this.i() && i == 0 && this.g >= 0) {
|
||||||
|
this.enumSetting.setValue(this.enumSetting.getValues().get(this.g));
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
package openonyx.ui.internal;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import openonyx.history.SettingGroup;
|
||||||
|
import openonyx.render.group_e.FontStyle;
|
||||||
|
import openonyx.theme.Fonts;
|
||||||
|
import openonyx.theme.ThemeManager;
|
||||||
|
import openonyx.ui.RenderContext;
|
||||||
|
import openonyx.ui.UiComponent;
|
||||||
|
|
||||||
|
public class GroupControl extends SettingControl {
|
||||||
|
private float j;
|
||||||
|
protected static final float m = 13.0F;
|
||||||
|
private final SettingList settingList = new SettingList();
|
||||||
|
private final ToggleSwitch toggleSwitch;
|
||||||
|
private final SettingGroup settingGroup;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(RenderContext renderContext) {
|
||||||
|
if (this.toggleSwitch != null) {
|
||||||
|
this.toggleSwitch.setBounds(this.f + this.e - 38.0F, this.d + (this.G() - 22.0F) / 2.0F, 38.0F, 22.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.j = this.settingList.layout(this.m(), this.d + this.G(), this.B());
|
||||||
|
super.update(renderContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupControl(SettingGroup settingGroup) {
|
||||||
|
super(settingGroupx);
|
||||||
|
this.settingGroup = settingGroupx;
|
||||||
|
this.settingList.setSettings(settingGroupx.getSettings());
|
||||||
|
this.uiComponents.addAll(this.settingList.getSettingControls());
|
||||||
|
if (settingGroupx.isToggleable()) {
|
||||||
|
this.toggleSwitch = new ToggleSwitch(() -> settingGroupx.getEnabled().getValue(), boolean_ -> settingGroupx.getEnabled().setValue(boolean_));
|
||||||
|
this.uiComponents.add(this.toggleSwitch);
|
||||||
|
} else {
|
||||||
|
this.toggleSwitch = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected FontStyle L() {
|
||||||
|
return Fonts.FONT_STYLE18;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float L(RenderContext renderContext) {
|
||||||
|
return this.G() + this.j + (this.j > 0.5F ? 6.0F : 0.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float G() {
|
||||||
|
GroupControl groupControl1 = this;
|
||||||
|
float f = groupControl1.A();
|
||||||
|
return groupControl1.toggleSwitch == null ? f : Math.max(f, 34.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float m() {
|
||||||
|
return this.f + 13.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseClicked(float f, float g, int i) {
|
||||||
|
GroupControl groupControl1 = this;
|
||||||
|
if (!groupControl1.i()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator iterator = groupControl1.uiComponents.iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
if (((UiComponent)iterator.next()).mouseClicked(f, g, i)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (groupControl1.toggleSwitch != null
|
||||||
|
&& i == 0
|
||||||
|
&& f >= groupControl1.f
|
||||||
|
&& f < groupControl1.f + groupControl1.e
|
||||||
|
&& g >= groupControl1.d
|
||||||
|
&& g < groupControl1.d + groupControl1.G()) {
|
||||||
|
groupControl1.settingGroup.getEnabled().toggle();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void d(RenderContext renderContext, float f) {
|
||||||
|
float g = this.toggleSwitch == null ? 0.0F : 48.0F;
|
||||||
|
this.L(renderContext, this.e - g);
|
||||||
|
if (this.j > 0.5F) {
|
||||||
|
renderContext.render2D
|
||||||
|
.rect(this.f + 3.0F, this.d + this.G(), 1.0F, this.j, ThemeManager.withAlpha(renderContext.palette().outlineVariant(), f * 0.7F));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.settingList.drawDividers(renderContext.render2D, this.m(), this.B(), renderContext.palette().outlineVariant(), f);
|
||||||
|
|
||||||
|
for (Iterator iterator1 = iterator = this.uiComponents.iterator(); iterator1.hasNext(); iterator1 = iterator) {
|
||||||
|
((UiComponent)iterator.next()).render(renderContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float B() {
|
||||||
|
return Math.max(0.0F, this.e - 13.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,279 @@
|
|||||||
|
package openonyx.ui.internal;
|
||||||
|
|
||||||
|
import openonyx.features.ModuleState;
|
||||||
|
import openonyx.history.internal.KeybindSetting;
|
||||||
|
import openonyx.input.KeyInput;
|
||||||
|
import openonyx.render.Render2D;
|
||||||
|
import openonyx.render.group_d.Animation;
|
||||||
|
import openonyx.render.group_d.Easings;
|
||||||
|
import openonyx.render.group_e.FontStyle;
|
||||||
|
import openonyx.theme.Fonts;
|
||||||
|
import openonyx.theme.ThemeManager;
|
||||||
|
import openonyx.theme.internal.ColorUtils;
|
||||||
|
import openonyx.ui.RenderContext;
|
||||||
|
import openonyx.ui.UiSupport_545;
|
||||||
|
|
||||||
|
public class KeybindControl extends SettingControl {
|
||||||
|
private final Animation animation;
|
||||||
|
private boolean C;
|
||||||
|
private static final float J = 12.0F;
|
||||||
|
private final UiSupport_545[] uiSupport_545s;
|
||||||
|
private final UiSupport_545 uiSupport_545;
|
||||||
|
private static final ModuleState[] MODULE_STATES;
|
||||||
|
private static final String[] k;
|
||||||
|
private boolean g;
|
||||||
|
private static final float M = 20.0F;
|
||||||
|
private static final float L = 8.0F;
|
||||||
|
private float j;
|
||||||
|
private float m;
|
||||||
|
private final KeybindSetting keybindSetting;
|
||||||
|
|
||||||
|
public KeybindControl(KeybindSetting keybindSetting) {
|
||||||
|
int i = --2;
|
||||||
|
super(keybindSettingx);
|
||||||
|
this.uiSupport_545 = new UiSupport_545();
|
||||||
|
UiSupport_545[] uiSupport_545sx = new UiSupport_545[i];
|
||||||
|
boolean bl = true;
|
||||||
|
uiSupport_545sx[0] = new UiSupport_545();
|
||||||
|
uiSupport_545sx[1] = new UiSupport_545();
|
||||||
|
this.uiSupport_545s = uiSupport_545sx;
|
||||||
|
this.animation = new Animation(0.0F);
|
||||||
|
this.keybindSetting = keybindSettingx;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean l() {
|
||||||
|
return this.keybindSetting.getBindMode() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String L() {
|
||||||
|
return this.g ? "Press a key..." : this.keybindSetting.getDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private float I(RenderContext renderContext) {
|
||||||
|
return Math.max(58.0F, renderContext.render2D.getTextWidth(Fonts.FONT_STYLE16, this.L()) + 20.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int L(float f, float g) {
|
||||||
|
if (!this.h()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gx < this.B() || gx >= this.B() + 20.0F) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
float h;
|
||||||
|
return !((h = f - this.m) < 0.0F) && !(h >= this.m()) ? (int)(h / this.j) : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int d(int i) {
|
||||||
|
return ThemeManager.withAlpha(i, this.F() * this.animation.getValue() * (ColorUtils.alpha(i) / 255.0F));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean h() {
|
||||||
|
return this.l() && this.animation.getValue() > 0.95F;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(RenderContext renderContext) {
|
||||||
|
super.update(renderContext);
|
||||||
|
float f = this.l() && this.keybindSetting.isBound() ? 1.0F : 0.0F;
|
||||||
|
KeybindControl keybindControl1;
|
||||||
|
if (!this.C) {
|
||||||
|
this.C = true;
|
||||||
|
keybindControl1 = this;
|
||||||
|
this.animation.set(f);
|
||||||
|
} else {
|
||||||
|
if (this.animation.getTarget() != f) {
|
||||||
|
this.animation.animateTo(f, 200.0F, Easings.EASING6);
|
||||||
|
}
|
||||||
|
|
||||||
|
keybindControl1 = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
keybindControl1.animation.update(renderContext.i);
|
||||||
|
this.j = this.D(renderContext);
|
||||||
|
this.m = this.i(renderContext);
|
||||||
|
boolean bl = renderContext.H >= this.d(renderContext)
|
||||||
|
&& renderContext.H < this.f + this.e
|
||||||
|
&& renderContext.f >= this.B()
|
||||||
|
&& renderContext.f < this.B() + 20.0F;
|
||||||
|
this.uiSupport_545.L(renderContext.i, bl, this.g);
|
||||||
|
int jx = this.L(renderContext.H, renderContext.f);
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (int kx = i = 0; kx < this.uiSupport_545s.length; kx = i) {
|
||||||
|
UiSupport_545 uiSupport_545x = this.uiSupport_545s[i];
|
||||||
|
boolean bl1 = jx == i;
|
||||||
|
i++;
|
||||||
|
uiSupport_545x.L(renderContext.i, bl1, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float L(int i) {
|
||||||
|
return this.m + i * this.j;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float m() {
|
||||||
|
return this.j * MODULE_STATES.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float i(RenderContext renderContext) {
|
||||||
|
return this.d(renderContext) - 8.0F - this.m();
|
||||||
|
}
|
||||||
|
|
||||||
|
private float D(RenderContext renderContext) {
|
||||||
|
float f = 0.0F;
|
||||||
|
String[] strings = k;
|
||||||
|
int jx = k.length;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (int kx = i = 0; kx < jx; kx = i) {
|
||||||
|
String string = strings[i];
|
||||||
|
i++;
|
||||||
|
f = Math.max(f, renderContext.render2D.getTextWidth(Fonts.FONT_STYLE16, string));
|
||||||
|
}
|
||||||
|
|
||||||
|
return f + 24.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
ModuleState[] moduleStates = new ModuleState[2];
|
||||||
|
boolean bl = true;
|
||||||
|
moduleStates[0] = ModuleState.TOGGLE;
|
||||||
|
moduleStates[1] = ModuleState.HOLD;
|
||||||
|
MODULE_STATES = moduleStates;
|
||||||
|
String[] strings = new String[2];
|
||||||
|
bl = true;
|
||||||
|
strings[0] = "Toggle";
|
||||||
|
strings[1] = "Hold";
|
||||||
|
k = strings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseClicked(float f, float g, int i) {
|
||||||
|
if (this.i() && this.contains(f, gx)) {
|
||||||
|
int jx;
|
||||||
|
if ((jx = this.L(f, gx)) >= 0) {
|
||||||
|
if (i != 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.keybindSetting.getBindMode().setValue(MODULE_STATES[jx]);
|
||||||
|
return true;
|
||||||
|
} else if (i == 1) {
|
||||||
|
this.keybindSetting.clear();
|
||||||
|
this.g = false;
|
||||||
|
return true;
|
||||||
|
} else if (i == 0) {
|
||||||
|
this.g = !this.g;
|
||||||
|
return true;
|
||||||
|
} else if (this.g && i >= 2) {
|
||||||
|
this.g = false;
|
||||||
|
this.keybindSetting.bindMouse(i);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float B() {
|
||||||
|
return this.I() - 10.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float d(RenderContext renderContext) {
|
||||||
|
return this.f + this.e - this.I(renderContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean keyTyped(KeyInput keyInput) {
|
||||||
|
if (!this.g) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.g = false;
|
||||||
|
if (keyInput.key() == 1) {
|
||||||
|
this.keybindSetting.clear();
|
||||||
|
} else {
|
||||||
|
this.keybindSetting.bind(keyInput.key());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void d(RenderContext renderContext, float j) {
|
||||||
|
Render2D render2D = renderContext.render2D;
|
||||||
|
float gx = this.I(renderContext);
|
||||||
|
float f = this.d(renderContext);
|
||||||
|
float h = this.B();
|
||||||
|
float i = (this.animation.getValue() > 0.01F ? this.m : f) - 10.0F - this.f;
|
||||||
|
this.L(renderContext, i);
|
||||||
|
this.i(renderContext, h);
|
||||||
|
KeybindControl keybindControl1;
|
||||||
|
if (this.g) {
|
||||||
|
render2D.roundedRect(f, h, gx, 20.0F, Float.MAX_VALUE, this.L(renderContext.palette().secondaryContainer()));
|
||||||
|
keybindControl1 = this;
|
||||||
|
} else {
|
||||||
|
render2D.roundedOutline(f, h, gx, 20.0F, Float.MAX_VALUE, 1.0F, this.L(renderContext.palette().outline()));
|
||||||
|
keybindControl1 = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
keybindControl1.uiSupport_545.L(render2D, f, h, gx, 20.0F, Float.MAX_VALUE, this.L(renderContext.palette().onSurface()));
|
||||||
|
render2D.drawTextCenteredVCentered(
|
||||||
|
Fonts.FONT_STYLE16,
|
||||||
|
this.L(),
|
||||||
|
f + gx / 2.0F,
|
||||||
|
this.I(),
|
||||||
|
this.L(this.g ? renderContext.palette().onSecondaryContainer() : renderContext.palette().onSurface())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int L() {
|
||||||
|
return this.keybindSetting.getBindMode() != null && this.keybindSetting.getBindMode().is(ModuleState.HOLD) ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float L(RenderContext renderContext) {
|
||||||
|
return this.A();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void i(RenderContext renderContext, float f) {
|
||||||
|
KeybindControl keybindControl1 = this;
|
||||||
|
if (keybindControl1.l() && !(keybindControl1.animation.getValue() <= 0.01F)) {
|
||||||
|
Render2D render2D;
|
||||||
|
Render2D render2D1 = render2D = renderContext.render2D;
|
||||||
|
int i = keybindControl1.L();
|
||||||
|
float gx = 10.0F;
|
||||||
|
render2D1.roundedOutline(keybindControl1.m, f, keybindControl1.m(), 20.0F, Float.MAX_VALUE, 1.0F, keybindControl1.d(renderContext.palette().outline()));
|
||||||
|
|
||||||
|
for (int mx = kx = 0; mx < MODULE_STATES.length; mx = kx) {
|
||||||
|
float h = keybindControl1.L(kx);
|
||||||
|
boolean bl = kx == 0;
|
||||||
|
boolean bl1 = kx == MODULE_STATES.length - 1;
|
||||||
|
float jx = bl ? gx : 0.0F;
|
||||||
|
float l = bl1 ? gx : 0.0F;
|
||||||
|
if (kx == i) {
|
||||||
|
render2D.L(h, f, keybindControl1.j, 20.0F, jx, l, l, jx, keybindControl1.d(renderContext.palette().secondaryContainer()));
|
||||||
|
}
|
||||||
|
|
||||||
|
keybindControl1.uiSupport_545s[kx]
|
||||||
|
.L(render2D, h, f, keybindControl1.j, 20.0F, Math.max(jx, l), keybindControl1.d(renderContext.palette().onSurface()));
|
||||||
|
if (!bl) {
|
||||||
|
render2D.rect(h, f, 1.0F, 20.0F, keybindControl1.d(renderContext.palette().outline()));
|
||||||
|
}
|
||||||
|
|
||||||
|
FontStyle fontStyle = Fonts.FONT_STYLE16;
|
||||||
|
String string = k[kx];
|
||||||
|
float n = h + keybindControl1.j / 2.0F;
|
||||||
|
float o = keybindControl1.I();
|
||||||
|
int p = keybindControl1.d(kx == i ? renderContext.palette().onSecondaryContainer() : renderContext.palette().onSurfaceVariant());
|
||||||
|
kx++;
|
||||||
|
render2D.drawTextCenteredVCentered(fontStyle, string, n, o, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package openonyx.ui.internal;
|
||||||
|
|
||||||
|
import openonyx.render.Render2D;
|
||||||
|
import openonyx.render.group_d.Animation;
|
||||||
|
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_554;
|
||||||
|
|
||||||
|
public class LabelButton extends UiComponent {
|
||||||
|
private final Animation animation = new Animation(0.0F);
|
||||||
|
private float m = 1.0F;
|
||||||
|
private static final float h = 12.0F;
|
||||||
|
private final Runnable runnable;
|
||||||
|
private static final float I = 0.16F;
|
||||||
|
private static final float H = 0.62F;
|
||||||
|
private final String e;
|
||||||
|
|
||||||
|
public void L(float f) {
|
||||||
|
this.m = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(RenderContext renderContext) {
|
||||||
|
LabelButton labelButton1 = this;
|
||||||
|
labelButton1.update(renderContext);
|
||||||
|
float f = labelButton1.h ? 1.0F : 0.0F;
|
||||||
|
if (labelButton1.animation.getTarget() != f) {
|
||||||
|
labelButton1.animation.animateTo(f, 150.0F, Easings.EASING6);
|
||||||
|
}
|
||||||
|
|
||||||
|
labelButton1.animation.update(renderContext.i);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseClicked(float f, float g, int i) {
|
||||||
|
if (i == 0 && this.I && this.contains(f, g)) {
|
||||||
|
this.runnable.run();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(RenderContext renderContext) {
|
||||||
|
Render2D render2D = renderContext.render2D;
|
||||||
|
Palette palette;
|
||||||
|
Palette palette1 = palette = renderContext.palette();
|
||||||
|
float hx = this.animation.getValue();
|
||||||
|
float g = this.e / this.m;
|
||||||
|
float f = this.i / this.m;
|
||||||
|
int i = palette1.onSecondaryContainer();
|
||||||
|
render2D.pushAlpha(UiSupport_554.L());
|
||||||
|
render2D.pushMatrix();
|
||||||
|
render2D.transforms().d(this.f, this.d).L(this.m, this.m);
|
||||||
|
render2D.shadow(0.0F, 0.0F, g, f, 12.0F, 1);
|
||||||
|
render2D.blurRect(0.0F, 0.0F, g, f, 12.0F, ThemeManager.withAlpha(palette.secondaryContainer(), 0.62F + 0.16F * hx));
|
||||||
|
if (hx > 0.001F) {
|
||||||
|
render2D.roundedRect(0.0F, 0.0F, g, f, 12.0F, ThemeManager.withAlpha(i, 0.08F * hx));
|
||||||
|
}
|
||||||
|
|
||||||
|
render2D.drawTextCenteredVCentered(Fonts.FONT_STYLE14, this.e, g / 2.0F, f / 2.0F, i);
|
||||||
|
render2D.popMatrix();
|
||||||
|
render2D.popAlpha();
|
||||||
|
if (this.h) {
|
||||||
|
render2D.usePointerCursor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public LabelButton(String string, Runnable runnable) {
|
||||||
|
this.e = string;
|
||||||
|
this.runnable = runnablex;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,213 @@
|
|||||||
|
package openonyx.ui.internal;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import openonyx.history.ModeOption;
|
||||||
|
import openonyx.history.ModeSetting;
|
||||||
|
import openonyx.render.Render2D;
|
||||||
|
import openonyx.render.group_d.Animation;
|
||||||
|
import openonyx.render.group_d.Easings;
|
||||||
|
import openonyx.render.group_e.FontStyle;
|
||||||
|
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 ModeControl<M extends ModeOption> extends SettingControl {
|
||||||
|
private boolean A;
|
||||||
|
private static final float K = 13.0F;
|
||||||
|
private static final float B = 4.0F;
|
||||||
|
private final Animation animation;
|
||||||
|
private final List<UiSupport_545> uiSupport_545s;
|
||||||
|
private final SettingList settingList;
|
||||||
|
private static final float c = 7.0F;
|
||||||
|
private static final float a = 24.0F;
|
||||||
|
private static final float k = 8.0F;
|
||||||
|
private final ModeSetting<M> modeSetting;
|
||||||
|
private static final float M = 1.5F;
|
||||||
|
private M modeOption;
|
||||||
|
private int j;
|
||||||
|
private float m;
|
||||||
|
private final List<Animation> animations;
|
||||||
|
|
||||||
|
private float G() {
|
||||||
|
return this.L(this.modeSetting.getModes().size() - 1) + 24.0F - 4.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(RenderContext renderContext) {
|
||||||
|
ModeControl modeControl1 = this;
|
||||||
|
if (modeControl1.modeOption != modeControl1.modeSetting.getValue()) {
|
||||||
|
modeControl1.d();
|
||||||
|
}
|
||||||
|
|
||||||
|
modeControl1.m = modeControl1.settingList.layout(modeControl1.f + 13.0F, modeControl1.B(), Math.max(0.0F, modeControl1.e - 13.0F));
|
||||||
|
ModeControl modeControl2;
|
||||||
|
if (!modeControl1.A) {
|
||||||
|
modeControl1.animation.set(modeControl1.m);
|
||||||
|
modeControl2 = modeControl1;
|
||||||
|
} else {
|
||||||
|
if (modeControl1.animation.getTarget() != modeControl1.m) {
|
||||||
|
modeControl1.animation.animateTo(modeControl1.m, 300.0F, Easings.EASING2);
|
||||||
|
}
|
||||||
|
|
||||||
|
modeControl2 = modeControl1;
|
||||||
|
}
|
||||||
|
|
||||||
|
modeControl2.animation.update(renderContext.i);
|
||||||
|
int jx = 0;
|
||||||
|
modeControl1.j = -1;
|
||||||
|
|
||||||
|
for (int i = 0; jx < modeControl1.modeSetting.getModes().size(); jx = i) {
|
||||||
|
boolean bl1 = modeControl1.modeSetting.getValue() == modeControl1.modeSetting.getModes().get(i);
|
||||||
|
boolean bl = renderContext.H >= modeControl1.f
|
||||||
|
&& renderContext.H < modeControl1.f + modeControl1.e
|
||||||
|
&& renderContext.f >= modeControl1.L(i)
|
||||||
|
&& renderContext.f < modeControl1.L(i) + 24.0F;
|
||||||
|
if (bl) {
|
||||||
|
modeControl1.j = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
Animation animationx = modeControl1.animations.get(i);
|
||||||
|
Animation animation1;
|
||||||
|
if (!modeControl1.A) {
|
||||||
|
animationx.set(bl1 ? 1.0F : 0.0F);
|
||||||
|
animation1 = animationx;
|
||||||
|
} else {
|
||||||
|
if (animationx.getTarget() != (bl1 ? 1.0F : 0.0F)) {
|
||||||
|
animationx.animateTo(bl1 ? 1.0F : 0.0F, 200.0F, Easings.EASING2);
|
||||||
|
}
|
||||||
|
|
||||||
|
animation1 = animationx;
|
||||||
|
}
|
||||||
|
|
||||||
|
animation1.update(renderContext.i);
|
||||||
|
UiSupport_545 uiSupport_545 = modeControl1.uiSupport_545s.get(i);
|
||||||
|
i++;
|
||||||
|
uiSupport_545.L(renderContext.i, bl, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
modeControl1.A = true;
|
||||||
|
modeControl1.update(renderContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseClicked(float f, float g, int i) {
|
||||||
|
ModeControl modeControl1 = this;
|
||||||
|
if (modeControl1.i() && i == 0) {
|
||||||
|
if (modeControl1.j >= 0) {
|
||||||
|
modeControl1.modeSetting.setMode(modeControl1.modeSetting.getModes().get(modeControl1.j));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator iterator = modeControl1.uiComponents.iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
if (((UiComponent)iterator.next()).mouseClicked(f, g, i)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float m() {
|
||||||
|
return this.l() - 1.5F;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float L(int i) {
|
||||||
|
return this.m() - 4.0F + i * 24.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void d(RenderContext renderContext, float f) {
|
||||||
|
ModeControl modeControl1 = this;
|
||||||
|
Render2D render2D = renderContext.render2D;
|
||||||
|
int mx = 0;
|
||||||
|
modeControl1.L(renderContext, modeControl1.e);
|
||||||
|
|
||||||
|
for (int jx = 0; mx < modeControl1.modeSetting.getModes().size(); mx = jx) {
|
||||||
|
ModeOption modeOptionx = modeControl1.modeSetting.getModes().get(jx);
|
||||||
|
float g;
|
||||||
|
float h = (g = modeControl1.L(jx)) + 12.0F;
|
||||||
|
int i = modeControl1.modeSetting.getValue() == modeOptionx;
|
||||||
|
modeControl1.uiSupport_545s
|
||||||
|
.get(jx)
|
||||||
|
.L(render2D, modeControl1.f - 4.0F, g, modeControl1.e + 8.0F, 24.0F, 8.0F, modeControl1.L(renderContext.palette().onSurface()));
|
||||||
|
i = i ? renderContext.palette().primary() : renderContext.palette().onSurfaceVariant();
|
||||||
|
render2D.L(modeControl1.f + 8.0F, h, 8.0F, 1.5F, modeControl1.L(i));
|
||||||
|
float l;
|
||||||
|
if ((l = modeControl1.animations.get(jx).getValue()) > 0.01F) {
|
||||||
|
render2D.circle(modeControl1.f + 8.0F, h, 4.0F * l, modeControl1.L(renderContext.palette().primary()));
|
||||||
|
}
|
||||||
|
|
||||||
|
FontStyle fontStyle = Fonts.FONT_STYLE15;
|
||||||
|
String string = modeOptionx.getName();
|
||||||
|
float n = modeControl1.f + 16.0F + 9.0F;
|
||||||
|
Palette palette = renderContext.palette();
|
||||||
|
jx++;
|
||||||
|
render2D.drawTextVCentered(fontStyle, string, n, h, modeControl1.L(palette.onSurface()));
|
||||||
|
}
|
||||||
|
|
||||||
|
float kx;
|
||||||
|
if (!((kx = modeControl1.animation.getValue()) <= 0.5F)) {
|
||||||
|
render2D.pushScissor(modeControl1.f, modeControl1.B(), modeControl1.e, kx);
|
||||||
|
render2D.rect(modeControl1.f + 3.0F, modeControl1.B(), 1.0F, kx, ThemeManager.withAlpha(renderContext.palette().outlineVariant(), f * 0.7F));
|
||||||
|
modeControl1.settingList
|
||||||
|
.drawDividers(render2D, modeControl1.f + 13.0F, Math.max(0.0F, modeControl1.e - 13.0F), renderContext.palette().outlineVariant(), f);
|
||||||
|
Iterator iterator;
|
||||||
|
Iterator iterator1 = iterator = modeControl1.uiComponents.iterator();
|
||||||
|
|
||||||
|
while (iterator1.hasNext()) {
|
||||||
|
UiComponent uiComponent = (UiComponent)iterator.next();
|
||||||
|
iterator1 = iterator;
|
||||||
|
uiComponent.render(renderContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
render2D.popScissor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float L(RenderContext renderContext) {
|
||||||
|
float f = this.animation.getValue();
|
||||||
|
return this.G() - this.d + (f > 0.5F ? 7.0F + f : 0.0F) + 6.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float B() {
|
||||||
|
return this.G() + 7.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModeControl(ModeSetting<M> modeSetting) {
|
||||||
|
int jx = 5 >> 3;
|
||||||
|
super(modeSettingx);
|
||||||
|
this.animations = new ArrayList<>();
|
||||||
|
this.uiSupport_545s = new ArrayList<>();
|
||||||
|
this.settingList = new SettingList();
|
||||||
|
this.animation = new Animation(0.0F);
|
||||||
|
this.j = -1;
|
||||||
|
this.modeSetting = modeSettingx;
|
||||||
|
|
||||||
|
for (int i = jx; jx < modeSettingx.getModes().size(); jx = i) {
|
||||||
|
this.animations.add(new Animation(0.0F));
|
||||||
|
i++;
|
||||||
|
this.uiSupport_545s.add(new UiSupport_545());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.d();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void d() {
|
||||||
|
this.modeOption = this.modeSetting.getValue();
|
||||||
|
this.uiComponents.clear();
|
||||||
|
this.settingList.setSettings(this.modeOption.getSettings());
|
||||||
|
this.uiComponents.addAll(this.settingList.getSettingControls());
|
||||||
|
this.m = 0.0F;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user