From d673d9a78d2b2b09e4f7d24233d841106c0ed141 Mon Sep 17 00:00:00 2001 From: GirafiStudios Date: Sun, 9 Apr 2017 23:43:21 +0200 Subject: [PATCH] Changed GUI config category strings, Closes #960 Updated to latest Forge, to start using the new GUI Factory stuff. Greatly simplifies the class. --- build.properties | 2 +- .../client/gui/GuiBOPConfig.java | 44 --------------- .../client/gui/GuiBOPFactory.java | 53 +++++++++++++++++++ .../biomesoplenty/client/gui/GuiFactory.java | 25 --------- .../config/GameplayConfigurationHandler.java | 4 +- .../biomesoplenty/core/BiomesOPlenty.java | 2 +- .../assets/biomesoplenty/lang/en_US.lang | 8 +-- 7 files changed, 61 insertions(+), 77 deletions(-) delete mode 100644 src/main/java/biomesoplenty/client/gui/GuiBOPConfig.java create mode 100644 src/main/java/biomesoplenty/client/gui/GuiBOPFactory.java delete mode 100644 src/main/java/biomesoplenty/client/gui/GuiFactory.java diff --git a/build.properties b/build.properties index cf56bc50e..efa94f358 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ minecraft_version=1.11.2 -forge_version=13.20.0.2224 +forge_version=13.20.0.2279 mod_version=6.0.2 mappings_version=snapshot_nodoc_20170121 diff --git a/src/main/java/biomesoplenty/client/gui/GuiBOPConfig.java b/src/main/java/biomesoplenty/client/gui/GuiBOPConfig.java deleted file mode 100644 index 5dd7c36b0..000000000 --- a/src/main/java/biomesoplenty/client/gui/GuiBOPConfig.java +++ /dev/null @@ -1,44 +0,0 @@ -package biomesoplenty.client.gui; - -import java.util.ArrayList; -import java.util.List; - -import biomesoplenty.common.config.GameplayConfigurationHandler; -import biomesoplenty.common.config.MiscConfigurationHandler; -import biomesoplenty.common.remote.TrailManager; -import biomesoplenty.common.util.entity.PlayerUtil; -import biomesoplenty.core.BiomesOPlenty; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.util.text.translation.I18n; -import net.minecraftforge.common.config.ConfigElement; -import net.minecraftforge.fml.client.config.DummyConfigElement; -import net.minecraftforge.fml.client.config.GuiConfig; -import net.minecraftforge.fml.client.config.IConfigElement; - -public class GuiBOPConfig extends GuiConfig -{ - public GuiBOPConfig(GuiScreen parentScreen) - { - super(parentScreen, GuiBOPConfig.getConfigElements(), BiomesOPlenty.MOD_ID, false, false, "/biomesoplenty"); - } - - private static List getConfigElements() - { - List list = new ArrayList(); - - List convenienceSettings = new ConfigElement(GameplayConfigurationHandler.config.getCategory(GameplayConfigurationHandler.convenienceSettings.toLowerCase())).getChildElements(); - List guiSettings = new ConfigElement(MiscConfigurationHandler.config.getCategory(MiscConfigurationHandler.GUI_SETTINGS.toLowerCase())).getChildElements(); - List textureSettings = new ConfigElement(MiscConfigurationHandler.config.getCategory(MiscConfigurationHandler.VISUAL_SETTINGS.toLowerCase())).getChildElements(); - List trailSettings = new ConfigElement(MiscConfigurationHandler.config.getCategory(MiscConfigurationHandler.TRAIL_SETTINGS.toLowerCase())).getChildElements(); - - list.add(new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.category.convenienceSettings.title"), "config.category.convenienceSettings", convenienceSettings)); - list.add(new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.category.guiSettings.title"), "config.category.guiSettings", guiSettings)); - list.add(new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.category.textureSettings.title"), "config.category.textureSettings", textureSettings)); - if (TrailManager.trailsMap.containsKey(PlayerUtil.getClientPlayerUUID())) - { - list.add(new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.category.trailSettings.title"), "config.category.trailSettings", trailSettings)); - } - - return list; - } -} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/client/gui/GuiBOPFactory.java b/src/main/java/biomesoplenty/client/gui/GuiBOPFactory.java new file mode 100644 index 000000000..27be4109c --- /dev/null +++ b/src/main/java/biomesoplenty/client/gui/GuiBOPFactory.java @@ -0,0 +1,53 @@ +package biomesoplenty.client.gui; + +import biomesoplenty.common.config.GameplayConfigurationHandler; +import biomesoplenty.common.remote.TrailManager; +import biomesoplenty.common.util.entity.PlayerUtil; +import biomesoplenty.core.BiomesOPlenty; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.util.text.translation.I18n; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.fml.client.DefaultGuiFactory; +import net.minecraftforge.fml.client.config.DummyConfigElement.DummyCategoryElement; +import net.minecraftforge.fml.client.config.GuiConfig; +import net.minecraftforge.fml.client.config.IConfigElement; + +import java.util.ArrayList; +import java.util.List; + +import static biomesoplenty.common.config.GameplayConfigurationHandler.CONVENIENCE_SETTINGS; +import static biomesoplenty.common.config.MiscConfigurationHandler.*; + +public class GuiBOPFactory extends DefaultGuiFactory +{ + public GuiBOPFactory() + { + super(BiomesOPlenty.MOD_ID, BiomesOPlenty.MOD_NAME); + } + + @Override + public GuiScreen createConfigGui(GuiScreen parentScreen) + { + return new GuiConfig(parentScreen, getConfigElements(), modid, false, false, title); + } + + private static List getConfigElements() + { + List list = new ArrayList(); + + List convenience_settings = new ConfigElement(GameplayConfigurationHandler.config.getCategory(CONVENIENCE_SETTINGS.toLowerCase())).getChildElements(); + List gui_settings = new ConfigElement(config.getCategory(GUI_SETTINGS.toLowerCase())).getChildElements(); + List texture_settings = new ConfigElement(config.getCategory(VISUAL_SETTINGS.toLowerCase())).getChildElements(); + List trail_settings = new ConfigElement(config.getCategory(TRAIL_SETTINGS.toLowerCase())).getChildElements(); + + list.add(new DummyCategoryElement(I18n.translateToLocal("config.category.convenienceSettings.title"), "config.category.convenienceSettings", convenience_settings)); + list.add(new DummyCategoryElement(I18n.translateToLocal("config.category.guiSettings.title"), "config.category.guiSettings", gui_settings)); + list.add(new DummyCategoryElement(I18n.translateToLocal("config.category.textureSettings.title"), "config.category.textureSettings", texture_settings)); + if (TrailManager.trailsMap.containsKey(PlayerUtil.getClientPlayerUUID())) + { + list.add(new DummyCategoryElement(I18n.translateToLocal("config.category.trailSettings.title"), "config.category.trailSettings", trail_settings)); + } + + return list; + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/client/gui/GuiFactory.java b/src/main/java/biomesoplenty/client/gui/GuiFactory.java deleted file mode 100644 index 3155eb1ce..000000000 --- a/src/main/java/biomesoplenty/client/gui/GuiFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -package biomesoplenty.client.gui; - -import java.util.Set; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraftforge.fml.client.IModGuiFactory; - -public class GuiFactory implements IModGuiFactory { - - @Override - public void initialize(Minecraft minecraftInstance) { } - - @Override - public Class mainConfigGuiClass() - { - return GuiBOPConfig.class; - } - - @Override - public Set runtimeGuiCategories() { return null; } - - @Override - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { return null; } -} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/config/GameplayConfigurationHandler.java b/src/main/java/biomesoplenty/common/config/GameplayConfigurationHandler.java index ec0003ef6..fec31608e 100644 --- a/src/main/java/biomesoplenty/common/config/GameplayConfigurationHandler.java +++ b/src/main/java/biomesoplenty/common/config/GameplayConfigurationHandler.java @@ -18,7 +18,7 @@ public class GameplayConfigurationHandler { public static Configuration config; - public static String convenienceSettings = "Convenience Settings"; + public static final String CONVENIENCE_SETTINGS = "Convenience Settings"; public static boolean flowerDropsNeedShears; @@ -35,7 +35,7 @@ public class GameplayConfigurationHandler { try { - flowerDropsNeedShears = config.getBoolean("Flower Drops Need Shears", convenienceSettings, false, "Require shears to be used to collect flower drops."); + flowerDropsNeedShears = config.getBoolean("Flower Drops Need Shears", CONVENIENCE_SETTINGS, false, "Require shears to be used to collect flower drops."); } catch (Exception e) { diff --git a/src/main/java/biomesoplenty/core/BiomesOPlenty.java b/src/main/java/biomesoplenty/core/BiomesOPlenty.java index e85aee9cc..8bc8163f3 100644 --- a/src/main/java/biomesoplenty/core/BiomesOPlenty.java +++ b/src/main/java/biomesoplenty/core/BiomesOPlenty.java @@ -50,7 +50,7 @@ public class BiomesOPlenty public static final String MOD_NAME = "Biomes O' Plenty"; public static final String MOD_ID = "biomesoplenty"; public static final String MOD_VERSION = "@MOD_VERSION@"; - public static final String GUI_FACTORY = "biomesoplenty.client.gui.GuiFactory"; + public static final String GUI_FACTORY = "biomesoplenty.client.gui.GuiBOPFactory"; @Instance(MOD_ID) public static BiomesOPlenty instance; diff --git a/src/main/resources/assets/biomesoplenty/lang/en_US.lang b/src/main/resources/assets/biomesoplenty/lang/en_US.lang index 232d09386..d64174702 100644 --- a/src/main/resources/assets/biomesoplenty/lang/en_US.lang +++ b/src/main/resources/assets/biomesoplenty/lang/en_US.lang @@ -49,10 +49,10 @@ config.category.convenienceSettings.title=Convenience Settings config.category.guiSettings.title=GUI Settings config.category.textureSettings.title=Texture Settings config.category.trailSettings.title=Trail Settings -config.category.convenienceSettings.tooltip=Require shears to be used to collect flower drops. -config.category.guiSettings.tooltip=Use the Biomes O' Plenty World Type by default when selecting a world. -config.category.textureSettings.tooltip=Override the Forge bucket texture and use ours instead (It's nicer!) -config.category.trailSettings.tooltip=Modify Trail Visibility +config.category.convenienceSettings.tooltip=Settings for convenience. +config.category.guiSettings.tooltip=GUI related settings. +config.category.textureSettings.tooltip=Texture related settings. +config.category.trailSettings.tooltip=Settings to modify trail visibility. commands.biomesoplenty.usage=/biomesoplenty [args] commands.biomesoplenty.biomename.usage=/biomesoplenty biomename [biomeId]