From 91dc0f4ce12f0be735ec2ef9058ab3997637c85c Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 7 Dec 2016 15:25:04 +0100 Subject: [PATCH] You can now change the booklet's font size in the lang file Closes #461 --- .../api/booklet/internal/GuiBookletBase.java | 6 ++++ .../mod/booklet/button/EntryButton.java | 10 ++++-- .../mod/booklet/gui/GuiBooklet.java | 33 +++++++++++++++++++ .../mod/booklet/gui/GuiEntry.java | 4 +-- .../mod/booklet/gui/GuiMainPage.java | 8 ++--- .../mod/booklet/gui/GuiPage.java | 2 +- .../mod/booklet/page/PageCoffeeMachine.java | 4 +-- .../mod/booklet/page/PageCrafting.java | 2 +- .../mod/booklet/page/PageCrusherRecipe.java | 2 +- .../mod/booklet/page/PageEmpowerer.java | 2 +- .../mod/booklet/page/PageFurnace.java | 2 +- .../mod/booklet/page/PageReconstructor.java | 2 +- .../mod/booklet/page/PageTextOnly.java | 2 +- .../assets/actuallyadditions/lang/en_US.lang | 9 +++-- 14 files changed, 68 insertions(+), 20 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/internal/GuiBookletBase.java b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/internal/GuiBookletBase.java index 0aa235f3d..590338969 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/internal/GuiBookletBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/internal/GuiBookletBase.java @@ -33,4 +33,10 @@ public abstract class GuiBookletBase extends GuiScreen{ public abstract int getSizeY(); public abstract void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer); + + public abstract float getSmallFontSize(); + + public abstract float getMediumFontSize(); + + public abstract float getLargeFontSize(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/EntryButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/EntryButton.java index 3a71f592a..01f9e0dbe 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/EntryButton.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/EntryButton.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.booklet.button; +import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; +import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; @@ -23,10 +25,12 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class EntryButton extends GuiButton{ - public ItemStack stackToRender; + private final GuiBookletBase gui; + private final ItemStack stackToRender; - public EntryButton(int id, int x, int y, int width, int height, String text, ItemStack stackToRender){ + public EntryButton(GuiBookletBase gui, int id, int x, int y, int width, int height, String text, ItemStack stackToRender){ super(id, x, y, width, height, text); + this.gui = gui; this.stackToRender = stackToRender; } @@ -48,7 +52,7 @@ public class EntryButton extends GuiButton{ textOffsetX = 10; } - float scale = 0.75F; + float scale = this.gui.getMediumFontSize(); if(this.hovered){ GlStateManager.pushMatrix(); 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 fbe9c73d6..a7ac473c1 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 @@ -18,6 +18,7 @@ import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave; import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; +import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; @@ -53,6 +54,10 @@ public abstract class GuiBooklet extends GuiBookletBase{ private GuiButton buttonRight; private GuiButton buttonBack; + private float smallFontSize; + private float mediumFontSize; + private float largeFontSize; + public GuiBooklet(GuiScreen previousScreen, GuiBookletBase parentPage){ this.previousScreen = previousScreen; this.parentPage = parentPage; @@ -68,6 +73,19 @@ 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; + } + if(this.hasPageLeftButton()){ List hoverText = Arrays.asList(TextFormatting.GOLD+"Previous Page", TextFormatting.ITALIC+"Or scroll up"); this.buttonLeft = new TexturedButton(RES_LOC_GADGETS, -2000, this.guiLeft-12, this.guiTop+this.ySize-8, 18, 54, 18, 10, hoverText); @@ -247,6 +265,21 @@ public abstract class GuiBooklet extends GuiBookletBase{ return true; } + @Override + public float getSmallFontSize(){ + return this.smallFontSize; + } + + @Override + public float getMediumFontSize(){ + return this.mediumFontSize; + } + + @Override + public float getLargeFontSize(){ + return this.largeFontSize; + } + public void onSearchBarChanged(String searchBarText){ GuiBookletBase parent = !(this instanceof GuiEntry) ? this : this.parentPage; this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, parent, ActuallyAdditionsAPI.allAndSearch, 0, searchBarText, true)); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java index 865be4d18..eabef9a7a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java @@ -71,7 +71,7 @@ public class GuiEntry extends GuiBooklet{ for(int i = 0; i < 2; i++){ String pageStrg = "Page "+(this.entryPage*2+i+1)+"/"+this.pageAmount*2; - this.renderScaledAsciiString(pageStrg, this.guiLeft+25+i*136, this.guiTop+this.ySize-7, 0xFFFFFF, false, 0.8F); + this.renderScaledAsciiString(pageStrg, this.guiLeft+25+i*136, this.guiTop+this.ySize-7, 0xFFFFFF, false, this.getLargeFontSize()); } } @@ -92,7 +92,7 @@ public class GuiEntry extends GuiBooklet{ int id = y+x*BUTTONS_PER_PAGE; if(this.chapters.size() > id+idOffset){ IBookletChapter chapter = this.chapters.get(id+idOffset); - this.buttonList.add(new EntryButton(id, this.guiLeft+14+x*142, this.guiTop+11+y*13, 115, 10, chapter.getLocalizedNameWithFormatting(), chapter.getDisplayItemStack())); + this.buttonList.add(new EntryButton(this, id, this.guiLeft+14+x*142, this.guiTop+11+y*13, 115, 10, chapter.getLocalizedNameWithFormatting(), chapter.getDisplayItemStack())); } else{ return; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java index beca9c099..6ea035ab3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java @@ -125,7 +125,7 @@ public class GuiMainPage extends GuiBooklet{ for(int i = 0; i < BUTTONS_PER_PAGE; i++){ if(ActuallyAdditionsAPI.BOOKLET_ENTRIES.size() > i){ IBookletEntry entry = ActuallyAdditionsAPI.BOOKLET_ENTRIES.get(i); - this.buttonList.add(new EntryButton(i, this.guiLeft+156, this.guiTop+11+i*13, 115, 10, "- "+entry.getLocalizedNameWithFormatting(), null)); + this.buttonList.add(new EntryButton(this, i, this.guiLeft+156, this.guiTop+11+i*13, 115, 10, "- "+entry.getLocalizedNameWithFormatting(), null)); } else{ return; @@ -230,15 +230,15 @@ public class GuiMainPage extends GuiBooklet{ if(this.showTutorial){ String text = TextFormatting.BLUE+"It looks like this is the first time you are using this manual. \nIf you click the button below, some useful bookmarks will be stored at the bottom of the GUI. You should definitely check them out to get started with "+ModUtil.NAME+"! \nIf you don't want this, shift-click the button."; - this.renderSplitScaledAsciiString(text, this.guiLeft+11, this.guiTop+55, 0, false, 0.75F, 120); + this.renderSplitScaledAsciiString(text, this.guiLeft+11, this.guiTop+55, 0, false, this.getMediumFontSize(), 120); } else if(this.quote != null && !this.quote.isEmpty() && this.quoteGuy != null){ int quoteSize = this.quote.size(); for(int i = 0; i < quoteSize; i++){ - this.renderScaledAsciiString(TextFormatting.ITALIC+this.quote.get(i), this.guiLeft+25, this.guiTop+90+(i*8), 0, false, 0.75F); + this.renderScaledAsciiString(TextFormatting.ITALIC+this.quote.get(i), this.guiLeft+25, this.guiTop+90+(i*8), 0, false, this.getMediumFontSize()); } - this.renderScaledAsciiString("- "+this.quoteGuy, this.guiLeft+60, this.guiTop+93+quoteSize*8, 0, false, 0.8F); + this.renderScaledAsciiString("- "+this.quoteGuy, this.guiLeft+60, this.guiTop+93+quoteSize*8, 0, false, this.getLargeFontSize()); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java index a67ba795f..5ba55457a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java @@ -174,7 +174,7 @@ public class GuiPage extends GuiBooklet{ if(page != null){ IBookletChapter chapter = this.pages[i].getChapter(); String pageStrg = "Page "+(chapter.getPageIndex(this.pages[i])+1)+"/"+chapter.getAllPages().length; - this.renderScaledAsciiString(pageStrg, this.guiLeft+25+i*136, this.guiTop+this.ySize-7, 0xFFFFFF, false, 0.8F); + this.renderScaledAsciiString(pageStrg, this.guiLeft+25+i*136, this.guiTop+this.ySize-7, 0xFFFFFF, false, this.getLargeFontSize()); GlStateManager.color(1F, 1F, 1F); page.drawScreenPre(this, this.guiLeft+6+i*142, this.guiTop+7, mouseX, mouseY, partialTicks); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeMachine.java index 975a4b133..ce1cd2599 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeMachine.java @@ -41,8 +41,8 @@ public class PageCoffeeMachine extends BookletPage{ gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); GuiUtils.drawTexturedModalRect(startX+5, startY+10, 0, 74, 117, 72, 0); - gui.renderScaledAsciiString("(Coffee Maker Recipe)", startX+6, startY+78, 0, false, 0.65F); - gui.renderSplitScaledAsciiString("Hover over this to see the effect!", startX+5, startY+51, 0, false, 0.5F, 35); + gui.renderScaledAsciiString("(Coffee Maker Recipe)", startX+6, startY+78, 0, false, gui.getMediumFontSize()); + gui.renderSplitScaledAsciiString("Hover over this to see the effect!", startX+5, startY+51, 0, false, gui.getSmallFontSize(), 35); PageTextOnly.renderTextToPage(gui, this, startX+6, startY+90); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java index 665614e8f..0fea2d4f0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java @@ -68,7 +68,7 @@ public class PageCrafting extends BookletPage{ gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); GuiUtils.drawTexturedModalRect(startX+5, startY+6, 20, 0, 116, 54, 0); - gui.renderScaledAsciiString("("+StringUtil.localize(this.recipeTypeLocKey)+")", startX+6, startY+65, 0, false, 0.65F); + gui.renderScaledAsciiString("("+StringUtil.localize(this.recipeTypeLocKey)+")", startX+6, startY+65, 0, false, gui.getMediumFontSize()); PageTextOnly.renderTextToPage(gui, this, startX+6, startY+80); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java index b22dc57be..3afd57621 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java @@ -35,7 +35,7 @@ public class PageCrusherRecipe extends BookletPage{ gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); GuiUtils.drawTexturedModalRect(startX+38, startY+6, 136, 0, 52, 74, 0); - gui.renderScaledAsciiString("(Crusher Recipe)", startX+36, startY+85, 0, false, 0.65F); + gui.renderScaledAsciiString("(Crusher Recipe)", startX+36, startY+85, 0, false, gui.getMediumFontSize()); PageTextOnly.renderTextToPage(gui, this, startX+6, startY+100); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageEmpowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageEmpowerer.java index f2b045fe4..84e37e6a4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageEmpowerer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageEmpowerer.java @@ -34,7 +34,7 @@ public class PageEmpowerer extends BookletPage{ gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); GuiUtils.drawTexturedModalRect(startX+5, startY+10, 117, 74, 116, 72, 0); - gui.renderScaledAsciiString("(Empowerer Recipe)", startX+6, startY+85, 0, false, 0.65F); + gui.renderScaledAsciiString("(Empowerer Recipe)", startX+6, startY+85, 0, false, gui.getMediumFontSize()); PageTextOnly.renderTextToPage(gui, this, startX+6, startY+100); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java index 65009e410..0e37157b9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java @@ -50,7 +50,7 @@ public class PageFurnace extends BookletPage{ gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); GuiUtils.drawTexturedModalRect(startX+23, startY+10, 0, 146, 80, 26, 0); - gui.renderScaledAsciiString("(Furnace Recipe)", startX+32, startY+42, 0, false, 0.65F); + gui.renderScaledAsciiString("(Furnace Recipe)", startX+32, startY+42, 0, false, gui.getMediumFontSize()); PageTextOnly.renderTextToPage(gui, this, startX+6, startY+57); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java index 9926f7d91..336a1bb38 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java @@ -34,7 +34,7 @@ public class PageReconstructor extends BookletPage{ gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); GuiUtils.drawTexturedModalRect(startX+30, startY+10, 80, 146, 68, 48, 0); - gui.renderScaledAsciiString("(Atomic Reconstructor Recipe)", startX+12, startY+63, 0, false, 0.65F); + gui.renderScaledAsciiString("(Atomic Reconstructor Recipe)", startX+12, startY+63, 0, false, gui.getMediumFontSize()); PageTextOnly.renderTextToPage(gui, this, startX+6, startY+88); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java index d12216dc7..021ebea1f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java @@ -28,7 +28,7 @@ public class PageTextOnly extends BookletPage{ public static void renderTextToPage(GuiBookletBase gui, BookletPage page, int x, int y){ String text = page.getInfoText(); if(text != null && !text.isEmpty()){ - gui.renderSplitScaledAsciiString(text, x, y, 0, false, 0.75F, 120); + gui.renderSplitScaledAsciiString(text, x, y, 0, false, gui.getMediumFontSize(), 120); } } diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 6843e989f..d803d38b9 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -751,8 +751,8 @@ achievement.actuallyadditions.getUnProbed.desc=Be probed by someone but sneak an #Booklet Recipe Names booklet.actuallyadditions.shapelessRecipe=Shapeless Recipe booklet.actuallyadditions.shapedRecipe=Shaped Recipe -booklet.actuallyadditions.shapelessOreRecipe=Shapeless OreDictionary Recipe -booklet.actuallyadditions.shapedOreRecipe=Shaped OreDictionary Recipe +booklet.actuallyadditions.shapelessOreRecipe=Shapeless OreDict Recipe +booklet.actuallyadditions.shapedOreRecipe=Shaped OreDict Recipe #Booklet Entries booklet.actuallyadditions.indexEntry.gettingStarted.name=Getting Started @@ -768,6 +768,11 @@ booklet.actuallyadditions.indexEntry.reconstruction.name=Reconstruction booklet.actuallyadditions.indexEntry.laserRelays.name=Laser Transport booklet.actuallyadditions.indexEntry.updatesAndInfos.name=Updates and Infos +#Booklet Font Size +booklet.actuallyadditions.fontSize.small=0.5 +booklet.actuallyadditions.fontSize.medium=0.75 +booklet.actuallyadditions.fontSize.large=0.8 + #Booklet Info booklet.actuallyadditions.recipeDisabled=The crafting recipe for this item is disabled in the Config File! If you're on a server, ask the server author to enable it in the config. If you're on a client, press the 'Open Config'-Button on the top right and enable the recipe! booklet.actuallyadditions.unavailable=Parts of this feature are currently disabled or incomplete due to the not fully complete 1.8.9 and 1.9 Port. You may experience something that's missing or doesn't fully work. Please use this item with caution!