mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-24 05:47:59 +01:00
Update trait dex icon to look more like a lightbulb and change the icon when there are unread entries
This commit is contained in:
parent
5448db4bdd
commit
2a0e6bc14b
7 changed files with 31 additions and 5 deletions
|
@ -90,6 +90,10 @@ public class TraitDiscovery implements NbtSerialisable {
|
||||||
.flatMap(entry -> Registry.ITEM.getOrEmpty(entry.getKey()).stream());
|
.flatMap(entry -> Registry.ITEM.getOrEmpty(entry.getKey()).stream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUnread() {
|
||||||
|
return !unreadTraits.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isUnread(Trait trait) {
|
public boolean isUnread(Trait trait) {
|
||||||
return unreadTraits.contains(trait);
|
return unreadTraits.contains(trait);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,8 @@ public class SpellbookChapterList {
|
||||||
int color,
|
int color,
|
||||||
Optional<Content> content) {
|
Optional<Content> content) {
|
||||||
|
|
||||||
public Identifier icon() {
|
public static Identifier createIcon(Identifier id, String suffex) {
|
||||||
return new Identifier(id().getNamespace(), "textures/gui/container/pages/" + id().getPath() + ".png");
|
return new Identifier(id.getNamespace(), "textures/gui/container/pages/" + id.getPath() + suffex + ".png");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,10 @@ public class SpellbookChapterList {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default Identifier getIcon(Chapter chapter, Identifier icon) {
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
static Optional<Content> of(BiConsumer<SpellbookScreen, Identifier> init, Drawable obj) {
|
static Optional<Content> of(BiConsumer<SpellbookScreen, Identifier> init, Drawable obj) {
|
||||||
return Optional.of(new Content() {
|
return Optional.of(new Content() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -162,7 +162,7 @@ public class SpellbookScreen extends HandledScreen<SpellbookScreenHandler> imple
|
||||||
drawTexture(matrices, bounds.left, bounds.top, isRight ? 510 - bounds.width : 402, v, bounds.width, bounds.height, 512, 256);
|
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.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);
|
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);
|
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.client.gui.spellbook;
|
package com.minelittlepony.unicopia.client.gui.spellbook;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import com.minelittlepony.common.client.gui.dimension.Bounds;
|
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;
|
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;
|
return tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
record Tab (Chapter chapter, Bounds bounds, Identifier icon) {}
|
record Tab (Chapter chapter, Bounds bounds, Supplier<Identifier> icon) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.client.gui.spellbook;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import com.minelittlepony.common.client.gui.IViewRoot;
|
import com.minelittlepony.common.client.gui.IViewRoot;
|
||||||
import com.minelittlepony.common.client.gui.ScrollContainer;
|
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.element.Label;
|
||||||
import com.minelittlepony.common.client.gui.sprite.TextureSprite;
|
import com.minelittlepony.common.client.gui.sprite.TextureSprite;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.*;
|
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.client.gui.spellbook.SpellbookScreen.ImageButton;
|
||||||
import com.minelittlepony.unicopia.container.SpellbookState;
|
import com.minelittlepony.unicopia.container.SpellbookState;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
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.item.*;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.Util;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
|
|
||||||
public class SpellbookTraitDexPageContent extends DrawableHelper implements SpellbookChapterList.Content, SpellbookScreen.RecipesChangedListener {
|
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 SpellbookScreen screen;
|
||||||
|
|
||||||
|
private final Function<Identifier, Identifier> unreadIcon = Util.memoize(id -> Chapter.createIcon(id, "_unread"));
|
||||||
|
|
||||||
public SpellbookTraitDexPageContent(SpellbookScreen screen) {
|
public SpellbookTraitDexPageContent(SpellbookScreen screen) {
|
||||||
this.screen = 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
|
@Override
|
||||||
public void init(SpellbookScreen screen, Identifier pageId) {
|
public void init(SpellbookScreen screen, Identifier pageId) {
|
||||||
state = screen.getState().getState(pageId);
|
state = screen.getState().getState(pageId);
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 777 B After Width: | Height: | Size: 777 B |
Binary file not shown.
After Width: | Height: | Size: 794 B |
Loading…
Reference in a new issue