diff options
author | syeyoung <cyoung06@naver.com> | 2023-02-08 21:19:03 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2023-02-08 21:19:03 +0900 |
commit | c553002ccaac367cf1e9abcd71316b80720db37b (patch) | |
tree | 42e8b0ae63c0c8b961928c9e4e6b21ba1dea3a78 /mod/src/main/java/kr | |
parent | a8f67b684de08e1e7fa751ca78a068a4e6400cd1 (diff) | |
download | Skyblock-Dungeons-Guide-c553002ccaac367cf1e9abcd71316b80720db37b.tar.gz Skyblock-Dungeons-Guide-c553002ccaac367cf1e9abcd71316b80720db37b.tar.bz2 Skyblock-Dungeons-Guide-c553002ccaac367cf1e9abcd71316b80720db37b.zip |
- Name
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'mod/src/main/java/kr')
41 files changed, 1072 insertions, 953 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/AColor.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/AColor.java index 35b9e41f..a031a8f3 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/AColor.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/AColor.java @@ -18,6 +18,9 @@ package kr.syeyoung.dungeonsguide.mod.config.types; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.shaders.ChromaShader; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.shaders.Shader; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.shaders.SingleColorShader; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -52,6 +55,11 @@ public class AColor extends Color { return aColor; } + public Shader getShader() { + if (chroma) return new ChromaShader(chromaSpeed, getRGB()); + else return new SingleColorShader(getRGB()); + } + @Override public String toString() { return "AColor{" + diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCRTextStyle.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCRTextStyle.java new file mode 100644 index 00000000..9d1d099b --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCRTextStyle.java @@ -0,0 +1,73 @@ +/* + * 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.mod.config.types; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; + + +public class TCRTextStyle implements FeatureTypeHandler<DefaultingDelegatingTextStyle> { + public static final TCRTextStyle INSTANCE = new TCRTextStyle(); + + @Override + public DefaultingDelegatingTextStyle deserialize(JsonElement element) { + JsonObject object = element.getAsJsonObject(); + DefaultingDelegatingTextStyle textStyle = new DefaultingDelegatingTextStyle(); + textStyle.setSize(object.has("size") && !object.get("size").isJsonNull() ? object.get("size").getAsDouble() : null); + textStyle.setTopAscent(object.has("topAscent") && !object.get("topAscent").isJsonNull()? object.get("topAscent").getAsDouble() : null); + textStyle.setBottomAscent(object.has("bottomAscent") && !object.get("bottomAscent").isJsonNull()? object.get("bottomAscent").getAsDouble() : null); + textStyle.setBold(object.has("bold") && !object.get("bold").isJsonNull()? object.get("bold").getAsBoolean() : null); + textStyle.setItalics(object.has("italics") && !object.get("italics").isJsonNull()? object.get("italics").getAsBoolean() : null); + textStyle.setStrikeThrough(object.has("strikethrough") && !object.get("strikethrough").isJsonNull()? object.get("strikethrough").getAsBoolean() : null); + textStyle.setUnderline(object.has("underline") && !object.get("underline").isJsonNull()? object.get("underline").getAsBoolean() : null); + textStyle.setOutline(object.has("outline") && !object.get("outline").isJsonNull()? object.get("outline").getAsBoolean() : null); + textStyle.setShadow(object.has("shadow") && !object.get("shadow").isJsonNull()? object.get("shadow").getAsBoolean() : null); + textStyle.setBackgroundShader(object.has("backgroundColor") && !object.get("backgroundColor").isJsonNull()? TCAColor.INSTANCE.deserialize(object.get("backgroundColor")) : null); + textStyle.setTextShader(object.has("textColor") && !object.get("textColor").isJsonNull()? TCAColor.INSTANCE.deserialize(object.get("textColor")) : null); + textStyle.setStrikeThroughShader(object.has("strikethroughColor") && !object.get("strikethroughColor").isJsonNull()? TCAColor.INSTANCE.deserialize(object.get("strikethroughColor")) : null); + textStyle.setUnderlineShader(object.has("underlineColor") && !object.get("underlineColor").isJsonNull()? TCAColor.INSTANCE.deserialize(object.get("underlineColor")) : null); + textStyle.setOutlineShader(object.has("outlineColor") && !object.get("outlineColor").isJsonNull()? TCAColor.INSTANCE.deserialize(object.get("outlineColor")) : null); + textStyle.setShadowShader(object.has("shadowColor") && !object.get("shadowColor").isJsonNull()? TCAColor.INSTANCE.deserialize(object.get("shadowColor")) : null); + return textStyle; + } + + @Override + public JsonElement serialize(DefaultingDelegatingTextStyle element) { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("size", element.size); + jsonObject.addProperty("topAscent", element.topAscent); + jsonObject.addProperty("bottomAscent", element.bottomAscent); + jsonObject.addProperty("bold", element.bold); + jsonObject.addProperty("italics", element.italics); + jsonObject.addProperty("strikethrough", element.strikeThrough); + jsonObject.addProperty("underline", element.underline); + jsonObject.addProperty("outline", element.outline); + jsonObject.addProperty("shadow", element.shadow); + jsonObject.add("backgroundColor", element.backgroundShader == null ? null : TCAColor.INSTANCE.serialize(element.backgroundShader)); + jsonObject.add("textColor", element.textShader == null ? null : TCAColor.INSTANCE.serialize(element.textShader)); + jsonObject.add("strikethroughColor", element.strikeThroughShader == null ? null : TCAColor.INSTANCE.serialize(element.strikeThroughShader)); + jsonObject.add("underlineColor", element.underlineShader == null ? null : TCAColor.INSTANCE.serialize(element.underlineShader)); + jsonObject.add("outlineColor", element.outlineShader == null ? null : TCAColor.INSTANCE.serialize(element.outlineShader)); + jsonObject.add("shadowColor", element.shadowShader == null ? null : TCAColor.INSTANCE.serialize(element.shadowShader)); + return jsonObject; + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCRTextStyleMap.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCRTextStyleMap.java new file mode 100644 index 00000000..9311ff2b --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCRTextStyleMap.java @@ -0,0 +1,49 @@ +/* + * 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.mod.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; + +import java.util.HashMap; +import java.util.Map; + + +public class TCRTextStyleMap implements FeatureTypeHandler<Map<String, DefaultingDelegatingTextStyle>> { + public static final TCRTextStyleMap INSTANCE = new TCRTextStyleMap(); + @Override + public Map<String, DefaultingDelegatingTextStyle> deserialize(JsonElement element) { + JsonObject jsonObject = element.getAsJsonObject(); + Map<String, DefaultingDelegatingTextStyle> map = new HashMap<>(); + for (Map.Entry<String, JsonElement> stringJsonElementEntry : jsonObject.entrySet()) { + map.put(stringJsonElementEntry.getKey(), TCRTextStyle.INSTANCE.deserialize(stringJsonElementEntry.getValue())); + } + return map; + } + + @Override + public JsonElement serialize(Map<String, DefaultingDelegatingTextStyle> element) { + JsonObject jsonObject = new JsonObject(); + for (Map.Entry<String, DefaultingDelegatingTextStyle> stringDefaultingDelegatingTextStyleEntry : element.entrySet()) { + jsonObject.add(stringDefaultingDelegatingTextStyleEntry.getKey(), TCRTextStyle.INSTANCE.serialize(stringDefaultingDelegatingTextStyleEntry.getValue())); + } + return jsonObject; + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractFeature.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractFeature.java index 363fd24e..28650192 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractFeature.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractFeature.java @@ -18,12 +18,10 @@ package kr.syeyoung.dungeonsguide.mod.features; -import com.google.common.base.Supplier; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import kr.syeyoung.dungeonsguide.mod.config.guiconfig.configv3.DefaultConfigurePageWidget; import kr.syeyoung.dungeonsguide.mod.config.types.FeatureTypeHandler; -import kr.syeyoung.dungeonsguide.mod.gui.MPanel; import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; import lombok.Getter; import lombok.Setter; diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java index ea1972b2..0fe84145 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java @@ -23,17 +23,11 @@ import kr.syeyoung.dungeonsguide.mod.config.guiconfig.configv3.MainConfigWidget; import kr.syeyoung.dungeonsguide.mod.config.types.GUIPosition; import kr.syeyoung.dungeonsguide.mod.config.types.TCGUIPosition; import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; -import kr.syeyoung.dungeonsguide.mod.guiv2.DomElement; import kr.syeyoung.dungeonsguide.mod.guiv2.GuiScreenAdapter; import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; import kr.syeyoung.dungeonsguide.mod.guiv2.elements.GlobalHUDScale; import kr.syeyoung.dungeonsguide.mod.guiv2.elements.Navigator; import kr.syeyoung.dungeonsguide.mod.guiv2.elements.Text; -import kr.syeyoung.dungeonsguide.mod.guiv2.layouter.Layouter; -import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.ConstraintBox; -import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Size; -import kr.syeyoung.dungeonsguide.mod.guiv2.renderer.Renderer; -import kr.syeyoung.dungeonsguide.mod.guiv2.renderer.RenderingContext; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedImportOnlyWidget; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On; @@ -42,7 +36,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.util.ResourceLocation; -import java.util.Collections; import java.util.List; @Getter diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureRegistry.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureRegistry.java index 1c0bc38e..03cf914f 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureRegistry.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureRegistry.java @@ -42,6 +42,7 @@ import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.FeatureVi import kr.syeyoung.dungeonsguide.mod.features.impl.secret.*; import kr.syeyoung.dungeonsguide.mod.features.impl.secret.mechanicbrowser.FeatureMechanicBrowse; import kr.syeyoung.dungeonsguide.mod.features.impl.solvers.*; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; import kr.syeyoung.dungeonsguide.mod.overlay.OverlayManager; import lombok.Getter; import org.lwjgl.input.Keyboard; @@ -80,6 +81,8 @@ public class FeatureRegistry { return abstractFeature; } + public static final DefaultTextHUDFeatureStyleFeature DEFAULT_STYLE = register(new DefaultTextHUDFeatureStyleFeature()); + public static final PathfindLineProperties SECRET_LINE_PROPERTIES_GLOBAL = register(new PathfindLineProperties("Dungeon.Secrets.Preferences", "Global Line Settings", "Global Line Settings", "secret.lineproperties.global", true, null)); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebugTrap.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebugTrap.java index 93e7363e..84783d12 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebugTrap.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebugTrap.java @@ -21,35 +21,28 @@ package kr.syeyoung.dungeonsguide.mod.features.impl.advanced; import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.config.types.AColor; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.passive.EntityBat; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class FeatureDebugTrap extends TextHUDFeature { public FeatureDebugTrap() { super("Debug", "Display the current amount of bat entities", "", "advanced.bat"); - getStyles().add(new TextStyle("base", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("batsamm", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("base", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("batsamm", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - private static final List<StyledText> dummyText= new ArrayList<>(); - static { - dummyText.add(new StyledText("Bats: ","base")); - dummyText.add(new StyledText("9999","batsamm")); - } - - static List<Long> avgStorage = new ArrayList<>(); public static void updateVal(long timeItTookForThePacketToProcess){ @@ -72,26 +65,24 @@ public class FeatureDebugTrap extends TextHUDFeature { } @Override - public List<String> getUsedTextStyle() { - return Arrays.asList("batsamm", "base"); - } - - @Override - public List<StyledText> getDummyText() { - return dummyText; + public TextSpan getDummyText() { + TextSpan textSpan = new TextSpan(new NullTextStyle(), ""); + textSpan.addChild(new TextSpan(getStyle("base"), "Bats: ")); + textSpan.addChild(new TextSpan(getStyle("batsamm"), "9999")); + return textSpan; } @Override - public List<StyledText> getText() { + public TextSpan getText() { List<Entity> bats = Minecraft.getMinecraft().theWorld.getEntities(EntityBat.class, e -> true); - List<StyledText> actualBit = new ArrayList<>(); - actualBit.add(new StyledText("Bats: ","base")); + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("base"), "Bats: ")); - actualBit.add(new StyledText(String.valueOf(getAvgTimeItTookToPacket()),"batsamm")); + actualBit.addChild(new TextSpan(getStyle("batsamm"), String.valueOf(getAvgTimeItTookToPacket()))); return actualBit; } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDetectFreeze.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDetectFreeze.java index b996c86f..8101f060 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDetectFreeze.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDetectFreeze.java @@ -20,8 +20,6 @@ package kr.syeyoung.dungeonsguide.mod.features.impl.advanced; import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; -import kr.syeyoung.dungeonsguide.mod.events.impl.DGTickEvent; -import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; import net.minecraftforge.fml.common.gameevent.TickEvent; diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomCoordDisplay.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomCoordDisplay.java index 1b5357eb..1e1b622b 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomCoordDisplay.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomCoordDisplay.java @@ -25,35 +25,29 @@ import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.config.types.AColor; import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.util.BlockPos; import java.awt.*; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; public class FeatureRoomCoordDisplay extends TextHUDFeature { public FeatureRoomCoordDisplay() { super("Debug", "Display Coordinate Relative to the Dungeon Room and room's rotation", "X: 0 Y: 3 Z: 5 Facing: Z+" , "advanced.coords"); this.setEnabled(false); - getStyles().add(new TextStyle("coord", new AColor(Color.yellow.getRGB(),true), new AColor(0, 0,0,0), false)); + registerDefaultStyle("coord", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(Color.yellow.getRGB(),true)).setBackgroundShader(new AColor(0, 0,0,0))); } SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - private static final List<StyledText> dummyText= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("X: 0 Y: 3 Z: 5 Facing: Z+","coord")); - } @Override - public List<StyledText> getDummyText() { - return dummyText; + public TextSpan getDummyText() { + return new TextSpan(getStyle("coord"), "X: 0 Y: 3 Z: 5 Facing: Z+"); } private static final String[] facing = {"Z+", "X-", "Z-", "X+"}; @@ -75,21 +69,16 @@ public class FeatureRoomCoordDisplay extends TextHUDFeature { } @Override - public List<String> getUsedTextStyle() { - return Collections.singletonList("coord"); - } - - @Override - public List<StyledText> getText() { - if (!skyblockStatus.isOnDungeon()) return Collections.emptyList(); + public TextSpan getText() { + if (!skyblockStatus.isOnDungeon()) return new TextSpan(new NullTextStyle(), ""); DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); - if (context == null) return Collections.emptyList(); + if (context == null) return new TextSpan(new NullTextStyle(), ""); EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; Point roomPt = context.getScaffoldParser().getDungeonMapLayout().worldPointToRoomPoint(thePlayer.getPosition()); DungeonRoom dungeonRoom = context.getScaffoldParser().getRoomMap().get(roomPt); if (dungeonRoom == null) { - return Collections.emptyList(); + return new TextSpan(new NullTextStyle(), ""); } int facing = (int) (thePlayer.rotationYaw + 45) % 360; @@ -98,7 +87,7 @@ public class FeatureRoomCoordDisplay extends TextHUDFeature { OffsetPoint offsetPoint = new OffsetPoint(dungeonRoom, new BlockPos((int)thePlayer.posX, (int)thePlayer.posY, (int)thePlayer.posZ)); - return Collections.singletonList(new StyledText("X: "+offsetPoint.getX()+" Y: "+offsetPoint.getY()+" Z: "+offsetPoint.getZ()+" Facing: "+ FeatureRoomCoordDisplay.facing[real], "coord")); + return new TextSpan(getStyle("coord"), "X: "+offsetPoint.getX()+" Y: "+offsetPoint.getY()+" Z: "+offsetPoint.getZ()+" Facing: "+ FeatureRoomCoordDisplay.facing[real]); } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomDebugInfo.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomDebugInfo.java index ac7c7b90..3ecea83b 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomDebugInfo.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomDebugInfo.java @@ -24,41 +24,29 @@ import kr.syeyoung.dungeonsguide.mod.config.types.AColor; import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.FontRenderer; import org.apache.commons.lang3.StringUtils; import java.awt.*; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; public class FeatureRoomDebugInfo extends TextHUDFeature { public FeatureRoomDebugInfo() { super("Debug", "Display Room Debug Info", "ONLY WORKS WITH SECRET SETTING", "advanced.debug.roominfo"); this.setEnabled(false); - getStyles().add(new TextStyle("info", new AColor(Color.white.getRGB(),true), new AColor(0, 0,0,0), false)); + registerDefaultStyle("info", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(Color.white.getRGB(),true)).setBackgroundShader(new AColor(0, 0,0,0))); } SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - private static final List<StyledText> dummyText= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("Line 1\nLine 2\nLine 3\nLine 4\nLine 5","info")); - } - - @Override - public List<StyledText> getDummyText() { - return dummyText; - } - @Override - public List<String> getUsedTextStyle() { - return Collections.singletonList("info"); + public TextSpan getDummyText() { + return new TextSpan(getStyle("info"), "Line 1\nLine 2\nLine 3\nLine 4\nLine 5"); } @Override @@ -71,13 +59,13 @@ public class FeatureRoomDebugInfo extends TextHUDFeature { } @Override - public List<StyledText> getText() { - if (!skyblockStatus.isOnDungeon()) return Collections.emptyList(); - if (!FeatureRegistry.DEBUG.isEnabled()) return Collections.emptyList(); + public TextSpan getText() { + if (!skyblockStatus.isOnDungeon()) return new TextSpan(new NullTextStyle(), ""); + if (!FeatureRegistry.DEBUG.isEnabled()) return new TextSpan(new NullTextStyle(), ""); DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); - if (context == null) return Collections.emptyList(); + if (context == null) return new TextSpan(new NullTextStyle(), ""); EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - if (context.getScaffoldParser() == null) return Collections.emptyList(); + if (context.getScaffoldParser() == null) return new TextSpan(new NullTextStyle(), ""); Point roomPt = context.getScaffoldParser().getDungeonMapLayout().worldPointToRoomPoint(thePlayer.getPosition()); DungeonRoom dungeonRoom = context.getScaffoldParser().getRoomMap().get(roomPt); FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; @@ -100,6 +88,6 @@ public class FeatureRoomDebugInfo extends TextHUDFeature { str +="room name: " + dungeonRoom.getDungeonRoomInfo().getName()+"\n"; str +="room state / max secret: " + dungeonRoom.getCurrentState() + " / "+dungeonRoom.getTotalSecrets(); } - return Collections.singletonList(new StyledText(str, "info")); + return new TextSpan(getStyle("info"), str); } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureBossHealth.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureBossHealth.java index 9c534176..9f761821 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureBossHealth.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureBossHealth.java @@ -25,13 +25,14 @@ import kr.syeyoung.dungeonsguide.mod.config.types.AColor; import kr.syeyoung.dungeonsguide.mod.config.types.TCBoolean; import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.HealthData; import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class FeatureBossHealth extends TextHUDFeature { @@ -42,11 +43,11 @@ public class FeatureBossHealth extends TextHUDFeature { addParameter("formatHealth", new FeatureParameter<Boolean>("formatHealth", "format health", "1234568 -> 1m", true, TCBoolean.INSTANCE, nval -> formatHealth = nval)); addParameter("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, TCBoolean.INSTANCE, nval -> ignoreInattackable = nval)); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("health", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator2", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("maxHealth", new AColor(0x55, 0x55,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("title", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("health", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("separator2", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("maxHealth", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); } @@ -61,13 +62,8 @@ public class FeatureBossHealth extends TextHUDFeature { } @Override - public java.util.List<String> getUsedTextStyle() { - return Arrays.asList("title", "separator", "health", "separator2", "maxHealth"); - } - - @Override - public java.util.List<StyledText> getDummyText() { - List<StyledText> actualBit = new ArrayList<StyledText>(); + public TextSpan getDummyText() { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); 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); @@ -76,21 +72,21 @@ public class FeatureBossHealth extends TextHUDFeature { return actualBit; } - public void addLine(HealthData data, List<StyledText> actualBit) { + public void addLine(HealthData data, TextSpan actualBit) { if (ignoreInattackable && !data.isAttackable()) return; - actualBit.add(new StyledText(data.getName(),"title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText( (formatHealth ? TextUtils.format(data.getHealth()) : data.getHealth()) + (totalHealth ? "" : "\n"),"health")); + actualBit.addChild(new TextSpan(getStyle("title"), data.getName())); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("health"), (formatHealth ? TextUtils.format(data.getHealth()) : data.getHealth()) + (totalHealth ? "" : "\n"))); if (totalHealth) { - actualBit.add(new StyledText("/", "separator2")); - actualBit.add(new StyledText( (formatHealth ? TextUtils.format(data.getMaxHealth()) : data.getMaxHealth()) +"\n","maxHealth")); + actualBit.addChild(new TextSpan(getStyle("separator2"), "/")); + actualBit.addChild(new TextSpan(getStyle("maxHealth"), (formatHealth ? TextUtils.format(data.getMaxHealth()) : data.getMaxHealth()) +"\n")); } } @Override - public java.util.List<StyledText> getText() { - List<StyledText> actualBit = new ArrayList<StyledText>(); + public TextSpan getText() { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); List<HealthData> healths = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor().getHealths(); for (HealthData heal : healths) { addLine(heal, actualBit); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureCurrentPhase.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureCurrentPhase.java index bfc32c74..ef97deb1 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureCurrentPhase.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureCurrentPhase.java @@ -22,53 +22,45 @@ package kr.syeyoung.dungeonsguide.mod.features.impl.boss; import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.config.types.AColor; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; public class FeatureCurrentPhase extends TextHUDFeature { public FeatureCurrentPhase() { super("Dungeon.Bossfight", "Display Current Phase", "Displays the current phase of bossfight", "bossfight.phasedisplay"); this.setEnabled(true); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("phase", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("title", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("phase", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); } SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - private static final List<StyledText> dummyText= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("Current Phase","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("fight-2","phase")); - } @Override public boolean isHUDViewable() { return skyblockStatus.isOnDungeon() && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() != null; } @Override - public List<String> getUsedTextStyle() { - return Arrays.asList("title", "separator", "phase"); - } - - @Override - public List<StyledText> getDummyText() { - return dummyText; + public TextSpan getDummyText() { + TextSpan textSpan = new TextSpan(new NullTextStyle(), ""); + textSpan.addChild(new TextSpan(getStyle("title"), "Current Phase")); + textSpan.addChild(new TextSpan(getStyle("separator"), ": ")); + textSpan.addChild(new TextSpan(getStyle("phase"), "fight-2")); + return textSpan; } @Override - public List<StyledText> getText() { + public TextSpan getText() { String currentPhase = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor().getCurrentPhase(); - List<StyledText> actualBit = new ArrayList<StyledText>(); - actualBit.add(new StyledText("Current Phase","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(currentPhase,"phase")); + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("title"), "Current Phase")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("phase"), currentPhase)); return actualBit; } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureTerracotaTimer.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureTerracotaTimer.java index 61ca037c..a93c62c5 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureTerracotaTimer.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureTerracotaTimer.java @@ -23,33 +23,26 @@ import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.config.types.AColor; import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightProcessorSadan; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; import net.minecraft.entity.boss.BossStatus; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - public class FeatureTerracotaTimer extends TextHUDFeature { public FeatureTerracotaTimer() { super("Dungeon.Bossfight.Floor 6", "Display Terracotta phase timer", "Displays Terracotta phase timer", "bossfight.terracota"); this.setEnabled(true); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("time", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("title", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("time", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); } SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - private static final List<StyledText> dummyText= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("Terracottas","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("1m 99s","time")); - } @Override public boolean isHUDViewable() { return skyblockStatus.isOnDungeon() && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() instanceof BossfightProcessorSadan && @@ -57,21 +50,20 @@ public class FeatureTerracotaTimer extends TextHUDFeature { } @Override - public List<String> getUsedTextStyle() { - return Arrays.asList("title", "separator", "number", "unit"); - } - - @Override - public List<StyledText> getDummyText() { - return dummyText; + public TextSpan getDummyText() { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("title"), "Terracottas")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("time"), "1m 99s")); + return actualBit; } @Override - public List<StyledText> getText() { - List<StyledText> actualBit = new ArrayList<StyledText>(); - actualBit.add(new StyledText("Terracottas","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(TextUtils.formatTime((long) (BossStatus.healthScale * 1000 * 60 * 1.5)),"time")); + public TextSpan getText() { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("title"), "Terracottas")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("time"), TextUtils.formatTime((long) (BossStatus.healthScale * 1000 * 60 * 1.5)))); return actualBit; } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornBearPercentage.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornBearPercentage.java index 0c712337..8e52ee32 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornBearPercentage.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornBearPercentage.java @@ -23,56 +23,47 @@ import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.config.types.AColor; import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightProcessorThorn; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; public class FeatureThornBearPercentage extends TextHUDFeature { public FeatureThornBearPercentage() { super("Dungeon.Bossfight.Floor 4", "Display Spirit Bear Summon Percentage", "Displays spirit bear summon percentage in hud", "bossfight.spiritbear"); this.setEnabled(true); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("unit", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("title", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("number", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("unit", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); } SkyblockStatus skyblockStatus = DungeonsGuide.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() && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() instanceof BossfightProcessorThorn; } - - @Override - public java.util.List<String> getUsedTextStyle() { - return Arrays.asList("title", "separator", "number", "unit"); - } - @Override - public java.util.List<StyledText> getDummyText() { + public TextSpan getDummyText() { + TextSpan dummyText = new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("title"), "Spirit Bear")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("number"), "50")); + dummyText.addChild(new TextSpan(getStyle("unit"), "%")); return dummyText; } @Override - public java.util.List<StyledText> getText() { + public TextSpan getText() { int percentage = (int) (((BossfightProcessorThorn) DungeonsGuide.getDungeonsGuide().getDungeonFacade().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")); + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("title"), "Spirit Bear")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("number"), percentage+"")); + actualBit.addChild(new TextSpan(getStyle("unit"), "%")); return actualBit; } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornSpiritBowTimer.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornSpiritBowTimer.java index 11ea4247..212f1019 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornSpiritBowTimer.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornSpiritBowTimer.java @@ -25,53 +25,46 @@ import kr.syeyoung.dungeonsguide.mod.config.types.AColor; import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightProcessorThorn; import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; import kr.syeyoung.dungeonsguide.mod.events.impl.TitleEvent; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; import net.minecraftforge.client.event.ClientChatReceivedEvent; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - public class FeatureThornSpiritBowTimer extends TextHUDFeature { public FeatureThornSpiritBowTimer() { super("Dungeon.Bossfight.Floor 4", "Display Spirit bow timer", "Displays how long until spirit bow gets destroyed", "bossfight.spiritbowdisplay"); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("time", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("title", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("time", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); } SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - private static final List<StyledText> dummyText= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("Spirit Bow Destruction","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("1s","time")); - } @Override public boolean isHUDViewable() { return skyblockStatus.isOnDungeon() && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() instanceof BossfightProcessorThorn && time > System.currentTimeMillis(); } - @Override - public List<String> getUsedTextStyle() { - return Arrays.asList("title", "separator", "time"); - } @Override - public List<StyledText> getDummyText() { + public TextSpan getDummyText() { + TextSpan dummyText = new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("title"), "Spirit Bow Destruction")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("time"), "1s")); return dummyText; } @Override - public List<StyledText> getText() { - List<StyledText> actualBit = new ArrayList<StyledText>(); - actualBit.add(new StyledText("Spirit Bow Destruction","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(TextUtils.formatTime(time - System.currentTimeMillis()),"time")); + public TextSpan getText() { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("title"), "Spirit Bow Destruction")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("time"), TextUtils.formatTime(time - System.currentTimeMillis()))); return actualBit; } private long time = 0; diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyInviteViewer.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyInviteViewer.java index 5ea37c96..a0d796e9 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyInviteViewer.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyInviteViewer.java @@ -19,7 +19,6 @@ package kr.syeyoung.dungeonsguide.mod.features.impl.discord.inviteViewer; -import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.config.types.TCInteger; import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; @@ -32,9 +31,6 @@ import kr.syeyoung.dungeonsguide.mod.overlay.OverlayType; import kr.syeyoung.dungeonsguide.mod.overlay.OverlayWidget; import kr.syeyoung.dungeonsguide.mod.overlay.WholeScreenPositioner; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - public class PartyInviteViewer extends AbstractGuiFeature { private WidgetPartyInviteViewer partyInviteViewer; private OverlayWidget widget; diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonCurrentRoomSecrets.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonCurrentRoomSecrets.java index 5b408f5f..a54a8861 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonCurrentRoomSecrets.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonCurrentRoomSecrets.java @@ -23,51 +23,41 @@ import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.config.types.AColor; import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import net.minecraftforge.client.event.ClientChatReceivedEvent; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - public class FeatureDungeonCurrentRoomSecrets extends TextHUDFeature { public FeatureDungeonCurrentRoomSecrets() { super("Dungeon.HUDs", "Display # Secrets in current room", "Display what your actionbar says", "dungeon.stats.secretsroom"); this.setEnabled(false); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("currentSecrets", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator2", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("totalSecrets", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("title", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("currentSecrets", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("separator2", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("totalSecrets", DefaultingDelegatingTextStyle.ofDefault().setTextShader( new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); } SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - private static final List<StyledText> dummyText= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("Secrets In Room","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("5","currentSecrets")); - dummyText.add(new StyledText("/","separator2")); - dummyText.add(new StyledText("8","totalSecrets")); - } - @Override public boolean isHUDViewable() { return skyblockStatus.isOnDungeon(); } @Override - public List<String> getUsedTextStyle() { - return Arrays.asList("title", "separator", "currentSecrets", "separator2", "totalSecrets"); - } - - @Override - public List<StyledText> getDummyText() { - return dummyText; + public TextSpan getDummyText() { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("title"), "Secrets In Room")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("currentSecrets"), "5")); + actualBit.addChild(new TextSpan(getStyle("separator2"), "/")); + actualBit.addChild(new TextSpan(getStyle("totalSecrets"), "8")); + return actualBit; } private int latestCurrSecrets = 0; @@ -75,14 +65,14 @@ public class FeatureDungeonCurrentRoomSecrets extends TextHUDFeature { @Override - public List<StyledText> getText() { - if (DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() != null) return new ArrayList<StyledText>(); - List<StyledText> actualBit = new ArrayList<StyledText>(); - actualBit.add(new StyledText("Secrets In Room","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(latestCurrSecrets +"","currentSecrets")); - actualBit.add(new StyledText("/","separator2")); - actualBit.add(new StyledText(latestTotalSecrets +"","totalSecrets")); + public TextSpan getText() { + if (DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() != null) return new TextSpan(new NullTextStyle(), ""); + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("title"), "Secrets In Room")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("currentSecrets"), latestCurrSecrets +"")); + actualBit.addChild(new TextSpan(getStyle("separator2"), "/")); + actualBit.addChild(new TextSpan(getStyle("totalSecrets"), latestTotalSecrets +"")); return actualBit; } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonDeaths.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonDeaths.java index 3b961cef..d45ad441 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonDeaths.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonDeaths.java @@ -27,9 +27,12 @@ import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.mod.dungeon.events.impl.DungeonDeathEvent; import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; import kr.syeyoung.dungeonsguide.mod.events.impl.DungeonLeftEvent; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.parallelUniverse.tab.TabList; import kr.syeyoung.dungeonsguide.mod.parallelUniverse.tab.TabListEntry; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; @@ -38,7 +41,8 @@ import net.minecraft.client.Minecraft; import net.minecraft.util.ChatComponentText; import net.minecraftforge.client.event.ClientChatReceivedEvent; -import java.util.*; +import java.util.HashMap; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -46,11 +50,11 @@ public class FeatureDungeonDeaths extends TextHUDFeature { public FeatureDungeonDeaths() { super("Dungeon.HUDs", "Display Deaths", "Display names of player and death count in dungeon run", "dungeon.stats.deaths"); this.setEnabled(false); - getStyles().add(new TextStyle("username", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("total", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("deaths", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("totalDeaths", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("username", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("total", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("deaths", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("totalDeaths", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); } SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); @@ -61,58 +65,51 @@ public class FeatureDungeonDeaths extends TextHUDFeature { return context != null; } - @Override - public List<String> getUsedTextStyle() { - return Arrays.asList("username", "separator", "deaths", "total", "totalDeaths"); - } @Getter private final Map<String, Integer> deaths = new HashMap<>(); @Override - public List<StyledText> getText() { + public TextSpan getText() { - List<StyledText> text= new ArrayList<StyledText>(); + TextSpan text= new TextSpan(new NullTextStyle(), ""); Map<String, Integer> deaths = getDeaths(); int i = 0; int deathsCnt = 0; for (Map.Entry<String, Integer> death:deaths.entrySet()) { - text.add(new StyledText(death.getKey(),"username")); - text.add(new StyledText(": ","separator")); - text.add(new StyledText(death.getValue()+"\n","deaths")); + text.addChild(new TextSpan(getStyle("username"), death.getKey())); + text.addChild(new TextSpan(getStyle("separator"), ": ")); + text.addChild(new TextSpan(getStyle("deaths"), death.getValue()+"\n")); deathsCnt += death.getValue(); } - text.add(new StyledText("Total Deaths","total")); - text.add(new StyledText(": ","separator")); - text.add(new StyledText(getTotalDeaths()+"","totalDeaths")); + text.addChild(new TextSpan(getStyle("total"), "Total Deaths")); + text.addChild(new TextSpan(getStyle("separator"), ": ")); + text.addChild(new TextSpan(getStyle("totalDeaths"), getTotalDeaths()+"")); 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("rioho","username")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("-999999\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() { + public TextSpan getDummyText() { + TextSpan dummyText= new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("username"), "syeyoung")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("deaths"), "-130\n")); + dummyText.addChild(new TextSpan(getStyle("username"), "rioho")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("deaths"), "-999999\n")); + dummyText.addChild(new TextSpan(getStyle("username"), "dungeonsguide")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("deaths"), "-42\n")); + dummyText.addChild(new TextSpan(getStyle("username"), "penguinman")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("deaths"), "0\n")); + dummyText.addChild(new TextSpan(getStyle("username"), "probablysalt")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("deaths"), "0\n")); + dummyText.addChild(new TextSpan(getStyle("total"), "Total Deaths")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("totalDeaths"), "0")); return dummyText; } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonMilestone.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonMilestone.java index 0db654c4..2c4b0562 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonMilestone.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonMilestone.java @@ -27,9 +27,11 @@ import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; import kr.syeyoung.dungeonsguide.mod.events.impl.DungeonLeftEvent; import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.parallelUniverse.tab.TabList; import kr.syeyoung.dungeonsguide.mod.parallelUniverse.tab.TabListEntry; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; @@ -38,7 +40,6 @@ import net.minecraft.util.ChatComponentText; import net.minecraftforge.client.event.ClientChatReceivedEvent; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.regex.Pattern; @@ -46,19 +47,13 @@ public class FeatureDungeonMilestone extends TextHUDFeature { public FeatureDungeonMilestone() { super("Dungeon.HUDs", "Display Current Class Milestone", "Display current class milestone of yourself", "dungeon.stats.milestone"); this.setEnabled(false); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("title", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("number", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); } SkyblockStatus skyblockStatus = DungeonsGuide.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 boolean isHUDViewable() { @@ -66,25 +61,24 @@ public class FeatureDungeonMilestone extends TextHUDFeature { } @Override - public List<String> getUsedTextStyle() { - return Arrays.asList("title", "separator", "number"); - } - - @Override - public List<StyledText> getDummyText() { + public TextSpan getDummyText() { + TextSpan dummyText = new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("title"), "Milestone")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("number"), "9")); return dummyText; } @Override - public List<StyledText> getText() { - List<StyledText> actualBit = new ArrayList<StyledText>(); - actualBit.add(new StyledText("Milestone","title")); - actualBit.add(new StyledText(": ","separator")); + public TextSpan getText() { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("title"), "Milestone")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); for (TabListEntry tabListEntry : TabList.INSTANCE.getTabListEntries()) { String name = tabListEntry.getEffectiveName(); if (name.startsWith("§r Milestone: §r")) { String milestone = TextUtils.stripColor(name).substring(13); - actualBit.add(new StyledText(milestone+"","number")); + actualBit.addChild(new TextSpan(getStyle("number"), milestone+"")); break; } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRealTime.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRealTime.java index a3c6952a..cb97b9b0 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRealTime.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRealTime.java @@ -23,23 +23,22 @@ import kr.syeyoung.dungeonsguide.mod.config.types.AColor; import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; import kr.syeyoung.dungeonsguide.mod.events.impl.DungeonLeftEvent; import kr.syeyoung.dungeonsguide.mod.events.impl.DungeonStartedEvent; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - public class FeatureDungeonRealTime extends TextHUDFeature { public FeatureDungeonRealTime() { super("Dungeon.HUDs", "Display Real Time-Dungeon Time", "Display how much real time has passed since dungeon run started", "dungeon.stats.realtime"); this.setEnabled(false); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("discriminator", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("title", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("discriminator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0xAA,0xAA,0xAA,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("number", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); } private long started = -1; @@ -48,36 +47,30 @@ public class FeatureDungeonRealTime extends TextHUDFeature { return System.currentTimeMillis() - started; } - private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("Time ","title")); - dummyText.add(new StyledText("(Real)","discriminator")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("-42h","number")); - } @Override public boolean isHUDViewable() { return started != -1; } - @Override - public java.util.List<String> getUsedTextStyle() { - return Arrays.asList("title", "discriminator", "separator", "number"); - } @Override - public java.util.List<StyledText> getDummyText() { + public TextSpan getDummyText() { + TextSpan dummyText = new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("title"), "Time ")); + dummyText.addChild(new TextSpan(getStyle("discriminator"), "(Real)")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("number"), "-42h")); return dummyText; } @Override - public java.util.List<StyledText> getText() { - List<StyledText> actualBit = new ArrayList<StyledText>(); - actualBit.add(new StyledText("Time","title")); - actualBit.add(new StyledText("(Real)","discriminator")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(TextUtils.formatTime(getTimeElapsed()),"number")); + public TextSpan getText() { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("title"), "Time")); + actualBit.addChild(new TextSpan(getStyle("discriminator"), "(Real)")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("number"), TextUtils.formatTime(getTimeElapsed()))); return actualBit; } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRoomName.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRoomName.java index ed006124..9916ba8f 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRoomName.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRoomName.java @@ -24,22 +24,22 @@ import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.config.types.AColor; import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import java.awt.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; public class FeatureDungeonRoomName extends TextHUDFeature { public FeatureDungeonRoomName() { super("Dungeon.HUDs", "Display name of the room you are in", "Display name of the room you are in", "dungeon.roomname"); - getStyles().add(new TextStyle("in", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("roomname", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("in", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("roomname", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); } SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); @@ -54,39 +54,32 @@ public class FeatureDungeonRoomName extends TextHUDFeature { return totalSecrets; } - private static final List<StyledText> dummyText= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("You're in ","in")); - dummyText.add(new StyledText("puzzle-tictactoe","roomname")); - } - @Override public boolean isHUDViewable() { return skyblockStatus.isOnDungeon() && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getScaffoldParser() != null; } - @Override - public List<String> getUsedTextStyle() { - return Arrays.asList("roomname", "in"); - } @Override - public List<StyledText> getDummyText() { + public TextSpan getDummyText() { + TextSpan dummyText = new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("in"), "You're in ")); + dummyText.addChild(new TextSpan(getStyle("roomname"), "puzzle-tictactoe")); return dummyText; } @Override - public List<StyledText> getText() { + public TextSpan getText() { EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; Point roomPt = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getScaffoldParser().getDungeonMapLayout().worldPointToRoomPoint(player.getPosition()); DungeonRoom dungeonRoom = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getScaffoldParser().getRoomMap().get(roomPt); - List<StyledText> actualBit = new ArrayList<StyledText>(); - actualBit.add(new StyledText("You're in ","in")); + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("in"), "You're in ")); if (dungeonRoom == null) { - actualBit.add(new StyledText("Unknown","roomname")); + actualBit.addChild(new TextSpan(getStyle("roomname"), "Unknown")); } else { - actualBit.add(new StyledText(dungeonRoom.getDungeonRoomInfo().getName(),"roomname")); + actualBit.addChild(new TextSpan(getStyle("roomname"), dungeonRoom.getDungeonRoomInfo().getName())); } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSBTime.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSBTime.java index 1a60e1a4..aa9efed8 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSBTime.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSBTime.java @@ -21,9 +21,12 @@ package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.config.types.AColor; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; import net.minecraft.client.Minecraft; import net.minecraft.scoreboard.Score; @@ -31,10 +34,7 @@ import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.scoreboard.Scoreboard; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; -import java.util.List; public class FeatureDungeonSBTime extends TextHUDFeature { @@ -43,10 +43,10 @@ public class FeatureDungeonSBTime extends TextHUDFeature { public FeatureDungeonSBTime() { super("Dungeon.HUDs", "Display Ingame Dungeon Time", "Display how much time skyblock thinks has passed since dungeon run started", "dungeon.stats.igtime"); this.setEnabled(false); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("discriminator", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("title", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("discriminator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0xAA,0xAA,0xAA,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("number", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); } public int getTimeElapsed() { @@ -72,35 +72,29 @@ public class FeatureDungeonSBTime extends TextHUDFeature { return time2 * 1000; } - private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("Time ","title")); - dummyText.add(new StyledText("(Ig)","discriminator")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("-42h","number")); - } @Override public boolean isHUDViewable() { return skyblockStatus.isOnDungeon(); } - @Override - public java.util.List<String> getUsedTextStyle() { - return Arrays.asList("title", "discriminator", "separator", "number"); - } @Override - public java.util.List<StyledText> getDummyText() { + public TextSpan getDummyText() { + TextSpan dummyText = new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("title"), "Time ")); + dummyText.addChild(new TextSpan(getStyle("discriminator"), "(Ig)")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("number"), "-42h")); return dummyText; } @Override - public java.util.List<StyledText> getText() { - List<StyledText> actualBit = new ArrayList<StyledText>(); - actualBit.add(new StyledText("Time","title")); - actualBit.add(new StyledText("(Ig)","discriminator")); - actualBit.add(new StyledText(": ","separator")); + public TextSpan getText() { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("title"), "Time")); + actualBit.addChild(new TextSpan(getStyle("discriminator"), "(Ig)")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard(); ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); Collection<Score> scores = scoreboard.getSortedScores(objective); @@ -112,7 +106,7 @@ public class FeatureDungeonSBTime extends TextHUDFeature { time = strippedLine.substring(14); } } - actualBit.add(new StyledText(time,"number")); + actualBit.addChild(new TextSpan(getStyle("number"), time)); return actualBit; } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonScore.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonScore.java index e5f6a581..133e2f44 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonScore.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonScore.java @@ -28,9 +28,11 @@ import kr.syeyoung.dungeonsguide.mod.dungeon.map.DungeonRoomScaffoldParser; import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.parallelUniverse.tab.TabList; import kr.syeyoung.dungeonsguide.mod.parallelUniverse.tab.TabListEntry; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; @@ -41,9 +43,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import net.minecraft.util.MathHelper; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -53,15 +52,15 @@ public class FeatureDungeonScore extends TextHUDFeature { this.setEnabled(false); addParameter("verbose", new FeatureParameter<Boolean>("verbose", "Show each score instead of sum", "Skill: 100 Explore: 58 S->S+(5 tombs) instead of Score: 305", true, TCBoolean.INSTANCE)); - getStyles().add(new TextStyle("scorename", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("score", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("brackets", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("etc", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("currentScore", new AColor(0xFF, 0xAA,0x00,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("arrow", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("nextScore", new AColor(0xFF, 0xAA,0x00,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("required", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("scorename", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("score", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("brackets", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("etc", DefaultingDelegatingTextStyle.ofDefault().setTextShader( new AColor(0xAA,0xAA,0xAA,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("currentScore", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0xFF, 0xAA,0x00,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("arrow", DefaultingDelegatingTextStyle.ofDefault().setTextShader( new AColor(0xAA,0xAA,0xAA,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("nextScore", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0xFF, 0xAA,0x00,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("required", DefaultingDelegatingTextStyle.ofDefault().setTextShader( new AColor(0xAA,0xAA,0xAA,255)).setBackgroundShader(new AColor(0, 0,0,0))); } SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); @@ -70,98 +69,89 @@ public class FeatureDungeonScore extends TextHUDFeature { return skyblockStatus.isOnDungeon(); } - private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>(); - private static final java.util.List<StyledText> dummyText2= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("Score","scorename")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("305 ","score")); - dummyText.add(new StyledText("(","brackets")); - dummyText.add(new StyledText("S+","currentScore")); - dummyText.add(new StyledText(")","brackets")); - - - - dummyText2.add(new StyledText("Skill","scorename")); - dummyText2.add(new StyledText(": ","separator")); - dummyText2.add(new StyledText("100 ","score")); - dummyText2.add(new StyledText("(","brackets")); - dummyText2.add(new StyledText("0 Deaths","etc")); - dummyText2.add(new StyledText(")\n","brackets")); - dummyText2.add(new StyledText("Explorer","scorename")); - dummyText2.add(new StyledText(": ","separator")); - dummyText2.add(new StyledText("99 ","score")); - dummyText2.add(new StyledText("(","brackets")); - dummyText2.add(new StyledText("Rooms O Secrets 39/40","etc")); - dummyText2.add(new StyledText(")\n","brackets")); - dummyText2.add(new StyledText("Time","scorename")); - dummyText2.add(new StyledText(": ","separator")); - dummyText2.add(new StyledText("100 ","score")); - dummyText2.add(new StyledText("Bonus","scorename")); - dummyText2.add(new StyledText(": ","separator")); - dummyText2.add(new StyledText("0 ","score")); - dummyText2.add(new StyledText("Total","scorename")); - dummyText2.add(new StyledText(": ","separator")); - dummyText2.add(new StyledText("299\n","score")); - dummyText2.add(new StyledText("S","currentScore")); - dummyText2.add(new StyledText("->","arrow")); - dummyText2.add(new StyledText("S+ ","nextScore")); - dummyText2.add(new StyledText("(","brackets")); - dummyText2.add(new StyledText("1 Required 1 crypt","required")); - dummyText2.add(new StyledText(")","brackets")); - - } - @Override - public java.util.List<String> getUsedTextStyle() { - return Arrays.asList("scorename", "separator", "score", "brackets", "etc", "currentScore", "arrow", "nextScore", "required"); + public TextSpan getDummyText() { + if (this.<Boolean>getParameter("verbose").getValue()) { + TextSpan dummyText2 = new TextSpan(new NullTextStyle(), ""); + dummyText2.addChild(new TextSpan(getStyle("scorename"), "Skill")); + dummyText2.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText2.addChild(new TextSpan(getStyle("score"), "100 ")); + dummyText2.addChild(new TextSpan(getStyle("brackets"), "(")); + dummyText2.addChild(new TextSpan(getStyle("etc"), "0 Deaths")); + dummyText2.addChild(new TextSpan(getStyle("brackets"), ")\n")); + dummyText2.addChild(new TextSpan(getStyle("scorename"), "Explorer")); + dummyText2.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText2.addChild(new TextSpan(getStyle("score"), "99 ")); + dummyText2.addChild(new TextSpan(getStyle("brackets"), "(")); + dummyText2.addChild(new TextSpan(getStyle("etc"), "Rooms O Secrets 39/40")); + dummyText2.addChild(new TextSpan(getStyle("brackets"), ")\n")); + dummyText2.addChild(new TextSpan(getStyle("scorename"), "Time")); + dummyText2.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText2.addChild(new TextSpan(getStyle("score"), "100 ")); + dummyText2.addChild(new TextSpan(getStyle("scorename"), "Bonus")); + dummyText2.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText2.addChild(new TextSpan(getStyle("score"), "0 ")); + dummyText2.addChild(new TextSpan(getStyle("scorename"), "Total")); + dummyText2.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText2.addChild(new TextSpan(getStyle("score"), "299\n")); + dummyText2.addChild(new TextSpan(getStyle("currentScore"), "S")); + dummyText2.addChild(new TextSpan(getStyle("arrow"), "->")); + dummyText2.addChild(new TextSpan(getStyle("nextScore"), "S+ ")); + dummyText2.addChild(new TextSpan(getStyle("brackets"), "(")); + dummyText2.addChild(new TextSpan(getStyle("required"), "1 Required 1 crypt")); + dummyText2.addChild(new TextSpan(getStyle("brackets"), ")")); + return dummyText2; + } else { + TextSpan dummyText = new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("scorename"), "Score")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("score"), "305 ")); + dummyText.addChild(new TextSpan(getStyle("brackets"), "(")); + dummyText.addChild(new TextSpan(getStyle("currentScore"), "S+")); + dummyText.addChild(new TextSpan(getStyle("brackets"), ")")); + return dummyText; + } } @Override - public java.util.List<StyledText> getDummyText() { - - if (this.<Boolean>getParameter("verbose").getValue()) {return dummyText2;} else return dummyText; - } - - @Override - public java.util.List<StyledText> getText() { - List<StyledText> actualBit = new ArrayList<StyledText>(); + public TextSpan getText() { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); ScoreCalculation score = calculateScore(); - if (score == null) return new ArrayList<StyledText>(); + if (score == null) return new TextSpan(new NullTextStyle(), ""); int sum = score.time + score.skill + score.explorer + score.bonus; if (this.<Boolean>getParameter("verbose").getValue()) { - actualBit.add(new StyledText("Skill", "scorename")); - actualBit.add(new StyledText(": ", "separator")); - actualBit.add(new StyledText(score.skill + " ", "score")); - actualBit.add(new StyledText("(", "brackets")); - actualBit.add(new StyledText(score.deaths + " Deaths", "etc")); - actualBit.add(new StyledText(")\n", "brackets")); - actualBit.add(new StyledText("Explorer", "scorename")); - actualBit.add(new StyledText(": ", "separator")); - actualBit.add(new StyledText(score.explorer + " ", "score")); - actualBit.add(new StyledText("(", "brackets")); - actualBit.add(new StyledText("Rooms " + (score.fullyCleared ? "O" : "X") + " Secrets " + score.secrets + "/" + score.effectiveTotalSecrets +" of "+score.getTotalSecrets() + (score.totalSecretsKnown ? "" : "?"), "etc")); - actualBit.add(new StyledText(")\n", "brackets")); - actualBit.add(new StyledText("Time", "scorename")); - actualBit.add(new StyledText(": ", "separator")); - actualBit.add(new StyledText(score.time + " ", "score")); - actualBit.add(new StyledText("Bonus", "scorename")); - actualBit.add(new StyledText(": ", "separator")); - actualBit.add(new StyledText(score.bonus + " ", "score")); - actualBit.add(new StyledText("Total", "scorename")); - actualBit.add(new StyledText(": ", "separator")); - actualBit.add(new StyledText(sum + "\n", "score")); - actualBit.addAll(buildRequirement(score)); + actualBit.addChild(new TextSpan(getStyle("scorename"), "Skill")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("score"), score.skill + " ")); + actualBit.addChild(new TextSpan(getStyle("brackets"), "(")); + actualBit.addChild(new TextSpan(getStyle("etc"), score.deaths + " Deaths")); + actualBit.addChild(new TextSpan(getStyle("brackets"), ")\n")); + actualBit.addChild(new TextSpan(getStyle("scorename"), "Explorer")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("score"), score.explorer + " ")); + actualBit.addChild(new TextSpan(getStyle("brackets"), "(")); + actualBit.addChild(new TextSpan(getStyle("etc"), "Rooms " + (score.fullyCleared ? "O" : "X") + " Secrets " + score.secrets + "/" + score.effectiveTotalSecrets +" of "+score.getTotalSecrets() + (score.totalSecretsKnown ? "" : "?"))); + actualBit.addChild(new TextSpan(getStyle("brackets"), ")\n")); + actualBit.addChild(new TextSpan(getStyle("scorename"), "Time")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("score"), score.time + " ")); + actualBit.addChild(new TextSpan(getStyle("scorename"), "Bonus")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("score"), score.bonus + " ")); + actualBit.addChild(new TextSpan(getStyle("scorename"), "Total")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("score"), sum + "\n")); + actualBit.addChild(buildRequirement(score)); } else { String letter = getLetter(sum); - actualBit.add(new StyledText("Score", "scorename")); - actualBit.add(new StyledText(": ", "separator")); - actualBit.add(new StyledText(sum + " ", "score")); - actualBit.add(new StyledText("(", "brackets")); - actualBit.add(new StyledText(letter, "currentScore")); - actualBit.add(new StyledText(")", "brackets")); + actualBit.addChild(new TextSpan(getStyle("scorename"), "Score")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("score"), sum + " ")); + actualBit.addChild(new TextSpan(getStyle("brackets"), "(")); + actualBit.addChild(new TextSpan(getStyle("currentScore"), letter)); + actualBit.addChild(new TextSpan(getStyle("brackets"), ")")); } return actualBit; @@ -325,13 +315,13 @@ public class FeatureDungeonScore extends TextHUDFeature { if (letter.equals("S")) return "S+"; else return null; } - public List<StyledText> buildRequirement(ScoreCalculation calculation) { - List<StyledText> actualBit = new ArrayList<StyledText>(); + public TextSpan buildRequirement(ScoreCalculation calculation) { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); int current = calculation.time + calculation.bonus + calculation.explorer + calculation.skill; String currentLetter = getLetter(current); String nextLetter= getNextLetter(currentLetter); if (nextLetter == null) { - actualBit.add(new StyledText("S+ Expected","nextScore")); + actualBit.addChild(new TextSpan(getStyle("nextScore"), "S+ Expected")); return actualBit; } int req = getScoreRequirement(nextLetter); @@ -344,12 +334,12 @@ public class FeatureDungeonScore extends TextHUDFeature { double secretPer = 40.0 / calculation.effectiveTotalSecrets; int secrets = (int) Math.ceil(reqPT / secretPer); - actualBit.add(new StyledText(currentLetter,"currentScore")); - actualBit.add(new StyledText("->","arrow")); - actualBit.add(new StyledText(nextLetter+" ","nextScore")); - actualBit.add(new StyledText("(","brackets")); - actualBit.add(new StyledText(reqPT2+" required "+tombsBreakable+" crypt "+secrets+" secrets","required")); - actualBit.add(new StyledText(")","brackets")); + actualBit.addChild(new TextSpan(getStyle("currentScore"), currentLetter)); + actualBit.addChild(new TextSpan(getStyle("arrow"), "->")); + actualBit.addChild(new TextSpan(getStyle("nextScore"), nextLetter+" ")); + actualBit.addChild(new TextSpan(getStyle("brackets"), "(")); + actualBit.addChild(new TextSpan(getStyle("required"), reqPT2+" required "+tombsBreakable+" crypt "+secrets+" secrets")); + actualBit.addChild(new TextSpan(getStyle("brackets"), ")")); return actualBit; } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSecrets.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSecrets.java index da9553a9..fd5a3e72 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSecrets.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSecrets.java @@ -24,27 +24,26 @@ import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.config.types.AColor; import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.parallelUniverse.tab.TabList; import kr.syeyoung.dungeonsguide.mod.parallelUniverse.tab.TabListEntry; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - public class FeatureDungeonSecrets extends TextHUDFeature { public FeatureDungeonSecrets() { super("Dungeon.HUDs", "Display Total # of Secrets", "Display how much total secrets have been found in a dungeon run.\n+ sign means DG does not know the correct number, but it's somewhere above that number.", "dungeon.stats.secrets"); this.setEnabled(false); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("currentSecrets", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator2", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("totalSecrets", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("unknown", new AColor(0xFF, 0xFF,0x55,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("title", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("currentSecrets", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("separator2", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("totalSecrets", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("unknown", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0xFF, 0xFF,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); } SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); @@ -107,15 +106,6 @@ public class FeatureDungeonSecrets extends TextHUDFeature { } - private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("Secrets","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("999","currentSecrets")); - dummyText.add(new StyledText("/","separator2")); - dummyText.add(new StyledText("2","totalSecrets")); - dummyText.add(new StyledText("+","unknown")); - } @Override public boolean isHUDViewable() { @@ -123,25 +113,27 @@ public class FeatureDungeonSecrets extends TextHUDFeature { } @Override - public java.util.List<String> getUsedTextStyle() { - return Arrays.asList("title", "separator", "currentSecrets", "separator2", "totalSecrets", "unknown"); - } - - @Override - public java.util.List<StyledText> getDummyText() { + public TextSpan getDummyText() { + TextSpan dummyText = new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("title"), "Secrets")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("currentSecrets"), "999")); + dummyText.addChild(new TextSpan(getStyle("separator2"), "/")); + dummyText.addChild(new TextSpan(getStyle("totalSecrets"), "2")); + dummyText.addChild(new TextSpan(getStyle("unknown"), "+")); return dummyText; } @Override - public java.util.List<StyledText> getText() { - List<StyledText> actualBit = new ArrayList<StyledText>(); - actualBit.add(new StyledText("Secrets","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(getSecretsFound() +"","currentSecrets")); - actualBit.add(new StyledText("/","separator2")); - - actualBit.add(new StyledText((int)Math.ceil(getTotalSecretsInt() * DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getSecretPercentage())+" of "+getTotalSecretsInt(),"totalSecrets")); - actualBit.add(new StyledText(getTotalSecrets().contains("+") ? "+" : "","unknown")); + public TextSpan getText() { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("title"), "Secrets")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("currentSecrets"), getSecretsFound() +"")); + actualBit.addChild(new TextSpan(getStyle("separator2"), "/")); + + actualBit.addChild(new TextSpan(getStyle("totalSecrets"), (int)Math.ceil(getTotalSecretsInt() * DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getSecretPercentage())+" of "+getTotalSecretsInt())); + actualBit.addChild(new TextSpan(getStyle("unknown"), getTotalSecrets().contains("+") ? "+" : "")); return actualBit; } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonTombs.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonTombs.java index f62d755f..788ac509 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonTombs.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonTombs.java @@ -22,24 +22,23 @@ package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.config.types.AColor; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.parallelUniverse.tab.TabList; import kr.syeyoung.dungeonsguide.mod.parallelUniverse.tab.TabListEntry; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - public class FeatureDungeonTombs extends TextHUDFeature { public FeatureDungeonTombs() { super("Dungeon.HUDs", "Display # of Crypts", "Display how much total crypts have been blown up in a dungeon run", "dungeon.stats.tombs"); this.setEnabled(false); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("title", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("number", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); } SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); @@ -54,12 +53,6 @@ public class FeatureDungeonTombs extends TextHUDFeature { return 0; } - private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("Crypts","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("42","number")); - } @Override public boolean isHUDViewable() { @@ -67,21 +60,20 @@ public class FeatureDungeonTombs extends TextHUDFeature { } @Override - public java.util.List<String> getUsedTextStyle() { - return Arrays.asList("title", "separator", "number"); - } - - @Override - public java.util.List<StyledText> getDummyText() { + public TextSpan getDummyText() { + TextSpan dummyText = new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("title"), "Crypts")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("number"), "42")); return dummyText; } @Override - public java.util.List<StyledText> getText() { - List<StyledText> actualBit = new ArrayList<StyledText>(); - actualBit.add(new StyledText("Crypts","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(getTombsFound()+"","number")); + public TextSpan getText() { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("title"), "Crypts")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("number"), getTombsFound()+"")); return actualBit; } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWarnLowHealth.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWarnLowHealth.java index c48b9046..e14ccb8b 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWarnLowHealth.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWarnLowHealth.java @@ -24,28 +24,26 @@ import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.config.types.AColor; import kr.syeyoung.dungeonsguide.mod.config.types.TCInteger; import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.parallelUniverse.scoreboard.Objective; import kr.syeyoung.dungeonsguide.mod.parallelUniverse.scoreboard.Score; import kr.syeyoung.dungeonsguide.mod.parallelUniverse.scoreboard.ScoreboardManager; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - public class FeatureWarnLowHealth extends TextHUDFeature { public FeatureWarnLowHealth() { super("Dungeon.Teammates", "Low Health Warning", "Warn if someone is on low health", "dungeon.lowhealthwarn"); addParameter("threshold", new FeatureParameter<Integer>("threshold", "Health Threshold", "Health Threshold for this feature to be toggled. default to 500", 500, TCInteger.INSTANCE)); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0xFF, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("unit", new AColor(0xFF, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("title", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("number", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0xFF, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("unit", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0xFF, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); setEnabled(false); } @@ -59,29 +57,21 @@ public class FeatureWarnLowHealth extends TextHUDFeature { } @Override - public List<String> getUsedTextStyle() { - return Arrays.asList("title", "separator", "number", "unit"); - } - - private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("DungeonsGuide","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("500","number")); - dummyText.add(new StyledText("hp","unit")); - } - - @Override - public List<StyledText> getDummyText() { + public TextSpan getDummyText() { + TextSpan dummyText = new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("title"), "DungeonsGuide")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("number"), "500")); + dummyText.addChild(new TextSpan(getStyle("unit"), "hp")); return dummyText; } @Override - public List<StyledText> getText() { + public TextSpan getText() { String lowestHealthName = ""; int lowestHealth = 999999999; Objective objective = ScoreboardManager.INSTANCE.getSidebarObjective(); - if (objective == null) return Collections.emptyList(); + if (objective == null) return new TextSpan(new NullTextStyle(), ""); for (Score sc : objective.getScores()) { String line = sc.getVisibleName(); String stripped = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(line)); @@ -94,13 +84,13 @@ public class FeatureWarnLowHealth extends TextHUDFeature { } } } - if (lowestHealth > this.<Integer>getParameter("threshold").getValue()) return new ArrayList<StyledText>(); + if (lowestHealth > this.<Integer>getParameter("threshold").getValue()) return new TextSpan(new NullTextStyle(), ""); - List<StyledText> actualBit = new ArrayList<StyledText>(); - actualBit.add(new StyledText(lowestHealthName,"title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(lowestHealth+"","number")); - actualBit.add(new StyledText("hp","unit")); + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("title"), lowestHealthName)); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("number"), lowestHealth+"")); + actualBit.addChild(new TextSpan(getStyle("unit"), "hp")); return actualBit; } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWatcherWarning.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWatcherWarning.java index 71241ff3..fe2c28d5 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWatcherWarning.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWatcherWarning.java @@ -26,21 +26,18 @@ import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; import kr.syeyoung.dungeonsguide.mod.events.impl.DungeonLeftEvent; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import net.minecraftforge.client.event.ClientChatReceivedEvent; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; import java.util.UUID; -public class FeatureWatcherWarning extends TextHUDFeature { +public class FeatureWatcherWarning extends TextHUDFeature { public FeatureWatcherWarning() { super("Dungeon.Blood Room","Watcher Spawn Alert", "Alert when watcher says 'That will be enough for now'", "dungen.watcherwarn"); - getStyles().add(new TextStyle("warning", new AColor(0xFF, 0x69,0x17,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("warning", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0xFF, 0x69,0x17,255)).setBackgroundShader(new AColor(0, 0,0,0))); setEnabled(false); } @@ -50,24 +47,15 @@ public class FeatureWatcherWarning extends TextHUDFeature { return warning > System.currentTimeMillis(); } - @Override - public List<String> getUsedTextStyle() { - return Collections.singletonList("warning"); - } - private final UUID lastRoomUID = UUID.randomUUID(); private long warning = 0; - private static final List<StyledText> text = new ArrayList<StyledText>(); - static { - text.add(new StyledText("Watcher finished spawning all mobs!", "warning")); - } - @Override - public List<StyledText> getText() { - return text; + public TextSpan getText() { + return new TextSpan(getStyle("warning"), "Watcher finished spawning all mobs!"); } + @DGEventHandler() public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { if (clientChatReceivedEvent.message.getFormattedText().equals("§r§c[BOSS] The Watcher§r§f: That will be enough for now.§r")) { diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureCooldownCounter.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureCooldownCounter.java index e879e45c..c7d6b21d 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureCooldownCounter.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureCooldownCounter.java @@ -22,36 +22,33 @@ package kr.syeyoung.dungeonsguide.mod.features.impl.etc; import kr.syeyoung.dungeonsguide.mod.config.types.AColor; import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; import kr.syeyoung.dungeonsguide.mod.events.impl.DungeonLeftEvent; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.inventory.ContainerChest; import net.minecraftforge.client.event.GuiOpenEvent; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - public class FeatureCooldownCounter extends TextHUDFeature { public FeatureCooldownCounter() { super("Dungeon", "Dungeon Cooldown Counter", "Counts 10 seconds after leaving dungeon", "qol.cooldown"); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("title", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("number", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); } private long leftDungeonTime = 0L; - private static final java.util.List<StyledText> dummyText= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("Cooldown","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("20s","number")); - } @Override - public List<StyledText> getDummyText() { + public TextSpan getDummyText() { + TextSpan dummyText = new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("title"), "Cooldown")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("number"), "20s")); return dummyText; } @@ -59,18 +56,13 @@ public class FeatureCooldownCounter extends TextHUDFeature { public boolean isHUDViewable() { return System.currentTimeMillis() - leftDungeonTime < 20000; } - - @Override - public java.util.List<String> getUsedTextStyle() { - return Arrays.asList("title", "separator", "number"); - } - + @Override - public List<StyledText> getText() { - List<StyledText> actualBit = new ArrayList<StyledText>(); - actualBit.add(new StyledText("Cooldown","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText((20 - (System.currentTimeMillis() - leftDungeonTime) / 1000)+"s","number")); + public TextSpan getText() { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); + actualBit.addChild(new TextSpan(getStyle("title"), "Cooldown")); + actualBit.addChild(new TextSpan(getStyle("separator"), ": ")); + actualBit.addChild(new TextSpan(getStyle("number"), (20 - (System.currentTimeMillis() - leftDungeonTime) / 1000)+"s")); return actualBit; } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/FeatureAbilityCooldown.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/FeatureAbilityCooldown.java index 5f06ccd6..af21fcb1 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/FeatureAbilityCooldown.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/FeatureAbilityCooldown.java @@ -26,9 +26,12 @@ import kr.syeyoung.dungeonsguide.mod.config.types.TCInteger; import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; import kr.syeyoung.dungeonsguide.mod.events.impl.DGTickEvent; import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; @@ -45,11 +48,11 @@ public class FeatureAbilityCooldown extends TextHUDFeature { public FeatureAbilityCooldown() { super("Misc", "View Ability Cooldowns", "A handy hud for viewing cooldown abilities", "etc.abilitycd2"); - getStyles().add(new TextStyle("abilityname", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("unit",new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("ready",new AColor(0xDF, 0x00,0x67,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("abilityname", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("number", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("unit",DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("ready",DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0xDF, 0x00,0x67,255)).setBackgroundShader(new AColor(0, 0,0,0))); addParameter("disable", new FeatureParameter<Boolean>("disable", "Disable outside of dungeon", "Disable the feature when out of dungeon", false, TCBoolean.INSTANCE)); addParameter("decimal", new FeatureParameter<Integer>("decimal", "Decimal places", "ex) 2 -> Cooldown: 3.21 3-> Cooldown: 3.210", 0, TCInteger.INSTANCE)); } @@ -59,31 +62,23 @@ public class FeatureAbilityCooldown extends TextHUDFeature { return SkyblockStatus.isOnSkyblock() && (!this.<Boolean>getParameter("disable").getValue() || (this.<Boolean>getParameter("disable").getValue() && SkyblockStatus.isOnSkyblock())); } - @Override - public List<String> getUsedTextStyle() { - return Arrays.asList("abilityname", "separator", "number", "unit", "ready"); - } - - private static final List<StyledText> dummy = new ArrayList<>(); - - static { - dummy.add(new StyledText("Random Ability", "abilityname")); - dummy.add(new StyledText(": ", "separator")); - dummy.add(new StyledText("10", "number")); - dummy.add(new StyledText("s\n", "unit")); - dummy.add(new StyledText("Random Ability2", "abilityname")); - dummy.add(new StyledText(": ", "separator")); - dummy.add(new StyledText("10", "number")); - dummy.add(new StyledText("m ", "unit")); - dummy.add(new StyledText("9", "number")); - dummy.add(new StyledText("s\n", "unit")); - dummy.add(new StyledText("Random Ability", "abilityname")); - dummy.add(new StyledText(": ", "separator")); - dummy.add(new StyledText("READY", "ready")); - } @Override - public List<StyledText> getDummyText() { + public TextSpan getDummyText() { + TextSpan dummy = new TextSpan(new NullTextStyle(), ""); + dummy.addChild(new TextSpan(getStyle("abilityname"), "Random Ability")); + dummy.addChild(new TextSpan(getStyle("separator"), ": ")); + dummy.addChild(new TextSpan(getStyle("number"), "10")); + dummy.addChild(new TextSpan(getStyle("unit"), "s\n")); + dummy.addChild(new TextSpan(getStyle("abilityname"), "Random Ability2")); + dummy.addChild(new TextSpan(getStyle("separator"), ": ")); + dummy.addChild(new TextSpan(getStyle("number"), "10")); + dummy.addChild(new TextSpan(getStyle("unit"), "m ")); + dummy.addChild(new TextSpan(getStyle("number"), "9")); + dummy.addChild(new TextSpan(getStyle("unit"), "s\n")); + dummy.addChild(new TextSpan(getStyle("abilityname"), "Random Ability")); + dummy.addChild(new TextSpan(getStyle("separator"), ": ")); + dummy.addChild(new TextSpan(getStyle("ready"), "READY")); return dummy; } @@ -250,24 +245,24 @@ public class FeatureAbilityCooldown extends TextHUDFeature { }); @Override - public List<StyledText> getText() { - List<StyledText> cooldowns = new ArrayList<>(); + public TextSpan getText() { + TextSpan cooldowns = new TextSpan(new NullTextStyle(), ""); for (UsedAbility usedAbility : usedAbilities) { long end = usedAbility.getCooldownEnd(); if (System.currentTimeMillis() >= end) { if (System.currentTimeMillis() <= end + 20000) { - cooldowns.add(new StyledText(usedAbility.getAbility().getName(), "abilityname")); - cooldowns.add(new StyledText(": ", "separator")); - cooldowns.add(new StyledText("READY\n", "ready")); + cooldowns.addChild(new TextSpan(getStyle("abilityname"), usedAbility.getAbility().getName())); + cooldowns.addChild(new TextSpan(getStyle("separator"), ": ")); + cooldowns.addChild(new TextSpan(getStyle("ready"), "READY\n")); } } else { - cooldowns.add(new StyledText(usedAbility.getAbility().getName(), "abilityname")); - cooldowns.add(new StyledText(": ", "separator")); + cooldowns.addChild(new TextSpan(getStyle("abilityname"), usedAbility.getAbility().getName())); + cooldowns.addChild(new TextSpan(getStyle("separator"), ": ")); long millies = end-System.currentTimeMillis(); double decimalPlaces = (double ) Math.pow(10, 3- this.<Integer>getParameter("decimal").getValue()); if (decimalPlaces == 0) { - cooldowns.add(new StyledText( this.<Integer>getParameter("decimal").getValue()+" decimal places? You'd be joking\n", "unit")); + cooldowns.addChild(new TextSpan(getStyle("unit"), this.<Integer>getParameter("decimal").getValue()+" decimal places? You'd be joking\n")); continue; } millies = (long) (((millies-1) / decimalPlaces + 1) * decimalPlaces); @@ -277,18 +272,18 @@ public class FeatureAbilityCooldown extends TextHUDFeature { String secondStr = String.format("%."+(this.<Integer>getParameter("decimal").getValue())+"f", seconds); if (hr > 0) { - cooldowns.add(new StyledText(String.valueOf(hr), "number")); - cooldowns.add(new StyledText("h ", "unit")); + cooldowns.addChild(new TextSpan(getStyle("number"), String.valueOf(hr))); + cooldowns.addChild(new TextSpan(getStyle("unit"), "h ")); } if (hr > 0 || min > 0) { - cooldowns.add(new StyledText(String.valueOf(min), "number")); - cooldowns.add(new StyledText("m ", "unit")); + cooldowns.addChild(new TextSpan(getStyle("number"), String.valueOf(min))); + cooldowns.addChild(new TextSpan(getStyle("unit"), "m ")); } if (hr > 0 || min > 0 || seconds > 0) { - cooldowns.add(new StyledText(secondStr, "number")); - cooldowns.add(new StyledText("s ", "unit")); + cooldowns.addChild(new TextSpan(getStyle("number"), secondStr)); + cooldowns.addChild(new TextSpan(getStyle("unit"), "s ")); } - cooldowns.add(new StyledText("\n", "unit")); + cooldowns.addChild(new TextSpan(getStyle("unit"), "\n")); } } return cooldowns; diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyList.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyList.java index 229bcfaf..3117b60f 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyList.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyList.java @@ -20,23 +20,22 @@ package kr.syeyoung.dungeonsguide.mod.features.impl.party; import kr.syeyoung.dungeonsguide.mod.config.types.AColor; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.party.PartyContext; import kr.syeyoung.dungeonsguide.mod.party.PartyManager; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - public class FeaturePartyList extends TextHUDFeature { public FeaturePartyList() { super("Party","Party List", "Party List as GUI", "party.list"); - getStyles().add(new TextStyle("name", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("player", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("allinvite", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("name", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("player", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("allinvite", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0xAA,0xAA,0xAA,255)).setBackgroundShader(new AColor(0, 0,0,0))); setEnabled(false); } @@ -44,50 +43,43 @@ public class FeaturePartyList extends TextHUDFeature { public boolean isHUDViewable() { return PartyManager.INSTANCE.getPartyContext() != null; } + @Override - public java.util.List<String> getUsedTextStyle() { - return Arrays.asList("name" ,"separator", "player", "allinvite"); - } - - private static final List<StyledText> dummyText = new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("Leader","name")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("syeyoung","player")); - dummyText.add(new StyledText("\nModerator","name")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("rioho, RaidShadowLegends, Tricked","player")); - dummyText.add(new StyledText("\nMember","name")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("Everyone","player")); - dummyText.add(new StyledText("\nAll invite Off","allinvite")); - } - - @Override - public List<StyledText> getDummyText() { + public TextSpan getDummyText() { + TextSpan dummyText = new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("name"), "Leader")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("player"), "syeyoung")); + dummyText.addChild(new TextSpan(getStyle("name"), "\nModerator")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("player"), "rioho, RaidShadowLegends, Tricked")); + dummyText.addChild(new TextSpan(getStyle("name"), "\nMember")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("player"), "Everyone")); + dummyText.addChild(new TextSpan(getStyle("allinvite"), "\nAll invite Off")); return dummyText; } @Override - public List<StyledText> getText() { + public TextSpan getText() { PartyContext pc = PartyManager.INSTANCE.getPartyContext(); - List<StyledText> text= new ArrayList<>(); - text.add(new StyledText("Leader","name")); - text.add(new StyledText(": ","separator")); - text.add(new StyledText(pc.getPartyOwner()+"","player")); - text.add(new StyledText("\nModerator","name")); - text.add(new StyledText(": ","separator")); - text.add(new StyledText(pc.getPartyModerator() == null ? "????" : String.join(", ", pc.getPartyModerator()) + (pc.isModeratorComplete() ? "" : " ?"),"player")); - text.add(new StyledText("\nMember","name")); - text.add(new StyledText(": ","separator")); - text.add(new StyledText(pc.getPartyMember() == null ? "????" : String.join(", ", pc.getPartyMember()) + (pc.isMemberComplete() ? "" : " ?"),"player")); + TextSpan text = new TextSpan(new NullTextStyle(), ""); + text.addChild(new TextSpan(getStyle("name"), "Leader")); + text.addChild(new TextSpan(getStyle("separator"), ": ")); + text.addChild(new TextSpan(getStyle("player"), pc.getPartyOwner()+"")); + text.addChild(new TextSpan(getStyle("name"), "\nModerator")); + text.addChild(new TextSpan(getStyle("separator"), ": ")); + text.addChild(new TextSpan(getStyle("player"), pc.getPartyModerator() == null ? "????" : String.join(", ", pc.getPartyModerator()) + (pc.isModeratorComplete() ? "" : " ?"))); + text.addChild(new TextSpan(getStyle("name"), "\nMember")); + text.addChild(new TextSpan(getStyle("separator"), ": ")); + text.addChild(new TextSpan(getStyle("player"), pc.getPartyMember() == null ? "????" : String.join(", ", pc.getPartyMember()) + (pc.isMemberComplete() ? "" : " ?"))); if (pc.getAllInvite() != null && !pc.getAllInvite()) - text.add(new StyledText("\nAll invite Off","allinvite")); + text.addChild(new TextSpan(getStyle("allinvite"), "\nAll invite Off")); else if (pc.getAllInvite() != null) - text.add(new StyledText("\nAll invite On","allinvite")); + text.addChild(new TextSpan(getStyle("allinvite"), "\nAll invite On")); else - text.add(new StyledText("\nAll invite Unknown","allinvite")); + text.addChild(new TextSpan(getStyle("allinvite"), "\nAll invite Unknown")); return text; } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyReady.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyReady.java index f061188b..8fa350e6 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyReady.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyReady.java @@ -23,9 +23,12 @@ import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; import kr.syeyoung.dungeonsguide.mod.config.types.AColor; import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; import kr.syeyoung.dungeonsguide.mod.events.impl.DungeonStartedEvent; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.party.PartyContext; import kr.syeyoung.dungeonsguide.mod.party.PartyManager; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; @@ -36,11 +39,11 @@ import java.util.*; public class FeaturePartyReady extends TextHUDFeature { public FeaturePartyReady() { super("Party","Party Ready List", "Check if your party member have said r or not", "party.readylist"); - getStyles().add(new TextStyle("player", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("ready", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("notready", new AColor(0xFF, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("terminal", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("player", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("ready", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("notready", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0xFF, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("terminal", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); setEnabled(true); } @@ -49,37 +52,30 @@ public class FeaturePartyReady extends TextHUDFeature { return PartyManager.INSTANCE.getPartyContext() != null && PartyManager.INSTANCE.getPartyContext().isPartyExistHypixel() && "Dungeon Hub".equals(SkyblockStatus.locationName); } - @Override - public List<String> getUsedTextStyle() { - return Arrays.asList("separator", "player", "ready", "notready", "terminal"); - } - - private static final List<StyledText> dummyText = new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("syeyoung","player")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("Ready","ready")); - dummyText.add(new StyledText(" 4","terminal")); - dummyText.add(new StyledText("\nrioho","player")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("Ready","ready")); - dummyText.add(new StyledText(" 3","terminal")); - dummyText.add(new StyledText("\nRaidShadowLegends","player")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("Not Ready","notready")); - dummyText.add(new StyledText(" 2t","terminal")); - dummyText.add(new StyledText("\nTricked","player")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("Ready","ready")); - dummyText.add(new StyledText(" ss","terminal")); - dummyText.add(new StyledText("\nMr. Penguin","player")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("Not Ready","notready")); - dummyText.add(new StyledText(" 2b","terminal")); - } @Override - public List<StyledText> getDummyText() { + public TextSpan getDummyText() { + TextSpan dummyText = new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("player"), "syeyoung")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("ready"), "Ready")); + dummyText.addChild(new TextSpan(getStyle("terminal"), " 4")); + dummyText.addChild(new TextSpan(getStyle("player"), "\nrioho")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("ready"), "Ready")); + dummyText.addChild(new TextSpan(getStyle("terminal"), " 3")); + dummyText.addChild(new TextSpan(getStyle("player"), "\nRaidShadowLegends")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("notready"), "Not Ready")); + dummyText.addChild(new TextSpan(getStyle("terminal"), " 2t")); + dummyText.addChild(new TextSpan(getStyle("player"), "\nTricked")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("ready"), "Ready")); + dummyText.addChild(new TextSpan(getStyle("terminal"), " ss")); + dummyText.addChild(new TextSpan(getStyle("player"), "\nMr. Penguin")); + dummyText.addChild(new TextSpan(getStyle("separator"), ": ")); + dummyText.addChild(new TextSpan(getStyle("notready"), "Not Ready")); + dummyText.addChild(new TextSpan(getStyle("terminal"), " 2b")); return dummyText; } @@ -87,19 +83,19 @@ public class FeaturePartyReady extends TextHUDFeature { private Map<String, String> terminal = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); @Override - public List<StyledText> getText() { + public TextSpan getText() { PartyContext pc = PartyManager.INSTANCE.getPartyContext(); - List<StyledText> text= new ArrayList<>(); + TextSpan text = new TextSpan(new NullTextStyle(), ""); boolean first = true; for (String partyRawMember : pc.getPartyRawMembers()) { - text.add(new StyledText((first ? "":"\n") + partyRawMember, "player")); - text.add(new StyledText(": ","separator")); + text.addChild(new TextSpan(getStyle("player"), (first ? "":"\n") + partyRawMember)); + text.addChild(new TextSpan(getStyle("separator"), ": ")); if (ready.contains(partyRawMember)) - text.add(new StyledText("Ready","ready")); + text.addChild(new TextSpan(getStyle("ready"), "Ready")); else - text.add(new StyledText("Not Ready","notready")); + text.addChild(new TextSpan(getStyle("notready"), "Not Ready")); if (terminal.get(partyRawMember) != null) { - text.add(new StyledText(" "+ terminal.get(partyRawMember), "terminal")); + text.addChild(new TextSpan(getStyle("terminal"), " "+ terminal.get(partyRawMember))); } first =false; } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinder.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinder.java index b7ec2730..fe6410cc 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinder.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinder.java @@ -23,7 +23,6 @@ import kr.syeyoung.dungeonsguide.mod.config.guiconfig.configv3.CategoryPageWidge import kr.syeyoung.dungeonsguide.mod.config.guiconfig.configv3.MainConfigWidget; import kr.syeyoung.dungeonsguide.mod.discord.DiscordIntegrationManager; import kr.syeyoung.dungeonsguide.mod.events.impl.WindowUpdateEvent; -import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.mod.features.impl.discord.invteTooltip.MTooltipInvite; import kr.syeyoung.dungeonsguide.mod.gui.MPanel; import kr.syeyoung.dungeonsguide.mod.gui.elements.*; diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureActions.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureActions.java index 0622c683..a642c5c5 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureActions.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureActions.java @@ -27,30 +27,30 @@ import kr.syeyoung.dungeonsguide.mod.dungeon.actions.AbstractAction; import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; -import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultTextHUDFeatureStyleFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.NullTextStyle; import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import java.awt.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; public class FeatureActions extends TextHUDFeature { public FeatureActions() { super("Dungeon.Secrets", "Action Viewer", "View List of actions that needs to be taken", "secret.actionview"); - getStyles().add(new TextStyle("pathfinding", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("mechanic", new AColor(0x55, 0xFF,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("state", new AColor(0x55, 0xFF,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("current", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("dot", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("action", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("afterline", new AColor(0xAA, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("pathfinding", DefaultingDelegatingTextStyle.derive(() -> FeatureRegistry.DEFAULT_STYLE.getStyle(DefaultTextHUDFeatureStyleFeature.Styles.NAME))); + registerDefaultStyle("mechanic", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("separator", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("state", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("current", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("number", DefaultingDelegatingTextStyle.ofDefault().setTextShader( new AColor(0x00, 0xAA,0xAA,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("dot", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0x55,0x55,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("action", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x55, 0xFF,0xFF,255)).setBackgroundShader(new AColor(0, 0,0,0))); + registerDefaultStyle("afterline", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0xAA, 0xAA,0xAA,255)).setBackgroundShader(new AColor(0, 0,0,0))); } @@ -67,42 +67,35 @@ public class FeatureActions extends TextHUDFeature { return dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor; } - private static final List<StyledText> dummyText= new ArrayList<StyledText>(); - static { - dummyText.add(new StyledText("Pathfinding ","pathfinding")); - dummyText.add(new StyledText("Secret ","mechanic")); - dummyText.add(new StyledText("-> ","separator")); - dummyText.add(new StyledText("Found\n","state")); - dummyText.add(new StyledText("> ","current")); - dummyText.add(new StyledText("1","number")); - dummyText.add(new StyledText(". ","dot")); - dummyText.add(new StyledText("Move ","action")); - dummyText.add(new StyledText("OffsetPoint{x=1,y=42,z=1} \n","afterline")); - dummyText.add(new StyledText(" ","current")); - dummyText.add(new StyledText("2","number")); - dummyText.add(new StyledText(". ","dot")); - dummyText.add(new StyledText("Click ","action")); - dummyText.add(new StyledText("OffsetPoint{x=1,y=42,z=1} \n","afterline")); - dummyText.add(new StyledText(" ","current")); - dummyText.add(new StyledText("3","number")); - dummyText.add(new StyledText(". ","dot")); - dummyText.add(new StyledText("Profit ","action")); - } - - @Override - public List<String> getUsedTextStyle() { - return Arrays.asList("pathfinding","mechanic","separator","state","current", "number", "dot", "action", "afterline"); - } @Override - public List<StyledText> getDummyText() { + public TextSpan getDummyText() { + TextSpan dummyText = new TextSpan(new NullTextStyle(), ""); + dummyText.addChild(new TextSpan(getStyle("pathfinding"), "Pathfinding ")); + dummyText.addChild(new TextSpan(getStyle("mechanic"), "Secret ")); + dummyText.addChild(new TextSpan(getStyle("separator"), "-> ")); + dummyText.addChild(new TextSpan(getStyle("state"), "Found\n")); + dummyText.addChild(new TextSpan(getStyle("current"), "> ")); + dummyText.addChild(new TextSpan(getStyle("number"), "1")); + dummyText.addChild(new TextSpan(getStyle("dot"), ". ")); + dummyText.addChild(new TextSpan(getStyle("action"), "Move ")); + dummyText.addChild(new TextSpan(getStyle("afterline"), "OffsetPoint{x=1,y=42,z=1} \n")); + dummyText.addChild(new TextSpan(getStyle("current"), " ")); + dummyText.addChild(new TextSpan(getStyle("number"), "2")); + dummyText.addChild(new TextSpan(getStyle("dot"), ". ")); + dummyText.addChild(new TextSpan(getStyle("action"), "Click ")); + dummyText.addChild(new TextSpan(getStyle("afterline"), "OffsetPoint{x=1,y=42,z=1} \n")); + dummyText.addChild(new TextSpan(getStyle("current"), " ")); + dummyText.addChild(new TextSpan(getStyle("number"), "3")); + dummyText.addChild(new TextSpan(getStyle("dot"), ". ")); + dummyText.addChild(new TextSpan(getStyle("action"), "Profit ")); return dummyText; } @Override - public List<StyledText> getText() { - List<StyledText> actualBit = new ArrayList<StyledText>(); + public TextSpan getText() { + TextSpan actualBit = new TextSpan(new NullTextStyle(), ""); DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); @@ -111,27 +104,27 @@ public class FeatureActions extends TextHUDFeature { DungeonRoom dungeonRoom = context.getScaffoldParser().getRoomMap().get(roomPt); for (ActionRoute path : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getPath().values()) { - actualBit.add(new StyledText("Pathfinding ","pathfinding")); - actualBit.add(new StyledText(path.getMechanic()+" ","mechanic")); - actualBit.add(new StyledText("-> ","separator")); - actualBit.add(new StyledText(path.getState()+"\n","state")); + actualBit.addChild(new TextSpan(getStyle("pathfinding"), "Pathfinding ")); + actualBit.addChild(new TextSpan(getStyle("mechanic"), path.getMechanic()+" ")); + actualBit.addChild(new TextSpan(getStyle("separator"), "-> ")); + actualBit.addChild(new TextSpan(getStyle("state"), path.getState()+"\n")); for (int i = Math.max(0,path.getCurrent()-2); i < path.getActions().size(); i++) { - actualBit.add(new StyledText((i == path.getCurrent() ? ">" : " ") +" ","current")); - actualBit.add(new StyledText(i+"","number")); - actualBit.add(new StyledText(". ","dot")); + actualBit.addChild(new TextSpan(getStyle("current"), (i == path.getCurrent() ? ">" : " ") +" ")); + actualBit.addChild(new TextSpan(getStyle("number"), i+"")); + actualBit.addChild(new TextSpan(getStyle("dot"), ". ")); AbstractAction action = path.getActions().get(i); String[] str = action.toString().split("\n"); - actualBit.add(new StyledText(str[0] + " ","action")); - actualBit.add(new StyledText("(","afterline")); + actualBit.addChild(new TextSpan(getStyle("action"), str[0] + " ")); + actualBit.addChild(new TextSpan(getStyle("afterline"), "(")); for (int i1 = 1; i1 < str.length; i1++) { String base = str[i1].trim(); if (base.startsWith("-")) base = base.substring(1); base = base.trim(); - actualBit.add(new StyledText(base+" ","afterline")); + actualBit.addChild(new TextSpan(getStyle("afterline"), base+" ")); } - actualBit.add(new StyledText(")\n","afterline")); + actualBit.addChild(new TextSpan(getStyle("afterline"), ")\n")); } } return actualBit; diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureSoulRoomWarning.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureSoulRoomWarning.java index 1496fa92..545f8629 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureSoulRoomWarning.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureSoulRoomWarning.java @@ -32,8 +32,10 @@ import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; import kr.syeyoung.dungeonsguide.mod.events.impl.DGTickEvent; import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.mod.features.text.*; +import kr.syeyoung.dungeonsguide.mod.features.text.DefaultingDelegatingTextStyle; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedImportOnlyWidget; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On; @@ -51,7 +53,7 @@ public class FeatureSoulRoomWarning extends TextHUDFeature { public FeatureSoulRoomWarning() { super("Dungeon.HUDs","Secret Soul Alert", "Alert if there is an fairy soul in the room", "secret.fairysoulwarn"); - getStyles().add(new TextStyle("warning", new AColor(0xFF, 0x69,0x17,255), new AColor(0, 0,0,0), false)); + registerDefaultStyle("warning", DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0xFF, 0x69,0x17,255)).setBackgroundShader(new AColor(0, 0,0,0))); addParameter("roomuids", new FeatureParameter<>("roomuids", "Disabled room Names", "Disable for these rooms", new ArrayList<>(), TCStringList.INSTANCE) .setWidgetGenerator(RoomConfiguration::new)); @@ -63,22 +65,14 @@ public class FeatureSoulRoomWarning extends TextHUDFeature { return warning > System.currentTimeMillis(); } - @Override - public List<String> getUsedTextStyle() { - return Collections.singletonList("warning"); - } private UUID lastRoomUID = UUID.randomUUID(); private long warning = 0; - private static final List<StyledText> text = new ArrayList<StyledText>(); - static { - text.add(new StyledText("There is a fairy soul in this room!", "warning")); - } @Override - public List<StyledText> getText() { - return text; + public TextSpan getText() { + return new TextSpan(getStyle("warning"), "There is a fairy soul in this room!"); } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/DefaultTextHUDFeatureStyleFeature.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/DefaultTextHUDFeatureStyleFeature.java new file mode 100644 index 00000000..e01aa909 --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/DefaultTextHUDFeatureStyleFeature.java @@ -0,0 +1,70 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2023 cyoung06 (syeyoung) + * + * 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.mod.features.text; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.config.types.TCRTextStyleMap; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +public class DefaultTextHUDFeatureStyleFeature extends SimpleFeature { + public enum Styles { + NAME + } + + public DefaultTextHUDFeatureStyleFeature() { + super("Misc", "Quick HUD Style Settings", "Configure the default hud style", "misc.defaulthud"); + + registerDefaultStyle(Styles.NAME, DefaultingDelegatingTextStyle.ofDefault().setTextShader(new AColor(0x00, 0xAA,0xAA,255))); + + addParameter("newstyle", new FeatureParameter<>("newstyle", "TextStyle", "", styleMap, new TCRTextStyleMap(), this::updateStyle)); + } + + public DefaultingDelegatingTextStyle getStyle(Styles styles) { + return styleMap.get(styles.name()); + } + + + private Map<String, DefaultingDelegatingTextStyle> defaultStyleMap = new HashMap<>(); + private Map<String, DefaultingDelegatingTextStyle> styleMap = new HashMap<>(); + public void registerDefaultStyle(Styles styles, DefaultingDelegatingTextStyle style) { + defaultStyleMap.put(styles.name(), style); + } + public void updateStyle(Map<String, DefaultingDelegatingTextStyle> map) { + styleMap.clear(); + Set<String> wasIn = new HashSet<>(map.keySet()); + Set<String> needsToBeIn = new HashSet<>(defaultStyleMap.keySet()); + needsToBeIn.removeAll(wasIn); + for (Map.Entry<String, DefaultingDelegatingTextStyle> stringDefaultingDelegatingTextStyleEntry : map.entrySet()) { + if (!defaultStyleMap.containsKey(stringDefaultingDelegatingTextStyleEntry.getKey())) continue; + DefaultingDelegatingTextStyle newStyle = stringDefaultingDelegatingTextStyleEntry.getValue(); + newStyle.setParent(() -> defaultStyleMap.get(stringDefaultingDelegatingTextStyleEntry.getKey())); + styleMap.put(stringDefaultingDelegatingTextStyleEntry.getKey(), newStyle); + } + for (String s : needsToBeIn) { + styleMap.put(s, new DefaultingDelegatingTextStyle().setParent(() -> defaultStyleMap.get(s))); + map.put(s, styleMap.get(s)); + } + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/DefaultingDelegatingTextStyle.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/DefaultingDelegatingTextStyle.java index 3c6915be..c60bb4dd 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/DefaultingDelegatingTextStyle.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/DefaultingDelegatingTextStyle.java @@ -18,17 +18,19 @@ package kr.syeyoung.dungeonsguide.mod.features.text; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.fonts.DefaultFontRenderer; import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.fonts.FontRenderer; import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.shaders.Shader; -import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.shaders.SingleColorShader; import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.styles.ITextStyle; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; +import java.util.function.Supplier; + @Setter @Accessors(chain = true) -public class DefaultingDelegatingTextStyle implements ITextStyle { +public class DefaultingDelegatingTextStyle implements ITextStyle, Cloneable { public Double size; public Double topAscent; public Double bottomAscent; @@ -42,18 +44,24 @@ public class DefaultingDelegatingTextStyle implements ITextStyle { public Boolean outline; public Boolean shadow; - public Shader backgroundShader; - public Shader textShader; - public Shader strikeThroughShader; - public Shader underlineShader; - public Shader outlineShader; - public Shader shadowShader; + public AColor backgroundShader; + public AColor textShader; + public AColor strikeThroughShader; + public AColor underlineShader; + public AColor outlineShader; + public AColor shadowShader; @Getter @Setter - public DefaultingDelegatingTextStyle parent; + public Supplier<DefaultingDelegatingTextStyle> parent; public FontRenderer fontRenderer; + public static DefaultingDelegatingTextStyle derive(Supplier<DefaultingDelegatingTextStyle> parent) { + DefaultingDelegatingTextStyle defaultTextHUDFeatureStyleFeature = new DefaultingDelegatingTextStyle(); + defaultTextHUDFeatureStyleFeature.setParent(parent); + return defaultTextHUDFeatureStyleFeature; + } + public static DefaultingDelegatingTextStyle ofDefault() { DefaultingDelegatingTextStyle parentDelegatingTextStyle = new DefaultingDelegatingTextStyle(); parentDelegatingTextStyle.size = 8.0; @@ -66,94 +74,106 @@ public class DefaultingDelegatingTextStyle implements ITextStyle { parentDelegatingTextStyle.shadow = false; parentDelegatingTextStyle.outline = false; - parentDelegatingTextStyle.backgroundShader = new SingleColorShader(0x00FFFFFF); - parentDelegatingTextStyle.textShader = new SingleColorShader(0xFFFFFFFF); - parentDelegatingTextStyle.strikeThroughShader = new SingleColorShader(0xFF000000); - parentDelegatingTextStyle.underlineShader = new SingleColorShader(0xFF000000); - parentDelegatingTextStyle.outlineShader = new SingleColorShader(0xFF000000); - parentDelegatingTextStyle.shadowShader = new SingleColorShader(0xFF000000); + parentDelegatingTextStyle.backgroundShader = null; + parentDelegatingTextStyle.textShader = new AColor(0xFFFFFFFF, true); + parentDelegatingTextStyle.strikeThroughShader = new AColor(0xFF000000, true); + parentDelegatingTextStyle.underlineShader = new AColor(0xFF000000, true); + parentDelegatingTextStyle.outlineShader = new AColor(0xFF000000, true); + parentDelegatingTextStyle.shadowShader = new AColor(0xFF000000, true); parentDelegatingTextStyle.fontRenderer = DefaultFontRenderer.DEFAULT_RENDERER; return parentDelegatingTextStyle; } + + public DefaultingDelegatingTextStyle getParent() { + return parent.get(); + } @Override public Double getSize() { - return parent != null && size == null ? parent.getSize() : size; + return parent != null && size == null ? getParent().getSize() : size; } @Override public Double getTopAscent() { - return parent != null && topAscent == null ? parent.getTopAscent() : topAscent; + return parent != null && topAscent == null ? getParent().getTopAscent() : topAscent; } @Override public Double getBottomAscent() { - return parent != null && bottomAscent == null ? parent.getBottomAscent() : bottomAscent; + return parent != null && bottomAscent == null ? getParent().getBottomAscent() : bottomAscent; } @Override public Boolean isBold() { - return parent != null && bold == null ? parent.isBold() : bold; + return parent != null && bold == null ? getParent().isBold() : bold; } @Override public Boolean isItalics() { - return parent != null && italics == null ? parent.isItalics() : italics; + return parent != null && italics == null ? getParent().isItalics() : italics; } @Override public Boolean isOutline() { - return parent != null && outline == null ? parent.isOutline() : outline; + return parent != null && outline == null ? getParent().isOutline() : outline; } @Override public Boolean isShadow() { - return parent != null && shadow == null ? parent.isShadow() : shadow; + return parent != null && shadow == null ? getParent().isShadow() : shadow; } @Override public Boolean isStrikeThrough() { - return parent != null && strikeThrough == null ? parent.isStrikeThrough() : strikeThrough; + return parent != null && strikeThrough == null ? getParent().isStrikeThrough() : strikeThrough; } @Override public Boolean isUnderline() { - return parent != null && underline == null ? parent.isUnderline() : underline; + return parent != null && underline == null ? getParent().isUnderline() : underline; } @Override public FontRenderer getFontRenderer() { - return parent != null && fontRenderer == null ? parent.getFontRenderer() : fontRenderer; + return parent != null && fontRenderer == null ? getParent().getFontRenderer() : fontRenderer; } @Override public Shader getShadowShader() { - return parent != null && shadowShader == null ? parent.getShadowShader() : shadowShader; + return parent != null && shadowShader == null ? getParent().getShadowShader() : shadowShader.getShader(); } @Override public Shader getBackgroundShader() { - return parent != null && backgroundShader == null ? parent.getBackgroundShader() : backgroundShader; + return parent != null && backgroundShader == null ? getParent().getBackgroundShader() : backgroundShader.getShader(); } @Override public Shader getOutlineShader() { - return parent != null && outlineShader == null ? parent.getOutlineShader() : outlineShader; + return parent != null && outlineShader == null ? getParent().getOutlineShader() : outlineShader.getShader(); } @Override public Shader getStrikeThroughShader() { - return parent != null && strikeThroughShader == null ? parent.getStrikeThroughShader() : strikeThroughShader; + return parent != null && strikeThroughShader == null ? getParent().getStrikeThroughShader() : strikeThroughShader.getShader(); } @Override public Shader getTextShader() { - return parent != null && textShader == null ? parent.getTextShader() : textShader; + return parent != null && textShader == null ? getParent().getTextShader() : textShader.getShader(); } @Override public Shader getUnderlineShader() { - return parent != null && underlineShader == null ? parent.getUnderlineShader() : underlineShader; + return parent != null && underlineShader == null ? getParent().getUnderlineShader() : underlineShader.getShader(); + } + + public DefaultingDelegatingTextStyle clone() { + try { + return (DefaultingDelegatingTextStyle) super.clone(); + } catch (CloneNotSupportedException e) { + throw new RuntimeException(e); + } } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/NullTextStyle.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/NullTextStyle.java new file mode 100644 index 00000000..06869ecd --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/NullTextStyle.java @@ -0,0 +1,110 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2023 cyoung06 (syeyoung) + * + * 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.mod.features.text; + +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.fonts.DefaultFontRenderer; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.fonts.FontRenderer; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.shaders.Shader; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.shaders.SingleColorShader; +import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.styles.ITextStyle; +import lombok.Setter; +import lombok.experimental.Accessors; + +@Setter @Accessors(chain = true) +public class NullTextStyle implements ITextStyle, Cloneable { + @Override + public Double getSize() { + return 0.0; + } + + @Override + public Double getTopAscent() { + return 0.0; + } + + @Override + public Double getBottomAscent() { + return 0.0; + } + + @Override + public Boolean isBold() { + return false; + } + + @Override + public Boolean isItalics() { + return false; + } + + @Override + public Boolean isStrikeThrough() { + return false; + } + + @Override + public Boolean isUnderline() { + return false; + } + + @Override + public Boolean isOutline() { + return false; + } + + @Override + public Boolean isShadow() { + return false; + } + + @Override + public Shader getBackgroundShader() { + return null; + } + + @Override + public Shader getTextShader() { + return new SingleColorShader(0); + } + + @Override + public Shader getStrikeThroughShader() { + return null; + } + + @Override + public Shader getUnderlineShader() { + return null; + } + + @Override + public Shader getOutlineShader() { + return null; + } + + @Override + public Shader getShadowShader() { + return null; + } + + @Override + public FontRenderer getFontRenderer() { + return DefaultFontRenderer.DEFAULT_RENDERER; + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledText.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledText.java index d9f936fa..9d463175 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledText.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledText.java @@ -18,12 +18,15 @@ package kr.syeyoung.dungeonsguide.mod.features.text; -import lombok.AllArgsConstructor; import lombok.Data; @Data -@AllArgsConstructor public class StyledText { private String text; private String group; + + public StyledText(String group, String text) { + this.text = text; + this.group = group; + } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledTextSpan.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledTextSpan.java new file mode 100644 index 00000000..f38ac82f --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledTextSpan.java @@ -0,0 +1,32 @@ +/* + * 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.mod.features.text; + +import lombok.Data; + +@Data +public class StyledTextSpan { + private String text; + private String group; + + public StyledTextSpan(String group, String text) { + this.text = text; + this.group = group; + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java index 179a21f0..aacb770b 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java @@ -18,16 +18,15 @@ package kr.syeyoung.dungeonsguide.mod.features.text; -import kr.syeyoung.dungeonsguide.mod.config.guiconfig.configv3.ParameterItem; import kr.syeyoung.dungeonsguide.mod.config.guiconfig.location2.MarkerProvider; -import kr.syeyoung.dungeonsguide.mod.config.types.*; +import kr.syeyoung.dungeonsguide.mod.config.types.TCEnum; +import kr.syeyoung.dungeonsguide.mod.config.types.TCRTextStyleMap; import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; import kr.syeyoung.dungeonsguide.mod.events.impl.DGTickEvent; import kr.syeyoung.dungeonsguide.mod.features.AbstractHUDFeature; import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; import kr.syeyoung.dungeonsguide.mod.guiv2.DomElement; import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; -import kr.syeyoung.dungeonsguide.mod.guiv2.elements.CompatLayer; import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.BreakWord; import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.RichText; import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan; @@ -40,18 +39,15 @@ import kr.syeyoung.dungeonsguide.mod.overlay.OverlayWidget; import lombok.RequiredArgsConstructor; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; import java.util.*; -public abstract class TextHUDFeature extends AbstractHUDFeature implements StyledTextProvider { +public abstract class TextHUDFeature extends AbstractHUDFeature { protected TextHUDFeature(String category, String name, String description, String key) { super(category, name, description, key); - addParameter("textStylesNEW", new FeatureParameter<List<TextStyle>>("textStylesNEW", "", "", new ArrayList<TextStyle>(), TCTextStyleList.INSTANCE) - .setWidgetGenerator((param) -> new CompatLayer(new PanelTextParameterConfig(TextHUDFeature.this)))); - addParameter("alignment", new FeatureParameter<RichText.TextAlign>("alignment", "Alignment", "Alignment", RichText.TextAlign.LEFT, new TCEnum<>(RichText.TextAlign.values()), richText::setAlign)); - addParameter("scale", new FeatureParameter<Double>("scale", "Scale", "Scale", 1.0, TCDouble.INSTANCE) - .setWidgetGenerator((param) -> new ParameterItem(param, new TCDouble.DoubleEditWidget(param, 0.1, Double.POSITIVE_INFINITY)))); + + addParameter("alignment", new FeatureParameter<>("alignment", "Alignment", "Alignment", RichText.TextAlign.LEFT, new TCEnum<>(RichText.TextAlign.values()), richText::setAlign)); + addParameter("newstyle", new FeatureParameter<>("newstyle", "TextStyle", "", styleMap, new TCRTextStyleMap(), this::updateStyle)); } @Override @@ -68,27 +64,13 @@ public abstract class TextHUDFeature extends AbstractHUDFeature implements Style public OverlayWidget instantiateWidget() { return new OverlayWidget(richText, OverlayType.UNDER_CHAT, new GUIRectPositioner(this::getFeatureRect)); } - - private Map<String, ParentDelegatingTextStyle> builtTextStyles = new HashMap<>(); - @DGEventHandler public void onTick0(DGTickEvent dgTickEvent) { try { checkVisibility(); if (isHUDViewable()) { - List<StyledText> asd = getText(); - - ParentDelegatingTextStyle defaultStyle = ParentDelegatingTextStyle.ofDefault(); - defaultStyle.setSize((double) (this.<Double>getParameter("scale").getValue() * 8)); - - TextSpan span = new TextSpan(defaultStyle, ""); - - for (StyledText styledText : asd) { - TextStyle style = getStylesMap().get(styledText.getGroup()); - TextSpan textSpan = new TextSpan(style.getLinked(), styledText.getText()); - span.addChild(textSpan); - } - richText.setRootSpan(span); + TextSpan asd = getText(); + richText.setRootSpan(asd); } } catch (Exception e) { e.printStackTrace(); @@ -127,27 +109,14 @@ public abstract class TextHUDFeature extends AbstractHUDFeature implements Style @Override public List<Widget> build(DomElement buildContext) { - List<StyledText> asd = hudFeature.getDummyText(); + TextSpan textSpan = hudFeature.getDummyText(); RichText richText = new RichText(new TextSpan( ParentDelegatingTextStyle.ofDefault(), "" - ), BreakWord.WORD, false, RichText.TextAlign.LEFT); - richText.setAlign( - hudFeature.<RichText.TextAlign>getParameter("alignment").getValue() - ); - - ParentDelegatingTextStyle defaultStyle = ParentDelegatingTextStyle.ofDefault(); - defaultStyle.setSize((double) (hudFeature.<Double>getParameter("scale").getValue() * 8)); + ), BreakWord.WORD, false, hudFeature.<RichText.TextAlign>getParameter("alignment").getValue()); - TextSpan span = new TextSpan(defaultStyle, ""); - - for (StyledText styledText : asd) { - TextStyle style = hudFeature.getStylesMap().get(styledText.getGroup()); - TextSpan textSpan = new TextSpan(style.getLinked(), styledText.getText()); - span.addChild(textSpan); - } - richText.setRootSpan(span); + richText.setRootSpan(textSpan); return Collections.singletonList(richText); } @@ -158,50 +127,41 @@ public abstract class TextHUDFeature extends AbstractHUDFeature implements Style return new TextHUDDemo(this); } - 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() { + public TextSpan getDummyText() { return getText(); } - public abstract List<StyledText> getText(); + public abstract TextSpan getText(); - public List<TextStyle> getStyles() { - return this.<List<TextStyle>>getParameter("textStylesNEW").getValue(); - } + private Map<String, DefaultingDelegatingTextStyle> defaultStyleMap = new HashMap<>(); + private Map<String, DefaultingDelegatingTextStyle> styleMap = new HashMap<>(); + public void registerDefaultStyle(String name, DefaultingDelegatingTextStyle style) { + defaultStyleMap.put(name, style); + } + public DefaultingDelegatingTextStyle getStyle(String name) { + return styleMap.get(name); + } - 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, new ParentDelegatingTextStyle())); - } - stylesMap = res; + public void updateStyle(Map<String, DefaultingDelegatingTextStyle> map) { + styleMap.clear(); + Set<String> wasIn = new HashSet<>(map.keySet()); + Set<String> needsToBeIn = new HashSet<>(defaultStyleMap.keySet()); + needsToBeIn.removeAll(wasIn); + for (Map.Entry<String, DefaultingDelegatingTextStyle> stringDefaultingDelegatingTextStyleEntry : map.entrySet()) { + if (!defaultStyleMap.containsKey(stringDefaultingDelegatingTextStyleEntry.getKey())) continue; + DefaultingDelegatingTextStyle newStyle = stringDefaultingDelegatingTextStyleEntry.getValue(); + newStyle.setParent(() -> defaultStyleMap.get(stringDefaultingDelegatingTextStyleEntry.getKey())); + styleMap.put(stringDefaultingDelegatingTextStyleEntry.getKey(), newStyle); + } + for (String s : needsToBeIn) { + styleMap.put(s, new DefaultingDelegatingTextStyle().setParent(() -> defaultStyleMap.get(s))); + map.put(s, styleMap.get(s)); } - return stylesMap; } - @Override public void getTooltipForEditor(List<Widget> widgets) { super.getTooltipForEditor(widgets); @@ -223,7 +183,7 @@ public abstract class TextHUDFeature extends AbstractHUDFeature implements Style @Override public void onParameterReset() { - stylesMap = null; + } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/styles/ParentDelegatingTextStyle.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/styles/ParentDelegatingTextStyle.java index e8f74858..f9d4909d 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/styles/ParentDelegatingTextStyle.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/styles/ParentDelegatingTextStyle.java @@ -65,7 +65,7 @@ public class ParentDelegatingTextStyle implements ITextStyle { parentDelegatingTextStyle.shadow = false; parentDelegatingTextStyle.outline = false; - parentDelegatingTextStyle.backgroundShader = new SingleColorShader(0xFFFFFFFF); + parentDelegatingTextStyle.backgroundShader = new SingleColorShader(0x00000000); parentDelegatingTextStyle.textShader = new SingleColorShader(0xFFFFFFFF); parentDelegatingTextStyle.strikeThroughShader = new SingleColorShader(0xFF000000); parentDelegatingTextStyle.underlineShader = new SingleColorShader(0xFF000000); |