aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/features/text
diff options
context:
space:
mode:
authorsyeyoung <cyoung06@naver.com>2022-05-21 21:18:14 +0900
committersyeyoung <cyoung06@naver.com>2022-05-21 21:28:52 +0900
commit20dd3f99a7b139b5848128246c622fd9cfefa478 (patch)
tree78e5f84ad22fd53876d488f6b58c3528aebe6501 /src/main/java/kr/syeyoung/dungeonsguide/features/text
parent50de034c046c4ddea033b73793c8825ecb5bb86f (diff)
downloadSkyblock-Dungeons-Guide-20dd3f99a7b139b5848128246c622fd9cfefa478.tar.gz
Skyblock-Dungeons-Guide-20dd3f99a7b139b5848128246c622fd9cfefa478.tar.bz2
Skyblock-Dungeons-Guide-20dd3f99a7b139b5848128246c622fd9cfefa478.zip
- Project separation
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features/text')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java284
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledText.java29
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextProvider.java30
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java245
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java191
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java36
6 files changed, 0 insertions, 815 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
deleted file mode 100644
index beeff007..00000000
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
- * Copyright (C) 2021 cyoung06
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package kr.syeyoung.dungeonsguide.features.text;
-
-import kr.syeyoung.dungeonsguide.config.types.AColor;
-import kr.syeyoung.dungeonsguide.gui.MPanel;
-import kr.syeyoung.dungeonsguide.gui.elements.MEditableAColor;
-import kr.syeyoung.dungeonsguide.gui.elements.MPanelScaledGUI;
-import kr.syeyoung.dungeonsguide.gui.elements.MScrollablePanel;
-import kr.syeyoung.dungeonsguide.gui.elements.MToggleButton;
-import kr.syeyoung.dungeonsguide.utils.RenderUtils;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.Gui;
-import net.minecraft.client.gui.ScaledResolution;
-import net.minecraft.client.renderer.GlStateManager;
-import org.lwjgl.input.Keyboard;
-import org.lwjgl.opengl.GL11;
-import org.lwjgl.opengl.GL14;
-
-import java.awt.*;
-import java.util.*;
-import java.util.List;
-
-public class PanelTextParameterConfig extends MPanel {
-
- private final StyledTextProvider feature;
-
- private final MEditableAColor currentColor;
- private final MEditableAColor backgroundColor;
- private final MToggleButton shadow;
-
- private MScrollablePanel mScrollablePanel;
- private MPanelScaledGUI rendering;
-
- @Override
- public void onBoundsUpdate() {
- }
- @Override
- public Dimension getPreferredSize() {
- return new Dimension(400, getPanelBound().height + 20);
- }
-
- public PanelTextParameterConfig(final StyledTextProvider feature) {
- 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.setOnUpdate(new Runnable() {
- @Override
- public void run() {
- for (String se:selected)
- feature.getStylesMap().get(se).setColor(currentColor.getColor());
- }
- });
- add(currentColor);
- backgroundColor = new MEditableAColor();
- backgroundColor.setColor(new AColor(0xff555555, true));
- backgroundColor.setEnableEdit(false);
- backgroundColor.setSize(new Dimension(15, 10));
- backgroundColor.setOnUpdate(new Runnable() {
- @Override
- public void run() {
- for (String se:selected)
- feature.getStylesMap().get(se).setBackground(backgroundColor.getColor());
- }
- });
- add(backgroundColor);
- shadow = new MToggleButton();
- shadow.setSize(new Dimension(20, 10));
- shadow.setOnToggle(new Runnable() {
- @Override
- public void run() {
- for (String se:selected)
- feature.getStylesMap().get(se).setShadow(shadow.isEnabled());
- }
- });
- add(shadow);
-
- mScrollablePanel = new MScrollablePanel(3);
- mScrollablePanel.setHideScrollBarWhenNotNecessary(true);
- add(mScrollablePanel);
-
- mScrollablePanel.add(rendering = new MPanelScaledGUI() {
- @Override
- public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
- super.render(absMousex, absMousey, relMousex0, relMousey0, partialTicks, scissor);
-
- List<StyledText> texts = feature.getDummyText();
- Map<String, TextStyle> styles = feature.getStylesMap();
- List<StyledTextRenderer.StyleTextAssociated> calc = StyledTextRenderer.drawTextWithStylesAssociated(texts, 0,0, getEffectiveDimension().width, styles, StyledTextRenderer.Alignment.LEFT);
- boolean bool =scissor.contains(absMousex, absMousey);
- for (StyledTextRenderer.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, 0x4244A800);
- } else if (bool && calc3.getRectangle().contains(relMousex0, relMousey0)) {
- for (StyledTextRenderer.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, 0x55777777);
- }
- }
- }
- }
-
-
- 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<StyledTextRenderer.StyleTextAssociated> calc = StyledTextRenderer.calculate(texts, 0,0, styles);
- for (StyledTextRenderer.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)) && parent.getLastAbsClip().contains(absMouseX * getScale(), absMouseY* getScale())) {
- selected.clear();
- dragStart = true;
- lastX = absMouseX;
- lastY = absMouseY;
- }
- currentColor.setEnableEdit(selected.size() != 0);
- PanelTextParameterConfig.this.backgroundColor.setEnableEdit(selected.size() != 0);
- if (existed != selected.isEmpty()) {
- if (selected.size() != 0) {
- currentColor.setColor(styles.get(selected.iterator().next()).getColor());
- PanelTextParameterConfig.this.backgroundColor.setColor(styles.get(selected.iterator().next()).getBackground());
- shadow.setEnabled(styles.get(selected.iterator().next()).isShadow());
- } else {
- currentColor.setColor(new AColor(0xff555555, true));
- PanelTextParameterConfig.this.backgroundColor.setColor(new AColor(0xff555555, true));
- shadow.setEnabled(false);
- }
- }
-
- if (selected.size() == 1) {
- currentColor.setColor(styles.get(selected.iterator().next()).getColor());
- PanelTextParameterConfig.this.backgroundColor.setColor(styles.get(selected.iterator().next()).getBackground());
- shadow.setEnabled(styles.get(selected.iterator().next()).isShadow());
- }
- }
-
- @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) {
- int dx= absMouseX - lastX;
- int dy= absMouseY - lastY;
- int actualOFFX = (int) (dx / getScale());
- int actualOFFY = (int) (dy / getScale());
- lastX =(int) (actualOFFX * getScale())+lastX;
- lastY =(int) (actualOFFY * getScale())+lastY;
- mScrollablePanel.getScrollBarX().addToCurrent(-actualOFFX);
- mScrollablePanel.getScrollBarY().addToCurrent(-actualOFFY);
- }
- }
-
- @Override
- public Dimension getPreferredSize() {
- List<StyledTextRenderer.StyleTextAssociated> calc = StyledTextRenderer.calculate(feature.getDummyText(), 0,0, feature.getStylesMap());
- int w = 0, h = 0;
- for (StyledTextRenderer.StyleTextAssociated styleTextAssociated : calc) {
- int endX = styleTextAssociated.getRectangle().x + styleTextAssociated.getRectangle().width;
- int endY = styleTextAssociated.getRectangle().y + styleTextAssociated.getRectangle().height;
- if (endX > w) w = endX;
- if (endY > h) h = endY;
- }
- return new Dimension((int) (w * getScale()),(int) (h * getScale()));
- }
-
- @Override
- public void resize(int parentWidth, int parentHeight) {
- setBounds(new Rectangle(new Point(0,0), getPreferredSize()));
- }
-
-
- @Override
- public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {
- if ( parent.getLastAbsClip().contains(absMouseX * getScale(), absMouseY* getScale())) {
- double scale = rendering.getScale();
- 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;
- rendering.setScale(scale);
- mScrollablePanel.setBounds(new Rectangle(new Point(5,5),getPanelBound()));
- }
- }
- });
-
-
- }
-
- private final Set<String> selected = new HashSet<String>();
-
- @Override
- public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
-
- GlStateManager.pushMatrix();
-
- Dimension dim = getPanelBound();
- int width = dim.width, height = dim.height;
- Gui.drawRect(0,0,getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.12f));
- Gui.drawRect(4,4,width+6, height+6, 0xFF222222);
- Gui.drawRect(5,5,width+5, height+5, RenderUtils.blendAlpha(0x141414, 0.15f));
-
-
- GlStateManager.translate(5, height + 7, 0);
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- fr.drawString("Press Shift to multi-select", 0, 0, 0xFFBFBFBF);
- GlStateManager.popMatrix();
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(width + 15, 5, 0);
- GlStateManager.pushMatrix();
- fr.drawString("Selected Groups: "+selected, 0, 0, 0xFFBFBFBF);
- GlStateManager.popMatrix();
- fr.drawString("Text Color: ", 0, 10, 0xFFFFFFFF);
- fr.drawString("Background Color: ", 0, 20, 0xFFFFFFFF);
- fr.drawString("Shadow: ", 0, 39, 0xFFFFFFFF);
-
- GlStateManager.popMatrix();
- }
-
- private Dimension getPanelBound(){
-// return new Dimension((getBounds().width-25)/2, 100);
- return new Dimension(150,100);
- }
-
- @Override
- public void setBounds(Rectangle bounds) {
- super.setBounds(bounds);
-
- Dimension dim = getPanelBound();
- currentColor.setBounds(new Rectangle(75+dim.width , 14, 15, 10));
- backgroundColor.setBounds(new Rectangle(110+dim.width , 24, 15, 10));
- shadow.setBounds(new Rectangle(75+dim.width , 43, 30, 10));
- mScrollablePanel.setBounds(new Rectangle(5,5,dim.width,dim.height));
- }
-}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledText.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledText.java
deleted file mode 100644
index 10f9b06d..00000000
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledText.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
- * Copyright (C) 2021 cyoung06
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-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/StyledTextProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextProvider.java
deleted file mode 100644
index f3eba3a9..00000000
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextProvider.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
- * Copyright (C) 2021 cyoung06
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package kr.syeyoung.dungeonsguide.features.text;
-
-import java.util.List;
-import java.util.Map;
-
-public interface StyledTextProvider {
- List<StyledText> getDummyText();
- List<StyledText> getText();
-
- List<TextStyle> getStyles();
- Map<String, TextStyle> getStylesMap();
-}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java
deleted file mode 100644
index 9ebc138b..00000000
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
- * Copyright (C) 2021 cyoung06
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package kr.syeyoung.dungeonsguide.features.text;
-
-import kr.syeyoung.dungeonsguide.utils.RenderUtils;
-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 net.minecraftforge.fml.relauncher.ReflectionHelper;
-import org.lwjgl.opengl.GL11;
-import org.lwjgl.opengl.GL14;
-
-import java.awt.*;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-public class StyledTextRenderer {
-
- public static enum Alignment {
- LEFT, CENTER, RIGHT
- }
-
- private static final Method renderChar = ReflectionHelper.findMethod(FontRenderer.class, null, new String[] {"renderChar", "func_181559_a"}, char.class, boolean.class);
- private static final Method doDraw = ReflectionHelper.findMethod(FontRenderer.class, null, new String[] {"doDraw"}, float.class);
- private static final Field posX = ReflectionHelper.findField(FontRenderer.class, "posX", "field_78295_j");
- private static final Field posY = ReflectionHelper.findField(FontRenderer.class, "posY", "field_78296_k");
-
-
- public static List<StyleTextAssociated> drawTextWithStylesAssociated(List<StyledText> texts, int x, int y,int width, Map<String, TextStyle> styleMap, Alignment alignment) {
- String[] totalLines = (texts.stream().map( a-> a.getText()).collect(Collectors.joining())+" ").split("\n");
-
-
- GlStateManager.enableBlend();
- GlStateManager.enableAlpha();
- GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
-
- int currentLine = 0;
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int currX = alignment == Alignment.LEFT ? x : alignment == Alignment.CENTER ? (x+width-fr.getStringWidth(totalLines[currentLine]))/2 : (x+width-fr.getStringWidth(totalLines[currentLine]));
- int currY = y;
- int maxHeightForLine = 0;
- List<StyleTextAssociated> associateds = new ArrayList<StyleTextAssociated>();
- for (StyledText st : texts) {
- TextStyle ts = styleMap.get(st.getGroup());
- String[] lines = st.getText().split("\n");
- for (int i = 0; i < lines.length; i++) {
- String str = lines[i];
- Dimension d = null;
- try {
- d = drawFragmentText(fr, str, ts, currX, currY, false);
- } catch (InvocationTargetException | IllegalAccessException e) {
- e.printStackTrace();
- }
- associateds.add(new StyleTextAssociated(st, new Rectangle(currX, currY, d.width, d.height)));
- currX += d.width;
- if (maxHeightForLine < d.height)
- maxHeightForLine = d.height;
-
- if (i+1 != lines.length) {
- currY += maxHeightForLine ;
- currentLine++;
- currX = alignment == Alignment.LEFT ? x : alignment == Alignment.CENTER ? (x+width-fr.getStringWidth(totalLines[currentLine]))/2 : (x+width-fr.getStringWidth(totalLines[currentLine]));
- maxHeightForLine = 0;
- }
- }
- if (st.getText().endsWith("\n")) {
- currY += maxHeightForLine;
- currentLine++;
- currX = alignment == Alignment.LEFT ? x : alignment == Alignment.CENTER ? (x+width-fr.getStringWidth(totalLines[currentLine]))/2 : (x+width-fr.getStringWidth(totalLines[currentLine]));
- maxHeightForLine = 0;
- }
- }
- return associateds;
- }
-
- public static List<StyleTextAssociated> calculate(List<StyledText> texts, int x, int y, Map<String, TextStyle> styleMap) {
- int currX = x;
- int currY = y;
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int maxHeightForLine = 0;
- List<StyleTextAssociated> associateds = new ArrayList<StyleTextAssociated>();
- for (StyledText st : texts) {
- TextStyle ts = styleMap.get(st.getGroup());
- String[] lines = st.getText().split("\n");
- for (int i = 0; i < lines.length; i++) {
- String str = lines[i];
- Dimension d = null;
- try {
- d = drawFragmentText(fr, str, ts, currX, currY, true);
- } catch (InvocationTargetException | IllegalAccessException e) {
- e.printStackTrace();
- }
- associateds.add(new StyleTextAssociated(st, new Rectangle(currX, currY, d.width, d.height)));
- currX += d.width;
- if (maxHeightForLine < d.height)
- maxHeightForLine = d.height;
-
- if (i+1 != lines.length) {
- currY += maxHeightForLine;
- currX = x;
- maxHeightForLine = 0;
- }
- }
- if (st.getText().endsWith("\n")) {
- currY += maxHeightForLine;
- currX = x;
- maxHeightForLine = 0;
- }
- }
- return associateds;
- }
-
- @Data
- @AllArgsConstructor
- public static class StyleTextAssociated {
- private StyledText styledText;
- private Rectangle rectangle;
- }
-
- private static Dimension drawFragmentText(FontRenderer fr, String content, TextStyle style, int x, int y, boolean stopDraw) throws InvocationTargetException, IllegalAccessException {
- if (stopDraw)
- return new Dimension(fr.getStringWidth(content), fr.FONT_HEIGHT);
-
- int bgColor = RenderUtils.getColorAt(x,y, style.getBackground());
- if ((bgColor & 0xFF000000) != 0)
- Gui.drawRect(x,y, x+fr.getStringWidth(content), y + fr.FONT_HEIGHT, bgColor);
-
-
- posX.set(fr, x+1);
- posY.set(fr, y+1);
-
- if (style.isShadow()) {
- char[] charArr = content.toCharArray();
- float width = 0;
- for (int i = 0; i < charArr.length; i++) {
- int color = RenderUtils.getColorAt(x + width, y, style.getColor());
- color = (color & 16579836) >> 2 | color & -16777216;
-
- width +=renderChar(fr, charArr[i], color,true, false, false, false);
- }
- }
- posX.set(fr, x);
- posY.set(fr, y);
- {
- char[] charArr = content.toCharArray();
- float width = 0;
- for (int i = 0; i < charArr.length; i++) {
- int color = RenderUtils.getColorAt(x + width, y, style.getColor());
-
- width +=renderChar(fr, charArr[i], color, false, false, false, false);
- }
- return new Dimension((int) width, fr.FONT_HEIGHT);
- }
- }
-
- private static float renderChar(FontRenderer fr, char character, int color, boolean shadow, boolean randomStyle, boolean boldStyle, boolean italicStyle) throws InvocationTargetException, IllegalAccessException {
- RenderUtils.GL_SETCOLOR(color);
- int j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(character);
-
- if (randomStyle && j != -1)
- {
- int k = fr.getCharWidth(character);
- char c1;
-
- while (true)
- {
- j = fr.fontRandom.nextInt("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".length());
- c1 = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".charAt(j);
-
- if (k == fr.getCharWidth(c1))
- {
- break;
- }
- }
-
- character = c1;
- }
-
- float f1 = j == -1 || fr.getUnicodeFlag() ? 0.5f : 1f;
- boolean flag = (character == 0 || j == -1 || fr.getUnicodeFlag()) && shadow;
-
- if (flag)
- {
- posX.set(fr,(float) posX.get(fr) - f1);
- posY.set(fr,(float) posY.get(fr) - f1);
- }
-
- float f = (float) renderChar.invoke(fr, character, italicStyle);
-
- if (flag)
- {
- posX.set(fr,(float) posX.get(fr) + f1);
- posY.set(fr,(float) posY.get(fr) + f1);
- }
-
- if (boldStyle)
- {
- posX.set(fr,(float) posX.get(fr) + f1);
-
- if (flag)
- {
- posX.set(fr,(float) posX.get(fr) - f1);
- posY.set(fr,(float) posY.get(fr) - f1);
- }
-
- renderChar.invoke(fr, character, italicStyle);
- posX.set(fr,(float) posX.get(fr) - f1);
-
- if (flag)
- {
- posX.set(fr,(float) posX.get(fr) + f1);
- posY.set(fr,(float) posY.get(fr) + f1);
- }
-
- ++f;
- }
- doDraw.invoke(fr, f);
-
- return f;
- }
-}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java
deleted file mode 100644
index b0cda000..00000000
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
- * Copyright (C) 2021 cyoung06
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package kr.syeyoung.dungeonsguide.features.text;
-
-import com.google.common.base.Supplier;
-import com.google.gson.JsonObject;
-import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator;
-import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit;
-import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit;
-import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel;
-import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig;
-import kr.syeyoung.dungeonsguide.config.types.AColor;
-import kr.syeyoung.dungeonsguide.features.FeatureParameter;
-import kr.syeyoung.dungeonsguide.features.GuiFeature;
-import kr.syeyoung.dungeonsguide.gui.MPanel;
-import kr.syeyoung.dungeonsguide.gui.elements.MFloatSelectionButton;
-import kr.syeyoung.dungeonsguide.gui.elements.MPassiveLabelAndElement;
-import kr.syeyoung.dungeonsguide.gui.elements.MStringSelectionButton;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.renderer.GlStateManager;
-
-import java.util.*;
-import java.util.List;
-
-public abstract class TextHUDFeature extends GuiFeature implements StyledTextProvider {
- 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("textStylesNEW", new FeatureParameter<List<TextStyle>>("textStylesNEW", "", "", new ArrayList<TextStyle>(), "list_textStyle"));
- this.parameters.put("alignment", new FeatureParameter<String>("alignment", "Alignment", "Alignment", "LEFT", "string"));
- this.parameters.put("scale", new FeatureParameter<Float>("scale", "Scale", "Scale", 1.0f, "float"));
- }
-
- @Override
- public void drawHUD(float partialTicks) {
- if (isHUDViewable()) {
- List<StyledText> asd = getText();
-
- double scale = 1;
- if (doesScaleWithHeight()) {
- FontRenderer fr = getFontRenderer();
- scale = getFeatureRect().getRectangle().getHeight() / (fr.FONT_HEIGHT* countLines(asd));
- } else {
- scale = this.<Float>getParameter("scale").getValue();
- }
- GlStateManager.scale(scale, scale, 0);
- StyledTextRenderer.drawTextWithStylesAssociated(asd, 0, 0, (int) (Math.abs(getFeatureRect().getWidth())/scale), getStylesMap(),
- StyledTextRenderer.Alignment.valueOf(TextHUDFeature.this.<String>getParameter("alignment").getValue()));
- }
- }
-
- public boolean doesScaleWithHeight() {
- return true;
- }
-
- @Override
- public void drawDemo(float partialTicks) {
- List<StyledText> asd = getDummyText();
- double scale = 1;
- if (doesScaleWithHeight()) {
- FontRenderer fr = getFontRenderer();
- scale = getFeatureRect().getRectangle().getHeight() / (fr.FONT_HEIGHT* countLines(asd));
- } else {
- scale = this.<Float>getParameter("scale").getValue();
- }
- GlStateManager.scale(scale, scale, 0);
-
- StyledTextRenderer.drawTextWithStylesAssociated(asd, 0, 0, (int) (Math.abs(getFeatureRect().getWidth())/scale), getStylesMap(),
- StyledTextRenderer.Alignment.valueOf(TextHUDFeature.this.<String>getParameter("alignment").getValue()));
- }
-
- 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.toCharArray()) {
- if (c == '\n') lines++;
- }
- return lines;
- }
-
- public abstract boolean isHUDViewable();
-
- public abstract List<String> getUsedTextStyle();
- public List<StyledText> getDummyText() {
- return getText();
- }
- public abstract List<StyledText> getText();
-
- public List<TextStyle> getStyles() {
- return this.<List<TextStyle>>getParameter("textStylesNEW").getValue();
- }
- private Map<String, TextStyle> stylesMap;
- public Map<String, TextStyle> getStylesMap() {
- 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), new AColor(0x00777777, true), false));
- }
- stylesMap = res;
- }
- return stylesMap;
- }
-
-
- @Override
- public String getEditRoute(RootConfigPanel rootConfigPanel) {
- ConfigPanelCreator.map.put("base." + getKey() , new Supplier<MPanel>() {
- @Override
- public MPanel get() {
-
- MFeatureEdit featureEdit = new MFeatureEdit(TextHUDFeature.this, rootConfigPanel);
- featureEdit.addParameterEdit("textStyleNEW", new PanelTextParameterConfig(TextHUDFeature.this));
-
- StyledTextRenderer.Alignment alignment = StyledTextRenderer.Alignment.valueOf(TextHUDFeature.this.<String>getParameter("alignment").getValue());
- MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(Arrays.asList("LEFT", "CENTER", "RIGHT"), alignment.name());
- mStringSelectionButton.setOnUpdate(() -> {
- TextHUDFeature.this.<String>getParameter("alignment").setValue(mStringSelectionButton.getSelected());
- });
- featureEdit.addParameterEdit("alignment", new MParameterEdit(TextHUDFeature.this, TextHUDFeature.this.<String>getParameter("alignment"), rootConfigPanel, mStringSelectionButton, (a) -> false));
-
- for (FeatureParameter parameter: getParameters()) {
- if (parameter.getKey().equals("textStylesNEW")) continue;
- if (parameter.getKey().equals("alignment")) continue;
- featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(TextHUDFeature.this, parameter, rootConfigPanel));
- }
- return featureEdit;
- }
- });
- return "base." + getKey() ;
- }
-
- @Override
- public List<MPanel> getTooltipForEditor(GuiGuiLocationConfig guiGuiLocationConfig) {
- List<MPanel> mPanels = super.getTooltipForEditor(guiGuiLocationConfig);
- StyledTextRenderer.Alignment alignment = StyledTextRenderer.Alignment.valueOf(this.<String>getParameter("alignment").getValue());
- MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(Arrays.asList("LEFT", "CENTER", "RIGHT"), alignment.name());
- mStringSelectionButton.setOnUpdate(() -> {
- TextHUDFeature.this.<String>getParameter("alignment").setValue(mStringSelectionButton.getSelected());
- });
-
- mPanels.add(new MPassiveLabelAndElement("Alignment", mStringSelectionButton));
- if (!doesScaleWithHeight()) {
- mPanels.add(new MPassiveLabelAndElement("Scale", new MFloatSelectionButton(TextHUDFeature.this.<Float>getParameter("scale").getValue()) {{
- setOnUpdate(() ->{
- TextHUDFeature.this.<Float>getParameter("scale").setValue(this.getData());
- }); }
- }));
- }
-
- return mPanels;
- }
-
- @Override
- public void onParameterReset() {
- stylesMap = null;
- }
-
- @Override
- public void loadConfig(JsonObject jsonObject) {
- super.loadConfig(jsonObject);
- StyledTextRenderer.Alignment alignment;
- try {
- alignment = StyledTextRenderer.Alignment.valueOf(TextHUDFeature.this.<String>getParameter("alignment").getValue());
- } catch (Exception e) {alignment = StyledTextRenderer.Alignment.LEFT;}
- TextHUDFeature.this.<String>getParameter("alignment").setValue(alignment.name());
- }
-}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java
deleted file mode 100644
index 7af96457..00000000
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
- * Copyright (C) 2021 cyoung06
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-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;
- private AColor background;
- private boolean shadow = false;
-}