diff options
author | syeyoung <cyong06@naver.com> | 2021-02-06 14:43:37 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-02-06 14:43:37 +0900 |
commit | e7d6517b2e1fb4aa7a5993e53739006a3fca39c8 (patch) | |
tree | ab097980bcd8809c2bcfa55b832367fd44f38036 /src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss | |
parent | 5f51b33a4f19454072c92638e040647d4a3f6f38 (diff) | |
download | Skyblock-Dungeons-Guide-e7d6517b2e1fb4aa7a5993e53739006a3fca39c8.tar.gz Skyblock-Dungeons-Guide-e7d6517b2e1fb4aa7a5993e53739006a3fca39c8.tar.bz2 Skyblock-Dungeons-Guide-e7d6517b2e1fb4aa7a5993e53739006a3fca39c8.zip |
THE period to gui overhaul
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss')
3 files changed, 89 insertions, 36 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBossHealth.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBossHealth.java index 229c4251..a2ab97d3 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBossHealth.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBossHealth.java @@ -6,56 +6,86 @@ import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.GuiFeature; import kr.syeyoung.dungeonsguide.features.listener.ChatListener; +import kr.syeyoung.dungeonsguide.features.text.StyledText; +import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessorThorn; import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.HealthData; import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.client.gui.FontRenderer; import net.minecraft.util.ChatComponentText; import net.minecraftforge.client.event.ClientChatReceivedEvent; +import scala.actors.threadpool.Arrays; import java.awt.*; import java.awt.font.TextHitInfo; +import java.util.ArrayList; import java.util.Map; import java.util.regex.Matcher; import java.util.List; import java.util.regex.Pattern; -public class FeatureBossHealth extends GuiFeature { +public class FeatureBossHealth extends TextHUDFeature { public FeatureBossHealth() { super("Bossfight", "Display Boss Health(s)", "Show the health of boss and minibosses in bossfight (Guardians, Priests..)", "bossfight.health", false, getFontRenderer().getStringWidth("The Professor: 4242m"), getFontRenderer().FONT_HEIGHT * 5); this.setEnabled(true); - parameters.put("color", new FeatureParameter<Color>("color", "Color", "Color of text", Color.orange, "color")); parameters.put("totalHealth", new FeatureParameter<Boolean>("totalHealth", "show total health", "Show total health along with current health", false, "boolean")); parameters.put("formatHealth", new FeatureParameter<Boolean>("formatHealth", "format health", "1234568 -> 1m", true, "boolean")); parameters.put("ignoreInattackable", new FeatureParameter<Boolean>("ignoreInattackable", "Don't show health of in-attackable enemy", "For example, do not show guardians health when they're not attackable", false, "boolean")); } SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); + + + @Override + public boolean doesScaleWithHeight() { + return false; + } + @Override - public void drawHUD(float partialTicks) { - if (!skyblockStatus.isOnDungeon()) return; - DungeonContext context = skyblockStatus.getContext(); - if (context == null) return; - if (context.getBossfightProcessor() == null) return; - List<HealthData> healths = context.getBossfightProcessor().getHealths(); - int i = 0; - FontRenderer fr = getFontRenderer(); + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon() && skyblockStatus.getContext() != null && skyblockStatus.getContext().getBossfightProcessor() != null; + } + + @Override + public java.util.List<String> getUsedTextStyle() { + return Arrays.asList(new String[] { + "title", "separator", "health", "separator2", "maxHealth" + }); + } + + @Override + public java.util.List<StyledText> getDummyText() { + List<StyledText> actualBit = new ArrayList<StyledText>(); + addLine(new HealthData("The Professor", 3300000, 5000000, false), actualBit); + addLine(new HealthData("Chaos Guardian", 500000, 2000000, true), actualBit); + addLine(new HealthData("Healing Guardian", 1000000, 3000000, true), actualBit); + addLine(new HealthData("Laser Guardian", 5000000, 5000000, true), actualBit); + addLine(new HealthData("Giant", 10000000, 20000000, false), actualBit); + return actualBit; + } + + public void addLine(HealthData data, List<StyledText> actualBit) { boolean format = this.<Boolean>getParameter("formatHealth").getValue(); boolean total = this.<Boolean>getParameter("totalHealth").getValue(); boolean ignore = this.<Boolean>getParameter("ignoreInattackable").getValue(); - for (HealthData heal : healths) { - if (ignore && !heal.isAttackable()) continue; - fr.drawString(heal.getName() + ": " + (format ? TextUtils.format(heal.getHealth()) : heal.getHealth()) + (total ? "/"+(format ? TextUtils.format(heal.getMaxHealth()) : heal.getMaxHealth()) : ""), 0, i, this.<Color>getParameter("color").getValue().getRGB()); - i += 8; + if (ignore && !data.isAttackable()) return; + + actualBit.add(new StyledText(data.getName(),"title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText( (format ? TextUtils.format(data.getHealth()) : data.getHealth()) + (total ? "" : "\n"),"health")); + if (total) { + actualBit.add(new StyledText("/", "separator2")); + actualBit.add(new StyledText( (format ? TextUtils.format(data.getMaxHealth()) : data.getMaxHealth()) +"\n","maxHealth")); } } @Override - public void drawDemo(float partialTicks) { - FontRenderer fr = getFontRenderer(); - fr.drawString("The Professor: 3.3m", 0,0, this.<Color>getParameter("color").getValue().getRGB()); - fr.drawString("Chaos Guardian: 500k", 0,8, this.<Color>getParameter("color").getValue().getRGB()); - fr.drawString("Healing Guardian: 1m", 0,16, this.<Color>getParameter("color").getValue().getRGB()); - fr.drawString("Laser Guardian: 5m", 0,24, this.<Color>getParameter("color").getValue().getRGB()); - fr.drawString("Giant: 10m", 0,32, this.<Color>getParameter("color").getValue().getRGB()); + public java.util.List<StyledText> getText() { + List<StyledText> actualBit = new ArrayList<StyledText>(); + List<HealthData> healths = skyblockStatus.getContext().getBossfightProcessor().getHealths(); + for (HealthData heal : healths) { + addLine(heal, actualBit); } + return actualBit; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBoxRealLivid.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBoxRealLivid.java index 88d6998d..8a1a1dcc 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBoxRealLivid.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBoxRealLivid.java @@ -36,7 +36,7 @@ public class FeatureBoxRealLivid extends SimpleFeature implements WorldRenderLis if (!(skyblockStatus.getContext().getBossfightProcessor() instanceof BossfightProcessorLivid)) return; EntityOtherPlayerMP playerMP = ((BossfightProcessorLivid) skyblockStatus.getContext().getBossfightProcessor()).getRealLivid(); - Color c = this.<Color>getParameter("color").getValue(); + AColor c = this.<AColor>getParameter("color").getValue(); RenderUtils.highlightBox(playerMP, AxisAlignedBB.fromBounds(-0.4,-1.5,-0.4,0.4,0,0.4), c, partialTicks, true); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureThornBearPercentage.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureThornBearPercentage.java index c62ce149..30be7430 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureThornBearPercentage.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureThornBearPercentage.java @@ -5,36 +5,59 @@ import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; 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.roomprocessor.bossfight.BossfightProcessorThorn; import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.HealthData; import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.client.gui.FontRenderer; +import scala.actors.threadpool.Arrays; import java.awt.*; +import java.util.ArrayList; import java.util.List; -public class FeatureThornBearPercentage extends GuiFeature { +public class FeatureThornBearPercentage extends TextHUDFeature { public FeatureThornBearPercentage() { super("Bossfight", "Display Spirit Bear Summon Percentage", "Displays spirit bear summon percentage in hud", "bossfight.spiritbear", true, getFontRenderer().getStringWidth("Spirit Bear: 100%"), getFontRenderer().FONT_HEIGHT); this.setEnabled(true); - parameters.put("color", new FeatureParameter<Color>("color", "Color", "Color of text", Color.orange, "color")); - } + } SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); + + private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>(); + static { + dummyText.add(new StyledText("Spirit Bear","title")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("50","number")); + dummyText.add(new StyledText("%","unit")); + } + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon() && skyblockStatus.getContext() != null && skyblockStatus.getContext().getBossfightProcessor() instanceof BossfightProcessorThorn; + } + @Override - public void drawHUD(float partialTicks) { - if (!skyblockStatus.isOnDungeon()) return; - DungeonContext context = skyblockStatus.getContext(); - if (context == null) return; - if (!(context.getBossfightProcessor() instanceof BossfightProcessorThorn)) return; - int percentage = (int) (((BossfightProcessorThorn) context.getBossfightProcessor()).calculatePercentage() * 100); - FontRenderer fr = getFontRenderer(); - fr.drawString("Spirit Bear: "+percentage+"%", 0,0, this.<Color>getParameter("color").getValue().getRGB()); + public java.util.List<String> getUsedTextStyle() { + return Arrays.asList(new String[] { + "title", "separator", "number", "unit" + }); } @Override - public void drawDemo(float partialTicks) { - FontRenderer fr = getFontRenderer(); - fr.drawString("Spirit Bear: 50%", 0,0, this.<Color>getParameter("color").getValue().getRGB()); + public java.util.List<StyledText> getDummyText() { + return dummyText; } + + @Override + public java.util.List<StyledText> getText() { + int percentage = (int) (((BossfightProcessorThorn) skyblockStatus.getContext().getBossfightProcessor()).calculatePercentage() * 100); + List<StyledText> actualBit = new ArrayList<StyledText>(); + actualBit.add(new StyledText("Spirit Bear","title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(percentage+"","number")); + actualBit.add(new StyledText("%","unit")); + return actualBit; + } + } |