Refactoring finished.
This commit is contained in:
@@ -23,6 +23,7 @@ import ve.ucv.ciens.ccg.nxtar.network.ServiceDiscoveryThread;
|
|||||||
import ve.ucv.ciens.ccg.nxtar.network.VideoStreamingThread;
|
import ve.ucv.ciens.ccg.nxtar.network.VideoStreamingThread;
|
||||||
import ve.ucv.ciens.ccg.nxtar.states.BaseState;
|
import ve.ucv.ciens.ccg.nxtar.states.BaseState;
|
||||||
import ve.ucv.ciens.ccg.nxtar.states.InGameState;
|
import ve.ucv.ciens.ccg.nxtar.states.InGameState;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.states.MainMenuStateBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.states.OuyaMainMenuState;
|
import ve.ucv.ciens.ccg.nxtar.states.OuyaMainMenuState;
|
||||||
import ve.ucv.ciens.ccg.nxtar.states.PauseState;
|
import ve.ucv.ciens.ccg.nxtar.states.PauseState;
|
||||||
import ve.ucv.ciens.ccg.nxtar.states.TabletMainMenuState;
|
import ve.ucv.ciens.ccg.nxtar.states.TabletMainMenuState;
|
||||||
@@ -33,14 +34,28 @@ import com.badlogic.gdx.Game;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.controllers.Controllers;
|
import com.badlogic.gdx.controllers.Controllers;
|
||||||
import com.badlogic.gdx.controllers.mappings.Ouya;
|
import com.badlogic.gdx.controllers.mappings.Ouya;
|
||||||
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Core of the application.</p>
|
||||||
|
*
|
||||||
|
* <p>This class has three basic resposibilities:</p>
|
||||||
|
* <ul>
|
||||||
|
* <li> Handling the main game loop.</li>
|
||||||
|
* <li> Starting and destroying the networking threads.</li>
|
||||||
|
* <li> Rendering debug information.</li>
|
||||||
|
* </ul>
|
||||||
|
* @author Miguel Angel Astor Romero
|
||||||
|
*/
|
||||||
public class NxtARCore extends Game implements NetworkConnectionListener{
|
public class NxtARCore extends Game implements NetworkConnectionListener{
|
||||||
private static final String TAG = "NXTAR_CORE_MAIN";
|
private static final String TAG = "NXTAR_CORE_MAIN";
|
||||||
private static final String CLASS_NAME = NxtARCore.class.getSimpleName();
|
private static final String CLASS_NAME = NxtARCore.class.getSimpleName();
|
||||||
|
|
||||||
// Game state management fields.
|
/**
|
||||||
|
* Valid game states.
|
||||||
|
*/
|
||||||
public enum game_states_t {
|
public enum game_states_t {
|
||||||
MAIN_MENU(0), IN_GAME(1), PAUSED(2);
|
MAIN_MENU(0), IN_GAME(1), PAUSED(2);
|
||||||
|
|
||||||
@@ -54,15 +69,22 @@ public class NxtARCore extends Game implements NetworkConnectionListener{
|
|||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public game_states_t nextState;
|
/**
|
||||||
|
* The current application state.
|
||||||
|
*/
|
||||||
private game_states_t currState;
|
private game_states_t currState;
|
||||||
|
/**
|
||||||
|
* <p>The state to change to.</p>
|
||||||
|
* <p> Usually null. A state change is scheduled by setting this field to a {@link game_states_t} value.</p>
|
||||||
|
*/
|
||||||
|
public game_states_t nextState;
|
||||||
|
|
||||||
// Screens.
|
// Screens.
|
||||||
private BaseState[] states;
|
private BaseState[] states;
|
||||||
|
|
||||||
// Assorted fields.
|
// Assorted fields.
|
||||||
public SpriteBatch batch;
|
public SpriteBatch batch;
|
||||||
public Toaster toaster;
|
private Toaster toaster;
|
||||||
|
|
||||||
// Networking related fields.
|
// Networking related fields.
|
||||||
private int connections;
|
private int connections;
|
||||||
@@ -72,35 +94,45 @@ public class NxtARCore extends Game implements NetworkConnectionListener{
|
|||||||
private RobotControlThread robotThread;
|
private RobotControlThread robotThread;
|
||||||
|
|
||||||
// Overlay font.
|
// Overlay font.
|
||||||
|
private OrthographicCamera pixelPerfectCamera;
|
||||||
private float fontX;
|
private float fontX;
|
||||||
private float fontY;
|
private float fontY;
|
||||||
private BitmapFont font;
|
private BitmapFont font;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Set up the basic application fields.</p>
|
||||||
|
*/
|
||||||
public NxtARCore(Application concreteApp){
|
public NxtARCore(Application concreteApp){
|
||||||
super();
|
super();
|
||||||
connections = 0;
|
connections = 0;
|
||||||
try{
|
try{
|
||||||
this.toaster = (Toaster)concreteApp;
|
this.toaster = (Toaster)concreteApp;
|
||||||
|
}catch(ClassCastException cc){
|
||||||
|
Gdx.app.debug(TAG, CLASS_NAME + ".Main() :: concreteApp does not implement the Toaster interface. Toasting disabled.");
|
||||||
|
this.toaster = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
this.mcastEnabler = (MulticastEnabler)concreteApp;
|
this.mcastEnabler = (MulticastEnabler)concreteApp;
|
||||||
}catch(ClassCastException cc){
|
}catch(ClassCastException cc){
|
||||||
Gdx.app.debug(TAG, CLASS_NAME + ".Main() :: concreteApp does not implement some of the required interfaces.");
|
Gdx.app.error(TAG, CLASS_NAME + ".Main() :: concreteApp does not implement MulticastEnabler. Quitting.");
|
||||||
Gdx.app.exit();
|
Gdx.app.exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void create(){
|
public void create(){
|
||||||
// Create the state objects.
|
// Create the state objects.
|
||||||
states = new BaseState[3];
|
states = new BaseState[3];
|
||||||
if(Ouya.runningOnOuya)states[0] = new OuyaMainMenuState(this);
|
if(Ouya.runningOnOuya)states[game_states_t.MAIN_MENU.getValue()] = new OuyaMainMenuState(this);
|
||||||
else states[1] = new TabletMainMenuState(this);
|
else states[game_states_t.MAIN_MENU.getValue()] = new TabletMainMenuState(this);
|
||||||
states[1] = new InGameState(this);
|
states[game_states_t.IN_GAME.getValue()] = new InGameState(this);
|
||||||
states[2] = new PauseState(this);
|
states[game_states_t.PAUSED.getValue()] = new PauseState(this);
|
||||||
|
|
||||||
// Set up fields.
|
// Set up fields.
|
||||||
batch = new SpriteBatch();
|
batch = new SpriteBatch();
|
||||||
|
|
||||||
if(ProjectConstants.DEBUG){
|
if(ProjectConstants.DEBUG)
|
||||||
|
pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());{
|
||||||
// Set up the overlay font.
|
// Set up the overlay font.
|
||||||
fontX = -((Gdx.graphics.getWidth() * ProjectConstants.OVERSCAN) / 2) + 10;
|
fontX = -((Gdx.graphics.getWidth() * ProjectConstants.OVERSCAN) / 2) + 10;
|
||||||
fontY = ((Gdx.graphics.getHeight() * ProjectConstants.OVERSCAN) / 2) - 10;
|
fontY = ((Gdx.graphics.getHeight() * ProjectConstants.OVERSCAN) / 2) - 10;
|
||||||
@@ -125,12 +157,14 @@ public class NxtARCore extends Game implements NetworkConnectionListener{
|
|||||||
serviceDiscoveryThread.start();
|
serviceDiscoveryThread.start();
|
||||||
videoThread.start();
|
videoThread.start();
|
||||||
videoThread.startStreaming();
|
videoThread.startStreaming();
|
||||||
|
videoThread.addNetworkConnectionListener(this);
|
||||||
//robotThread.start();
|
//robotThread.start();
|
||||||
|
|
||||||
// Set the current and next states.
|
// Set the current and next states.
|
||||||
currState = game_states_t.MAIN_MENU;
|
currState = game_states_t.MAIN_MENU;
|
||||||
nextState = null;
|
nextState = null;
|
||||||
this.setScreen(states[currState.getValue()]);
|
this.setScreen(states[currState.getValue()]);
|
||||||
|
states[currState.getValue()].onStateSet();
|
||||||
|
|
||||||
// Set initial input handlers.
|
// Set initial input handlers.
|
||||||
Gdx.input.setInputProcessor(states[currState.getValue()]);
|
Gdx.input.setInputProcessor(states[currState.getValue()]);
|
||||||
@@ -141,25 +175,25 @@ public class NxtARCore extends Game implements NetworkConnectionListener{
|
|||||||
// Gdx.app.setLogLevel(Application.LOG_NONE);
|
// Gdx.app.setLogLevel(Application.LOG_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(){
|
public void render(){
|
||||||
super.render();
|
super.render();
|
||||||
|
|
||||||
// If the current state set a value for nextState then switch to that state.
|
// If the current state set a value for nextState then switch to that state.
|
||||||
if(nextState != null){
|
if(nextState != null){
|
||||||
// Change the input processors.
|
// Invalidate all input processors.
|
||||||
Gdx.input.setInputProcessor(states[nextState.getValue()]);
|
Gdx.input.setInputProcessor(null);
|
||||||
Controllers.removeListener(states[currState.getValue()]);
|
Controllers.removeListener(states[currState.getValue()]);
|
||||||
Controllers.addListener(states[nextState.getValue()]);
|
|
||||||
|
|
||||||
// Swap the pointers and set the new screen.
|
// Swap the pointers and set the new screen.
|
||||||
currState = nextState;
|
currState = nextState;
|
||||||
nextState = null;
|
nextState = null;
|
||||||
setScreen(states[currState.getValue()]);
|
setScreen(states[currState.getValue()]);
|
||||||
|
states[currState.getValue()].onStateSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ProjectConstants.DEBUG){
|
if(ProjectConstants.DEBUG){
|
||||||
// Draw the FPS overlay.
|
// Draw the FPS overlay.
|
||||||
|
batch.setProjectionMatrix(pixelPerfectCamera.combined);
|
||||||
batch.begin();{
|
batch.begin();{
|
||||||
font.draw(batch, String.format("Render FPS: %d", Gdx.graphics.getFramesPerSecond()), fontX, fontY);
|
font.draw(batch, String.format("Render FPS: %d", Gdx.graphics.getFramesPerSecond()), fontX, fontY);
|
||||||
font.draw(batch, String.format("Total stream FPS: %d", videoThread.getFps()), fontX, fontY - font.getCapHeight() - 5);
|
font.draw(batch, String.format("Total stream FPS: %d", videoThread.getFps()), fontX, fontY - font.getCapHeight() - 5);
|
||||||
@@ -168,22 +202,16 @@ public class NxtARCore extends Game implements NetworkConnectionListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resize(int width, int height){ }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void pause(){
|
public void pause(){
|
||||||
if(videoThread != null)
|
if(videoThread != null)
|
||||||
videoThread.pause();
|
videoThread.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resume(){
|
public void resume(){
|
||||||
if(videoThread != null)
|
if(videoThread != null)
|
||||||
videoThread.play();
|
videoThread.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose(){
|
public void dispose(){
|
||||||
// Finish network threads.
|
// Finish network threads.
|
||||||
videoThread.finish();
|
videoThread.finish();
|
||||||
@@ -202,12 +230,21 @@ public class NxtARCore extends Game implements NetworkConnectionListener{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void networkStreamConnected(String streamName){
|
public synchronized void networkStreamConnected(String streamName){
|
||||||
if(streamName.compareTo(VideoStreamingThread.THREAD_NAME) == 0 || streamName.compareTo(RobotControlThread.THREAD_NAME) == 0)
|
if(streamName.equals(VideoStreamingThread.THREAD_NAME) || streamName.equals(RobotControlThread.THREAD_NAME))
|
||||||
connections += 1;
|
connections += 1;
|
||||||
if(connections >= 2){
|
if(connections >= 1){
|
||||||
Gdx.app.debug(TAG, CLASS_NAME + ".networkStreamConnected() :: Stopping service broadcast.");
|
Gdx.app.debug(TAG, CLASS_NAME + ".networkStreamConnected() :: Stopping service broadcast.");
|
||||||
serviceDiscoveryThread.finish();
|
serviceDiscoveryThread.finish();
|
||||||
mcastEnabler.disableMulticast();
|
mcastEnabler.disableMulticast();
|
||||||
|
toaster.showShortToast("Client connected");
|
||||||
|
((MainMenuStateBase)states[game_states_t.MAIN_MENU.getValue()]).onClientConnected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toast(String msg, boolean longToast){
|
||||||
|
if(toaster != null){
|
||||||
|
if(longToast) toaster.showLongToast(msg);
|
||||||
|
else toaster.showShortToast(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,6 +45,7 @@ public class VideoStreamingThread extends Thread {
|
|||||||
private boolean endProtocol;*/
|
private boolean endProtocol;*/
|
||||||
private boolean done;
|
private boolean done;
|
||||||
private boolean pause;
|
private boolean pause;
|
||||||
|
private boolean coreNotified;
|
||||||
private Object protocolPauseMonitor;
|
private Object protocolPauseMonitor;
|
||||||
private Socket client;
|
private Socket client;
|
||||||
//private ObjectInputStream reader;
|
//private ObjectInputStream reader;
|
||||||
@@ -70,6 +71,7 @@ public class VideoStreamingThread extends Thread {
|
|||||||
/*endProtocol = false;
|
/*endProtocol = false;
|
||||||
pauseProtocol = false;*/
|
pauseProtocol = false;*/
|
||||||
done = false;
|
done = false;
|
||||||
|
coreNotified = false;
|
||||||
//protocolState = ProtocolState_t.WAIT_FOR_START;
|
//protocolState = ProtocolState_t.WAIT_FOR_START;
|
||||||
protocolPauseMonitor = new Object();
|
protocolPauseMonitor = new Object();
|
||||||
frameMonitor = VideoFrameMonitor.getInstance();
|
frameMonitor = VideoFrameMonitor.getInstance();
|
||||||
@@ -456,8 +458,10 @@ public class VideoStreamingThread extends Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Gdx.app.debug(TAG, CLASS_NAME + ".run() :: Receiving.");
|
Gdx.app.debug(TAG, CLASS_NAME + ".run() :: Receiving.");
|
||||||
if(netListener != null)
|
if(netListener != null && !coreNotified && frameMonitor.getCurrentFrame() != null){
|
||||||
|
coreNotified = true;
|
||||||
netListener.networkStreamConnected(THREAD_NAME);
|
netListener.networkStreamConnected(THREAD_NAME);
|
||||||
|
}
|
||||||
receiveUdp();
|
receiveUdp();
|
||||||
frames++;
|
frames++;
|
||||||
now = System.currentTimeMillis();
|
now = System.currentTimeMillis();
|
||||||
|
@@ -27,6 +27,9 @@ import com.badlogic.gdx.math.Vector3;
|
|||||||
public abstract class BaseState implements Screen, ControllerListener, InputProcessor {
|
public abstract class BaseState implements Screen, ControllerListener, InputProcessor {
|
||||||
protected NxtARCore core;
|
protected NxtARCore core;
|
||||||
|
|
||||||
|
/* STATE METHODS */
|
||||||
|
public abstract void onStateSet();
|
||||||
|
|
||||||
/* SCREEN METHODS*/
|
/* SCREEN METHODS*/
|
||||||
@Override
|
@Override
|
||||||
public abstract void render(float delta);
|
public abstract void render(float delta);
|
||||||
|
@@ -23,9 +23,10 @@ import ve.ucv.ciens.ccg.nxtar.utils.Size;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.controllers.Controller;
|
import com.badlogic.gdx.controllers.Controller;
|
||||||
|
import com.badlogic.gdx.controllers.Controllers;
|
||||||
import com.badlogic.gdx.controllers.PovDirection;
|
import com.badlogic.gdx.controllers.PovDirection;
|
||||||
import com.badlogic.gdx.controllers.mappings.Ouya;
|
import com.badlogic.gdx.controllers.mappings.Ouya;
|
||||||
import com.badlogic.gdx.graphics.GL10;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
import com.badlogic.gdx.graphics.Pixmap;
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
@@ -101,7 +102,7 @@ public class InGameState extends BaseState{
|
|||||||
Size dimensions = null;
|
Size dimensions = null;
|
||||||
|
|
||||||
Gdx.gl.glClearColor(1, 1, 1, 1);
|
Gdx.gl.glClearColor(1, 1, 1, 1);
|
||||||
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
frame = frameMonitor.getCurrentFrame();
|
frame = frameMonitor.getCurrentFrame();
|
||||||
if(frame != null){
|
if(frame != null){
|
||||||
@@ -111,7 +112,7 @@ public class InGameState extends BaseState{
|
|||||||
try{
|
try{
|
||||||
videoFrame = new Pixmap(getOptimalTextureSize(dimensions.getWidth()), getOptimalTextureSize(dimensions.getHeight()), temp.getFormat());
|
videoFrame = new Pixmap(getOptimalTextureSize(dimensions.getWidth()), getOptimalTextureSize(dimensions.getHeight()), temp.getFormat());
|
||||||
}catch(ImageTooBigException e){
|
}catch(ImageTooBigException e){
|
||||||
core.toaster.showLongToast("Cannot display received frame.\n" + e.getMessage());
|
core.toast("Cannot display received frame.\n" + e.getMessage(), true);
|
||||||
Gdx.app.exit();
|
Gdx.app.exit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -206,6 +207,16 @@ public class InGameState extends BaseState{
|
|||||||
throw new ImageTooBigException("No valid texture size found. Image too large.");
|
throw new ImageTooBigException("No valid texture size found. Image too large.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*;;;;;;;;;;;;;;;;;;
|
||||||
|
; HELPER METHODS ;
|
||||||
|
;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStateSet(){
|
||||||
|
Controllers.addListener(this);
|
||||||
|
Gdx.input.setInputProcessor(this);
|
||||||
|
}
|
||||||
|
|
||||||
private void setUpButtons(){
|
private void setUpButtons(){
|
||||||
buttonTexture = new Texture(Gdx.files.internal("data/gfx/gui/PBCrichton_Flat_Button.png"));
|
buttonTexture = new Texture(Gdx.files.internal("data/gfx/gui/PBCrichton_Flat_Button.png"));
|
||||||
buttonTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
|
buttonTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
|
||||||
@@ -347,13 +358,11 @@ public class InGameState extends BaseState{
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
; END INPUT PROCESSOR METHODS ;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; BEGIN CONTROLLER LISTENER METHODS ;
|
; BEGIN CONTROLLER LISTENER METHODS ;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean scrolled(int amount) {
|
public boolean scrolled(int amount) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
@@ -433,7 +442,4 @@ public class InGameState extends BaseState{
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
; END CONTROLLER LISTENER METHODS ;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
|
||||||
}
|
}
|
||||||
|
@@ -15,45 +15,125 @@
|
|||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar.states;
|
package ve.ucv.ciens.ccg.nxtar.states;
|
||||||
|
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.controllers.Controllers;
|
||||||
|
import com.badlogic.gdx.controllers.mappings.Ouya;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.NinePatch;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||||
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
|
||||||
|
|
||||||
|
|
||||||
public abstract class MainMenuStateBase extends BaseState{
|
public abstract class MainMenuStateBase extends BaseState{
|
||||||
|
protected static final String TAG = "MAIN_MENU";
|
||||||
|
|
||||||
|
// Client connection helper fields.
|
||||||
|
protected boolean clientConnected;
|
||||||
|
|
||||||
|
// Buttons and other gui components.
|
||||||
|
protected TextButton startButton;
|
||||||
|
protected Rectangle startButtonBBox;
|
||||||
|
protected Sprite clientConnectedLedOn;
|
||||||
|
protected Sprite clientConnectedLedOff;
|
||||||
|
|
||||||
|
// Graphic data for the start button.
|
||||||
|
private Texture startButtonEnabledTexture;
|
||||||
|
private Texture startButtonDisabledTexture;
|
||||||
|
private Texture startButtonPressedTexture;
|
||||||
|
private NinePatch startButtonEnabled9p;
|
||||||
|
private NinePatch startButtonDisabled9p;
|
||||||
|
private NinePatch startButtonPressed9p;
|
||||||
|
private BitmapFont font;
|
||||||
|
|
||||||
|
// Other graphics.
|
||||||
|
private Texture clientConnectedLedOffTexture;
|
||||||
|
private Texture clientConnectedLedOnTexture;
|
||||||
|
|
||||||
|
public MainMenuStateBase(){
|
||||||
|
// Create the start button background.
|
||||||
|
startButtonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png"));
|
||||||
|
startButtonEnabled9p = new NinePatch(new TextureRegion(startButtonEnabledTexture, 0, 0, startButtonEnabledTexture.getWidth(), startButtonEnabledTexture.getHeight()), 49, 49, 45, 45);
|
||||||
|
|
||||||
|
startButtonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png"));
|
||||||
|
startButtonDisabled9p = new NinePatch(new TextureRegion(startButtonDisabledTexture, 0, 0, startButtonDisabledTexture.getWidth(), startButtonDisabledTexture.getHeight()), 49, 49, 45, 45);
|
||||||
|
|
||||||
|
startButtonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png"));
|
||||||
|
startButtonPressed9p = new NinePatch(new TextureRegion(startButtonPressedTexture, 0, 0, startButtonPressedTexture.getWidth(), startButtonPressedTexture.getHeight()), 49, 49, 45, 45);
|
||||||
|
|
||||||
|
// Create the start button font.
|
||||||
|
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
|
||||||
|
font = generator.generateFont(Ouya.runningOnOuya ? 60 : 40, ProjectConstants.FONT_CHARS, false);
|
||||||
|
generator.dispose();
|
||||||
|
|
||||||
|
// Create the start button itself.
|
||||||
|
TextButtonStyle tbs = new TextButtonStyle();
|
||||||
|
tbs.font = font;
|
||||||
|
tbs.up = new NinePatchDrawable(startButtonEnabled9p);
|
||||||
|
tbs.checked = new NinePatchDrawable(startButtonPressed9p);
|
||||||
|
tbs.disabled = new NinePatchDrawable(startButtonDisabled9p);
|
||||||
|
tbs.disabledFontColor = new Color(0, 0, 0, 1);
|
||||||
|
startButton = new TextButton("Start server", tbs);
|
||||||
|
startButton.setText("Start game");
|
||||||
|
startButton.setDisabled(true);
|
||||||
|
startButtonBBox = new Rectangle(0, 0, startButton.getWidth(), startButton.getHeight());
|
||||||
|
|
||||||
|
// Create the connection leds.
|
||||||
|
TextureRegion region;
|
||||||
|
clientConnectedLedOnTexture = new Texture("data/gfx/gui/Anonymous_Button_Green.png");
|
||||||
|
region = new TextureRegion(clientConnectedLedOnTexture, clientConnectedLedOnTexture.getWidth(), clientConnectedLedOnTexture.getHeight());
|
||||||
|
clientConnectedLedOn = new Sprite(region);
|
||||||
|
|
||||||
|
clientConnectedLedOffTexture = new Texture("data/gfx/gui/Anonymous_Button_Red.png");
|
||||||
|
region = new TextureRegion(clientConnectedLedOffTexture, clientConnectedLedOffTexture.getWidth(), clientConnectedLedOffTexture.getHeight());
|
||||||
|
clientConnectedLedOff = new Sprite(region);
|
||||||
|
|
||||||
|
clientConnected = false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract void render(float delta);
|
public abstract void render(float delta);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resize(int width, int height) {
|
public abstract void resize(int width, int height);
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract void show();
|
||||||
|
@Override
|
||||||
|
public abstract void hide();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract void pause();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract void resume();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose(){
|
||||||
|
startButtonEnabledTexture.dispose();
|
||||||
|
startButtonDisabledTexture.dispose();
|
||||||
|
startButtonPressedTexture.dispose();
|
||||||
|
clientConnectedLedOnTexture.dispose();
|
||||||
|
clientConnectedLedOffTexture.dispose();
|
||||||
|
font.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void onStateSet(){
|
||||||
// TODO Auto-generated method stub
|
Controllers.addListener(this);
|
||||||
|
Gdx.input.setInputProcessor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void onClientConnected(){
|
||||||
public void hide() {
|
clientConnected = true;
|
||||||
// TODO Auto-generated method stub
|
startButton.setDisabled(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void pause() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resume() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -17,22 +17,77 @@ package ve.ucv.ciens.ccg.nxtar.states;
|
|||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.controllers.Controller;
|
import com.badlogic.gdx.controllers.Controller;
|
||||||
|
import com.badlogic.gdx.controllers.Controllers;
|
||||||
import com.badlogic.gdx.controllers.PovDirection;
|
import com.badlogic.gdx.controllers.PovDirection;
|
||||||
|
import com.badlogic.gdx.graphics.GL10;
|
||||||
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
import com.badlogic.gdx.math.Vector3;
|
import com.badlogic.gdx.math.Vector3;
|
||||||
|
|
||||||
public class OuyaMainMenuState extends MainMenuStateBase{
|
public class OuyaMainMenuState extends MainMenuStateBase{
|
||||||
|
private OrthographicCamera pixelPerfectCamera;
|
||||||
|
|
||||||
public OuyaMainMenuState(final NxtARCore core){
|
public OuyaMainMenuState(final NxtARCore core){
|
||||||
this.core = core;
|
this.core = core;
|
||||||
|
this.pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
|
Gdx.gl.glClearColor(1, 1, 1, 1);
|
||||||
|
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
|
||||||
|
core.batch.begin();{
|
||||||
|
this.startButton.draw(core.batch, 1.0f);
|
||||||
|
}core.batch.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resize(int width, int height) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pause() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resume() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose(){
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*;;;;;;;;;;;;;;;;;;
|
||||||
|
; HELPER METHODS ;
|
||||||
|
;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStateSet(){
|
||||||
|
super.onStateSet();
|
||||||
|
}
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; BEGIN INPUT PROCESSOR METHODS ;
|
; BEGIN INPUT PROCESSOR METHODS ;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
@@ -78,13 +133,11 @@ public class OuyaMainMenuState extends MainMenuStateBase{
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
; END INPUT PROCESSOR METHODS ;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; BEGIN CONTROLLER LISTENER METHODS ;
|
; BEGIN CONTROLLER LISTENER METHODS ;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean scrolled(int amount) {
|
public boolean scrolled(int amount) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
@@ -148,7 +201,4 @@ public class OuyaMainMenuState extends MainMenuStateBase{
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
; END CONTROLLER LISTENER METHODS ;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
|
||||||
}
|
}
|
||||||
|
@@ -69,6 +69,14 @@ public class PauseState extends BaseState {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*;;;;;;;;;;;;;;;;;;
|
||||||
|
; HELPER METHODS ;
|
||||||
|
;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStateSet(){
|
||||||
|
}
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; BEGIN INPUT PROCESSOR METHODS ;
|
; BEGIN INPUT PROCESSOR METHODS ;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
|
@@ -16,139 +16,235 @@
|
|||||||
package ve.ucv.ciens.ccg.nxtar.states;
|
package ve.ucv.ciens.ccg.nxtar.states;
|
||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.NxtARCore.game_states_t;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.controllers.Controller;
|
import com.badlogic.gdx.controllers.Controller;
|
||||||
import com.badlogic.gdx.controllers.PovDirection;
|
import com.badlogic.gdx.controllers.PovDirection;
|
||||||
|
import com.badlogic.gdx.graphics.GL10;
|
||||||
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.math.Vector3;
|
import com.badlogic.gdx.math.Vector3;
|
||||||
|
|
||||||
public class TabletMainMenuState extends MainMenuStateBase{
|
public class TabletMainMenuState extends MainMenuStateBase{
|
||||||
|
protected static final String CLASS_NAME = TabletMainMenuState.class.getSimpleName();
|
||||||
|
|
||||||
|
private OrthographicCamera pixelPerfectCamera;
|
||||||
|
|
||||||
|
// Button touch helper fields.
|
||||||
|
private Vector3 win2world;
|
||||||
|
private Vector2 touchPointWorldCoords;
|
||||||
|
private boolean startButtonTouched;
|
||||||
|
private int startButtonTouchPointer;
|
||||||
|
|
||||||
public TabletMainMenuState(final NxtARCore core){
|
public TabletMainMenuState(final NxtARCore core){
|
||||||
this.core = core;
|
this.core = core;
|
||||||
|
pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
|
startButton.setPosition(-(startButton.getWidth() / 2), -(startButton.getHeight() / 2));
|
||||||
|
startButtonBBox.setPosition(startButton.getX(), startButton.getY());
|
||||||
|
|
||||||
|
win2world = new Vector3(0.0f, 0.0f, 0.0f);
|
||||||
|
touchPointWorldCoords = new Vector2();
|
||||||
|
|
||||||
|
startButtonTouched = false;
|
||||||
|
startButtonTouchPointer = -1;
|
||||||
|
|
||||||
|
float ledYPos = (-(Gdx.graphics.getHeight() / 2) * 0.5f) + (startButton.getY() * 0.5f);
|
||||||
|
clientConnectedLedOn.setSize(clientConnectedLedOn.getWidth() * 0.5f, clientConnectedLedOn.getHeight() * 0.5f);
|
||||||
|
clientConnectedLedOn.setPosition(-(clientConnectedLedOn.getWidth() / 2), ledYPos);
|
||||||
|
|
||||||
|
clientConnectedLedOff.setSize(clientConnectedLedOff.getWidth() * 0.5f, clientConnectedLedOff.getHeight() * 0.5f);
|
||||||
|
clientConnectedLedOff.setPosition(-(clientConnectedLedOff.getWidth() / 2), ledYPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta){
|
||||||
// TODO Auto-generated method stub
|
Gdx.gl.glClearColor(1, 1, 1, 1);
|
||||||
|
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
|
||||||
|
core.batch.begin();{
|
||||||
|
if(clientConnected){
|
||||||
|
clientConnectedLedOn.draw(core.batch);
|
||||||
|
}else{
|
||||||
|
clientConnectedLedOff.draw(core.batch);
|
||||||
|
}
|
||||||
|
startButton.draw(core.batch, 1.0f);
|
||||||
|
}core.batch.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
@Override
|
||||||
; BEGIN INPUT PROCESSOR METHODS ;
|
public void resize(int width, int height){ }
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyDown(int keycode) {
|
public void show(){ }
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
@Override
|
||||||
|
public void hide(){ }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pause(){ }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resume(){ }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose(){
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*;;;;;;;;;;;;;;;;;;
|
||||||
|
; HELPER METHODS ;
|
||||||
|
;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStateSet(){
|
||||||
|
super.onStateSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unprojectTouch(int screenX, int screenY){
|
||||||
|
win2world.set(screenX, screenY, 0.0f);
|
||||||
|
pixelPerfectCamera.unproject(win2world);
|
||||||
|
touchPointWorldCoords.set(win2world.x, win2world.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; INPUT PROCESSOR METHODS ;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean touchDown(int screenX, int screenY, int pointer, int button){
|
||||||
|
unprojectTouch(screenX, screenY);
|
||||||
|
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown(%d, %d, %d, %d)", screenX, screenY, pointer, button));
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
|
||||||
|
|
||||||
|
if(!startButton.isDisabled() && startButtonBBox.contains(touchPointWorldCoords)){
|
||||||
|
startButton.setChecked(true);
|
||||||
|
startButtonTouched = true;
|
||||||
|
startButtonTouchPointer = pointer;
|
||||||
|
core.nextState = game_states_t.IN_GAME;
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button pressed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean touchUp(int screenX, int screenY, int pointer, int button){
|
||||||
|
unprojectTouch(screenX, screenY);
|
||||||
|
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp(%d, %d, %d, %d)", screenX, screenY, pointer, button));
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
|
||||||
|
|
||||||
|
if(!startButton.isDisabled() && startButtonBBox.contains(touchPointWorldCoords)){
|
||||||
|
startButton.setChecked(false);
|
||||||
|
startButtonTouched = false;
|
||||||
|
startButtonTouchPointer = -1;
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button released.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean touchDragged(int screenX, int screenY, int pointer){
|
||||||
|
unprojectTouch(screenX, screenY);
|
||||||
|
|
||||||
|
if(!startButton.isDisabled() && startButtonTouched && pointer == startButtonTouchPointer && !startButtonBBox.contains(touchPointWorldCoords)){
|
||||||
|
startButtonTouchPointer = -1;
|
||||||
|
startButtonTouched = false;
|
||||||
|
startButton.setChecked(false);
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Start button released.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; UNUSED CONTROLLER LISTENER METHODS ;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean keyDown(int keycode){
|
||||||
|
// Unused.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyUp(int keycode) {
|
public boolean keyUp(int keycode){
|
||||||
// TODO Auto-generated method stub
|
// Unused.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyTyped(char character) {
|
public boolean keyTyped(char character){
|
||||||
// TODO Auto-generated method stub
|
// Unused.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
|
public boolean mouseMoved(int screenX, int screenY){
|
||||||
// TODO Auto-generated method stub
|
// Unused.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
|
public boolean scrolled(int amount){
|
||||||
// TODO Auto-generated method stub
|
// Unused.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDragged(int screenX, int screenY, int pointer) {
|
public void connected(Controller controller){
|
||||||
// TODO Auto-generated method stub
|
// Unused.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disconnected(Controller controller){
|
||||||
|
// Unused.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean buttonDown(Controller controller, int buttonCode){
|
||||||
|
// Unused.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseMoved(int screenX, int screenY) {
|
public boolean buttonUp(Controller controller, int buttonCode){
|
||||||
// TODO Auto-generated method stub
|
// Unused.
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
; END INPUT PROCESSOR METHODS ;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
; BEGIN CONTROLLER LISTENER METHODS ;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
|
||||||
@Override
|
|
||||||
public boolean scrolled(int amount) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connected(Controller controller) {
|
public boolean axisMoved(Controller controller, int axisCode, float value){
|
||||||
// TODO Auto-generated method stub
|
// Unused.
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disconnected(Controller controller) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean buttonDown(Controller controller, int buttonCode) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean buttonUp(Controller controller, int buttonCode) {
|
public boolean povMoved(Controller controller, int povCode, PovDirection value){
|
||||||
// TODO Auto-generated method stub
|
// Unused.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean axisMoved(Controller controller, int axisCode, float value) {
|
public boolean xSliderMoved(Controller controller, int sliderCode, boolean value){
|
||||||
// TODO Auto-generated method stub
|
// Unused.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean povMoved(Controller controller, int povCode,
|
public boolean ySliderMoved(Controller controller, int sliderCode, boolean value){
|
||||||
PovDirection value) {
|
// Unused.
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean xSliderMoved(Controller controller, int sliderCode,
|
public boolean accelerometerMoved(Controller controller, int accelerometerCode, Vector3 value){
|
||||||
boolean value) {
|
// Unused.
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean ySliderMoved(Controller controller, int sliderCode,
|
|
||||||
boolean value) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean accelerometerMoved(Controller controller,
|
|
||||||
int accelerometerCode, Vector3 value) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
; END CONTROLLER LISTENER METHODS ;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,8 @@ public abstract class ProjectConstants {
|
|||||||
|
|
||||||
public static final float OVERSCAN;
|
public static final float OVERSCAN;
|
||||||
|
|
||||||
|
public static final String FONT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.,:;!<21>?<3F>";
|
||||||
|
|
||||||
static{
|
static{
|
||||||
OVERSCAN = Ouya.runningOnOuya ? 0.9f : 1.0f;
|
OVERSCAN = Ouya.runningOnOuya ? 0.9f : 1.0f;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user