diff options
| author | shedaniel <daniel@shedaniel.me> | 2023-06-01 16:51:17 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2023-06-01 16:55:09 +0800 |
| commit | e7b215a7da342a18b0c0cd297cd847eda11c65e8 (patch) | |
| tree | 06aff563981c5d8c58ca137cc2aa18b278b84a69 /api/src/main | |
| parent | d933211cc47ef3c6c370e26763e0ded885f1a0d8 (diff) | |
| download | RoughlyEnoughItems-e7b215a7da342a18b0c0cd297cd847eda11c65e8.tar.gz RoughlyEnoughItems-e7b215a7da342a18b0c0cd297cd847eda11c65e8.tar.bz2 RoughlyEnoughItems-e7b215a7da342a18b0c0cd297cd847eda11c65e8.zip | |
Close #1421
Diffstat (limited to 'api/src/main')
| -rw-r--r-- | api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java | 13 | ||||
| -rw-r--r-- | api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayRendererProvider.java | 79 |
2 files changed, 92 insertions, 0 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java index 49b63e1f5..70db769e3 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java @@ -89,6 +89,19 @@ public interface OverlayDecider extends Comparable<OverlayDecider> { } /** + * Returns the provider for rendering the overlay. + * Return {@code null} to pass the rendering to the next decider. + * + * @return the provider for rendering the overlay + * @see OverlayRendererProvider for more information + * @since 8.3 + */ + @ApiStatus.Experimental + default OverlayRendererProvider getRendererProvider() { + return null; + } + + /** * {@inheritDoc} */ @Override diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayRendererProvider.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayRendererProvider.java new file mode 100644 index 000000000..e690218b7 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayRendererProvider.java @@ -0,0 +1,79 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.client.registry.screen; + +import com.mojang.blaze3d.vertex.PoseStack; +import me.shedaniel.rei.api.client.overlay.ScreenOverlay; +import org.jetbrains.annotations.ApiStatus; + +/** + * The provider for a renderer provider. + * <p> + * {@link #onApplied(Sink)} is called when this provider is selected for a screen, + * and {@link #onRemoved()} is called when this provider is removed from a screen, + * for example if the screen is now no longer applicable for this provider, or + * the screen is closed. + * <p> + * {@link Sink} is given to the provider to allow the provider to render the overlay, + * whatever it deems necessary. + */ +@ApiStatus.Experimental +public interface OverlayRendererProvider { + default void onApplied(Sink sink) { + } + + default void onRemoved() { + } + + @ApiStatus.NonExtendable + interface Sink { + /** + * Renders the overlay. + * + * @param matrices the matrices + * @param mouseX the mouse x + * @param mouseY the mouse y + * @param delta the delta + */ + void render(PoseStack matrices, int mouseX, int mouseY, float delta); + + /** + * Renders the overlay components that are supposed to be rendered last, + * for example, menu entries, or tooltips. + * + * @param matrices the matrices + * @param mouseX the mouse x + * @param mouseY the mouse y + * @param delta the delta + */ + void lateRender(PoseStack matrices, int mouseX, int mouseY, float delta); + + /** + * Returns the overlay. + * + * @return the overlay + */ + ScreenOverlay getOverlay(); + } +} |
