From ccb88fd4168ad89e2972dcd25b455ad3cf9665a7 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 14 Jan 2017 01:28:20 +0100 Subject: [PATCH] Added a config option to change the booklet's font size Closes #554 --- .../mod/booklet/gui/GuiBooklet.java | 31 ++++++++++++------- .../mod/config/ConfigCategories.java | 1 - .../mod/config/values/ConfigIntValues.java | 6 +++- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiBooklet.java index 250c1bbf4..c96554151 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiBooklet.java @@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.booklet.gui; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; import de.ellpeck.actuallyadditions.mod.booklet.button.BookmarkButton; +import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.data.PlayerData; import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave; import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton; @@ -66,6 +67,21 @@ public abstract class GuiBooklet extends GuiBookletBase{ this.ySize = 180; } + private static float getFontSize(String lang, ConfigIntValues config, float defaultValue){ + int conf = config.getValue(); + if(conf <= 0){ + try{ + return Float.parseFloat(StringUtil.localize("booklet."+ModUtil.MOD_ID+".fontSize."+lang)); + } + catch(Exception e){ + return defaultValue; + } + } + else{ + return (float)conf/100F; + } + } + @Override public void initGui(){ super.initGui(); @@ -73,18 +89,9 @@ public abstract class GuiBooklet extends GuiBookletBase{ this.guiLeft = (this.width-this.xSize)/2; this.guiTop = (this.height-this.ySize)/2; - try{ - this.smallFontSize = Float.parseFloat(StringUtil.localize("booklet."+ModUtil.MOD_ID+".fontSize.small")); - this.mediumFontSize = Float.parseFloat(StringUtil.localize("booklet."+ModUtil.MOD_ID+".fontSize.medium")); - this.largeFontSize = Float.parseFloat(StringUtil.localize("booklet."+ModUtil.MOD_ID+".fontSize.large")); - } - catch(Exception e){ - ModUtil.LOGGER.error("Getting the booklet font size from the lang file failed!", e); - - this.smallFontSize = 0.5F; - this.mediumFontSize = 0.75F; - this.largeFontSize = 0.8F; - } + this.smallFontSize = getFontSize("small", ConfigIntValues.FONT_SIZE_SMALL, 0.5F); + this.mediumFontSize = getFontSize("medium", ConfigIntValues.FONT_SIZE_MEDIUM, 0.75F); + this.largeFontSize = getFontSize("large", ConfigIntValues.FONT_SIZE_LARGE, 0.8F); if(this.hasPageLeftButton()){ List hoverText = Arrays.asList(TextFormatting.GOLD+"Previous Page", TextFormatting.ITALIC+"Or scroll up"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java index 0bded76c7..3ee27cd20 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java @@ -14,7 +14,6 @@ import java.util.Locale; public enum ConfigCategories{ - PERFORMANCE("Performance", "Performance Settings"), TOOL_VALUES("Tool Values", "Values for Tools"), MACHINE_VALUES("Machine Values", "Values for Machines"), MOB_DROPS("Mob Drops", "Everything regarding Item drops from mobs"), diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java index 0b5f9f97e..fd27ca416 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java @@ -25,7 +25,11 @@ public enum ConfigIntValues{ WORMS_DIE_TIME("Worm Death Time", ConfigCategories.OTHER, 0, 0, 10000000, "The amount of ticks it takes for a worm to die. When at 0 ticks, it will not die."), TILE_ENTITY_UPDATE_INTERVAL("Tile Entities: Update Interval", ConfigCategories.OTHER, 5, 1, 100, "The amount of ticks waited before a TileEntity sends an additional Update to the Client"), - CTRL_INFO_NBT_CHAR_LIMIT("Advanced Info NBT Character Limit", ConfigCategories.OTHER, 1000, 0, 100000000, "The maximum amount of characters that is displayed by the NBT view of the CTRL Advanced Info. Set to a zero to have no limit"); + CTRL_INFO_NBT_CHAR_LIMIT("Advanced Info NBT Character Limit", ConfigCategories.OTHER, 1000, 0, 100000000, "The maximum amount of characters that is displayed by the NBT view of the CTRL Advanced Info. Set to a zero to have no limit"), + + FONT_SIZE_SMALL("Booklet Small Font Size", ConfigCategories.OTHER, 0, 0, 500, "The size of the booklet's small font in percent. Set to 0 to use defaults from the lang file."), + FONT_SIZE_MEDIUM("Booklet Medium Font Size", ConfigCategories.OTHER, 0, 0, 500, "The size of the booklet's medium font in percent. Set to 0 to use defaults from the lang file."), + FONT_SIZE_LARGE("Booklet Large Font Size", ConfigCategories.OTHER, 0, 0, 500, "The size of the booklet's large font in percent. Set to 0 to use defaults from the lang file."); public final String name; public final String category;