From e0846d66498e6983e9e2a75de893bbb8673072f2 Mon Sep 17 00:00:00 2001 From: glisco Date: Sun, 29 Dec 2024 17:42:30 +0100 Subject: [PATCH] [ui] extract base screen tooltip rendering in into overridable functions --- gradle.properties | 2 +- .../wispforest/owo/ui/base/BaseOwoHandledScreen.java | 11 ++++++++++- .../java/io/wispforest/owo/ui/base/BaseOwoScreen.java | 11 ++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2f1e84c2..43bf360a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ minecraft_version=1.21.4 yarn_mappings=1.21.4+build.1 loader_version=0.16.9 # Mod Properties -mod_version=0.12.19 +mod_version=0.12.20 maven_group=io.wispforest archives_base_name=owo-lib # Dependencies diff --git a/src/main/java/io/wispforest/owo/ui/base/BaseOwoHandledScreen.java b/src/main/java/io/wispforest/owo/ui/base/BaseOwoHandledScreen.java index b2dfad6b..820d0c04 100644 --- a/src/main/java/io/wispforest/owo/ui/base/BaseOwoHandledScreen.java +++ b/src/main/java/io/wispforest/owo/ui/base/BaseOwoHandledScreen.java @@ -93,10 +93,19 @@ protected void init() { } ScreenEvents.afterRender(this).register((screen, drawContext, mouseX, mouseY, tickDelta) -> { - if (this.uiAdapter != null) this.uiAdapter.drawTooltip(drawContext, mouseX, mouseY, tickDelta); + this.drawComponentTooltip(drawContext, mouseX, mouseY, tickDelta); }); } + /** + * Draw the tooltip of this screen's component tree, invoked + * by {@link ScreenEvents#afterRender(Screen)} so that tooltips are + * properly rendered above content + */ + protected void drawComponentTooltip(DrawContext drawContext, int mouseX, int mouseY, float tickDelta) { + if (this.uiAdapter != null) this.uiAdapter.drawTooltip(drawContext, mouseX, mouseY, tickDelta); + } + /** * Disable the slot at the given index. Note * that this is hard override and the slot cannot diff --git a/src/main/java/io/wispforest/owo/ui/base/BaseOwoScreen.java b/src/main/java/io/wispforest/owo/ui/base/BaseOwoScreen.java index 7ecc3786..44c353be 100644 --- a/src/main/java/io/wispforest/owo/ui/base/BaseOwoScreen.java +++ b/src/main/java/io/wispforest/owo/ui/base/BaseOwoScreen.java @@ -100,10 +100,19 @@ protected void init() { } ScreenEvents.afterRender(this).register((screen, drawContext, mouseX, mouseY, tickDelta) -> { - if (this.uiAdapter != null) this.uiAdapter.drawTooltip(drawContext, mouseX, mouseY, tickDelta); + this.drawComponentTooltip(drawContext, mouseX, mouseY, tickDelta); }); } + /** + * Draw the tooltip of this screen's component tree, invoked + * by {@link ScreenEvents#afterRender(Screen)} so that tooltips are + * properly rendered above content + */ + protected void drawComponentTooltip(DrawContext drawContext, int mouseX, int mouseY, float tickDelta) { + if (this.uiAdapter != null) this.uiAdapter.drawTooltip(drawContext, mouseX, mouseY, tickDelta); + } + /** * A convenience shorthand for querying a component from the adapter's * root component via {@link ParentComponent#childById(Class, String)}