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 | |
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')
11 files changed, 220 insertions, 74 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; + } + } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxSkelemaster.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxSkelemaster.java index a4a144e5..1786e7cf 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxSkelemaster.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxSkelemaster.java @@ -43,7 +43,7 @@ public class FeatureBoxSkelemaster extends SimpleFeature implements WorldRenderL return input.getName().contains("Skeleton Master"); } }); - Color c = this.<Color>getParameter("color").getValue(); + AColor c = this.<AColor>getParameter("color").getValue(); for (EntityArmorStand entitySkeleton : skeletonList) { RenderUtils.highlightBox(entitySkeleton, c, partialTicks, true); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxStarMobs.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxStarMobs.java index 64176d71..670ad077 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxStarMobs.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxStarMobs.java @@ -42,7 +42,7 @@ public class FeatureBoxStarMobs extends SimpleFeature implements WorldRenderList return input.getName().contains("✯"); } }); - Color c = this.<Color>getParameter("color").getValue(); + AColor c = this.<AColor>getParameter("color").getValue(); for (EntityArmorStand entitySkeleton : skeletonList) { RenderUtils.highlightBox(entitySkeleton, c, partialTicks, true); } 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 64bb3744..6f824724 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 @@ -39,6 +39,11 @@ public class FeatureDungeonDeaths extends TextHUDFeature implements ChatListener } @Override + public boolean doesScaleWithHeight() { + return false; + } + + @Override public List<String> getUsedTextStyle() { return Arrays.asList(new String[] { "username", "separator", "deaths", "total", "totalDeaths" diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java index 15f0baaf..4b8cae3b 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java @@ -63,11 +63,10 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, parameters.put("showtotalsecrets", new FeatureParameter<Boolean>("showtotalsecrets", "Show Total secrets in the room", "Option to overlay total secrets in the specific room", true, "boolean")); parameters.put("playerheadscale", new FeatureParameter<Float>("playerheadscale", "Player head scale", "Scale factor of player heads, defaults to 1", 1.0f, "float")); parameters.put("textScale", new FeatureParameter<Float>("textScale", "Text scale", "Scale factor of texts on map, defaults to 1", 1.0f, "float")); + parameters.put("border_color", new FeatureParameter<AColor>("border_color", "Color of the border", "Same as name", new AColor(255,255,255,255), "acolor")); parameters.put("background_color", new FeatureParameter<AColor>("background_color", "Color of the background", "Same as name", new AColor(0x22000000, true), "acolor")); - parameters.put("chromaborder", new FeatureParameter<Boolean>("chromaborder", "Chroma border", "Rainbow!!! (Overrides border color option)", false, "boolean")); parameters.put("player_color", new FeatureParameter<AColor>("player_color", "Color of the player border", "Same as name", new AColor(255,255,255,0), "acolor")); - parameters.put("player_chroma", new FeatureParameter<Boolean>("player_chroma", "Chroma border for player", "Rainbow!!! (Overrides border color option)", false, "boolean")); } SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); @@ -113,7 +112,7 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, DungeonContext context = skyblockStatus.getContext(); MapProcessor mapProcessor = context.getMapProcessor(); MapData mapData = mapProcessor.getLastMapData2(); - Gui.drawRect(0,0,getFeatureRect().width, getFeatureRect().height, this.<AColor>getParameter("background_color").getValue().getRGB()); + Gui.drawRect(0,0,getFeatureRect().width, getFeatureRect().height, RenderUtils.getColorAt(getFeatureRect().x, getFeatureRect().y, this.<AColor>getParameter("background_color").getValue())); GlStateManager.color(1,1,1,1); GlStateManager.pushMatrix();; if (mapData == null) { @@ -123,7 +122,7 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, } GlStateManager.popMatrix(); GL11.glLineWidth(2); - RenderUtils.drawUnfilledBox(0,0,getFeatureRect().width, getFeatureRect().height, this.<AColor>getParameter("border_color").getValue().getRGB(), this.<Boolean>getParameter("chromaborder").getValue()); + RenderUtils.drawUnfilledBox(0,0,getFeatureRect().width, getFeatureRect().height, this.<AColor>getParameter("border_color").getValue()); } @Override @@ -132,11 +131,11 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, drawHUD(partialTicks); return; } - Gui.drawRect(0,0,getFeatureRect().width, getFeatureRect().height, this.<AColor>getParameter("background_color").getValue().getRGB()); + Gui.drawRect(0,0,getFeatureRect().width, getFeatureRect().height, RenderUtils.getColorAt(getFeatureRect().x, getFeatureRect().y, this.<AColor>getParameter("background_color").getValue())); FontRenderer fr = getFontRenderer(); fr.drawString("Please join a dungeon to see preview", getFeatureRect().width / 2 - fr.getStringWidth("Please join a dungeon to see preview") / 2, getFeatureRect().height / 2 - fr.FONT_HEIGHT / 2, 0xFFFFFFFF); GL11.glLineWidth(2); - RenderUtils.drawUnfilledBox(0,0,getFeatureRect().width, getFeatureRect().height, this.<AColor>getParameter("border_color").getValue().getRGB(), this.<Boolean>getParameter("chromaborder").getValue()); + RenderUtils.drawUnfilledBox(0,0,getFeatureRect().width, getFeatureRect().height, this.<AColor>getParameter("border_color").getValue()); } public void renderMap(float partialTicks, MapProcessor mapProcessor, MapData mapData, DungeonContext context){ @@ -212,7 +211,7 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, GlStateManager.scale(s,s,0); Gui.drawScaledCustomSizeModalRect(-4, -4, 8.0F, (float) l2, 8, i3, 8, 8, 64.0F, 64.0F); GL11.glLineWidth(1); - RenderUtils.drawUnfilledBox(-4,-4,4, 4, this.<AColor>getParameter("player_color").getValue().getRGB(), this.<Boolean>getParameter("player_chroma").getValue()); + RenderUtils.drawUnfilledBox(-4,-4,4, 4, this.<AColor>getParameter("player_color").getValue()); } GlStateManager.popMatrix(); } 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 ffcfbfa8..17a41e5b 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 @@ -51,22 +51,6 @@ public class FeatureWarnLowHealth extends TextHUDFeature { }); } - @Override - public void drawDemo(float partialTicks) { - FontRenderer fr = getFontRenderer(); - double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; - GlStateManager.scale(scale, scale, 0); - super.drawDemo(partialTicks); - } - - @Override - public void drawHUD(float partialTicks) { - 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")); 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 6595aee4..06ac0fca 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java @@ -34,6 +34,7 @@ public class PanelTextParameterConfig extends MPanel { private TextHUDFeature feature; private MEditableAColor currentColor; + private MEditableAColor backgroundColor; @Override public void onBoundsUpdate() { @@ -63,12 +64,28 @@ public class PanelTextParameterConfig extends MPanel { } }); add(currentColor); + backgroundColor = new MEditableAColor(); + backgroundColor.setColor(new AColor(0xff555555, true)); + backgroundColor.setEnableEdit(false); + backgroundColor.setSize(new Dimension(15, 10)); + backgroundColor.setBounds(new Rectangle(415 , 14, 15, 10)); + backgroundColor.setOnUpdate(new Runnable() { + @Override + public void run() { + for (String se:selected) + feature.getStylesMap().get(se).setBackground(backgroundColor.getColor()); + } + }); + add(backgroundColor); + + } private Set<String> selected = new HashSet<String>(); @Override public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + GlStateManager.pushMatrix(); int width = 200, height = 100; @@ -78,23 +95,28 @@ public class PanelTextParameterConfig extends MPanel { Rectangle clip = new Rectangle(scissor.x + 5, scissor.y + 5, width, height); clip(new ScaledResolution(Minecraft.getMinecraft()), clip.x, clip.y, clip.width, clip.height); + GlStateManager.pushMatrix(); + GlStateManager.translate(offsetX + 5, offsetY + 5, 0); + GlStateManager.scale(scale, scale, 0); + + List<StyledText> texts = feature.getDummyText(); Map<String, TextStyle> styles = feature.getStylesMap(); - List<TextHUDFeature.StyleTextAssociated> calc = feature.calculate(texts, 5,5, styles); + List<TextHUDFeature.StyleTextAssociated> calc = feature.drawTextWithStylesAssociated(texts, 0,0, styles); boolean bool =clip.contains(absMousex, absMousey); for (TextHUDFeature.StyleTextAssociated calc3: calc) { if (selected.contains(calc3.getStyledText().getGroup())) { - Gui.drawRect(calc3.getRectangle().x, calc3.getRectangle().y, calc3.getRectangle().x + calc3.getRectangle().width, calc3.getRectangle().y + calc3.getRectangle().height, 0xFF44A800); - } else if (bool && calc3.getRectangle().contains(relMousex0, relMousey0)) { + Gui.drawRect(calc3.getRectangle().x, calc3.getRectangle().y, calc3.getRectangle().x + calc3.getRectangle().width, calc3.getRectangle().y + calc3.getRectangle().height, 0x4244A800); + } else if (bool && calc3.getRectangle().contains((relMousex0-5 -offsetX) * scale , (relMousey0 - 5 - offsetY) * scale)) { for (TextHUDFeature.StyleTextAssociated calc2 : calc) { if (calc2.getStyledText().getGroup().equals(calc3.getStyledText().getGroup())) - Gui.drawRect(calc2.getRectangle().x, calc2.getRectangle().y, calc2.getRectangle().x + calc2.getRectangle().width, calc2.getRectangle().y + calc2.getRectangle().height, 0xFF777777); + Gui.drawRect(calc2.getRectangle().x, calc2.getRectangle().y, calc2.getRectangle().x + calc2.getRectangle().width, calc2.getRectangle().y + calc2.getRectangle().height, 0x55777777); } } } - feature.drawTextWithStylesAssociated(texts, 5,5, styles); clip(new ScaledResolution(Minecraft.getMinecraft()), scissor.x, scissor.y, scissor.width, scissor.height); + GlStateManager.popMatrix(); GlStateManager.translate(5, height + 7, 0); GlStateManager.scale(0.5,0.5,0); @@ -109,19 +131,27 @@ public class PanelTextParameterConfig extends MPanel { fr.drawString("Selected Groups: "+selected, 0, 0, 0xFFBFBFBF); GlStateManager.popMatrix(); fr.drawString("Text Color: ", 0, 10, 0xFFFFFFFF); + fr.drawString("Background Color: ", 100, 10, 0xFFFFFFFF); GlStateManager.popMatrix(); } + private int offsetX = 0; + private int offsetY = 0; + private float scale = 1; + + private int lastX; + private int lastY; + private boolean dragStart = false; @Override public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { List<StyledText> texts = feature.getDummyText(); Map<String, TextStyle> styles = feature.getStylesMap(); boolean existed = selected.isEmpty(); boolean found = false; - List<TextHUDFeature.StyleTextAssociated> calc = feature.calculate(texts, 5,5, styles); + List<TextHUDFeature.StyleTextAssociated> calc = feature.calculate(texts, 0,0, styles); for (TextHUDFeature.StyleTextAssociated calc3: calc) { - if (calc3.getRectangle().contains(relMouseX, relMouseY)) { + if (calc3.getRectangle().contains((relMouseX-5 -offsetX) * scale , (relMouseY - 5 - offsetY) * scale)) { if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { if (!selected.contains(calc3.getStyledText().getGroup())) selected.add(calc3.getStyledText().getGroup()); @@ -137,16 +167,56 @@ public class PanelTextParameterConfig extends MPanel { if (!found && !(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) && relMouseX >= 5 && relMouseX <= 205 && relMouseY >= 5 && relMouseY <= 105) { selected.clear(); + dragStart = true; + lastX = absMouseX; + lastY = absMouseY; } currentColor.setEnableEdit(selected.size() != 0); + backgroundColor.setEnableEdit(selected.size() != 0); if (existed != selected.isEmpty()) { - if (selected.size() != 0) + if (selected.size() != 0) { currentColor.setColor(styles.get(selected.iterator().next()).getColor()); - else + backgroundColor.setColor(styles.get(selected.iterator().next()).getBackground()); + } else { currentColor.setColor(new AColor(0xff555555, true)); + backgroundColor.setColor(new AColor(0xff555555, true)); + } } - if (selected.size() == 1) + if (selected.size() == 1) { currentColor.setColor(styles.get(selected.iterator().next()).getColor()); + backgroundColor.setColor(styles.get(selected.iterator().next()).getBackground()); + } + } + + @Override + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { + dragStart = false; + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + if (dragStart) { + offsetX += absMouseX - lastX; + offsetY += absMouseY - lastY; + lastX = absMouseX; + lastY = absMouseY; + + if (offsetX < 0) offsetX = 0; + if (offsetY < 0) offsetY =0; + } + } + + @Override + public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + if ( relMouseX0 >= 5 && relMouseX0 <= 205 && relMouseY0 >= 5 && relMouseY0 <= 105) { + if (scrollAmount > 0) { + scale += 0.1; + } else if (scrollAmount < 0) { + scale -= 0.1; + } + if (scale < 0.1) scale = 0.1f; + if (scale > 5) scale = 5.0f; + } } } 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 a7502a7f..4bfb9041 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java @@ -14,6 +14,8 @@ import lombok.AllArgsConstructor; import lombok.Data; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; import scala.actors.threadpool.Arrays; import java.awt.*; @@ -28,16 +30,46 @@ public abstract class TextHUDFeature extends GuiFeature { @Override public void drawHUD(float partialTicks) { + if (isHUDViewable()) { + List<StyledText> asd = getText(); - if (isHUDViewable()) + if (doesScaleWithHeight()) { + FontRenderer fr = getFontRenderer(); + double scale = getFeatureRect().getHeight() / (fr.FONT_HEIGHT* countLines(asd)); + GlStateManager.scale(scale, scale, 0); + } drawTextWithStylesAssociated(getText(), 0, 0, getStylesMap()); + } + } + + public boolean doesScaleWithHeight() { + return true; } @Override public void drawDemo(float partialTicks) { + List<StyledText> asd = getDummyText(); + if (doesScaleWithHeight()) { + FontRenderer fr = getFontRenderer(); + double scale = getFeatureRect().getHeight() / (fr.FONT_HEIGHT * countLines(asd)); + GlStateManager.scale(scale, scale, 0); + } drawTextWithStylesAssociated(getDummyText(), 0, 0, getStylesMap()); } + public int countLines(List<StyledText> texts) { + StringBuilder things = new StringBuilder(); + for (StyledText text : texts) { + things.append(text.getText()); + } + String things2 = things.toString().trim(); + int lines = 1; + for (char c : things2.toString().toCharArray()) { + if (c == '\n') lines++; + } + return lines; + } + public abstract boolean isHUDViewable(); public abstract List<String> getUsedTextStyle(); @@ -59,7 +91,7 @@ public abstract class TextHUDFeature extends GuiFeature { } for (String str : getUsedTextStyle()) { if (!res.containsKey(str)) - res.put(str, new TextStyle(str, new AColor(0xffffffff, true))); + res.put(str, new TextStyle(str, new AColor(0xffffffff, true), new AColor(0x00777777, true))); } stylesMap = res; } @@ -141,6 +173,8 @@ public abstract class TextHUDFeature extends GuiFeature { if (stopDraw) return new Dimension(fr.getStringWidth(content), fr.FONT_HEIGHT); + Gui.drawRect(x,y, x+fr.getStringWidth(content), y + fr.FONT_HEIGHT, RenderUtils.getColorAt(x,y, style.getBackground())); + if (!style.getColor().isChroma()) { fr.drawString(content, x, y, style.getColor().getRGB()); return new Dimension(fr.getStringWidth(content), fr.FONT_HEIGHT); @@ -148,7 +182,7 @@ public abstract class TextHUDFeature extends GuiFeature { char[] charArr = content.toCharArray(); int width = 0; for (int i = 0; i < charArr.length; i++) { - fr.drawString(String.valueOf(charArr[i]), x + width, y, RenderUtils.getChromaColorAt(x + width, y, style.getColor().getChromaSpeed())); + fr.drawString(String.valueOf(charArr[i]), x + width, y, RenderUtils.getColorAt(x + width, y, style.getColor())); width += fr.getCharWidth(charArr[i]); } return new Dimension(width, fr.FONT_HEIGHT); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java index 2353cd11..0df4c9a5 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java @@ -13,4 +13,5 @@ import java.awt.*; public class TextStyle { private String groupName; private AColor color; + private AColor background; } |