diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitDiscovery.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitDiscovery.java index edf637f6..6c7ab527 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitDiscovery.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitDiscovery.java @@ -90,6 +90,10 @@ public class TraitDiscovery implements NbtSerialisable { .flatMap(entry -> Registry.ITEM.getOrEmpty(entry.getKey()).stream()); } + public boolean isUnread() { + return !unreadTraits.isEmpty(); + } + public boolean isUnread(Trait trait) { return unreadTraits.contains(trait); } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java index 3066a2c9..b319d108 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java @@ -58,8 +58,8 @@ public class SpellbookChapterList { int color, Optional content) { - public Identifier icon() { - return new Identifier(id().getNamespace(), "textures/gui/container/pages/" + id().getPath() + ".png"); + public static Identifier createIcon(Identifier id, String suffex) { + return new Identifier(id.getNamespace(), "textures/gui/container/pages/" + id.getPath() + suffex + ".png"); } } @@ -77,6 +77,10 @@ public class SpellbookChapterList { return false; } + default Identifier getIcon(Chapter chapter, Identifier icon) { + return icon; + } + static Optional of(BiConsumer init, Drawable obj) { return Optional.of(new Content() { @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java index 16fe432d..222bb210 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java @@ -162,7 +162,7 @@ public class SpellbookScreen extends HandledScreen imple drawTexture(matrices, bounds.left, bounds.top, isRight ? 510 - bounds.width : 402, v, bounds.width, bounds.height, 512, 256); RenderSystem.setShaderColor(1, 1, 1, 1); - RenderSystem.setShaderTexture(0, tab.icon()); + RenderSystem.setShaderTexture(0, tab.icon().get()); drawTexture(matrices, isRight ? bounds.left + bounds.width - 16 - 10 : bounds.left + 10, bounds.top + (bounds.height - 16) / 2, 0, 0, 16, 16, 16, 16); RenderSystem.setShaderTexture(0, TEXTURE); }); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTabBar.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTabBar.java index cd98517d..313a9fd6 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTabBar.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTabBar.java @@ -1,6 +1,7 @@ package com.minelittlepony.unicopia.client.gui.spellbook; import java.util.*; +import java.util.function.Supplier; import java.util.stream.Stream; import com.minelittlepony.common.client.gui.dimension.Bounds; @@ -61,11 +62,15 @@ public class SpellbookTabBar { } int xPosition = side == TabSide.LEFT ? left - width + tabInset : left + backgroundWidth - tabInset; - tabs.add(new Tab(leftTabs.get(i), new Bounds(top + tabY, xPosition, width, tabHeight), leftTabs.get(i).icon())); + Chapter chapter = leftTabs.get(i); + Identifier icon = Chapter.createIcon(chapter.id(), ""); + tabs.add(new Tab(leftTabs.get(i), new Bounds(top + tabY, xPosition, width, tabHeight), () -> { + return chapter.content().map(content -> content.getIcon(chapter, icon)).orElse(icon); + })); } return tabs; } - record Tab (Chapter chapter, Bounds bounds, Identifier icon) {} + record Tab (Chapter chapter, Bounds bounds, Supplier icon) {} } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java index 1e8d7e9d..304cc471 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java @@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.client.gui.spellbook; import java.util.Comparator; import java.util.List; +import java.util.function.Function; import com.minelittlepony.common.client.gui.IViewRoot; import com.minelittlepony.common.client.gui.ScrollContainer; @@ -9,6 +10,7 @@ import com.minelittlepony.common.client.gui.element.Button; import com.minelittlepony.common.client.gui.element.Label; import com.minelittlepony.common.client.gui.sprite.TextureSprite; import com.minelittlepony.unicopia.ability.magic.spell.trait.*; +import com.minelittlepony.unicopia.client.gui.spellbook.SpellbookChapterList.Chapter; import com.minelittlepony.unicopia.client.gui.spellbook.SpellbookScreen.ImageButton; import com.minelittlepony.unicopia.container.SpellbookState; import com.minelittlepony.unicopia.entity.player.Pony; @@ -20,6 +22,7 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.*; import net.minecraft.text.Text; import net.minecraft.util.Identifier; +import net.minecraft.util.Util; import net.minecraft.util.collection.DefaultedList; public class SpellbookTraitDexPageContent extends DrawableHelper implements SpellbookChapterList.Content, SpellbookScreen.RecipesChangedListener { @@ -32,6 +35,8 @@ public class SpellbookTraitDexPageContent extends DrawableHelper implements Spel private final SpellbookScreen screen; + private final Function unreadIcon = Util.memoize(id -> Chapter.createIcon(id, "_unread")); + public SpellbookTraitDexPageContent(SpellbookScreen screen) { this.screen = screen; } @@ -41,6 +46,14 @@ public class SpellbookTraitDexPageContent extends DrawableHelper implements Spel } + @Override + public Identifier getIcon(Chapter chapter, Identifier icon) { + if (Pony.of(MinecraftClient.getInstance().player).getDiscoveries().isUnread()) { + return unreadIcon.apply(chapter.id()); + } + return icon; + } + @Override public void init(SpellbookScreen screen, Identifier pageId) { state = screen.getState().getState(pageId); diff --git a/src/main/resources/assets/unicopia/textures/gui/container/pages/traits.png b/src/main/resources/assets/unicopia/textures/gui/container/pages/traits.png index 76db65bb..2d62b4d5 100644 Binary files a/src/main/resources/assets/unicopia/textures/gui/container/pages/traits.png and b/src/main/resources/assets/unicopia/textures/gui/container/pages/traits.png differ diff --git a/src/main/resources/assets/unicopia/textures/gui/container/pages/traits_unread.png b/src/main/resources/assets/unicopia/textures/gui/container/pages/traits_unread.png new file mode 100644 index 00000000..e825ea26 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/gui/container/pages/traits_unread.png differ