From cc9c496f6ebb583f19c286c7886202f3bfc9cf75 Mon Sep 17 00:00:00 2001 From: gigabit101 Date: Mon, 10 Aug 2015 22:04:54 +0100 Subject: [PATCH] Small changes to PDA --- src/main/java/techreborn/pda/GuiManual.java | 7 +++ .../java/techreborn/pda/PageCollection.java | 2 +- .../java/techreborn/pda/pages/BlocksPage.java | 60 +++++++++++++++++++ .../techreborn/pda/pages/ContentsPage.java | 45 ++++++++++++++ .../java/techreborn/pda/pages/ItemsPage.java | 60 +++++++++++++++++++ 5 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 src/main/java/techreborn/pda/pages/BlocksPage.java create mode 100644 src/main/java/techreborn/pda/pages/ContentsPage.java create mode 100644 src/main/java/techreborn/pda/pages/ItemsPage.java diff --git a/src/main/java/techreborn/pda/GuiManual.java b/src/main/java/techreborn/pda/GuiManual.java index 82b251bbf..175d312d3 100644 --- a/src/main/java/techreborn/pda/GuiManual.java +++ b/src/main/java/techreborn/pda/GuiManual.java @@ -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), "")); diff --git a/src/main/java/techreborn/pda/PageCollection.java b/src/main/java/techreborn/pda/PageCollection.java index 4db38cdfa..2d6078726 100644 --- a/src/main/java/techreborn/pda/PageCollection.java +++ b/src/main/java/techreborn/pda/PageCollection.java @@ -12,7 +12,7 @@ import techreborn.pda.pages.BasePage; public class PageCollection extends Gui{ public final List pages = Lists.newArrayList(); - private String ACTIVE_PAGE = "INDEX"; + private String ACTIVE_PAGE = "CONTENTS"; protected int x; protected int y; diff --git a/src/main/java/techreborn/pda/pages/BlocksPage.java b/src/main/java/techreborn/pda/pages/BlocksPage.java new file mode 100644 index 000000000..68c2152f3 --- /dev/null +++ b/src/main/java/techreborn/pda/pages/BlocksPage.java @@ -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); + } + } + } +} diff --git a/src/main/java/techreborn/pda/pages/ContentsPage.java b/src/main/java/techreborn/pda/pages/ContentsPage.java new file mode 100644 index 000000000..bce97a4d4 --- /dev/null +++ b/src/main/java/techreborn/pda/pages/ContentsPage.java @@ -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); + } + } + } + +} diff --git a/src/main/java/techreborn/pda/pages/ItemsPage.java b/src/main/java/techreborn/pda/pages/ItemsPage.java new file mode 100644 index 000000000..6c2cc9811 --- /dev/null +++ b/src/main/java/techreborn/pda/pages/ItemsPage.java @@ -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); + } + } + } +}