Package gaiasky.gui.vr
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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
axisMoved
(VRContext.VRDevice device, int axis, float valueX, float valueY) An axis was moved on theVRContext.VRDevice
void
build
(com.badlogic.gdx.scenes.scene2d.ui.Skin skin) boolean
buttonPressed
(VRContext.VRDevice device, int button) A button was pressed on theVRContext.VRDevice
boolean
buttonReleased
(VRContext.VRDevice device, int button) A button was released on theVRContext.VRDevice
boolean
buttonTouched
(VRContext.VRDevice device, int button) A button was touched on theVRContext.VRDevice
boolean
buttonUntouched
(VRContext.VRDevice device, int button) A button was untouched on theVRContext.VRDevice
boolean
Removes the focus from this GUI and returns true if the focus was in the GUI, false otherwise.void
connected
(VRContext.VRDevice device) A newVRContext.VRDevice
has connectedboolean
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].void
disconnected
(VRContext.VRDevice device) AVRContext.VRDevice
has disconnectedvoid
dispose()
void
doneLoading
(com.badlogic.gdx.assets.AssetManager assetManager) Hook that runs after the assets have been loaded.void
event
(int code) Unhandled event on theVRContext.VRDevice
com.badlogic.gdx.scenes.scene2d.Actor
Returns the first actor found with the specified name.com.badlogic.gdx.scenes.scene2d.Stage
Returns the stagevoid
initialize
(com.badlogic.gdx.assets.AssetManager manager, com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Initializes the GUI, adding all the resources to the asset manager queue for loadingboolean
isVR()
Returns whether this GUI is a VR gui.boolean
keyDown
(int keycode) boolean
keyTyped
(char character) boolean
keyUp
(int keycode) boolean
mouseMoved
(int screenX, int screenY) boolean
mustDraw()
Returns whether this GUI must be drawn or notvoid
Event notification call.void
render
(int rw, int rh) Renders this GUIvoid
resize
(int width, int height) Resizes this GUI to the given values at the end of the current loopvoid
resizeImmediate
(int width, int height) Resizes without waiting for the current loop to finishboolean
scrolled
(float amountX, float amountY) void
setBackBufferSize
(int width, int height) Sets the back buffer size.void
void
setSkin
(com.badlogic.gdx.scenes.scene2d.ui.Skin skin) void
setVisibilityToggles
(ComponentTypes.ComponentType[] entities, ComponentTypes visible) Sets the visibility state of the component entitiesvoid
setVR
(boolean vr) Whether this GUI is to be used in VR modeboolean
touchDown
(int screenX, int screenY, int pointer, int button) boolean
touchDragged
(int screenX, int screenY, int pointer) boolean
touchUp
(int screenX, int screenY, int pointer, int button) void
update
(double dt) Updates the GUIboolean
updateUnitsPerPixel
(float upp) Updates the units-per-pixel value of this GUI.
-
Field Details
-
WIDTH
public static final int WIDTH- See Also:
-
HEIGHT
public static final int HEIGHT- See Also:
-
-
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 interfaceIGui
- Parameters:
manager
- The asset manager to load the resources withbatch
- 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 interfaceIGui
- 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 -
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 -
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 -
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 interfaceIGui
- Parameters:
width
- The new widthheight
- 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 interfaceIGui
- 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 interfaceIGui
- Returns:
- The stage
-
setVisibilityToggles
Description copied from interface:IGui
Sets the visibility state of the component entities- Specified by:
setVisibilityToggles
in interfaceIGui
- Parameters:
entities
- The entitiesvisible
- The states
-
findActor
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. -
setVR
public void setVR(boolean vr) Description copied from interface:IGui
Whether this GUI is to be used in VR mode -
isVR
public boolean isVR()Description copied from interface:IGui
Returns whether this GUI is a VR gui. -
mustDraw
public boolean mustDraw()Description copied from interface:IGui
Returns whether this GUI must be drawn or not -
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 interfaceIGui
-
setBackBufferSize
public void setBackBufferSize(int width, int height) Description copied from interface:IGui
Sets the back buffer size.- Specified by:
setBackBufferSize
in interfaceIGui
-
dispose
public void dispose()- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
-
notify
Description copied from interface:IObserver
Event notification call. -
setScene
-
setSkin
public void setSkin(com.badlogic.gdx.scenes.scene2d.ui.Skin skin) -
connected
Description copied from interface:VRDeviceListener
A newVRContext.VRDevice
has connected- Specified by:
connected
in interfaceVRDeviceListener
-
disconnected
Description copied from interface:VRDeviceListener
AVRContext.VRDevice
has disconnected- Specified by:
disconnected
in interfaceVRDeviceListener
-
buttonPressed
Description copied from interface:VRDeviceListener
A button was pressed on theVRContext.VRDevice
- Specified by:
buttonPressed
in interfaceVRDeviceListener
- Returns:
- True if the event was handled.
-
buttonReleased
Description copied from interface:VRDeviceListener
A button was released on theVRContext.VRDevice
- Specified by:
buttonReleased
in interfaceVRDeviceListener
- Returns:
- True if the event was handled.
-
buttonTouched
Description copied from interface:VRDeviceListener
A button was touched on theVRContext.VRDevice
- Specified by:
buttonTouched
in interfaceVRDeviceListener
- Returns:
- True if the event was handled.
-
buttonUntouched
Description copied from interface:VRDeviceListener
A button was untouched on theVRContext.VRDevice
- Specified by:
buttonUntouched
in interfaceVRDeviceListener
- Returns:
- True if the event was handled.
-
axisMoved
Description copied from interface:VRDeviceListener
An axis was moved on theVRContext.VRDevice
- Specified by:
axisMoved
in interfaceVRDeviceListener
- Returns:
- True if the event was handled.
-
event
public void event(int code) Description copied from interface:VRDeviceListener
Unhandled event on theVRContext.VRDevice
- Specified by:
event
in interfaceVRDeviceListener
- Parameters:
code
- Event code
-
keyDown
public boolean keyDown(int keycode) - Specified by:
keyDown
in interfacecom.badlogic.gdx.InputProcessor
-
keyUp
public boolean keyUp(int keycode) - Specified by:
keyUp
in interfacecom.badlogic.gdx.InputProcessor
-
keyTyped
public boolean keyTyped(char character) - Specified by:
keyTyped
in interfacecom.badlogic.gdx.InputProcessor
-
touchDown
public boolean touchDown(int screenX, int screenY, int pointer, int button) - Specified by:
touchDown
in interfacecom.badlogic.gdx.InputProcessor
-
touchUp
public boolean touchUp(int screenX, int screenY, int pointer, int button) - Specified by:
touchUp
in interfacecom.badlogic.gdx.InputProcessor
-
touchDragged
public boolean touchDragged(int screenX, int screenY, int pointer) - Specified by:
touchDragged
in interfacecom.badlogic.gdx.InputProcessor
-
mouseMoved
public boolean mouseMoved(int screenX, int screenY) - Specified by:
mouseMoved
in interfacecom.badlogic.gdx.InputProcessor
-
scrolled
public boolean scrolled(float amountX, float amountY) - Specified by:
scrolled
in interfacecom.badlogic.gdx.InputProcessor
-