mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Finished crafting page.
This commit is contained in:
parent
12abe6f6f6
commit
24e2a9e88d
10 changed files with 91 additions and 34 deletions
|
@ -75,9 +75,10 @@ public final class InitBooklet{
|
|||
if(!ActuallyAdditionsAPI.ALL_CHAPTERS.contains(chapter)){
|
||||
ActuallyAdditionsAPI.ALL_CHAPTERS.add(chapter);
|
||||
chapCount++;
|
||||
}
|
||||
|
||||
for(IBookletPage page : chapter.getAllPages()){
|
||||
pageCount++;
|
||||
|
||||
List<ItemStack> items = page.getItemStacksForPage();
|
||||
List<FluidStack> fluids = page.getFluidStacksForPage();
|
||||
|
||||
|
@ -87,8 +88,7 @@ public final class InitBooklet{
|
|||
infoCount++;
|
||||
}
|
||||
}
|
||||
|
||||
pageCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
|||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
@ -56,6 +57,7 @@ public abstract class GuiBooklet extends GuiBookletBase{
|
|||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks){
|
||||
GlStateManager.color(1F, 1F, 1F);
|
||||
this.mc.getTextureManager().bindTexture(RES_LOC_GUI);
|
||||
drawModalRectWithCustomSizedTexture(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize, 512, 512);
|
||||
|
||||
|
|
|
@ -12,13 +12,17 @@ package de.ellpeck.actuallyadditions.mod.booklet.gui;
|
|||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.button.EntryButton;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
@ -27,11 +31,13 @@ public class GuiEntry extends GuiBooklet{
|
|||
//The page in the entry. Say you have 2 more chapters than fit on one double page, then those 2 would be displayed on entryPage 1 instead.
|
||||
private final int entryPage;
|
||||
private final IBookletEntry entry;
|
||||
private final List<IBookletChapter> chapters;
|
||||
|
||||
public GuiEntry(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletEntry entry, int entryPage){
|
||||
super(previousScreen, parentPage);
|
||||
this.entryPage = entryPage;
|
||||
this.entry = entry;
|
||||
this.chapters = entry.getChaptersForGuiDisplaying(this, null /*TODO Insert search bar text here*/);
|
||||
}
|
||||
|
||||
public GuiEntry(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletEntry entry, IBookletChapter chapterForPageCalc){
|
||||
|
@ -48,12 +54,11 @@ public class GuiEntry extends GuiBooklet{
|
|||
super.initGui();
|
||||
|
||||
int idOffset = this.entryPage*(BUTTONS_PER_PAGE*2);
|
||||
List<IBookletChapter> chapters = this.entry.getChaptersForGuiDisplaying(this, null /*TODO Insert search bar text here*/);
|
||||
for(int x = 0; x < 2; x++){
|
||||
for(int y = 0; y < BUTTONS_PER_PAGE; y++){
|
||||
int id = y+x*BUTTONS_PER_PAGE;
|
||||
if(chapters.size() > id+idOffset){
|
||||
IBookletChapter chapter = chapters.get(id+idOffset);
|
||||
if(this.chapters.size() > id+idOffset){
|
||||
IBookletChapter chapter = this.chapters.get(id+idOffset);
|
||||
this.buttonList.add(new EntryButton(id, this.guiLeft+14+x*142, this.guiTop+11+y*13, 115, 10, chapter.getLocalizedNameWithFormatting(), chapter.getDisplayItemStack()));
|
||||
}
|
||||
else{
|
||||
|
@ -63,6 +68,26 @@ public class GuiEntry extends GuiBooklet{
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException{
|
||||
if(button instanceof EntryButton){
|
||||
int actualId = button.id+this.entryPage*(BUTTONS_PER_PAGE*2);
|
||||
|
||||
if(this.chapters.size() > actualId){
|
||||
IBookletChapter chapter = this.chapters.get(actualId);
|
||||
if(chapter != null){
|
||||
IBookletPage[] pages = chapter.getAllPages();
|
||||
if(pages != null && pages.length > 0){
|
||||
this.mc.displayGuiScreen(BookletUtils.createPageGui(this.previousScreen, this, pages[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
super.actionPerformed(button);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer){
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class GuiMainPage extends GuiBooklet{
|
|||
if(ActuallyAdditionsAPI.BOOKLET_ENTRIES.size() > button.id){
|
||||
IBookletEntry entry = ActuallyAdditionsAPI.BOOKLET_ENTRIES.get(button.id);
|
||||
if(entry != null){
|
||||
this.mc.displayGuiScreen(new GuiEntry(null, this, entry, 0));
|
||||
this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, this, entry, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
|
|||
import de.ellpeck.actuallyadditions.mod.booklet.page.ItemDisplay;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
@ -111,6 +112,15 @@ public class GuiPage extends GuiBooklet{
|
|||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks){
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
|
||||
for(int i = 0; i < this.pages.length; i++){
|
||||
IBookletPage page = this.pages[i];
|
||||
if(page != null){
|
||||
GlStateManager.color(1F, 1F, 1F);
|
||||
page.drawScreenPre(this, this.guiLeft+6+i*142, this.guiTop+7, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
for(ItemDisplay display : this.itemDisplays){
|
||||
display.drawPre();
|
||||
}
|
||||
|
@ -118,22 +128,13 @@ public class GuiPage extends GuiBooklet{
|
|||
for(int i = 0; i < this.pages.length; i++){
|
||||
IBookletPage page = this.pages[i];
|
||||
if(page != null){
|
||||
page.drawScreenPre(this, this.guiLeft+6+i*142, this.guiTop+7, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
|
||||
for(ItemDisplay display : this.itemDisplays){
|
||||
display.drawPost(mouseX, mouseY);
|
||||
}
|
||||
|
||||
for(int i = 0; i < this.pages.length; i++){
|
||||
IBookletPage page = this.pages[i];
|
||||
if(page != null){
|
||||
GlStateManager.color(1F, 1F, 1F);
|
||||
page.drawScreenPost(this, this.guiLeft+6+i*142, this.guiTop+7, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
for(ItemDisplay display : this.itemDisplays){
|
||||
display.drawPost(mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,6 +19,7 @@ import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
|||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
|
|
@ -11,13 +11,19 @@
|
|||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
|
@ -26,6 +32,7 @@ import java.util.List;
|
|||
|
||||
public class PageCrafting extends BookletPage{
|
||||
|
||||
private String recipeTypeLocKey;
|
||||
private boolean isWildcard;
|
||||
private final List<IRecipe> recipes;
|
||||
|
||||
|
@ -43,6 +50,19 @@ public class PageCrafting extends BookletPage{
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){
|
||||
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
|
||||
|
||||
gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS);
|
||||
GuiUtils.drawTexturedModalRect(startX+5, startY+6, 20, 0, 116, 54, 0);
|
||||
|
||||
gui.renderScaledAsciiString("("+StringUtil.localize(this.recipeTypeLocKey)+")", startX+6, startY+65, 0, false, 0.65F);
|
||||
|
||||
PageTextOnly.renderTextToPage(gui, this, startX+6, startY+80);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(GuiBookletBase gui, int startX, int startY){
|
||||
super.initGui(gui, startX, startY);
|
||||
|
@ -87,12 +107,14 @@ public class PageCrafting extends BookletPage{
|
|||
width = shaped.recipeWidth;
|
||||
height = shaped.recipeHeight;
|
||||
stacks = shaped.recipeItems;
|
||||
this.recipeTypeLocKey = "booklet."+ModUtil.MOD_ID+".shapedRecipe";
|
||||
}
|
||||
else if(recipe instanceof ShapelessRecipes){
|
||||
ShapelessRecipes shapeless = (ShapelessRecipes)recipe;
|
||||
for(int i = 0; i < shapeless.recipeItems.size(); i++){
|
||||
stacks[i] = shapeless.recipeItems.get(i);
|
||||
}
|
||||
this.recipeTypeLocKey = "booklet."+ModUtil.MOD_ID+".shapelessRecipe";
|
||||
}
|
||||
else if(recipe instanceof ShapedOreRecipe){
|
||||
ShapedOreRecipe shaped = (ShapedOreRecipe)recipe;
|
||||
|
@ -109,6 +131,7 @@ public class PageCrafting extends BookletPage{
|
|||
stacks[i] = input instanceof ItemStack ? (ItemStack)input : (((List<ItemStack>)input).isEmpty() ? null : ((List<ItemStack>)input).get(0));
|
||||
}
|
||||
}
|
||||
this.recipeTypeLocKey = "booklet."+ModUtil.MOD_ID+".shapedOreRecipe";
|
||||
}
|
||||
else if(recipe instanceof ShapelessOreRecipe){
|
||||
ShapelessOreRecipe shapeless = (ShapelessOreRecipe)recipe;
|
||||
|
@ -116,6 +139,7 @@ public class PageCrafting extends BookletPage{
|
|||
Object input = shapeless.getInput().get(i);
|
||||
stacks[i] = input instanceof ItemStack ? (ItemStack)input : (((List<ItemStack>)input).isEmpty() ? null : ((List<ItemStack>)input).get(0));
|
||||
}
|
||||
this.recipeTypeLocKey = "booklet."+ModUtil.MOD_ID+".shapelessOreRecipe";
|
||||
}
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
|
@ -128,11 +152,11 @@ public class PageCrafting extends BookletPage{
|
|||
copy.setItemDamage(0);
|
||||
}
|
||||
|
||||
gui.addItemRenderer(stack, startX+10+x*18, startY+10+y*18, 1F, true);
|
||||
gui.addItemRenderer(copy, startX+6+x*18, startY+7+y*18, 1F, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gui.addItemRenderer(recipe.getRecipeOutput(), startX+50, startY+50, 1F, false);
|
||||
gui.addItemRenderer(recipe.getRecipeOutput(), startX+100, startY+25, 1F, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -22,12 +23,16 @@ public class PageTextOnly extends BookletPage{
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void drawScreenPost(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){
|
||||
super.drawScreenPost(gui, startX, startY, mouseX, mouseY, partialTicks);
|
||||
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){
|
||||
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
|
||||
renderTextToPage(gui, this, startX+6, startY+5);
|
||||
}
|
||||
|
||||
String text = this.getInfoText();
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void renderTextToPage(GuiBookletBase gui, BookletPage page, int x, int y){
|
||||
String text = page.getInfoText();
|
||||
if(text != null && !text.isEmpty()){
|
||||
gui.renderSplitScaledAsciiString(text, startX+6, startY+5, 0, false, 0.75F, 120);
|
||||
gui.renderSplitScaledAsciiString(text, x, y, 0, false, 0.75F, 120);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,6 @@ public final class StringUtil{
|
|||
return "";
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void renderScaledAsciiString(FontRenderer font, String text, int x, int y, int color, boolean shadow, float scale){
|
||||
GlStateManager.pushMatrix();
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.7 KiB |
Loading…
Reference in a new issue