Small changes to PDA

This commit is contained in:
gigabit101 2015-08-10 22:04:54 +01:00
parent fe049cc160
commit cc9c496f6e
5 changed files with 173 additions and 1 deletions

View file

@ -14,8 +14,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import techreborn.init.ModBlocks;
import techreborn.init.ModItems;
import techreborn.pda.pages.BlocksPage;
import techreborn.pda.pages.ContentsPage;
import techreborn.pda.pages.CraftingInfoPage;
import techreborn.pda.pages.IndexPage;
import techreborn.pda.pages.ItemsPage;
import techreborn.pda.pages.TitledPage;
@SideOnly(Side.CLIENT)
@ -39,6 +42,10 @@ public class GuiManual extends GuiScreen{
pageIndex = 0;
final PageCollection pageCollection = new PageCollection();
pageCollection.addPage(new IndexPage("INDEX", pageCollection));
pageCollection.addPage(new ContentsPage("CONTENTS", pageCollection));
pageCollection.addPage(new ItemsPage("ITEMS", pageCollection));
pageCollection.addPage(new BlocksPage("BLOCKS", pageCollection));
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Aesu), ""));
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE."+getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.AlloyFurnace), ""));

View file

@ -12,7 +12,7 @@ import techreborn.pda.pages.BasePage;
public class PageCollection extends Gui{
public final List<BasePage> pages = Lists.newArrayList();
private String ACTIVE_PAGE = "INDEX";
private String ACTIVE_PAGE = "CONTENTS";
protected int x;
protected int y;

View file

@ -0,0 +1,60 @@
package techreborn.pda.pages;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import techreborn.pda.PageCollection;
import techreborn.pda.util.GuiButtonAHeight;
import techreborn.pda.util.GuiButtonTextOnly;
public class BlocksPage extends TitledPage{
public BlocksPage(String name, PageCollection collection) {
super(name, false, collection, "techreborn.pda.blockspage", 518915);
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
buttonList.clear();
int row = 0;
int collum = 0;
for (BasePage page : collection.pages){
if (page.hasIndexButton){
String indexName = page.INDEX_NAME;
if (page.getReferenceName() != null && page.getReferenceName().contains("BLOCK_PAGE")){
if (indexName==null && page instanceof CraftingInfoPage) indexName = ttl(((CraftingInfoPage)page).result.getUnlocalizedName()+".name");
else if (indexName==null) indexName = page.getReferenceName();
int colour = 0000000;
buttonList.add(new GuiButtonTextOnly(999, getXMin()+5+collum*81, getYMin()+20+(row*7), 82, 7, indexName, page.getReferenceName(), colour));
row++;
if (row > 21){
row = 0;
collum++;
}
}
}
}
}
@Override
public void actionPerformed(GuiButton button) {
if (button instanceof GuiButtonTextOnly)
collection.changeActivePage(((GuiButtonTextOnly)button).LINKED_PAGE);
}
@Override
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
}
@Override
public void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.drawScreen(minecraft, offsetX, offsetY, mouseX, mouseY);
for (int k = 0; k < this.buttonList.size(); ++k){
if (buttonList.get(k) instanceof GuiButtonTextOnly && ((GuiButtonTextOnly) buttonList.get(k)).getIsHovering()) {
((GuiButtonTextOnly) this.buttonList.get(k)).drawButton(this.mc, mouseX + offsetX, mouseY + offsetY);
}
}
}
}

View file

@ -0,0 +1,45 @@
package techreborn.pda.pages;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import techreborn.pda.PageCollection;
import techreborn.pda.util.GuiButtonTextOnly;
public class ContentsPage extends TitledPage{
public ContentsPage(String name, PageCollection collection) {
super(name, false, collection, "techreborn.pda.contents", 518915);
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
buttonList.clear();
buttonList.add(new GuiButton(0, getXMin() + 25, getYMin() + 20, "ITEMS"));
buttonList.add(new GuiButton(1, getXMin() + 25, getYMin() + 40, "BLOCKS"));
buttonList.add(new GuiButton(2, getXMin() + 25, getYMin() + 160, "INDEX"));
}
@Override
public void actionPerformed(GuiButton button) {
if (button.id == 0)collection.changeActivePage("ITEMS");
if (button.id == 1)collection.changeActivePage("BLOCKS");
if (button.id == 2)collection.changeActivePage("INDEX");
}
@Override
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
}
@Override
public void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.drawScreen(minecraft, offsetX, offsetY, mouseX, mouseY);
for (int k = 0; k < this.buttonList.size(); ++k){
if (buttonList.get(k) instanceof GuiButtonTextOnly && ((GuiButtonTextOnly) buttonList.get(k)).getIsHovering()) {
((GuiButtonTextOnly) this.buttonList.get(k)).drawButton(this.mc, mouseX + offsetX, mouseY + offsetY);
}
}
}
}

View file

@ -0,0 +1,60 @@
package techreborn.pda.pages;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import techreborn.pda.PageCollection;
import techreborn.pda.util.GuiButtonAHeight;
import techreborn.pda.util.GuiButtonTextOnly;
public class ItemsPage extends TitledPage{
public ItemsPage(String name, PageCollection collection) {
super(name, false, collection, "techreborn.pda.itemspage", 518915);
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
buttonList.clear();
int row = 0;
int collum = 0;
for (BasePage page : collection.pages){
if (page.hasIndexButton){
String indexName = page.INDEX_NAME;
if (page.getReferenceName() != null && page.getReferenceName().contains("ITEM_PAGE")){
if (indexName==null && page instanceof CraftingInfoPage) indexName = ttl(((CraftingInfoPage)page).result.getUnlocalizedName()+".name");
else if (indexName==null) indexName = page.getReferenceName();
int colour = 0000000;
buttonList.add(new GuiButtonTextOnly(999, getXMin()+5+collum*81, getYMin()+20+(row*7), 82, 7, indexName, page.getReferenceName(), colour));
row++;
if (row > 21){
row = 0;
collum++;
}
}
}
}
}
@Override
public void actionPerformed(GuiButton button) {
if (button instanceof GuiButtonTextOnly)
collection.changeActivePage(((GuiButtonTextOnly)button).LINKED_PAGE);
}
@Override
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
}
@Override
public void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.drawScreen(minecraft, offsetX, offsetY, mouseX, mouseY);
for (int k = 0; k < this.buttonList.size(); ++k){
if (buttonList.get(k) instanceof GuiButtonTextOnly && ((GuiButtonTextOnly) buttonList.get(k)).getIsHovering()) {
((GuiButtonTextOnly) this.buttonList.get(k)).drawButton(this.mc, mouseX + offsetX, mouseY + offsetY);
}
}
}
}