AbstractMoveableScreen
The AbstractMoveableScreen class extends Screen to provide a framework for creating editor screens with movable widgets. It handles widget rendering, input (dragging, clicking, scrolling), and context menus, enabling users to position and configure widgets interactively.
Class Variables
- WidgetRenderer widgetRenderer: Manages rendering and interaction for widgets on this screen. 
- GlobalConfig.get().getSnapSize(): Defines grid divisions for widget snapping during dragging (default: 100; higher values create smaller grids). 
Constructor
public AbstractMoveableScreen(Text title, WidgetRenderer renderer)- Parameters: - titlesets the screen title;- rendererprovides the widget renderer.
Key Methods
- onDisplayed(): Sets - widgetRenderer.isInEditorto- truewhen the screen opens.
- render(DrawContext, int, int, float): Renders the screen title, background (if no world), widgets via - widgetRenderer.renderWidgets, and tooltips if enabled in- GlobalConfig. Also renders context menus via- ContextMenuManager.
- close(): Resets - widgetRenderer.isInEditorto- false, calls- widgetRenderer.onCloseScreen, and closes context menus.
- mouseDragged(double, double, int, double, double): Handles widget dragging with snapping based on - GlobalConfig.get().getSnapSize().
- handleClickOnWidget(Widget, double, double, int): Customizable method for handling widget clicks (e.g., toggling visibility). 
- shouldPause(): Returns - falseby default, preventing game pause.
Input Handling
Overrides input methods (mouseClicked, mouseReleased, keyPressed, etc.) to delegate to widgetRenderer and ContextMenuManager, supporting widget dragging, context menu interactions, and keyboard controls (e.g., Delete/Backspace for widget actions).
Ensure widgetRenderer is initialized with widgets, or the screen will be empty.
Last updated
Was this helpful?
