mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Clicking on a trait in a recipe will now take you to that trait in the dex
This commit is contained in:
parent
c5349bd242
commit
fce836bf3b
2 changed files with 29 additions and 5 deletions
|
@ -47,10 +47,11 @@ public class SpellbookScreen extends HandledScreen<SpellbookScreenHandler> imple
|
|||
private final RecipeBookWidget recipeBook = new RecipeBookWidget();
|
||||
|
||||
private final Chapter craftingChapter;
|
||||
private final SpellbookTraitDexPageContent traitDex = new SpellbookTraitDexPageContent(this);
|
||||
private final SpellbookChapterList chapters = new SpellbookChapterList(this,
|
||||
craftingChapter = new Chapter(SpellbookChapterList.CRAFTING_ID, TabSide.LEFT, 0, 0, Optional.of(new SpellbookCraftingPageContent(this))),
|
||||
new Chapter(SpellbookChapterList.PROFILE_ID, TabSide.LEFT, 1, 0, Optional.of(new SpellbookProfilePageContent(this))),
|
||||
new Chapter(SpellbookChapterList.TRAIT_DEX_ID, TabSide.LEFT, 3, 0, Optional.of(new SpellbookTraitDexPageContent(this)))
|
||||
new Chapter(SpellbookChapterList.TRAIT_DEX_ID, TabSide.LEFT, 3, 0, Optional.of(traitDex))
|
||||
);
|
||||
private final SpellbookTabBar tabs = new SpellbookTabBar(this, chapters);
|
||||
|
||||
|
@ -77,6 +78,10 @@ public class SpellbookScreen extends HandledScreen<SpellbookScreenHandler> imple
|
|||
return handler.getSpellbookState();
|
||||
}
|
||||
|
||||
public SpellbookTraitDexPageContent getTraitDex() {
|
||||
return traitDex;
|
||||
}
|
||||
|
||||
public void addPageButtons(int buttonY, int prevX, int nextX, IntConsumer pageAction) {
|
||||
addDrawableChild(new PageButton(this, x + nextX, y + buttonY, 1, pageAction));
|
||||
addDrawableChild(new PageButton(this, x + prevX, y + buttonY, -1, pageAction));
|
||||
|
@ -225,6 +230,11 @@ public class SpellbookScreen extends HandledScreen<SpellbookScreenHandler> imple
|
|||
}) || super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearAndInit() {
|
||||
super.clearAndInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||
return hoveredElement(mouseX, mouseY).filter((element) -> {
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package com.minelittlepony.unicopia.client.gui.spellbook;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.minelittlepony.common.client.gui.IViewRoot;
|
||||
import com.minelittlepony.common.client.gui.ScrollContainer;
|
||||
import com.minelittlepony.common.client.gui.*;
|
||||
import com.minelittlepony.common.client.gui.element.Button;
|
||||
import com.minelittlepony.common.client.gui.element.Label;
|
||||
import com.minelittlepony.common.client.gui.sprite.TextureSprite;
|
||||
|
@ -20,6 +18,7 @@ import net.minecraft.client.MinecraftClient;
|
|||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Util;
|
||||
|
@ -68,6 +67,21 @@ public class SpellbookTraitDexPageContent extends DrawableHelper implements Spel
|
|||
});
|
||||
}
|
||||
|
||||
public void pageTo(SpellbookScreen screen, Trait trait) {
|
||||
int page = Arrays.binarySearch(traits, trait);
|
||||
if (page < 0) {
|
||||
return;
|
||||
}
|
||||
page /= 2;
|
||||
state = screen.getState().getState(SpellbookChapterList.TRAIT_DEX_ID);
|
||||
state.setOffset(page);
|
||||
leftPage.scrollbar.scrollBy(leftPage.scrollbar.getVerticalScrollAmount());
|
||||
rightPage.scrollbar.scrollBy(rightPage.scrollbar.getVerticalScrollAmount());
|
||||
|
||||
GameGui.playSound(SoundEvents.ITEM_BOOK_PAGE_TURN);
|
||||
screen.clearAndInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecipesChanged() {
|
||||
init(screen, SpellbookChapterList.TRAIT_DEX_ID);
|
||||
|
|
Loading…
Reference in a new issue