Added an achievement button to the lexicon main page.

This commit is contained in:
Lizbeth Rika committed 2015-04-03 18:13:54 +01:00
1 parent b1cbdeffc7
commit fd7dc29fe1
6 files changed
+97 -4

No files matched your search

@@ -0,0 +1,36 @@
/**
* 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 @ [Apr 3, 2015, 5:55:36 PM (GMT)]
*/
package vazkii.botania.client.gui;
import cpw.mods.fml.relauncher.ReflectionHelper;
import vazkii.botania.common.achievement.ModAchievements;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiOptionButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.achievement.GuiAchievements;
import net.minecraft.client.resources.I18n;
import net.minecraft.stats.StatFileWriter;
import net.minecraftforge.common.AchievementPage;
public class GuiAchievementsHacky extends GuiAchievements {
public GuiAchievementsHacky(GuiScreen p_i45026_1_, StatFileWriter p_i45026_2_) {
super(p_i45026_1_, p_i45026_2_);
}
@Override
public void initGui() {
super.initGui();
ReflectionHelper.setPrivateValue(GuiAchievements.class, this, ModAchievements.pageIndex, "currentPage");
((GuiButton) buttonList.get(1)).displayString = ModAchievements.botaniaPage.getName();
}
}
@@ -22,6 +22,7 @@ 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.achievement.GuiAchievements;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
@@ -35,7 +36,9 @@ import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.core.proxy.ClientProxy;
import vazkii.botania.client.gui.GuiAchievementsHacky;
import vazkii.botania.client.gui.GuiBotaniaConfig;
import vazkii.botania.client.gui.lexicon.button.GuiButtonAchievement;
import vazkii.botania.client.gui.lexicon.button.GuiButtonBookmark;
import vazkii.botania.client.gui.lexicon.button.GuiButtonCategory;
import vazkii.botania.client.gui.lexicon.button.GuiButtonHistory;
@@ -123,9 +126,10 @@ public class GuiLexicon extends GuiScreen {
}
}
populateBookmarks();
if(isMainPage())
buttonList.add(new GuiButtonOptions(-1, left, top));
if(isMainPage()) {
buttonList.add(new GuiButtonOptions(-1, left - 6, top + 5));
buttonList.add(new GuiButtonAchievement(-2, left - 6, top + 18));
}
}
@Override
@@ -246,6 +250,8 @@ public class GuiLexicon extends GuiScreen {
ClientTickHandler.notifyPageChange();
} else if(par1GuiButton.id == -1)
mc.displayGuiScreen(new GuiBotaniaConfig(this));
else if(par1GuiButton.id == -2)
mc.displayGuiScreen(new GuiAchievementsHacky(this, mc.thePlayer.getStatFileWriter()));
}
public void handleBookmark(GuiButton par1GuiButton) {
@@ -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 @ [Apr 3, 2015, 5:44:36 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.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
public class GuiButtonAchievement extends GuiButtonLexicon {
public GuiButtonAchievement(int id, int x, int y) {
super(id, x, y, 11, 11, "");
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(field_146123_n);
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
GL11.glColor4f(1F, 1F, 1F, 1F);
drawTexturedModalRect(xPosition, yPosition, k == 2 ? 110 : 99, 191, 11, 11);
List<String> tooltip = new ArrayList();
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("botaniamisc.achievements"));
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip);
}
}
@@ -25,7 +25,8 @@ import cpw.mods.fml.common.FMLCommonHandler;
public final class ModAchievements {
public static AchievementPage botaniaPage;
public static int pageIndex;
public static Achievement flowerPickup;
public static Achievement lexiconUse;
public static Achievement daybloomPickup;
@@ -115,6 +116,7 @@ public final class ModAchievements {
desu.setStackDisplayName("desu gun");
desuGun = new AchievementMod(LibAchievementNames.DESU_GUN, -8, -2, desu, null).setSpecial();
pageIndex = AchievementPage.getAchievementPages().size();
botaniaPage = new AchievementPage(LibMisc.MOD_NAME, AchievementMod.achievements.toArray(new Achievement[AchievementMod.achievements.size()]));
AchievementPage.registerAchievementPage(botaniaPage);
@@ -109,6 +109,7 @@ botaniamisc.clickToAddWarp=Right click to bind to this position
botaniamisc.hasKeepIvy=Has Resolute Ivy
botaniamisc.active=&aActive
botaniamisc.inactive=&cInactive
botaniamisc.achievements=Botania Achievements
# NEI INTEGRATION
botania.nei.brewery=Botanical Brewery
Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 64 KiB