aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/features/text
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/text
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/text')
-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
4 files changed, 130 insertions, 50 deletions
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;