From 8fdf23d475a5742b4efd3e01035d5ad623107a18 Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Thu, 28 Aug 2025 11:31:12 -0400 Subject: [PATCH 01/20] chore: add javadocs to BaseWidget --- .../dev/cigarette/gui/widget/BaseWidget.java | 156 ++++++++++++++++++ 1 file changed, 156 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/widget/BaseWidget.java b/src/main/java/dev/cigarette/gui/widget/BaseWidget.java index 8c0d476e..671e588c 100644 --- a/src/main/java/dev/cigarette/gui/widget/BaseWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/BaseWidget.java @@ -12,33 +12,87 @@ import java.util.function.Consumer; +/** + * Extends the base widget providing default functionality for saving/loading custom state from the config. + * + * @param The custom state this widget stores. Use {@code BaseWidget.Stateless} for widgets that should not hold state. + */ public abstract class BaseWidget extends ClickableWidget { + /** + * The default state of this widget for resetting. + */ private StateType defaultState; + /** + * The current state of this widget. + */ private StateType state; + /** + * Whether this widget is focused by the user. + */ protected boolean focused = false; + /** + * Whether this widget is capturing hover events to render tooltips. + */ protected boolean captureHover = false; + /** + * Whether this widget is currently hovered by the mouse. + */ protected boolean hovered = false; + /** + * The registered config key for saving and loading this widget's state. + */ protected String configKey; + /** + * The tooltip state of this widget. + */ private final TooltipState tooltip = new TooltipState(); + /** + * A callback triggered when the state changes. For registered widgets, this is used to write the new state to the config. + */ protected @Nullable Consumer stateCallback = null; + /** + * A callback triggered when the config is loaded setting the state. This widget must be registered before the config loads. + */ protected @Nullable Consumer fsCallback = null; + /** + * A callback triggered when the state changes. Used primarily to trigger module {@code whenEnabled} and {@code whenDisabled} events. + */ protected @Nullable Consumer moduleCallback = null; + /** + * Create a basic widget that holds custom state and saves/loads it from the cigarette config. + * + * @param message The text to display when this widget is rendered + * @param tooltip The text to display when this widget is hovered + */ public BaseWidget(String message, @Nullable String tooltip) { super(0, 0, 0, 0, message == null ? Text.empty() : Text.literal(message)); if (tooltip != null) this.setTooltip(Tooltip.of(Text.literal(tooltip))); } + /** + * {@return whether this widget is holding custom state} + */ public boolean isStateless() { return this.state instanceof Stateless; } + /** + * Sets the state of this widget and calls any attached module and state callbacks. Those callbacks trigger module {@code whenEnabled} and {@code whenDisabled} events (given that this is a boolean widget), and writes the new state to the config. + * + * @param state The new state to set to this widget + */ public final void setRawState(StateType state) { this.state = state; if (moduleCallback != null) moduleCallback.accept(this.state); if (stateCallback != null) stateCallback.accept(this.state); } + /** + * Toggles the state of this widget and calls any attached module and state callbacks. Those callbacks trigger module {@code whenEnabled} and {@code whenDisabled} events, and writes the new state to the config. + * + * @throws IllegalStateException If this widget is not of a boolean state type + */ @SuppressWarnings("unchecked") public final void toggleRawState() { if (this.state instanceof Boolean booleanState) { @@ -48,15 +102,31 @@ public final void toggleRawState() { throw new IllegalStateException("Cannot toggle state from a non-boolean component."); } + /** + * {@return the custom state} + * + * @throws IllegalStateException If this widget is a stateless widget + */ public final StateType getRawState() { if (this.state instanceof Stateless) throw new IllegalStateException("Cannot get state from a stateless component."); return this.state; } + /** + * Binds a callback that is triggered when the state is set. Most often used in modules to trigger {@code whenEnabled} and {@code whenDisabled} events. + *

Note that there are no checks on whether the new state is different from the previous state.

+ * + * @param callback The callback that accepts the newest state + */ public void registerModuleCallback(Consumer callback) { this.moduleCallback = callback; } + /** + * The default callback attached to this widget when it is initially registered to the config. This callback receives the state of this widget from the config once it is loaded by the client. Triggers the module state callback which trigger module {@code whenEnabled} and {@code whenDisabled} events. + * + * @param newState The new state to set + */ @SuppressWarnings("unchecked") private void defaultFSCallback(Object newState) { try { @@ -67,6 +137,11 @@ private void defaultFSCallback(Object newState) { } } + /** + * Registers this widget to the config so it can save/load its state. + * + * @param key The key in the config to store the value of this widgets state under + */ public void registerConfigKey(String key) { if (this.state instanceof Stateless) return; if (this.configKey != null) throw new IllegalStateException("Cannot configure a config key more than once."); @@ -76,6 +151,12 @@ public void registerConfigKey(String key) { FileSystem.registerUpdate(key, this.fsCallback); } + /** + * Registers this widget to the config so it can save/load its state. This method has an additional callback that can be defined which will receive the state of the widget once it is loaded by the client. + * + * @param key The key in the config to store the value of this widgets state under + * @param loadedState A callback which receives the state from the config once loaded by the client + */ public void registerConfigKeyAnd(String key, Consumer loadedState) { if (this.state instanceof Stateless) return; if (this.configKey != null) throw new IllegalStateException("Cannot configure a config key more than once."); @@ -88,46 +169,96 @@ public void registerConfigKeyAnd(String key, Consumer loadedState) { FileSystem.registerUpdate(key, this.fsCallback); } + /** + * Sets this widget to capture hovering events. This is required to be set for tooltips to be rendered. + * + * @return This widget for method chaining + */ protected BaseWidget captureHover() { this.captureHover = true; return this; } + /** + * Sets this widget's focused state. + * + * @param state The focused state to set + */ public void setFocused(boolean state) { this.focused = state; } + /** + * Sets this widget to be focused. + */ public void setFocused() { this.focused = true; } + /** + * Sets this widget to be unfocused. + */ public void unfocus() { this.focused = false; } + /** + * Sets the hover tooltip of this widget. The tooltip will only be rendered if {@code captureHover} was called allowing this widget to capture hovering events. + *

For basic tooltips, you can use {@code Tooltip.of(Text.literal(String))} to convert a String to a Tooltip.

+ * + * @param tooltip The tooltip + */ @Override public void setTooltip(Tooltip tooltip) { this.tooltip.setTooltip(tooltip); } + /** + * Sets the position of this widget. + * + * @param x The distance from the left edge of the screen + * @param y The distance from the top edge of the screen + * @return This widget for method chaining + */ public BaseWidget withXY(int x, int y) { this.setX(x); this.setY(y); return this; } + /** + * Sets the width and height of this widget. + * + * @param w The width of the widget + * @param h The height of the widget + * @return This widget for method chaining + */ public BaseWidget withWH(int w, int h) { this.setWidth(w); this.setHeight(h); return this; } + /** + * Sets the state and stored default state of this widget. + * + * @param state The default state to set + * @return This widget for method chaining + */ public BaseWidget withDefault(StateType state) { this.defaultState = state; this.state = state; return this; } + /** + * Replacement method for the {@code ClickableWidget::render} method that cannot be overridden. Automatically handles rendering tooltips when this widget is hovered and the top-most widget. Also pulls the bounding box of this widget and supplies the values to the {@code render} method for cleaner code. + * + * @param context The draw context to pass through + * @param mouseX The mouse X position to pass through + * @param mouseY The mouse Y position to pass through + * @param deltaTicks The delta ticks to pass through + */ public void _render(DrawContext context, int mouseX, int mouseY, float deltaTicks) { if (!this.visible) return; this.hovered = captureHover && isMouseOver(mouseX, mouseY) && CigaretteScreen.isHoverable(this); @@ -135,17 +266,42 @@ public void _render(DrawContext context, int mouseX, int mouseY, float deltaTick if (this.hovered) this.tooltip.render(true, this.isFocused(), this.getNavigationFocus()); } + /** + * Alias that calls {@code _render} but looks nicer. + *

Automatically handles rendering tooltips when this widget is hovered and the top-most widget. Also pulls the bounding box of this widget and supplies the values to the {@code render} method for cleaner code.

+ * + * @param context The draw context to pass through + * @param mouseX The mouse X position to pass through + * @param mouseY The mouse Y position to pass through + * @param deltaTicks The delta ticks to pass through + */ @Override protected void renderWidget(DrawContext context, int mouseX, int mouseY, float deltaTicks) { this._render(context, mouseX, mouseY, deltaTicks); } + /** + * The custom rendering method that replaces the built-in {@code ClickableWidget::render} method. + * + * @param context The current draw context + * @param hovered Whether this widget is hovered by the mouse + * @param mouseX Current mouse X position + * @param mouseY Current mouse Y position + * @param deltaTicks Current delta ticks + * @param left Distance to the left edge of this widget from the left of the screen + * @param top Distance to the top edge of this widget from the top of the screen + * @param right Distance to the right edge of this widget from the left of the screen + * @param bottom Distance to the bottom edge of this widget from the top of the screen + */ protected abstract void render(DrawContext context, boolean hovered, int mouseX, int mouseY, float deltaTicks, int left, int top, int right, int bottom); @Override protected void appendClickableNarrations(NarrationMessageBuilder builder) { } + /** + * Empty class for widgets that do not hold any custom state. + */ public static class Stateless { } } From e4c1ee18ce39754e871d54747a9032fd296acb59 Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Thu, 28 Aug 2025 11:31:25 -0400 Subject: [PATCH 02/20] chore: add javadocs to TextWidget --- .../dev/cigarette/gui/widget/TextWidget.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/widget/TextWidget.java b/src/main/java/dev/cigarette/gui/widget/TextWidget.java index 8b2558ef..28079fab 100644 --- a/src/main/java/dev/cigarette/gui/widget/TextWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/TextWidget.java @@ -7,34 +7,81 @@ import org.jetbrains.annotations.Nullable; public class TextWidget extends BaseWidget { + /** + * Whether a line should be rendered at the bottom of this widget's bounding box. + */ private boolean underlined = false; + /** + * Whether the text should be centered inside this widget's bounding box. + */ private boolean centered = true; + /** + * Creates a widget whose only purpose is to render text and a tooltip. + * + * @param x The initial X position of this widget + * @param y The initial Y position of this widget + * @param width The initial width of this widget + * @param height The initial height of this widget + * @param message The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + */ public TextWidget(int x, int y, int width, int height, String message, @Nullable String tooltip) { super(message, tooltip); this.captureHover().withXY(x, y).withWH(width, height); } + /** + * Creates a widget whose only purpose is to render text and a tooltip. + * + * @param x The initial X position of this widget + * @param y The initial Y position of this widget + * @param width The initial width of this widget + * @param height The initial height of this widget + * @param message The text to display inside this widget + */ public TextWidget(int x, int y, int width, int height, String message) { super(message, null); this.captureHover().withXY(x, y).withWH(width, height); } + /** + * Creates a widget whose only purpose is to render text and a tooltip. + * + * @param message The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + */ public TextWidget(String message, @Nullable String tooltip) { super(message, tooltip); this.captureHover(); } + /** + * Creates a widget whose only purpose is to render text and a tooltip. + * + * @param message The text to display inside this widget + */ public TextWidget(String message) { super(message, null); this.captureHover(); } + /** + * Sets this widget to render a line at the bottom of its bounding box. + * + * @return This for method chaining + */ public TextWidget withUnderline() { underlined = true; return this; } + /** + * Sets whether this widget should render its text centered in its bounding box. + * + * @param center Whether the text should be centered + * @return This for method chaining + */ public TextWidget centered(boolean center) { this.centered = center; return this; From 180a48e159d3feb8319f4a3dc62ca25d229781d3 Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Thu, 28 Aug 2025 11:31:36 -0400 Subject: [PATCH 03/20] chore: add javadocs to PassthroughWidget --- .../gui/widget/PassthroughWidget.java | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/widget/PassthroughWidget.java b/src/main/java/dev/cigarette/gui/widget/PassthroughWidget.java index c7b9b861..23467076 100644 --- a/src/main/java/dev/cigarette/gui/widget/PassthroughWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/PassthroughWidget.java @@ -7,27 +7,66 @@ import java.util.Map; import java.util.TreeMap; +/** + * Extends the passthrough widget which holds children widgets and automatically forwards events and rendering to them. + * + * @param The type of children this widget stores. Use {@code Widget extends BaseWidget} to allow any types as children. + * @param The custom state this widget stores. Use {@code BaseWidget.Stateless} for widgets that should not hold state. + */ public abstract class PassthroughWidget, StateType> extends BaseWidget { + /** + * The children that this widget is the parent of, mapped by String to the actual child reference for sorting capabilities. + *

There is no default methods for adding children as defined in {@code PassthroughWidget}, so check the subclasses for implementation details.

+ */ protected Map children = new LinkedHashMap<>(); + /** + * Left offsetting for dropdown continuation for widgets that may render scrollbars or have inconsistent sizing. + */ protected int childLeftOffset = 0; + /** + * Creates the super class. + * + * @param x The initial X position of this widget + * @param y The initial Y position of this widget + * @param width The initial width of this widget + * @param height The initial height of this widget + * @param message The text to display inside this widget + */ public PassthroughWidget(int x, int y, int width, int height, String message) { super(message, null); this.withXY(x, y).withWH(width, height); } + /** + * Creates the super class. + * + * @param message The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + */ public PassthroughWidget(String message, @Nullable String tooltip) { super(message, tooltip); } + /** + * Creates the super class. + * + * @param message The text to display inside this widget + */ public PassthroughWidget(String message) { super(message, null); } + /** + * Switches the {@code Map} type of {@code children} to a {@code TreeMap} which automatically sorts by the {@code String} keys. + */ public void alphabetic() { this.children = new TreeMap<>(this.children); } + /** + * Sets this widget and all of its children to be unfocused. + */ @Override public void unfocus() { for (BaseWidget child : children.values()) { @@ -36,6 +75,12 @@ public void unfocus() { } } + /** + * Forwards mouse move events to all the children of this widget. + * + * @param mouseX the X coordinate of the mouse + * @param mouseY the Y coordinate of the mouse + */ @Override public void mouseMoved(double mouseX, double mouseY) { if (children.isEmpty()) return; @@ -45,6 +90,15 @@ public void mouseMoved(double mouseX, double mouseY) { } } + /** + * Forwards mouse clicked events to all the children of this widget. + *

The first child that handles the event will be focused and all subsequent children will be unfocused and will not receive the event.

+ * + * @param mouseX the X coordinate of the mouse + * @param mouseY the Y coordinate of the mouse + * @param button the mouse button number + * @return Whether a child handled the click + */ @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { if (children.isEmpty()) return false; @@ -62,6 +116,14 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { return wasHandled; } + /** + * Forwards mouse released events to all the children of this widget. + * + * @param mouseX the X coordinate of the mouse + * @param mouseY the Y coordinate of the mouse + * @param button the mouse button number + * @return {@code false} + */ @Override public boolean mouseReleased(double mouseX, double mouseY, int button) { if (children.isEmpty()) return false; @@ -72,6 +134,16 @@ public boolean mouseReleased(double mouseX, double mouseY, int button) { return false; } + /** + * Forwards mouse dragged events to all the children of this widget. + * + * @param mouseX the current X coordinate of the mouse + * @param mouseY the current Y coordinate of the mouse + * @param button the mouse button number + * @param deltaX the difference of the current X with the previous X coordinate + * @param deltaY the difference of the current Y with the previous Y coordinate + * @return {@code false} + */ @Override public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { if (children.isEmpty()) return false; @@ -82,6 +154,16 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del return false; } + /** + * Forwards mouse scrolled events to all the children of this widget. + *

This returns after the first child that handles the event.

+ * + * @param mouseX the X coordinate of the mouse + * @param mouseY the Y coordinate of the mouse + * @param horizontalAmount the horizontal scroll amount + * @param verticalAmount the vertical scroll amount + * @return Whether a child handled the scroll + */ @Override public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) { if (children.isEmpty()) return false; @@ -93,6 +175,15 @@ public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmou return false; } + /** + * Forwards key pressed events to all the children of this widget. + *

This returns after the first child that handles the event.

+ * + * @param keyCode the named key code of the event as described in the {@link org.lwjgl.glfw.GLFW GLFW} class + * @param scanCode the unique/platform-specific scan code of the keyboard input + * @param modifiers a GLFW bitfield describing the modifier keys that are held down (see GLFW Modifier key flags) + * @return Whether a child handled the key press + */ @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (children.isEmpty()) return false; @@ -104,6 +195,15 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { return false; } + /** + * Forwards the key released events to all the children of this widget. + *

This returns after the first child that handles the event.

+ * + * @param keyCode the named key code of the event as described in the {@link org.lwjgl.glfw.GLFW GLFW} class + * @param scanCode the unique/platform-specific scan code of the keyboard input + * @param modifiers a GLFW bitfield describing the modifier keys that are held down (see GLFW Modifier key flags) + * @return Whether a child handled the key release + */ @Override public boolean keyReleased(int keyCode, int scanCode, int modifiers) { if (children.isEmpty()) return false; @@ -115,6 +215,14 @@ public boolean keyReleased(int keyCode, int scanCode, int modifiers) { return false; } + /** + * Forwards the char typed events to all the children of this widget. + *

This returns after the first child that handles the event.

+ * + * @param chr the captured character + * @param modifiers a GLFW bitfield describing the modifier keys that are held down (see GLFW Modifier key flags) + * @return Whether a child handled the char type + */ @Override public boolean charTyped(char chr, int modifiers) { if (children.isEmpty()) return false; From 60dc379e5aa99713ee84c4f4cf6bc107f4a78185 Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Thu, 28 Aug 2025 11:32:24 -0400 Subject: [PATCH 04/20] chore: add javadocs to ScrollableWidget --- .../gui/widget/ScrollableWidget.java | 120 +++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/cigarette/gui/widget/ScrollableWidget.java b/src/main/java/dev/cigarette/gui/widget/ScrollableWidget.java index cebf76b7..2bde8588 100644 --- a/src/main/java/dev/cigarette/gui/widget/ScrollableWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ScrollableWidget.java @@ -11,24 +11,82 @@ import java.util.Collection; import java.util.Objects; +/** + * Extends a scrollable widget which provides scrolling functionality. + * + * @param The type of children this widget stores. Use {@code Widget extends BaseWidget} to allow any types as children. + */ public class ScrollableWidget> extends PassthroughWidget, BaseWidget.Stateless> { + /** + * Multiplier applied to the vertical scrolling delta to determine distance to actually scroll. + */ private static final int VERTICAL_SCROLL_MULTIPLIER = 6; + /** + * The default width of this widget. + */ private static final int DEFAULT_WIDTH = 100; + /** + * The default height of this widget. + */ private static final int DEFAULT_HEIGHT = 200; + /** + * The default scrollbar width of this widget. + */ private static final int DEFAULT_SCROLLBAR_WIDTH = 3; + /** + * The height of the bottom padding for the rounded effect. + */ private static final int BOTTOM_ROUNDED_RECT_HEIGHT = 6; + /** + * The height of each row inside this widget. + */ private final int rowHeight = 20; + /** + * Whether this widget is supposed to be scrollable or not. + */ private boolean shouldScroll = false; + /** + * The current scroll position. + */ private double scrollPosition = 0D; + /** + * The optional header that can move this widget when dragged. + */ private @Nullable DraggableWidget header; + /** + * The category offset index. + */ private int categoryOffsetIndex = 0; + /** + * Whether this widget is expanded, revealing its children, or not. + */ public boolean expanded = true; + /** + * Partial ticks when the widget is expanded. + */ private int ticksOnOpen = 0; + /** + * Max ticks to complete the expanding animation. + */ private static final int MAX_TICKS_ON_OPEN = 20; + /** + * Callback triggered when the header is clicked to toggle the {@code expanded} state of this widget. + */ private @Nullable Runnable onToggleExpand; + /** + * Whether to show the bottom rounding effect or not. + */ private boolean showBottomRoundedRect = true; + /** + * Creates a widget that renders children in a scrollable window. + * + * @param x The initial X position of this widget + * @param y The initial Y position of this widget + * @param headerText The text to display as the header at the top of this widget + * @param children The children to attach to this widget + */ @SafeVarargs public ScrollableWidget(int x, int y, @Nullable String headerText, @Nullable Widgets... children) { super(x, y, DEFAULT_WIDTH + DEFAULT_SCROLLBAR_WIDTH, DEFAULT_HEIGHT, null); @@ -36,6 +94,13 @@ public ScrollableWidget(int x, int y, @Nullable String headerText, @Nullable Wid this.setChildren(children).setHeader(headerText, null); } + /** + * Creates a widget that renders children in a scrollable window. + * + * @param x The initial X position of this widget + * @param y The initial Y position of this widget + * @param children The children to attach to this widget + */ @SafeVarargs public ScrollableWidget(int x, int y, @Nullable Widgets... children) { super(x, y, DEFAULT_WIDTH + DEFAULT_SCROLLBAR_WIDTH, DEFAULT_HEIGHT, null); @@ -43,11 +108,24 @@ public ScrollableWidget(int x, int y, @Nullable Widgets... children) { this.setChildren(children); } + /** + * Creates a widget that renders children in a scrollable window. + * + * @param x The initial X position of this widget + * @param y The initial Y position of this widget + */ public ScrollableWidget(int x, int y) { super(x, y, DEFAULT_WIDTH + DEFAULT_SCROLLBAR_WIDTH, DEFAULT_HEIGHT, null); this.withDefault(new BaseWidget.Stateless()); } + /** + * Creates a widget that renders children in a scrollable window. + * + * @param x The initial X position of this widget + * @param y The initial Y position of this widget + * @param showBottomRoundedRect Whether to show the bottom rounded effect + */ public ScrollableWidget(int x, int y, boolean showBottomRoundedRect) { super(x, y, DEFAULT_WIDTH + DEFAULT_SCROLLBAR_WIDTH, DEFAULT_HEIGHT, null); this.withDefault(new BaseWidget.Stateless()); @@ -56,17 +134,26 @@ public ScrollableWidget(int x, int y, boolean showBottomRoundedRect) { @Override public BaseWidget withXY(int x, int y) { - if(this.header != null) this.header.withXY(x, y); + if (this.header != null) this.header.withXY(x, y); super.withXY(x, y); return this; } + /** + * {@return whether the container should be scrollable} Updates {@code shouldScroll}. + */ private boolean updateShouldScroll() { this.shouldScroll = ((children == null ? 0 : children.size()) + (header != null ? 1 : 0)) * rowHeight > this.height; return this.shouldScroll; } + /** + * Sets the children attached to this widget. + * + * @param children The children to attach + * @return This widget for method chaining + */ @SafeVarargs public final ScrollableWidget setChildren(@Nullable Widgets... children) { for (Widgets widget : children) { @@ -77,10 +164,23 @@ public final ScrollableWidget setChildren(@Nullable Widgets... children return updateChildrenSizing(); } + /** + * Sets the header text of this widget. This creates a {@code DraggableWidget} that renders at the top of the widget that also controls its position. + * + * @param headerText The text to display + * @return This widget for method chaining + */ public ScrollableWidget setHeader(@Nullable String headerText) { return this.setHeader(headerText, null); } + /** + * Sets the header text of this widget. This creates a {@code DraggableWidget} that renders at the top of the widget that also controls its position. + * + * @param headerText The text to display + * @param onToggleExpand The callback to run when the header is right-clicked + * @return This widget for method chaining + */ public ScrollableWidget setHeader(@Nullable String headerText, @Nullable Runnable onToggleExpand) { this.onToggleExpand = onToggleExpand; if (headerText == null) { @@ -105,6 +205,11 @@ public ScrollableWidget setHeader(@Nullable String headerText, @Nullabl return updateChildrenSizing(); } + /** + * Sets all the children width and heights. This also triggers {@code updateShouldScroll} to set whether there needs to be a scrollbar. + * + * @return This widget for method chaining + */ private ScrollableWidget updateChildrenSizing() { if (this.children != null) { int rightMargin = this.updateShouldScroll() ? DEFAULT_SCROLLBAR_WIDTH : 0; @@ -121,14 +226,27 @@ private ScrollableWidget updateChildrenSizing() { return this; } + /** + * {@return the category offset index} + */ public int getCategoryOffsetIndex() { return this.categoryOffsetIndex; } + /** + * Sets the category offset index. + * + * @param index The category offset index + */ public void setCategoryOffsetIndex(int index) { this.categoryOffsetIndex = Math.max(0, index); } + /** + * Sets whether this widget is expanded. + * + * @param expanded Whether this widget should be expanded + */ public void setExpanded(boolean expanded) { if (this.expanded == expanded) return; From 9e8628c1a4e3e37290f186ec871c41c1e0a5c2a0 Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Thu, 2 Oct 2025 12:48:09 -0400 Subject: [PATCH 05/20] chore: add javadocs to ColorSquareWidget --- src/main/java/dev/cigarette/gui/widget/ColorSquareWidget.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/widget/ColorSquareWidget.java b/src/main/java/dev/cigarette/gui/widget/ColorSquareWidget.java index 96e80591..3e47161c 100644 --- a/src/main/java/dev/cigarette/gui/widget/ColorSquareWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ColorSquareWidget.java @@ -3,6 +3,9 @@ import net.minecraft.client.gui.DrawContext; public class ColorSquareWidget extends BaseWidget { + /** + * Creates a widget whose only purpose is to render a colored square. + */ public ColorSquareWidget() { super("", null); this.withDefault(0xFFFFFFFF); From 67992b652bfcf0b88a5d59dc22837d6b1a32f124 Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Thu, 2 Oct 2025 13:05:34 -0400 Subject: [PATCH 06/20] chore: add javadocs to DropdownWidget --- .../cigarette/gui/widget/DropdownWidget.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java b/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java index 7a31a5eb..a4546648 100644 --- a/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java @@ -11,22 +11,64 @@ public class DropdownWidget, StateType> extends PassthroughWidget, BaseWidget.Stateless> { + /** + * The heading widget. + */ protected Widget header; + /** + * The child widgets inside the dropdown menu. + */ protected ScrollableWidget> container; + /** + * Whether the child widgets in this dropdown should be visible. + */ private boolean dropdownVisible = false; + /** + * Whether a dropdown indicator should be rendered. + */ private boolean dropdownIndicator = true; + /** + * The time at which the rotation started. + */ private long rotateStartMillis = 0L; + /** + * The current rotation of the dropdown indicator. + */ private double rotateAngleRad = 0.0; + /** + * The current rotation of the dropdown indicator whilst the dropdown is open. + */ private double rotateOffsetRad = 0.0; + /** + * + */ private static final int ROTATION_PERIOD_MS = 2000; + /** + * Whether the dropdown menu is currently animating. + */ private boolean animating = false; + /** + * Whether the dropdown menu is in progress of opening. + */ private boolean opening = false; + /** + * The time at which the animation started. + */ private long animStartMillis = 0L; + /** + * The maximum animation runtime on opening/closing the dropdown. + */ private static final int TOGGLE_ANIM_MS = 220; + /** + * Creates a widget that can expand like a dropdown menu to show child widgets. + * + * @param message The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + */ public DropdownWidget(String message, @Nullable String tooltip) { super(message, tooltip); this.withDefault(new BaseWidget.Stateless()); @@ -34,16 +76,34 @@ public DropdownWidget(String message, @Nullable String tooltip) { super.children.put("0", this.container); } + /** + * Sets this widgets header widget. The dropdown menu opens when this widget is right-clicked and this widget is always visible. + * + * @param header The widget to use as the header + * @return This widget for method chaining + */ public DropdownWidget setHeader(Widget header) { this.header = header; return this; } + /** + * Sets this widget's children. These widgets will become visible when the dropdown menu is opened. + * + * @param children The children to attach + * @return This widget for method chaining + */ public DropdownWidget setChildren(@Nullable BaseWidget... children) { this.container.setChildren(children); return this; } + /** + * Sets whether this widget should render a dropdown indicator over the heading widget. + * + * @param indicator Whether the indicator should be rendered + * @return This widget for method chaining + */ public DropdownWidget withIndicator(boolean indicator) { this.dropdownIndicator = indicator; return this; @@ -215,6 +275,16 @@ protected void render(DrawContext context, boolean hovered, int mouseX, int mous } } + /** + * Render the clients logo at a specific location and rotation. Used as the dropdown indicator. + * + * @param context The draw context to draw on + * @param x The X position to draw at + * @param y The Y position to draw at + * @param w The width of the texture + * @param h The height of the texture + * @param angle The rotation of the texture + */ public static void cigaretteOnlyAt(DrawContext context, int x, int y, int w, int h, int angle) { context.getMatrices().push(); float cx = x + w / 2f; From ff73111035fc67bf065f55c7362bd46607fb421b Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Thu, 2 Oct 2025 13:30:12 -0400 Subject: [PATCH 07/20] chore: add javadocs to ColorDropdownWidget --- .../gui/widget/ColorDropdownWidget.java | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java b/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java index 55763ee9..981389b7 100644 --- a/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java @@ -5,24 +5,53 @@ import org.jetbrains.annotations.Nullable; public class ColorDropdownWidget, StateType> extends DropdownWidget { + /** + * Additional header widget to render the color state from the sliders. + */ private final ColorSquareWidget colorSquare = new ColorSquareWidget(); + /** + * The slider that controls the red content in the color. + */ private final SliderWidget sliderRed = new SliderWidget("Red").withBounds(0, 255, 255); + /** + * The slider that controls the green content in the color. + */ private final SliderWidget sliderGreen = new SliderWidget("Green").withBounds(0, 255, 255); + /** + * The slider that controls the blue content in the color. + */ private final SliderWidget sliderBlue = new SliderWidget("Blue").withBounds(0, 255, 255); + /** + * The slider that controls the alpha content in the color. + */ private final SliderWidget sliderAlpha = new SliderWidget("Alpha").withBounds(0, 255, 255); + /** + * {@return the color state in ARGB format} + */ public int getStateARGB() { return this.colorSquare.getRawState(); } + /** + * {@return the color state in RGBA format} + */ public int getStateRGBA() { return ((this.colorSquare.getRawState() & 0xFFFFFF) << 8) + ((this.colorSquare.getRawState() >> 24) & 0xFF); } + /** + * {@return the color state in RGB format} + */ public int getStateRGB() { return this.colorSquare.getRawState() & 0xFFFFFF; } + /** + * {@return the toggled state of this widget} + * + * @throws IllegalStateException If the header of this widget is not an instance of {@code ToggleWidget} + */ public boolean getToggleState() { if (this.header instanceof ToggleWidget) { return ((ToggleWidget) this.header).getRawState(); @@ -30,6 +59,12 @@ public boolean getToggleState() { throw new IllegalStateException("Cannot get boolean state on a stateless header in a dropdown widget."); } + /** + * Creates a dropdown widget pre-made for color configuration. Has a {@code ToggleWidget} and {@code ColorSquareWidget} header, and {@code SliderWidget} children for customizing the selected color. + * + * @param message The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + */ @SuppressWarnings("unchecked") public ColorDropdownWidget(String message, @Nullable String tooltip) { super(message, tooltip); @@ -38,6 +73,12 @@ public ColorDropdownWidget(String message, @Nullable String tooltip) { this.attachChildren().captureHover(); } + /** + * Sets the color state and stored default color state of this widget. + * + * @param argb The default state to set in ARGB format + * @return This widget for method chaining + */ public ColorDropdownWidget withDefaultColor(int argb) { this.colorSquare.withDefault(argb); sliderAlpha.withDefault((double) ((argb >> 24) & 0xFF)); @@ -47,17 +88,34 @@ public ColorDropdownWidget withDefaultColor(int argb) { return this; } + /** + * Sets the state and stored default state of the heading {@code ToggleWidget}. + * + * @param state The default state to set + * @return This widget for method chaining + */ public ColorDropdownWidget withDefaultState(StateType state) { this.header.withDefault(state); return this; } + /** + * Sets whether this widget should include an alpha slider. + * + * @param alpha Whether an alpha slider should be included + * @return This widget for method chaining + */ public ColorDropdownWidget withAlpha(boolean alpha) { this.sliderAlpha.disabled = !alpha; if (!alpha) this.sliderAlpha.withDefault(255d); return this; } + /** + * Attaches the children to the dropdown menu and binds callbacks when sliders are moved. + * + * @return This widget for method chaining + */ private ColorDropdownWidget attachChildren() { this.container.setChildren(this.sliderRed, this.sliderGreen, this.sliderBlue, this.sliderAlpha); this.sliderRed.stateCallback = ((newColor -> { @@ -79,6 +137,13 @@ private ColorDropdownWidget attachChildren() { return this; } + /** + * Generator for modules using this as a top-level widget. Creates a togglable {@code ColorDropdownWidget}. + * + * @param displayName The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + * @return A {@code GeneratedWidgets} object for use in {@code BaseModule} constructing + */ public static BaseModule.GeneratedWidgets module(String displayName, @Nullable String tooltip) { ColorDropdownWidget wrapper = new ColorDropdownWidget<>(displayName, tooltip); ToggleWidget widget = new ToggleWidget(displayName, tooltip); @@ -86,6 +151,13 @@ public static BaseModule.GeneratedWidgets module(String d return new BaseModule.GeneratedWidgets<>(wrapper, widget); } + /** + * Creates and returns a new togglable {@code ColorDropdownWidget}. + * + * @param displayName The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + * @return the new widget with a {@code ToggleWidget} attached as the header + */ public static ColorDropdownWidget buildToggle(String displayName, @Nullable String tooltip) { ColorDropdownWidget wrapper = new ColorDropdownWidget<>(displayName, tooltip); ToggleWidget widget = new ToggleWidget(displayName, tooltip); @@ -93,6 +165,13 @@ public static ColorDropdownWidget buildToggle(String disp return wrapper; } + /** + * Creates and returns a new {@code ColorDropdownWidget} with only the color configuration, no toggling. + * + * @param displayName The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + * @return thw new widget with a {@code TextWidget} attached as the header + */ public static ColorDropdownWidget buildText(String displayName, @Nullable String tooltip) { ColorDropdownWidget wrapper = new ColorDropdownWidget<>(displayName, tooltip); TextWidget widget = new TextWidget(displayName, tooltip).centered(false); From 10e83dd8347d6c7ee602fc369f4ca390582bb959 Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Thu, 2 Oct 2025 13:51:27 -0400 Subject: [PATCH 08/20] chore: add javadocs to DraggableWidget --- .../cigarette/gui/widget/DraggableWidget.java | 86 ++++++++++++++++++- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/src/main/java/dev/cigarette/gui/widget/DraggableWidget.java b/src/main/java/dev/cigarette/gui/widget/DraggableWidget.java index 8d147930..ef437055 100644 --- a/src/main/java/dev/cigarette/gui/widget/DraggableWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/DraggableWidget.java @@ -20,28 +20,80 @@ public interface ClickCallback { void onClick(double mouseX, double mouseY, int button); } + /** + * Whether this widget is actively being dragged by the user. + */ private boolean dragging = false; + /** + * The starting X position of the drag on screen. + */ private int startingX = 0; + /** + * The starting Y position of the drag on screen. + */ private int startingY = 0; + /** + * The starting mouse X position that initiated the drag. + */ private double startingMouseX = 0; + /** + * The starting mouse Y position that initiated the drag. + */ private double startingMouseY = 0; + /** + * Callback triggered when this widget is moved as a result of a drag. + */ private @Nullable DragCallback dragCallback = null; + /** + * Callback triggered when this widget is right-clicked. + */ private @Nullable ClickCallback clickCallback = null; + /** + * If this widget is responsible for a {@code ScrollableWidget}'s visibility, this signals whether that widget is collapsed. Used for rounding the bottom corners of this widget when collapsed. + */ public boolean expanded = false; + /** + * The current number of ticks the collapse animation has progressed through. + */ private int ticksOnCollapse = 0; + /** + * The max number of ticks the collapse animation lasts. + */ private static final int MAX_TICKS_ON_COLLAPSE = 10; + /** + * Creates a widget that can be dragged and clicked. + * + * @param x The initial X position of this widget + * @param y The initial Y position of this widget + * @param width The initial width of this widget + * @param height The initial height of this widget + * @param message The text to display inside this widget + */ public DraggableWidget(int x, int y, int width, int height, String message) { super(message, null); this.captureHover().withXY(x, y).withWH(width, height); } + /** + * Creates a widget that can be dragged and clicked. + * + * @param message The text to display inside this widget + */ public DraggableWidget(String message) { super(message, null); this.captureHover(); } + /** + * Captures a mouse click to initiate dragging and trigger click callbacks. + * + * @param mouseX the X coordinate of the mouse + * @param mouseY the Y coordinate of the mouse + * @param button the mouse button number + * @return Whether this widget handled the click + */ @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { if (isMouseOver(mouseX, mouseY)) { @@ -68,6 +120,16 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { return false; } + /** + * Captures a mouse drag to update the position of this widget. + * + * @param mouseX the X coordinate of the mouse + * @param mouseY the Y coordinate of the mouse + * @param button the mouse button number + * @param ignored the mouse delta X + * @param ignored_ the mouse delta Y + * @return Whether this widget handled the drag + */ @Override public boolean mouseDragged(double mouseX, double mouseY, int button, double ignored, double ignored_) { if (dragging) { @@ -90,26 +152,42 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double ign return dragging; } + /** + * Captures a mouse release to stop the dragging of this widget. + *

Does not prevent this event from propagating to other elements.

+ * + * @param mouseX the X coordinate of the mouse + * @param mouseY the Y coordinate of the mouse + * @param button the mouse button number + * @return {@code false} + */ @Override public boolean mouseReleased(double mouseX, double mouseY, int button) { dragging = false; return false; } + /** + * Attaches a callback that is triggered when this widget is dragged to a new position. + * + * @param callback The callback to trigger on drag + */ public void onDrag(DragCallback callback) { this.dragCallback = callback; } + /** + * Attaches a callback that is triggered when this widget is clicked and not dragged. + * + * @param callback The callback to trigger on click + */ public void onClick(ClickCallback callback) { this.clickCallback = callback; } - - - @Override public void render(DrawContext context, boolean hovered, int mouseX, int mouseY, float deltaTicks, int left, - int top, int right, int bottom) { + int top, int right, int bottom) { TextRenderer textRenderer = Cigarette.REGULAR; int bgColor = Color.color(left, top); if (!this.expanded) { From 0400ae7f2e5af094af906da8bead307effe7a7da Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Thu, 2 Oct 2025 14:08:38 -0400 Subject: [PATCH 09/20] chore: add javadocs to SliderWidget --- .../cigarette/gui/widget/SliderWidget.java | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/widget/SliderWidget.java b/src/main/java/dev/cigarette/gui/widget/SliderWidget.java index a0afa7e2..09f9d87d 100644 --- a/src/main/java/dev/cigarette/gui/widget/SliderWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/SliderWidget.java @@ -11,14 +11,41 @@ import java.util.function.Consumer; public class SliderWidget extends BaseWidget { + /** + * The amount of padding on the left and right side of the sliders bounding box to prevent the slider bar from reaching the border. + */ private static final int SLIDER_PADDING = 4; + /** + * Callback triggered when this widget's state changes. + */ private @Nullable Consumer sliderCallback = null; + /** + * The maximum value this slider can hold. + */ private double maxState = 0; + /** + * The minimum value this slider can hold. + */ private double minState = 0; + /** + * The number of decimal places to include when getting this widgets state. + */ private int decimalPlaces = 0; + /** + * Whether the slider head is actively being dragged by the user. + */ private boolean dragging = false; + /** + * Whether this slider is disabled. + */ public boolean disabled = false; + /** + * Updates the state of the slider and triggers the state change callback. + *

This returns prematurely if the state is not within bounds.

+ * + * @param state The new state to set to this widget + */ public void setState(double state) { if (state > maxState) return; if (state < minState) return; @@ -26,6 +53,12 @@ public void setState(double state) { if (sliderCallback != null) sliderCallback.accept(state); } + /** + * Updates the raw state of the slider do the {@code decimalPlaces} degree of accuracy. + *

This returns prematurely if the state is not within bounds. Does not trigger any callbacks by itself.

+ * + * @param state The new state to set to this widget + */ protected void setAccurateState(double state) { if (state > maxState) return; if (state < minState) return; @@ -33,6 +66,11 @@ protected void setAccurateState(double state) { this.setRawState(Math.round(state * mult) / mult); } + /** + * Updates the stored state based on the position of the slider. + * + * @param mouseX the X coordinate of the mouse + */ private void setStateFromDrag(double mouseX) { int left = this.getX() + SLIDER_PADDING; int width = this.getWidth() - 2 * SLIDER_PADDING; @@ -41,26 +79,64 @@ private void setStateFromDrag(double mouseX) { this.setState(value); } + /** + * Creates a widget with a slider to adjust its value. + * + * @param x The initial X position of this widget + * @param y The initial Y position of this widget + * @param width The initial width of this widget + * @param height The initial height of this widget + * @param message The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + */ public SliderWidget(int x, int y, int width, int height, String message, @Nullable String tooltip) { super(message, tooltip); this.captureHover().withXY(x, y).withWH(width, height).withDefault(0d); } + /** + * Creates a widget with a slider to adjust its value. + * + * @param x The initial X position of this widget + * @param y The initial Y position of this widget + * @param width The initial width of this widget + * @param height The initial height of this widget + * @param message The text to display inside this widget + */ public SliderWidget(int x, int y, int width, int height, String message) { super(message, null); this.captureHover().withXY(x, y).withWH(width, height).withDefault(0d); } + /** + * Creates a widget with a slider to adjust its value. + * + * @param message The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + */ public SliderWidget(String message, String tooltip) { super(message, tooltip); this.captureHover().withDefault(0d); } + /** + * Creates a widget with a slider to adjust its value. + * + * @param message The text to display inside this widget + */ public SliderWidget(String message) { super(message, null); this.captureHover().withDefault(0d); } + /** + * Sets the min, max, and default state of this widget. + * + * @param min The minimum value the state can be + * @param def The default state to set + * @param max The maximum value the state can be + * @return This widget for method chaining + */ public SliderWidget withBounds(double min, double def, double max) { this.minState = min; this.maxState = max; @@ -68,11 +144,25 @@ public SliderWidget withBounds(double min, double def, double max) { return this; } + /** + * Sets how many decimal places will be reported when getting the state. + * + * @param decimalPlaces The number of decimal places + * @return This widget for method chaining + */ public SliderWidget withAccuracy(int decimalPlaces) { this.decimalPlaces = decimalPlaces; return this; } + /** + * Captures a mouse click to initiate dragging on the slider. + * + * @param mouseX the X coordinate of the mouse + * @param mouseY the Y coordinate of the mouse + * @param button the mouse button number + * @return Whether this widget handled the click + */ @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { if (this.disabled) return false; @@ -82,6 +172,16 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { return true; } + /** + * Captures a mouse drag to update the state and position of the slider. + * + * @param mouseX the X coordinate of the mouse + * @param mouseY the Y coordinate of the mouse + * @param button the mouse button number + * @param ignored the mouse delta X + * @param ignored_ the mouse delta Y + * @return Whether this widget handled the drag + */ @Override public boolean mouseDragged(double mouseX, double mouseY, int button, double ignored, double ignored_) { if (this.disabled) return false; @@ -90,6 +190,15 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double ign return true; } + /** + * Captures a mouse release to stop the dragging of the slider. + *

Does not prevent this event from propagating to other elements.

+ * + * @param mouseX the X coordinate of the mouse + * @param mouseY the Y coordinate of the mouse + * @param button the mouse button number + * @return {@code false} + */ @Override public boolean mouseReleased(double mouseX, double mouseY, int button) { if (this.disabled) return false; From f2b6874164ba59ad7b0c39d71b6f1a4158d97098 Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Thu, 2 Oct 2025 14:51:56 -0400 Subject: [PATCH 10/20] chore: add javadocs to ToggleWidget --- .../cigarette/gui/widget/ToggleWidget.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java b/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java index 13887077..74077dec 100644 --- a/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java @@ -13,13 +13,33 @@ import java.util.function.Consumer; public class ToggleWidget extends BaseWidget { + /** + * The max number of ticks the hover animation runs for. + */ private static final int MAX_HOVER_TICKS = 35; + /** + * The current number of ticks the hover animation has run for. + */ private int ticksOnHover = 0; private @Nullable Consumer callback = null; + /** + * The max number of ticks the enable animation runs for. + */ private static final float MAX_ENABLE_TICKS = 5f; + /** + * The current number of ticks the enable animation has run for. + */ private float ticksOnEnable = 0f; + /** + * Smoothly transition from color {@code a} to color {@code b} in {@code t} partial ticks. + * + * @param a The starting ARGB color to transition from + * @param b The new ARGB color to transition to + * @param t Partial ticks + * @return The current ARGB color at {@code t} partial ticks + */ private static int lerpColor(int a, int b, float t) { t = Math.max(0f, Math.min(1f, t)); int aA = (a >> 24) & 0xFF; @@ -40,16 +60,35 @@ private static int lerpColor(int a, int b, float t) { return (rA & 0xFF) << 24 | (rR & 0xFF) << 16 | (rG & 0xFF) << 8 | (rB & 0xFF); } + /** + * Creates a togglable widget. + * + * @param message The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + */ public ToggleWidget(String message, @Nullable String tooltip) { super(message, tooltip); this.captureHover().withDefault(false); } + /** + * Sets the state and stored default state of this widget. + * + * @param state The default state to set + * @return This widget for method chaining + */ public ToggleWidget withDefaultState(boolean state) { this.withDefault(state); return this; } + /** + * Generator for modules using this as a top-level widget. + * + * @param displayName The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + * @return A {@code GeneratedWidgets} object for use in {@code BaseModule} constructing + */ public static BaseModule.GeneratedWidgets module(String displayName, @Nullable String tooltip) { DropdownWidget wrapper = new DropdownWidget<>(displayName, tooltip); ToggleWidget widget = new ToggleWidget(displayName, tooltip); @@ -57,6 +96,14 @@ public static BaseModule.GeneratedWidgets module(String d return new BaseModule.GeneratedWidgets<>(wrapper, widget); } + /** + * Captures a mouse click to switch the state. + * + * @param mouseX the X coordinate of the mouse + * @param mouseY the Y coordinate of the mouse + * @param button the mouse button number + * @return Whether this widget handled the click + */ @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { if (!isMouseOver(mouseX, mouseY)) return false; @@ -100,6 +147,12 @@ protected void render(DrawContext context, boolean hovered, int mouseX, int mous } public class ToggleWidgetDisabled extends ToggleWidget { + /** + * Creates a togglable widget whose state can not be changed and renders disabled. + * + * @param message The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + */ public ToggleWidgetDisabled(String message, @Nullable String tooltip) { super(message, tooltip); } From 6f263f02175d40ef4bc6e631ec54a48518c8dfb1 Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Thu, 2 Oct 2025 15:02:38 -0400 Subject: [PATCH 11/20] chore: add javadocs to KeybindWidget --- .../cigarette/gui/widget/KeybindWidget.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java b/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java index a0222d6e..fcf9b752 100644 --- a/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java @@ -17,9 +17,21 @@ import java.util.function.Consumer; public class KeybindWidget extends BaseWidget { + /** + * The internal Minecraft KeyBinding. + */ private final KeyBinding keyBinding; + /** + * The KeyBindings actual key for rendering and configuration. + */ private InputUtil.Key utilKey; + /** + * Creates a widget that stores a keybind and allows it to be configured. + * + * @param message The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + */ public KeybindWidget(String message, @Nullable String tooltip) { super(message, tooltip); this.utilKey = InputUtil.UNKNOWN_KEY; @@ -27,6 +39,12 @@ public KeybindWidget(String message, @Nullable String tooltip) { KeyBindingHelper.registerKeyBinding(this.keyBinding); } + /** + * Sets the key and stored default key of this widget. + * + * @param key The default key to set + * @return This widget for method chaining + */ public KeybindWidget withDefaultKey(int key) { utilKey = InputUtil.fromKeyCode(key, 0); keyBinding.setBoundKey(utilKey); @@ -34,24 +52,41 @@ public KeybindWidget withDefaultKey(int key) { return this; } + /** + * Update the stored key of this widget from an input event. + * + * @param key The new key to set to this widget + */ public void setBoundKey(@Nullable InputUtil.Key key) { utilKey = key == null ? InputUtil.UNKNOWN_KEY : key; keyBinding.setBoundKey(utilKey); this.setRawState(utilKey.getCode()); } + /** + * {@return the internal Minecraft KeyBinding} + */ public KeyBinding getKeybind() { return this.keyBinding; } + /** + * Stops this widget from capturing keys to update binding. + */ protected void clearBinding() { CigaretteScreen.bindingKey = null; } + /** + * Toggles whether this widget is currently binding and capturing keys. + */ protected void toggleBinding() { CigaretteScreen.bindingKey = isBinding() ? null : this; } + /** + * {@return whether this widget is currently being binded by the user} + */ protected boolean isBinding() { return CigaretteScreen.bindingKey == this; } @@ -74,6 +109,14 @@ public void registerConfigKeyAnd(String key, Consumer loadedState) { }); } + /** + * Captures a mouse click to toggle whether the keybind is being binded. + * + * @param mouseX the X coordinate of the mouse + * @param mouseY the Y coordinate of the mouse + * @param button the mouse button number + * @return Whether this widget handled the click + */ @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { if (isMouseOver(mouseX, mouseY)) { @@ -85,6 +128,14 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { return false; } + /** + * Captures a key press to bind to the internal KeyBinding. + * + * @param keyCode the named key code of the event as described in the {@link org.lwjgl.glfw.GLFW GLFW} class + * @param scanCode the unique/platform-specific scan code of the keyboard input + * @param modifiers a GLFW bitfield describing the modifier keys that are held down (see GLFW Modifier key flags) + * @return Whether this widget handled the key press + */ @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (!isBinding()) return false; @@ -100,6 +151,13 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { return true; } + /** + * Renders the key or binding state of this widget at a specific location. + * + * @param context The draw context to draw on + * @param top The upper-bounding Y position to draw within + * @param right The right-bounding X position to draw within + */ public void renderKeyText(DrawContext context, int top, int right) { TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; From bcce83b24c6ce071d41107e9f70f8ea675e7616a Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Thu, 2 Oct 2025 15:09:16 -0400 Subject: [PATCH 12/20] chore: add javadocs to ToggleKeybindWidget --- .../gui/widget/ToggleKeybindWidget.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java b/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java index 6be151b3..50fcb72c 100644 --- a/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java @@ -9,8 +9,17 @@ import java.util.function.Consumer; public class ToggleKeybindWidget extends ToggleWidget { + /** + * The {@code KeybindWidget} for handling configuration of the keybind. + */ protected KeybindWidget widget; + /** + * Creates a widget that stores a keybind and can be toggled. + * + * @param message The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + */ public ToggleKeybindWidget(String message, @Nullable String tooltip) { super(message, tooltip); this.widget = new KeybindWidget(message, null); @@ -21,26 +30,52 @@ public ToggleKeybindWidget withDefaultState(boolean state) { return this; } + /** + * Sets the key and stored default key of this widget. + * + * @param keyCode The default key to set + * @return This widget for method chaining + */ public ToggleKeybindWidget withDefaultKey(int keyCode) { this.widget.withDefaultKey(keyCode); return this; } + /** + * {@return the internal Minecraft KeyBinding} + */ public KeyBinding getKeybind() { return this.widget.getKeybind(); } + /** + * Generator for modules using this as a top-level widget. + * + * @param displayName The text to display inside this widget + * @param tooltip The tooltip to render when this widget is hovered + * @return A {@code GeneratedWidgets} object for use in {@code BaseModule} constructing + */ public static BaseModule.GeneratedWidgets keybindModule(String displayName, @Nullable String tooltip) { ToggleKeybindWidget widget = new ToggleKeybindWidget(displayName, tooltip); return new BaseModule.GeneratedWidgets<>(null, widget); } + /** + * Sets the width of this widget. + * + * @param width The widget of the widget + */ @Override public void setWidth(int width) { super.setWidth(width); this.widget.setWidth(width); } + /** + * Sets the height of this widget. + * + * @param height The height of the widget + */ @Override public void setHeight(int height) { super.setHeight(height); From ce7b54df8d0aa6f000f860c484ccce81ba11d8df Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Thu, 2 Oct 2025 15:13:28 -0400 Subject: [PATCH 13/20] chore: format unformatted javadocs --- .../dev/cigarette/gui/widget/ColorDropdownWidget.java | 6 +++--- .../java/dev/cigarette/gui/widget/DropdownWidget.java | 10 +++++----- .../java/dev/cigarette/gui/widget/KeybindWidget.java | 8 ++++---- .../java/dev/cigarette/gui/widget/SliderWidget.java | 8 ++++---- .../dev/cigarette/gui/widget/ToggleKeybindWidget.java | 2 +- .../java/dev/cigarette/gui/widget/ToggleWidget.java | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java b/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java index 981389b7..f653ac44 100644 --- a/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java @@ -141,7 +141,7 @@ private ColorDropdownWidget attachChildren() { * Generator for modules using this as a top-level widget. Creates a togglable {@code ColorDropdownWidget}. * * @param displayName The text to display inside this widget - * @param tooltip The tooltip to render when this widget is hovered + * @param tooltip The tooltip to render when this widget is hovered * @return A {@code GeneratedWidgets} object for use in {@code BaseModule} constructing */ public static BaseModule.GeneratedWidgets module(String displayName, @Nullable String tooltip) { @@ -155,7 +155,7 @@ public static BaseModule.GeneratedWidgets module(String d * Creates and returns a new togglable {@code ColorDropdownWidget}. * * @param displayName The text to display inside this widget - * @param tooltip The tooltip to render when this widget is hovered + * @param tooltip The tooltip to render when this widget is hovered * @return the new widget with a {@code ToggleWidget} attached as the header */ public static ColorDropdownWidget buildToggle(String displayName, @Nullable String tooltip) { @@ -169,7 +169,7 @@ public static ColorDropdownWidget buildToggle(String disp * Creates and returns a new {@code ColorDropdownWidget} with only the color configuration, no toggling. * * @param displayName The text to display inside this widget - * @param tooltip The tooltip to render when this widget is hovered + * @param tooltip The tooltip to render when this widget is hovered * @return thw new widget with a {@code TextWidget} attached as the header */ public static ColorDropdownWidget buildText(String displayName, @Nullable String tooltip) { diff --git a/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java b/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java index a4546648..92a9b940 100644 --- a/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java @@ -279,11 +279,11 @@ protected void render(DrawContext context, boolean hovered, int mouseX, int mous * Render the clients logo at a specific location and rotation. Used as the dropdown indicator. * * @param context The draw context to draw on - * @param x The X position to draw at - * @param y The Y position to draw at - * @param w The width of the texture - * @param h The height of the texture - * @param angle The rotation of the texture + * @param x The X position to draw at + * @param y The Y position to draw at + * @param w The width of the texture + * @param h The height of the texture + * @param angle The rotation of the texture */ public static void cigaretteOnlyAt(DrawContext context, int x, int y, int w, int h, int angle) { context.getMatrices().push(); diff --git a/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java b/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java index fcf9b752..f19bf64a 100644 --- a/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java @@ -131,8 +131,8 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { /** * Captures a key press to bind to the internal KeyBinding. * - * @param keyCode the named key code of the event as described in the {@link org.lwjgl.glfw.GLFW GLFW} class - * @param scanCode the unique/platform-specific scan code of the keyboard input + * @param keyCode the named key code of the event as described in the {@link org.lwjgl.glfw.GLFW GLFW} class + * @param scanCode the unique/platform-specific scan code of the keyboard input * @param modifiers a GLFW bitfield describing the modifier keys that are held down (see GLFW Modifier key flags) * @return Whether this widget handled the key press */ @@ -155,8 +155,8 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { * Renders the key or binding state of this widget at a specific location. * * @param context The draw context to draw on - * @param top The upper-bounding Y position to draw within - * @param right The right-bounding X position to draw within + * @param top The upper-bounding Y position to draw within + * @param right The right-bounding X position to draw within */ public void renderKeyText(DrawContext context, int top, int right) { TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; diff --git a/src/main/java/dev/cigarette/gui/widget/SliderWidget.java b/src/main/java/dev/cigarette/gui/widget/SliderWidget.java index 09f9d87d..50c30643 100644 --- a/src/main/java/dev/cigarette/gui/widget/SliderWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/SliderWidget.java @@ -175,10 +175,10 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { /** * Captures a mouse drag to update the state and position of the slider. * - * @param mouseX the X coordinate of the mouse - * @param mouseY the Y coordinate of the mouse - * @param button the mouse button number - * @param ignored the mouse delta X + * @param mouseX the X coordinate of the mouse + * @param mouseY the Y coordinate of the mouse + * @param button the mouse button number + * @param ignored the mouse delta X * @param ignored_ the mouse delta Y * @return Whether this widget handled the drag */ diff --git a/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java b/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java index 50fcb72c..af77a138 100644 --- a/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java @@ -52,7 +52,7 @@ public KeyBinding getKeybind() { * Generator for modules using this as a top-level widget. * * @param displayName The text to display inside this widget - * @param tooltip The tooltip to render when this widget is hovered + * @param tooltip The tooltip to render when this widget is hovered * @return A {@code GeneratedWidgets} object for use in {@code BaseModule} constructing */ public static BaseModule.GeneratedWidgets keybindModule(String displayName, @Nullable String tooltip) { diff --git a/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java b/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java index 74077dec..d89136c4 100644 --- a/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java @@ -86,7 +86,7 @@ public ToggleWidget withDefaultState(boolean state) { * Generator for modules using this as a top-level widget. * * @param displayName The text to display inside this widget - * @param tooltip The tooltip to render when this widget is hovered + * @param tooltip The tooltip to render when this widget is hovered * @return A {@code GeneratedWidgets} object for use in {@code BaseModule} constructing */ public static BaseModule.GeneratedWidgets module(String displayName, @Nullable String tooltip) { From 6fef9df48401d97a8c4454ed85e92bae872fcfd8 Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Fri, 3 Oct 2025 09:44:08 -0400 Subject: [PATCH 14/20] chore: add most javadocs to CigaretteScreen --- .../dev/cigarette/gui/CigaretteScreen.java | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/CigaretteScreen.java b/src/main/java/dev/cigarette/gui/CigaretteScreen.java index afaf6625..a21cbb56 100644 --- a/src/main/java/dev/cigarette/gui/CigaretteScreen.java +++ b/src/main/java/dev/cigarette/gui/CigaretteScreen.java @@ -16,32 +16,88 @@ import java.util.Stack; public class CigaretteScreen extends Screen { + /** + * Primary feature color. (Orange) + */ public static final int PRIMARY_COLOR = 0xFFFE5F00; + /** + * Secondary feature color. (Brown) + */ public static final int SECONDARY_COLOR = 0xFFC44700; + /** + * Primary text color. (White) + */ public static final int PRIMARY_TEXT_COLOR = 0xFFFFFFFF; + /** + * Primary background color. (Dark Gray) + */ public static final int BACKGROUND_COLOR = 0xFF1A1A1A; + /** + * Dark background color usually used in gradients with {@code BACKGROUND_COLOR}. (Black) + */ public static final int DARK_BACKGROUND_COLOR = 0xFF000000; + /** + * Color of enabled things. (Bright Green) + */ public static final int ENABLED_COLOR = 0xFF3AFC3A; + /** + * Reference to the hovered widget. + */ public static @Nullable Object hoverHandled = null; + /** + * An ordered list of the widgets on the screen. Ordered by time of focus descending. Event propagation starts with the most recent focused to the last focused. + */ private final Stack> priority = new Stack<>(); + /** + * The screen that was being rendered before this GUI was opened. + */ private Screen parent = null; + /** + * Whether the GUI is in process of opening. + */ private boolean begin = false; + /** + * The time at which the GUI was opened. + */ private long openStartNanos = 0L; + /** + * Whether the GUI is in process of closing. + */ private boolean closing = false; + /** + * The time at which the GUI was closed. + */ private long closeStartNanos = 0L; + /** + * The length of the opening animation in seconds. + */ private static final double OPEN_DURATION_S = 0.4; private static final double OPEN_STAGGER_S = 0.06; private static final int OPEN_DISTANCE_PX = 24; + /** + * The length of the closing animation as a multiplier of {@code OPEN_DURATION_S}. + */ private static final double CLOSE_DURATION_FACTOR = 0.6; private static final double CLOSE_STAGGER_FACTOR = 0.6; + /** + * The total number of categories in the GUI. + */ private int categoryCount = 0; + /** + * Reference to a {@code KeybindWidget} or {@code ToggleKeybindWidget} that is actively listening for keys to bind. + */ public static @Nullable KeybindWidget bindingKey = null; protected CigaretteScreen() { super(Text.literal("Cigarette Client")); } + /** + * Called when the GUI is being opened to set the previous screen. + * + * @param parent The parent screen that will be reverted to on close + */ public void setParent(@Nullable Screen parent) { this.parent = parent; } @@ -120,6 +176,9 @@ public void mouseMoved(double mouseX, double mouseY) { } } + /** + * Called when the GUI should be closed. + */ @Override public void close() { assert client != null; @@ -143,6 +202,12 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { return true; } + /** + * {@return whether the provided widget can be hovered} If so, that widget is set as the hovered widget. + *

A widget must call {@code captureHover()} to be hoverable.

+ * + * @param obj The widget to check if it can be hovered + */ public static boolean isHoverable(Object obj) { if (hoverHandled == null) { hoverHandled = obj; @@ -151,6 +216,14 @@ public static boolean isHoverable(Object obj) { return hoverHandled == obj; } + /** + * Replaces the built-in {@code Screen::render} method. Handles animations and category rendering for the GUI. + * + * @param context The current draw context + * @param mouseX Current mouse X position + * @param mouseY Current mouse Y position + * @param deltaTicks Current delta ticks + */ @Override public void render(DrawContext context, int mouseX, int mouseY, float deltaTicks) { this.renderBackground(context, mouseX, mouseY, deltaTicks); From 6923ad4eaffb90e000e840371a07f4504ca7cf3d Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Fri, 3 Oct 2025 09:51:27 -0400 Subject: [PATCH 15/20] chore: add javadocs to Scissor --- src/main/java/dev/cigarette/gui/Scissor.java | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/Scissor.java b/src/main/java/dev/cigarette/gui/Scissor.java index ab657057..8bb50cec 100644 --- a/src/main/java/dev/cigarette/gui/Scissor.java +++ b/src/main/java/dev/cigarette/gui/Scissor.java @@ -4,14 +4,44 @@ import java.util.Stack; +/** + * Custom scissor utility for screen rendering. + */ public class Scissor { + /** + * An exclusive (non-additive) scissor. Use {@code apply()} to activate and {@code remove()} to deactivate. + */ private static class Bound { + /** + * The draw context this scissor is attached to. + */ DrawContext context; + /** + * The left edge of this bounding box. + */ int left; + /** + * The top edge of this bounding box. + */ int top; + /** + * The right edge of this bounding box. + */ int right; + /** + * The bottom edge of this bounding box. + */ int bottom; + /** + * Creates a new exclusive scissor. + * + * @param context The draw context to apply the scissor to + * @param left The left edge of the bounding box + * @param top The top edge of the bounding box + * @param right The right edge of the bounding box + * @param bottom The bottom edge of the bounding box + */ Bound(DrawContext context, int left, int top, int right, int bottom) { this.context = context; this.left = left; @@ -20,11 +50,17 @@ private static class Bound { this.bottom = bottom; } + /** + * Activate this scissor. This does not deactivate any other scissors that are applied. + */ void apply() { if (this.context == null) return; this.context.enableScissor(left, top, right, bottom); } + /** + * Deactivate this scissor. + */ void remove() { if (this.context == null) return; this.context.disableScissor(); @@ -33,6 +69,15 @@ void remove() { private static final Stack exclusiveScissors = new Stack<>(); + /** + * Push an exclusive (non-additive) scissor to a {@code DrawContext}. + * + * @param context The draw context to activate the scissor on + * @param left The left edge of the bounding box + * @param top The top edge of the bounding box + * @param right The right edge of the bounding box + * @param bottom The bottom edge of the bounding box + */ public static void pushExclusive(DrawContext context, int left, int top, int right, int bottom) { Bound bound = new Bound(context, left, top, right, bottom); @@ -45,6 +90,9 @@ public static void pushExclusive(DrawContext context, int left, int top, int rig bound.apply(); } + /** + * Pop the top-most exclusive scissor from the stack. + */ public static void popExclusive() { if (exclusiveScissors.isEmpty()) return; Bound latest = exclusiveScissors.pop(); From 2f2f6f4c938b1e51ff28c4a40e724740cc8f9c67 Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Fri, 3 Oct 2025 10:08:00 -0400 Subject: [PATCH 16/20] chore: add remaining javadocs to widget class definitions --- .../java/dev/cigarette/gui/widget/ColorDropdownWidget.java | 6 ++++++ .../java/dev/cigarette/gui/widget/ColorSquareWidget.java | 3 +++ src/main/java/dev/cigarette/gui/widget/DraggableWidget.java | 3 +++ src/main/java/dev/cigarette/gui/widget/DropdownWidget.java | 6 ++++++ src/main/java/dev/cigarette/gui/widget/KeybindWidget.java | 3 +++ src/main/java/dev/cigarette/gui/widget/SliderWidget.java | 3 +++ src/main/java/dev/cigarette/gui/widget/TextWidget.java | 3 +++ .../java/dev/cigarette/gui/widget/ToggleKeybindWidget.java | 3 +++ src/main/java/dev/cigarette/gui/widget/ToggleWidget.java | 3 +++ 9 files changed, 33 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java b/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java index f653ac44..8b86cf20 100644 --- a/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java @@ -4,6 +4,12 @@ import net.minecraft.client.gui.DrawContext; import org.jetbrains.annotations.Nullable; +/** + * An extension on {@code DropdownWidget} pre-made for color configuration. + * + * @param The type of children this widget stores. Use {@code Widget extends BaseWidget} to allow any types as children. + * @param The custom state this widget stores. Use {@code BaseWidget.Stateless} for widgets that should not hold state. + */ public class ColorDropdownWidget, StateType> extends DropdownWidget { /** * Additional header widget to render the color state from the sliders. diff --git a/src/main/java/dev/cigarette/gui/widget/ColorSquareWidget.java b/src/main/java/dev/cigarette/gui/widget/ColorSquareWidget.java index 3e47161c..f4cdd60b 100644 --- a/src/main/java/dev/cigarette/gui/widget/ColorSquareWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ColorSquareWidget.java @@ -2,6 +2,9 @@ import net.minecraft.client.gui.DrawContext; +/** + * A widget that only renders a colored square. + */ public class ColorSquareWidget extends BaseWidget { /** * Creates a widget whose only purpose is to render a colored square. diff --git a/src/main/java/dev/cigarette/gui/widget/DraggableWidget.java b/src/main/java/dev/cigarette/gui/widget/DraggableWidget.java index ef437055..e7d731ed 100644 --- a/src/main/java/dev/cigarette/gui/widget/DraggableWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/DraggableWidget.java @@ -11,6 +11,9 @@ import org.jetbrains.annotations.Nullable; import org.lwjgl.glfw.GLFW; +/** + * A widget that can be dragged around the screen. + */ public class DraggableWidget extends BaseWidget { public interface DragCallback { void updateParentPosition(int newX, int newY, int deltaX, int deltaY); diff --git a/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java b/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java index 92a9b940..a632b077 100644 --- a/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java @@ -9,6 +9,12 @@ import org.joml.Quaternionf; import org.lwjgl.glfw.GLFW; +/** + * A dropdown widget which can show and hide children widgets. + * + * @param The type of children this widget stores. Use {@code Widget extends BaseWidget} to allow any types as children. + * @param The custom state this widget stores. Use {@code BaseWidget.Stateless} for widgets that should not hold state. + */ public class DropdownWidget, StateType> extends PassthroughWidget, BaseWidget.Stateless> { /** diff --git a/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java b/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java index f19bf64a..1446732e 100644 --- a/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java @@ -16,6 +16,9 @@ import java.util.UUID; import java.util.function.Consumer; +/** + * A widget that lets the user bind a key. + */ public class KeybindWidget extends BaseWidget { /** * The internal Minecraft KeyBinding. diff --git a/src/main/java/dev/cigarette/gui/widget/SliderWidget.java b/src/main/java/dev/cigarette/gui/widget/SliderWidget.java index 50c30643..48a9e0ee 100644 --- a/src/main/java/dev/cigarette/gui/widget/SliderWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/SliderWidget.java @@ -10,6 +10,9 @@ import java.util.function.Consumer; +/** + * A widget that holds a value that be adjusted by a slider. + */ public class SliderWidget extends BaseWidget { /** * The amount of padding on the left and right side of the sliders bounding box to prevent the slider bar from reaching the border. diff --git a/src/main/java/dev/cigarette/gui/widget/TextWidget.java b/src/main/java/dev/cigarette/gui/widget/TextWidget.java index 28079fab..8ae7a603 100644 --- a/src/main/java/dev/cigarette/gui/widget/TextWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/TextWidget.java @@ -6,6 +6,9 @@ import net.minecraft.client.gui.DrawContext; import org.jetbrains.annotations.Nullable; +/** + * A widget that only renders text. + */ public class TextWidget extends BaseWidget { /** * Whether a line should be rendered at the bottom of this widget's bounding box. diff --git a/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java b/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java index af77a138..848e9593 100644 --- a/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java @@ -8,6 +8,9 @@ import java.util.function.Consumer; +/** + * A widget that can be toggled by the user and lets a key be bound. + */ public class ToggleKeybindWidget extends ToggleWidget { /** * The {@code KeybindWidget} for handling configuration of the keybind. diff --git a/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java b/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java index d89136c4..7d291aac 100644 --- a/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java @@ -12,6 +12,9 @@ import java.util.function.Consumer; +/** + * A widget that can be toggled by the user. + */ public class ToggleWidget extends BaseWidget { /** * The max number of ticks the hover animation runs for. From 96ba29da50ded4e08614fe5ca94566dc17c97c09 Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Fri, 3 Oct 2025 10:26:07 -0400 Subject: [PATCH 17/20] chore: add javadocs to CategoryInstance --- .../dev/cigarette/gui/CategoryInstance.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/CategoryInstance.java b/src/main/java/dev/cigarette/gui/CategoryInstance.java index f398f137..99239487 100644 --- a/src/main/java/dev/cigarette/gui/CategoryInstance.java +++ b/src/main/java/dev/cigarette/gui/CategoryInstance.java @@ -6,11 +6,30 @@ import java.util.HashSet; +/** + * A category that groups modules together to be rendered by the GUI. + */ public class CategoryInstance { + /** + * The root widget that contains each module's top-level widget for rendering. + */ public final ScrollableWidget> widget; + /** + * The list of each module attached to this category. + */ public final HashSet> children = new HashSet<>(); + /** + * Whether this category is expanded or collapsed. + */ public boolean expanded = false; + /** + * Creates a new category to group modules. + * + * @param displayName The text to display in the header of the category. + * @param x The initial X position of this category + * @param y The initial Y position of this category + */ public CategoryInstance(String displayName, int x, int y) { this.widget = new ScrollableWidget<>(x, y); this.widget.setHeader(displayName, () -> { @@ -19,6 +38,11 @@ public CategoryInstance(String displayName, int x, int y) { this.widget.alphabetic(); } + /** + * Attaches a list of modules to this category. + * + * @param children The list of modules to attach + */ public void attach(BaseModule... children) { BaseWidget[] childWidgets = new BaseWidget[children.length]; for (int i = 0; i < children.length; i++) { From c1108af8ffdd4c624dfe3e02e5e792345900bdab Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Fri, 3 Oct 2025 10:30:57 -0400 Subject: [PATCH 18/20] chore: add javadocs to RenderUtil --- src/main/java/dev/cigarette/gui/RenderUtil.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/dev/cigarette/gui/RenderUtil.java b/src/main/java/dev/cigarette/gui/RenderUtil.java index d03ab3d9..dd1cf0e9 100644 --- a/src/main/java/dev/cigarette/gui/RenderUtil.java +++ b/src/main/java/dev/cigarette/gui/RenderUtil.java @@ -2,15 +2,26 @@ import com.mojang.blaze3d.systems.RenderSystem; +/** + * Custom utilities for screen rendering. + */ public final class RenderUtil { private RenderUtil() {} + /** + * Set the opacity of the renderer. + * + * @param alpha The opacity to set, between 0 and 1 + */ public static void pushOpacity(float alpha) { if (alpha < 0f) alpha = 0f; if (alpha > 1f) alpha = 1f; RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, alpha); } + /** + * Reset the opacity of the renderer. + */ public static void popOpacity() { RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); } From f63bfb606b00a3e3b69ad1183071086b13a19393 Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Fri, 3 Oct 2025 10:37:51 -0400 Subject: [PATCH 19/20] chore: fix missing javadoc and errors --- src/main/java/dev/cigarette/gui/widget/DropdownWidget.java | 2 +- src/main/java/dev/cigarette/gui/widget/KeybindWidget.java | 4 ++-- src/main/java/dev/cigarette/gui/widget/ScrollableWidget.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java b/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java index a632b077..1bbef301 100644 --- a/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java @@ -48,7 +48,7 @@ public class DropdownWidget, StateType> */ private double rotateOffsetRad = 0.0; /** - * + * The time it takes in milliseconds for a full rotation of the dropdown indicator. */ private static final int ROTATION_PERIOD_MS = 2000; diff --git a/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java b/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java index 1446732e..cf168ccb 100644 --- a/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/KeybindWidget.java @@ -88,7 +88,7 @@ protected void toggleBinding() { } /** - * {@return whether this widget is currently being binded by the user} + * {@return whether this widget is currently being bound by the user} */ protected boolean isBinding() { return CigaretteScreen.bindingKey == this; @@ -113,7 +113,7 @@ public void registerConfigKeyAnd(String key, Consumer loadedState) { } /** - * Captures a mouse click to toggle whether the keybind is being binded. + * Captures a mouse click to toggle whether the keybind is being bound. * * @param mouseX the X coordinate of the mouse * @param mouseY the Y coordinate of the mouse diff --git a/src/main/java/dev/cigarette/gui/widget/ScrollableWidget.java b/src/main/java/dev/cigarette/gui/widget/ScrollableWidget.java index 2bde8588..5c4d45df 100644 --- a/src/main/java/dev/cigarette/gui/widget/ScrollableWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ScrollableWidget.java @@ -12,7 +12,7 @@ import java.util.Objects; /** - * Extends a scrollable widget which provides scrolling functionality. + * A scrollable widget which provides scrolling functionality. * * @param The type of children this widget stores. Use {@code Widget extends BaseWidget} to allow any types as children. */ From c4e0f09899f2391f07c305c227265d7517e2aeda Mon Sep 17 00:00:00 2001 From: UndercoverGoose <53491740+UndercoverGoose@users.noreply.github.com> Date: Wed, 8 Oct 2025 14:11:42 -0400 Subject: [PATCH 20/20] replace code docs with links where applicable --- .../dev/cigarette/gui/CigaretteScreen.java | 11 +++++----- src/main/java/dev/cigarette/gui/Scissor.java | 4 ++-- .../dev/cigarette/gui/widget/BaseWidget.java | 12 +++++----- .../gui/widget/ColorDropdownWidget.java | 22 +++++++++---------- .../cigarette/gui/widget/DraggableWidget.java | 2 +- .../cigarette/gui/widget/DropdownWidget.java | 2 +- .../gui/widget/PassthroughWidget.java | 6 ++--- .../gui/widget/ScrollableWidget.java | 10 ++++----- .../cigarette/gui/widget/SliderWidget.java | 2 +- .../gui/widget/ToggleKeybindWidget.java | 4 ++-- .../cigarette/gui/widget/ToggleWidget.java | 2 +- 11 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/main/java/dev/cigarette/gui/CigaretteScreen.java b/src/main/java/dev/cigarette/gui/CigaretteScreen.java index a21cbb56..0d084078 100644 --- a/src/main/java/dev/cigarette/gui/CigaretteScreen.java +++ b/src/main/java/dev/cigarette/gui/CigaretteScreen.java @@ -5,6 +5,7 @@ import dev.cigarette.gui.widget.BaseWidget; import dev.cigarette.gui.widget.KeybindWidget; import dev.cigarette.gui.widget.ScrollableWidget; +import dev.cigarette.gui.widget.ToggleKeybindWidget; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.Element; @@ -33,7 +34,7 @@ public class CigaretteScreen extends Screen { */ public static final int BACKGROUND_COLOR = 0xFF1A1A1A; /** - * Dark background color usually used in gradients with {@code BACKGROUND_COLOR}. (Black) + * Dark background color usually used in gradients with {@link #BACKGROUND_COLOR}. (Black) */ public static final int DARK_BACKGROUND_COLOR = 0xFF000000; /** @@ -76,7 +77,7 @@ public class CigaretteScreen extends Screen { private static final int OPEN_DISTANCE_PX = 24; /** - * The length of the closing animation as a multiplier of {@code OPEN_DURATION_S}. + * The length of the closing animation as a multiplier of {@link #OPEN_DURATION_S}. */ private static final double CLOSE_DURATION_FACTOR = 0.6; private static final double CLOSE_STAGGER_FACTOR = 0.6; @@ -85,7 +86,7 @@ public class CigaretteScreen extends Screen { */ private int categoryCount = 0; /** - * Reference to a {@code KeybindWidget} or {@code ToggleKeybindWidget} that is actively listening for keys to bind. + * Reference to a {@link KeybindWidget} or {@link ToggleKeybindWidget} that is actively listening for keys to bind. */ public static @Nullable KeybindWidget bindingKey = null; @@ -204,7 +205,7 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { /** * {@return whether the provided widget can be hovered} If so, that widget is set as the hovered widget. - *

A widget must call {@code captureHover()} to be hoverable.

+ *

A widget must call {@link BaseWidget#captureHover() captureHover()} to be hoverable.

* * @param obj The widget to check if it can be hovered */ @@ -217,7 +218,7 @@ public static boolean isHoverable(Object obj) { } /** - * Replaces the built-in {@code Screen::render} method. Handles animations and category rendering for the GUI. + * Replaces the built-in {@link Screen#render(DrawContext, int, int, float) Screen.render()} method. Handles animations and category rendering for the GUI. * * @param context The current draw context * @param mouseX Current mouse X position diff --git a/src/main/java/dev/cigarette/gui/Scissor.java b/src/main/java/dev/cigarette/gui/Scissor.java index 8bb50cec..c59c4243 100644 --- a/src/main/java/dev/cigarette/gui/Scissor.java +++ b/src/main/java/dev/cigarette/gui/Scissor.java @@ -9,7 +9,7 @@ */ public class Scissor { /** - * An exclusive (non-additive) scissor. Use {@code apply()} to activate and {@code remove()} to deactivate. + * An exclusive (non-additive) scissor. Use {@link #apply()} to activate and {@link #remove()} to deactivate. */ private static class Bound { /** @@ -70,7 +70,7 @@ void remove() { private static final Stack exclusiveScissors = new Stack<>(); /** - * Push an exclusive (non-additive) scissor to a {@code DrawContext}. + * Push an exclusive (non-additive) scissor to a {@link DrawContext}. * * @param context The draw context to activate the scissor on * @param left The left edge of the bounding box diff --git a/src/main/java/dev/cigarette/gui/widget/BaseWidget.java b/src/main/java/dev/cigarette/gui/widget/BaseWidget.java index 671e588c..947158aa 100644 --- a/src/main/java/dev/cigarette/gui/widget/BaseWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/BaseWidget.java @@ -15,7 +15,7 @@ /** * Extends the base widget providing default functionality for saving/loading custom state from the config. * - * @param The custom state this widget stores. Use {@code BaseWidget.Stateless} for widgets that should not hold state. + * @param The custom state this widget stores. Use {@link BaseWidget.Stateless} for widgets that should not hold state. */ public abstract class BaseWidget extends ClickableWidget { /** @@ -203,7 +203,7 @@ public void unfocus() { } /** - * Sets the hover tooltip of this widget. The tooltip will only be rendered if {@code captureHover} was called allowing this widget to capture hovering events. + * Sets the hover tooltip of this widget. The tooltip will only be rendered if {@link #captureHover()} was called allowing this widget to capture hovering events. *

For basic tooltips, you can use {@code Tooltip.of(Text.literal(String))} to convert a String to a Tooltip.

* * @param tooltip The tooltip @@ -252,7 +252,7 @@ public BaseWidget withDefault(StateType state) { } /** - * Replacement method for the {@code ClickableWidget::render} method that cannot be overridden. Automatically handles rendering tooltips when this widget is hovered and the top-most widget. Also pulls the bounding box of this widget and supplies the values to the {@code render} method for cleaner code. + * Replacement method for the {@link ClickableWidget#render(DrawContext, int, int, float) ClickableWidget.render()} method that cannot be overridden. Automatically handles rendering tooltips when this widget is hovered and the top-most widget. Also pulls the bounding box of this widget and supplies the values to the {@link #render(DrawContext, boolean, int, int, float, int, int, int, int) render()} method for cleaner code. * * @param context The draw context to pass through * @param mouseX The mouse X position to pass through @@ -267,8 +267,8 @@ public void _render(DrawContext context, int mouseX, int mouseY, float deltaTick } /** - * Alias that calls {@code _render} but looks nicer. - *

Automatically handles rendering tooltips when this widget is hovered and the top-most widget. Also pulls the bounding box of this widget and supplies the values to the {@code render} method for cleaner code.

+ * Alias that calls {@link #_render(DrawContext, int, int, float) _render()} but looks nicer. + *

Automatically handles rendering tooltips when this widget is hovered and the top-most widget. Also pulls the bounding box of this widget and supplies the values to the {@link #render(DrawContext, boolean, int, int, float, int, int, int, int) render()} method for cleaner code.

* * @param context The draw context to pass through * @param mouseX The mouse X position to pass through @@ -281,7 +281,7 @@ protected void renderWidget(DrawContext context, int mouseX, int mouseY, float d } /** - * The custom rendering method that replaces the built-in {@code ClickableWidget::render} method. + * The custom rendering method that replaces the built-in {@link ClickableWidget#render(DrawContext, int, int, float) ClickableWidget.render()} method. * * @param context The current draw context * @param hovered Whether this widget is hovered by the mouse diff --git a/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java b/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java index 8b86cf20..281fbdf1 100644 --- a/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ColorDropdownWidget.java @@ -5,10 +5,10 @@ import org.jetbrains.annotations.Nullable; /** - * An extension on {@code DropdownWidget} pre-made for color configuration. + * An extension on {@link DropdownWidget} pre-made for color configuration. * * @param The type of children this widget stores. Use {@code Widget extends BaseWidget} to allow any types as children. - * @param The custom state this widget stores. Use {@code BaseWidget.Stateless} for widgets that should not hold state. + * @param The custom state this widget stores. Use {@link BaseWidget.Stateless} for widgets that should not hold state. */ public class ColorDropdownWidget, StateType> extends DropdownWidget { /** @@ -56,7 +56,7 @@ public int getStateRGB() { /** * {@return the toggled state of this widget} * - * @throws IllegalStateException If the header of this widget is not an instance of {@code ToggleWidget} + * @throws IllegalStateException If the header of this widget is not an instance of {@link ToggleWidget} */ public boolean getToggleState() { if (this.header instanceof ToggleWidget) { @@ -66,7 +66,7 @@ public boolean getToggleState() { } /** - * Creates a dropdown widget pre-made for color configuration. Has a {@code ToggleWidget} and {@code ColorSquareWidget} header, and {@code SliderWidget} children for customizing the selected color. + * Creates a dropdown widget pre-made for color configuration. Has a {@link ToggleWidget} and {@link ColorSquareWidget} header, and {@link SliderWidget} children for customizing the selected color. * * @param message The text to display inside this widget * @param tooltip The tooltip to render when this widget is hovered @@ -95,7 +95,7 @@ public ColorDropdownWidget withDefaultColor(int argb) { } /** - * Sets the state and stored default state of the heading {@code ToggleWidget}. + * Sets the state and stored default state of the heading {@link ToggleWidget}. * * @param state The default state to set * @return This widget for method chaining @@ -144,11 +144,11 @@ private ColorDropdownWidget attachChildren() { } /** - * Generator for modules using this as a top-level widget. Creates a togglable {@code ColorDropdownWidget}. + * Generator for modules using this as a top-level widget. Creates a togglable {@link ColorDropdownWidget}. * * @param displayName The text to display inside this widget * @param tooltip The tooltip to render when this widget is hovered - * @return A {@code GeneratedWidgets} object for use in {@code BaseModule} constructing + * @return A {@link BaseModule.GeneratedWidgets} object for use in {@link BaseModule} constructing */ public static BaseModule.GeneratedWidgets module(String displayName, @Nullable String tooltip) { ColorDropdownWidget wrapper = new ColorDropdownWidget<>(displayName, tooltip); @@ -158,11 +158,11 @@ public static BaseModule.GeneratedWidgets module(String d } /** - * Creates and returns a new togglable {@code ColorDropdownWidget}. + * Creates and returns a new togglable {@link ColorDropdownWidget}. * * @param displayName The text to display inside this widget * @param tooltip The tooltip to render when this widget is hovered - * @return the new widget with a {@code ToggleWidget} attached as the header + * @return the new widget with a {@link ToggleWidget} attached as the header */ public static ColorDropdownWidget buildToggle(String displayName, @Nullable String tooltip) { ColorDropdownWidget wrapper = new ColorDropdownWidget<>(displayName, tooltip); @@ -172,11 +172,11 @@ public static ColorDropdownWidget buildToggle(String disp } /** - * Creates and returns a new {@code ColorDropdownWidget} with only the color configuration, no toggling. + * Creates and returns a new {@link ColorDropdownWidget} with only the color configuration, no toggling. * * @param displayName The text to display inside this widget * @param tooltip The tooltip to render when this widget is hovered - * @return thw new widget with a {@code TextWidget} attached as the header + * @return thw new widget with a {@link TextWidget} attached as the header */ public static ColorDropdownWidget buildText(String displayName, @Nullable String tooltip) { ColorDropdownWidget wrapper = new ColorDropdownWidget<>(displayName, tooltip); diff --git a/src/main/java/dev/cigarette/gui/widget/DraggableWidget.java b/src/main/java/dev/cigarette/gui/widget/DraggableWidget.java index e7d731ed..eee326ae 100644 --- a/src/main/java/dev/cigarette/gui/widget/DraggableWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/DraggableWidget.java @@ -52,7 +52,7 @@ public interface ClickCallback { */ private @Nullable ClickCallback clickCallback = null; /** - * If this widget is responsible for a {@code ScrollableWidget}'s visibility, this signals whether that widget is collapsed. Used for rounding the bottom corners of this widget when collapsed. + * If this widget is responsible for a {@link ScrollableWidget}'s visibility, this signals whether that widget is collapsed. Used for rounding the bottom corners of this widget when collapsed. */ public boolean expanded = false; diff --git a/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java b/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java index 1bbef301..99e32571 100644 --- a/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/DropdownWidget.java @@ -13,7 +13,7 @@ * A dropdown widget which can show and hide children widgets. * * @param The type of children this widget stores. Use {@code Widget extends BaseWidget} to allow any types as children. - * @param The custom state this widget stores. Use {@code BaseWidget.Stateless} for widgets that should not hold state. + * @param The custom state this widget stores. Use {@link BaseWidget.Stateless} for widgets that should not hold state. */ public class DropdownWidget, StateType> extends PassthroughWidget, BaseWidget.Stateless> { diff --git a/src/main/java/dev/cigarette/gui/widget/PassthroughWidget.java b/src/main/java/dev/cigarette/gui/widget/PassthroughWidget.java index 23467076..3cf9d35d 100644 --- a/src/main/java/dev/cigarette/gui/widget/PassthroughWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/PassthroughWidget.java @@ -11,12 +11,12 @@ * Extends the passthrough widget which holds children widgets and automatically forwards events and rendering to them. * * @param The type of children this widget stores. Use {@code Widget extends BaseWidget} to allow any types as children. - * @param The custom state this widget stores. Use {@code BaseWidget.Stateless} for widgets that should not hold state. + * @param The custom state this widget stores. Use {@link BaseWidget.Stateless} for widgets that should not hold state. */ public abstract class PassthroughWidget, StateType> extends BaseWidget { /** * The children that this widget is the parent of, mapped by String to the actual child reference for sorting capabilities. - *

There is no default methods for adding children as defined in {@code PassthroughWidget}, so check the subclasses for implementation details.

+ *

There is no default methods for adding children as defined in {@link PassthroughWidget}, so check the subclasses for implementation details.

*/ protected Map children = new LinkedHashMap<>(); /** @@ -58,7 +58,7 @@ public PassthroughWidget(String message) { } /** - * Switches the {@code Map} type of {@code children} to a {@code TreeMap} which automatically sorts by the {@code String} keys. + * Switches the {@link Map} type of {@link #children} to a {@link TreeMap} which automatically sorts by the {@link String} keys. */ public void alphabetic() { this.children = new TreeMap<>(this.children); diff --git a/src/main/java/dev/cigarette/gui/widget/ScrollableWidget.java b/src/main/java/dev/cigarette/gui/widget/ScrollableWidget.java index 5c4d45df..f386b9aa 100644 --- a/src/main/java/dev/cigarette/gui/widget/ScrollableWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ScrollableWidget.java @@ -71,7 +71,7 @@ public class ScrollableWidget> */ private static final int MAX_TICKS_ON_OPEN = 20; /** - * Callback triggered when the header is clicked to toggle the {@code expanded} state of this widget. + * Callback triggered when the header is clicked to toggle the {@link #expanded} state of this widget. */ private @Nullable Runnable onToggleExpand; /** @@ -140,7 +140,7 @@ public BaseWidget withXY(int x, int y) { } /** - * {@return whether the container should be scrollable} Updates {@code shouldScroll}. + * {@return whether the container should be scrollable} Updates {@link #shouldScroll}. */ private boolean updateShouldScroll() { this.shouldScroll = ((children == null ? 0 : children.size()) + (header != null ? 1 : 0)) @@ -165,7 +165,7 @@ public final ScrollableWidget setChildren(@Nullable Widgets... children } /** - * Sets the header text of this widget. This creates a {@code DraggableWidget} that renders at the top of the widget that also controls its position. + * Sets the header text of this widget. This creates a {@link DraggableWidget} that renders at the top of the widget that also controls its position. * * @param headerText The text to display * @return This widget for method chaining @@ -175,7 +175,7 @@ public ScrollableWidget setHeader(@Nullable String headerText) { } /** - * Sets the header text of this widget. This creates a {@code DraggableWidget} that renders at the top of the widget that also controls its position. + * Sets the header text of this widget. This creates a {@link DraggableWidget} that renders at the top of the widget that also controls its position. * * @param headerText The text to display * @param onToggleExpand The callback to run when the header is right-clicked @@ -206,7 +206,7 @@ public ScrollableWidget setHeader(@Nullable String headerText, @Nullabl } /** - * Sets all the children width and heights. This also triggers {@code updateShouldScroll} to set whether there needs to be a scrollbar. + * Sets all the children width and heights. This also triggers {@link #updateShouldScroll()} to set whether there needs to be a scrollbar. * * @return This widget for method chaining */ diff --git a/src/main/java/dev/cigarette/gui/widget/SliderWidget.java b/src/main/java/dev/cigarette/gui/widget/SliderWidget.java index 48a9e0ee..04456b5a 100644 --- a/src/main/java/dev/cigarette/gui/widget/SliderWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/SliderWidget.java @@ -57,7 +57,7 @@ public void setState(double state) { } /** - * Updates the raw state of the slider do the {@code decimalPlaces} degree of accuracy. + * Updates the raw state of the slider do the {@link #decimalPlaces} degree of accuracy. *

This returns prematurely if the state is not within bounds. Does not trigger any callbacks by itself.

* * @param state The new state to set to this widget diff --git a/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java b/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java index 848e9593..3af56ca7 100644 --- a/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ToggleKeybindWidget.java @@ -13,7 +13,7 @@ */ public class ToggleKeybindWidget extends ToggleWidget { /** - * The {@code KeybindWidget} for handling configuration of the keybind. + * The {@link KeybindWidget} for handling configuration of the keybind. */ protected KeybindWidget widget; @@ -56,7 +56,7 @@ public KeyBinding getKeybind() { * * @param displayName The text to display inside this widget * @param tooltip The tooltip to render when this widget is hovered - * @return A {@code GeneratedWidgets} object for use in {@code BaseModule} constructing + * @return A {@link BaseModule.GeneratedWidgets} object for use in {@link BaseModule} constructing */ public static BaseModule.GeneratedWidgets keybindModule(String displayName, @Nullable String tooltip) { ToggleKeybindWidget widget = new ToggleKeybindWidget(displayName, tooltip); diff --git a/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java b/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java index 7d291aac..9cab2628 100644 --- a/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java +++ b/src/main/java/dev/cigarette/gui/widget/ToggleWidget.java @@ -90,7 +90,7 @@ public ToggleWidget withDefaultState(boolean state) { * * @param displayName The text to display inside this widget * @param tooltip The tooltip to render when this widget is hovered - * @return A {@code GeneratedWidgets} object for use in {@code BaseModule} constructing + * @return A {@link BaseModule.GeneratedWidgets} object for use in {@link BaseModule} constructing */ public static BaseModule.GeneratedWidgets module(String displayName, @Nullable String tooltip) { DropdownWidget wrapper = new DropdownWidget<>(displayName, tooltip);