Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deaths and kills scrolling in /pv #1323

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -568,18 +568,18 @@ public void drawPage(int mouseX, int mouseY, float partialTicks) {

float killDeathX = guiLeft + xStart + xOffset * 3;

int index = 0;
int skipCount = 0;
int indexKills = 0;
int skipCountKills = 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) {
float killY = guiTop + yStartTop + yOffset * ((indexKills - skipCountKills) - killScroll);
if (!isSearch) skipCountKills++;
if (isSearch && killY + 6 < guiTop + yStartTop + 75 && killY >= guiTop + yStartTop) {
renderedKills++;
Utils.renderAlignedString(
EnumChatFormatting.YELLOW + "K: " + killType,
Expand All @@ -590,22 +590,22 @@ public void drawPage(int mouseX, int mouseY, float partialTicks) {
);
}

index++;
indexKills++;
}
}

index = 0;
skipCount = 0;
int indexDeaths = 0;
int skipCountDeaths = 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) {
float deathY = guiTop + yStartBottom + yOffset * ((indexDeaths - skipCountDeaths) - deathScroll);
if (!isSearch) skipCountDeaths++;
if (isSearch && deathY + 6 < guiTop + yStartBottom + 75 && deathY >= guiTop + yStartBottom) {
renderedDeaths++;
Utils.renderAlignedString(
EnumChatFormatting.YELLOW + "D: " + deathType,
Expand All @@ -615,7 +615,7 @@ public void drawPage(int mouseX, int mouseY, float partialTicks) {
76
);
}
index++;
indexDeaths++;
}
}

Expand Down Expand Up @@ -644,11 +644,13 @@ public void drawPage(int mouseX, int mouseY, float partialTicks) {
}
}

if (killScroll > renderedDeaths) {
killScroll = renderedDeaths;
int killsMaxScroll = (indexKills - skipCountKills) - renderedKills;
if (killScroll > killsMaxScroll) {
killScroll = killsMaxScroll;
}
if (deathScroll > renderedKills) {
deathScroll = renderedKills;
int deathsMaxScroll = (indexDeaths - skipCountDeaths) - renderedDeaths;
if (deathScroll > deathsMaxScroll) {
deathScroll = deathsMaxScroll;
}
}

Expand Down
Loading