diff options
Diffstat (limited to 'src/main/java')
13 files changed, 828 insertions, 9 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/api/ApiFetchur.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/api/ApiFetchur.java index d760bd27..0a80d93c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/api/ApiFetchur.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/api/ApiFetchur.java @@ -409,8 +409,10 @@ public class ApiFetchur { } } if (playerData.has("dungeons")) { - String id = getOrDefault(playerData, "selected_dungeon_class", null); + String id = getOrDefault(playerData.getAsJsonObject("dungeons"), "selected_dungeon_class", null); + System.out.println(id); DungeonClass dungeonClass = DungeonClass.getClassByJsonName(id); + System.out.println(dungeonClass); playerProfile.setSelectedClass(dungeonClass); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonFloorStat.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonFloorStat.java new file mode 100644 index 00000000..f72dcce4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonFloorStat.java @@ -0,0 +1,80 @@ +package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; + +import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; +import kr.syeyoung.dungeonsguide.features.impl.party.api.*; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; + +import java.awt.*; +import java.util.Arrays; + +public class DataRenderDungeonFloorStat implements DataRenderer { + private DungeonType dungeonType; + private int floor; + public DataRenderDungeonFloorStat(DungeonType dungeonType, int floor) { + this.dungeonType = dungeonType; + this.floor = floor; + } + + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + floor; + + boolean flag = false; + DungeonSpecificData<DungeonStat> dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); + if (dungeonStatDungeonSpecificData != null) { + FloorSpecificData<DungeonStat.PlayedFloor> playedFloorFloorSpecificData = dungeonStatDungeonSpecificData.getData().getPlays().get(floor); + if (playedFloorFloorSpecificData != null) { + flag = true; + fr.drawString("§b" + floorName + " §a" + playedFloorFloorSpecificData.getData().getBestScore() + " §f" + playedFloorFloorSpecificData.getData().getCompletions() + "§7/§f" + playedFloorFloorSpecificData.getData().getWatcherKills() + "§7/§f" + playedFloorFloorSpecificData.getData().getTimes_played() + " §7(" + (int) (playedFloorFloorSpecificData.getData().getCompletions() / (double) playedFloorFloorSpecificData.getData().getWatcherKills()) + "%)", 0, 0, -1); + fr.drawString("§6S+ §e" + (playedFloorFloorSpecificData.getData().getFastestTimeSPlus() != -1 ? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeSPlus()) : "n/a") + " §6S §e" + (playedFloorFloorSpecificData.getData().getFastestTimeS() != -1 ? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeS()) : "n/a"), 0, fr.FONT_HEIGHT, -1); + } + } + if (!flag) { + fr.drawString("§cNo Stat for "+floorName, 0,0,-1); + } + + return getDimension(); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + floor; + + + fr.drawString("§b"+floorName+" §a305 §f10§7/§f35§7/§f50 §7("+(int)(1000.0/35.0)+"%)", 0,0,-1); + fr.drawString("§6S+ §e10m 53s §6S §e15m 13s", 0, fr.FONT_HEIGHT, -1); + return getDimension(); + } + + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + + DungeonSpecificData<DungeonStat> dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); + if (dungeonStatDungeonSpecificData == null) return; + FloorSpecificData<DungeonStat.PlayedFloor> playedFloorFloorSpecificData = dungeonStatDungeonSpecificData.getData().getPlays().get(floor); + if (playedFloorFloorSpecificData == null) return; + String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + floor; + + FeatureEditPane.drawHoveringText(Arrays.asList( + "§bFloor "+floorName, + "§bBest Score§7: §f"+playedFloorFloorSpecificData.getData().getBestScore(), + "§bTotal Completions§7: §f"+playedFloorFloorSpecificData.getData().getCompletions(), + "§bTotal Watcher kills§7: §f"+playedFloorFloorSpecificData.getData().getWatcherKills(), + "§bTotal Runs§7: §f"+playedFloorFloorSpecificData.getData().getTimes_played(), + "§bFastest S+§7: §f"+(playedFloorFloorSpecificData.getData().getFastestTimeSPlus() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeSPlus()) : "n/a"), + "§bFastest S§7: §f"+(playedFloorFloorSpecificData.getData().getFastestTimeS() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeS()) : "n/a"), + "§bFastest Run§7: §f"+(playedFloorFloorSpecificData.getData().getFastestTime() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTime()) : "n/a"), + "§bMost Mobs Killed§7: §f"+playedFloorFloorSpecificData.getData().getMostMobsKilled(), + "§bTotal Mobs Killed§7: §f"+playedFloorFloorSpecificData.getData().getMobsKilled() + ), mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonHighestFloorStat.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonHighestFloorStat.java new file mode 100644 index 00000000..631fad58 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonHighestFloorStat.java @@ -0,0 +1,82 @@ +package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; + +import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; +import kr.syeyoung.dungeonsguide.features.impl.party.api.*; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; + +import java.awt.*; +import java.util.Arrays; + +public class DataRenderDungeonHighestFloorStat implements DataRenderer { + private DungeonType dungeonType; + public DataRenderDungeonHighestFloorStat(DungeonType dungeonType) { + this.dungeonType = dungeonType; + } + + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + boolean flag = false; + DungeonSpecificData<DungeonStat> dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); + if (dungeonStatDungeonSpecificData != null) { + if (dungeonStatDungeonSpecificData.getData().getHighestCompleted() != -1) { + FloorSpecificData<DungeonStat.PlayedFloor> playedFloorFloorSpecificData = dungeonStatDungeonSpecificData.getData().getPlays().get(dungeonStatDungeonSpecificData.getData().getHighestCompleted()); + String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + dungeonStatDungeonSpecificData.getData().getHighestCompleted(); + if (playedFloorFloorSpecificData != null) { + flag = true; + fr.drawString("§bH: " + floorName + " §a" + playedFloorFloorSpecificData.getData().getBestScore() + " §f" + playedFloorFloorSpecificData.getData().getCompletions() + "§7/§f" + playedFloorFloorSpecificData.getData().getWatcherKills() + "§7/§f" + playedFloorFloorSpecificData.getData().getTimes_played() + " §7(" + (int) (playedFloorFloorSpecificData.getData().getCompletions() / (double) playedFloorFloorSpecificData.getData().getWatcherKills()) + "%)", 0, 0, -1); + fr.drawString("§6S+ §e" + (playedFloorFloorSpecificData.getData().getFastestTimeSPlus() != -1 ? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeSPlus()) : "n/a") + " §6S §e" + (playedFloorFloorSpecificData.getData().getFastestTimeS() != -1 ? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeS()) : "n/a"), 0, fr.FONT_HEIGHT, -1); + } + } + } + if (!flag) { + fr.drawString("§cNo Highest Floor for ", 0,0,-1); + fr.drawString("§c"+dungeonType.getFamiliarName(), 0,0,-1); + } + + return getDimension(); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + "9"; + + + fr.drawString("§bH: "+floorName+" §a305 §f10§7/§f35§7/§f50 §7("+(int)(1000.0/35.0)+"%)", 0,0,-1); + fr.drawString("§6S+ §e10m 53s §6S §e15m 13s", 0, fr.FONT_HEIGHT, -1); + return getDimension(); + } + + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + + DungeonSpecificData<DungeonStat> dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); + if (dungeonStatDungeonSpecificData == null) return; + if (dungeonStatDungeonSpecificData.getData().getHighestCompleted() == -1) return; + FloorSpecificData<DungeonStat.PlayedFloor> playedFloorFloorSpecificData = dungeonStatDungeonSpecificData.getData().getPlays().get( dungeonStatDungeonSpecificData.getData().getHighestCompleted()); + if (playedFloorFloorSpecificData == null) return; + String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + dungeonStatDungeonSpecificData.getData().getHighestCompleted(); + + FeatureEditPane.drawHoveringText(Arrays.asList( + "§bFloor "+floorName, + "§bBest Score§7: §f"+playedFloorFloorSpecificData.getData().getBestScore(), + "§bTotal Completions§7: §f"+playedFloorFloorSpecificData.getData().getCompletions(), + "§bTotal Watcher kills§7: §f"+playedFloorFloorSpecificData.getData().getWatcherKills(), + "§bTotal Runs§7: §f"+playedFloorFloorSpecificData.getData().getTimes_played(), + "§bFastest S+§7: §f"+(playedFloorFloorSpecificData.getData().getFastestTimeSPlus() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeSPlus()) : "n/a"), + "§bFastest S§7: §f"+(playedFloorFloorSpecificData.getData().getFastestTimeS() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeS()) : "n/a"), + "§bFastest Run§7: §f"+(playedFloorFloorSpecificData.getData().getFastestTime() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTime()) : "n/a"), + "§bMost Mobs Killed§7: §f"+playedFloorFloorSpecificData.getData().getMostMobsKilled(), + "§bTotal Mobs Killed§7: §f"+playedFloorFloorSpecificData.getData().getMobsKilled() + ), mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderer.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderer.java index 95847014..b1ceff9e 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderer.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderer.java @@ -6,4 +6,10 @@ import java.awt.*; public interface DataRenderer { Dimension renderData(PlayerProfile playerProfile); + void onHover(PlayerProfile playerProfile, int mouseX, int mouseY); + + + Dimension renderDummy(); + + Dimension getDimension(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererClassLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererClassLv.java new file mode 100644 index 00000000..363cbeee --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererClassLv.java @@ -0,0 +1,64 @@ +package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; + +import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; +import kr.syeyoung.dungeonsguide.features.impl.party.api.*; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import kr.syeyoung.dungeonsguide.utils.XPUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; + +import java.awt.*; +import java.util.Arrays; + +public class DataRendererClassLv implements DataRenderer { + private DungeonClass dungeonClass; + public DataRendererClassLv(DungeonClass dungeonClass) { + this.dungeonClass = dungeonClass; + } + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + ClassSpecificData<PlayerProfile.PlayerClassData> dungeonStatDungeonSpecificData = playerProfile.getPlayerClassData().get(dungeonClass); + boolean selected = playerProfile.getSelectedClass() == dungeonClass; +// System.out.println(playerProfile.getSelectedClass()); + if (dungeonStatDungeonSpecificData == null) { + fr.drawString(dungeonClass.getFamilarName(), 0,0, 0xFF55ffff); + fr.drawString("Unknown", fr.getStringWidth(dungeonClass.getFamilarName()+" "),0,0xFFFFFFFF); + if (selected) + fr.drawString("★", fr.getStringWidth(dungeonClass.getFamilarName()+" Unknown "),0,0xFFAAAAAA); + } else { + XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); + fr.drawString(dungeonClass.getFamilarName(), 0,0, 0xFF55ffff); + fr.drawString(xpCalcResult.getLevel()+"", fr.getStringWidth(dungeonClass.getFamilarName()+" "),0,0xFFFFFFFF); + if (selected) + fr.drawString("★", fr.getStringWidth(dungeonClass.getFamilarName()+" "+xpCalcResult.getLevel()+" "),0,0xFFAAAAAA); + + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,xpCalcResult.getRemainingXp() == 0 ? 1 : (float) (xpCalcResult.getNextLvXp() / xpCalcResult.getRemainingXp())); + } + + return new Dimension(100, fr.FONT_HEIGHT*2); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString(dungeonClass.getFamilarName(), 0,0, 0xFF55ffff); + fr.drawString("99", fr.getStringWidth(dungeonClass.getFamilarName()+" "),0,0xFFFFFFFF); + fr.drawString("★", fr.getStringWidth(dungeonClass.getFamilarName()+" 99 "),0,0xFFAAAAAA); + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,1.0f); + return new Dimension(100, fr.FONT_HEIGHT*2); + } + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + ClassSpecificData<PlayerProfile.PlayerClassData> dungeonStatDungeonSpecificData = playerProfile.getPlayerClassData().get(dungeonClass); + if (dungeonStatDungeonSpecificData == null) return; + XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); + FeatureEditPane.drawHoveringText(Arrays.asList("§bCurrent Lv§7: §e"+xpCalcResult.getLevel(),"§bExp§7: §e"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "§7/§e"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "§bTotal Xp§7: §e"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererDungeonLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererDungeonLv.java new file mode 100644 index 00000000..f9a41e6f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererDungeonLv.java @@ -0,0 +1,60 @@ +package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; + +import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; +import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonSpecificData; +import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonStat; +import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonType; +import kr.syeyoung.dungeonsguide.features.impl.party.api.PlayerProfile; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import kr.syeyoung.dungeonsguide.utils.XPUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; + +import java.awt.*; +import java.util.Arrays; + +public class DataRendererDungeonLv implements DataRenderer { + private DungeonType dungeonType; + public DataRendererDungeonLv(DungeonType dungeonType) { + this.dungeonType = dungeonType; + } + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + DungeonSpecificData<DungeonStat> dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); + if (dungeonStatDungeonSpecificData == null) { + fr.drawString(dungeonType.getFamiliarName(), 0,0, 0xFFFF5555); + fr.drawString("Unknown", fr.getStringWidth(dungeonType.getFamiliarName()+" "),0,0xFFFFFFFF); + } else { + XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); + fr.drawString(dungeonType.getFamiliarName(), 0,0, 0xFFFF5555); + fr.drawString(xpCalcResult.getLevel()+"", fr.getStringWidth(dungeonType.getFamiliarName()+" "),0,0xFFFFFFFF); + + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,xpCalcResult.getRemainingXp() == 0 ? 1 : (float) (xpCalcResult.getNextLvXp() / xpCalcResult.getRemainingXp())); + } + + return new Dimension(100, fr.FONT_HEIGHT*2); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString(dungeonType.getFamiliarName(), 0,0, 0xFFFF5555); + fr.drawString("99", fr.getStringWidth(dungeonType.getFamiliarName()+" "),0,0xFFFFFFFF); + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,1.0f); + return new Dimension(100, fr.FONT_HEIGHT*2); + } + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + DungeonSpecificData<DungeonStat> dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); + if (dungeonStatDungeonSpecificData == null) return; + XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); + FeatureEditPane.drawHoveringText(Arrays.asList("§bCurrent Lv§7: §e"+xpCalcResult.getLevel(),"§bExp§7: §e"+TextUtils.format((long)xpCalcResult.getRemainingXp()) + "§7/§e"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "§bTotal Xp§7: §e"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererEditor.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererEditor.java index 808fa8b3..1e30e5eb 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererEditor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererEditor.java @@ -2,6 +2,16 @@ package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; import kr.syeyoung.dungeonsguide.gui.MPanel; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; + +import java.awt.*; +import java.util.HashSet; +import java.util.List; +import java.util.Set; public class DataRendererEditor extends MPanel { private FeatureViewPlayerOnJoin feature; @@ -11,4 +21,283 @@ public class DataRendererEditor extends MPanel { this.config = config; this.feature = featureViewPlayerOnJoin; } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(5,5,parentWidth-10, 260)); + } + + private String currentlySelected; + private int selectedX; + private int selectedY; + private int lastX; + private int lastY; + private int scrollY; + private final int baseWidth = 100; + private final int hamburgerWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth("=="); + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Gui.drawRect(0,0,getBounds().width, getBounds().height, 0xFF444444); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + + + fr.drawString("Current", (baseWidth + hamburgerWidth+10 -fr.getStringWidth("Current")) /2 , 4, 0xFFFFFFFF); + Gui.drawRect(4,4 + fr.FONT_HEIGHT + 3,baseWidth + hamburgerWidth+6 + 1, 236+ fr.FONT_HEIGHT + 3, 0xFF222222); + Gui.drawRect(5,5+ fr.FONT_HEIGHT + 3,baseWidth + hamburgerWidth + 5 + 1, 235+ fr.FONT_HEIGHT + 3, 0xFF555555); + Gui.drawRect(5 + hamburgerWidth,4+ fr.FONT_HEIGHT + 3,6 + hamburgerWidth, 236+ fr.FONT_HEIGHT + 3, 0xFF222222); + + fr.drawString("Available", (310 + baseWidth + hamburgerWidth -fr.getStringWidth("Available")) / 2, 4, 0xFFFFFFFF); + Gui.drawRect(154,4 + fr.FONT_HEIGHT + 3,150 + baseWidth + hamburgerWidth + 6+1, 236+ fr.FONT_HEIGHT + 3, 0xFF222222); + Gui.drawRect(155,5+ fr.FONT_HEIGHT + 3,150 + baseWidth + hamburgerWidth + 5+1, 235+ fr.FONT_HEIGHT + 3, 0xFF555555); + Gui.drawRect(155 + hamburgerWidth,4 + fr.FONT_HEIGHT + 3,156 + hamburgerWidth, 236+ fr.FONT_HEIGHT + 3, 0xFF222222); + + GlStateManager.pushMatrix(); + clip(sr, scissor.x + 6+hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + GlStateManager.translate(6+hamburgerWidth, 5+fr.FONT_HEIGHT+3, 0); + int culmutativeY = 0; + int relSelectedY = selectedY - (5+ fr.FONT_HEIGHT + 3); + boolean drewit = false; + for (String datarenderers : feature.<List<String>>getParameter("datarenderers").getValue()) { + + if (0 <= selectedX && selectedX <= hamburgerWidth+11 && currentlySelected != null) { + DataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(currentlySelected); + Dimension dim; + if (dataRenderer == null) dim = new Dimension(0,fr.FONT_HEIGHT*2); + else dim = dataRenderer.getDimension(); + + if (culmutativeY + dim.height > relSelectedY && relSelectedY >= culmutativeY && !drewit) { + clip(sr, scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + if (dataRenderer == null) { + fr.drawString("Couldn't find Datarenderer", 0,0, 0xFFFF0000); + fr.drawString(currentlySelected, 0,fr.FONT_HEIGHT, 0xFFFF0000); + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.renderDummy(); + GlStateManager.popMatrix(); + } + clip(sr, scissor.x, scissor.y, scissor.width, scissor.height); + GlStateManager.translate(-hamburgerWidth-1, 0, 0); + Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFF777777); + fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + GlStateManager.translate(hamburgerWidth+1,dim.height,0); + drewit = true; + } + } + + DataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); + clip(sr, scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + Dimension dim; + + if (dataRenderer == null) { + fr.drawString("Couldn't find Datarenderer", 0,0, 0xFFFF0000); + fr.drawString(datarenderers, 0,fr.FONT_HEIGHT, 0xFFFF0000); + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.renderDummy(); + GlStateManager.popMatrix(); + } + clip(sr, scissor.x, scissor.y, scissor.width, scissor.height); + GlStateManager.translate(-hamburgerWidth-1, 0, 0); + Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFFAAAAAA); + fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + GlStateManager.translate(hamburgerWidth+1,dim.height,0); + + culmutativeY += dim.height; + } + + if (currentlySelected != null && new Rectangle(0,5+fr.FONT_HEIGHT + 3, hamburgerWidth+11, 232).contains(selectedX, selectedY) && !drewit) { + DataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(currentlySelected); + Dimension dim; + clip(sr, scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + if (dataRenderer == null) { + fr.drawString("Couldn't find Datarenderer", 0,0, 0xFFFF0000); + fr.drawString(currentlySelected, 0,fr.FONT_HEIGHT, 0xFFFF0000); + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.renderDummy(); + GlStateManager.popMatrix(); + } + clip(sr, scissor.x, scissor.y, scissor.width, scissor.height); + GlStateManager.translate(-hamburgerWidth-1, 0, 0); + Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFF777777); + fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + GlStateManager.translate(hamburgerWidth+1,dim.height,0); + } + GlStateManager.popMatrix(); + + + GlStateManager.pushMatrix(); + GlStateManager.translate(156+hamburgerWidth, 5+fr.FONT_HEIGHT+3 - scrollY, 0); + + Set<String> rest = new HashSet<>(DataRendererRegistry.getValidDataRenderer()); + rest.removeAll( feature.<List<String>>getParameter("datarenderers").getValue()); + rest.remove(currentlySelected); + for (String datarenderers : rest) { + DataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); + clip(sr, scissor.x + 156 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + Dimension dim; + if (dataRenderer == null) { + fr.drawString("Couldn't find Datarenderer", 0,0, 0xFFFF0000); + fr.drawString(datarenderers, 0,fr.FONT_HEIGHT, 0xFFFF0000); + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.renderDummy(); + GlStateManager.popMatrix(); + } + clip(sr, scissor.x + 156, scissor.y + 5+fr.FONT_HEIGHT+3, hamburgerWidth, 230); + GlStateManager.translate(-hamburgerWidth-1, 0, 0); + Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFFAAAAAA); + fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + GlStateManager.translate(hamburgerWidth+1,dim.height,0); + } + GlStateManager.popMatrix(); + clip(sr, 0,0,sr.getScaledWidth(), sr.getScaledHeight()); + { + if (currentlySelected != null) { + GlStateManager.pushMatrix(); + GlStateManager.translate(selectedX+hamburgerWidth+1, selectedY, 0); + DataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(currentlySelected); + Dimension dim; + if (dataRenderer == null) { + fr.drawString("Couldn't find Datarenderer", 0, 0, 0xFFFF0000); + fr.drawString(currentlySelected, 0, fr.FONT_HEIGHT, 0xFFFF0000); + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.renderDummy(); + GlStateManager.popMatrix(); + } + GlStateManager.translate(-hamburgerWidth-1, 0, 0); + Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFFAAAAAA); + fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + GlStateManager.popMatrix(); + } + } + clip(sr, scissor.x, scissor.y, scissor.width, scissor.height); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + super.mouseClicked(absMouseX, absMouseY, relMouseX, relMouseY, mouseButton); + lastX = relMouseX; + lastY = relMouseY; + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int legitRelY = relMouseY - (5+fr.FONT_HEIGHT+3); + if (new Rectangle(155,5+fr.FONT_HEIGHT + 3, hamburgerWidth, 230).contains(relMouseX, relMouseY)) { + Set<String> rest = new HashSet<>(DataRendererRegistry.getValidDataRenderer()); + rest.removeAll( feature.<List<String>>getParameter("datarenderers").getValue()); + rest.remove(currentlySelected); + int culmutativeY = 0; + for (String datarenderers : rest) { + DataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); + Dimension dim; + if (dataRenderer == null) { + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.getDimension(); + GlStateManager.popMatrix(); + } + culmutativeY += dim.height; + + if (legitRelY < culmutativeY) { + currentlySelected = datarenderers; + selectedX = 155; + selectedY = culmutativeY - dim.height + 5+fr.FONT_HEIGHT + 3 - scrollY; + break; + } + } + } + if (new Rectangle(5,5+fr.FONT_HEIGHT + 3, hamburgerWidth, 230).contains(relMouseX, relMouseY)) { + List<String> rest = feature.<List<String>>getParameter("datarenderers").getValue(); + int culmutativeY = 0; + for (String datarenderers : rest) { + DataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); + Dimension dim; + if (dataRenderer == null) { + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.getDimension(); + GlStateManager.popMatrix(); + } + culmutativeY += dim.height; + + if (legitRelY < culmutativeY) { + currentlySelected = datarenderers; + selectedX = 5; + selectedY = culmutativeY - dim.height + 5+fr.FONT_HEIGHT + 3; + rest.remove(datarenderers); + break; + } + } + } + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + super.mouseClickMove(absMouseX, absMouseY, relMouseX, relMouseY, clickedMouseButton, timeSinceLastClick); + if (currentlySelected != null) { + int dx = relMouseX - lastX; + int dy = relMouseY - lastY; + selectedX += dx; + selectedY += dy; + } + lastX = relMouseX; + lastY = relMouseY; + } + + @Override + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { + super.mouseReleased(absMouseX, absMouseY, relMouseX, relMouseY, state); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int legitRelY = selectedY - (5+fr.FONT_HEIGHT+3); + if (currentlySelected != null && new Rectangle(0,5+fr.FONT_HEIGHT + 3, hamburgerWidth+11, 232).contains(selectedX, selectedY)) { + Set<String> rest = new HashSet<>(DataRendererRegistry.getValidDataRenderer()); + int culmutativeY = 0; + List<String > asdasdkasd = feature.<List<String>>getParameter("datarenderers").getValue(); + int index = asdasdkasd.size(); + for (int i = 0; i <asdasdkasd.size(); i++) { + String datarenderers = asdasdkasd.get(i); + DataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); + Dimension dim; + if (dataRenderer == null) { + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.getDimension(); + GlStateManager.popMatrix(); + } + culmutativeY += dim.height; + + if (legitRelY < culmutativeY) { + index = i; + break; + } + } + + asdasdkasd.add(index, currentlySelected); + } + + currentlySelected = null; + } + + @Override + public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + super.mouseScrolled(absMouseX, absMouseY, relMouseX0, relMouseY0, scrollAmount); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + if (!new Rectangle(155,5+fr.FONT_HEIGHT + 3, hamburgerWidth, 230).contains(relMouseX0, relMouseY0)) return; + + if (scrollAmount > 0) scrollY += 20; + if (scrollAmount < 0) scrollY -= 20; + if (scrollY < 0) scrollY = 0; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererFairySouls.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererFairySouls.java new file mode 100644 index 00000000..884c1c58 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererFairySouls.java @@ -0,0 +1,39 @@ +package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; + +import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; +import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonSpecificData; +import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonStat; +import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonType; +import kr.syeyoung.dungeonsguide.features.impl.party.api.PlayerProfile; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import kr.syeyoung.dungeonsguide.utils.XPUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; + +import java.awt.*; +import java.util.Arrays; + +public class DataRendererFairySouls implements DataRenderer { + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("§eFairy Souls §f"+playerProfile.getFairySouls(), 0,0,-1); + return new Dimension(100, fr.FONT_HEIGHT); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("§eFairy Souls §f300", 0,0,-1); + return new Dimension(100, fr.FONT_HEIGHT); + } + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererRegistry.java index a8085f0d..4a97bd3c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererRegistry.java @@ -1,5 +1,9 @@ package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; +import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonClass; +import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonType; +import kr.syeyoung.dungeonsguide.features.impl.party.api.Skill; + import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -14,4 +18,22 @@ public class DataRendererRegistry { public static Set<String> getValidDataRenderer() { return dataRendererMap.keySet(); } + + static { + dataRendererMap.put("catalv", new DataRendererDungeonLv(DungeonType.CATACOMBS)); + for (DungeonClass value : DungeonClass.values()) { + dataRendererMap.put("class_"+value.getJsonName()+"_lv", new DataRendererClassLv(value)); + } + dataRendererMap.put("selected_class_lv", new DataRendererSelectedClassLv()); + for (Skill value : Skill.values()) { + dataRendererMap.put("skill_"+value.getJsonName()+"_lv", new DataRendererSkillLv(value)); + } + for (DungeonType value : DungeonType.values()) { + for (Integer validFloor : value.getValidFloors()) { + dataRendererMap.put("dungeon_"+value.getJsonName()+"_"+validFloor+"_stat", new DataRenderDungeonFloorStat(value, validFloor)); + } + dataRendererMap.put("dungeon_"+value.getJsonName()+"_higheststat", new DataRenderDungeonHighestFloorStat(value)); + } + dataRendererMap.put("fairyouls", new DataRendererFairySouls()); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSelectedClassLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSelectedClassLv.java new file mode 100644 index 00000000..35478c5a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSelectedClassLv.java @@ -0,0 +1,56 @@ +package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; + +import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; +import kr.syeyoung.dungeonsguide.features.impl.party.api.ClassSpecificData; +import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonClass; +import kr.syeyoung.dungeonsguide.features.impl.party.api.PlayerProfile; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import kr.syeyoung.dungeonsguide.utils.XPUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; + +import java.awt.*; +import java.util.Arrays; + +public class DataRendererSelectedClassLv implements DataRenderer { + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + ClassSpecificData<PlayerProfile.PlayerClassData> dungeonStatDungeonSpecificData = playerProfile.getPlayerClassData().get(playerProfile.getSelectedClass()); + if (dungeonStatDungeonSpecificData == null) { + fr.drawString("Unknown Selected", 0,0, 0xFF55ffff); + } else { + XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); + fr.drawString(playerProfile.getSelectedClass().getFamilarName(), 0,0, 0xFF55ffff); + fr.drawString(xpCalcResult.getLevel()+"", fr.getStringWidth(playerProfile.getSelectedClass().getFamilarName()+" "),0,0xFFFFFFFF); + fr.drawString("★", fr.getStringWidth(playerProfile.getSelectedClass().getFamilarName()+" "+xpCalcResult.getLevel()+" "),0,0xFFAAAAAA); + + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,xpCalcResult.getRemainingXp() == 0 ? 1 : (float) (xpCalcResult.getNextLvXp() / xpCalcResult.getRemainingXp())); + } + + return new Dimension(100, fr.FONT_HEIGHT*2); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("SelectedClass", 0,0, 0xFF55ffff); + fr.drawString("99", fr.getStringWidth("SelectedClass "),0,0xFFFFFFFF); + fr.drawString("★", fr.getStringWidth("SelectedClass 99 "),0,0xFFAAAAAA); + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,1.0f); + return new Dimension(100, fr.FONT_HEIGHT*2); + } + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + ClassSpecificData<PlayerProfile.PlayerClassData> dungeonStatDungeonSpecificData = playerProfile.getPlayerClassData().get(playerProfile.getSelectedClass()); + if (dungeonStatDungeonSpecificData == null) return; + XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); + FeatureEditPane.drawHoveringText(Arrays.asList("§bCurrent Lv§7: §e"+xpCalcResult.getLevel(),"§bExp§7: §e"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "§7/§e"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "§bTotal Xp§7: §e"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSkillLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSkillLv.java new file mode 100644 index 00000000..16442f22 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSkillLv.java @@ -0,0 +1,60 @@ +package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; + +import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane; +import kr.syeyoung.dungeonsguide.features.impl.party.api.ClassSpecificData; +import kr.syeyoung.dungeonsguide.features.impl.party.api.DungeonClass; +import kr.syeyoung.dungeonsguide.features.impl.party.api.PlayerProfile; +import kr.syeyoung.dungeonsguide.features.impl.party.api.Skill; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import kr.syeyoung.dungeonsguide.utils.XPUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; + +import java.awt.*; +import java.util.Arrays; + +public class DataRendererSkillLv implements DataRenderer { + private Skill skill; + public DataRendererSkillLv(Skill skill) { + this.skill = skill; + } + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + Double xp = playerProfile.getSkillXp().get(skill); + if (xp == null) { + fr.drawString(skill.getFriendlyName(), 0,0, 0xFF55ffff); + fr.drawString("Unknown", fr.getStringWidth(skill.getFriendlyName()+" "),0,0xFFFFFFFF); + } else { + XPUtils.XPCalcResult xpCalcResult = XPUtils.getSkillXp(skill, xp); + fr.drawString(skill.getFriendlyName(), 0,0, 0xFF55ffff); + fr.drawString(xpCalcResult.getLevel()+"", fr.getStringWidth(skill.getFriendlyName()+" "),0,0xFFFFFFFF); + + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,xpCalcResult.getRemainingXp() == 0 ? 1 : (float) (xpCalcResult.getNextLvXp() / xpCalcResult.getRemainingXp())); + } + + return new Dimension(100, fr.FONT_HEIGHT*2); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString(skill.getFriendlyName(), 0,0, 0xFF55ffff); + fr.drawString("99", fr.getStringWidth(skill.getFriendlyName()+" "),0,0xFFFFFFFF); + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,1.0f); + return new Dimension(100, fr.FONT_HEIGHT*2); + } + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + Double xp = playerProfile.getSkillXp().get(skill); + if (xp == null) return; + XPUtils.XPCalcResult xpCalcResult = XPUtils.getSkillXp(skill, xp); + FeatureEditPane.drawHoveringText(Arrays.asList("§bCurrent Lv§7: §e"+xpCalcResult.getLevel(),"§bExp§7: §e"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "§7/§e"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "§bTotal Xp§7: §e"+ TextUtils.format(xp.longValue())),mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java index effbf35e..5e68e174 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java @@ -111,7 +111,7 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen if (popupRect == null) { - popupRect = new Rectangle(mouseX, mouseY, 190, 220); + popupRect = new Rectangle(mouseX, mouseY, 200, 220); if (popupRect.y + popupRect.height > scaledResolution.getScaledHeight()) { popupRect.y -= popupRect.y + popupRect.height - scaledResolution.getScaledHeight(); } @@ -170,18 +170,25 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen GlStateManager.pushMatrix(); GlStateManager.translate(95, 5, 0); + int culmutativeY = 5; + DataRenderer dataRendererToHover = null; for (String datarenderers : this.<List<String>>getParameter("datarenderers").getValue()) { DataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); + Dimension dim; if (dataRenderer == null) { fr.drawString("Couldn't find Datarenderer", 0,0, 0xFFFF0000); fr.drawString(datarenderers, 0,fr.FONT_HEIGHT, 0xFFFF0000); - GlStateManager.translate(0, fr.FONT_HEIGHT * 2, 0); + dim = new Dimension(0, fr.FONT_HEIGHT * 2); } else { GlStateManager.pushMatrix(); - Dimension dimension = dataRenderer.renderData(playerProfile.get()); + dim = dataRenderer.renderData(playerProfile.get()); GlStateManager.popMatrix(); - GlStateManager.translate(0,dimension.height,0); } + if (relX >= 95 && relX <= popupRect.width && relY >= culmutativeY && relY < culmutativeY+dim.height && dataRenderer != null) { + dataRendererToHover = dataRenderer; + } + culmutativeY += dim.height; + GlStateManager.translate(0,dim.height,0); } GlStateManager.popMatrix(); @@ -231,6 +238,9 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen } GL11.glDisable(GL11.GL_SCISSOR_TEST); + if (dataRendererToHover != null) { + dataRendererToHover.onHover(playerProfile.get(), relX, relY); + } GlStateManager.popMatrix(); // 33 66 108 130 154 // 5 75 } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java index b2722e77..72f5f793 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java @@ -14,10 +14,7 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.passive.EntityBat; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.Vec3; -import net.minecraft.util.Vector3d; +import net.minecraft.util.*; import org.lwjgl.opengl.GL11; import javax.vecmath.Vector3f; @@ -25,6 +22,58 @@ import java.awt.*; import java.util.List; public class RenderUtils { + public static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png"); + + public static void drawTexturedRect(float x, float y, float width, float height, int filter) { + drawTexturedRect(x, y, width, height, 0.0F, 1.0F, 0.0F, 1.0F, filter); + } + public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) { + GlStateManager.enableTexture2D(); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 771); + GL11.glTexParameteri(3553, 10241, filter); + GL11.glTexParameteri(3553, 10240, filter); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos((double)x, (double)(y + height), 0.0D).tex((double)uMin, (double)vMax).endVertex(); + worldrenderer.pos((double)(x + width), (double)(y + height), 0.0D).tex((double)uMax, (double)vMax).endVertex(); + worldrenderer.pos((double)(x + width), (double)y, 0.0D).tex((double)uMax, (double)vMin).endVertex(); + worldrenderer.pos((double)x, (double)y, 0.0D).tex((double)uMin, (double)vMin).endVertex(); + tessellator.draw(); + GL11.glTexParameteri(3553, 10241, 9728); + GL11.glTexParameteri(3553, 10240, 9728); + GlStateManager.disableBlend(); + } + public static void renderBar(float x, float y, float xSize, float completed) { + Minecraft.getMinecraft().getTextureManager().bindTexture(icons); + completed = (float)Math.round(completed / 0.05F) * 0.05F; + float notcompleted = 1.0F - completed; + int displayNum = 0; + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + float width = 0.0F; + if (completed < 0.5F && (displayNum == 1 || displayNum == 0)) { + width = (0.5F - completed) * xSize; + drawTexturedRect(x + xSize * completed, y, width, 5.0F, xSize * completed / 256.0F, xSize / 2.0F / 256.0F, 0.2890625F, 0.30859375F, 9728); + } + + if (completed < 1.0F && (displayNum == 2 || displayNum == 0)) { + width = Math.min(xSize * notcompleted, xSize / 2.0F); + drawTexturedRect(x + xSize / 2.0F + Math.max(xSize * (completed - 0.5F), 0.0F), y, width, 5.0F, (182.0F - xSize / 2.0F + Math.max(xSize * (completed - 0.5F), 0.0F)) / 256.0F, 0.7109375F, 0.2890625F, 0.30859375F, 9728); + } + + if (completed > 0.0F && (displayNum == 3 || displayNum == 0)) { + width = Math.min(xSize * completed, xSize / 2.0F); + drawTexturedRect(x, y, width, 5.0F, 0.0F, width / 256.0F, 0.30859375F, 0.328125F, 9728); + } + + if (completed > 0.5F && (displayNum == 4 || displayNum == 0)) { + width = Math.min(xSize * (completed - 0.5F), xSize / 2.0F); + drawTexturedRect(x + xSize / 2.0F, y, width, 5.0F, (182.0F - xSize / 2.0F) / 256.0F, (182.0F - xSize / 2.0F + width) / 256.0F, 0.30859375F, 0.328125F, 9728); + } + + } + public static void drawUnfilledBox(int left, int top, int right, int bottom, int color, boolean chroma) { if (left < right) |