aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorCobble8 <41165207+Cobble8@users.noreply.github.com>2022-10-21 10:28:32 -0400
committerGitHub <noreply@github.com>2022-10-21 07:28:32 -0700
commit78714fc2fddb99ba9f1239d7d0d95837a312cbb8 (patch)
treeeee79149c76fedf4b6665a6a9e509620984c2d61 /src/main/java
parente95971ee12531b14246d9a31eff0c8b4e66bfe18 (diff)
downloadNotEnoughUpdates-78714fc2fddb99ba9f1239d7d0d95837a312cbb8.tar.gz
NotEnoughUpdates-78714fc2fddb99ba9f1239d7d0d95837a312cbb8.tar.bz2
NotEnoughUpdates-78714fc2fddb99ba9f1239d7d0d95837a312cbb8.zip
Made cool kill/death stuff in profile viewer (#376)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java97
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java5
2 files changed, 84 insertions, 18 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 f8da4144..a0af254c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java
@@ -31,8 +31,10 @@ import net.minecraft.client.Minecraft;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import org.apache.commons.lang3.text.WordUtils;
+import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
+import java.io.IOException;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
@@ -41,6 +43,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
@@ -51,9 +54,43 @@ public class ExtraPage extends GuiProfileViewerPage {
private static final ResourceLocation pv_extra = new ResourceLocation("notenoughupdates:pv_extra.png");
private TreeMap<Integer, Set<String>> topKills = null;
private TreeMap<Integer, Set<String>> topDeaths = null;
+ private int deathScroll = 0;
+ private int killScroll = 0;
+ private int mouseDWheel = 0;
+
public ExtraPage(GuiProfileViewer instance) {
super(instance);
+ getInstance().killDeathSearchTextField.setSize(80, 12);
+ }
+
+ @Override
+ public void keyTyped(char typedChar, int keyCode) throws IOException {
+ super.keyTyped(typedChar, keyCode);
+ if (getInstance().killDeathSearchTextField.getFocus()) {
+ getInstance().killDeathSearchTextField.keyTyped(typedChar, keyCode);
+ killScroll = 0;
+ deathScroll = 0;
+ }
+ }
+
+ @Override
+ public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ //Note: don't know why it made me make it return a boolean, but it fixed the error, so I left it alone.
+
+ //Dimensions: X: guiLeft + xStart + xOffset * 3, Y: guiTop + yStartBottom + 77, Width: 80, Height: 12
+ if (mouseX >= GuiProfileViewer.getGuiLeft() + 22 + 103 * 3 &&
+ mouseX <= GuiProfileViewer.getGuiLeft() + 22 + 103 * 3 + 80 &&
+ mouseY >= GuiProfileViewer.getGuiTop() + 105 + 77 && mouseY <= GuiProfileViewer.getGuiTop() + 105 + 77 + 12) {
+ getInstance().killDeathSearchTextField.mouseClicked(mouseX, mouseY, mouseButton);
+ getInstance().playerNameTextField.otherComponentClick();
+ return true;
+ }
+
+ getInstance().killDeathSearchTextField.otherComponentClick();
+
+ return false;
}
// pls update in the future tyvm !!!
@@ -411,35 +448,59 @@ public class ExtraPage extends GuiProfileViewerPage {
}
}
+ 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;
for (int killCount : topKills.descendingKeySet()) {
- if (index >= 6) break;
Set<String> kills = topKills.get(killCount);
for (String killType : kills) {
- if (index >= 6) break;
- Utils.renderAlignedString(
- EnumChatFormatting.YELLOW + killType + " Kills",
- EnumChatFormatting.WHITE.toString() + killCount,
- guiLeft + xStart + xOffset * 3,
- guiTop + yStartTop + yOffset * index,
- 76
- );
+ 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) {
+ Utils.renderAlignedString(
+ EnumChatFormatting.YELLOW + killType + " Kills",
+ EnumChatFormatting.WHITE.toString() + killCount,
+ killDeathX,
+ killY,
+ 76
+ );
+ }
+
+
index++;
}
}
index = 0;
+ skipCount = 0;
for (int deathCount : topDeaths.descendingKeySet()) {
- if (index >= 6) break;
Set<String> deaths = topDeaths.get(deathCount);
for (String deathType : deaths) {
- if (index >= 6) break;
- Utils.renderAlignedString(
- EnumChatFormatting.YELLOW + "Deaths: " + deathType,
- EnumChatFormatting.WHITE.toString() + deathCount,
- guiLeft + xStart + xOffset * 3,
- guiTop + yStartBottom + yOffset * index,
- 76
- );
+ 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) {
+ Utils.renderAlignedString(
+ EnumChatFormatting.YELLOW + "Deaths: " + deathType,
+ EnumChatFormatting.WHITE.toString() + deathCount,
+ killDeathX,
+ deathY,
+ 76
+ );
+ }
index++;
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
index c78a6167..f327dae5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
@@ -176,6 +176,7 @@ public class GuiProfileViewer extends GuiScreen {
);
public final GuiElementTextField playerNameTextField;
public final GuiElementTextField inventoryTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
+ public final GuiElementTextField killDeathSearchTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
private final Map<ProfileViewerPage, GuiProfileViewerPage> pages = new HashMap<>();
public int sizeX;
public int sizeY;
@@ -874,6 +875,7 @@ public class GuiProfileViewer extends GuiScreen {
currentPage = page;
inventoryTextField.otherComponentClick();
playerNameTextField.otherComponentClick();
+ killDeathSearchTextField.otherComponentClick();
return;
}
}
@@ -890,6 +892,7 @@ public class GuiProfileViewer extends GuiScreen {
if (mouseY > guiTop + sizeY + 5 && mouseY < guiTop + sizeY + 25) {
playerNameTextField.mouseClicked(mouseX, mouseY, mouseButton);
inventoryTextField.otherComponentClick();
+ killDeathSearchTextField.otherComponentClick();
return;
}
}
@@ -961,11 +964,13 @@ public class GuiProfileViewer extends GuiScreen {
}
playerNameTextField.otherComponentClick();
inventoryTextField.otherComponentClick();
+ killDeathSearchTextField.otherComponentClick();
return;
}
profileDropdownSelected = false;
playerNameTextField.otherComponentClick();
inventoryTextField.otherComponentClick();
+ killDeathSearchTextField.otherComponentClick();
}
@Override