mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-16 10:34:40 +00:00
Actual work on getting the Lexicon GUI to show something.
This commit is contained in:
1 parent
31dc2dfe3c
commit
3c16be7de4
12 files changed
+171
-14
No files matched your search
@@ -31,6 +31,10 @@ public class LexiconEntry {
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
}
|
||||
|
||||
public String getUnlocalizedName() {
|
||||
return unlocalizedName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets what pages you want this entry to have.
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,7 @@ import vazkii.botania.api.internal.IGuiLexiconEntry;
|
||||
|
||||
public abstract class LexiconPage {
|
||||
|
||||
private final String unlocalizedName;
|
||||
public String unlocalizedName;
|
||||
|
||||
public LexiconPage(String unlocalizedName) {
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
|
||||
@@ -13,6 +13,7 @@ package vazkii.botania.client.gui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
@@ -39,8 +40,8 @@ public class GuiLexicon extends GuiScreen {
|
||||
left = width / 2 - guiWidth / 2;
|
||||
top = height / 2 - guiHeight / 2;
|
||||
|
||||
buttonList.clear();
|
||||
if(isIndex()) {
|
||||
buttonList.clear();
|
||||
int x = 18;
|
||||
for(int i = 0; i < 12; i++) {
|
||||
int y = 16 + i * 12;
|
||||
@@ -57,12 +58,26 @@ public class GuiLexicon extends GuiScreen {
|
||||
drawTexturedModalRect(left, top, 0, 0, guiWidth, guiHeight);
|
||||
drawCenteredString(fontRenderer, getTitle(), left + guiWidth / 2, top - 12, 0x00FF00);
|
||||
|
||||
drawHeader();
|
||||
|
||||
super.drawScreen(par1, par2, par3);
|
||||
}
|
||||
|
||||
void drawHeader() {
|
||||
boolean unicode = fontRenderer.getUnicodeFlag();
|
||||
fontRenderer.setUnicodeFlag(true);
|
||||
fontRenderer.drawSplitString(StatCollector.translateToLocal("botania.gui.lexicon.header"), left + 15, top + 20, 110, 0);
|
||||
fontRenderer.setUnicodeFlag(unicode);
|
||||
|
||||
super.drawScreen(par1, par2, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
int i = par1GuiButton.id - 3;
|
||||
List<LexiconCategory> categoryList = BotaniaAPI.getAllCategories();
|
||||
LexiconCategory category = i >= categoryList.size() ? null : categoryList.get(i);
|
||||
|
||||
if(category != null)
|
||||
mc.displayGuiScreen(new GuiLexiconIndex(category));
|
||||
}
|
||||
|
||||
String getTitle() {
|
||||
|
||||
@@ -11,11 +11,50 @@
|
||||
*/
|
||||
package vazkii.botania.client.gui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.LexiconCategory;
|
||||
import vazkii.botania.api.LexiconEntry;
|
||||
import vazkii.botania.client.gui.button.GuiButtonBack;
|
||||
import vazkii.botania.client.gui.button.GuiButtonInvisible;
|
||||
|
||||
public class GuiLexiconIndex extends GuiLexicon {
|
||||
|
||||
LexiconCategory category;
|
||||
String title;
|
||||
|
||||
public GuiLexiconIndex(LexiconCategory category) {
|
||||
this.category = category;
|
||||
title = StatCollector.translateToLocal(category.getUnlocalizedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int par1, int par2, float par3) {
|
||||
super.drawScreen(par1, par2, par3);
|
||||
void drawHeader() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
buttonList.add(new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
void populateIndex() {
|
||||
List<LexiconEntry> entryList = category.entries;
|
||||
for(int i = 0; i < 12; i++) {
|
||||
GuiButtonInvisible button = (GuiButtonInvisible) buttonList.get(i);
|
||||
LexiconEntry entry = i >= entryList.size() ? null : entryList.get(i);
|
||||
if(entry != null)
|
||||
button.displayString = " " + StatCollector.translateToLocal(entry.getUnlocalizedName());
|
||||
else button.displayString = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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 a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Jan 14, 2014, 9:54:21 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.gui.button;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.client.gui.GuiLexicon;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
public class GuiButtonBack extends GuiButton {
|
||||
|
||||
public GuiButtonBack(int par1, int par2, int par3) {
|
||||
super(par1, par2, par3, 18, 9, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
|
||||
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
drawTexturedModalRect(xPosition, yPosition, 36, 180, 18, 9);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,7 +13,7 @@ package vazkii.botania.common.core.handler;
|
||||
|
||||
import vazkii.botania.api.internal.IInternalMethodHandler;
|
||||
import vazkii.botania.api.page.LexiconPage;
|
||||
import vazkii.botania.common.page.PageText;
|
||||
import vazkii.botania.common.lexicon.page.PageText;
|
||||
|
||||
public class InternalMethodHandler implements IInternalMethodHandler {
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.core.handler.InternalMethodHandler;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.network.GuiHandler;
|
||||
import vazkii.botania.common.page.LexiconData;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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 a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Jan 14, 2014, 9:47:21 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.lexicon;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.LexiconCategory;
|
||||
import vazkii.botania.api.LexiconEntry;
|
||||
import vazkii.botania.api.page.LexiconPage;
|
||||
|
||||
public class BLexiconEntry extends LexiconEntry {
|
||||
|
||||
public BLexiconEntry(String unlocalizedName, LexiconCategory category) {
|
||||
super(unlocalizedName);
|
||||
BotaniaAPI.addEntry(this, category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLexiconPages(LexiconPage... pages) {
|
||||
for(LexiconPage page : pages)
|
||||
page.unlocalizedName = "botania.page." + getUnlocalizedName() + page.unlocalizedName;
|
||||
|
||||
super.setLexiconPages(pages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName() {
|
||||
return "botania.entry." + super.getUnlocalizedName();
|
||||
}
|
||||
|
||||
}
|
||||
+23
-1
@@ -9,10 +9,12 @@
|
||||
*
|
||||
* File Created @ [Jan 14, 2014, 9:12:15 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.page;
|
||||
package vazkii.botania.common.lexicon;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.LexiconCategory;
|
||||
import vazkii.botania.api.LexiconEntry;
|
||||
import vazkii.botania.common.lexicon.page.PageText;
|
||||
import vazkii.botania.common.lib.LibLexicon;
|
||||
|
||||
public final class LexiconData {
|
||||
@@ -32,7 +34,27 @@ public final class LexiconData {
|
||||
BotaniaAPI.addCategory(categoryTools = new LexiconCategory(LibLexicon.CATEGORY_TOOLS));
|
||||
BotaniaAPI.addCategory(categoryMisc = new LexiconCategory(LibLexicon.CATEGORY_MISC));
|
||||
|
||||
LexiconEntry entry;
|
||||
|
||||
// BASICS ENTRIES
|
||||
entry = new BLexiconEntry("world", categoryBasics);
|
||||
entry.setLexiconPages(new PageText("0"), new PageText("1"));
|
||||
|
||||
entry = new BLexiconEntry("basicConcepts", categoryBasics);
|
||||
entry.setLexiconPages(new PageText("0"));
|
||||
|
||||
entry = new BLexiconEntry("gettingStarted", categoryBasics);
|
||||
entry.setLexiconPages(new PageText("0"));
|
||||
|
||||
// ENERGY ENTRIES
|
||||
|
||||
// FLOWERS ENTRIES
|
||||
|
||||
// DEVICES ENTRIES
|
||||
|
||||
// TOOLS ENTRIES
|
||||
|
||||
// MISC ENTRIES
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
*
|
||||
* File Created @ [Jan 14, 2014, 6:45:33 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.page;
|
||||
package vazkii.botania.common.lexicon.page;
|
||||
|
||||
import vazkii.botania.api.internal.IGuiLexiconEntry;
|
||||
import vazkii.botania.api.page.LexiconPage;
|
||||
@@ -11,10 +11,10 @@
|
||||
*/
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import vazkii.botania.client.gui.GuiLexiconIndex;
|
||||
import vazkii.botania.common.lib.LibGuiIDs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.client.gui.GuiLexicon;
|
||||
import vazkii.botania.common.lib.LibGuiIDs;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
@@ -28,7 +28,7 @@ public class GuiHandler implements IGuiHandler {
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
switch(ID) {
|
||||
case LibGuiIDs.LEXICON :
|
||||
return new GuiLexiconIndex();
|
||||
return new GuiLexicon();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -15,4 +15,9 @@ botania.category.energy=Energy and Mana
|
||||
botania.category.flowers=Magical Flora
|
||||
botania.category.devices=Natural Apparatus
|
||||
botania.category.tools=Mystical Instruments
|
||||
botania.category.misc=Miscellaneous
|
||||
botania.category.misc=Miscellaneous
|
||||
|
||||
# LEXICON ENTRIES
|
||||
botania.entry.world=The World
|
||||
botania.entry.basicConcepts=Basic Concepts
|
||||
botania.entry.gettingStarted=Getting Started
|
||||
Reference in new issue
Block a user