aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLulonaut <lulonaut@tutanota.de>2022-10-26 23:04:47 +0200
committerGitHub <noreply@github.com>2022-10-26 21:04:47 +0000
commit8832bff4c5e61fb1019b8ad13cec636dd7b0dd44 (patch)
treeef1c538b7a1848fc28307f5fdd7568113454ff1c
parent3377ca0321869f45e9624e5454fe227bb62da2db (diff)
downloadNotEnoughUpdates-8832bff4c5e61fb1019b8ad13cec636dd7b0dd44.tar.gz
NotEnoughUpdates-8832bff4c5e61fb1019b8ad13cec636dd7b0dd44.tar.bz2
NotEnoughUpdates-8832bff4c5e61fb1019b8ad13cec636dd7b0dd44.zip
no more infinite scroll (#394)
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java81
1 files changed, 57 insertions, 24 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java
index a0af254c..64afdb75 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java
@@ -58,7 +58,6 @@ public class ExtraPage extends GuiProfileViewerPage {
private int killScroll = 0;
private int mouseDWheel = 0;
-
public ExtraPage(GuiProfileViewer instance) {
super(instance);
getInstance().killDeathSearchTextField.setSize(80, 12);
@@ -109,7 +108,8 @@ public class ExtraPage extends GuiProfileViewerPage {
float xStart,
float yStartTop,
float xOffset,
- float yOffset) {
+ float yOffset
+ ) {
int guiLeft = GuiProfileViewer.getGuiLeft();
int guiTop = GuiProfileViewer.getGuiTop();
yStartTop = yStartTop + 78;
@@ -448,31 +448,28 @@ public class ExtraPage extends GuiProfileViewerPage {
}
}
- getInstance().killDeathSearchTextField.render((int) (guiLeft + xStart + xOffset * 3), (int) (guiTop + yStartBottom + 77));
+ getInstance().killDeathSearchTextField.render(
+ (int) (guiLeft + xStart + xOffset * 3),
+ (int) (guiTop + yStartBottom + 77)
+ );
float killDeathX = guiLeft + xStart + xOffset * 3;
- if(mouseX >= killDeathX && mouseX <= killDeathX+76) {
- if(mouseY >= guiTop + yStartTop && mouseY <= guiTop + yStartTop + 65) {
- if(mouseDWheel != 0) {if(mouseDWheel > 0) {killScroll-=1;} else {killScroll+=1;}} mouseDWheel = Mouse.getDWheel();
- if(killScroll < 0) {killScroll = 0;}
- } else if(mouseY >= guiTop + yStartBottom && mouseY <= guiTop + yStartBottom + 65) {
- if(mouseDWheel != 0) {if(mouseDWheel > 0) {deathScroll-=1;} else {deathScroll+=1;}} mouseDWheel = Mouse.getDWheel();
- if(deathScroll < 0) {deathScroll = 0;}
- }
-
- }
int index = 0;
int skipCount = 0;
+ int renderedKills = 0;
for (int killCount : topKills.descendingKeySet()) {
Set<String> kills = topKills.get(killCount);
for (String killType : kills) {
- boolean isSearch = getInstance().killDeathSearchTextField.getText().isEmpty() || killType.toLowerCase(Locale.ROOT).contains(getInstance().killDeathSearchTextField.getText().toLowerCase(Locale.ROOT));
- float killY = guiTop + yStartTop + yOffset * ((index-skipCount) - killScroll);
- if(!isSearch) skipCount++;
- if(isSearch && killY+6 < guiTop+yStartTop+65 && killY >= guiTop + yStartTop) {
+ boolean isSearch =
+ getInstance().killDeathSearchTextField.getText().isEmpty() || killType.toLowerCase(Locale.ROOT).contains(
+ getInstance().killDeathSearchTextField.getText().toLowerCase(Locale.ROOT));
+ float killY = guiTop + yStartTop + yOffset * ((index - skipCount) - killScroll);
+ if (!isSearch) skipCount++;
+ if (isSearch && killY + 6 < guiTop + yStartTop + 65 && killY >= guiTop + yStartTop) {
+ renderedKills++;
Utils.renderAlignedString(
- EnumChatFormatting.YELLOW + killType + " Kills",
+ EnumChatFormatting.YELLOW + "K: " + killType,
EnumChatFormatting.WHITE.toString() + killCount,
killDeathX,
killY,
@@ -480,21 +477,25 @@ public class ExtraPage extends GuiProfileViewerPage {
);
}
-
index++;
}
}
+
index = 0;
skipCount = 0;
+ int renderedDeaths = 0;
for (int deathCount : topDeaths.descendingKeySet()) {
Set<String> deaths = topDeaths.get(deathCount);
for (String deathType : deaths) {
- boolean isSearch = getInstance().killDeathSearchTextField.getText().isEmpty() || deathType.toLowerCase(Locale.ROOT).contains(getInstance().killDeathSearchTextField.getText().toLowerCase(Locale.ROOT));
- float deathY = guiTop + yStartBottom + yOffset * ((index-skipCount) - deathScroll);
- if(!isSearch) skipCount++;
- if(isSearch && deathY+6 < guiTop+yStartBottom+65 && deathY >= guiTop + yStartBottom) {
+ boolean isSearch =
+ getInstance().killDeathSearchTextField.getText().isEmpty() || deathType.toLowerCase(Locale.ROOT).contains(
+ getInstance().killDeathSearchTextField.getText().toLowerCase(Locale.ROOT));
+ float deathY = guiTop + yStartBottom + yOffset * ((index - skipCount) - deathScroll);
+ if (!isSearch) skipCount++;
+ if (isSearch && deathY + 6 < guiTop + yStartBottom + 65 && deathY >= guiTop + yStartBottom) {
+ renderedDeaths++;
Utils.renderAlignedString(
- EnumChatFormatting.YELLOW + "Deaths: " + deathType,
+ EnumChatFormatting.YELLOW + "D: " + deathType,
EnumChatFormatting.WHITE.toString() + deathCount,
killDeathX,
deathY,
@@ -504,6 +505,38 @@ public class ExtraPage extends GuiProfileViewerPage {
index++;
}
}
+
+ mouseDWheel = Mouse.getDWheel();
+ if (mouseX >= killDeathX && mouseX <= killDeathX + 76) {
+ if (mouseY >= guiTop + yStartTop && mouseY <= guiTop + yStartTop + 65) {
+ if (mouseDWheel > 0) {
+ killScroll -= 1;
+ } else if (mouseDWheel < 0) {
+ killScroll += 1;
+ }
+
+ if (killScroll < 0) {
+ killScroll = 0;
+ }
+ } else if (mouseY >= guiTop + yStartBottom && mouseY <= guiTop + yStartBottom + 65) {
+ if (mouseDWheel > 0) {
+ deathScroll -= 1;
+ } else if (mouseDWheel < 0) {
+ deathScroll += 1;
+ }
+ if (deathScroll < 0) {
+ deathScroll = 0;
+ }
+
+ }
+ }
+
+ if (killScroll > renderedDeaths) {
+ killScroll = renderedDeaths;
+ }
+ if (deathScroll > renderedKills) {
+ deathScroll = renderedKills;
+ }
}
private String getTimeSinceString(JsonObject profileInfo, String path) {