Skip to content

Commit

Permalink
[ui] extract base screen tooltip rendering in into overridable functions
Browse files Browse the repository at this point in the history
  • Loading branch information
gliscowo committed Dec 29, 2024
1 parent 8ecca4f commit e0846d6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/io/wispforest/owo/ui/base/BaseOwoScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down

0 comments on commit e0846d6

Please sign in to comment.