82 lines
2.6 KiB
Java
82 lines
2.6 KiB
Java
package openonyx.ui.internal;
|
|
|
|
import java.util.Iterator;
|
|
import java.util.function.Consumer;
|
|
import openonyx.core.OnyxClient;
|
|
import openonyx.theme.Fonts;
|
|
import openonyx.ui.RenderContext;
|
|
import openonyx.ui.ScrollList;
|
|
import openonyx.ui.UiComponent;
|
|
|
|
public class ConfigList extends ScrollList {
|
|
private static final float j = 9.0F;
|
|
private final Consumer<ConfigRow> configRowConsumer;
|
|
private static final float l = 5.0F;
|
|
private final Consumer<ConfigRow> configRowConsumer2;
|
|
private final Consumer<ConfigRow> configRowConsumer3;
|
|
|
|
@Override
|
|
public boolean mouseClicked(float f, float g, int i) {
|
|
return this.contains(f, g) && super.mouseClicked(f, g, i);
|
|
}
|
|
|
|
public ConfigList(Consumer<ConfigRow> consumer, Consumer<ConfigRow> consumer1, Consumer<ConfigRow> consumer2) {
|
|
this.configRowConsumer2 = consumer;
|
|
this.configRowConsumer = consumer1;
|
|
this.configRowConsumer3 = consumer2;
|
|
this.d();
|
|
}
|
|
|
|
public ConfigRow L() {
|
|
ConfigList configList1 = this;
|
|
UiComponent uiComponent;
|
|
return (uiComponent = configList1.L()) instanceof ConfigRow ? (ConfigRow)uiComponent : null;
|
|
}
|
|
|
|
@Override
|
|
protected void i(RenderContext renderContext) {
|
|
float f = this.d - this.animation.getValue();
|
|
|
|
Iterator iterator;
|
|
for (Iterator iterator1 = iterator = this.uiComponents.iterator(); iterator1.hasNext(); iterator1 = iterator) {
|
|
((UiComponent)iterator.next()).setBounds(this.f, f, this.e - 9.0F, 50.0F);
|
|
f += 55.0F;
|
|
}
|
|
|
|
this.I = this.uiComponents.isEmpty() ? 0.0F : this.uiComponents.size() * 55.0F - 5.0F;
|
|
}
|
|
|
|
@Override
|
|
public void render(RenderContext renderContext) {
|
|
if (this.uiComponents.isEmpty()) {
|
|
renderContext.render2D
|
|
.drawTextCenteredVCentered(
|
|
Fonts.getFontstylE15(), "No configs saved yet", this.f + this.e / 2.0F, this.d + this.i / 2.0F, renderContext.palette().onSurfaceVariant()
|
|
);
|
|
} else {
|
|
super.render(renderContext);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void d() {
|
|
ConfigList configList1 = this;
|
|
configList1.uiComponents.clear();
|
|
configList1.D();
|
|
configList1.m = 0.0F;
|
|
configList1.animation.set(0.0F);
|
|
Iterator iterator = OnyxClient.configManager.L().iterator();
|
|
Iterator iterator1 = iterator;
|
|
|
|
while (iterator1.hasNext()) {
|
|
String string = (String)iterator.next();
|
|
iterator1 = iterator;
|
|
configList1.uiComponents.add(new ConfigRow(string, configList1.configRowConsumer2, configList1.configRowConsumer, configList1.configRowConsumer3));
|
|
}
|
|
}
|
|
|
|
public int D() {
|
|
return this.uiComponents.size();
|
|
}
|
|
}
|