-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
320 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/mcp/mobius/waila/gui/hud/ComponentRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package mcp.mobius.waila.gui.hud; | ||
|
||
import java.util.Random; | ||
|
||
import mcp.mobius.waila.WailaClient; | ||
import mcp.mobius.waila.api.ITooltipComponent; | ||
import mcp.mobius.waila.api.util.WRenders; | ||
import mcp.mobius.waila.util.DisplayUtil; | ||
import net.minecraft.client.DeltaTracker; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.util.Mth; | ||
|
||
public interface ComponentRenderer { | ||
|
||
Random RANDOM = new Random(); | ||
|
||
void render(GuiGraphics ctx, ITooltipComponent component, int x, int y, int cw, int ch, DeltaTracker delta); | ||
|
||
ComponentRenderer DEFAULT = (ctx, component, x, y, cw, ch, delta) -> { | ||
component.render(ctx, x, y, delta); | ||
|
||
if (WailaClient.showComponentBounds) { | ||
ctx.pose().pushPose(); | ||
var scale = (float) Minecraft.getInstance().getWindow().getGuiScale(); | ||
ctx.pose().scale(1 / scale, 1 / scale, 1); | ||
|
||
var buf = WRenders.buffer(RenderType.gui()); | ||
var bx = Mth.floor(x * scale + 0.5); | ||
var by = Mth.floor(y * scale + 0.5); | ||
var bw = Mth.floor(cw * scale + 0.5); | ||
var bh = Mth.floor(ch * scale + 0.5); | ||
var color = (0xFF << 24) + Mth.hsvToRgb(RANDOM.nextFloat(), RANDOM.nextFloat(), 1f); | ||
DisplayUtil.renderRectBorder(ctx.pose().last().pose(), buf, bx, by, bw, bh, 1, color, color); | ||
|
||
ctx.pose().popPose(); | ||
ctx.flush(); | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.