Search in sources :

Example 1 with ResearchProgression

use of hellfirepvp.astralsorcery.common.data.research.ResearchProgression in project AstralSorcery by HellFirePvP.

the class ScreenJournalProgression method onSearchTextInput.

private void onSearchTextInput() {
    if (!this.inProgressView() && this.isCurrentlyDragging()) {
        this.stopDragging(-1, -1);
        progressionRenderer.applyMovedMouseOffset();
    }
    PlayerProgress prog = ResearchHelper.getClientProgress();
    this.searchResult.clear();
    this.searchResultPageIndex.clear();
    String searchText = this.searchTextEntry.getText().toLowerCase(Locale.ROOT);
    for (ResearchProgression research : ResearchProgression.values()) {
        if (!prog.hasResearch(research)) {
            continue;
        }
        for (ResearchNode node : research.getResearchNodes()) {
            if (node.getName().getString().toLowerCase(Locale.ROOT).contains(searchText) && !this.searchResult.contains(node)) {
                this.searchResult.add(node);
            }
        }
    }
    this.searchResult.sort(Comparator.comparing(node -> node.getName().getString()));
    FontRenderer fr = Minecraft.getInstance().fontRenderer;
    int addedPages = 0;
    int pageIndex = 0;
    while (addedPages < this.searchResult.size()) {
        List<ResearchNode> page = this.searchResultPageIndex.computeIfAbsent(pageIndex, index -> new ArrayList<>());
        int remainingLines = (pageIndex % 2 == 0 ? searchEntriesLeft : searchEntriesRight) - page.size();
        ResearchNode toAddNode = this.searchResult.get(addedPages);
        int lines = fr.trimStringToWidth(toAddNode.getName(), searchEntryDrawWidth).size();
        if (remainingLines < lines) {
            // Add this node to the next page.
            pageIndex++;
            continue;
        }
        page.add(toAddNode);
        addedPages++;
    }
    // Shift the pages further down in case the result gets narrower
    while (this.searchPageOffset > 0 && this.searchPageOffset >= this.searchResultPageIndex.size()) {
        this.searchPageOffset--;
    }
}
Also used : java.util(java.util) ResearchProgression(hellfirepvp.astralsorcery.common.data.research.ResearchProgression) SoundsAS(hellfirepvp.astralsorcery.common.lib.SoundsAS) IReorderingProcessor(net.minecraft.util.IReorderingProcessor) RenderingUtils(hellfirepvp.astralsorcery.client.util.RenderingUtils) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) RenderingDrawUtils(hellfirepvp.astralsorcery.client.util.RenderingDrawUtils) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) ScreenTextEntry(hellfirepvp.astralsorcery.client.util.ScreenTextEntry) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress) Minecraft(net.minecraft.client.Minecraft) ResearchNode(hellfirepvp.astralsorcery.common.data.research.ResearchNode) SoundHelper(hellfirepvp.astralsorcery.common.util.sound.SoundHelper) StringTextComponent(net.minecraft.util.text.StringTextComponent) GL11(org.lwjgl.opengl.GL11) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) TexturesAS(hellfirepvp.astralsorcery.client.lib.TexturesAS) ResearchHelper(hellfirepvp.astralsorcery.common.data.research.ResearchHelper) ClientScheduler(hellfirepvp.astralsorcery.client.ClientScheduler) Maps(com.google.common.collect.Maps) java.awt(java.awt) List(java.util.List) ScreenJournalProgressionRenderer(hellfirepvp.astralsorcery.client.screen.journal.progression.ScreenJournalProgressionRenderer) FontRenderer(net.minecraft.client.gui.FontRenderer) MathHelper(net.minecraft.util.math.MathHelper) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) RenderingGuiUtils(hellfirepvp.astralsorcery.client.util.RenderingGuiUtils) ResearchProgression(hellfirepvp.astralsorcery.common.data.research.ResearchProgression) ResearchNode(hellfirepvp.astralsorcery.common.data.research.ResearchNode) FontRenderer(net.minecraft.client.gui.FontRenderer) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress)

Example 2 with ResearchProgression

use of hellfirepvp.astralsorcery.common.data.research.ResearchProgression in project AstralSorcery by HellFirePvP.

the class GalaxySizeHandler method buildRequiredRectangle.

@Nullable
@Override
public float[] buildRequiredRectangle() {
    float leftMost = 0;
    float rightMost = 0;
    float upperMost = 0;
    float lowerMost = 0;
    PlayerProgress progress = ResearchHelper.getClientProgress();
    for (ResearchProgression resProgress : progress.getResearchProgression()) {
        JournalCluster cluster = JournalProgressionClusterMapping.getClusterMapping(resProgress);
        int x = cluster.x;
        int y = cluster.y;
        if (x < leftMost)
            leftMost = x;
        if (x > rightMost)
            rightMost = x;
        if (y > lowerMost)
            lowerMost = y;
        if (y < upperMost)
            upperMost = y;
        x = cluster.maxX;
        y = cluster.maxY;
        if (x < leftMost)
            leftMost = x;
        if (x > rightMost)
            rightMost = x;
        if (y > lowerMost)
            lowerMost = y;
        if (y < upperMost)
            upperMost = y;
    }
    return new float[] { leftMost, rightMost, upperMost, lowerMost };
}
Also used : ResearchProgression(hellfirepvp.astralsorcery.common.data.research.ResearchProgression) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress) Nullable(javax.annotation.Nullable)

Example 3 with ResearchProgression

use of hellfirepvp.astralsorcery.common.data.research.ResearchProgression in project AstralSorcery by HellFirePvP.

the class ScreenJournalProgressionRenderer method handleZoomIn.

/**
 * Thresholds for zooming in:
 * 1.0 - 4.0 don't care.
 * 4.0 - 6.0 has to have focus + centering to center of cluster
 * 6.0 - 10.0 transition (6.0 - 8.0) + cluster rendering + handling (cursor movement)
 */
public void handleZoomIn(float mouseX, float mouseY) {
    float scale = sizeHandler.getScalingFactor();
    // double nextScale = Math.min(10.0D, scale + 0.2D);
    if (scale >= 4.0F) {
        if (focusedClusterZoom == null) {
            ResearchProgression prog = tryFocusCluster(mouseX, mouseY);
            if (prog != null) {
                focus(prog);
            }
        }
        if (focusedClusterZoom == null) {
            return;
        }
        if (scale < 6.1F) {
            // Floating point shenanigans
            float vDiv = (2F - (scale - 4F)) * 10F;
            JournalCluster cluster = JournalProgressionClusterMapping.getClusterMapping(focusedClusterZoom);
            float x = this.sizeHandler.evRelativePosX(cluster.x);
            float y = this.sizeHandler.evRelativePosY(cluster.y);
            float width = this.sizeHandler.scaledDistanceX(cluster.x, cluster.maxX);
            float height = this.sizeHandler.scaledDistanceY(cluster.y, cluster.maxY);
            Vector3 center = new Vector3(x + width / 2, y + height / 2, 0);
            Vector3 mousePos = new Vector3(mousePointScaled.getScaledPosX(), mousePointScaled.getScaledPosY(), 0);
            Vector3 dir = center.subtract(mousePos);
            if (vDiv > 0.05) {
                dir.divide(vDiv);
            }
            if (!hasPrevOffset) {
                mousePointScaled.updateScaledPos(sizeHandler.clampX((float) (mousePos.getX() + dir.getX())), sizeHandler.clampY((float) (mousePos.getY() + dir.getY())), sizeHandler.getScalingFactor());
            } else {
                previousMousePointScaled.updateScaledPos(sizeHandler.clampX((float) (mousePos.getX() + dir.getX())), sizeHandler.clampY((float) (mousePos.getY() + dir.getY())), sizeHandler.getScalingFactor());
            }
            updateMouseState();
        } else if (clusterRenderer != null) {
            clusterRenderer.handleZoomIn();
        }
    }
    this.sizeHandler.handleZoomIn();
    this.mousePointScaled.rescale(sizeHandler.getScalingFactor());
    if (this.previousMousePointScaled != null) {
        this.previousMousePointScaled.rescale(sizeHandler.getScalingFactor());
    }
}
Also used : ResearchProgression(hellfirepvp.astralsorcery.common.data.research.ResearchProgression) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3)

Example 4 with ResearchProgression

use of hellfirepvp.astralsorcery.common.data.research.ResearchProgression in project AstralSorcery by HellFirePvP.

the class ProgressGatedPerk method serializeData.

@Override
public void serializeData(JsonObject perkData) {
    super.serializeData(perkData);
    if (!this.neededConstellations.isEmpty()) {
        JsonArray array = new JsonArray();
        for (IConstellation cst : this.neededConstellations) {
            array.add(cst.getRegistryName().toString());
        }
        perkData.add("neededConstellations", array);
    }
    if (!this.neededResearch.isEmpty()) {
        JsonArray array = new JsonArray();
        for (ResearchProgression research : this.neededResearch) {
            array.add(research.name());
        }
        perkData.add("neededResearch", array);
    }
    if (!this.neededProgression.isEmpty()) {
        JsonArray array = new JsonArray();
        for (ProgressionTier progress : this.neededProgression) {
            array.add(progress.name());
        }
        perkData.add("neededProgression", array);
    }
}
Also used : JsonArray(com.google.gson.JsonArray) ResearchProgression(hellfirepvp.astralsorcery.common.data.research.ResearchProgression) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation) ProgressionTier(hellfirepvp.astralsorcery.common.data.research.ProgressionTier)

Example 5 with ResearchProgression

use of hellfirepvp.astralsorcery.common.data.research.ResearchProgression in project AstralSorcery by HellFirePvP.

the class ScreenJournalProgressionRenderer method drawClusters.

private void drawClusters(MatrixStack renderStack, float zLevel) {
    clusterRectMap.clear();
    if (sizeHandler.getScalingFactor() >= 8.01)
        return;
    PlayerProgress thisProgress = ResearchHelper.getClientProgress();
    for (ResearchProgression progress : thisProgress.getResearchProgression()) {
        renderCluster(renderStack, progress, JournalProgressionClusterMapping.getClusterMapping(progress), zLevel);
    }
}
Also used : ResearchProgression(hellfirepvp.astralsorcery.common.data.research.ResearchProgression) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress)

Aggregations

ResearchProgression (hellfirepvp.astralsorcery.common.data.research.ResearchProgression)5 PlayerProgress (hellfirepvp.astralsorcery.common.data.research.PlayerProgress)3 Maps (com.google.common.collect.Maps)1 JsonArray (com.google.gson.JsonArray)1 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1 ClientScheduler (hellfirepvp.astralsorcery.client.ClientScheduler)1 TexturesAS (hellfirepvp.astralsorcery.client.lib.TexturesAS)1 ScreenJournalProgressionRenderer (hellfirepvp.astralsorcery.client.screen.journal.progression.ScreenJournalProgressionRenderer)1 RenderingDrawUtils (hellfirepvp.astralsorcery.client.util.RenderingDrawUtils)1 RenderingGuiUtils (hellfirepvp.astralsorcery.client.util.RenderingGuiUtils)1 RenderingUtils (hellfirepvp.astralsorcery.client.util.RenderingUtils)1 ScreenTextEntry (hellfirepvp.astralsorcery.client.util.ScreenTextEntry)1 IConstellation (hellfirepvp.astralsorcery.common.constellation.IConstellation)1 ProgressionTier (hellfirepvp.astralsorcery.common.data.research.ProgressionTier)1 ResearchHelper (hellfirepvp.astralsorcery.common.data.research.ResearchHelper)1 ResearchNode (hellfirepvp.astralsorcery.common.data.research.ResearchNode)1 SoundsAS (hellfirepvp.astralsorcery.common.lib.SoundsAS)1 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)1 SoundHelper (hellfirepvp.astralsorcery.common.util.sound.SoundHelper)1