From ac6cf7c3bc80f7f639e72a0e8cb4fc06a57c8831 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 12 Jun 2016 13:39:26 +0200 Subject: [PATCH] Added video introduction page --- .../api/ActuallyAdditionsAPI.java | 2 +- .../api/booklet/BookletPage.java | 13 +++++ .../api/internal/IBookletGui.java | 7 ++- .../mod/booklet/BookletUtils.java | 15 +++++- .../mod/booklet/GuiBooklet.java | 23 ++++++--- .../mod/booklet/InitBooklet.java | 1 + .../mod/booklet/page/PageButton.java | 46 ++++++++++++++++++ .../mod/booklet/page/PageLinkButton.java | 29 +++++++++++ .../actuallyadditions/mod/items/ItemMisc.java | 5 +- .../mod/items/metalists/TheMiscItems.java | 4 +- .../mod/jei/JEIActuallyAdditionsPlugin.java | 2 + .../assets/actuallyadditions/lang/en_US.lang | 6 ++- .../models/item/itemMiscYoutubeIcon.json | 6 +++ .../textures/items/itemMiscYoutubeIcon.png | Bin 0 -> 355 bytes 14 files changed, 146 insertions(+), 13 deletions(-) create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageButton.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java create mode 100644 src/main/resources/assets/actuallyadditions/models/item/itemMiscYoutubeIcon.json create mode 100644 src/main/resources/assets/actuallyadditions/textures/items/itemMiscYoutubeIcon.png diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java index ee19c33d9..9afc96cee 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java @@ -30,7 +30,7 @@ public class ActuallyAdditionsAPI{ public static final String MOD_ID = "actuallyadditions"; public static final String API_ID = MOD_ID+"api"; - public static final String API_VERSION = "15"; + public static final String API_VERSION = "16"; public static final List CRUSHER_RECIPES = new ArrayList(); public static final List BALL_OF_FUR_RETURN_ITEMS = new ArrayList(); public static final List TREASURE_CHEST_LOOT = new ArrayList(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/BookletPage.java b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/BookletPage.java index e8842732a..bc8aaee35 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/BookletPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/BookletPage.java @@ -11,6 +11,7 @@ package de.ellpeck.actuallyadditions.api.booklet; import de.ellpeck.actuallyadditions.api.internal.IBookletGui; +import net.minecraft.client.gui.GuiButton; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -20,6 +21,18 @@ public abstract class BookletPage{ public boolean arePageStacksWildcard; protected IBookletChapter chapter; + public void onOpened(IBookletGui gui){ + + } + + public void onClosed(IBookletGui gui){ + + } + + public boolean onActionPerformed(IBookletGui gui, GuiButton button){ + return false; + } + /** * The ID of the page, for the page number etc. * Don't make two pages in the same chapter with the same ID. diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IBookletGui.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IBookletGui.java index 8c4f20ff7..ca92ace10 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IBookletGui.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IBookletGui.java @@ -11,10 +11,13 @@ package de.ellpeck.actuallyadditions.api.internal; import de.ellpeck.actuallyadditions.api.booklet.BookletPage; +import net.minecraft.client.gui.GuiButton; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import java.util.List; + /** * This is a helper interface for BookletPage * This is not supposed to be implemented. @@ -27,7 +30,7 @@ public interface IBookletGui{ * This method should be used when drawing an ItemStack to a booklet page * It displays the hoverover text of the item and also contains the "show more info"-text and clickable part * - * @param renderTransferButton if the "show more info"-text and clickable part should exist- + * @param renderTransferButton if the "show more info"-text and clickable part should exist */ @SideOnly(Side.CLIENT) void renderTooltipAndTransferButton(BookletPage from, ItemStack stack, int x, int y, boolean renderTransferButton, boolean mousePressed); @@ -43,4 +46,6 @@ public interface IBookletGui{ void drawRect(int startX, int startY, int u, int v, int xSize, int ySize); IEntrySet getCurrentEntrySet(); + + List getButtonList(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/BookletUtils.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/BookletUtils.java index 06f117d39..6f692eab6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/BookletUtils.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/BookletUtils.java @@ -249,6 +249,9 @@ public class BookletUtils{ } } + if(booklet.currentEntrySet.getCurrentPage() != null){ + booklet.currentEntrySet.getCurrentPage().onClosed(booklet); + } booklet.currentEntrySet.setPage(null); booklet.currentEntrySet.setChapter(null); @@ -325,7 +328,13 @@ public class BookletUtils{ booklet.searchField.setText(""); booklet.currentEntrySet.setChapter(chapter); - booklet.currentEntrySet.setPage(page != null && doesChapterHavePage(chapter, page) ? page : chapter.getPages()[0]); + + if(booklet.currentEntrySet.getCurrentPage() != null){ + booklet.currentEntrySet.getCurrentPage().onClosed(booklet); + } + BookletPage pageToSet = page != null && doesChapterHavePage(chapter, page) ? page : chapter.getPages()[0]; + booklet.currentEntrySet.setPage(pageToSet); + pageToSet.onOpened(booklet); booklet.buttonForward.visible = getNextPage(chapter, booklet.currentEntrySet.getCurrentPage()) != null; booklet.buttonBackward.visible = getPrevPage(chapter, booklet.currentEntrySet.getCurrentPage()) != null; @@ -386,7 +395,9 @@ public class BookletUtils{ if(booklet.currentEntrySet.getCurrentPage() != null){ BookletPage page = getNextPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()); if(page != null){ + booklet.currentEntrySet.getCurrentPage().onClosed(booklet); booklet.currentEntrySet.setPage(page); + page.onOpened(booklet); } booklet.buttonForward.visible = getNextPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()) != null; @@ -408,7 +419,9 @@ public class BookletUtils{ if(booklet.currentEntrySet.getCurrentPage() != null){ BookletPage page = getPrevPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()); if(page != null){ + booklet.currentEntrySet.getCurrentPage().onClosed(booklet); booklet.currentEntrySet.setPage(page); + page.onOpened(booklet); } booklet.buttonForward.visible = getNextPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()) != null; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/GuiBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/GuiBooklet.java index 3b9e272ff..c9abd2e72 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/GuiBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/GuiBooklet.java @@ -101,6 +101,7 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{ return this.fontRendererObj; } + @Override public List getButtonList(){ return this.buttonList; } @@ -143,8 +144,15 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{ //Pre-Renders the current page's content etc. BookletUtils.renderPre(this, x, y, this.ticksElapsed, this.mousePressed); - //Does vanilla drawing stuff - super.drawScreen(x, y, f); + //Buttons and search field + if(this.currentEntrySet.getCurrentPage() != null){ + this.fontRendererObj.setUnicodeFlag(false); + } + for(GuiButton button : this.buttonList){ + button.drawButton(this.mc, x, y); + } + this.fontRendererObj.setUnicodeFlag(true); + this.searchField.drawTextBox(); //Renders the current page's content @@ -156,14 +164,11 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{ this.fontRendererObj.setUnicodeFlag(false); BookletUtils.doHoverTexts(this, x, y); BookletUtils.drawAchievementInfo(this, false, x, y); - this.fontRendererObj.setUnicodeFlag(true); this.fontRendererObj.setUnicodeFlag(unicodeBefore); //Resets mouse - if(this.mousePressed){ - this.mousePressed = false; - } + this.mousePressed = false; } @Override @@ -224,6 +229,12 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{ @Override public void actionPerformed(GuiButton button){ + if(this.currentEntrySet.getCurrentPage() != null){ + if(this.currentEntrySet.getCurrentPage().onActionPerformed(this, button)){ + return; + } + } + //Handles update if(button == this.buttonUpdate){ if(UpdateChecker.needsUpdateNotify){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java index 4543ce866..caa398885 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java @@ -61,6 +61,7 @@ public class InitBooklet{ private static void initChapters(){ //Getting Started chapterIntro = new BookletChapter("intro", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemBooklet), new PageTextOnly(1), new PageTextOnly(2), new PageTextOnly(3)); + new BookletChapter("videoGuide", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.YOUTUBE_ICON.ordinal()), new PageLinkButton(1, "https://www.youtube.com/watch?v=fhjz0Ew56pM")).setImportant(); new BookletChapter("bookTutorial", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemBooklet), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, ItemCrafting.recipeBook)); new BookletChapter("crystals", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockAtomicReconstructor), new PageTextOnly(1).addTextReplacement("", TileEntityAtomicReconstructor.ENERGY_USE), new PageTextOnly(2), new PageTextOnly(3), new PagePicture(4, "pageAtomicReconstructor", 0).setNoText(), new PageTextOnly(5), new PageCrafting(6, BlockCrafting.recipeAtomicReconstructor).setPageStacksWildcard(), new PageCrafting(7, MiscCrafting.recipesCrystals).setNoText(), new PageCrafting(8, MiscCrafting.recipesCrystalBlocks).setNoText(), new PageReconstructor(9, LensRecipeHandler.mainPageRecipes).setNoText()).setSpecial(); new BookletChapter("coalGen", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockCoalGenerator), new PageCrafting(1, BlockCrafting.recipeCoalGen).addTextReplacement("", TileEntityCoalGenerator.PRODUCE).setPageStacksWildcard()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageButton.java new file mode 100644 index 000000000..a30b06d7f --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageButton.java @@ -0,0 +1,46 @@ +/* + * This file ("PageButton.java") is part of the Actually Additions mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://ellpeck.de/actaddlicense + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015-2016 Ellpeck + */ + +package de.ellpeck.actuallyadditions.mod.booklet.page; + +import de.ellpeck.actuallyadditions.api.internal.IBookletGui; +import de.ellpeck.actuallyadditions.mod.util.ModUtil; +import de.ellpeck.actuallyadditions.mod.util.StringUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; + +public abstract class PageButton extends PageTextOnly{ + + private GuiButton button; + + public PageButton(int id){ + super(id); + } + + @Override + public void onOpened(IBookletGui gui){ + String text = StringUtil.localize("booklet."+ModUtil.MOD_ID+".chapter."+this.chapter.getUnlocalizedName()+".page."+this.localizationKey+".button"); + int width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(text); + this.button = new GuiButton(-1239, gui.getGuiLeft()+gui.getXSize()/2-width/2-8, gui.getGuiTop()+gui.getYSize()-40, width+15, 20, text); + gui.getButtonList().add(this.button); + } + + @Override + public void onClosed(IBookletGui gui){ + gui.getButtonList().remove(this.button); + } + + @Override + public boolean onActionPerformed(IBookletGui gui, GuiButton button){ + return button == this.button && this.onAction(); + } + + public abstract boolean onAction(); +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java new file mode 100644 index 000000000..8bf1cd4b9 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java @@ -0,0 +1,29 @@ +/* + * This file ("PageYoutubeButton.java") is part of the Actually Additions mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://ellpeck.de/actaddlicense + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015-2016 Ellpeck + */ + +package de.ellpeck.actuallyadditions.mod.booklet.page; + +import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils; + +public class PageLinkButton extends PageButton{ + + private String link; + + public PageLinkButton(int id, String link){ + super(id); + this.link = link; + } + + @Override + public boolean onAction(){ + BookletUtils.openBrowser(this.link); + return true; + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java index 7b3f358d0..d13099d81 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java @@ -38,7 +38,6 @@ public class ItemMisc extends ItemBase{ return damage; } - @Override public String getUnlocalizedName(ItemStack stack){ return stack.getItemDamage() >= allMiscItems.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+allMiscItems[stack.getItemDamage()].name; @@ -54,7 +53,9 @@ public class ItemMisc extends ItemBase{ @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs tab, List list){ for(int j = 0; j < allMiscItems.length; j++){ - list.add(new ItemStack(this, 1, j)); + if(j != TheMiscItems.YOUTUBE_ICON.ordinal()){ + list.add(new ItemStack(this, 1, j)); + } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheMiscItems.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheMiscItems.java index ab1fc0009..0ad74b899 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheMiscItems.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheMiscItems.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.items.metalists; +import de.ellpeck.actuallyadditions.mod.util.Util; import net.minecraft.item.EnumRarity; public enum TheMiscItems{ @@ -34,7 +35,8 @@ public enum TheMiscItems{ BLACK_DYE("BlackDye", EnumRarity.EPIC), LENS("Lens", EnumRarity.UNCOMMON), ENDER_STAR("EnderStar", EnumRarity.EPIC), - SPAWNER_SHARD("SpawnerShard", EnumRarity.EPIC); + SPAWNER_SHARD("SpawnerShard", EnumRarity.EPIC), + YOUTUBE_ICON("YoutubeIcon", Util.FALLBACK_RARITY); public final String name; public final EnumRarity rarity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java index 9a30b8483..472a46e63 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java @@ -17,6 +17,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCoffeeMachine; import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFurnaceDouble; import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiGrinder; import de.ellpeck.actuallyadditions.mod.items.InitItems; +import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.jei.booklet.BookletRecipeCategory; import de.ellpeck.actuallyadditions.mod.jei.booklet.BookletRecipeHandler; import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineRecipeCategory; @@ -84,6 +85,7 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin{ blacklist.addItemToBlacklist(new ItemStack(InitBlocks.blockCoffee)); blacklist.addItemToBlacklist(new ItemStack(InitBlocks.blockWildPlant, 1, Util.WILDCARD)); blacklist.addItemToBlacklist(new ItemStack(InitBlocks.blockColoredLampOn, 1, Util.WILDCARD)); + blacklist.addItemToBlacklist(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.YOUTUBE_ICON.ordinal())); IRecipeTransferRegistry transfer = registry.getRecipeTransferRegistry(); transfer.addRecipeTransferHandler(ContainerCrafter.class, VanillaRecipeCategoryUid.CRAFTING, 1, 9, 10, 36); diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index ab1a733ea..264ee9924 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -899,4 +899,8 @@ booklet.actuallyadditions.chapter.displayStand.text.1=The Display Stand booklet.actuallyadditions.chapter.displayStand.text.2=The Leaf Blower and Advanced Leaf Blower can be placed onto the display stand, resulting in the grass and leaves around it to be blown away. Potion Rings can be placed onto the display stand. The normal version will give the specified potion effect to only one living entity in a small area, while the advanced version will give a potion effect to all living entities in a big area while using up a significant amount of RF. booklet.actuallyadditions.chapter.itemFilter.name=Item Filter -booklet.actuallyadditions.chapter.itemFilter.text.1=The Item Filter can be used in Advanced Item Laser Relays, ESDs and Ranged Collectors to enlargen the size of their whitelist. This can be done by right-clicking with the filter in hand and placing items to be filtered inside of it. The filter can then be placed into any whitelist slot in the desired machine. For more information on this, hover over the whitelist buttons in the GUIs of whitelistable machines! \ No newline at end of file +booklet.actuallyadditions.chapter.itemFilter.text.1=The Item Filter can be used in Advanced Item Laser Relays, ESDs and Ranged Collectors to enlargen the size of their whitelist. This can be done by right-clicking with the filter in hand and placing items to be filtered inside of it. The filter can then be placed into any whitelist slot in the desired machine. For more information on this, hover over the whitelist buttons in the GUIs of whitelistable machines! + +booklet.actuallyadditions.chapter.videoGuide.name=A Video Guide +booklet.actuallyadditions.chapter.videoGuide.text.1=If you are a bit confused as to what is going on or just want to get a glimpse of what Actually Additions has to offer, there is this brilliant video by a guy called Booty Toast (yes, that is a weird name), that shows off what is possible in a really enjoyable way. Just click the button to have the video opened on YouTube! Give it a watch! +booklet.actuallyadditions.chapter.videoGuide.page.1.button=Watch Video \ No newline at end of file diff --git a/src/main/resources/assets/actuallyadditions/models/item/itemMiscYoutubeIcon.json b/src/main/resources/assets/actuallyadditions/models/item/itemMiscYoutubeIcon.json new file mode 100644 index 000000000..0c1d55470 --- /dev/null +++ b/src/main/resources/assets/actuallyadditions/models/item/itemMiscYoutubeIcon.json @@ -0,0 +1,6 @@ +{ + "parent": "actuallyadditions:item/standardItem", + "textures": { + "layer0": "actuallyadditions:items/itemMiscYoutubeIcon" + } +} diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemMiscYoutubeIcon.png b/src/main/resources/assets/actuallyadditions/textures/items/itemMiscYoutubeIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..ea9c8ab15f9e1048d84172ea1b9216dbe2038182 GIT binary patch literal 355 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzmUKs7M+SzC{oH>NS%G}c0*}aI z1_r)8Aj~**Pmw23P@=>&q9iy!t)x7$D3zfgF*C13FE6!3!9>qM&oalj&JU>Op{I*u zNQC>_s|T|VIS3s4_+D3MtcZ1HnE?)>k= zZD*szZ(<>#cVlPQO}{R3O=f%DsS5AJxBEipU37}z|MNsscgpGg)tb5wSI@p6Bz82B z^RvmqYx$R~b