Added a notification to the lexicon's main page when the mod updates to let you know things have changed and not to panic if something doesn't work as it used to.

This commit is contained in:
Vasco Lavos committed 2015-08-25 19:00:03 +01:00
1 parent 70ebd4c7ab
commit e4f349ca0c
6 files changed
+119 -8

No files matched your search

@@ -24,19 +24,22 @@ import vazkii.botania.client.challenge.ModChallenges;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
import vazkii.botania.client.gui.lexicon.GuiLexiconEntry;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibMisc;
public final class PresistantVariableHelper {
private static final String TAG_FIRST_LOAD = "firstLoad";
private static final String TAG_BOOKMARK_COUNT = "bookmarkCount";
private static final String TAG_BOOKMARK_PREFIX = "bookmark";
private static final String TAG_BOOKMARKS = "bookmarks";
private static final String TAG_CHALLENGES = "challenges";
private static final String TAG_LEXICON_NOTES = "lexiconNotes";
private static final String TAG_FIRST_LOAD = "firstLoad";
private static final String TAG_LAST_BOTANIA_VERSION = "lastBotaniaVersion";
private static File cacheFile;
public static boolean firstLoad = true;
public static String lastBotaniaVersion = "";
public static void save() throws IOException {
NBTTagCompound cmp = new NBTTagCompound();
@@ -67,6 +70,7 @@ public final class PresistantVariableHelper {
cmp.setTag(TAG_LEXICON_NOTES, notesCmp);
cmp.setBoolean(TAG_FIRST_LOAD, firstLoad);
cmp.setString(TAG_LAST_BOTANIA_VERSION, lastBotaniaVersion);
injectNBTToFile(cmp, getCacheFile());
}
@@ -99,10 +103,14 @@ public final class PresistantVariableHelper {
for(String key : keys)
GuiLexicon.notes.put(key, notesCmp.getString(key));
}
lastBotaniaVersion = cmp.hasKey(TAG_LAST_BOTANIA_VERSION) ? cmp.getString(TAG_LAST_BOTANIA_VERSION) : "(N/A)";
firstLoad = cmp.hasKey(TAG_FIRST_LOAD) ? cmp.getBoolean(TAG_FIRST_LOAD) : firstLoad;
if(firstLoad)
if(firstLoad) {
GuiLexicon.currentOpenLexicon = new GuiLexiconEntry(LexiconData.welcome, new GuiLexicon());
lastBotaniaVersion = LibMisc.VERSION;
}
}
public static void saveSafe() {
@@ -207,6 +207,7 @@ public class ClientProxy extends CommonProxy {
try {
PresistantVariableHelper.load();
PresistantVariableHelper.save();
} catch (IOException e) {
FMLLog.severe("Botania's Presistant Variables couldn't load!");
e.printStackTrace();
@@ -10,6 +10,10 @@
*/
package vazkii.botania.client.gui.lexicon;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
@@ -51,11 +55,13 @@ 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.GuiButtonUpdateWarning;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.handler.SheddingHandler;
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;
public class GuiLexicon extends GuiScreen {
@@ -157,6 +163,13 @@ public class GuiLexicon extends GuiScreen {
buttonList.add(new GuiButtonOptions(-1, left - 6, top + 13));
buttonList.add(new GuiButtonAchievement(-2, left - 6, top + 26));
buttonList.add(new GuiButtonChallenges(-3, left - 6, top + 40));
GuiButtonUpdateWarning button = new GuiButtonUpdateWarning(-4, left - 6, top + 60);
buttonList.add(button);
if(PresistantVariableHelper.lastBotaniaVersion.equals(LibMisc.VERSION)) {
button.enabled = false;
button.visible = false;
}
}
buttonList.add(new GuiButtonNotes(this, NOTES_BUTTON_ID, left - 4, top - 4));
}
@@ -207,7 +220,7 @@ public class GuiLexicon extends GuiScreen {
GL11.glColor4f(1F, 1F, 1F, 1F);
mc.renderEngine.bindTexture(texture);
drawTexturedModalRect(left - 19, top + 42, 67, 180, 19, 26);
if(par1 >= left - 19 && par1 < left && par2 >= top + 42 && par2 < top + 68) {
if(par1 >= left - 19 && par1 < left && par2 >= top + 62 && par2 < top + 88) {
mc.renderEngine.bindTexture(textureToff);
GL11.glPushMatrix();
GL11.glScalef(0.5F, 0.5F, 0.5F);
@@ -325,14 +338,36 @@ public class GuiLexicon extends GuiScreen {
mc.displayGuiScreen(new GuiLexiconIndex(category));
ClientTickHandler.notifyPageChange();
} else if(par1GuiButton.id == -1)
} else switch(par1GuiButton.id) {
case -1 :
mc.displayGuiScreen(new GuiBotaniaConfig(this));
else if(par1GuiButton.id == -2)
break;
case -2 :
mc.displayGuiScreen(new GuiAchievementsHacky(this, mc.thePlayer.getStatFileWriter()));
else if(par1GuiButton.id == -3)
break;
case -3 :
mc.displayGuiScreen(new GuiLexiconChallengesList());
else if(par1GuiButton.id == NOTES_BUTTON_ID)
break;
case -4 :
if(isShiftKeyDown()) {
try {
if(Desktop.isDesktopSupported())
Desktop.getDesktop().browse(new URI("http://botaniamod.net/changelog.php#" + PresistantVariableHelper.lastBotaniaVersion.replaceAll("\\.|\\s", "-")));
} catch (Exception e) {
e.printStackTrace();
}
} else {
PresistantVariableHelper.lastBotaniaVersion = LibMisc.VERSION;
PresistantVariableHelper.saveSafe();
par1GuiButton.visible = false;
par1GuiButton.enabled = false;
}
break;
case NOTES_BUTTON_ID :
notesEnabled = !notesEnabled;
break;
}
}
public void handleBookmark(GuiButton par1GuiButton) {
@@ -0,0 +1,61 @@
/**
* 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 @ [Aug 25, 2015, 6:13:11 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.handler.PresistantVariableHelper;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
public class GuiButtonUpdateWarning extends GuiButtonLexicon {
public GuiButtonUpdateWarning(int id, int x, int y) {
super(id, x, y, 11, 11, "");
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
if(!visible || !enabled)
return;
field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(field_146123_n);
boolean red = k == 2 || ClientTickHandler.ticksInGame % 10 < 5;
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
GL11.glColor4f(1F, 1F, 1F, 1F);
drawTexturedModalRect(xPosition, yPosition, red ? 153 : 142, 180, 11, 11);
List<String> tooltip = new ArrayList();
String version = PresistantVariableHelper.lastBotaniaVersion;
for(int i = 0; i < 6; i++) {
tooltip.add(EnumChatFormatting.GRAY + String.format(StatCollector.translateToLocal("botaniamisc.changes" + i), version).replaceAll("&", "\u00a7"));
if(i == 3)
tooltip.add("");
}
int tooltipY = (tooltip.size() - 1) * 10 - 25;
if(k == 2)
RenderHelper.renderTooltip(par2 - 125, par3 + tooltipY, tooltip);
}
}
@@ -136,6 +136,12 @@ botaniamisc.showNotes=Show Notes
botaniamisc.notes=Notes
botaniamisc.pay2win=Upgrade your Mana Pool to infuse this item
botaniamisc.justDoIt=DO IT
botaniamisc.changes0=&aBotania&7 has changed since you last used it in this instance!
botaniamisc.changes1=The last version of &aBotania&7 you used was &b%s&7.
botaniamisc.changes2=Things change, don't panic. If something seems off, read the entry again.
botaniamisc.changes3=&oEveryone is afraid of change, yet change is the force that moves us forward.
botaniamisc.changes4=&fShift-Left Click&7 to read the changes since then
botaniamisc.changes5=&fLeft Click&7 to dismiss this
# NEI INTEGRATION
botania.nei.brewery=Botanical Brewery
Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB