mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Change main page layout and add a button to change the gui scale
This commit is contained in:
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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user