From 6a0bfcae23a43877f5e894200b6cacfe623dd48e Mon Sep 17 00:00:00 2001 From: ThatGravyBoat Date: Tue, 2 Jul 2024 18:41:26 -0230 Subject: [PATCH] Misc changes and additions --- .../dev/dediamondpro/minemark/LayoutStyle.java | 4 ++++ .../minemark/MineMarkHtmlParser.java | 1 + .../dediamondpro/minemark/elements/Element.java | 17 ++++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/dev/dediamondpro/minemark/LayoutStyle.java b/src/main/java/dev/dediamondpro/minemark/LayoutStyle.java index d49bf4d..bc4f8e5 100644 --- a/src/main/java/dev/dediamondpro/minemark/LayoutStyle.java +++ b/src/main/java/dev/dediamondpro/minemark/LayoutStyle.java @@ -146,6 +146,10 @@ public void put(StyleType styleType, T value) { customStyles.put(styleType, value); } + public void remove(StyleType styleType) { + customStyles.remove(styleType); + } + public boolean has(StyleType styleType) { return customStyles.containsKey(styleType); } diff --git a/src/main/java/dev/dediamondpro/minemark/MineMarkHtmlParser.java b/src/main/java/dev/dediamondpro/minemark/MineMarkHtmlParser.java index 4069397..ee483d3 100644 --- a/src/main/java/dev/dediamondpro/minemark/MineMarkHtmlParser.java +++ b/src/main/java/dev/dediamondpro/minemark/MineMarkHtmlParser.java @@ -97,6 +97,7 @@ public void endElement(String uri, String localName, String qName) { break; } addText(); + currentElement.complete(); currentElement = currentElement.getParent(); } diff --git a/src/main/java/dev/dediamondpro/minemark/elements/Element.java b/src/main/java/dev/dediamondpro/minemark/elements/Element.java index a4e87e4..21a4734 100644 --- a/src/main/java/dev/dediamondpro/minemark/elements/Element.java +++ b/src/main/java/dev/dediamondpro/minemark/elements/Element.java @@ -60,10 +60,18 @@ public Element(@NotNull S style, @NotNull LayoutStyle layoutStyle, @Nullable Ele this.attributes = attributes; } + /** + * Called when an element is ended and all children are created. + */ + @ApiStatus.OverrideOnly + public void complete() { + + } + /** * Internal method for drawing an element, should never be used directly. */ - @ApiStatus.Internal + @ApiStatus.OverrideOnly public void drawInternal(float xOffset, float yOffset, float mouseX, float mouseY, R renderData){ for (Element child : children) { child.drawInternal(xOffset, yOffset, mouseX, mouseY, renderData); @@ -73,7 +81,7 @@ public void drawInternal(float xOffset, float yOffset, float mouseX, float mouse /** * Internal method called before drawing an element, should never be used directly. */ - @ApiStatus.Internal + @ApiStatus.OverrideOnly public void beforeDrawInternal(float xOffset, float yOffset, float mouseX, float mouseY, R renderData) { for (Element child : children) { child.beforeDrawInternal(xOffset, yOffset, mouseX, mouseY, renderData); @@ -83,7 +91,7 @@ public void beforeDrawInternal(float xOffset, float yOffset, float mouseX, float /** * Internal method for called when the mouse is clicked, should never be used directly. */ - @ApiStatus.Internal + @ApiStatus.OverrideOnly public void onMouseClickedInternal(MouseButton button, float mouseX, float mouseY) { for (Element child : children) { child.onMouseClickedInternal(button, mouseX, mouseY); @@ -131,7 +139,10 @@ public void close() { /** * Build a tree of elements for debugging purposes + *

+ * Use {@link MineMarkElement#getTree()} to get the full tree */ + @ApiStatus.Internal public String buildTree(int depth) { StringBuilder builder = new StringBuilder(); builder.append(this);