Class LayerStack

java.lang.Object
com.github.darksoulq.abyssallib.world.gui.layer.LayerStack
All Implemented Interfaces:
GuiLayer

public class LayerStack extends Object implements GuiLayer
A composite GUI layer that manages a collection of sub-layers in a stack.

Only one layer from the stack is rendered at any given time. This class facilitates navigation through these layers, handling the cleanup of the previous layer before rendering the next one.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new LayerStack with the provided layers.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Cleans up the currently active layer.
    int
    Gets the index of the current active layer.
    void
    Forces a re-render on the next tick by invalidating the render cache.
    void
    next(GuiView view)
    Switches to the next layer in the stack, wrapping back to the start if necessary.
    void
    Switches to the previous layer in the stack, wrapping to the end if necessary.
    void
    Renders the currently active layer to the GUI view.
    void
    setIndex(GuiView view, int index)
    Jumps directly to a specific layer index in the stack.
    int
    Gets the total number of layers in the stack.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LayerStack

      public LayerStack(List<GuiLayer> layers)
      Constructs a new LayerStack with the provided layers.
      Parameters:
      layers - the list of layers to include in the stack
  • Method Details

    • next

      public void next(GuiView view)
      Switches to the next layer in the stack, wrapping back to the start if necessary.
      Parameters:
      view - the active GUI view context
    • previous

      public void previous(GuiView view)
      Switches to the previous layer in the stack, wrapping to the end if necessary.
      Parameters:
      view - the active GUI view context
    • setIndex

      public void setIndex(GuiView view, int index)
      Jumps directly to a specific layer index in the stack.
      Parameters:
      view - the active GUI view context
      index - the target index
    • renderTo

      public void renderTo(GuiView view)
      Renders the currently active layer to the GUI view.

      Rendering only occurs if the active index has changed since the last update.

      Specified by:
      renderTo in interface GuiLayer
      Parameters:
      view - the view instance to render into
    • cleanup

      public void cleanup(GuiView view)
      Cleans up the currently active layer.
      Specified by:
      cleanup in interface GuiLayer
      Parameters:
      view - the view instance being cleaned up
    • getIndex

      public int getIndex()
      Gets the index of the current active layer.
      Returns:
      the current index
    • size

      public int size()
      Gets the total number of layers in the stack.
      Returns:
      the layer count
    • invalidate

      public void invalidate()
      Forces a re-render on the next tick by invalidating the render cache.