Class MainVRGui

java.lang.Object
gaiasky.gui.vr.MainVRGui
All Implemented Interfaces:
com.badlogic.gdx.InputProcessor, com.badlogic.gdx.utils.Disposable, IObserver, IGui, VRDeviceListener

public class MainVRGui extends Object implements VRDeviceListener, com.badlogic.gdx.InputProcessor, IGui, IObserver, com.badlogic.gdx.utils.Disposable
Creates and manages the VR UI and all its interactions with controllers.
  • Field Details

  • Constructor Details

    • MainVRGui

      public MainVRGui(com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
  • Method Details

    • initialize

      public void initialize(com.badlogic.gdx.assets.AssetManager manager, com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Description copied from interface: IGui
      Initializes the GUI, adding all the resources to the asset manager queue for loading
      Specified by:
      initialize in interface IGui
      Parameters:
      manager - The asset manager to load the resources with
      batch - The sprite batch to use for this GUI's stage
    • doneLoading

      public void doneLoading(com.badlogic.gdx.assets.AssetManager assetManager)
      Description copied from interface: IGui
      Hook that runs after the assets have been loaded. Completes the initialization process
      Specified by:
      doneLoading in interface IGui
      Parameters:
      assetManager - The asset manager
    • build

      public void build(com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
    • 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
    • contains

      public boolean contains(int x, int y, com.badlogic.gdx.math.Vector3[] points)
      Checks whether the quadrilateral or polygon defined by points contains the point [x,y].
      Parameters:
      x - The coordinate X of the point to test.
      y - The coordinate Y of the point to test.
      points - The points defining the polygon.
      Returns:
      Whether the point is in the polygon.
    • 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
    • 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
    • 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.
    • 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
    • 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
    • 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.
    • 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. The units-per-pixel is the same as 1/UI_SCALE.
      Specified by:
      updateUnitsPerPixel in interface IGui
    • setBackBufferSize

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

      public void dispose()
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
    • 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.
    • setScene

      public void setScene(Scene scene)
    • setSkin

      public void setSkin(com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
    • connected

      public void connected(VRContext.VRDevice device)
      Description copied from interface: VRDeviceListener
      A new VRContext.VRDevice has connected
      Specified by:
      connected in interface VRDeviceListener
    • disconnected

      public void disconnected(VRContext.VRDevice device)
      Description copied from interface: VRDeviceListener
      A VRContext.VRDevice has disconnected
      Specified by:
      disconnected in interface VRDeviceListener
    • buttonPressed

      public boolean buttonPressed(VRContext.VRDevice device, int button)
      Description copied from interface: VRDeviceListener
      A button was pressed on the VRContext.VRDevice
      Specified by:
      buttonPressed in interface VRDeviceListener
      Returns:
      True if the event was handled.
    • buttonReleased

      public boolean buttonReleased(VRContext.VRDevice device, int button)
      Description copied from interface: VRDeviceListener
      A button was released on the VRContext.VRDevice
      Specified by:
      buttonReleased in interface VRDeviceListener
      Returns:
      True if the event was handled.
    • buttonTouched

      public boolean buttonTouched(VRContext.VRDevice device, int button)
      Description copied from interface: VRDeviceListener
      A button was touched on the VRContext.VRDevice
      Specified by:
      buttonTouched in interface VRDeviceListener
      Returns:
      True if the event was handled.
    • buttonUntouched

      public boolean buttonUntouched(VRContext.VRDevice device, int button)
      Description copied from interface: VRDeviceListener
      A button was untouched on the VRContext.VRDevice
      Specified by:
      buttonUntouched in interface VRDeviceListener
      Returns:
      True if the event was handled.
    • axisMoved

      public boolean axisMoved(VRContext.VRDevice device, int axis, float valueX, float valueY)
      Description copied from interface: VRDeviceListener
      An axis was moved on the VRContext.VRDevice
      Specified by:
      axisMoved in interface VRDeviceListener
      Returns:
      True if the event was handled.
    • event

      public void event(int code)
      Description copied from interface: VRDeviceListener
      Unhandled event on the VRContext.VRDevice
      Specified by:
      event in interface VRDeviceListener
      Parameters:
      code - Event code
    • keyDown

      public boolean keyDown(int keycode)
      Specified by:
      keyDown in interface com.badlogic.gdx.InputProcessor
    • keyUp

      public boolean keyUp(int keycode)
      Specified by:
      keyUp in interface com.badlogic.gdx.InputProcessor
    • keyTyped

      public boolean keyTyped(char character)
      Specified by:
      keyTyped in interface com.badlogic.gdx.InputProcessor
    • touchDown

      public boolean touchDown(int screenX, int screenY, int pointer, int button)
      Specified by:
      touchDown in interface com.badlogic.gdx.InputProcessor
    • touchUp

      public boolean touchUp(int screenX, int screenY, int pointer, int button)
      Specified by:
      touchUp in interface com.badlogic.gdx.InputProcessor
    • touchDragged

      public boolean touchDragged(int screenX, int screenY, int pointer)
      Specified by:
      touchDragged in interface com.badlogic.gdx.InputProcessor
    • mouseMoved

      public boolean mouseMoved(int screenX, int screenY)
      Specified by:
      mouseMoved in interface com.badlogic.gdx.InputProcessor
    • scrolled

      public boolean scrolled(float amountX, float amountY)
      Specified by:
      scrolled in interface com.badlogic.gdx.InputProcessor