From b8e0dde333e87cddbb52bef36ee1db3802079d77 Mon Sep 17 00:00:00 2001 From: Arthur Uzulin Date: Sun, 7 Feb 2016 18:26:04 +1100 Subject: [PATCH] Book section gating - Added section unlock criteria - Added type adapter for Hex/Binary int String -> int --- .../mantle/client/book/BookLoader.java | 4 +- .../mantle/client/book/data/BookData.java | 49 +++++++++-- .../mantle/client/book/data/SectionData.java | 40 ++++++++- .../deserializer/HexStringDeserializer.java | 29 +++++++ .../book/data/element/CriteriaData.java | 9 -- .../mantle/client/gui/book/GuiBook.java | 83 +++++++++++++++---- .../gui/book/element/ElementSection.java | 29 ++++++- .../mantle/books/TestBook/appearance.json | 8 +- .../assets/mantle/books/TestBook/index.json | 75 +++-------------- 9 files changed, 221 insertions(+), 105 deletions(-) create mode 100644 src/main/java/slimeknights/mantle/client/book/data/deserializer/HexStringDeserializer.java delete mode 100644 src/main/java/slimeknights/mantle/client/book/data/element/CriteriaData.java diff --git a/src/main/java/slimeknights/mantle/client/book/BookLoader.java b/src/main/java/slimeknights/mantle/client/book/BookLoader.java index 399a173..bc24240 100644 --- a/src/main/java/slimeknights/mantle/client/book/BookLoader.java +++ b/src/main/java/slimeknights/mantle/client/book/BookLoader.java @@ -1,6 +1,7 @@ package slimeknights.mantle.client.book; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import java.util.HashMap; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.IReloadableResourceManager; @@ -27,6 +28,7 @@ import slimeknights.mantle.client.book.data.content.ContentTextImage; import slimeknights.mantle.client.book.data.content.ContentTextLeftImage; import slimeknights.mantle.client.book.data.content.ContentTextRightImage; import slimeknights.mantle.client.book.data.content.PageContent; +import slimeknights.mantle.client.book.data.deserializer.HexStringDeserializer; import slimeknights.mantle.client.book.repository.BookRepository; import slimeknights.mantle.network.NetworkWrapper; import slimeknights.mantle.network.book.PacketUpdateSavedPage; @@ -35,7 +37,7 @@ import slimeknights.mantle.network.book.PacketUpdateSavedPage; public class BookLoader implements IResourceManagerReloadListener { /** GSON object to be used for book loading purposes */ - public static final Gson GSON = new Gson(); + public static final Gson GSON = new GsonBuilder().registerTypeAdapter(int.class, new HexStringDeserializer()).create(); /** Maps page content presets to names */ private static final HashMap> typeToContentMap = new HashMap<>(); diff --git a/src/main/java/slimeknights/mantle/client/book/data/BookData.java b/src/main/java/slimeknights/mantle/client/book/data/BookData.java index b67feba..c689916 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/BookData.java +++ b/src/main/java/slimeknights/mantle/client/book/data/BookData.java @@ -6,6 +6,7 @@ import java.util.List; import javax.annotation.Nullable; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatFileWriter; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -90,18 +91,26 @@ public class BookData implements IDataItem { } public SectionData findSection(String name) { + return findSection(name, null); + } + + public SectionData findSection(String name, @Nullable StatFileWriter writer) { for (SectionData section : sections) if (section.name.equals(name.toLowerCase())) - return section; + return section.isUnlocked(writer) ? section : null; return null; } public int getFirstPageNumber(SectionData section) { + return getFirstPageNumber(section, null); + } + + public int getFirstPageNumber(SectionData section, @Nullable StatFileWriter writer) { int pages = 0; for (SectionData sect : sections) { if (section == sect) - return pages + 1; + return section.isUnlocked(writer) ? pages + 1 : -1; pages += sect.getPageCount(); } @@ -110,11 +119,18 @@ public class BookData implements IDataItem { } public PageData findPage(int number) { + return findPage(number, null); + } + + public PageData findPage(int number, @Nullable StatFileWriter writer) { if (number < 0) return null; int pages = 0; for (SectionData section : sections) { + if (!section.isUnlocked(writer)) + continue; + if (pages + section.getPageCount() > number) return section.pages.get(number - pages); else @@ -125,10 +141,18 @@ public class BookData implements IDataItem { } public PageData findPage(String location) { - return findPage(findPageNumber(location)); + return findPage(location, null); + } + + public PageData findPage(String location, @Nullable StatFileWriter writer) { + return findPage(findPageNumber(location, writer)); } public int findPageNumber(String location) { + return findPageNumber(location, null); + } + + public int findPageNumber(String location, @Nullable StatFileWriter writer) { location = location.toLowerCase(); int pages = 0; @@ -140,6 +164,9 @@ public class BookData implements IDataItem { String pageName = location.substring(location.indexOf('.') + 1); for (SectionData section : sections) { + if (!section.isUnlocked(writer)) + continue; + if (!sectionName.equals(section.name)) { pages += section.getPageCount(); continue; @@ -159,15 +186,23 @@ public class BookData implements IDataItem { } public int getPageCount() { + return getPageCount(null); + } + + public int getPageCount(@Nullable StatFileWriter writer) { int pages = 0; for (SectionData section : sections) { - pages += section.getPageCount(); + pages += section.isUnlocked(writer) ? section.getPageCount() : 0; } return pages; } public int getFullPageCount() { - return (int) Math.ceil((getPageCount() - 1) / 2F) + 1; + return getFullPageCount(null); + } + + public int getFullPageCount(@Nullable StatFileWriter writer) { + return (int) Math.ceil((getPageCount(writer) - 1) / 2F) + 1; } public String getItemAction(ItemStackData item) { @@ -180,8 +215,8 @@ public class BookData implements IDataItem { } public void openGui(@Nullable ItemStack item) { - if (Minecraft.getMinecraft().currentScreen == null) - Minecraft.getMinecraft().displayGuiScreen(new GuiBook(this, item)); + if (Minecraft.getMinecraft().thePlayer != null) + Minecraft.getMinecraft().displayGuiScreen(new GuiBook(this, Minecraft.getMinecraft().thePlayer.getStatFileWriter(), item)); } public void addRepository(BookRepository repository) { diff --git a/src/main/java/slimeknights/mantle/client/book/data/SectionData.java b/src/main/java/slimeknights/mantle/client/book/data/SectionData.java index 64d9c89..3e835e6 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/SectionData.java +++ b/src/main/java/slimeknights/mantle/client/book/data/SectionData.java @@ -3,11 +3,13 @@ package slimeknights.mantle.client.book.data; import java.util.ArrayList; import java.util.Arrays; import net.minecraft.client.resources.IResource; +import net.minecraft.stats.Achievement; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatFileWriter; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import slimeknights.mantle.client.book.BookLoader; import slimeknights.mantle.client.book.data.content.ContentError; -import slimeknights.mantle.client.book.data.element.CriteriaData; import slimeknights.mantle.client.book.data.element.ImageData; import static slimeknights.mantle.client.book.ResourceHelper.getResource; import static slimeknights.mantle.client.book.ResourceHelper.getResourceLocation; @@ -19,7 +21,7 @@ public class SectionData implements IDataItem { public String name = null; public String title = ""; public ImageData icon = new ImageData(); - public CriteriaData[] unlockCriteria = new CriteriaData[0]; + public String[] requirements = new String[0]; public String data = ""; public transient int unnamedPageCounter = 0; @@ -70,4 +72,38 @@ public class SectionData implements IDataItem { public int getPageCount() { return pages.size(); } + + public boolean isUnlocked(StatFileWriter writer) { + if (writer == null || requirements == null || requirements.length == 0) + return true; + + for (String achievement : requirements) { + if (!requirementSatisfied(achievement, writer)) + return false; + } + + return true; + } + + public static boolean requirementSatisfied(String requirement, StatFileWriter writer) { + if (writer == null) + return true; + + Achievement achievement = findAchievement(requirement); + + return achievement == null || writer.hasAchievementUnlocked(achievement); + + } + + public static Achievement findAchievement(String name) { + if (name == null || name.isEmpty()) + return null; + + for (Achievement achievement : AchievementList.achievementList) { + if (achievement.statId.equals(name)) + return achievement; + } + + return null; + } } diff --git a/src/main/java/slimeknights/mantle/client/book/data/deserializer/HexStringDeserializer.java b/src/main/java/slimeknights/mantle/client/book/data/deserializer/HexStringDeserializer.java new file mode 100644 index 0000000..acc928b --- /dev/null +++ b/src/main/java/slimeknights/mantle/client/book/data/deserializer/HexStringDeserializer.java @@ -0,0 +1,29 @@ +package slimeknights.mantle.client.book.data.deserializer; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import java.lang.reflect.Type; + +public class HexStringDeserializer implements JsonDeserializer { + + @Override + public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + if (json.isJsonPrimitive() && json.getAsJsonPrimitive().isNumber()) + return json.getAsInt(); + else if (json.isJsonPrimitive() && json.getAsJsonPrimitive().isString()) { + try { + String s = json.getAsString(); + + if (s.toLowerCase().startsWith("0b")) + return Integer.parseInt(s.substring(2), 2); + else if (s.toLowerCase().startsWith("0x")) + return Integer.parseInt(s.substring(2), 16); + } catch (NumberFormatException ignored) { + } + } + + return null; + } +} diff --git a/src/main/java/slimeknights/mantle/client/book/data/element/CriteriaData.java b/src/main/java/slimeknights/mantle/client/book/data/element/CriteriaData.java deleted file mode 100644 index 39eba91..0000000 --- a/src/main/java/slimeknights/mantle/client/book/data/element/CriteriaData.java +++ /dev/null @@ -1,9 +0,0 @@ -package slimeknights.mantle.client.book.data.element; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class CriteriaData { - // TODO criteria parsing -} diff --git a/src/main/java/slimeknights/mantle/client/gui/book/GuiBook.java b/src/main/java/slimeknights/mantle/client/gui/book/GuiBook.java index b550863..1c2247f 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/GuiBook.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/GuiBook.java @@ -3,12 +3,17 @@ package slimeknights.mantle.client.gui.book; import java.io.IOException; import java.util.ArrayList; import javax.annotation.Nullable; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.IProgressMeter; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.C16PacketClientStatus; +import net.minecraft.stats.StatFileWriter; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -23,7 +28,7 @@ import slimeknights.mantle.client.book.data.element.ItemStackData; import slimeknights.mantle.client.gui.book.element.BookElement; @SideOnly(Side.CLIENT) -public class GuiBook extends GuiScreen { +public class GuiBook extends GuiScreen implements IProgressMeter { private static final ResourceLocation TEX_BOOK = new ResourceLocation("mantle:textures/gui/book.png"); private static final ResourceLocation TEX_BOOKFRONT = new ResourceLocation("mantle:textures/gui/bookfront.png"); @@ -39,8 +44,7 @@ public class GuiBook extends GuiScreen { public static final int PAGE_WIDTH = (int) ((PAGE_WIDTH_UNSCALED - (PAGE_PADDING + PAGE_MARGIN) * 2) / PAGE_SCALE); public static final int PAGE_HEIGHT = (int) ((PAGE_HEIGHT_UNSCALED - (PAGE_PADDING + PAGE_MARGIN) * 2) / PAGE_SCALE); - public static boolean side = false; - + private boolean loadingAchievements = true; private GuiArrow previousArrow, nextArrow, backArrow, indexArrow; public final BookData book; @@ -51,15 +55,16 @@ public class GuiBook extends GuiScreen { private ArrayList leftElements = new ArrayList<>(); private ArrayList rightElements = new ArrayList<>(); - public GuiBook(BookData book, @Nullable ItemStack item) { + public StatFileWriter statFile; + + public GuiBook(BookData book, StatFileWriter statFile, @Nullable ItemStack item) { this.book = book; this.item = item; - openPage(book.findPageNumber(BookHelper.getSavedPage(item))); + this.statFile = statFile; } public void drawerTransform(boolean rightSide) { - side = rightSide; if (rightSide) GlStateManager.translate(width / 2 + PAGE_PADDING + PAGE_MARGIN, height / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING + PAGE_MARGIN, 0); else @@ -70,6 +75,16 @@ public class GuiBook extends GuiScreen { @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { FontRenderer font = mc.fontRendererObj; + + if (loadingAchievements) { + this.drawDefaultBackground(); + + this.drawCenteredString(this.fontRendererObj, I18n.format("multiplayer.downloadingStats"), this.width / 2, this.height / 2, 16777215); + this.drawCenteredString(this.fontRendererObj, lanSearchStates[(int) (Minecraft.getSystemTime() / 150L % (long) lanSearchStates.length)], this.width / 2, this.height / 2 + this.fontRendererObj.FONT_HEIGHT * 2, 16777215); + + return; + } + GlStateManager.enableAlpha(); GlStateManager.enableBlend(); @@ -160,7 +175,7 @@ public class GuiBook extends GuiScreen { // Set color back to white GlStateManager.color(1F, 1F, 1F, 1F); - if ((page < book.getFullPageCount() - 1 || book.getPageCount() % 2 != 0) && page < book.getFullPageCount()) { + if ((page < book.getFullPageCount(statFile) - 1 || book.getPageCount(statFile) % 2 != 0) && page < book.getFullPageCount(statFile)) { drawModalRectWithCustomSizedTexture(width / 2, height / 2 - PAGE_HEIGHT_UNSCALED / 2, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, 512, 512); GlStateManager.pushMatrix(); @@ -203,6 +218,9 @@ public class GuiBook extends GuiScreen { } public void openPage(int page, boolean returner) { + if (loadingAchievements) + return; + if (page < 0) return; @@ -214,7 +232,7 @@ public class GuiBook extends GuiScreen { else bookPage = (page - 2) / 2 + 1; - if (bookPage >= -1 && bookPage < book.getFullPageCount()) { + if (bookPage >= -1 && bookPage < book.getFullPageCount(statFile)) { if (returner) oldPage = this.page; @@ -228,6 +246,9 @@ public class GuiBook extends GuiScreen { } private void buildPages() { + if (loadingAchievements) + return; + leftElements.clear(); rightElements.clear(); @@ -235,13 +256,13 @@ public class GuiBook extends GuiScreen { return; if (page == 0) { - PageData page = book.findPage(0); + PageData page = book.findPage(0, statFile); if (page != null) page.content.build(book, rightElements); } else { - PageData leftPage = book.findPage((page - 1) * 2 + 1); - PageData rightPage = book.findPage((page - 1) * 2 + 2); + PageData leftPage = book.findPage((page - 1) * 2 + 1, statFile); + PageData rightPage = book.findPage((page - 1) * 2 + 2, statFile); if (leftPage != null) leftPage.content.build(book, leftElements); @@ -259,6 +280,11 @@ public class GuiBook extends GuiScreen { public void initGui() { super.initGui(); + if (loadingAchievements) { + this.mc.getNetHandler().addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.REQUEST_STATS)); + return; + } + // The books are unreadable at Gui Scale set to small, so we'll double the scale, and of course half the size so that all our code still works as it should if (mc.gameSettings.guiScale == 1) { width /= 2F; @@ -282,8 +308,11 @@ public class GuiBook extends GuiScreen { public void updateScreen() { super.updateScreen(); + if (loadingAchievements) + return; + previousArrow.visible = page != -1; - nextArrow.visible = page < book.getFullPageCount() - (book.getPageCount() % 2 != 0 ? 0 : 1); + nextArrow.visible = page < book.getFullPageCount(statFile) - (book.getPageCount(statFile) % 2 != 0 ? 0 : 1); backArrow.visible = oldPage >= -1; if (page == -1) { @@ -300,10 +329,21 @@ public class GuiBook extends GuiScreen { nextArrow.yPosition = height / 2 + 75; } + @Override + public void doneLoading() { + loadingAchievements = false; + + initGui(); + openPage(book.findPageNumber(BookHelper.getSavedPage(item), statFile)); + } + @Override public void actionPerformed(GuiButton button) { + if (loadingAchievements) + return; + if (button instanceof GuiBookmark) { - openPage(book.findPageNumber(((GuiBookmark) button).data.page)); + openPage(book.findPageNumber(((GuiBookmark) button).data.page, statFile)); return; } @@ -314,8 +354,8 @@ public class GuiBook extends GuiScreen { page = -1; } else if (button == nextArrow) { page++; - if (page > book.getFullPageCount() - (book.getPageCount() % 2 != 0 ? 0 : 1)) - page = book.getFullPageCount() - 1; + if (page > book.getFullPageCount(statFile) - (book.getPageCount(statFile) % 2 != 0 ? 0 : 1)) + page = book.getFullPageCount(statFile) - 1; } else if (button == backArrow) { if (oldPage >= -1) page = oldPage; @@ -331,6 +371,9 @@ public class GuiBook extends GuiScreen { protected void keyTyped(char typedChar, int keyCode) throws IOException { super.keyTyped(typedChar, keyCode); + if (loadingAchievements) + return; + if (keyCode == Keyboard.KEY_LEFT || keyCode == Keyboard.KEY_A) actionPerformed(previousArrow); else if (keyCode == Keyboard.KEY_RIGHT || keyCode == Keyboard.KEY_D) @@ -339,6 +382,9 @@ public class GuiBook extends GuiScreen { @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + if (loadingAchievements) + return; + super.mouseClicked(mouseX, mouseY, mouseButton); boolean right = false; @@ -361,10 +407,13 @@ public class GuiBook extends GuiScreen { @Override public void onGuiClosed() { - PageData page = this.page == 0 ? book.findPage(0) : book.findPage((this.page - 1) * 2 + 1); + if (loadingAchievements) + return; + + PageData page = this.page == 0 ? book.findPage(0, statFile) : book.findPage((this.page - 1) * 2 + 1, statFile); if (page == null) - page = book.findPage((this.page - 1) * 2 + 2); + page = book.findPage((this.page - 1) * 2 + 2, statFile); if (this.page == -1) BookLoader.updateSavedPage(mc.thePlayer, item, ""); diff --git a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementSection.java b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementSection.java index 0cd3263..583a288 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementSection.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementSection.java @@ -1,7 +1,11 @@ package slimeknights.mantle.client.gui.book.element; +import java.util.ArrayList; +import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.stats.Achievement; +import net.minecraft.util.EnumChatFormatting; import slimeknights.mantle.client.book.data.SectionData; public class ElementSection extends BookElement { @@ -21,12 +25,16 @@ public class ElementSection extends BookElement { @Override public void draw(int mouseX, int mouseY, float partialTicks) { + boolean unlocked = section.isUnlocked(parent.statFile); boolean hover = mouseX > x && mouseY > y && mouseX < x + WIDTH && mouseY < y + HEIGHT; if (section.icon != null) { Minecraft.getMinecraft().renderEngine.bindTexture(section.icon.location); - GlStateManager.color(1F, 1F, 1F, hover ? 1F : 0.5F); + if (unlocked) + GlStateManager.color(1F, 1F, 1F, hover ? 1F : 0.5F); + else + GlStateManager.color(0.5F, 0.5F, 0.5F, 1F); drawScaledCustomSizeModalRect(x + WIDTH / 2 - IMG_SIZE / 2, y + HEIGHT / 2 - IMG_SIZE / 2, section.icon.u, section.icon.v, section.icon.uw, section.icon.vh, IMG_SIZE, IMG_SIZE, section.icon.texWidth, section.icon.texHeight); } @@ -34,8 +42,25 @@ public class ElementSection extends BookElement { Minecraft.getMinecraft().fontRendererObj.drawString(section.title, x + WIDTH / 2 - Minecraft.getMinecraft().fontRendererObj.getStringWidth(section.title) / 2, y + HEIGHT - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT, hover ? 0xFF000000 : 0x7F000000); } + @Override + public void drawOverlay(int mouseX, int mouseY, float partialTicks) { + if (section != null && !section.isUnlocked(parent.statFile) && mouseX > x && mouseY > y && mouseX < x + WIDTH && mouseY < y + HEIGHT) { + List l = new ArrayList(); + l.add(EnumChatFormatting.RED + "Locked"); + l.add("Requirements:"); + + for (String requirement : section.requirements) { + Achievement achievement = SectionData.findAchievement(requirement); + if (achievement != null) + l.add((SectionData.requirementSatisfied(requirement, parent.statFile) ? EnumChatFormatting.GREEN : EnumChatFormatting.RED) + EnumChatFormatting.getTextWithoutFormattingCodes(achievement.getStatName().getFormattedText())); + } + + drawHoveringText(l, mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj); + } + } + public void mouseClicked(int mouseX, int mouseY, int mouseButton) { - if (mouseButton == 0 && section != null && mouseX > x && mouseY > y && mouseX < x + WIDTH && mouseY < y + HEIGHT) + if (mouseButton == 0 && section != null && section.isUnlocked(parent.statFile) && mouseX > x && mouseY > y && mouseX < x + WIDTH && mouseY < y + HEIGHT) parent.openPage(parent.book.getFirstPageNumber(section)); } } diff --git a/src/main/resources/assets/mantle/books/TestBook/appearance.json b/src/main/resources/assets/mantle/books/TestBook/appearance.json index a2c94fa..2b4a222 100644 --- a/src/main/resources/assets/mantle/books/TestBook/appearance.json +++ b/src/main/resources/assets/mantle/books/TestBook/appearance.json @@ -1,9 +1,9 @@ { - //"coverColor": 9127473, - //"arrowColor": 16379859, - //"arrowColorHover": 15496766, + //"coverColor": "0x0DED67", + //"arrowColor": "0xF9EFD3", + //"arrowColorHover": "0xEC763E", //"indexBookmark": true, - //"indexBookmarkColor": 13500416, + //"indexBookmarkColor": "0xCE0000", "title": "Materials and You", "subtitle": "By Skyla", "drawPageNumbers": true diff --git a/src/main/resources/assets/mantle/books/TestBook/index.json b/src/main/resources/assets/mantle/books/TestBook/index.json index 3f5c3a7..b55eab8 100644 --- a/src/main/resources/assets/mantle/books/TestBook/index.json +++ b/src/main/resources/assets/mantle/books/TestBook/index.json @@ -6,68 +6,17 @@ "file": "images/test.png" }, "data": "sections/section1.json" - }, { - "name": "test section", - "title": "Test Section", - "icon": { - "file": "images/test.png" }, - "data": "sections/section1.json" -}, { - "name": "test section", - "title": "Test Section", - "icon": { - "file": "images/test.png" - }, - "data": "sections/section1.json" -}, { - "name": "test section", - "title": "Test Section", - "icon": { - "file": "images/test.png" - }, - "data": "sections/section1.json" -}, { - "name": "test section", - "title": "Test Section", - "icon": { - "file": "images/test.png" - }, - "data": "sections/section1.json" -}, { - "name": "test section", - "title": "Test Section", - "icon": { - "file": "images/test.png" - }, - "data": "sections/section1.json" -}, { - "name": "test section", - "title": "Test Section", - "icon": { - "file": "images/test.png" - }, - "data": "sections/section1.json" -}, { - "name": "test section", - "title": "Test Section", - "icon": { - "file": "images/test.png" - }, - "data": "sections/section1.json" -}, { - "name": "test section", - "title": "Test Section", - "icon": { - "file": "images/test.png" - }, - "data": "sections/section1.json" -}, { - "name": "test section", - "title": "Test Section", - "icon": { - "file": "images/test.png" - }, - "data": "sections/section1.json" -} + { + "name": "section 2", + "title": "Locked Section", + "icon": { + "file": "images/test.png" + }, + "data": "sections/section1.json", + "requirements": [ + "achievement.buildHoe", + "achievement.makeBread" + ] + } ] \ No newline at end of file