Class AbstractGui

java.lang.Object
gaiasky.gui.main.AbstractGui
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, IObserver, IGui
Direct Known Subclasses:
DebugGui, FrameOutputGui, GamepadGui, LoadingGui, MainGui, SpacecraftGui, StereoGui, TimeGui, WelcomeGui, WelcomeGuiVR

public abstract class AbstractGui extends Object implements IObserver, IGui
Base implementation for top-level GUIs. Contains the essentials used by (almost) all.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
     
    protected int
     
    protected com.badlogic.gdx.Graphics
    Graphics instance.
    protected com.badlogic.gdx.utils.Array<IGuiInterface>
    The GUI interfaces, if any.
    protected final Object
    Lock for sync.
    protected String
    The name of this GUI.
    static final com.badlogic.gdx.utils.PoolManager
     
    protected com.badlogic.gdx.scenes.scene2d.ui.Skin
    The skin to use.
    protected com.badlogic.gdx.scenes.scene2d.Stage
    The user interface stage.
    protected float
    Units per pixel, 1/uiScale.
    protected boolean
    Whether we're in VR mode.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractGui(com.badlogic.gdx.Graphics graphics, Float unitsPerPixel)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Removes the focus from this GUI and returns true if the focus was in the GUI, false otherwise.
    protected void
     
    void
     
    com.badlogic.gdx.scenes.scene2d.Actor
    Returns the first actor found with the specified name.
    int
     
    int
     
    com.badlogic.gdx.scenes.scene2d.Stage
    Returns the stage
     
    float
    Gets the units per pixel of this GUI.
    boolean
    Returns whether this GUI is a VR gui.
    boolean
    Returns whether this GUI must be drawn or not
    void
    notify(Event event, Object source, Object... data)
    Event notification call.
    protected abstract void
    Adds the already created GUI objects to the stage.
    void
    render(int rw, int rh)
    Renders this GUI
    void
    resize(int width, int height)
    Resizes this GUI to the given values at the end of the current loop
    void
    resizeImmediate(int width, int height)
    Resizes without waiting for the current loop to finish
    void
    setBackBufferSize(int width, int height)
    Sets the back buffer size.
    void
    Sets the visibility state of the component entities
    void
    setVR(boolean vr)
    Whether this GUI is to be used in VR mode
    void
    update(double dt)
    Updates the GUI
    boolean
    Updates the units-per-pixel value of this GUI.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface IGui

    doneLoading, initialize
    Modifier and Type
    Method
    Description
    void
    doneLoading(com.badlogic.gdx.assets.AssetManager assetManager)
    Hook that runs after the assets have been loaded.
    void
    initialize(com.badlogic.gdx.assets.AssetManager assetManager, com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
    Initializes the GUI, adding all the resources to the asset manager queue for loading
  • Field Details

    • POOLS

      public static final com.badlogic.gdx.utils.PoolManager POOLS
    • graphics

      protected com.badlogic.gdx.Graphics graphics
      Graphics instance.
    • stage

      protected com.badlogic.gdx.scenes.scene2d.Stage stage
      The user interface stage.
    • skin

      protected com.badlogic.gdx.scenes.scene2d.ui.Skin skin
      The skin to use.
    • interfaces

      protected com.badlogic.gdx.utils.Array<IGuiInterface> interfaces
      The GUI interfaces, if any.
    • name

      protected String name
      The name of this GUI.
    • vr

      protected boolean vr
      Whether we're in VR mode.
    • unitsPerPixel

      protected float unitsPerPixel
      Units per pixel, 1/uiScale. This only works with a screen viewport.
    • lock

      protected final Object lock
      Lock for sync.
    • backBufferWidth

      protected int backBufferWidth
    • backBufferHeight

      protected int backBufferHeight
  • Constructor Details

    • AbstractGui

      public AbstractGui(com.badlogic.gdx.Graphics graphics, Float unitsPerPixel)
  • Method Details

    • update

      public void update(double dt)
      Description copied from interface: IGui
      Updates the GUI
      Specified by:
      update in interface IGui
      Parameters:
      dt - Time in seconds since the last frame
    • render

      public void render(int rw, int rh)
      Description copied from interface: IGui
      Renders this GUI
      Specified by:
      render in interface IGui
      Parameters:
      rw - The render width
      rh - The render height
    • clearScreen

      protected void clearScreen()
    • getGuiStage

      public com.badlogic.gdx.scenes.scene2d.Stage getGuiStage()
      Description copied from interface: IGui
      Returns the stage
      Specified by:
      getGuiStage in interface IGui
      Returns:
      The stage
    • getName

      public String getName()
    • dispose

      public void dispose()
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
    • resize

      public void resize(int width, int height)
      Description copied from interface: IGui
      Resizes this GUI to the given values at the end of the current loop
      Specified by:
      resize in interface IGui
      Parameters:
      width - The new width
      height - The new height
    • resizeImmediate

      public void resizeImmediate(int width, int height)
      Description copied from interface: IGui
      Resizes without waiting for the current loop to finish
      Specified by:
      resizeImmediate in interface IGui
      Parameters:
      width - The new width
      height - The new height
    • rebuildGui

      protected abstract void rebuildGui()
      Adds the already created GUI objects to the stage.
    • cancelTouchFocus

      public boolean cancelTouchFocus()
      Description copied from interface: IGui
      Removes the focus from this GUI and returns true if the focus was in the GUI, false otherwise.
      Specified by:
      cancelTouchFocus in interface IGui
      Returns:
      true if the focus was in the GUI, false otherwise.
    • findActor

      public com.badlogic.gdx.scenes.scene2d.Actor findActor(String name)
      Description copied from interface: IGui
      Returns the first actor found with the specified name. Note this recursively compares the name of every actor in the GUI.
      Specified by:
      findActor in interface IGui
      Returns:
      The actor if it exists, null otherwise.
    • setVisibilityToggles

      public void setVisibilityToggles(ComponentTypes.ComponentType[] entities, ComponentTypes visible)
      Description copied from interface: IGui
      Sets the visibility state of the component entities
      Specified by:
      setVisibilityToggles in interface IGui
      Parameters:
      entities - The entities
      visible - The states
    • notify

      public void notify(Event event, Object source, Object... data)
      Description copied from interface: IObserver
      Event notification call.
      Specified by:
      notify in interface IObserver
      Parameters:
      event - The event type.
      source - The source object, if any.
      data - The data associated with this event.
    • setVR

      public void setVR(boolean vr)
      Description copied from interface: IGui
      Whether this GUI is to be used in VR mode
      Specified by:
      setVR in interface IGui
      Parameters:
      vr - Vr mode is active
    • isVR

      public boolean isVR()
      Description copied from interface: IGui
      Returns whether this GUI is a VR gui.
      Specified by:
      isVR in interface IGui
      Returns:
      Is this a VR gui?
    • mustDraw

      public boolean mustDraw()
      Description copied from interface: IGui
      Returns whether this GUI must be drawn or not
      Specified by:
      mustDraw in interface IGui
      Returns:
      Whether this is visible
    • updateUnitsPerPixel

      public boolean updateUnitsPerPixel(float upp)
      Description copied from interface: IGui
      Updates the units-per-pixel value of this GUI. This defines the size of the GUI.
      Specified by:
      updateUnitsPerPixel in interface IGui
    • getUnitsPerPixel

      public float getUnitsPerPixel()
      Description copied from interface: IGui
      Gets the units per pixel of this GUI.
      Specified by:
      getUnitsPerPixel in interface IGui
      Returns:
      The units per pixel value.
    • setBackBufferSize

      public void setBackBufferSize(int width, int height)
      Description copied from interface: IGui
      Sets the back buffer size.
      Specified by:
      setBackBufferSize in interface IGui
    • getBackBufferWidth

      public int getBackBufferWidth()
    • getBackBufferHeight

      public int getBackBufferHeight()