Change main page layout and add a button to change the gui scale

This commit is contained in:
Vasco Lavos committed 2016-09-12 04:03:21 +01:00
1 parent 4d4bd7efc4
commit 8928fda9a9
8 files changed
+131 -32

No files matched your search

@@ -34,12 +34,14 @@ public final class PersistentVariableHelper {
private static final String TAG_CHALLENGES = "challenges";
private static final String TAG_LEXICON_NOTES = "lexiconNotes";
private static final String TAG_LAST_BOTANIA_VERSION = "lastBotaniaVersion";
private static final String TAG_LEXICON_GUI_SCALE = "lexiconGuiScale";
private static File cacheFile;
public static boolean firstLoad = true;
public static boolean dog = true;
public static String lastBotaniaVersion = "";
public static int lexiconGuiScale = 0;
public static void save() throws IOException {
NBTTagCompound cmp = new NBTTagCompound();
@@ -72,7 +74,8 @@ public final class PersistentVariableHelper {
cmp.setBoolean(TAG_FIRST_LOAD, firstLoad);
cmp.setBoolean(TAG_DOG, dog);
cmp.setString(TAG_LAST_BOTANIA_VERSION, lastBotaniaVersion);
cmp.setInteger(TAG_LEXICON_GUI_SCALE, lexiconGuiScale);
injectNBTToFile(cmp, getCacheFile());
}
@@ -114,6 +117,7 @@ public final class PersistentVariableHelper {
lastBotaniaVersion = LibMisc.VERSION;
dog = cmp.getBoolean(TAG_DOG);
lexiconGuiScale = cmp.getInteger(TAG_LEXICON_GUI_SCALE);
}
public static void saveSafe() {
@@ -10,11 +10,30 @@
*/
package vazkii.botania.client.gui.lexicon;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
@@ -23,8 +42,6 @@ import net.minecraft.util.ChatAllowedCharacters;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.MinecraftForge;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.BotaniaTutorialStartEvent;
import vazkii.botania.api.lexicon.LexiconCategory;
@@ -46,28 +63,14 @@ import vazkii.botania.client.gui.lexicon.button.GuiButtonHistory;
import vazkii.botania.client.gui.lexicon.button.GuiButtonInvisible;
import vazkii.botania.client.gui.lexicon.button.GuiButtonNotes;
import vazkii.botania.client.gui.lexicon.button.GuiButtonOptions;
import vazkii.botania.client.gui.lexicon.button.GuiButtonScaleChange;
import vazkii.botania.client.gui.lexicon.button.GuiButtonUpdateWarning;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.item.ItemLexicon;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lexicon.page.PageText;
import vazkii.botania.common.lib.LibMisc;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
public class GuiLexicon extends GuiScreen {
public static GuiLexicon currentOpenLexicon = new GuiLexicon();
@@ -106,7 +109,7 @@ public class GuiLexicon extends GuiScreen {
static int notesMoveTime;
public String note = "";
public String categoryHighlight = "";
List<LexiconCategory> allCategories;
String title;
@@ -133,6 +136,16 @@ public class GuiLexicon extends GuiScreen {
}
public void onInitGui() {
ScaledResolution res = new ScaledResolution(mc);
int guiScale = mc.gameSettings.guiScale;
if(PersistentVariableHelper.lexiconGuiScale > 0) {
mc.gameSettings.guiScale = PersistentVariableHelper.lexiconGuiScale;
res = new ScaledResolution(mc);
width = res.getScaledWidth();
height = res.getScaledHeight();
mc.gameSettings.guiScale = guiScale;
}
allCategories = new ArrayList<>(BotaniaAPI.getAllCategories());
Collections.sort(allCategories);
@@ -168,13 +181,14 @@ public class GuiLexicon extends GuiScreen {
}
populateBookmarks();
if(isMainPage()) {
buttonList.add(new GuiButtonOptions(-1, left - 6, top + guiHeight - 54));
buttonList.add(new GuiButtonAchievement(-2, left - 6, top + guiHeight - 40));
buttonList.add(new GuiButtonChallenges(-3, left - 6, top + guiHeight - 25));
GuiButtonUpdateWarning button = new GuiButtonUpdateWarning(-4, left - 6, top + guiHeight - 70);
buttonList.add(new GuiButtonOptions(-1, left + 20, top + guiHeight - 25));
buttonList.add(new GuiButtonAchievement(-2, left + 33, top + guiHeight - 25));
buttonList.add(new GuiButtonChallenges(-3, left + 45, top + guiHeight - 25));
buttonList.add(new GuiButtonScaleChange(-4, left + 57, top + guiHeight - 25));
GuiButtonUpdateWarning button = new GuiButtonUpdateWarning(-98, left - 6, top + guiHeight - 70);
buttonList.add(button);
if(PersistentVariableHelper.lastBotaniaVersion.equals(LibMisc.VERSION)) {
button.enabled = false;
button.visible = false;
@@ -199,6 +213,20 @@ public class GuiLexicon extends GuiScreen {
@Override
public void drawScreen(int par1, int par2, float par3) {
ScaledResolution res = new ScaledResolution(mc);
int guiScale = mc.gameSettings.guiScale;
if(PersistentVariableHelper.lexiconGuiScale > 0) {
mc.gameSettings.guiScale = PersistentVariableHelper.lexiconGuiScale;
float s = (float) PersistentVariableHelper.lexiconGuiScale / (float) res.getScaleFactor();
GlStateManager.scale(s, s, s);
res = new ScaledResolution(this.mc);
int sw = res.getScaledWidth();
int sh = res.getScaledHeight();
par1 = Mouse.getX() * sw / mc.displayWidth;
par2 = sh - Mouse.getY() * sh / mc.displayHeight - 1;
}
float time = ClientTickHandler.ticksInGame + par3;
timeDelta = time - lastTime;
lastTime = time;
@@ -264,6 +292,8 @@ public class GuiLexicon extends GuiScreen {
drawTexturedModalRect(tutorialArrowX, tutorialArrowY, 20, 200, TUTORIAL_ARROW_WIDTH, TUTORIAL_ARROW_HEIGHT);
GlStateManager.disableBlend();
}
mc.gameSettings.guiScale = guiScale;
}
public void drawNotes(float part) {
@@ -379,7 +409,23 @@ public class GuiLexicon extends GuiScreen {
case -3 :
mc.displayGuiScreen(new GuiLexiconChallengesList());
break;
case -4 :
case -4:
switch(PersistentVariableHelper.lexiconGuiScale) {
case 3:
PersistentVariableHelper.lexiconGuiScale = 4;
break;
case 4:
PersistentVariableHelper.lexiconGuiScale = 2;
break;
default:
PersistentVariableHelper.lexiconGuiScale = 3;
break;
}
PersistentVariableHelper.saveSafe();
mc.displayGuiScreen(new GuiLexicon());
break;
case -98 :
if(isShiftKeyDown()) {
try {
if(Desktop.isDesktopSupported())
@@ -518,6 +564,7 @@ public class GuiLexicon extends GuiScreen {
public static void startTutorial() {
tutorial.clear();
// TODO verify tutorial after changes
tutorial.add(LexiconData.lexicon);
tutorial.add(LexiconData.flowers);
@@ -37,7 +37,7 @@ public class GuiButtonAchievement extends GuiButtonLexicon {
drawTexturedModalRect(xPosition, yPosition, k == 2 ? 109 : 98, 191, 11, 11);
List<String> tooltip = new ArrayList<>();
tooltip.add(TextFormatting.YELLOW + I18n.format("botaniamisc.achievements"));
tooltip.add(TextFormatting.GREEN + I18n.format("botaniamisc.achievements"));
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
@@ -37,7 +37,7 @@ public class GuiButtonChallenges extends GuiButtonLexicon {
drawTexturedModalRect(xPosition, yPosition, k == 2 ? 131 : 120, 180, 11, 11);
List<String> tooltip = new ArrayList();
tooltip.add(TextFormatting.YELLOW + I18n.format("botaniamisc.challenges"));
tooltip.add(TextFormatting.GREEN + I18n.format("botaniamisc.challenges"));
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
@@ -38,11 +38,10 @@ public class GuiButtonOptions extends GuiButtonLexicon {
List<String> tooltip = new ArrayList<>();
for(int i = 0; i < 3; i++)
tooltip.add((i == 0 ? TextFormatting.RED : TextFormatting.GRAY) + I18n.format("botaniamisc.lexiconOptions" + i));
tooltip.add((i == 0 ? TextFormatting.GREEN : TextFormatting.GRAY) + I18n.format("botaniamisc.lexiconOptions" + i));
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip);
RenderHelper.renderTooltip(par2, par3, tooltip);
}
}
@@ -0,0 +1,48 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [12/09/2016, 03:17:42 (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
public class GuiButtonScaleChange extends GuiButtonLexicon {
public GuiButtonScaleChange(int id, int x, int y) {
super(id, x, y, 11, 11, "");
}
@Override
public void drawButton(@Nonnull Minecraft par1Minecraft, int par2, int par3) {
hovered = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(hovered);
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
GlStateManager.color(1F, 1F, 1F, 1F);
drawTexturedModalRect(xPosition, yPosition, k == 2 ? 152 : 141, 191, 11, 11);
List<String> tooltip = new ArrayList<>();
tooltip.add(TextFormatting.GREEN + I18n.format("botaniamisc.scaleChange"));
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip);
}
}
@@ -158,6 +158,7 @@ botaniamisc.altarRefill0=Right click with an empty hand to
botaniamisc.altarRefill1=add back the last recipe
botaniamisc.santaweaveInfo=Manaweave, changed up for the &cs&fe&ca&fs&co&fn
botaniamisc.enterToView=^ Press ENTER to view ^
botaniamisc.scaleChange=Change Scale
# NEI INTEGRATION
botania.nei.brewery=Botanical Brewery
@@ -3725,7 +3726,7 @@ botania.page.blazeBlock1=0x1a4
# -- CHALLENGES
botania.entry.challenges=Challenges
botania.tagline.challenges=Challenge yourself
botania.page.challenges0=&1Challenges&0 are available in the &1Lexica Botania&0 by clicking the icon on the left of the landing page shaped like a cup. These, as the name says, challenge the player to create a mechanism using the features only available in &1Botania&0 and &1Minecraft&0 itself.<br>Of course, you can use items from other mods to complete them, but that's no fun.
botania.page.challenges0=&1Challenges&0 are available in the &1Lexica Botania&0 by clicking the icon on the bottom of the landing page shaped like a cup. These, as the name says, challenge the player to create a mechanism using the features only available in &1Botania&0 and &1Minecraft&0 itself.<br>Of course, you can use items from other mods to complete them, but that's no fun.
botania.page.challenges1=All of the challenges are possible, of course. They just require some thinking and knowledge of the ins and outs of redstone and the &1Botania&0 mechanics themselves.<br>It's highly recommended that they're done without using features from external mods, as they have been created with that in mind, and aren't really challenges if you put down a block that solves them instantly.
botania.page.challenges2=The challenges aren't obligatory in any way, and do not provide any material reward. They're purely suggestions as to what &1Botania&0 can do, automation wise, and are but scratching the surface of that topic. Challenges need be marked completed manually.<br>It should be kept in mind that the boundaries of this world are one's imagination, so don't stop at the ideas in there!
Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 69 KiB