From 0b50d230146616b6a0e9af7a640838539539cff7 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 24 Jul 2014 23:59:58 -0500 Subject: [PATCH] Added Feature: #0711 - Options to change font size in game. --- client/gui/config/AEConfigGui.java | 45 ++++++++++++ client/gui/config/AEConfigGuiFactory.java | 36 +++++++++ core/AEConfig.java | 90 +++++++++++++++++------ core/AppEng.java | 8 +- transformer/AppEngCore.java | 2 +- 5 files changed, 152 insertions(+), 29 deletions(-) create mode 100644 client/gui/config/AEConfigGui.java create mode 100644 client/gui/config/AEConfigGuiFactory.java diff --git a/client/gui/config/AEConfigGui.java b/client/gui/config/AEConfigGui.java new file mode 100644 index 00000000..81b5a394 --- /dev/null +++ b/client/gui/config/AEConfigGui.java @@ -0,0 +1,45 @@ +package appeng.client.gui.config; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.ConfigElement; +import appeng.core.AEConfig; +import appeng.core.AppEng; +import cpw.mods.fml.client.config.GuiConfig; +import cpw.mods.fml.client.config.IConfigElement; + +public class AEConfigGui extends GuiConfig +{ + + private static List getConfigElements() + { + List list = new ArrayList(); + + for (String cat : AEConfig.instance.getCategoryNames()) + { + if ( cat.equals( "versionchecker" ) ) + continue; + + if ( cat.equals( "settings" ) ) + continue; + + ConfigCategory cc = AEConfig.instance.getCategory( cat ); + + if ( cc.isChild() ) + continue; + + ConfigElement ce = new ConfigElement( cc ); + list.add( ce ); + } + + return list; + } + + public AEConfigGui(GuiScreen parent) { + super( parent, getConfigElements(), AppEng.modid, false, false, GuiConfig.getAbridgedConfigPath( AEConfig.instance.getFilePath() ) ); + } + +} diff --git a/client/gui/config/AEConfigGuiFactory.java b/client/gui/config/AEConfigGuiFactory.java new file mode 100644 index 00000000..646be30a --- /dev/null +++ b/client/gui/config/AEConfigGuiFactory.java @@ -0,0 +1,36 @@ +package appeng.client.gui.config; + +import java.util.Set; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import cpw.mods.fml.client.IModGuiFactory; + +public class AEConfigGuiFactory implements IModGuiFactory +{ + + @Override + public void initialize(Minecraft minecraftInstance) + { + + } + + @Override + public Class mainConfigGuiClass() + { + return AEConfigGui.class; + } + + @Override + public Set runtimeGuiCategories() + { + return null; + } + + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) + { + return null; + } + +} diff --git a/core/AEConfig.java b/core/AEConfig.java index 3b769300..054ec21a 100644 --- a/core/AEConfig.java +++ b/core/AEConfig.java @@ -19,6 +19,9 @@ import appeng.core.settings.TickRates; import appeng.util.ConfigManager; import appeng.util.IConfigManagerHost; import appeng.util.Platform; +import cpw.mods.fml.client.event.ConfigChangedEvent; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class AEConfig extends Configuration implements IConfigureableObject, IConfigManagerHost { @@ -72,6 +75,20 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo return WirelessBaseCost + WirelessCostMultiplier * Math.pow( boosters, 1 + boosters / WirelessHighWirelessCount ); } + @Override + public Property get(String category, String key, String defaultValue, String comment, Property.Type type) + { + Property prop = super.get( category, key, defaultValue, comment, type ); + + if ( prop != null ) + { + if ( !category.equals( "Client" ) ) + prop.setRequiresMcRestart( true ); + } + + return prop; + } + public double spatialPowerScaler = 1.5; public double spatialPowerMultiplier = 1500.0; @@ -98,12 +115,55 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo public int staff_battery = 8000; public boolean updateable = false; - + final private File myPath; + + @SubscribeEvent + public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) + { + if ( eventArgs.modID.equals( AppEng.modid ) ) + { + clientSync(); + } + } + + private void clientSync() + { + enableEffects = get( "Client", "enableEffects", true ).getBoolean( true ); + useLargeFonts = get( "Client", "useTerminalUseLargeFont", false ).getBoolean( false ); + + for (Enum e : settings.getSettings()) + { + String Category = "Client"; // e.getClass().getSimpleName(); + Enum value = settings.getSetting( e ); + + Property p = this.get( Category, e.name(), value.name(), getListComment( value ) ); + + try + { + value = Enum.valueOf( value.getClass(), p.getString() ); + } + catch (IllegalArgumentException er) + { + AELog.info( "Invalid value '" + p.getString() + "' for " + e.name() + " using '" + value.name() + "' instead" ); + } + + settings.putSetting( e, value ); + } + + } + + public String getFilePath() + { + return myPath.toString(); + } + public AEConfig(String path) { super( new File( path + "AppliedEnergistics2.cfg" ) ); + myPath = new File( path + "AppliedEnergistics2.cfg" ); + + FMLCommonHandler.instance().bus().register( this ); final double DEFAULT_BC_EXCHANGE = 5.0; - // final double DEFAULT_UE_EXCHANGE = 5.0; final double DEFAULT_IC2_EXCHANGE = 2.0; final double DEFAULT_RTC_EXCHANGE = 1.0 / 11256.0; final double DEFAULT_RF_EXCHANGE = 0.5; @@ -123,8 +183,6 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo grinderOres = get( "GrindStone", "grinderOres", grinderOres ).getStringList(); oreDoublePercentage = get( "GrindStone", "oreDoublePercentage", oreDoublePercentage ).getDouble( oreDoublePercentage ); - enableEffects = get( "Client", "enableEffects", true ).getBoolean( true ); - useLargeFonts = get( "Client", "useTerminalUseLargeFont", false ).getBoolean( false ); settings.registerSetting( Settings.SEARCH_TOOLTIPS, YesNo.YES ); settings.registerSetting( Settings.TERMINAL_STYLE, TerminalStyle.TALL ); @@ -156,6 +214,8 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo colorapplicator_battery = get( "battery", "colorapplicator", colorapplicator_battery ).getInt( colorapplicator_battery ); mattercannon_battery = get( "battery", "mattercannon", mattercannon_battery ).getInt( mattercannon_battery ); + clientSync(); + for (AEFeature feature : AEFeature.values()) { if ( feature.isVisible() ) @@ -170,25 +230,6 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo if ( featureFlags.contains( AEFeature.WebsiteRecipes ) ) featureFlags.add( AEFeature.DuplicateItems ); - for (Enum e : settings.getSettings()) - { - String Category = e.getClass().getSimpleName(); - Enum value = settings.getSetting( e ); - - Property p = this.get( Category, e.name(), value.name(), getListComment( value ) ); - - try - { - value = Enum.valueOf( value.getClass(), p.getString() ); - } - catch (IllegalArgumentException er) - { - AELog.info( "Invalid value '" + p.getString() + "' for " + e.name() + " using '" + value.name() + "' instead" ); - } - - settings.putSetting( e, value ); - } - try { selectedPowerUnit = PowerUnits.valueOf( get( "Client", "PowerUnit", selectedPowerUnit.name(), getListComment( selectedPowerUnit ) ).getString() ); @@ -221,7 +262,7 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo latestTimeStamp = 0; } } - + updateable = true; } @@ -370,4 +411,5 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo selectedPowerUnit = Platform.rotateEnum( selectedPowerUnit, backwards, Settings.POWER_UNITS.getPossibleValues() ); save(); } + } diff --git a/core/AppEng.java b/core/AppEng.java index e7edcd2d..63f4798b 100644 --- a/core/AppEng.java +++ b/core/AppEng.java @@ -39,7 +39,7 @@ import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.event.FMLServerStoppingEvent; import cpw.mods.fml.common.network.NetworkRegistry; -@Mod(modid = AppEng.modid, acceptedMinecraftVersions = "[1.7.10]", name = AppEng.name, version = AEConfig.VERSION, dependencies = AppEng.dependencies) +@Mod(modid = AppEng.modid, acceptedMinecraftVersions = "[1.7.10]", name = AppEng.name, version = AEConfig.VERSION, dependencies = AppEng.dependencies, guiFactory = "appeng.client.gui.config.AEConfigGuiFactory") public class AppEng { @@ -64,7 +64,7 @@ public class AppEng "after:gregtech_addon;after:Mekanism;after:IC2;after:ThermalExpansion;after:BuildCraft|Core;" + // depend on version of forge used for build. - "required-after:AppliedEnergistics2-Core;" + "required-after:Forge@[" // require forge. + "required-after:appliedenergistics2-core;" + "required-after:Forge@[" // require forge. + net.minecraftforge.common.ForgeVersion.majorVersion + "." // majorVersion + net.minecraftforge.common.ForgeVersion.minorVersion + "." // minorVersion + net.minecraftforge.common.ForgeVersion.revisionVersion + "." // revisionVersion @@ -86,12 +86,12 @@ public class AppEng FMLCommonHandler.instance().registerCrashCallable( new CrashEnhancement( CrashInfo.MOD_VERSION ) ); } - public boolean isIntegrationEnabled( IntegrationType Name ) + public boolean isIntegrationEnabled(IntegrationType Name) { return IntegrationRegistry.instance.isEnabled( Name ); } - public Object getIntegration( IntegrationType Name ) + public Object getIntegration(IntegrationType Name) { return IntegrationRegistry.instance.getInstance( Name ); } diff --git a/transformer/AppEngCore.java b/transformer/AppEngCore.java index 9a21e314..be3389e0 100644 --- a/transformer/AppEngCore.java +++ b/transformer/AppEngCore.java @@ -71,7 +71,7 @@ public class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin @Override public String getModId() { - return "AppliedEnergistics2-Core"; + return "appliedenergistics2-core"; } @Override