Upload files to "src/openonyx/ui/internal"
This commit is contained in:
1 parent
8be910a919
commit
3794dae99d
5 files changed
+664
No files matched your search
@@ -0,0 +1,206 @@
|
|||||||
|
package openonyx.ui.internal;
|
||||||
|
|
||||||
|
import openonyx.history.ModeSetting;
|
||||||
|
import openonyx.history.Setting;
|
||||||
|
import openonyx.history.SettingGroup;
|
||||||
|
import openonyx.history.TabbedSettingGroup;
|
||||||
|
import openonyx.history.internal.ActionSetting;
|
||||||
|
import openonyx.history.internal.BlockSetSetting;
|
||||||
|
import openonyx.history.internal.BooleanSetting;
|
||||||
|
import openonyx.history.internal.ColorSetting;
|
||||||
|
import openonyx.history.internal.EnumSetting;
|
||||||
|
import openonyx.history.internal.KeybindSetting;
|
||||||
|
import openonyx.history.internal.MultiEnumSetting;
|
||||||
|
import openonyx.history.internal.MultiSelectSetting;
|
||||||
|
import openonyx.history.internal.NumberSetting;
|
||||||
|
import openonyx.history.internal.RangeSetting;
|
||||||
|
import openonyx.history.internal.TextSetting;
|
||||||
|
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.UiComponent;
|
||||||
|
|
||||||
|
public abstract class SettingControl extends UiComponent {
|
||||||
|
private final Animation animation3 = new Animation(0.0F);
|
||||||
|
private final Animation animation4 = new Animation(0.0F);
|
||||||
|
protected final Setting setting;
|
||||||
|
protected static final float h = 6.0F;
|
||||||
|
protected static final float l = 3.0F;
|
||||||
|
protected static final float I = 13.5F;
|
||||||
|
private boolean d;
|
||||||
|
protected static final FontStyle FONT_STYLE = Fonts.FONT_STYLE15;
|
||||||
|
private boolean f;
|
||||||
|
public static final float H = 15.0F;
|
||||||
|
protected static final FontStyle FONT_STYLE2 = Fonts.FONT_STYLE2;
|
||||||
|
|
||||||
|
protected float j() {
|
||||||
|
return this.I() ? this.H() + FONT_STYLE2.i() : this.k();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected float A() {
|
||||||
|
return this.j() - this.d + 6.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected float H() {
|
||||||
|
return this.k() + this.L().D() + 3.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float e() {
|
||||||
|
return this.animation3.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Setting getSetting() {
|
||||||
|
return this.setting;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void D(RenderContext renderContext, float f) {
|
||||||
|
if (this.I()) {
|
||||||
|
renderContext.render2D
|
||||||
|
.drawTextTop(
|
||||||
|
FONT_STYLE2,
|
||||||
|
renderContext.render2D.trimToWidth(FONT_STYLE2, this.setting.getDescription(), fx),
|
||||||
|
this.f,
|
||||||
|
this.H(),
|
||||||
|
this.L(ThemeManager.withAlpha(renderContext.palette().onSurfaceVariant(), 0.85F))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected float k() {
|
||||||
|
return this.d + 6.0F + this.L().i();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void d(RenderContext renderContext, float f);
|
||||||
|
|
||||||
|
protected float F() {
|
||||||
|
return this.animation4.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(RenderContext renderContext) {
|
||||||
|
SettingControl settingControl1 = this;
|
||||||
|
float fx;
|
||||||
|
if (!((fx = settingControl1.animation4.getValue()) <= 0.01F)) {
|
||||||
|
settingControl1.d(renderContext, fx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseClicked(float f, float g, int i) {
|
||||||
|
return this.i() && super.mouseClicked(fx, g, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected float l() {
|
||||||
|
return this.j() + 13.5F;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int L(int i) {
|
||||||
|
return ThemeManager.withAlpha(i, this.F() * (ColorUtils.alpha(i) / 255.0F));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean I() {
|
||||||
|
return !this.setting.getDescription().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SettingControl create(Setting setting) {
|
||||||
|
Setting setting1 = settingx;
|
||||||
|
if (setting1 instanceof BooleanSetting booleanSetting) {
|
||||||
|
return new CheckboxControl(booleanSetting);
|
||||||
|
} else if (setting1 instanceof NumberSetting numberSetting) {
|
||||||
|
return new SliderControl(numberSetting);
|
||||||
|
} else if (setting1 instanceof RangeSetting rangeSetting) {
|
||||||
|
return new RangeControl(rangeSetting);
|
||||||
|
} else if (setting1 instanceof EnumSetting enumSetting) {
|
||||||
|
return new EnumControl(enumSetting);
|
||||||
|
} else if (setting1 instanceof MultiSelectSetting multiSelectSetting) {
|
||||||
|
return new MultiSelectControl(multiSelectSetting);
|
||||||
|
} else if (setting1 instanceof MultiEnumSetting multiEnumSetting) {
|
||||||
|
return new MultiEnumControl(multiEnumSetting);
|
||||||
|
} else if (setting1 instanceof ColorSetting colorSetting) {
|
||||||
|
return new ColorControl(colorSetting);
|
||||||
|
} else if (setting1 instanceof ActionSetting actionSetting) {
|
||||||
|
return new ActionControl(actionSetting);
|
||||||
|
} else if (setting1 instanceof KeybindSetting keybindSetting) {
|
||||||
|
return new KeybindControl(keybindSetting);
|
||||||
|
} else if (setting1 instanceof BlockSetSetting blockSetSetting) {
|
||||||
|
return new BlockListControl(blockSetSetting);
|
||||||
|
} else if (setting1 instanceof TextSetting textSetting) {
|
||||||
|
return new TextControl(textSetting);
|
||||||
|
} else if (setting1 instanceof ModeSetting modeSetting) {
|
||||||
|
return new ModeControl(modeSetting);
|
||||||
|
} else if (setting1 instanceof TabbedSettingGroup tabbedSettingGroup) {
|
||||||
|
return new TabbedGroupControl(tabbedSettingGroup);
|
||||||
|
} else {
|
||||||
|
return setting1 instanceof SettingGroup settingGroup ? new GroupControl(settingGroup) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SettingControl(Setting setting) {
|
||||||
|
this.setting = settingx;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void L(RenderContext renderContext, float f) {
|
||||||
|
renderContext.render2D
|
||||||
|
.drawTextTop(
|
||||||
|
this.L(),
|
||||||
|
renderContext.render2D.trimToWidth(this.L(), this.setting.getName(), fx),
|
||||||
|
this.f,
|
||||||
|
this.d + 6.0F,
|
||||||
|
this.L(renderContext.palette().onSurface())
|
||||||
|
);
|
||||||
|
this.D(renderContext, fx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float h() {
|
||||||
|
return this.animation4.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(RenderContext renderContext) {
|
||||||
|
SettingControl settingControl1 = this;
|
||||||
|
settingControl1.update(renderContext);
|
||||||
|
boolean bl = settingControl1.setting.isVisible();
|
||||||
|
float fx = settingControl1.L(renderContext);
|
||||||
|
if (!settingControl1.f) {
|
||||||
|
settingControl1.f = true;
|
||||||
|
settingControl1.d = bl;
|
||||||
|
settingControl1.animation3.set(bl ? fx : 0.0F);
|
||||||
|
settingControl1.animation4.set(bl ? 1.0F : 0.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingControl settingControl2;
|
||||||
|
if (bl != settingControl1.d) {
|
||||||
|
settingControl1.d = bl;
|
||||||
|
settingControl1.animation3.animateTo(bl ? fx : 0.0F, 300.0F, Easings.EASING2);
|
||||||
|
settingControl1.animation4.animateTo(bl ? 1.0F : 0.0F, 200.0F, Easings.EASING6);
|
||||||
|
settingControl2 = settingControl1;
|
||||||
|
} else {
|
||||||
|
if (bl && settingControl1.animation3.isFinished() && settingControl1.animation3.getTarget() != fx) {
|
||||||
|
settingControl1.animation3.set(fx);
|
||||||
|
}
|
||||||
|
|
||||||
|
settingControl2 = settingControl1;
|
||||||
|
}
|
||||||
|
|
||||||
|
settingControl2.animation3.update(renderContext.i);
|
||||||
|
settingControl1.animation4.update(renderContext.i);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract float L(RenderContext renderContext);
|
||||||
|
|
||||||
|
protected FontStyle L() {
|
||||||
|
return FONT_STYLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean i() {
|
||||||
|
return this.animation4.getValue() > 0.95F;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected float I() {
|
||||||
|
return this.d + 6.0F + this.L().i() / 2.0F;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
package openonyx.ui.internal;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import openonyx.history.Setting;
|
||||||
|
import openonyx.render.Render2D;
|
||||||
|
import openonyx.theme.ThemeManager;
|
||||||
|
|
||||||
|
public final class SettingList {
|
||||||
|
private final List<SettingControl> settingControls = new ArrayList<>();
|
||||||
|
private final List<SettingListData> settingListDatas = new ArrayList<>();
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
this.settingControls.clear();
|
||||||
|
this.settingListDatas.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float layout(float f, float g, float h) {
|
||||||
|
SettingList settingList1 = this;
|
||||||
|
settingList1.settingListDatas.clear();
|
||||||
|
float l = g;
|
||||||
|
float i = 0.0F;
|
||||||
|
boolean bl = true;
|
||||||
|
Iterator iterator;
|
||||||
|
Iterator iterator1 = iterator = settingList1.settingControls.iterator();
|
||||||
|
|
||||||
|
while (iterator1.hasNext()) {
|
||||||
|
SettingControl settingControl;
|
||||||
|
SettingControl settingControl1 = settingControl = (SettingControl)iterator.next();
|
||||||
|
float j = settingControl1.e();
|
||||||
|
float k = settingControl1.h();
|
||||||
|
if (j <= 0.5F) {
|
||||||
|
iterator1 = iterator;
|
||||||
|
settingControl.setBounds(f, l, h, 0.0F);
|
||||||
|
} else {
|
||||||
|
if (!bl) {
|
||||||
|
settingList1.settingListDatas.add(new SettingListData(l + 7.5F, Math.min(i, k)));
|
||||||
|
l += 15.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
settingControl.setBounds(f, l, h, j);
|
||||||
|
l += j;
|
||||||
|
i = k;
|
||||||
|
bl = false;
|
||||||
|
iterator1 = iterator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return l - g;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return this.settingControls.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String decrypt(String string) {
|
||||||
|
String string1 = string;
|
||||||
|
int k = --3 << --3 ^ 6;
|
||||||
|
String string2;
|
||||||
|
int n = (string2 = string1).length();
|
||||||
|
char[] e = new char[n];
|
||||||
|
boolean bl = true;
|
||||||
|
int i;
|
||||||
|
int m = i = n - 1;
|
||||||
|
char[] c = e;
|
||||||
|
byte d = 116;
|
||||||
|
k = m;
|
||||||
|
byte b = 119;
|
||||||
|
|
||||||
|
while (k >= 0) {
|
||||||
|
int l = i;
|
||||||
|
int j = string2.charAt(i);
|
||||||
|
i--;
|
||||||
|
c[l] = (char)(j ^ b);
|
||||||
|
if (i < 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
j = i--;
|
||||||
|
c[j] = (char)(string2.charAt(j) ^ d);
|
||||||
|
k = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new String(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawDividers(Render2D render2D, float f, float g, int i, float h) {
|
||||||
|
SettingList settingList1 = this;
|
||||||
|
Iterator iterator;
|
||||||
|
Iterator iterator1 = iterator = settingList1.settingListDatas.iterator();
|
||||||
|
|
||||||
|
while (iterator1.hasNext()) {
|
||||||
|
SettingListData settingListData;
|
||||||
|
float j;
|
||||||
|
if ((j = (settingListData = (SettingListData)iterator.next()).alpha() * h) <= 0.01F) {
|
||||||
|
iterator1 = iterator;
|
||||||
|
} else {
|
||||||
|
render2D.rect(f, settingListData.y(), g, 1.0F, ThemeManager.withAlpha(i, j * 0.8F));
|
||||||
|
iterator1 = iterator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSettings(List<Setting> list) {
|
||||||
|
this.clear();
|
||||||
|
Iterator iterator = list.iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
SettingControl settingControl;
|
||||||
|
if ((settingControl = SettingControl.create((Setting)iterator.next())) != null) {
|
||||||
|
this.settingControls.add(settingControl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SettingControl> getSettingControls() {
|
||||||
|
return this.settingControls;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package openonyx.ui.internal;
|
||||||
|
|
||||||
|
record SettingListData(float y, float alpha) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,179 @@
|
|||||||
|
package openonyx.ui.internal;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import openonyx.features.ModuleCategory;
|
||||||
|
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.ui.MaterialIcons;
|
||||||
|
import openonyx.ui.RenderContext;
|
||||||
|
import openonyx.ui.UiComponent;
|
||||||
|
import openonyx.ui.UiSupport_545;
|
||||||
|
|
||||||
|
public class Sidebar extends UiComponent {
|
||||||
|
private final UiSupport_545[] uiSupport_545s;
|
||||||
|
private int m;
|
||||||
|
private final UiSupport_545 uiSupport_545;
|
||||||
|
private ModuleCategory moduleCategory;
|
||||||
|
private final Animation animation;
|
||||||
|
private boolean d;
|
||||||
|
private boolean i;
|
||||||
|
private final Runnable runnable;
|
||||||
|
private final Consumer<ModuleCategory> moduleCategoryConsumer;
|
||||||
|
private final Animation animation2;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(RenderContext renderContext) {
|
||||||
|
Render2D render2D;
|
||||||
|
(render2D = renderContext.render2D)
|
||||||
|
.roundedRect(
|
||||||
|
this.f + (this.e - this.animation.getValue()) / 2.0F,
|
||||||
|
this.d + this.animation2.getValue() + 2.0F,
|
||||||
|
this.animation.getValue(),
|
||||||
|
h(),
|
||||||
|
Float.MAX_VALUE,
|
||||||
|
renderContext.palette().secondaryContainer()
|
||||||
|
);
|
||||||
|
ModuleCategory[] moduleCategorys;
|
||||||
|
int j = (moduleCategorys = ModuleCategory.values()).length;
|
||||||
|
|
||||||
|
int k;
|
||||||
|
for (int mx = k = 0; mx < j; mx = k) {
|
||||||
|
ModuleCategory moduleCategoryx = moduleCategorys[k];
|
||||||
|
int ix = moduleCategoryx.ordinal();
|
||||||
|
float f = this.L(ix);
|
||||||
|
float g = this.f + this.e / 2.0F;
|
||||||
|
boolean bl = moduleCategoryx == this.moduleCategory;
|
||||||
|
this.uiSupport_545s[ix].L(render2D, this.f + (this.e - F()) / 2.0F, f + 2.0F, F(), h(), Float.MAX_VALUE, renderContext.palette().onSurface());
|
||||||
|
ix = bl ? renderContext.palette().onSecondaryContainer() : renderContext.palette().onSurfaceVariant();
|
||||||
|
MaterialIcons.L(render2D, moduleCategoryx, g, f + 2.0F + h() / 2.0F, 16.0F, ix);
|
||||||
|
ix = bl ? renderContext.palette().onSurface() : ThemeManager.withAlpha(renderContext.palette().onSurfaceVariant(), 0.9F);
|
||||||
|
FontStyle fontStyle = Fonts.getFontstylE2();
|
||||||
|
String string = moduleCategoryx.d();
|
||||||
|
float n = l();
|
||||||
|
k++;
|
||||||
|
render2D.drawTextCenteredVCentered(fontStyle, string, g, f + n, ix);
|
||||||
|
}
|
||||||
|
|
||||||
|
float h = this.d + this.i - I();
|
||||||
|
float l = this.f + this.e / 2.0F;
|
||||||
|
this.uiSupport_545.L(render2D, this.f + (this.e - F()) / 2.0F, h + 2.0F, F(), h(), Float.MAX_VALUE, renderContext.palette().onSurface());
|
||||||
|
render2D.drawIcon("\ue161", l, h + 2.0F + h() / 2.0F, 16.0F, renderContext.palette().onSurfaceVariant());
|
||||||
|
render2D.drawTextCenteredVCentered(Fonts.getFontstylE2(), "Configs", l, h + l(), ThemeManager.withAlpha(renderContext.palette().onSurfaceVariant(), 0.9F));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float F() {
|
||||||
|
return 46.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(RenderContext renderContext) {
|
||||||
|
super.update(renderContext);
|
||||||
|
if (!this.i) {
|
||||||
|
this.i = true;
|
||||||
|
this.animation2.set(this.d(this.moduleCategory.ordinal()));
|
||||||
|
this.animation.set(F());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.m = -1;
|
||||||
|
this.d = false;
|
||||||
|
ModuleCategory[] moduleCategorys;
|
||||||
|
int k = (moduleCategorys = ModuleCategory.values()).length;
|
||||||
|
|
||||||
|
int j;
|
||||||
|
for (int l = j = 0; l < k; l = j) {
|
||||||
|
int ix = moduleCategorys[j].ordinal();
|
||||||
|
boolean bl = renderContext.H >= this.f && renderContext.H < this.f + this.e && renderContext.f >= this.L(ix) && renderContext.f < this.L(ix) + I();
|
||||||
|
if (bl) {
|
||||||
|
this.m = ix;
|
||||||
|
}
|
||||||
|
|
||||||
|
UiSupport_545 uiSupport_545x = this.uiSupport_545s[ix];
|
||||||
|
j++;
|
||||||
|
uiSupport_545x.L(renderContext.i, bl, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
float f = this.d + this.i - I();
|
||||||
|
this.d = renderContext.H >= this.f && renderContext.H < this.f + this.e && renderContext.f >= f && renderContext.f < f + I();
|
||||||
|
this.uiSupport_545.L(renderContext.i, this.d, false);
|
||||||
|
this.animation2.update(renderContext.i);
|
||||||
|
this.animation.update(renderContext.i);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float l() {
|
||||||
|
return 36.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float d(int i) {
|
||||||
|
return ix * I();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseClicked(float f, float g, int i) {
|
||||||
|
if (ix != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.d) {
|
||||||
|
this.runnable.run();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.m < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.L(ModuleCategory.values()[this.m]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sidebar(ModuleCategory moduleCategory, Consumer<ModuleCategory> consumer, Runnable runnable) {
|
||||||
|
UiSupport_545[] uiSupport_545s1 = new UiSupport_545[ModuleCategory.values().length];
|
||||||
|
boolean bl = true;
|
||||||
|
this.uiSupport_545s = uiSupport_545s1;
|
||||||
|
int k = 0;
|
||||||
|
this.uiSupport_545 = new UiSupport_545();
|
||||||
|
this.animation2 = new Animation(0.0F);
|
||||||
|
this.animation = new Animation(0.0F);
|
||||||
|
this.m = -1;
|
||||||
|
this.moduleCategory = moduleCategoryx;
|
||||||
|
this.moduleCategoryConsumer = consumer;
|
||||||
|
this.runnable = runnablex;
|
||||||
|
|
||||||
|
for (int ix = 0; k < this.uiSupport_545s.length; k = ix) {
|
||||||
|
UiSupport_545[] uiSupport_545sx = this.uiSupport_545s;
|
||||||
|
int j = ix;
|
||||||
|
UiSupport_545 uiSupport_545x = new UiSupport_545();
|
||||||
|
ix++;
|
||||||
|
uiSupport_545sx[j] = uiSupport_545x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float h() {
|
||||||
|
return 26.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float I() {
|
||||||
|
return 50.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float L(int i) {
|
||||||
|
return this.d + this.d(ix);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void L(ModuleCategory moduleCategory) {
|
||||||
|
if (this.moduleCategory != moduleCategoryx) {
|
||||||
|
this.moduleCategory = moduleCategoryx;
|
||||||
|
this.animation2.animateTo(this.d(moduleCategoryx.ordinal()), 300.0F, Easings.EASING2);
|
||||||
|
this.animation.set(F() * 0.6F).animateTo(F(), 300.0F, Easings.EASING2);
|
||||||
|
this.moduleCategoryConsumer.accept(moduleCategoryx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModuleCategory getModuleCategory() {
|
||||||
|
return this.moduleCategory;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
package openonyx.ui.internal;
|
||||||
|
|
||||||
|
import openonyx.history.internal.NumberSetting;
|
||||||
|
import openonyx.input.KeyInput;
|
||||||
|
import openonyx.render.Render2D;
|
||||||
|
import openonyx.render.group_d.Animation;
|
||||||
|
import openonyx.render.group_d.Easings;
|
||||||
|
import openonyx.theme.Fonts;
|
||||||
|
import openonyx.theme.ThemeManager;
|
||||||
|
import openonyx.ui.RenderContext;
|
||||||
|
|
||||||
|
public class SliderControl extends SettingControl {
|
||||||
|
private boolean c;
|
||||||
|
private static final float a = 3.0F;
|
||||||
|
private static final float k = 3.0F;
|
||||||
|
private static final float g = 16.0F;
|
||||||
|
private static final float M = 5.0F;
|
||||||
|
private final Animation animation = new Animation(3.0F);
|
||||||
|
private final NumberSetting numberSetting;
|
||||||
|
private static final float m = 3.0F;
|
||||||
|
|
||||||
|
private double L() {
|
||||||
|
return this.numberSetting.getStep() > 0.0 ? this.numberSetting.getStep() : (this.numberSetting.getMax() - this.numberSetting.getMin()) / 100.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean keyTyped(KeyInput keyInput) {
|
||||||
|
if (this.i() && this.h) {
|
||||||
|
switch (keyInput.key()) {
|
||||||
|
case 203:
|
||||||
|
while (false) {
|
||||||
|
}
|
||||||
|
|
||||||
|
this.numberSetting.setValue(this.numberSetting.getValue() - this.L());
|
||||||
|
return true;
|
||||||
|
case 205:
|
||||||
|
this.numberSetting.setValue(this.numberSetting.getValue() + this.L());
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float L(RenderContext renderContext) {
|
||||||
|
return this.l() - this.d + 3.0F + 6.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void d(RenderContext renderContext, float f) {
|
||||||
|
SliderControl sliderControl1 = this;
|
||||||
|
Render2D render2D;
|
||||||
|
Render2D render2D1 = render2D = renderContext.render2D;
|
||||||
|
float j = renderContext.render2D.getTextWidth(Fonts.FONT_STYLE2, sliderControl1.numberSetting.format());
|
||||||
|
sliderControl1.L(renderContext, sliderControl1.e - j - 12.0F);
|
||||||
|
render2D1.drawTextRightVCentered(
|
||||||
|
Fonts.FONT_STYLE2,
|
||||||
|
sliderControl1.numberSetting.format(),
|
||||||
|
sliderControl1.f + sliderControl1.e,
|
||||||
|
sliderControl1.I(),
|
||||||
|
sliderControl1.L(renderContext.palette().onSurfaceVariant())
|
||||||
|
);
|
||||||
|
float kx = sliderControl1.m();
|
||||||
|
float gx = (float)sliderControl1.numberSetting.getNormalized();
|
||||||
|
gx = sliderControl1.B() + sliderControl1.G() * gx;
|
||||||
|
float h = sliderControl1.animation.getValue() / 2.0F;
|
||||||
|
float i;
|
||||||
|
if ((i = gx - h - 5.0F) > sliderControl1.f) {
|
||||||
|
render2D.roundedRect(sliderControl1.f, kx - 1.5F, i - sliderControl1.f, 3.0F, Float.MAX_VALUE, sliderControl1.L(renderContext.palette().primary()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((i = gx + h + 5.0F) < sliderControl1.f + sliderControl1.e) {
|
||||||
|
render2D.roundedRect(
|
||||||
|
i, kx - 1.5F, sliderControl1.f + sliderControl1.e - i, 3.0F, Float.MAX_VALUE, sliderControl1.L(renderContext.palette().surfaceContainerHighest())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sliderControl1.h || sliderControl1.c) {
|
||||||
|
render2D.circle(gx, kx, 11.0F, ThemeManager.withAlpha(renderContext.palette().primary(), f * (sliderControl1.c ? 0.1F : 0.08F)));
|
||||||
|
}
|
||||||
|
|
||||||
|
render2D.roundedRect(gx - h, kx - 8.0F, sliderControl1.animation.getValue(), 16.0F, Float.MAX_VALUE, sliderControl1.L(renderContext.palette().primary()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseDragged(float f, float g, int i, float h, float j) {
|
||||||
|
if (!this.c) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.L(f);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseClicked(float f, float g, int i) {
|
||||||
|
if (!this.i() || i != 0 || !this.contains(f, gx)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gx < this.j()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.c = true;
|
||||||
|
this.L(f);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(RenderContext renderContext) {
|
||||||
|
SliderControl sliderControl1 = this;
|
||||||
|
sliderControl1.update(renderContext);
|
||||||
|
float f = sliderControl1.c ? 1.5F : (sliderControl1.h ? 4.5F : 3.0F);
|
||||||
|
if (sliderControl1.animation.getTarget() != f) {
|
||||||
|
sliderControl1.animation.animateTo(f, 150.0F, Easings.EASING6);
|
||||||
|
}
|
||||||
|
|
||||||
|
sliderControl1.animation.update(renderContext.i);
|
||||||
|
if (sliderControl1.c) {
|
||||||
|
sliderControl1.L(renderContext.H);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float G() {
|
||||||
|
return this.e - 6.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void L(float f) {
|
||||||
|
this.numberSetting.setNormalized((f - this.B()) / this.G());
|
||||||
|
}
|
||||||
|
|
||||||
|
public SliderControl(NumberSetting numberSetting) {
|
||||||
|
super(numberSettingx);
|
||||||
|
this.numberSetting = numberSettingx;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float m() {
|
||||||
|
return this.l() + 1.5F;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseReleased(float f, float g, int i) {
|
||||||
|
boolean bl = this.c;
|
||||||
|
this.c = false;
|
||||||
|
return bl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float B() {
|
||||||
|
return this.f + 3.0F;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user