mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-16 18:44:44 +00:00
Starting on the Lexicon Entry GUI. First thing.
This commit is contained in:
1 parent
3c16be7de4
commit
44f27ff044
8 files changed
+158
-3
No files matched your search
@@ -11,6 +11,8 @@
|
||||
*/
|
||||
package vazkii.botania.api.internal;
|
||||
|
||||
import vazkii.botania.api.LexiconEntry;
|
||||
|
||||
/**
|
||||
* Internal interface for the Lexicon Entry GUI. This contains
|
||||
* everything that can be accessed from it. It's safe to cast
|
||||
@@ -18,4 +20,14 @@ package vazkii.botania.api.internal;
|
||||
*/
|
||||
public interface IGuiLexiconEntry {
|
||||
|
||||
/**
|
||||
* Gets the entry currently portrayed in this gui.
|
||||
*/
|
||||
public LexiconEntry getEntry();
|
||||
|
||||
/**
|
||||
* Gets the current page the lexicon GUI is browsing.
|
||||
*/
|
||||
public int getPageOn();
|
||||
|
||||
}
|
||||
@@ -73,6 +73,9 @@ public class GuiLexicon extends GuiScreen {
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
int i = par1GuiButton.id - 3;
|
||||
if(i < 0)
|
||||
return;
|
||||
|
||||
List<LexiconCategory> categoryList = BotaniaAPI.getAllCategories();
|
||||
LexiconCategory category = i >= categoryList.size() ? null : categoryList.get(i);
|
||||
|
||||
|
||||
@@ -11,8 +11,89 @@
|
||||
*/
|
||||
package vazkii.botania.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import vazkii.botania.api.LexiconEntry;
|
||||
import vazkii.botania.api.internal.IGuiLexiconEntry;
|
||||
import vazkii.botania.client.gui.button.GuiButtonBack;
|
||||
import vazkii.botania.client.gui.button.GuiButtonPage;
|
||||
|
||||
public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry {
|
||||
|
||||
int page = 0;
|
||||
LexiconEntry entry;
|
||||
GuiLexiconIndex index;
|
||||
String title;
|
||||
|
||||
GuiButton leftButton, rightButton;
|
||||
|
||||
public GuiLexiconEntry(LexiconEntry entry, GuiLexiconIndex index) {
|
||||
this.entry = entry;
|
||||
this.index = index;
|
||||
|
||||
title = StatCollector.translateToLocal(entry.getUnlocalizedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
buttonList.add(new GuiButtonBack(0, left + guiWidth / 2 - 8, top + guiHeight + 2));
|
||||
buttonList.add(leftButton = new GuiButtonPage(1, left, top + guiHeight - 10, false));
|
||||
buttonList.add(rightButton = new GuiButtonPage(2, left + guiWidth - 18, top + guiHeight - 10, true));
|
||||
|
||||
updatePageButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LexiconEntry getEntry() {
|
||||
return entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPageOn() {
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isIndex() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
void drawHeader() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
String getTitle() {
|
||||
return String.format("%s (%s/%s)", title, (page + 1), entry.pages.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
switch(par1GuiButton.id) {
|
||||
case 0 :
|
||||
mc.displayGuiScreen(index);
|
||||
break;
|
||||
case 1 :
|
||||
page--;
|
||||
break;
|
||||
case 2 :
|
||||
page++;
|
||||
break;
|
||||
}
|
||||
updatePageButtons();
|
||||
}
|
||||
|
||||
public void updatePageButtons() {
|
||||
leftButton.enabled = page != 0;
|
||||
rightButton.enabled = page + 1 < entry.pages.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int par1, int par2, float par3) {
|
||||
super.drawScreen(par1, par2, par3);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,8 +13,8 @@ package vazkii.botania.client.gui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
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;
|
||||
@@ -24,6 +24,7 @@ public class GuiLexiconIndex extends GuiLexicon {
|
||||
|
||||
LexiconCategory category;
|
||||
String title;
|
||||
int page = 0;
|
||||
|
||||
public GuiLexiconIndex(LexiconCategory category) {
|
||||
this.category = category;
|
||||
@@ -57,4 +58,18 @@ public class GuiLexiconIndex extends GuiLexicon {
|
||||
else button.displayString = "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if(par1GuiButton.id == 12)
|
||||
mc.displayGuiScreen(new GuiLexicon());
|
||||
else {
|
||||
int index = par1GuiButton.id + page * 12;
|
||||
if(index >= category.entries.size())
|
||||
return;
|
||||
|
||||
LexiconEntry entry = category.entries.get(index);
|
||||
mc.displayGuiScreen(new GuiLexiconEntry(entry, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,9 +25,12 @@ public class GuiButtonBack extends GuiButton {
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
|
||||
field_82253_i = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
|
||||
int k = getHoverState(field_82253_i);
|
||||
|
||||
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
drawTexturedModalRect(xPosition, yPosition, 36, 180, 18, 9);
|
||||
drawTexturedModalRect(xPosition, yPosition, 36, k == 2 ? 180 : 189, 18, 9);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* 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 16, 2014, 4:52:06 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 GuiButtonPage extends GuiButton {
|
||||
|
||||
boolean right;
|
||||
|
||||
public GuiButtonPage(int par1, int par2, int par3, boolean right) {
|
||||
super(par1, par2, par3, 18, 10, "");
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
|
||||
if(enabled) {
|
||||
field_82253_i = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
|
||||
int k = getHoverState(field_82253_i);
|
||||
|
||||
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
drawTexturedModalRect(xPosition, yPosition, k == 2 ? 18 : 0, right ? 180 : 190, 18, 10);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public final class LexiconData {
|
||||
entry.setLexiconPages(new PageText("0"), new PageText("1"));
|
||||
|
||||
entry = new BLexiconEntry("basicConcepts", categoryBasics);
|
||||
entry.setLexiconPages(new PageText("0"));
|
||||
entry.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"));
|
||||
|
||||
entry = new BLexiconEntry("gettingStarted", categoryBasics);
|
||||
entry.setLexiconPages(new PageText("0"));
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
Reference in new issue
Block a user