2018-05-13 18:43:49 +02:00
|
|
|
package com.minelittlepony.gui;
|
|
|
|
|
|
|
|
import com.minelittlepony.MineLittlePony;
|
|
|
|
import com.minelittlepony.PonyConfig;
|
2018-05-15 16:26:52 +02:00
|
|
|
import com.minelittlepony.PonyConfig.PonySettings;
|
2018-05-13 18:43:49 +02:00
|
|
|
import com.minelittlepony.pony.data.PonyLevel;
|
2018-05-15 16:26:52 +02:00
|
|
|
import com.minelittlepony.render.ponies.MobRenderers;
|
2018-05-13 18:43:49 +02:00
|
|
|
import com.mumfrey.liteloader.core.LiteLoader;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* In-Game options menu.
|
|
|
|
*
|
|
|
|
*/
|
2018-07-27 14:27:32 +02:00
|
|
|
public class GuiPonySettings extends SettingsPanel {
|
2018-05-13 18:43:49 +02:00
|
|
|
|
|
|
|
private static final String OPTIONS_PREFIX = "minelp.options.";
|
|
|
|
|
|
|
|
private static final String PONY_LEVEL = OPTIONS_PREFIX + "ponylevel";
|
|
|
|
|
|
|
|
private static final String MOB_PREFIX = "minelp.mobs.";
|
|
|
|
|
|
|
|
private PonyConfig config;
|
|
|
|
|
|
|
|
public GuiPonySettings() {
|
|
|
|
config = MineLittlePony.getConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void initGui() {
|
|
|
|
final int LEFT = width / 10;
|
|
|
|
final int RIGHT = mustScroll() ? LEFT : width - width / 3 - 16;
|
|
|
|
|
|
|
|
int row = mustScroll() ? 0 : 32;
|
|
|
|
|
|
|
|
if (!mustScroll()) {
|
|
|
|
addButton(new Label(width / 2, 12, getTitle(), -1, true));
|
|
|
|
}
|
|
|
|
|
|
|
|
addButton(new Label(LEFT, row += 15, PONY_LEVEL, -1));
|
|
|
|
addButton(new Slider(LEFT, row += 15, 0, 2, config.getPonyLevel().ordinal(), (int id, String name, float value) -> {
|
2018-07-27 14:27:32 +02:00
|
|
|
return format(PONY_LEVEL + "." + PonyLevel.valueFor(value).name().toLowerCase());
|
2018-05-13 18:43:49 +02:00
|
|
|
}, v -> {
|
|
|
|
PonyLevel level = PonyLevel.valueFor(v);
|
|
|
|
config.setPonyLevel(level);
|
|
|
|
return (float)level.ordinal();
|
|
|
|
}));
|
|
|
|
|
|
|
|
row += 15;
|
|
|
|
addButton(new Label(LEFT, row += 15, OPTIONS_PREFIX + "options", -1));
|
2018-05-15 16:26:52 +02:00
|
|
|
for (PonySettings i : PonySettings.values()) {
|
|
|
|
addButton(new Checkbox(LEFT, row += 15, OPTIONS_PREFIX + i.name().toLowerCase(), i.get(), i));
|
|
|
|
}
|
2018-05-13 18:43:49 +02:00
|
|
|
|
|
|
|
if (mustScroll()) {
|
|
|
|
row += 15;
|
|
|
|
} else {
|
|
|
|
row = 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
addButton(new Label(RIGHT, row += 15, MOB_PREFIX + "title", -1));
|
2018-05-15 16:26:52 +02:00
|
|
|
for (MobRenderers i : MobRenderers.values()) {
|
|
|
|
addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + i.name().toLowerCase(), i.get(), i));
|
|
|
|
}
|
2018-05-13 18:43:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-07-27 19:42:37 +02:00
|
|
|
public void drawContents(int mouseX, int mouseY, float partialTicks) {
|
2018-05-13 18:43:49 +02:00
|
|
|
drawDefaultBackground();
|
2018-07-27 19:42:37 +02:00
|
|
|
super.drawContents(mouseX, mouseY, partialTicks);
|
2018-05-13 18:43:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onGuiClosed() {
|
|
|
|
LiteLoader.getInstance().writeConfig(config);
|
|
|
|
}
|
|
|
|
|
2018-09-07 21:16:07 +02:00
|
|
|
@Override
|
2018-05-13 18:43:49 +02:00
|
|
|
protected String getTitle() {
|
|
|
|
return OPTIONS_PREFIX + "title";
|
|
|
|
}
|
|
|
|
}
|