Start on the new manual

This commit is contained in:
gigabit101 2016-02-25 18:25:52 +00:00
parent 7d6c982847
commit 82d2de7eb1
30 changed files with 423 additions and 81 deletions

View file

@ -0,0 +1,135 @@
package techreborn.manual;
import java.io.IOException;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.inventory.Container;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import techreborn.manual.pages.ContentsPage;
import techreborn.manual.pages.DescriptionPage;
import techreborn.manual.pages.GettingStartedPage;
@SideOnly(Side.CLIENT)
public class GuiManual extends GuiScreen
{
protected final PageCollection root;
protected int pageIndex = 0;
protected int xSize = 0;
protected int ySize = 0;
public Container inventorySlots;
protected int guiLeft;
protected int guiTop;
public GuiManual()
{
this.xSize = 146;
this.ySize = 180;
root = createRoot();
}
protected PageCollection createRoot()
{
pageIndex = 0;
final PageCollection pageCollection = new PageCollection();
pageCollection.addPage(new ContentsPage("CONTENTS", pageCollection));
pageCollection.addPage(new GettingStartedPage(Reference.pageNames.GETTINGSTARTED_PAGE, pageCollection));
pageCollection.addPage(new DescriptionPage(Reference.pageNames.GETTINGRUBBER_PAGE, pageCollection, true));
return pageCollection;
}
private int getNextPageIndex()
{
int i = pageIndex;
pageIndex++;
return i;
}
@Override
public void drawScreen(int mouseX, int mouseY, float par3)
{
drawGuiBackgroundLayer(par3, mouseX, mouseY);
super.drawScreen(mouseX, mouseY, par3);
prepareRenderState();
GL11.glPushMatrix();
root.drawScreen(this.mc, this.guiLeft, this.guiTop, mouseX - this.guiLeft, mouseY - this.guiTop);
GL11.glPopMatrix();
restoreRenderState();
}
protected void prepareRenderState()
{
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
}
protected void restoreRenderState()
{
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderHelper.enableStandardItemLighting();
}
protected void drawGuiBackgroundLayer(float p_146976_1_, int mouseX, int mouseY)
{
GL11.glPushMatrix();
GL11.glTranslated(this.guiLeft, this.guiTop, 0);
root.renderBackgroundLayer(this.mc, 0, 0, mouseX - this.guiLeft, mouseY - this.guiTop);
GL11.glPopMatrix();
}
@Override
public void setWorldAndResolution(Minecraft minecraft, int x, int y)
{
super.setWorldAndResolution(minecraft, x, y);
root.setWorldAndResolution(minecraft, x, y);
}
@Override
public void actionPerformed(GuiButton button)
{
root.actionPerformed(button);
}
@Override
public void mouseClicked(int par1, int par2, int par3) throws IOException
{
root.mouseClicked(par1, par2, par3);
}
@Override
public void handleInput() throws IOException
{
super.handleInput();
}
@Override
public void initGui()
{
super.initGui();
this.guiLeft = (this.width - this.xSize) / 2;
this.guiTop = (this.height - this.ySize) / 2;
}
@Override
public boolean doesGuiPauseGame()
{
return false;
}
}

View file

@ -0,0 +1,86 @@
package techreborn.manual;
import java.io.IOException;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import techreborn.manual.pages.BasePage;
public class PageCollection extends Gui {
public final List<BasePage> pages = Lists.newArrayList();
private String ACTIVE_PAGE = "CONTENTS";
protected int x;
protected int y;
public PageCollection() {
this.x = 0;
this.y = 0;
}
public void addPage(BasePage page) {
pages.add(page);
}
public BasePage getPageByName(String name) {
for (BasePage component : pages) {
if (component.getReferenceName().equals(ACTIVE_PAGE)) {
return component;
}
}
return null;
}
public BasePage getActivePage() {
for (BasePage component : pages) {
if (component.getReferenceName().equals(ACTIVE_PAGE)) {
return component;
}
}
return null;
}
public final void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
if (getActivePage() == null) return;
getActivePage().drawScreen(minecraft, offsetX, offsetY, mouseX, mouseY);
}
public final void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
if (getActivePage() == null) return;
getActivePage().renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
}
public void changeActivePage(String newPage) {
ACTIVE_PAGE = newPage;
if (getActivePage() == null) return;
getActivePage().setWorldAndResolution(Minecraft.getMinecraft(), x, y);
}
public void setWorldAndResolution(Minecraft minecraft, int x, int y) {
if (getActivePage() == null) return;
getActivePage().setWorldAndResolution(minecraft, x, y);
this.x = x;
this.y = y;
}
protected void actionPerformed(GuiButton button) {
if (getActivePage() == null) return;
getActivePage().actionPerformed(button);
}
// protected void mouseMovedOrUp(int par1, int par2, int par3) {
// if (getActivePage() == null) return;
// getActivePage().mo(par1, par2, par3);
// }
protected void mouseClicked(int par1, int par2, int par3) throws IOException {
if (getActivePage() == null) return;
getActivePage().mouseClicked(par1, par2, par3);
}
}

View file

@ -0,0 +1,14 @@
package techreborn.manual;
public class Reference
{
public static final String CONTENTS_KEY = "techreborn.manual.contents";
public static final String GETTINGSTARTED_KEY = "techreborn.manual.gettingstarted";
public static final String GETTINGRUBBER_KEY = "techreborn.manual.gettingrubber";
public class pageNames
{
public static final String GETTINGSTARTED_PAGE = "gettingstarted";
public static final String GETTINGRUBBER_PAGE = "gettingrubber";
}
}

View file

@ -0,0 +1,57 @@
package techreborn.manual.old;
import java.awt.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.item.ItemStack;
import techreborn.config.TechRebornConfigGui;
import techreborn.init.ModBlocks;
import techreborn.init.ModItems;
import techreborn.manual.PageCollection;
import techreborn.manual.pages.TitledPage;
import techreborn.manual.util.GuiButtonCustomTexture;
public class ContentsPageOld extends TitledPage {
public ContentsPageOld(String name, PageCollection collection) {
super(name, false, collection, "techreborn.pda.contents", Color.white.getRGB());
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
buttonList.clear();
buttonList.add(new GuiButtonCustomTexture(0, getXMin() + 25, getYMin() + 20, 0, 46, 80, 20, new ItemStack(ModBlocks.AlloySmelter), "INDEX", "MACHINES"));
buttonList.add(new GuiButtonCustomTexture(1, getXMin() + 160, getYMin() + 20, 0, 46, 80, 20, new ItemStack(ModItems.uuMatter), "INDEX", "ITEMS"));
buttonList.add(new GuiButtonCustomTexture(2, getXMin() + 25, getYMin() + 40, 0, 46, 80, 20, new ItemStack(ModBlocks.DieselGenerator), "INDEX", "POWER GENERATION"));
buttonList.add(new GuiButtonCustomTexture(3, getXMin() + 160, getYMin() + 40, 0, 46, 80, 20, new ItemStack(ModItems.advancedDrill), "INDEX", "TOOLS"));
buttonList.add(new GuiButtonCustomTexture(4, getXMin() + 25, getYMin() + 60, 0, 46, 80, 20, new ItemStack(ModBlocks.Aesu), "INDEX", "POWER STORAGE"));
buttonList.add(new GuiButtonCustomTexture(5, getXMin() + 25, getYMin() + 80, 0, 46, 80, 20, new ItemStack(ModBlocks.MachineCasing), "INDEX", "MULTIBLOCKS"));
buttonList.add(new GuiButtonCustomTexture(6, getXMin() + 160, getYMin() + 60, 0, 46, 80, 20, new ItemStack(ModItems.upgrades), "INDEX", "UPGRADES"));
buttonList.add(new GuiButtonCustomTexture(7, getXMin() + 160, getYMin() + 180, 0, 46, 80, 20, new ItemStack(ModItems.lapotronicOrb), "INDEX", "Changelog"));
buttonList.add(new GuiButtonCustomTexture(8, getXMin() + 25, getYMin() + 180, 0, 46, 80, 20, new ItemStack(ModItems.lapotronicOrb), "INDEX", "Configs"));
}
@Override
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
}
@Override
public void actionPerformed(GuiButton button) {
if (button.id == 0) collection.changeActivePage("MACHINES");
if (button.id == 1) collection.changeActivePage("ITEMS");
if (button.id == 2) collection.changeActivePage("POWER_GENERATION");
if (button.id == 3) collection.changeActivePage("TOOLS");
if (button.id == 4) collection.changeActivePage("POWER_STORAGE");
if (button.id == 5) collection.changeActivePage("MULTIBLOCKS");
if (button.id == 6) collection.changeActivePage("UPGRADES");
if (button.id == 7) collection.changeActivePage("VERSION");
if (button.id == 8) mc.displayGuiScreen(new TechRebornConfigGui(this));
if (button.id == 9) collection.changeActivePage("CONFIG");
}
}

View file

@ -0,0 +1,290 @@
package techreborn.manual.old;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.*;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import techreborn.manual.PageCollection;
import techreborn.manual.pages.TitledPage;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class CraftingInfoPage extends TitledPage {
public ItemStack result;
private boolean isSmelting = false;
private ItemStack[] recipe = new ItemStack[9];
private boolean hasRecipe = false;
private String rawDescription;
private List<String> formattedDescription;
private float descriptionScale = 0.66f;
public CraftingInfoPage(String name, PageCollection collection, ItemStack itemStack, String unlocalizedDescription) {
super(name, true, collection, itemStack.getUnlocalizedName() + ".name", Color.white.getRGB());
this.result = itemStack;
this.recipe = getFirstRecipeForItem(itemStack);
for (ItemStack stack : recipe) if (stack != null) hasRecipe = true;
if (unlocalizedDescription == "") rawDescription = ttl(itemStack.getUnlocalizedName() + ".description");
else rawDescription = ttl(unlocalizedDescription);
}
@Override
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
GL11.glPushMatrix();
if (isSmelting) {
drawTexturedModalRect(offsetX + 87, offsetY + 15, 116, 202, 82, 54);
} else {
if (hasRecipe) {
drawTexturedModalRect(offsetX + 70, offsetY + 15, 0, 202, 116, 54);
} else {
drawTexturedModalRect(offsetX + 119, offsetY + 17, 0, 202, 18, 18);
drawString(fontRendererObj, "No Crafting Recipe", offsetX + 145, offsetY + 17, Color.white.getRGB());
}
}
GL11.glPopMatrix();
}
public void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.drawScreen(minecraft, offsetX, offsetY, mouseX, mouseY);
int relativeMouseX = mouseX + offsetX;
int relativeMouseY = mouseY + offsetY;
int gridOffsetX = isSmelting ? 88 : 71;
int gridOffsetY = 16;
int itemBoxSize = 18;
addDescription(minecraft, offsetX, offsetY);
ItemStack tooltip = null;
int i = 0;
for (ItemStack input : recipe) {
if (input != null) {
int row = (i % 3);
int column = i / 3;
int itemX = offsetX + gridOffsetX + (row * itemBoxSize);
int itemY = offsetY + gridOffsetY + (column * itemBoxSize);
drawItemStack(input, itemX, itemY, "");
if (relativeMouseX > itemX - 2 && relativeMouseX < itemX - 2 + itemBoxSize &&
relativeMouseY > itemY - 2 && relativeMouseY < itemY - 2 + itemBoxSize) {
tooltip = input;
}
}
i++;
}
int itemX = offsetX + (isSmelting ? 148 : 165);
int itemY = offsetY + 34;
if (!hasRecipe) {
itemX = offsetX + 120;
itemY = offsetY + 18;
}
drawItemStack(result, itemX, itemY, "");
if (relativeMouseX > itemX - 2 && relativeMouseX < itemX - 2 + itemBoxSize &&
relativeMouseY > itemY - 2 && relativeMouseY < itemY - 2 + itemBoxSize) {
tooltip = result;
}
if (tooltip != null) {
drawItemStackTooltip(tooltip, relativeMouseX, relativeMouseY);
}
}
public void addDescription(Minecraft minecraft, int offsetX, int offsetY) {
GL11.glPushMatrix();
if (hasRecipe) GL11.glTranslated(offsetX + 5, offsetY + 75, 1);
else GL11.glTranslated(offsetX + 5, offsetY + 40, 1);
GL11.glScalef(descriptionScale, descriptionScale, descriptionScale);
int offset = 0;
for (String s : getFormattedText(fontRendererObj)) {
if (s == null) break;
if (s.contains("\\%") && s.substring(0, 2).equals("\\%")) {
s = s.substring(2);
offset += fontRendererObj.FONT_HEIGHT / 2;
}
fontRendererObj.drawString(s, 0, offset, Color.white.getRGB());
offset += fontRendererObj.FONT_HEIGHT;
}
GL11.glPopMatrix();
}
@SuppressWarnings("unchecked")
public List<String> getFormattedText(FontRenderer fr) {
if (formattedDescription == null) {
formattedDescription = new ArrayList<String>();
if (Strings.isNullOrEmpty(rawDescription)) {
formattedDescription = ImmutableList.of();
return formattedDescription;
}
if (!rawDescription.contains("\\n")) {
formattedDescription = ImmutableList.copyOf(fr.listFormattedStringToWidth(rawDescription, 370));
return formattedDescription;
}
List<String> segments = new ArrayList(); //Each separate string that is separated by a \n
String raw = rawDescription;
int escape = 0;
while (raw.contains("\\n")) {
segments.add(raw.substring(0, raw.indexOf("\\n")));
raw = raw.substring(raw.indexOf("\\n") + 2);
if (!raw.contains("\\n")) segments.add(raw);
escape++;
if (escape > 100) {
break;
}
}
for (String s : segments)
formattedDescription.addAll(ImmutableList.copyOf(fr.listFormattedStringToWidth(s, 370)));
}
return formattedDescription;
}
protected void drawItemStackTooltip(ItemStack stack, int x, int y) {
final Minecraft mc = Minecraft.getMinecraft();
FontRenderer font = Objects.firstNonNull(stack.getItem().getFontRenderer(stack), mc.fontRendererObj);
@SuppressWarnings("unchecked")
List<String> list = stack.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips);
List<String> colored = Lists.newArrayListWithCapacity(list.size());
colored.add(stack.getRarity().rarityColor + list.get(0));
for (String line : list)
colored.add(EnumChatFormatting.GRAY + line);
if (colored.size() >= 2) colored.remove(1);
drawHoveringText(colored, x, y, font);
}
private void drawItemStack(ItemStack par1ItemStack, int par2, int par3, String par4Str) {
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
this.zLevel = 200.0F;
RenderHelper.enableGUIStandardItemLighting();
GL11.glColor3f(1f, 1f, 1f);
GL11.glEnable(GL11.GL_NORMALIZE);
FontRenderer font = null;
if (par1ItemStack != null) font = par1ItemStack.getItem().getFontRenderer(par1ItemStack);
if (font == null) font = Minecraft.getMinecraft().fontRendererObj;
renderItemStack(par1ItemStack, par2, par3);
this.zLevel = 0.0F;
}
public void renderItemStack(ItemStack stack, int x, int y)
{
if (stack != null)
{
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.enableGUIStandardItemLighting();
RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
itemRenderer.renderItemAndEffectIntoGUI(stack, x, y);
GL11.glDisable(GL11.GL_LIGHTING);
}
}
@SuppressWarnings("unchecked")
private ItemStack[] getFirstRecipeForItem(ItemStack resultingItem) {
ItemStack[] recipeItems = new ItemStack[9];
for (IRecipe recipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
if (recipe == null) continue;
ItemStack result = recipe.getRecipeOutput();
if (result == null || !result.isItemEqual(resultingItem)) continue;
Object[] input = getRecipeInput(recipe);
if (input == null) continue;
for (int i = 0; i < input.length; i++)
recipeItems[i] = convertToStack(input[i]);
break;
}
Iterator iterator = FurnaceRecipes.instance().getSmeltingList().entrySet().iterator();
Map.Entry entry;
while (iterator.hasNext()) {
entry = (Map.Entry) iterator.next();
if (entry.getKey() instanceof ItemStack && ((ItemStack) entry.getValue()).isItemEqual(result)) {
isSmelting = true;
recipeItems[0] = (ItemStack) entry.getKey();
}
}
return recipeItems;
}
protected ItemStack convertToStack(Object obj) {
ItemStack entry = null;
if (obj instanceof ItemStack) {
entry = (ItemStack) obj;
} else if (obj instanceof List) {
@SuppressWarnings("unchecked")
List<ItemStack> list = (List<ItemStack>) obj;
if (list.size() > 0) entry = list.get(0);
}
if (entry == null) return null;
entry = entry.copy();
if (entry.getItemDamage() == OreDictionary.WILDCARD_VALUE) entry.setItemDamage(0);
return entry;
}
@SuppressWarnings("unchecked")
private Object[] getRecipeInput(IRecipe recipe) {
if (recipe instanceof ShapelessOreRecipe) return ((ShapelessOreRecipe) recipe).getInput().toArray();
else if (recipe instanceof ShapedOreRecipe) return getShapedOreRecipe((ShapedOreRecipe) recipe);
else if (recipe instanceof ShapedRecipes) return ((ShapedRecipes) recipe).recipeItems;
else if (recipe instanceof ShapelessRecipes)
return ((ShapelessRecipes) recipe).recipeItems.toArray(new ItemStack[0]);
return null;
}
private Object[] getShapedOreRecipe(ShapedOreRecipe recipe) {
try {
Field field = ShapedOreRecipe.class.getDeclaredField("width");
if (field != null) {
field.setAccessible(true);
int width = field.getInt(recipe);
Object[] input = recipe.getInput();
Object[] grid = new Object[9];
for (int i = 0, offset = 0, y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++, i++) {
if (x < width && offset < input.length) {
grid[i] = input[offset];
offset++;
} else {
grid[i] = null;
}
}
}
return grid;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View file

@ -0,0 +1,176 @@
package techreborn.manual.old;
import java.io.IOException;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import techreborn.init.ModBlocks;
import techreborn.init.ModItems;
import techreborn.manual.PageCollection;
import techreborn.manual.pages.ContentsPage;
@SideOnly(Side.CLIENT)
public class GuiManualOld extends GuiScreen {
protected final PageCollection root;
protected int pageIndex = 0;
protected int xSize = 0;
protected int ySize = 0;
public Container inventorySlots;
protected int guiLeft;
protected int guiTop;
public GuiManualOld() {
this.xSize = 256;
this.ySize = 202;
root = createRoot();
}
protected PageCollection createRoot() {
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, "ITEM_PAGE"));
pageCollection.addPage(new ItemsPage("TOOLS", pageCollection, "TOOLS_PAGE"));
pageCollection.addPage(new ItemsPage("UPGRADES", pageCollection, "UPGRADES_PAGE"));
pageCollection.addPage(new ItemsPage("MACHINES", pageCollection, "MACHINES_PAGE"));
pageCollection.addPage(new ItemsPage("POWER_GENERATION", pageCollection, "POWER_GENERATION_PAGE"));
pageCollection.addPage(new ItemsPage("POWER_STORAGE", pageCollection, "POWER_STORAGE_PAGE"));
pageCollection.addPage(new VersionPage("VERSION", pageCollection, "VERSION PAGE", 777777));
pageCollection.addPage(new MultiBlockPage("MULTIBLOCKS", pageCollection, "MULTIBLOCK_PAGE"));
pageCollection.addPage(new CraftingInfoPage("POWER_STORAGE_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Aesu), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.AlloyFurnace), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.AlloySmelter), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.BlastFurnace), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.centrifuge), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.chargeBench), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.ChemicalReactor), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.ChunkLoader), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.ComputerCube), ""));
pageCollection.addPage(new CraftingInfoPage("POWER_GENERATION_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.DieselGenerator), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.digitalChest), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Distillationtower), ""));
pageCollection.addPage(new CraftingInfoPage("POWER_GENERATION_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Dragoneggenergysiphoner), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.ElectricCraftingTable), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.FusionCoil), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.FusionControlComputer), ""));
pageCollection.addPage(new CraftingInfoPage("BLOCK_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Gasturbine), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.IndustrialGrinder), ""));
pageCollection.addPage(new CraftingInfoPage("POWER_GENERATION_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.heatGenerator), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.HighAdvancedMachineBlock), ""));
pageCollection.addPage(new CraftingInfoPage("POWER_STORAGE_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Idsu), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.ImplosionCompressor), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.IndustrialElectrolyzer), ""));
pageCollection.addPage(new CraftingInfoPage("POWER_STORAGE_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Lesu), ""));
pageCollection.addPage(new CraftingInfoPage("POWER_STORAGE_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.LesuStorage), ""));
pageCollection.addPage(new CraftingInfoPage("POWER_GENERATION_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.LightningRod), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.machineframe), ""));
pageCollection.addPage(new CraftingInfoPage("POWER_GENERATION_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.MagicalAbsorber), ""));
pageCollection.addPage(new CraftingInfoPage("POWER_GENERATION_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Magicenergeyconverter), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.MatterFabricator), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.PlasmaGenerator), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.quantumChest), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.quantumTank), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.RollingMachine), ""));
pageCollection.addPage(new CraftingInfoPage("POWER_GENERATION_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.Semifluidgenerator), ""));
pageCollection.addPage(new CraftingInfoPage("POWER_GENERATION_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.thermalGenerator), ""));
pageCollection.addPage(new CraftingInfoPage("MACHINES_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModBlocks.VacuumFreezer), ""));
pageCollection.addPage(new CraftingInfoPage("TOOLS_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModItems.advancedDrill), ""));
pageCollection.addPage(new CraftingInfoPage("TOOLS_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModItems.cloakingDevice), ""));
pageCollection.addPage(new CraftingInfoPage("TOOLS_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModItems.lapotronicOrb), ""));
pageCollection.addPage(new CraftingInfoPage("TOOLS_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModItems.lapotronpack), ""));
pageCollection.addPage(new CraftingInfoPage("TOOLS_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModItems.lithiumBatpack), ""));
pageCollection.addPage(new CraftingInfoPage("TOOLS_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModItems.omniTool), ""));
pageCollection.addPage(new CraftingInfoPage("TOOLS_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModItems.rockCutter), ""));
pageCollection.addPage(new CraftingInfoPage("ITEM_PAGE." + getNextPageIndex(), pageCollection, new ItemStack(ModItems.uuMatter), ""));
return pageCollection;
}
private int getNextPageIndex() {
int i = pageIndex;
pageIndex++;
return i;
}
@Override
public void drawScreen(int mouseX, int mouseY, float par3) {
drawGuiBackgroundLayer(par3, mouseX, mouseY);
super.drawScreen(mouseX, mouseY, par3);
prepareRenderState();
GL11.glPushMatrix();
root.drawScreen(this.mc, this.guiLeft, this.guiTop, mouseX - this.guiLeft, mouseY - this.guiTop);
GL11.glPopMatrix();
restoreRenderState();
}
protected void prepareRenderState() {
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
}
protected void restoreRenderState() {
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderHelper.enableStandardItemLighting();
}
protected void drawGuiBackgroundLayer(float p_146976_1_, int mouseX, int mouseY) {
GL11.glPushMatrix();
GL11.glTranslated(this.guiLeft, this.guiTop, 0);
root.renderBackgroundLayer(this.mc, 0, 0, mouseX - this.guiLeft, mouseY - this.guiTop);
GL11.glPopMatrix();
}
@Override
public void setWorldAndResolution(Minecraft minecraft, int x, int y) {
super.setWorldAndResolution(minecraft, x, y);
root.setWorldAndResolution(minecraft, x, y);
}
// @Override
// public void actionPerformed(GuiButton button) {
// root.actionPerformed(button);
// }
//
//
// @Override
// public void mouseClicked(int par1, int par2, int par3) throws IOException {
// root.mouseClicked(par1, par2, par3);
// }
@Override
public void handleInput() throws IOException {
super.handleInput();
}
@Override
public void initGui() {
super.initGui();
this.guiLeft = (this.width - this.xSize) / 2;
this.guiTop = (this.height - this.ySize) / 2;
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
}

View file

@ -0,0 +1,62 @@
package techreborn.manual.old;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import techreborn.manual.PageCollection;
import techreborn.manual.pages.BasePage;
import techreborn.manual.pages.TitledPage;
import techreborn.manual.util.GuiButtonTextOnly;
public class IndexPage extends TitledPage {
public IndexPage(String name, PageCollection collection) {
super(name, false, collection, "techreborn.pda.index", 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 (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(), 6666666));
row++;
if (row > 21) {
row = 0;
collum++;
}
}
}
}
@Override
public void actionPerformed(GuiButton button) {
if (button instanceof GuiButtonTextOnly)
collection.changeActivePage(((GuiButtonTextOnly) button).LINKED_PAGE);
if (button.id == 0) collection.changeActivePage("CONTENTS");
}
@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);
}
}
buttonList.add(new GuiButton(0, offsetX + 20, offsetY + 180, ttl("techreborn.pda.backbutton")));
}
}

View file

@ -0,0 +1,67 @@
package techreborn.manual.old;
import java.awt.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import techreborn.manual.PageCollection;
import techreborn.manual.pages.BasePage;
import techreborn.manual.pages.TitledPage;
import techreborn.manual.util.GuiButtonTextOnly;
public class ItemsPage extends TitledPage {
public String PAGE;
public ItemsPage(String name, PageCollection collection, String page) {
super(name, false, collection, page, Color.white.getRGB());
PAGE = page;
}
@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(PAGE)) {
if (indexName == null && page instanceof CraftingInfoPage)
indexName = ttl(((CraftingInfoPage) page).result.getUnlocalizedName() + ".name");
else if (indexName == null) indexName = page.getReferenceName();
int colour = 77777777;
buttonList.add(new GuiButtonTextOnly(999, getXMin() + 20 + collum * 120, getYMin() + 20 + (row * 7), 82, 7, indexName, page.getReferenceName(), 6666666));
row++;
if (row > 21) {
row = 0;
collum++;
}
}
}
}
buttonList.add(new GuiButton(1, getXMin() + 20, getYMin() + 180, ttl("techreborn.pda.backbutton")));
}
@Override
public void actionPerformed(GuiButton button) {
if (button instanceof GuiButtonTextOnly)
collection.changeActivePage(((GuiButtonTextOnly) button).LINKED_PAGE);
if (button.id == 1) collection.changeActivePage("CONTENTS");
}
@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,98 @@
package techreborn.manual.old;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
import reborncore.client.multiblock.Multiblock;
import reborncore.client.multiblock.MultiblockSet;
import techreborn.init.ModBlocks;
import techreborn.manual.PageCollection;
import techreborn.manual.pages.TitledPage;
import techreborn.proxies.ClientProxy;
import java.awt.*;
public class MultiBlockPage extends TitledPage {
public static ResourceLocation test = new ResourceLocation("techreborn:textures/pda/multiblocks/base.png");
public MultiBlockPage(String name, PageCollection collection, String unlocalizedTitle) {
super(name, false, collection, unlocalizedTitle, Color.white.getRGB());
}
@Override
public void initGui() {
super.initGui();
GuiButton button = new GuiButton(212, getXMin() + 30, getYMin() + 140, "Show multiblock in world");
buttonList.add(button);
if (ClientProxy.multiblockRenderEvent.currentMultiblock != null) {
button.displayString = "Hide multiblock in world";
}
}
@Override
public void drawBackground(int p_146278_1_) {
super.drawBackground(p_146278_1_);
}
@Override
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.renderOverlayComponents(minecraft, offsetX, offsetY, mouseX, mouseY);
drawCenteredString(fontRendererObj, ttl("techreborn.pda.multiblock.decripion"), offsetX + 128, offsetY + 20, Color.white.getRGB());
}
@Override
public void actionPerformed(GuiButton button) {
super.actionPerformed(button);
if (button.id == 212) {
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
{//This code here makes a basic multiblock and then sets to the selected one.
Multiblock multiblock = new Multiblock();
multiblock.addComponent(0, 0, 0, ModBlocks.MachineCasing, 0);
multiblock.addComponent(1, 0, 0, ModBlocks.MachineCasing, 0);
multiblock.addComponent(0, 0, 1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(-1, 0, 0, ModBlocks.MachineCasing, 0);
multiblock.addComponent(0, 0, -1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(-1, 0, -1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(-1, 0, 1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(1, 0, -1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(1, 0, 1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(1, 1, 0, ModBlocks.MachineCasing, 0);
multiblock.addComponent(0, 1, 1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(-1, 1, 0, ModBlocks.MachineCasing, 0);
multiblock.addComponent(0, 1, -1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(-1, 1, -1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(-1, 1, 1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(1, 1, -1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(1, 1, 1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(1, 2, 0, ModBlocks.MachineCasing, 0);
multiblock.addComponent(0, 2, 1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(-1, 2, 0, ModBlocks.MachineCasing, 0);
multiblock.addComponent(0, 2, -1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(-1, 2, -1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(-1, 2, 1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(1, 2, -1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(1, 2, 1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(1, 3, 0, ModBlocks.MachineCasing, 0);
multiblock.addComponent(0, 3, 1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(-1, 3, 0, ModBlocks.MachineCasing, 0);
multiblock.addComponent(0, 3, -1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(-1, 3, -1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(-1, 3, 1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(1, 3, -1, ModBlocks.MachineCasing, 0);
multiblock.addComponent(1, 3, 1, ModBlocks.MachineCasing, 0);
MultiblockSet set = new MultiblockSet(multiblock);
ClientProxy.multiblockRenderEvent.setMultiblock(set);
}
button.displayString = "Hide multiblock in world";
} else {
ClientProxy.multiblockRenderEvent.setMultiblock(null);
button.displayString = "Show multiblock in world";
}
}
}
}

View file

@ -0,0 +1,63 @@
package techreborn.manual.old;
import net.minecraft.client.Minecraft;
import org.lwjgl.opengl.GL11;
import techreborn.Core;
import techreborn.lib.ModInfo;
import techreborn.manual.PageCollection;
import techreborn.manual.pages.TitledPage;
import java.awt.*;
import java.util.ArrayList;
public class VersionPage extends TitledPage {
public VersionPage(String name, PageCollection collection, String unlocalizedTitle, int colour) {
super(name, false, collection, unlocalizedTitle, Color.white.getRGB());
}
@Override
public void initGui() {
super.initGui();
}
@Override
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.renderOverlayComponents(minecraft, offsetX, offsetY, mouseX, mouseY);
addDescription(mc, offsetX, offsetY);
addChangelog(mc, offsetX, offsetY);
addChangelog2(mc, offsetX, offsetY);
}
@Override
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
}
public void addDescription(Minecraft minecraft, int offsetX, int offsetY) {
GL11.glPushMatrix();
this.drawCenteredString(minecraft.fontRendererObj, "INSTALLED VERSION " + ModInfo.MOD_VERSION, offsetX + 120, offsetY + 20, 7777777);
this.drawCenteredString(minecraft.fontRendererObj, "LATEST VERSION " + "TODO", offsetX + 120, offsetY + 40, 7777777);
GL11.glPopMatrix();
}
public void addChangelog(Minecraft minecraft, int offsetX, int offsetY) {
GL11.glPushMatrix();
this.drawCenteredString(minecraft.fontRendererObj, "CHANGELOG", offsetX + 120, getYMin() + 50, 7777777);
GL11.glPopMatrix();
}
public void addChangelog2(Minecraft minecraft, int offsetX, int offsetY) {
ArrayList<String> changeLog = Core.INSTANCE.versionChecker.getChangeLogSinceCurrentVersion();
GL11.glPushMatrix();
GL11.glScalef(0.7F, 0.7F, 0.7F);
int y = offsetY + 105;
for (String change : changeLog) {
drawCenteredString(minecraft.fontRendererObj, change, offsetX + 230, y, Color.white.getRGB());
y += 10;
}
GL11.glPopMatrix();
}
}

View file

@ -0,0 +1,103 @@
package techreborn.manual.pages;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import techreborn.manual.PageCollection;
import java.io.IOException;
public class BasePage extends GuiScreen {
//Name used to reference the page
private String REFERENCE_NAME;
//Name Displayed in the index page
public String INDEX_NAME;
public boolean hasIndexButton = false;
public static final ResourceLocation PAGE_TEXTURE = new ResourceLocation("techreborn:textures/manual/gui/manual.png");
private final int xSize = 146;
private final int ySize = 180;
protected PageCollection collection;
public BasePage() {
}
public BasePage(String referenceName, PageCollection collection) {
this.REFERENCE_NAME = referenceName;
this.mc = Minecraft.getMinecraft();
this.collection = collection;
initGui();
}
public BasePage(String referenceName, boolean showInMenue, PageCollection collection) {
this(referenceName, collection);
this.hasIndexButton = showInMenue;
}
public int getXMin() {
return (this.width - xSize) / 2;
}
public int getYMin() {
return (this.height - ySize) / 2;
}
public void setXMin(int x) {
this.width = x;
}
public void setYMin(int y) {
this.height = y;
}
//Unlocalized Index Page Name
public BasePage setIndexName(String unlocalizedName) {
this.INDEX_NAME = ttl(unlocalizedName);
return this;
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
buttonList.clear();
buttonList.add(new GuiButton(0, getXMin() + 30, getYMin() + 150, 80, 16, ttl("techreborn.manual.backbutton")));
}
public void setReferenceName(String name) {
REFERENCE_NAME = name;
}
public String getReferenceName() {
return REFERENCE_NAME;
}
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
minecraft.renderEngine.bindTexture(PAGE_TEXTURE);
drawTexturedModalRect(offsetX, offsetY, 0, 0, xSize, ySize);
}
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
}
public void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.drawScreen(mouseX + offsetX, mouseY + offsetY, 0);
renderOverlayComponents(minecraft, offsetX, offsetY, mouseX, mouseY);
}
@Override
public void actionPerformed(GuiButton button) {
if (button.id == 0) collection.changeActivePage("CONTENTS");
}
@Override
public void mouseClicked(int par1, int par2, int par3) throws IOException {
super.mouseClicked(par1, par2, par3);
}
//Translate To Local
public String ttl(String unlocalizedName) {
return StatCollector.translateToLocal(unlocalizedName);
}
}

View file

@ -0,0 +1,43 @@
package techreborn.manual.pages;
import java.awt.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.item.ItemStack;
import techreborn.config.TechRebornConfigGui;
import techreborn.init.ModBlocks;
import techreborn.init.ModItems;
import techreborn.items.ItemPlates;
import techreborn.manual.PageCollection;
import techreborn.manual.Reference;
import techreborn.manual.util.GuiButtonCustomTexture;
public class ContentsPage extends TitledPage
{
public ContentsPage(String name, PageCollection collection)
{
super(name, false, collection, Reference.CONTENTS_KEY, Color.white.getRGB());
}
@SuppressWarnings("unchecked")
@Override
public void initGui()
{
buttonList.clear();
buttonList.add(new GuiButtonCustomTexture(0, getXMin() + 25, getYMin() + 20, 0, 46, 100, 20, ItemPlates.getPlateByName("iron"),
Reference.pageNames.GETTINGSTARTED_PAGE, ttl(Reference.GETTINGSTARTED_KEY)));
}
@Override
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY)
{
super.renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
}
@Override
public void actionPerformed(GuiButton button)
{
if (button.id == 0) collection.changeActivePage(Reference.pageNames.GETTINGSTARTED_PAGE);
}
}

View file

@ -0,0 +1,106 @@
package techreborn.manual.pages;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import techreborn.manual.PageCollection;
import techreborn.manual.Reference;
public class DescriptionPage extends TitledPage
{
public boolean hasImage;
private String rawDescription;
private List<String> formattedDescription;
private float descriptionScale = 0.88f;
public String imageprefix = "techreborn:textures/manual/screenshots/";
public DescriptionPage(String name, PageCollection collection, boolean hasImage)
{
super(name, false, collection, Reference.GETTINGSTARTED_KEY, Color.white.getRGB());
this.hasImage = hasImage;
this.rawDescription = "techreborn.manual." + this.getReferenceName() + ".description";
}
@Override
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY)
{
if(hasImage)
{
renderImage(offsetX, offsetY);
addDescription(mc, offsetX, offsetY + 50);
}
else
addDescription(mc, offsetX, offsetY);
}
public void renderImage(int offsetX, int offsetY)
{
TextureManager render = Minecraft.getMinecraft().renderEngine;
render.bindTexture(new ResourceLocation(imageprefix + this.getReferenceName() + ".png"));
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1F, 1F, 1F, 1F);
drawTexturedModalRect(offsetX, offsetY - 16, 0, 0, 120, this.height);
GL11.glDisable(GL11.GL_BLEND);
}
public void addDescription(Minecraft minecraft, int offsetX, int offsetY)
{
GL11.glPushMatrix();
GL11.glTranslated(offsetX + 15, offsetY + 40, 1);
GL11.glScalef(descriptionScale, descriptionScale, descriptionScale);
int offset = 0;
for (String s : getFormattedText(fontRendererObj))
{
if (s == null) break;
if (s.contains("\\%") && s.substring(0, 2).equals("\\%"))
{
s = s.substring(2);
offset += fontRendererObj.FONT_HEIGHT / 2;
}
fontRendererObj.drawString(s, 0, offset, Color.black.getRGB());
offset += fontRendererObj.FONT_HEIGHT;
}
GL11.glPopMatrix();
}
@SuppressWarnings("unchecked")
public List<String> getFormattedText(FontRenderer fr)
{
if (formattedDescription == null)
{
formattedDescription = new ArrayList<String>();
if (Strings.isNullOrEmpty(rawDescription))
{
formattedDescription = ImmutableList.of();
return formattedDescription;
}
if (!rawDescription.contains("\\n"))
{
formattedDescription = ImmutableList.copyOf(fr.listFormattedStringToWidth(rawDescription, 130));
return formattedDescription;
}
List<String> segments = new ArrayList();
String raw = rawDescription;
for (String s : segments)
formattedDescription.addAll(ImmutableList.copyOf(fr.listFormattedStringToWidth(s, 370)));
}
return formattedDescription;
}
}

View file

@ -0,0 +1,32 @@
package techreborn.manual.pages;
import java.awt.Color;
import net.minecraft.client.gui.GuiButton;
import techreborn.items.ItemParts;
import techreborn.items.ItemPlates;
import techreborn.manual.PageCollection;
import techreborn.manual.Reference;
import techreborn.manual.util.GuiButtonCustomTexture;
public class GettingStartedPage extends TitledPage
{
public GettingStartedPage(String name, PageCollection collection)
{
super(name, false, collection, Reference.GETTINGSTARTED_KEY, Color.white.getRGB());
}
@Override
public void initGui()
{
buttonList.clear();
buttonList.add(new GuiButtonCustomTexture(0, getXMin() + 25, getYMin() + 20, 0, 46, 100, 20, ItemParts.getPartByName("rubberSap"),
Reference.pageNames.GETTINGRUBBER_PAGE, ttl(Reference.GETTINGRUBBER_KEY)));
}
@Override
public void actionPerformed(GuiButton button)
{
if (button.id == 0) collection.changeActivePage(Reference.pageNames.GETTINGRUBBER_PAGE);
}
}

View file

@ -0,0 +1,22 @@
package techreborn.manual.pages;
import net.minecraft.client.Minecraft;
import techreborn.manual.PageCollection;
public class TitledPage extends BasePage {
private String title;
public boolean drawTitle = true;
private int colour;
public TitledPage(String name, boolean showInMenue, PageCollection collection, String unlocalizedTitle, int colour) {
super(name, showInMenue, collection);
this.title = unlocalizedTitle;
this.colour = colour;
}
@Override
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
if (title == null) title = INDEX_NAME;
if (drawTitle) drawCenteredString(minecraft.fontRendererObj, ttl(title), offsetX + 70, offsetY + 10, colour);
}
}

View file

@ -0,0 +1,48 @@
package techreborn.manual.util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
import org.lwjgl.opengl.GL11;
public class GuiButtonAHeight extends GuiButton {
public GuiButtonAHeight(int id, int xPos, int yPos, int width, int hight, String displayString) {
super(id, xPos, yPos, width, hight, displayString);
}
@Override
public void drawButton(Minecraft minecraft, int mouseX, int mouseY) {
if (this.visible) {
FontRenderer fontrenderer = minecraft.fontRendererObj;
minecraft.getTextureManager().bindTexture(buttonTextures);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
int k = this.getHoverState(this.hovered);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height);
if (this.height < 20) {
this.drawTexturedModalRect(xPosition, yPosition + 3, 0, (46 + k * 20) + 20 - height + 3, width / 2, height - 3);
this.drawTexturedModalRect(xPosition + width / 2, yPosition + 3, 200 - width / 2, (46 + k * 20) + 20 - height + 3, width / 2, height - 3);
}
this.mouseDragged(minecraft, mouseX, mouseY);
int l = 14737632;
if (packedFGColour != 0) {
l = packedFGColour;
} else if (!this.enabled) {
l = 10526880;
} else if (this.hovered) {
l = 16777120;
}
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l);
}
}
}

View file

@ -0,0 +1,59 @@
package techreborn.manual.util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.client.config.GuiButtonExt;
import org.lwjgl.opengl.GL11;
import java.awt.*;
public class GuiButtonCustomTexture extends GuiButtonExt {
public int textureU;
public int textureV;
public ItemStack itemstack;
public String LINKED_PAGE;
public String NAME;
public GuiButtonCustomTexture(int id, int xPos, int yPos, int u, int v, int width, int height, ItemStack stack, String linkedPage, String name) {
super(id, xPos, yPos, width, height, "_");
textureU = u;
textureV = v;
itemstack = stack;
NAME = name;
this.LINKED_PAGE = linkedPage;
}
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if (this.visible) {
boolean flag = mouseX >= this.xPosition && mouseY >= this.yPosition
&& mouseX < this.xPosition + this.width
&& mouseY < this.yPosition + this.height;
mc.getTextureManager().bindTexture(buttonTextures);
int u = textureU;
int v = textureV;
if (flag) {
u += width;
GL11.glPushMatrix();
GL11.glColor4f(0f, 0f, 0f, 1f);
this.drawTexturedModalRect(this.xPosition, this.yPosition, u, v, width, height);
GL11.glPopMatrix();
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(32826);
RenderHelper.enableStandardItemLighting();
RenderHelper.enableGUIStandardItemLighting();
RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
itemRenderer.renderItemIntoGUI(itemstack, this.xPosition, this.yPosition);
this.drawString(mc.fontRendererObj, this.NAME, this.xPosition + 20, this.yPosition + 3, Color.white.getRGB());
}
}
public boolean getIsHovering() {
return hovered;
}
}

View file

@ -0,0 +1,63 @@
package techreborn.manual.util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.opengl.GL11;
import java.awt.*;
public class GuiButtonTextOnly extends GuiButton {
public String LINKED_PAGE;
public int textColour;
public GuiButtonTextOnly(int id, int xPos, int yPos, int width, int hight, String displayString, String linkedPage, int colour) {
super(id, xPos, yPos, width, hight, displayString);
this.LINKED_PAGE = linkedPage;
this.textColour = colour;
}
@Override
public void drawButton(Minecraft minecraft, int mouseX, int mouseY) {
if (this.visible) {
FontRenderer fontrenderer = minecraft.fontRendererObj;
minecraft.getTextureManager().bindTexture(buttonTextures);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.mouseDragged(minecraft, mouseX, mouseY);
String trimmedDisplayString = displayString;
if (fontrenderer.getStringWidth(displayString) > width + 30 && !this.hovered) {
int energencyBreak = 0;
while (fontrenderer.getStringWidth(trimmedDisplayString) * 0.7 > width - 5) {
trimmedDisplayString = trimmedDisplayString.substring(0, trimmedDisplayString.length() - 1);
energencyBreak++;
if (energencyBreak > 100) break;
}
trimmedDisplayString += "...";
}
if (this.hovered) {
trimmedDisplayString = EnumChatFormatting.BOLD + "" + EnumChatFormatting.ITALIC + trimmedDisplayString;
GL11.glPushMatrix();
GL11.glColor4f(0f, 0f, 0f, 1f);
drawTexturedModalRect(xPosition + (int) (xPosition * 0.01), yPosition + (int) (yPosition * 0.01), 0, 46, (int) (fontrenderer.getStringWidth(trimmedDisplayString) * 0.72) + 2, 8);
GL11.glPopMatrix();
}
GL11.glPushMatrix();
GL11.glScalef(0.7F, 0.7F, 1);
fontrenderer.drawString(trimmedDisplayString, (int) (xPosition * 1.45), (int) ((yPosition + (height - 8) / 2) * 1.45), Color.WHITE.getRGB());
GL11.glPopMatrix();
}
}
public boolean getIsHovering() {
return hovered;
}
}