multipage config gui
added config page for reeds
This commit is contained in:
@@ -7,7 +7,7 @@ import cpw.mods.fml.common.gameevent.InputEvent;
|
|||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import mods.betterfoliage.BetterFoliage;
|
import mods.betterfoliage.BetterFoliage;
|
||||||
import mods.betterfoliage.client.gui.ConfigGuiScreen;
|
import mods.betterfoliage.client.gui.ConfigGuiMain;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@@ -22,6 +22,6 @@ public class KeyHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void handleKeyPress(InputEvent.KeyInputEvent event) {
|
public void handleKeyPress(InputEvent.KeyInputEvent event) {
|
||||||
if (guiBinding.isPressed()) FMLClientHandler.instance().showGuiScreen(new ConfigGuiScreen(null));
|
if (guiBinding.isPressed()) FMLClientHandler.instance().showGuiScreen(new ConfigGuiMain(null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class ConfigGuiFactory implements IModGuiFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||||
return ConfigGuiScreen.class;
|
return ConfigGuiMain.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package mods.betterfoliage.client.gui;
|
||||||
|
|
||||||
|
import mods.betterfoliage.client.gui.widget.OptionDoubleWidget;
|
||||||
|
import mods.betterfoliage.common.config.Config;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
|
|
||||||
|
public class ConfigGuiGrass extends ConfigGuiScreenBase {
|
||||||
|
|
||||||
|
public ConfigGuiGrass(GuiScreen parent) {
|
||||||
|
super(parent);
|
||||||
|
int id = 10;
|
||||||
|
widgets.add(new OptionDoubleWidget(Config.grassSize, -100, -70, 200, 50, id++, id++, "message.betterfoliage.size", "%.2f"));
|
||||||
|
widgets.add(new OptionDoubleWidget(Config.grassHOffset, -100, -40, 200, 50, id++, id++, "message.betterfoliage.hOffset", "%.3f"));
|
||||||
|
widgets.add(new OptionDoubleWidget(Config.grassHeightMin, -100, -10, 200, 50, id++, id++, "message.betterfoliage.minHeight", "%.2f"));
|
||||||
|
widgets.add(new OptionDoubleWidget(Config.grassHeightMax, -100, 20, 200, 50, id++, id++, "message.betterfoliage.maxHeight", "%.2f"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void addButtons(int x, int y) {
|
||||||
|
buttonList.add(new GuiButton(0, x - 50, y + 50, 100, 20, "Close"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onButtonPress(int id) {
|
||||||
|
if (id == 0) FMLClientHandler.instance().showGuiScreen(parent);
|
||||||
|
|
||||||
|
if (Config.grassHeightMin.value > Config.grassHeightMax.value) Config.grassHeightMin.value = Config.grassHeightMax.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package mods.betterfoliage.client.gui;
|
||||||
|
|
||||||
|
import mods.betterfoliage.client.gui.widget.OptionDoubleWidget;
|
||||||
|
import mods.betterfoliage.common.config.Config;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
|
|
||||||
|
public class ConfigGuiLeaves extends ConfigGuiScreenBase {
|
||||||
|
|
||||||
|
public enum Button {CLOSE, LEAVES_OFFSET_MODE}
|
||||||
|
|
||||||
|
public ConfigGuiLeaves(GuiScreen parent) {
|
||||||
|
super(parent);
|
||||||
|
int id = 10;
|
||||||
|
widgets.add(new OptionDoubleWidget(Config.leavesSize, -100, -70, 200, 50, id++, id++, "message.betterfoliage.size", "%.2f"));
|
||||||
|
widgets.add(new OptionDoubleWidget(Config.leavesHOffset, -100, -10, 200, 50, id++, id++, "message.betterfoliage.hOffset", "%.3f"));
|
||||||
|
widgets.add(new OptionDoubleWidget(Config.leavesVOffset, -100, 20, 200, 50, id++, id++, "message.betterfoliage.vOffset", "%.3f"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void addButtons(int x, int y) {
|
||||||
|
buttonList.add(new GuiButton(Button.CLOSE.ordinal(), x - 50, y + 50, 100, 20, "Close"));
|
||||||
|
buttonList.add(new GuiButton(Button.LEAVES_OFFSET_MODE.ordinal(), x - 100, y - 40, 200, 20, ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateButtons() {
|
||||||
|
setButtonOptionBoolean(Button.LEAVES_OFFSET_MODE.ordinal(), "message.betterfoliage.leavesMode", Config.leavesSkew ? "message.betterfoliage.leavesSkew" : "message.betterfoliage.leavesTranslate");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onButtonPress(int id) {
|
||||||
|
if (id == Button.CLOSE.ordinal()) FMLClientHandler.instance().showGuiScreen(parent);
|
||||||
|
if (id == Button.LEAVES_OFFSET_MODE.ordinal()) Config.leavesSkew = !Config.leavesSkew;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package mods.betterfoliage.client.gui;
|
||||||
|
|
||||||
|
import mods.betterfoliage.client.gui.widget.OptionDoubleWidget;
|
||||||
|
import mods.betterfoliage.client.gui.widget.OptionIntegerWidget;
|
||||||
|
import mods.betterfoliage.common.config.Config;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
|
|
||||||
|
public class ConfigGuiLilypad extends ConfigGuiScreenBase {
|
||||||
|
|
||||||
|
public ConfigGuiLilypad(GuiScreen parent) {
|
||||||
|
super(parent);
|
||||||
|
int id = 10;
|
||||||
|
widgets.add(new OptionDoubleWidget(Config.lilypadHOffset, -100, -40, 200, 50, id++, id++, "message.betterfoliage.hOffset", "%.3f"));
|
||||||
|
widgets.add(new OptionIntegerWidget(Config.lilypadChance, -100, -10, 200, 50, id++, id++, "message.betterfoliage.flowerChance"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void addButtons(int x, int y) {
|
||||||
|
buttonList.add(new GuiButton(0, x - 50, y + 50, 100, 20, "Close"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onButtonPress(int id) {
|
||||||
|
if (id == 0) FMLClientHandler.instance().showGuiScreen(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package mods.betterfoliage.client.gui;
|
||||||
|
|
||||||
|
import mods.betterfoliage.common.config.Config;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public class ConfigGuiMain extends ConfigGuiScreenBase {
|
||||||
|
|
||||||
|
public enum Button {CLOSE,
|
||||||
|
TOGGLE_LEAVES, CONFIG_LEAVES,
|
||||||
|
TOGGLE_GRASS, CONFIG_GRASS,
|
||||||
|
TOGGLE_CACTUS, CONFIG_CACTUS,
|
||||||
|
TOGGLE_LILYPAD, CONFIG_LILYPAD,
|
||||||
|
TOGGLE_REED, CONFIG_REED}
|
||||||
|
|
||||||
|
public ConfigGuiMain(GuiScreen parent) {
|
||||||
|
super(parent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
protected void addButtons(int x, int y) {
|
||||||
|
buttonList.add(new GuiButton(Button.CLOSE.ordinal(), x - 50, y + 80, 100, 20, "Close"));
|
||||||
|
buttonList.add(new GuiButton(Button.TOGGLE_LEAVES.ordinal(), x - 100, y - 100, 150, 20, ""));
|
||||||
|
buttonList.add(new GuiButton(Button.CONFIG_LEAVES.ordinal(), x + 60, y - 100, 40, 20, I18n.format("message.betterfoliage.config")));
|
||||||
|
|
||||||
|
buttonList.add(new GuiButton(Button.TOGGLE_GRASS.ordinal(), x - 100, y - 70, 150, 20, ""));
|
||||||
|
buttonList.add(new GuiButton(Button.CONFIG_GRASS.ordinal(), x + 60, y - 70, 40, 20, I18n.format("message.betterfoliage.config")));
|
||||||
|
|
||||||
|
buttonList.add(new GuiButton(Button.TOGGLE_CACTUS.ordinal(), x - 100, y - 40, 150, 20, ""));
|
||||||
|
buttonList.add(new GuiButton(Button.CONFIG_CACTUS.ordinal(), x + 60, y - 40, 40, 20, I18n.format("message.betterfoliage.config")));
|
||||||
|
|
||||||
|
buttonList.add(new GuiButton(Button.TOGGLE_LILYPAD.ordinal(), x - 100, y - 10, 150, 20, ""));
|
||||||
|
buttonList.add(new GuiButton(Button.CONFIG_LILYPAD.ordinal(), x + 60, y - 10, 40, 20, I18n.format("message.betterfoliage.config")));
|
||||||
|
|
||||||
|
buttonList.add(new GuiButton(Button.TOGGLE_REED.ordinal(), x - 100, y + 20, 150, 20, ""));
|
||||||
|
buttonList.add(new GuiButton(Button.CONFIG_REED.ordinal(), x + 60, y + 20, 40, 20, I18n.format("message.betterfoliage.config")));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateButtons() {
|
||||||
|
setButtonOptionBoolean(Button.TOGGLE_LEAVES.ordinal(), "message.betterfoliage.betterLeaves", Config.leavesEnabled);
|
||||||
|
setButtonOptionBoolean(Button.TOGGLE_GRASS.ordinal(), "message.betterfoliage.betterGrass", Config.grassEnabled);
|
||||||
|
setButtonOptionBoolean(Button.TOGGLE_CACTUS.ordinal(), "message.betterfoliage.betterCactus", Config.cactusEnabled);
|
||||||
|
setButtonOptionBoolean(Button.TOGGLE_LILYPAD.ordinal(), "message.betterfoliage.betterLilypad", Config.lilypadEnabled);
|
||||||
|
setButtonOptionBoolean(Button.TOGGLE_REED.ordinal(), "message.betterfoliage.betterReed", Config.reedEnabled);
|
||||||
|
((GuiButton) buttonList.get(Button.CONFIG_CACTUS.ordinal())).enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onButtonPress(int id) {
|
||||||
|
if (id == Button.CLOSE.ordinal()) {
|
||||||
|
Config.save();
|
||||||
|
Minecraft.getMinecraft().renderGlobal.loadRenderers();
|
||||||
|
FMLClientHandler.instance().showGuiScreen(parent);
|
||||||
|
}
|
||||||
|
if (id == Button.TOGGLE_LEAVES.ordinal()) Config.leavesEnabled = !Config.leavesEnabled;
|
||||||
|
if (id == Button.TOGGLE_GRASS.ordinal()) Config.grassEnabled = !Config.grassEnabled;
|
||||||
|
if (id == Button.TOGGLE_CACTUS.ordinal()) Config.cactusEnabled = !Config.cactusEnabled;
|
||||||
|
if (id == Button.TOGGLE_LILYPAD.ordinal()) Config.lilypadEnabled = !Config.lilypadEnabled;
|
||||||
|
if (id == Button.TOGGLE_REED.ordinal()) Config.reedEnabled = !Config.reedEnabled;
|
||||||
|
|
||||||
|
if (id== Button.CONFIG_LEAVES.ordinal()) FMLClientHandler.instance().showGuiScreen(new ConfigGuiLeaves(this));
|
||||||
|
if (id== Button.CONFIG_GRASS.ordinal()) FMLClientHandler.instance().showGuiScreen(new ConfigGuiGrass(this));
|
||||||
|
if (id== Button.CONFIG_LILYPAD.ordinal()) FMLClientHandler.instance().showGuiScreen(new ConfigGuiLilypad(this));
|
||||||
|
if (id== Button.CONFIG_REED.ordinal()) FMLClientHandler.instance().showGuiScreen(new ConfigGuiReed(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package mods.betterfoliage.client.gui;
|
||||||
|
|
||||||
|
import mods.betterfoliage.client.gui.widget.OptionDoubleWidget;
|
||||||
|
import mods.betterfoliage.client.gui.widget.OptionIntegerWidget;
|
||||||
|
import mods.betterfoliage.common.config.Config;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
|
|
||||||
|
public class ConfigGuiReed extends ConfigGuiScreenBase {
|
||||||
|
|
||||||
|
public ConfigGuiReed(GuiScreen parent) {
|
||||||
|
super(parent);
|
||||||
|
int id = 10;
|
||||||
|
widgets.add(new OptionDoubleWidget(Config.reedHOffset, -100, -70, 200, 50, id++, id++, "message.betterfoliage.hOffset", "%.3f"));
|
||||||
|
widgets.add(new OptionDoubleWidget(Config.reedHeightMin, -100, -40, 200, 50, id++, id++, "message.betterfoliage.minHeight", "%.2f"));
|
||||||
|
widgets.add(new OptionDoubleWidget(Config.reedHeightMax, -100, -10, 200, 50, id++, id++, "message.betterfoliage.maxHeight", "%.2f"));
|
||||||
|
widgets.add(new OptionIntegerWidget(Config.reedChance, -100, 20, 200, 50, id++, id++, "message.betterfoliage.reedChance"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void addButtons(int x, int y) {
|
||||||
|
buttonList.add(new GuiButton(0, x - 50, y + 50, 100, 20, "Close"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onButtonPress(int id) {
|
||||||
|
if (id == 0) FMLClientHandler.instance().showGuiScreen(parent);
|
||||||
|
|
||||||
|
if (Config.reedHeightMin.value > Config.reedHeightMax.value) Config.reedHeightMin.value = Config.reedHeightMax.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
package mods.betterfoliage.client.gui;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import mods.betterfoliage.common.config.Config;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraft.util.EnumChatFormatting;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class ConfigGuiScreen extends GuiScreen {
|
|
||||||
|
|
||||||
public enum Button {CLOSE, TOGGLE_LEAVES, TOGGLE_GRASS, LEAVES_OFFSET_MODE, TOGGLE_CACTUS, TOGGLE_LILYPAD}
|
|
||||||
|
|
||||||
private GuiScreen parent;
|
|
||||||
protected List<IOptionWidget> widgets = Lists.newLinkedList();
|
|
||||||
|
|
||||||
public ConfigGuiScreen(GuiScreen parent) {
|
|
||||||
this.parent = parent;
|
|
||||||
int id = 10;
|
|
||||||
widgets.add(new OptionDoubleWidget(Config.leavesSize, -160, -40, 150, 40, id++, id++, "message.betterfoliage.size", "%.2f"));
|
|
||||||
widgets.add(new OptionDoubleWidget(Config.leavesHOffset, -160, -10, 150, 40, id++, id++, "message.betterfoliage.hOffset", "%.3f"));
|
|
||||||
widgets.add(new OptionDoubleWidget(Config.leavesVOffset, -160, 20, 150, 40, id++, id++, "message.betterfoliage.vOffset", "%.3f"));
|
|
||||||
|
|
||||||
widgets.add(new OptionDoubleWidget(Config.grassSize, 10, -70, 150, 40, id++, id++, "message.betterfoliage.size", "%.2f"));
|
|
||||||
widgets.add(new OptionDoubleWidget(Config.grassHOffset, 10, -40, 150, 40, id++, id++, "message.betterfoliage.hOffset", "%.3f"));
|
|
||||||
widgets.add(new OptionDoubleWidget(Config.grassHeightMin, 10, -10, 150, 40, id++, id++, "message.betterfoliage.minHeight", "%.2f"));
|
|
||||||
widgets.add(new OptionDoubleWidget(Config.grassHeightMax, 10, 20, 150, 40, id++, id++, "message.betterfoliage.maxHeight", "%.2f"));
|
|
||||||
|
|
||||||
widgets.add(new OptionDoubleWidget(Config.lilypadHOffset, 10, 80, 150, 40, id++, id++, "message.betterfoliage.hOffset", "%.3f"));
|
|
||||||
widgets.add(new OptionIntegerWidget(Config.lilypadChance, 10, 110, 150, 40, id++, id++, "message.betterfoliage.flowerChance"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int par1, int par2, float par3) {
|
|
||||||
this.drawDefaultBackground();
|
|
||||||
int x = width / 2;
|
|
||||||
int y = height / 2 - 30;
|
|
||||||
for (IOptionWidget widget : widgets) widget.drawStrings(this, fontRendererObj, x, y, 14737632, 16777120);
|
|
||||||
super.drawScreen(par1, par2, par3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void initGui() {
|
|
||||||
int x = width / 2;
|
|
||||||
int y = height / 2 - 30;
|
|
||||||
for (IOptionWidget widget : widgets) widget.addButtons(buttonList, x, y);
|
|
||||||
buttonList.add(new GuiButton(Button.CLOSE.ordinal(), x - 50, y + 130, 100, 20, "Close"));
|
|
||||||
buttonList.add(new GuiButton(Button.TOGGLE_LEAVES.ordinal(), x - 160, y - 100, 150, 20, ""));
|
|
||||||
buttonList.add(new GuiButton(Button.LEAVES_OFFSET_MODE.ordinal(), x - 160, y - 70, 150, 20, ""));
|
|
||||||
buttonList.add(new GuiButton(Button.TOGGLE_GRASS.ordinal(), x + 10, y - 100, 150, 20, ""));
|
|
||||||
buttonList.add(new GuiButton(Button.TOGGLE_CACTUS.ordinal(), x -160, y + 50, 150, 20, ""));
|
|
||||||
buttonList.add(new GuiButton(Button.TOGGLE_LILYPAD.ordinal(), x + 10, y + 50, 150, 20, ""));
|
|
||||||
updateButtons();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateButtons() {
|
|
||||||
setButtonOptionBoolean(Button.TOGGLE_LEAVES, "message.betterfoliage.betterLeaves", Config.leavesEnabled);
|
|
||||||
setButtonOptionBoolean(Button.LEAVES_OFFSET_MODE, "message.betterfoliage.leavesMode", Config.leavesSkew ? "message.betterfoliage.leavesSkew" : "message.betterfoliage.leavesTranslate");
|
|
||||||
setButtonOptionBoolean(Button.TOGGLE_GRASS, "message.betterfoliage.betterGrass", Config.grassEnabled);
|
|
||||||
setButtonOptionBoolean(Button.TOGGLE_CACTUS, "message.betterfoliage.betterCactus", Config.cactusEnabled);
|
|
||||||
setButtonOptionBoolean(Button.TOGGLE_LILYPAD, "message.betterfoliage.betterLilypad", Config.lilypadEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void actionPerformed(GuiButton button) {
|
|
||||||
super.actionPerformed(button);
|
|
||||||
|
|
||||||
if (button.id == Button.CLOSE.ordinal()) {
|
|
||||||
Config.save();
|
|
||||||
Minecraft.getMinecraft().renderGlobal.loadRenderers();
|
|
||||||
FMLClientHandler.instance().showGuiScreen(parent);
|
|
||||||
}
|
|
||||||
if (button.id == Button.TOGGLE_LEAVES.ordinal()) Config.leavesEnabled = !Config.leavesEnabled;
|
|
||||||
if (button.id == Button.TOGGLE_GRASS.ordinal()) Config.grassEnabled = !Config.grassEnabled;
|
|
||||||
if (button.id == Button.LEAVES_OFFSET_MODE.ordinal()) Config.leavesSkew = !Config.leavesSkew;
|
|
||||||
if (button.id == Button.TOGGLE_CACTUS.ordinal()) Config.cactusEnabled = !Config.cactusEnabled;
|
|
||||||
if (button.id == Button.TOGGLE_LILYPAD.ordinal()) Config.lilypadEnabled = !Config.lilypadEnabled;
|
|
||||||
|
|
||||||
for (IOptionWidget widget : widgets) widget.onAction(button.id);
|
|
||||||
if (Config.grassHeightMin.value > Config.grassHeightMax.value) Config.grassHeightMin.value = Config.grassHeightMax.value;
|
|
||||||
if (Config.grassHeightMin.value > Config.grassHeightMax.value) Config.grassHeightMax.value = Config.grassHeightMin.value;
|
|
||||||
updateButtons();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
protected void setButtonOptionBoolean(Button enumButton, String msgKey, boolean option) {
|
|
||||||
for (GuiButton button : (List<GuiButton>) buttonList) {
|
|
||||||
if (button.id == enumButton.ordinal()) {
|
|
||||||
String optionText = option ? (EnumChatFormatting.GREEN + I18n.format("message.betterfoliage.optionOn")) : (EnumChatFormatting.RED + I18n.format("message.betterfoliage.optionOff"));
|
|
||||||
button.displayString = I18n.format(msgKey, optionText);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
protected void setButtonOptionBoolean(Button enumButton, String msgKey, String optionKey) {
|
|
||||||
for (GuiButton button : (List<GuiButton>) buttonList) {
|
|
||||||
if (button.id == enumButton.ordinal()) {
|
|
||||||
button.displayString = I18n.format(msgKey, I18n.format(optionKey));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package mods.betterfoliage.client.gui;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import mods.betterfoliage.client.gui.widget.IOptionWidget;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
public class ConfigGuiScreenBase extends GuiScreen {
|
||||||
|
|
||||||
|
protected GuiScreen parent;
|
||||||
|
protected List<IOptionWidget> widgets = Lists.newLinkedList();
|
||||||
|
|
||||||
|
public ConfigGuiScreenBase(GuiScreen parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int par1, int par2, float par3) {
|
||||||
|
this.drawDefaultBackground();
|
||||||
|
int x = width / 2;
|
||||||
|
int y = height / 2;
|
||||||
|
for (IOptionWidget widget : widgets) widget.drawStrings(this, fontRendererObj, x, y, 14737632, 16777120);
|
||||||
|
super.drawScreen(par1, par2, par3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
int x = width / 2;
|
||||||
|
int y = height / 2;
|
||||||
|
for (IOptionWidget widget : widgets) widget.addButtons(buttonList, x, y);
|
||||||
|
addButtons(x, y);
|
||||||
|
updateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addButtons(int x, int y) {}
|
||||||
|
|
||||||
|
protected void updateButtons() {}
|
||||||
|
|
||||||
|
protected void onButtonPress(int id) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton button) {
|
||||||
|
super.actionPerformed(button);
|
||||||
|
for (IOptionWidget widget : widgets) widget.onAction(button.id);
|
||||||
|
onButtonPress(button.id);
|
||||||
|
updateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
protected void setButtonOptionBoolean(int id, String msgKey, boolean option) {
|
||||||
|
for (GuiButton button : (List<GuiButton>) buttonList) {
|
||||||
|
if (button.id == id) {
|
||||||
|
String optionText = option ? (EnumChatFormatting.GREEN + I18n.format("message.betterfoliage.optionOn")) : (EnumChatFormatting.RED + I18n.format("message.betterfoliage.optionOff"));
|
||||||
|
button.displayString = I18n.format(msgKey, optionText);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
protected void setButtonOptionBoolean(int id, String msgKey, String optionKey) {
|
||||||
|
for (GuiButton button : (List<GuiButton>) buttonList) {
|
||||||
|
if (button.id == id) {
|
||||||
|
button.displayString = I18n.format(msgKey, I18n.format(optionKey));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package mods.betterfoliage.client.gui;
|
package mods.betterfoliage.client.gui.widget;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package mods.betterfoliage.client.gui;
|
package mods.betterfoliage.client.gui.widget;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package mods.betterfoliage.client.gui;
|
package mods.betterfoliage.client.gui.widget;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -2,12 +2,14 @@ key.betterfoliage.gui=Open Settings
|
|||||||
|
|
||||||
message.betterfoliage.optionOn=ON
|
message.betterfoliage.optionOn=ON
|
||||||
message.betterfoliage.optionOff=OFF
|
message.betterfoliage.optionOff=OFF
|
||||||
|
message.betterfoliage.config=Config
|
||||||
|
|
||||||
message.betterfoliage.close=Close
|
message.betterfoliage.close=Close
|
||||||
message.betterfoliage.betterLeaves=Better Leaves: %s
|
message.betterfoliage.betterLeaves=Better Leaves: %s
|
||||||
message.betterfoliage.betterGrass=Better Grass: %s
|
message.betterfoliage.betterGrass=Better Grass: %s
|
||||||
message.betterfoliage.betterCactus=Better Cactus: %s
|
message.betterfoliage.betterCactus=Better Cactus: %s
|
||||||
message.betterfoliage.betterLilypad=Better Lilypad: %s
|
message.betterfoliage.betterLilypad=Better Lilypad: %s
|
||||||
|
message.betterfoliage.betterReed=Better Reeds: %s
|
||||||
|
|
||||||
message.betterfoliage.size=Size
|
message.betterfoliage.size=Size
|
||||||
message.betterfoliage.hOffset=H.Offset
|
message.betterfoliage.hOffset=H.Offset
|
||||||
@@ -15,6 +17,7 @@ message.betterfoliage.vOffset=V.Offset
|
|||||||
message.betterfoliage.minHeight=Min.Height
|
message.betterfoliage.minHeight=Min.Height
|
||||||
message.betterfoliage.maxHeight=Max.Height
|
message.betterfoliage.maxHeight=Max.Height
|
||||||
message.betterfoliage.flowerChance=Flower Chance
|
message.betterfoliage.flowerChance=Flower Chance
|
||||||
|
message.betterfoliage.reedChance=Reed Chance
|
||||||
message.betterfoliage.leavesMode=Leaves Offset: %s
|
message.betterfoliage.leavesMode=Leaves Offset: %s
|
||||||
message.betterfoliage.leavesSkew=Skew
|
message.betterfoliage.leavesSkew=Skew
|
||||||
message.betterfoliage.leavesTranslate=Translate
|
message.betterfoliage.leavesTranslate=Translate
|
||||||
Reference in New Issue
Block a user