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--;
}
}
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 };
}
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());
}
}
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);
}
}
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);
}
}
Aggregations