From 6cb43704d06df2177e188c090a652f7e4f80a661 Mon Sep 17 00:00:00 2001 From: Juuxel <6596629+Juuxel@users.noreply.github.com> Date: Sun, 26 Jan 2020 13:04:43 +0200 Subject: Add a utility method to CottonHud that resizes the added widget --- .../io/github/cottonmc/cotton/gui/client/CottonHud.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java index 8eb5f42..a9d1d9b 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonHud.java @@ -44,6 +44,21 @@ public enum CottonHud implements HudRenderCallback { add(widget, Positioner.of(x, y)); } + /** + * Adds a new widget to the HUD at the specified offsets and resizes it. + * + * @param widget the widget + * @param x the x offset + * @param y the y offset + * @param width the width of the widget + * @param height the heigh of the widget + * @see Positioner#of documentation about the offsets + */ + public void add(WWidget widget, int x, int y, int width, int height) { + add(widget, Positioner.of(x, y)); + widget.setSize(width, height); + } + /** * Adds a new widget to the HUD with a custom positioner. * -- cgit