aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/features
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-02-06 02:43:13 +0900
committersyeyoung <cyong06@naver.com>2021-02-06 02:43:13 +0900
commit90fb4c2cdcd813d085e4c72d161b0efe06bcd164 (patch)
tree251092ba20e5fc9b0f89d87fc405eaecef3ac948 /src/main/java/kr/syeyoung/dungeonsguide/features
parentfe4dfe76628650cdd186726f7e419e8a2c4a624e (diff)
downloadSkyblock-Dungeons-Guide-90fb4c2cdcd813d085e4c72d161b0efe06bcd164.tar.gz
Skyblock-Dungeons-Guide-90fb4c2cdcd813d085e4c72d161b0efe06bcd164.tar.bz2
Skyblock-Dungeons-Guide-90fb4c2cdcd813d085e4c72d161b0efe06bcd164.zip
text hud go brrr
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonDeaths.java82
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMilestone.java54
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java129
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledText.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java45
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java4
6 files changed, 229 insertions, 87 deletions
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 89fcc47c..ecf1d6fb 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
@@ -7,40 +7,91 @@ import kr.syeyoung.dungeonsguide.features.FeatureParameter;
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.gui.FontRenderer;
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.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-public class FeatureDungeonDeaths extends GuiFeature implements ChatListener {
+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"));
+// 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;
+ public boolean isEnabled() {
+ if (!skyblockStatus.isOnDungeon()) return false;
+ DungeonContext context = skyblockStatus.getContext();
+ if (context == null) return false;
+ return true;
+ }
+
+ @Override
+ public List<String> getUsedTextStyle() {
+ return Arrays.asList(new String[] {
+ "username", "separator", "deaths", "total", "totalDeaths"
+ });
+ }
+
+ @Override
+ public List<StyledText> getText() {
+
+ List<StyledText> text= new ArrayList<StyledText>();
+
DungeonContext context = skyblockStatus.getContext();
- if (context == null) return;
Map<String, Integer> deaths = context.getDeaths();
int i = 0;
int deathsCnt = 0;
- FontRenderer fr = getFontRenderer();
for (Map.Entry<String, Integer> death:deaths.entrySet()) {
- fr.drawString(death.getKey()+": "+death.getValue(), 0,i, this.<Color>getParameter("color").getValue().getRGB());
- i += 8;
- deathsCnt += death.getValue();
+ text.add(new StyledText(death.getKey(),"username"));
+ text.add(new StyledText(": ","separator"));
+ text.add(new StyledText(death.getValue()+"\n","deaths"));
}
- fr.drawString("Total Deaths: "+deathsCnt, 0,i, this.<Color>getParameter("color").getValue().getRGB());
+ text.add(new StyledText("Total Deaths","total"));
+ text.add(new StyledText(": ","separator"));
+ text.add(new StyledText(deathsCnt+"","totalDeaths"));
+
+ return text;
+ }
+
+ private static final List<StyledText> dummyText= new ArrayList<StyledText>();
+ static {
+ dummyText.add(new StyledText("syeyoung","username"));
+ dummyText.add(new StyledText(": ","separator"));
+ dummyText.add(new StyledText("-130\n","deaths"));
+ dummyText.add(new StyledText("notsyeyoung","username"));
+ dummyText.add(new StyledText(": ","separator"));
+ dummyText.add(new StyledText("-13\n","deaths"));
+ dummyText.add(new StyledText("dungeonsguide","username"));
+ dummyText.add(new StyledText(": ","separator"));
+ dummyText.add(new StyledText("-42\n","deaths"));
+ dummyText.add(new StyledText("penguinman","username"));
+ dummyText.add(new StyledText(": ","separator"));
+ dummyText.add(new StyledText("0\n","deaths"));
+ dummyText.add(new StyledText("probablysalt","username"));
+ dummyText.add(new StyledText(": ","separator"));
+ dummyText.add(new StyledText("0\n","deaths"));
+ dummyText.add(new StyledText("Total Deaths","total"));
+ dummyText.add(new StyledText(": ","separator"));
+ dummyText.add(new StyledText("0","totalDeaths"));
+ }
+
+ @Override
+ public List<StyledText> getDummyText() {
+ return dummyText;
}
public int getTotalDeaths() {
@@ -54,17 +105,6 @@ public class FeatureDungeonDeaths extends GuiFeature implements ChatListener {
return d;
}
- @Override
- public void drawDemo(float partialTicks) {
- FontRenderer fr = getFontRenderer();
- fr.drawString("syeyoung: -130", 0,0, this.<Color>getParameter("color").getValue().getRGB());
- fr.drawString("notsyeyoung: -13", 0,8, this.<Color>getParameter("color").getValue().getRGB());
- fr.drawString("dungeonsguide: -42", 0,16, this.<Color>getParameter("color").getValue().getRGB());
- fr.drawString("--not more--", 0,24, this.<Color>getParameter("color").getValue().getRGB());
- fr.drawString("--maybe more--", 0,32, this.<Color>getParameter("color").getValue().getRGB());
- fr.drawString("Total Deaths: 0", 0,40, this.<Color>getParameter("color").getValue().getRGB());
- }
-
Pattern deathPattern = Pattern.compile("§r§c ☠ (.+?)§r§7 .+and became a ghost.+");
Pattern meDeathPattern = Pattern.compile("§r§c ☠ §r§7You .+and became a ghost.+");
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 bb65cb2c..6f2a6912 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
@@ -8,6 +8,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;
@@ -17,11 +19,14 @@ 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 FeatureDungeonMilestone extends GuiFeature implements ChatListener {
+public class FeatureDungeonMilestone extends TextHUDFeature implements ChatListener {
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);
@@ -29,30 +34,47 @@ public class FeatureDungeonMilestone extends GuiFeature implements ChatListener
}
SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus();
+
+ private static final List<StyledText> dummyText= new ArrayList<StyledText>();
+ static {
+ dummyText.add(new StyledText("Milestone","title"));
+ dummyText.add(new StyledText(": ","separator"));
+ dummyText.add(new StyledText("9","number"));
+ }
+
@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);
+ public boolean isEnabled() {
+ return skyblockStatus.isOnDungeon();
+ }
+
+ @Override
+ public List<String> getUsedTextStyle() {
+ return Arrays.asList(new String[] {
+ "title", "separator", "number"
+ });
+ }
+
+ @Override
+ public List<StyledText> getDummyText() {
+ return dummyText;
+ }
+
+ @Override
+ public List<StyledText> getText() {
+ List<StyledText> actualBit = new ArrayList<StyledText>();
+ actualBit.add(new StyledText("Milestone","title"));
+ actualBit.add(new StyledText(": ","separator"));
for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) {
String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName());
if (name.startsWith("§r Milestone: §r")) {
String milestone = TextUtils.stripColor(name).substring(13);
- fr.drawString("Milestone: "+milestone, 0,0, this.<Color>getParameter("color").getValue().getRGB());
- return;
+ actualBit.add(new StyledText(milestone+"","number"));
+ break;
}
}
- fr.drawString("Milestone: ?", 0,0, this.<Color>getParameter("color").getValue().getRGB());
+ return actualBit;
}
- @Override
- public void drawDemo(float partialTicks) {
- FontRenderer fr = getFontRenderer();
- double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT;
- GlStateManager.scale(scale, scale, 0);
- fr.drawString("Milestone: 9", 0,0, this.<Color>getParameter("color").getValue().getRGB());
- }
public static final Pattern milestone_pattern = Pattern.compile("§r§e§l(.+) Milestone §r§e(.)§r§7: .+ §r§a(.+)§r");
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 16f7cb74..4be95491 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java
@@ -3,6 +3,7 @@ package kr.syeyoung.dungeonsguide.features.text;
import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane;
import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig;
import kr.syeyoung.dungeonsguide.config.guiconfig.MParameter;
+import kr.syeyoung.dungeonsguide.config.types.AColor;
import kr.syeyoung.dungeonsguide.features.AbstractFeature;
import kr.syeyoung.dungeonsguide.features.FeatureParameter;
import kr.syeyoung.dungeonsguide.features.text.StyledText;
@@ -10,94 +11,142 @@ import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature;
import kr.syeyoung.dungeonsguide.features.text.TextStyle;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.gui.elements.MButton;
+import kr.syeyoung.dungeonsguide.gui.elements.MColor;
+import kr.syeyoung.dungeonsguide.gui.elements.MEditableAColor;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
+import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
+import org.w3c.dom.css.Rect;
import java.awt.*;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Map;
+import java.util.*;
import java.util.List;
public class PanelTextParameterConfig extends MPanel {
private TextHUDFeature feature;
+ private MEditableAColor currentColor;
+
@Override
public void onBoundsUpdate() {
}
@Override
public void resize(int parentWidth, int parentHeight) {
- this.setBounds(new Rectangle(0,0,parentWidth, parentHeight));
+ this.setBounds(new Rectangle(5,5,parentWidth-10, parentHeight-10));
}
private GuiConfig config;
- public PanelTextParameterConfig(final GuiConfig config, TextHUDFeature feature) {
+ public PanelTextParameterConfig(final GuiConfig config, final TextHUDFeature feature) {
this.config = config;
- for (FeatureParameter parameter: feature.getParameters()) {
- if (!parameter.getKey().equalsIgnoreCase("textStyles"))
- add(new MParameter(feature, parameter, config));
- }
+ this.feature = feature;
setBackgroundColor(new Color(38, 38, 38, 255));
+
+ currentColor = new MEditableAColor();
+ currentColor.setColor(new AColor(0xff555555, true));
+ currentColor.setEnableEdit(false);
+ currentColor.setSize(new Dimension(15, 10));
+ currentColor.setBounds(new Rectangle(275 , 14, 15, 10));
+ currentColor.setOnUpdate(new Runnable() {
+ @Override
+ public void run() {
+ for (String se:selected)
+ feature.getStylesMap().get(se).setColor(currentColor.getColor());
+ }
+ });
+ add(currentColor);
}
+ private Set<String> selected = new HashSet<String>();
- MPanel within;
@Override
public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
- int heights = 100;
- within = null;
- for (MPanel panel:getChildComponents()) {
- panel.setPosition(new Point(5, -offsetY + heights + 5));
- heights += panel.getBounds().height;
+ GlStateManager.pushMatrix();
- if (panel.getBounds().contains(relMousex0,relMousey0)) within = panel;
- }
- renderStyleEdit(absMousex, absMousey, relMousex0, relMousey0, partialTicks, scissor);
- if (within instanceof MParameter) {
- FeatureParameter feature = ((MParameter) within).getParameter();
- GL11.glDisable(GL11.GL_SCISSOR_TEST);
- FeatureEditPane.drawHoveringText(new ArrayList<String>(Arrays.asList(feature.getDescription().split("\n"))), relMousex0,relMousey0, Minecraft.getMinecraft().fontRendererObj);
- GL11.glEnable(GL11.GL_SCISSOR_TEST);
- }
- }
+ int width = 200, height = 100;
+ Gui.drawRect(0,0,getBounds().width, getBounds().height, 0xFF444444);
+ Gui.drawRect(4,4,width+6, height+6, 0xFF222222);
+ Gui.drawRect(5,5,width+5, height+5, 0xFF555555);
+ 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);
- public void renderStyleEdit(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
- GlStateManager.pushMatrix();
- GlStateManager.translate(0, -offsetY, 0);
List<StyledText> texts = feature.getDummyText();
Map<String, TextStyle> styles = feature.getStylesMap();
List<TextHUDFeature.StyleTextAssociated> calc = feature.calculate(texts, 5,5, styles);
+ boolean bool =clip.contains(absMousex, absMousey);
for (TextHUDFeature.StyleTextAssociated calc3: calc) {
- if (calc3.getRectangle().contains(relMousex0, relMousey0)) {
+ 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)) {
for (TextHUDFeature.StyleTextAssociated calc2 : calc) {
- if (calc2.getStyledText() == calc3.getStyledText())
- Gui.drawRect(calc2.getRectangle().x, calc2.getRectangle().y, calc2.getRectangle().x + calc2.getRectangle().width, calc2.getRectangle().y + calc2.getRectangle().height, 0xFF5E5E5E);
+ 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);
}
- break;
}
}
feature.drawTextWithStylesAssociated(texts, 5,5, styles);
+ clip(new ScaledResolution(Minecraft.getMinecraft()), scissor.x, scissor.y, scissor.width, scissor.height);
- // draw actual logic
+
+ GlStateManager.translate(5, height + 7, 0);
+ GlStateManager.scale(0.5,0.5,0);
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ fr.drawString("Press Shift to multi-select", 0, 0, 0xFFBFBFBF);
GlStateManager.popMatrix();
- }
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(width + 15, 5, 0);
+ GlStateManager.pushMatrix();
+ GlStateManager.scale(0.5,0.5,0);
+ fr.drawString("Selected Groups: "+selected, 0, 0, 0xFFBFBFBF);
+ GlStateManager.popMatrix();
+ fr.drawString("Text Color: ", 0, 10, 0xFFFFFFFF);
- public int offsetY = 0;
+ GlStateManager.popMatrix();
+ }
@Override
- public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {
- if (scrollAmount > 0) offsetY -= 20;
- else if (scrollAmount < 0) offsetY += 20;
- if (offsetY < 0) offsetY = 0;
- }
+ 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);
+ for (TextHUDFeature.StyleTextAssociated calc3: calc) {
+ if (calc3.getRectangle().contains(relMouseX, relMouseY)) {
+ if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
+ if (!selected.contains(calc3.getStyledText().getGroup()))
+ selected.add(calc3.getStyledText().getGroup());
+ else
+ selected.remove(calc3.getStyledText().getGroup());
+ } else {
+ selected.clear();
+ selected.add(calc3.getStyledText().getGroup());
+ }
+ found = true;
+ }
+ }
+ if (!found && !(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) && relMouseX >= 5 && relMouseX <= 205 && relMouseY >= 5 && relMouseY <= 105) {
+ selected.clear();
+ }
+ currentColor.setEnableEdit(selected.size() != 0);
+ if (existed != selected.isEmpty()) {
+ if (selected.size() != 0)
+ currentColor.setColor(styles.get(selected.iterator().next()).getColor());
+ else
+ currentColor.setColor(new AColor(0xff555555, true));
+ }
+
+ if (selected.size() == 1)
+ currentColor.setColor(styles.get(selected.iterator().next()).getColor());
+ }
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledText.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledText.java
index aee344cd..904fd034 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledText.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledText.java
@@ -1,8 +1,10 @@
package kr.syeyoung.dungeonsguide.features.text;
+import lombok.AllArgsConstructor;
import lombok.Data;
@Data
+@AllArgsConstructor
public class StyledText {
private String text;
private String group;
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 d8e72d68..d019f6bd 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java
@@ -24,7 +24,7 @@ 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) {
super(category, name, description, key, keepRatio, width, height);
- this.parameters.put("textStyles", new FeatureParameter<List<TextStyle>>("textStyles", "", "", new ArrayList<TextStyle>(), "list_textstyle"));
+ this.parameters.put("textStyles", new FeatureParameter<List<TextStyle>>("textStyles", "", "", new ArrayList<TextStyle>(), "list_textStyle"));
}
@Override
@@ -32,6 +32,13 @@ public abstract class TextHUDFeature extends GuiFeature {
drawTextWithStylesAssociated(getText(), 0, 0, getStylesMap());
}
+ @Override
+ public void drawDemo(float partialTicks) {
+ drawTextWithStylesAssociated(getDummyText(), 0, 0, getStylesMap());
+ }
+
+ public abstract boolean isEnabled();
+
public abstract List<String> getUsedTextStyle();
public List<StyledText> getDummyText() {
return getText();
@@ -41,13 +48,21 @@ public abstract class TextHUDFeature extends GuiFeature {
public List<TextStyle> getStyles() {
return this.<List<TextStyle>>getParameter("textStyles").getValue();
}
+ private Map<String, TextStyle> stylesMap;
public Map<String, TextStyle> getStylesMap() {
- List<TextStyle> styles = getStyles();
- Map<String, TextStyle> res = new HashMap<String, TextStyle>();
- for (TextStyle ts:styles) {
- res.put(ts.getGroupName(), ts);
+ if (stylesMap == null) {
+ List<TextStyle> styles = getStyles();
+ Map<String, TextStyle> res = new HashMap<String, TextStyle>();
+ for (TextStyle ts : styles) {
+ res.put(ts.getGroupName(), ts);
+ }
+ for (String str : getUsedTextStyle()) {
+ if (!res.containsKey(str))
+ res.put(str, new TextStyle(str, new AColor(0xffffffff, true)));
+ }
+ stylesMap = res;
}
- return res;
+ return stylesMap;
}
public List<StyleTextAssociated> drawTextWithStylesAssociated(List<StyledText> texts, int x, int y, Map<String, TextStyle> styleMap) {
@@ -57,7 +72,7 @@ public abstract class TextHUDFeature extends GuiFeature {
int maxHeightForLine = 0;
List<StyleTextAssociated> associateds = new ArrayList<StyleTextAssociated>();
for (StyledText st : texts) {
- TextStyle ts = styleMap.get(st);
+ TextStyle ts = styleMap.get(st.getGroup());
String[] lines = st.getText().split("\n");
for (int i = 0; i < lines.length; i++) {
String str = lines[i];
@@ -68,11 +83,16 @@ public abstract class TextHUDFeature extends GuiFeature {
maxHeightForLine = d.height;
if (i+1 != lines.length) {
- currY += maxHeightForLine;
+ currY += maxHeightForLine ;
currX = x;
maxHeightForLine = 0;
}
}
+ if (st.getText().endsWith("\n")) {
+ currY += maxHeightForLine ;
+ currX = x;
+ maxHeightForLine = 0;
+ }
}
return associateds;
}
@@ -84,7 +104,7 @@ public abstract class TextHUDFeature extends GuiFeature {
int maxHeightForLine = 0;
List<StyleTextAssociated> associateds = new ArrayList<StyleTextAssociated>();
for (StyledText st : texts) {
- TextStyle ts = styleMap.get(st);
+ TextStyle ts = styleMap.get(st.getGroup());
String[] lines = st.getText().split("\n");
for (int i = 0; i < lines.length; i++) {
String str = lines[i];
@@ -100,6 +120,11 @@ public abstract class TextHUDFeature extends GuiFeature {
maxHeightForLine = 0;
}
}
+ if (st.getText().endsWith("\n")) {
+ currY += maxHeightForLine;
+ currX = x;
+ maxHeightForLine = 0;
+ }
}
return associateds;
}
@@ -134,7 +159,7 @@ public abstract class TextHUDFeature extends GuiFeature {
ConfigPanelCreator.map.put("base." + getKey() , new Supplier<MPanel>() {
@Override
public MPanel get() {
- return new PanelDefaultParameterConfig(config, TextHUDFeature.this);
+ return new PanelTextParameterConfig(config, TextHUDFeature.this);
}
});
return "base." + getKey() ;
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 74e3c66a..2353cd11 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java
@@ -1,11 +1,15 @@
package kr.syeyoung.dungeonsguide.features.text;
import kr.syeyoung.dungeonsguide.config.types.AColor;
+import lombok.AllArgsConstructor;
import lombok.Data;
+import lombok.NoArgsConstructor;
import java.awt.*;
@Data
+@AllArgsConstructor
+@NoArgsConstructor
public class TextStyle {
private String groupName;
private AColor color;