You can now change the booklet's font size in the lang file

Closes #461
This commit is contained in:
Ellpeck 2016-12-07 15:25:04 +01:00
parent b0d3ee66a2
commit 91dc0f4ce1
14 changed files with 68 additions and 20 deletions

View file

@ -33,4 +33,10 @@ public abstract class GuiBookletBase extends GuiScreen{
public abstract int getSizeY(); public abstract int getSizeY();
public abstract void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer); 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();
} }

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.booklet.button; 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.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
@ -23,10 +25,12 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class EntryButton extends GuiButton{ 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); super(id, x, y, width, height, text);
this.gui = gui;
this.stackToRender = stackToRender; this.stackToRender = stackToRender;
} }
@ -48,7 +52,7 @@ public class EntryButton extends GuiButton{
textOffsetX = 10; textOffsetX = 10;
} }
float scale = 0.75F; float scale = this.gui.getMediumFontSize();
if(this.hovered){ if(this.hovered){
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();

View file

@ -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.inventory.gui.TexturedButton;
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
@ -53,6 +54,10 @@ public abstract class GuiBooklet extends GuiBookletBase{
private GuiButton buttonRight; private GuiButton buttonRight;
private GuiButton buttonBack; private GuiButton buttonBack;
private float smallFontSize;
private float mediumFontSize;
private float largeFontSize;
public GuiBooklet(GuiScreen previousScreen, GuiBookletBase parentPage){ public GuiBooklet(GuiScreen previousScreen, GuiBookletBase parentPage){
this.previousScreen = previousScreen; this.previousScreen = previousScreen;
this.parentPage = parentPage; this.parentPage = parentPage;
@ -68,6 +73,19 @@ public abstract class GuiBooklet extends GuiBookletBase{
this.guiLeft = (this.width-this.xSize)/2; this.guiLeft = (this.width-this.xSize)/2;
this.guiTop = (this.height-this.ySize)/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()){ if(this.hasPageLeftButton()){
List<String> hoverText = Arrays.asList(TextFormatting.GOLD+"Previous Page", TextFormatting.ITALIC+"Or scroll up"); List<String> 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); 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; 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){ public void onSearchBarChanged(String searchBarText){
GuiBookletBase parent = !(this instanceof GuiEntry) ? this : this.parentPage; GuiBookletBase parent = !(this instanceof GuiEntry) ? this : this.parentPage;
this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, parent, ActuallyAdditionsAPI.allAndSearch, 0, searchBarText, true)); this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, parent, ActuallyAdditionsAPI.allAndSearch, 0, searchBarText, true));

View file

@ -71,7 +71,7 @@ public class GuiEntry extends GuiBooklet{
for(int i = 0; i < 2; i++){ for(int i = 0; i < 2; i++){
String pageStrg = "Page "+(this.entryPage*2+i+1)+"/"+this.pageAmount*2; 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; int id = y+x*BUTTONS_PER_PAGE;
if(this.chapters.size() > id+idOffset){ if(this.chapters.size() > id+idOffset){
IBookletChapter chapter = this.chapters.get(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{ else{
return; return;

View file

@ -125,7 +125,7 @@ public class GuiMainPage extends GuiBooklet{
for(int i = 0; i < BUTTONS_PER_PAGE; i++){ for(int i = 0; i < BUTTONS_PER_PAGE; i++){
if(ActuallyAdditionsAPI.BOOKLET_ENTRIES.size() > i){ if(ActuallyAdditionsAPI.BOOKLET_ENTRIES.size() > i){
IBookletEntry entry = ActuallyAdditionsAPI.BOOKLET_ENTRIES.get(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{ else{
return; return;
@ -230,15 +230,15 @@ public class GuiMainPage extends GuiBooklet{
if(this.showTutorial){ 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."; 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){ else if(this.quote != null && !this.quote.isEmpty() && this.quoteGuy != null){
int quoteSize = this.quote.size(); int quoteSize = this.quote.size();
for(int i = 0; i < quoteSize; i++){ 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());
} }
} }

View file

@ -174,7 +174,7 @@ public class GuiPage extends GuiBooklet{
if(page != null){ if(page != null){
IBookletChapter chapter = this.pages[i].getChapter(); IBookletChapter chapter = this.pages[i].getChapter();
String pageStrg = "Page "+(chapter.getPageIndex(this.pages[i])+1)+"/"+chapter.getAllPages().length; 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); GlStateManager.color(1F, 1F, 1F);
page.drawScreenPre(this, this.guiLeft+6+i*142, this.guiTop+7, mouseX, mouseY, partialTicks); page.drawScreenPre(this, this.guiLeft+6+i*142, this.guiTop+7, mouseX, mouseY, partialTicks);

View file

@ -41,8 +41,8 @@ public class PageCoffeeMachine extends BookletPage{
gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS);
GuiUtils.drawTexturedModalRect(startX+5, startY+10, 0, 74, 117, 72, 0); 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.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, 0.5F, 35); 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); PageTextOnly.renderTextToPage(gui, this, startX+6, startY+90);
} }

View file

@ -68,7 +68,7 @@ public class PageCrafting extends BookletPage{
gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS);
GuiUtils.drawTexturedModalRect(startX+5, startY+6, 20, 0, 116, 54, 0); 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); PageTextOnly.renderTextToPage(gui, this, startX+6, startY+80);
} }

View file

@ -35,7 +35,7 @@ public class PageCrusherRecipe extends BookletPage{
gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS);
GuiUtils.drawTexturedModalRect(startX+38, startY+6, 136, 0, 52, 74, 0); 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); PageTextOnly.renderTextToPage(gui, this, startX+6, startY+100);
} }

View file

@ -34,7 +34,7 @@ public class PageEmpowerer extends BookletPage{
gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS);
GuiUtils.drawTexturedModalRect(startX+5, startY+10, 117, 74, 116, 72, 0); 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); PageTextOnly.renderTextToPage(gui, this, startX+6, startY+100);
} }

View file

@ -50,7 +50,7 @@ public class PageFurnace extends BookletPage{
gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS);
GuiUtils.drawTexturedModalRect(startX+23, startY+10, 0, 146, 80, 26, 0); 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); PageTextOnly.renderTextToPage(gui, this, startX+6, startY+57);
} }

View file

@ -34,7 +34,7 @@ public class PageReconstructor extends BookletPage{
gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS);
GuiUtils.drawTexturedModalRect(startX+30, startY+10, 80, 146, 68, 48, 0); 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); PageTextOnly.renderTextToPage(gui, this, startX+6, startY+88);
} }

View file

@ -28,7 +28,7 @@ public class PageTextOnly extends BookletPage{
public static void renderTextToPage(GuiBookletBase gui, BookletPage page, int x, int y){ public static void renderTextToPage(GuiBookletBase gui, BookletPage page, int x, int y){
String text = page.getInfoText(); String text = page.getInfoText();
if(text != null && !text.isEmpty()){ 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);
} }
} }

View file

@ -751,8 +751,8 @@ achievement.actuallyadditions.getUnProbed.desc=Be probed by someone but sneak an
#Booklet Recipe Names #Booklet Recipe Names
booklet.actuallyadditions.shapelessRecipe=Shapeless Recipe booklet.actuallyadditions.shapelessRecipe=Shapeless Recipe
booklet.actuallyadditions.shapedRecipe=Shaped Recipe booklet.actuallyadditions.shapedRecipe=Shaped Recipe
booklet.actuallyadditions.shapelessOreRecipe=Shapeless OreDictionary Recipe booklet.actuallyadditions.shapelessOreRecipe=Shapeless OreDict Recipe
booklet.actuallyadditions.shapedOreRecipe=Shaped OreDictionary Recipe booklet.actuallyadditions.shapedOreRecipe=Shaped OreDict Recipe
#Booklet Entries #Booklet Entries
booklet.actuallyadditions.indexEntry.gettingStarted.name=Getting Started 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.laserRelays.name=Laser Transport
booklet.actuallyadditions.indexEntry.updatesAndInfos.name=Updates and Infos 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 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.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! 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!