diff options
Diffstat (limited to 'src/main/java')
13 files changed, 361 insertions, 132 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java index 4281f6a3..c0d8d74b 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java @@ -45,6 +45,7 @@ public class MFeature extends MPanel { } }); addons.add(mStringSelectionButton); + mStringSelectionButton.setEnabled(feature.isEnabled()); mStringSelectionButton.setSize(new Dimension(30, 15)); add(mStringSelectionButton); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java index ee31fe36..72411e62 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java @@ -11,10 +11,12 @@ import net.minecraft.client.renderer.GlStateManager; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; +import java.util.List; import java.awt.*; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Set; public class PanelDefaultParameterConfig extends MPanel { @@ -33,9 +35,13 @@ public class PanelDefaultParameterConfig extends MPanel { } private GuiConfig config; - public PanelDefaultParameterConfig(final GuiConfig config, AbstractFeature feature) { + public PanelDefaultParameterConfig(final GuiConfig config, AbstractFeature feature, List<MPanel> pre, Set<String> ignore) { this.config = config; + for (MPanel mPanel : pre) { + add(mPanel); + } for (FeatureParameter parameter: feature.getParameters()) { + if (ignore.contains(parameter.getKey())) continue; add(new MParameter(feature, parameter, config)); } setBackgroundColor(new Color(38, 38, 38, 255)); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java index 77b852b0..cb7468ee 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java @@ -71,7 +71,7 @@ public abstract class AbstractFeature { ConfigPanelCreator.map.put("base." + key , new Supplier<MPanel>() { @Override public MPanel get() { - return new PanelDefaultParameterConfig(config, AbstractFeature.this); + return new PanelDefaultParameterConfig(config, AbstractFeature.this, Collections.<MPanel>emptyList(), Collections.<String>emptySet()); } }); return "base." + key ; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonDeaths.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonDeaths.java index ecf1d6fb..64bb3744 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonDeaths.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonDeaths.java @@ -27,12 +27,11 @@ public class FeatureDungeonDeaths extends TextHUDFeature implements ChatListener public FeatureDungeonDeaths() { super("Dungeon", "Display Deaths", "Display names of player and death count in dungeon run", "dungeon.stats.deaths", false, getFontRenderer().getStringWidth("longestplayernamepos: 100"), getFontRenderer().FONT_HEIGHT * 6); this.setEnabled(false); -// parameters.put("color", new FeatureParameter<Color>("color", "Color", "Color of text", Color.orange, "color")); } SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); @Override - public boolean isEnabled() { + public boolean isHUDViewable() { if (!skyblockStatus.isOnDungeon()) return false; DungeonContext context = skyblockStatus.getContext(); if (context == null) return false; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMilestone.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMilestone.java index 6f2a6912..c04ff1c0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMilestone.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMilestone.java @@ -30,7 +30,6 @@ public class FeatureDungeonMilestone extends TextHUDFeature implements ChatListe public FeatureDungeonMilestone() { super("Dungeon", "Display Current Class Milestone", "Display current class milestone of yourself", "dungeon.stats.milestone", true, getFontRenderer().getStringWidth("Milestone: 12"), getFontRenderer().FONT_HEIGHT); this.setEnabled(false); - parameters.put("color", new FeatureParameter<Color>("color", "Color", "Color of text", Color.orange, "color")); } SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); @@ -43,7 +42,7 @@ public class FeatureDungeonMilestone extends TextHUDFeature implements ChatListe } @Override - public boolean isEnabled() { + public boolean isHUDViewable() { return skyblockStatus.isOnDungeon(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRealTime.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRealTime.java index 59b46542..45426750 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRealTime.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRealTime.java @@ -8,42 +8,68 @@ import kr.syeyoung.dungeonsguide.features.listener.ChatListener; import kr.syeyoung.dungeonsguide.features.listener.DungeonEndListener; import kr.syeyoung.dungeonsguide.features.listener.DungeonStartListener; import kr.syeyoung.dungeonsguide.features.listener.TickListener; +import kr.syeyoung.dungeonsguide.features.text.StyledText; +import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.lwjgl.opengl.GL11; +import scala.actors.threadpool.Arrays; import java.awt.*; import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; -public class FeatureDungeonRealTime extends GuiFeature implements DungeonStartListener, DungeonEndListener { +public class FeatureDungeonRealTime extends TextHUDFeature implements DungeonStartListener, DungeonEndListener { public FeatureDungeonRealTime() { super("Dungeon", "Display Real Time-Dungeon Time", "Display how much real time has passed since dungeon run started", "dungeon.stats.realtime", true, getFontRenderer().getStringWidth("Time(Real): 59m 59s"), getFontRenderer().FONT_HEIGHT); this.setEnabled(false); - parameters.put("color", new FeatureParameter<Color>("color", "Color", "Color of text", Color.orange, "color")); } private long started = -1; - @Override - public void drawHUD(float partialTicks) { - if (started == -1) return; - FontRenderer fr = getFontRenderer(); - double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; - GlStateManager.scale(scale, scale, 0); - fr.drawString("Time(Real): "+TextUtils.formatTime(getTimeElapsed()), 0,0, this.<Color>getParameter("color").getValue().getRGB()); - } public long getTimeElapsed() { return System.currentTimeMillis() - started; } + private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>(); + static { + dummyText.add(new StyledText("Time","title")); + dummyText.add(new StyledText("(Real)","discriminator")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("-42h","number")); + } + + @Override + public boolean isHUDViewable() { + return started != -1; + } + + @Override + public java.util.List<String> getUsedTextStyle() { + return Arrays.asList(new String[] { + "title", "discriminator", "separator", "number" + }); + } + + @Override + public java.util.List<StyledText> getDummyText() { + return dummyText; + } + @Override - public void drawDemo(float partialTicks) { - FontRenderer fr = getFontRenderer(); - double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; - GlStateManager.scale(scale, scale, 0); - fr.drawString("Time(Real): -42h", 0,0, this.<Color>getParameter("color").getValue().getRGB()); + public java.util.List<StyledText> getText() { + List<StyledText> actualBit = new ArrayList<StyledText>(); + actualBit.add(new StyledText("Time","title")); + actualBit.add(new StyledText("(Real)","discriminator")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(TextUtils.formatTime(getTimeElapsed()),"number")); + return actualBit; } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSBTime.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSBTime.java index df711f67..1c4aae55 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSBTime.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSBTime.java @@ -6,6 +6,8 @@ import kr.syeyoung.dungeonsguide.events.DungeonEndedEvent; import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.GuiFeature; import kr.syeyoung.dungeonsguide.features.listener.*; +import kr.syeyoung.dungeonsguide.features.text.StyledText; +import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -16,38 +18,22 @@ import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.scoreboard.Scoreboard; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.lwjgl.opengl.GL11; +import scala.actors.threadpool.Arrays; import java.awt.*; +import java.util.ArrayList; import java.util.Collection; +import java.util.List; -public class FeatureDungeonSBTime extends GuiFeature { +public class FeatureDungeonSBTime extends TextHUDFeature { private SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); public FeatureDungeonSBTime() { super("Dungeon", "Display Ingame Dungeon Time", "Display how much time skyblock thinks has passed since dungeon run started", "dungeon.stats.igtime", true, getFontRenderer().getStringWidth("Time(IG): 1h 59m 59s"), getFontRenderer().FONT_HEIGHT); this.setEnabled(false); - parameters.put("color", new FeatureParameter<Color>("color", "Color", "Color of text", Color.orange, "color")); - } - @Override - public void drawHUD(float partialTicks) { - if (!skyblockStatus.isOnDungeon()) return; - FontRenderer fr = getFontRenderer(); - double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; - GlStateManager.scale(scale, scale, 0); - Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard(); - ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); - Collection<Score> scores = scoreboard.getSortedScores(objective); - String time = "unknown"; - for (Score sc:scores) { - ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); - String strippedLine = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()))).trim(); - if (strippedLine.startsWith("Time Elapsed: ")) { - time = strippedLine.substring(14); - } - } - fr.drawString("Time(Ig): "+time, 0,0, this.<Color>getParameter("color").getValue().getRGB()); } + public int getTimeElapsed() { Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard(); ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); @@ -71,12 +57,50 @@ public class FeatureDungeonSBTime extends GuiFeature { return time2 * 1000; } + private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>(); + static { + dummyText.add(new StyledText("Time","title")); + dummyText.add(new StyledText("(Ig)","discriminator")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("-42h","number")); + } + + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon(); + } + @Override - public void drawDemo(float partialTicks) { - FontRenderer fr = getFontRenderer(); - double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; - GlStateManager.scale(scale, scale, 0); + public java.util.List<String> getUsedTextStyle() { + return Arrays.asList(new String[] { + "title", "discriminator", "separator", "number" + }); + } + + @Override + public java.util.List<StyledText> getDummyText() { + return dummyText; + } - fr.drawString("Time(Ig): -42h", 0,0, this.<Color>getParameter("color").getValue().getRGB()); + @Override + public java.util.List<StyledText> getText() { + List<StyledText> actualBit = new ArrayList<StyledText>(); + actualBit.add(new StyledText("Time","title")); + actualBit.add(new StyledText("(Ig)","discriminator")); + actualBit.add(new StyledText(": ","separator")); + Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard(); + ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); + Collection<Score> scores = scoreboard.getSortedScores(objective); + String time = "unknown"; + for (Score sc:scores) { + ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); + String strippedLine = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()))).trim(); + if (strippedLine.startsWith("Time Elapsed: ")) { + time = strippedLine.substring(14); + } + } + actualBit.add(new StyledText(time,"number")); + return actualBit; } + } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java index 6bf0b279..18f51f88 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java @@ -7,6 +7,8 @@ import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.features.GuiFeature; +import kr.syeyoung.dungeonsguide.features.text.StyledText; +import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; import kr.syeyoung.dungeonsguide.utils.TextUtils; import lombok.AllArgsConstructor; import lombok.Data; @@ -17,56 +19,127 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.util.MathHelper; import org.lwjgl.opengl.GL11; +import scala.actors.threadpool.Arrays; import java.awt.*; +import java.util.ArrayList; +import java.util.List; -public class FeatureDungeonScore extends GuiFeature { +public class FeatureDungeonScore extends TextHUDFeature { public FeatureDungeonScore() { super("Dungeon", "Display Current Score", "Calculate and Display current score\nThis data is from pure calculation and can be different from actual score.", "dungeon.stats.score", false, 200, getFontRenderer().FONT_HEIGHT * 4); this.setEnabled(false); - parameters.put("color", new FeatureParameter<Color>("color", "Color", "Color of text", Color.orange, "color")); parameters.put("verbose", new FeatureParameter<Boolean>("verbose", "Show each score instead of sum", "Skill: 100 Explore: 58 S->S+(5 tombs) instead of Score: 305", true, "boolean")); } SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); @Override - public void drawHUD(float partialTicks) { - if (!skyblockStatus.isOnDungeon()) return; - FontRenderer fr = getFontRenderer(); + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon(); + } + + private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>(); + private static final java.util.List<StyledText> dummyText2= new ArrayList<StyledText>(); + static { + dummyText.add(new StyledText("Score","scorename")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("305 ","score")); + dummyText.add(new StyledText("(","brackets")); + dummyText.add(new StyledText("S+","currentScore")); + dummyText.add(new StyledText(")","brackets")); + + + + dummyText2.add(new StyledText("Skill","scorename")); + dummyText2.add(new StyledText(": ","separator")); + dummyText2.add(new StyledText("100 ","score")); + dummyText2.add(new StyledText("(","brackets")); + dummyText2.add(new StyledText("0 Deaths","etc")); + dummyText2.add(new StyledText(")\n","brackets")); + dummyText2.add(new StyledText("Explorer","scorename")); + dummyText2.add(new StyledText(": ","separator")); + dummyText2.add(new StyledText("99 ","score")); + dummyText2.add(new StyledText("(","brackets")); + dummyText2.add(new StyledText("Rooms O Secrets 39/40","etc")); + dummyText2.add(new StyledText(")\n","brackets")); + dummyText2.add(new StyledText("Time","scorename")); + dummyText2.add(new StyledText(": ","separator")); + dummyText2.add(new StyledText("100 ","score")); + dummyText2.add(new StyledText("Bonus","scorename")); + dummyText2.add(new StyledText(": ","separator")); + dummyText2.add(new StyledText("0 ","score")); + dummyText2.add(new StyledText("Total","scorename")); + dummyText2.add(new StyledText(": ","separator")); + dummyText2.add(new StyledText("299\n","score")); + dummyText2.add(new StyledText("S","currentScore")); + dummyText2.add(new StyledText("->","arrow")); + dummyText2.add(new StyledText("S+ ","nextScore")); + dummyText2.add(new StyledText("(","brackets"));; + dummyText2.add(new StyledText("1 Required 1 crypt","required")); + dummyText2.add(new StyledText(")","brackets")); + + } + + @Override + public java.util.List<String> getUsedTextStyle() { + return Arrays.asList(new String[] { + "scorename", "separator", "score", "brackets", "etc", "currentScore", "arrow", "nextScore", "required" + }); + } + + @Override + public java.util.List<StyledText> getDummyText() { + + if (this.<Boolean>getParameter("verbose").getValue()) {return dummyText2;} else return dummyText; + } + + @Override + public java.util.List<StyledText> getText() { + List<StyledText> actualBit = new ArrayList<StyledText>(); + ScoreCalculation score = calculateScore(); - if (score == null) return; + if (score == null) return new ArrayList<StyledText>(); int sum = score.time + score.skill + score.explorer + score.bonus; if (this.<Boolean>getParameter("verbose").getValue()) { - String req = buildRequirement(score); - int rgb = this.<Color>getParameter("color").getValue().getRGB(); - fr.drawString("Skill: "+score.skill+" ("+score.deaths+" Deaths)", 0, 0, rgb); - fr.drawString("Explorer: "+score.explorer+" (Rooms "+(score.fullyCleared ? "O" : "X") + " secrets "+score.secrets+"/"+score.totalSecrets+(score.totalSecretsKnown ? "": "?")+")", 0, 8, rgb); - fr.drawString("Time: "+score.time+" Bonus: "+score.bonus+" ::: Total: "+sum, 0, 16, rgb); - fr.drawString(req, 0, 24, rgb); + actualBit.add(new StyledText("Skill","scorename")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(score.skill+" ","score")); + actualBit.add(new StyledText("(","brackets")); + actualBit.add(new StyledText(score.deaths+" Deaths","etc")); + actualBit.add(new StyledText(")\n","brackets")); + actualBit.add(new StyledText("Explorer","scorename")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(score.explorer+" ","score")); + actualBit.add(new StyledText("(","brackets")); + actualBit.add(new StyledText("Rooms "+(score.fullyCleared ? "O":"X")+ " Secrets "+score.secrets+"/"+score.totalSecrets+(score.totalSecretsKnown ? "": "?"),"etc")); + actualBit.add(new StyledText(")\n","brackets")); + actualBit.add(new StyledText("Time","scorename")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(score.time+" ","score")); + actualBit.add(new StyledText("Bonus","scorename")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(score.bonus+" ","score")); + actualBit.add(new StyledText("Total","scorename")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(sum+"\n","score")); + actualBit.addAll(buildRequirement(score)); } else { - double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; - GlStateManager.scale(scale, scale, 0); String letter = getLetter(sum); - fr.drawString("Score: "+sum + "("+letter+")", 0,0, this.<Color>getParameter("color").getValue().getRGB()); + actualBit.add(new StyledText("Score","scorename")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(sum+" ","score")); + actualBit.add(new StyledText("(","brackets")); + actualBit.add(new StyledText(letter,"currentScore")); + actualBit.add(new StyledText(")","brackets")); } - } - @Override - public void drawDemo(float partialTicks) { - FontRenderer fr = getFontRenderer(); - if (this.<Boolean>getParameter("verbose").getValue()) { - int rgb = this.<Color>getParameter("color").getValue().getRGB(); - fr.drawString("Skill: 100 (0 Deaths)", 0, 0, rgb); - fr.drawString("Explorer: 99 (Rooms O 39/40)", 0, 8, rgb); - fr.drawString("Time: 100 Bonus: 0 Total: 299", 0, 16, rgb); - fr.drawString("S->S+ (1 Required 1 tomb)", 0, 24, rgb); - } else { - double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; - GlStateManager.scale(scale, scale, 0); - fr.drawString("Score: 305 (S+)", 0,0, this.<Color>getParameter("color").getValue().getRGB()); - } + return actualBit; } + + + + @Data @AllArgsConstructor public static class ScoreCalculation { @@ -193,11 +266,15 @@ public class FeatureDungeonScore extends GuiFeature { if (letter.equals("S")) return "S+"; else return null; } - public String buildRequirement(ScoreCalculation calculation) { + public List<StyledText> buildRequirement(ScoreCalculation calculation) { + List<StyledText> actualBit = new ArrayList<StyledText>(); int current = calculation.time + calculation.bonus + calculation.explorer + calculation.skill; String currentLetter = getLetter(current); String nextLetter= getNextLetter(currentLetter); - if (nextLetter == null) return "S+ Expected"; + if (nextLetter == null) { + actualBit.add(new StyledText(nextLetter+" Expected","nextScore")); + return actualBit; + } int req = getScoreRequirement(nextLetter); int reqPT2 = req- current; int reqPT = req - current; @@ -208,6 +285,12 @@ public class FeatureDungeonScore extends GuiFeature { double secretPer = 40.0 / calculation.totalSecrets; int secrets = (int) Math.ceil(reqPT / secretPer); - return currentLetter+"->"+nextLetter+" ("+reqPT2+" Req "+tombsBreakable+" crypts "+secrets+" secrets"+(calculation.totalSecretsKnown ? "" : "?")+")"; + actualBit.add(new StyledText(currentLetter,"currentScore")); + actualBit.add(new StyledText("->","arrow")); + actualBit.add(new StyledText(nextLetter+" ","nextScore")); + actualBit.add(new StyledText("(","brackets"));; + actualBit.add(new StyledText(reqPT2+" required "+tombsBreakable+" crypt "+secrets+" secrets","required")); + actualBit.add(new StyledText(")","brackets")); + return actualBit; } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSecrets.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSecrets.java index 614d7fee..e219fe5c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSecrets.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSecrets.java @@ -9,6 +9,8 @@ import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.features.GuiFeature; import kr.syeyoung.dungeonsguide.features.listener.ChatListener; import kr.syeyoung.dungeonsguide.features.listener.TickListener; +import kr.syeyoung.dungeonsguide.features.text.StyledText; +import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -18,35 +20,20 @@ import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.util.ChatComponentText; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.lwjgl.opengl.GL11; +import scala.actors.threadpool.Arrays; import java.awt.*; +import java.util.ArrayList; +import java.util.List; import java.util.regex.Pattern; -public class FeatureDungeonSecrets extends GuiFeature { +public class FeatureDungeonSecrets extends TextHUDFeature { public FeatureDungeonSecrets() { super("Dungeon", "Display #Secrets", "Display how much total secrets have been found in a dungeon run.\n+ sign means DG does not know the correct number, but it's somewhere above that number.", "dungeon.stats.secrets", true, getFontRenderer().getStringWidth("Secrets: 999/999+"), getFontRenderer().FONT_HEIGHT); this.setEnabled(false); - parameters.put("color", new FeatureParameter<Color>("color", "Color", "Color of text", Color.orange, "color")); } SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); - @Override - public void drawHUD(float partialTicks) { - if (!skyblockStatus.isOnDungeon()) return; - FontRenderer fr = getFontRenderer(); - double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; - GlStateManager.scale(scale, scale, 0); - fr.drawString("Secrets: "+getSecretsFound() +"/"+getTotalSecrets(), 0,0, this.<Color>getParameter("color").getValue().getRGB()); - } - - @Override - public void drawDemo(float partialTicks) { - FontRenderer fr = getFontRenderer(); - double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; - GlStateManager.scale(scale, scale, 0); - fr.drawString("Secrets: 999/2+", 0,0, this.<Color>getParameter("color").getValue().getRGB()); - } - public int getSecretsFound() { for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); @@ -69,4 +56,45 @@ public class FeatureDungeonSecrets extends GuiFeature { } return totalSecrets + (allknown ? "":"+"); } + + + private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>(); + static { + dummyText.add(new StyledText("Secrets","title")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("999","currentSecrets")); + dummyText.add(new StyledText("/","separator2")); + dummyText.add(new StyledText("2","totalSecrets")); + dummyText.add(new StyledText("+","unknown")); + } + + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon(); + } + + @Override + public java.util.List<String> getUsedTextStyle() { + return Arrays.asList(new String[] { + "title", "separator", "currentSecrets", "separator2", "totalSecrets", "unknown" + }); + } + + @Override + public java.util.List<StyledText> getDummyText() { + return dummyText; + } + + @Override + public java.util.List<StyledText> getText() { + List<StyledText> actualBit = new ArrayList<StyledText>(); + actualBit.add(new StyledText("Secrets","title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(getSecretsFound() +"","currentSecrets")); + actualBit.add(new StyledText("/","separator2")); + actualBit.add(new StyledText(getTotalSecrets().replace("+", ""),"totalSecrets")); + actualBit.add(new StyledText(getTotalSecrets().contains("+") ? "+" : "","unknown")); + return actualBit; + } + } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonTombs.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonTombs.java index d8ee4503..00f73c05 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonTombs.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonTombs.java @@ -4,6 +4,8 @@ import kr.syeyoung.dungeonsguide.SkyblockStatus; import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.GuiFeature; +import kr.syeyoung.dungeonsguide.features.text.StyledText; +import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -11,33 +13,19 @@ import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.scoreboard.ScorePlayerTeam; import org.lwjgl.opengl.GL11; +import scala.actors.threadpool.Arrays; import java.awt.*; +import java.util.ArrayList; +import java.util.List; -public class FeatureDungeonTombs extends GuiFeature { +public class FeatureDungeonTombs extends TextHUDFeature { public FeatureDungeonTombs() { super("Dungeon", "Display #Crypts", "Display how much total crypts have been blown up in a dungeon run", "dungeon.stats.tombs", true, getFontRenderer().getStringWidth("Crypts: 42"), getFontRenderer().FONT_HEIGHT); this.setEnabled(false); - parameters.put("color", new FeatureParameter<Color>("color", "Color", "Color of text", Color.orange, "color")); } SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); - @Override - public void drawHUD(float partialTicks) { - if (!skyblockStatus.isOnDungeon()) return; - FontRenderer fr = getFontRenderer(); - double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; - GlStateManager.scale(scale, scale, 0); - fr.drawString("Crypts: "+getTombsFound(), 0,0, this.<Color>getParameter("color").getValue().getRGB()); - } - - @Override - public void drawDemo(float partialTicks) { - FontRenderer fr = getFontRenderer(); - double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; - GlStateManager.scale(scale, scale, 0); - fr.drawString("Crypts: 42", 0,0, this.<Color>getParameter("color").getValue().getRGB()); - } public int getTombsFound() { for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { @@ -48,4 +36,38 @@ public class FeatureDungeonTombs extends GuiFeature { } return 0; } + + private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>(); + static { + dummyText.add(new StyledText("Crypts","title")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("42","number")); + } + + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon(); + } + + @Override + public java.util.List<String> getUsedTextStyle() { + return Arrays.asList(new String[] { + "title", "separator", "number" + }); + } + + @Override + public java.util.List<StyledText> getDummyText() { + return dummyText; + } + + @Override + public java.util.List<StyledText> getText() { + List<StyledText> actualBit = new ArrayList<StyledText>(); + actualBit.add(new StyledText("Crypts","title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(getTombsFound()+"","number")); + return actualBit; + } + } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWarnLowHealth.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWarnLowHealth.java index 09870ba3..ffcfbfa8 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWarnLowHealth.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWarnLowHealth.java @@ -7,6 +7,8 @@ import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.GuiFeature; import kr.syeyoung.dungeonsguide.features.SimpleFeature; import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener; +import kr.syeyoung.dungeonsguide.features.text.StyledText; +import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.client.Minecraft; @@ -20,29 +22,41 @@ import net.minecraft.scoreboard.Scoreboard; import net.minecraft.util.BlockPos; import org.jetbrains.annotations.Nullable; import org.lwjgl.opengl.GL11; +import scala.actors.threadpool.Arrays; import java.awt.*; +import java.util.ArrayList; import java.util.List; -public class FeatureWarnLowHealth extends GuiFeature { +public class FeatureWarnLowHealth extends TextHUDFeature { public FeatureWarnLowHealth() { super("Dungeon", "Low Health Warning", "Warn if someone is on low health", "dungeon.lowhealthwarn", false, 200, 50); - parameters.put("color", new FeatureParameter<Color>("color", "Color", "Color of playername", Color.yellow, "color")); parameters.put("threshold", new FeatureParameter<Integer>("threshold", "Health Threshold", "Health Threshold for this feature to be toggled. default to 500", 500, "integer")); - } private SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); + + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon(); + } + + @Override + public List<String> getUsedTextStyle() { + return Arrays.asList(new String[] { + "title", "separator", "number", "unit" + }); + } + @Override public void drawDemo(float partialTicks) { FontRenderer fr = getFontRenderer(); double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; GlStateManager.scale(scale, scale, 0); - fr.drawString("DungeonsGuide: ", 0,0,this.<Color>getParameter("color").getValue().getRGB()); - fr.drawString("500hp", fr.getStringWidth("DungeonsGuide: "), 0, Color.red.getRGB()); + super.drawDemo(partialTicks); } @Override @@ -50,6 +64,24 @@ public class FeatureWarnLowHealth extends GuiFeature { FontRenderer fr = getFontRenderer(); double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; GlStateManager.scale(scale, scale, 0); + super.drawHUD(partialTicks); + } + + private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>(); + static { + dummyText.add(new StyledText("DungeonsGuide","title")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("500","number")); + dummyText.add(new StyledText("hp","unit")); + } + + @Override + public List<StyledText> getDummyText() { + return dummyText; + } + + @Override + public List<StyledText> getText() { String lowestHealthName = ""; int lowestHealth = 999999999; Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard(); @@ -67,8 +99,13 @@ public class FeatureWarnLowHealth extends GuiFeature { } } } - if (lowestHealth > this.<Integer>getParameter("threshold").getValue()) return; - fr.drawString(lowestHealthName+": ", 0,0,this.<Color>getParameter("color").getValue().getRGB()); - fr.drawString(lowestHealth+"hp", fr.getStringWidth(lowestHealthName+"DungeonsGuide: "), 0, Color.red.getRGB()); + if (lowestHealth > this.<Integer>getParameter("threshold").getValue()) return new ArrayList<StyledText>(); + + List<StyledText> actualBit = new ArrayList<StyledText>(); + actualBit.add(new StyledText(lowestHealthName,"title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(lowestHealth+"","number")); + actualBit.add(new StyledText("hp","unit")); + return actualBit; } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java index 4be95491..6595aee4 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java @@ -41,7 +41,7 @@ public class PanelTextParameterConfig extends MPanel { @Override public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(5,5,parentWidth-10, parentHeight-10)); + this.setBounds(new Rectangle(5,5,parentWidth-10, 120)); } private GuiConfig config; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java index d019f6bd..a7502a7f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java @@ -14,12 +14,11 @@ import lombok.AllArgsConstructor; import lombok.Data; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; +import scala.actors.threadpool.Arrays; import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.*; import java.util.List; -import java.util.Map; public abstract class TextHUDFeature extends GuiFeature { protected TextHUDFeature(String category, String name, String description, String key, boolean keepRatio, int width, int height) { @@ -29,7 +28,9 @@ public abstract class TextHUDFeature extends GuiFeature { @Override public void drawHUD(float partialTicks) { - drawTextWithStylesAssociated(getText(), 0, 0, getStylesMap()); + + if (isHUDViewable()) + drawTextWithStylesAssociated(getText(), 0, 0, getStylesMap()); } @Override @@ -37,7 +38,7 @@ public abstract class TextHUDFeature extends GuiFeature { drawTextWithStylesAssociated(getDummyText(), 0, 0, getStylesMap()); } - public abstract boolean isEnabled(); + public abstract boolean isHUDViewable(); public abstract List<String> getUsedTextStyle(); public List<StyledText> getDummyText() { @@ -159,7 +160,10 @@ public abstract class TextHUDFeature extends GuiFeature { ConfigPanelCreator.map.put("base." + getKey() , new Supplier<MPanel>() { @Override public MPanel get() { - return new PanelTextParameterConfig(config, TextHUDFeature.this); + return new PanelDefaultParameterConfig(config, TextHUDFeature.this, + Arrays.asList(new MPanel[] { + new PanelTextParameterConfig(config, TextHUDFeature.this) + }), Collections.singleton("textStyles")); } }); return "base." + getKey() ; |