Skip to content

Commit e0846d6

Browse files
committed
[ui] extract base screen tooltip rendering in into overridable functions
1 parent 8ecca4f commit e0846d6

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ minecraft_version=1.21.4
77
yarn_mappings=1.21.4+build.1
88
loader_version=0.16.9
99
# Mod Properties
10-
mod_version=0.12.19
10+
mod_version=0.12.20
1111
maven_group=io.wispforest
1212
archives_base_name=owo-lib
1313
# Dependencies

src/main/java/io/wispforest/owo/ui/base/BaseOwoHandledScreen.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,19 @@ protected void init() {
9393
}
9494

9595
ScreenEvents.afterRender(this).register((screen, drawContext, mouseX, mouseY, tickDelta) -> {
96-
if (this.uiAdapter != null) this.uiAdapter.drawTooltip(drawContext, mouseX, mouseY, tickDelta);
96+
this.drawComponentTooltip(drawContext, mouseX, mouseY, tickDelta);
9797
});
9898
}
9999

100+
/**
101+
* Draw the tooltip of this screen's component tree, invoked
102+
* by {@link ScreenEvents#afterRender(Screen)} so that tooltips are
103+
* properly rendered above content
104+
*/
105+
protected void drawComponentTooltip(DrawContext drawContext, int mouseX, int mouseY, float tickDelta) {
106+
if (this.uiAdapter != null) this.uiAdapter.drawTooltip(drawContext, mouseX, mouseY, tickDelta);
107+
}
108+
100109
/**
101110
* Disable the slot at the given index. Note
102111
* that this is hard override and the slot cannot

src/main/java/io/wispforest/owo/ui/base/BaseOwoScreen.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,19 @@ protected void init() {
100100
}
101101

102102
ScreenEvents.afterRender(this).register((screen, drawContext, mouseX, mouseY, tickDelta) -> {
103-
if (this.uiAdapter != null) this.uiAdapter.drawTooltip(drawContext, mouseX, mouseY, tickDelta);
103+
this.drawComponentTooltip(drawContext, mouseX, mouseY, tickDelta);
104104
});
105105
}
106106

107+
/**
108+
* Draw the tooltip of this screen's component tree, invoked
109+
* by {@link ScreenEvents#afterRender(Screen)} so that tooltips are
110+
* properly rendered above content
111+
*/
112+
protected void drawComponentTooltip(DrawContext drawContext, int mouseX, int mouseY, float tickDelta) {
113+
if (this.uiAdapter != null) this.uiAdapter.drawTooltip(drawContext, mouseX, mouseY, tickDelta);
114+
}
115+
107116
/**
108117
* A convenience shorthand for querying a component from the adapter's
109118
* root component via {@link ParentComponent#childById(Class, String)}

0 commit comments

Comments
 (0)