Fixed OuyaMainMenuState.
This commit is contained in:
@@ -128,51 +128,55 @@ public class NxtARCore extends Game implements NetworkConnectionListener{
|
|||||||
states[game_states_t.IN_GAME.getValue()] = new InGameState(this);
|
states[game_states_t.IN_GAME.getValue()] = new InGameState(this);
|
||||||
states[game_states_t.PAUSED.getValue()] = new PauseState(this);
|
states[game_states_t.PAUSED.getValue()] = new PauseState(this);
|
||||||
|
|
||||||
|
for(BaseState state : states){
|
||||||
|
Controllers.addListener(state);
|
||||||
|
}
|
||||||
|
|
||||||
// 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());{
|
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;
|
||||||
|
|
||||||
font = new BitmapFont();
|
font = new BitmapFont();
|
||||||
font.setColor(1.0f, 1.0f, 0.0f, 1.0f);
|
font.setColor(1.0f, 1.0f, 0.0f, 1.0f);
|
||||||
if(!Ouya.runningOnOuya){
|
if(!Ouya.runningOnOuya){
|
||||||
font.setScale(1.0f);
|
font.setScale(1.0f);
|
||||||
}else{
|
}else{
|
||||||
font.setScale(2.5f);
|
font.setScale(2.5f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Start networking.
|
// Start networking.
|
||||||
mcastEnabler.enableMulticast();
|
mcastEnabler.enableMulticast();
|
||||||
|
|
||||||
Gdx.app.debug(TAG, CLASS_NAME + ".create() :: Creating network threads");
|
Gdx.app.debug(TAG, CLASS_NAME + ".create() :: Creating network threads");
|
||||||
serviceDiscoveryThread = ServiceDiscoveryThread.getInstance();
|
serviceDiscoveryThread = ServiceDiscoveryThread.getInstance();
|
||||||
videoThread = VideoStreamingThread.getInstance()/*.setToaster(toaster)*/;
|
videoThread = VideoStreamingThread.getInstance()/*.setToaster(toaster)*/;
|
||||||
//robotThread = RobotControlThread.getInstance().setToaster(toaster);
|
//robotThread = RobotControlThread.getInstance().setToaster(toaster);
|
||||||
|
|
||||||
serviceDiscoveryThread.start();
|
serviceDiscoveryThread.start();
|
||||||
videoThread.start();
|
videoThread.start();
|
||||||
videoThread.startStreaming();
|
videoThread.startStreaming();
|
||||||
videoThread.addNetworkConnectionListener(this);
|
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();
|
states[currState.getValue()].onStateSet();
|
||||||
|
|
||||||
// Set initial input handlers.
|
// Set initial input handlers.
|
||||||
Gdx.input.setInputProcessor(states[currState.getValue()]);
|
Gdx.input.setInputProcessor(states[currState.getValue()]);
|
||||||
Controllers.addListener(states[currState.getValue()]);
|
Controllers.addListener(states[currState.getValue()]);
|
||||||
|
|
||||||
// Anything else.
|
// Anything else.
|
||||||
Gdx.app.setLogLevel(Application.LOG_INFO);
|
Gdx.app.setLogLevel(Application.LOG_INFO);
|
||||||
// Gdx.app.setLogLevel(Application.LOG_NONE);
|
// Gdx.app.setLogLevel(Application.LOG_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(){
|
public void render(){
|
||||||
@@ -180,15 +184,14 @@ public class NxtARCore extends Game implements NetworkConnectionListener{
|
|||||||
|
|
||||||
// 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){
|
||||||
// Invalidate all input processors.
|
states[currState.getValue()].onStateUnset();
|
||||||
Gdx.input.setInputProcessor(null);
|
|
||||||
Controllers.removeListener(states[currState.getValue()]);
|
|
||||||
|
|
||||||
// Swap the pointers and set the new screen.
|
|
||||||
currState = nextState;
|
currState = nextState;
|
||||||
nextState = null;
|
nextState = null;
|
||||||
setScreen(states[currState.getValue()]);
|
|
||||||
states[currState.getValue()].onStateSet();
|
states[currState.getValue()].onStateSet();
|
||||||
|
|
||||||
|
setScreen(states[currState.getValue()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ProjectConstants.DEBUG){
|
if(ProjectConstants.DEBUG){
|
||||||
|
@@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Miguel Angel Astor Romero
|
* Copyright (C) 2014 Miguel Angel Astor Romero
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar.exceptions;
|
package ve.ucv.ciens.ccg.nxtar.exceptions;
|
||||||
|
|
||||||
public class ImageTooBigException extends Exception{
|
public class ImageTooBigException extends Exception{
|
||||||
private static final long serialVersionUID = 9989L;
|
private static final long serialVersionUID = 9989L;
|
||||||
|
|
||||||
public ImageTooBigException(String msg){
|
public ImageTooBigException(String msg){
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,86 +1,88 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Miguel Angel Astor Romero
|
* Copyright (C) 2014 Miguel Angel Astor Romero
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
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 com.badlogic.gdx.InputProcessor;
|
import com.badlogic.gdx.InputProcessor;
|
||||||
import com.badlogic.gdx.Screen;
|
import com.badlogic.gdx.Screen;
|
||||||
import com.badlogic.gdx.controllers.Controller;
|
import com.badlogic.gdx.controllers.Controller;
|
||||||
import com.badlogic.gdx.controllers.ControllerListener;
|
import com.badlogic.gdx.controllers.ControllerListener;
|
||||||
import com.badlogic.gdx.controllers.PovDirection;
|
import com.badlogic.gdx.controllers.PovDirection;
|
||||||
import com.badlogic.gdx.math.Vector3;
|
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;
|
||||||
|
protected boolean stateActive;
|
||||||
/* STATE METHODS */
|
|
||||||
public abstract void onStateSet();
|
/* STATE METHODS */
|
||||||
|
public abstract void onStateSet();
|
||||||
/* SCREEN METHODS*/
|
public abstract void onStateUnset();
|
||||||
@Override
|
|
||||||
public abstract void render(float delta);
|
/* SCREEN METHODS*/
|
||||||
@Override
|
@Override
|
||||||
public abstract void resize(int width, int height);
|
public abstract void render(float delta);
|
||||||
@Override
|
@Override
|
||||||
public abstract void show();
|
public abstract void resize(int width, int height);
|
||||||
@Override
|
@Override
|
||||||
public abstract void hide();
|
public abstract void show();
|
||||||
@Override
|
@Override
|
||||||
public abstract void pause();
|
public abstract void hide();
|
||||||
@Override
|
@Override
|
||||||
public abstract void resume();
|
public abstract void pause();
|
||||||
@Override
|
@Override
|
||||||
public abstract void dispose();
|
public abstract void resume();
|
||||||
|
@Override
|
||||||
/* INPUT PROCESSOR METHODS. */
|
public abstract void dispose();
|
||||||
@Override
|
|
||||||
public abstract boolean keyDown(int keycode);
|
/* INPUT PROCESSOR METHODS. */
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean keyUp(int keycode);
|
public abstract boolean keyDown(int keycode);
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean keyTyped(char character);
|
public abstract boolean keyUp(int keycode);
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean touchDown(int screenX, int screenY, int pointer, int button);
|
public abstract boolean keyTyped(char character);
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean touchUp(int screenX, int screenY, int pointer, int button);
|
public abstract boolean touchDown(int screenX, int screenY, int pointer, int button);
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean touchDragged(int screenX, int screenY, int pointer);
|
public abstract boolean touchUp(int screenX, int screenY, int pointer, int button);
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean mouseMoved(int screenX, int screenY);
|
public abstract boolean touchDragged(int screenX, int screenY, int pointer);
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean scrolled(int amount);
|
public abstract boolean mouseMoved(int screenX, int screenY);
|
||||||
|
@Override
|
||||||
/* CONTROLLER LISTENER METHODS. */
|
public abstract boolean scrolled(int amount);
|
||||||
@Override
|
|
||||||
public abstract void connected(Controller controller);
|
/* CONTROLLER LISTENER METHODS. */
|
||||||
@Override
|
@Override
|
||||||
public abstract void disconnected(Controller controller);
|
public abstract void connected(Controller controller);
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean buttonDown(Controller controller, int buttonCode);
|
public abstract void disconnected(Controller controller);
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean buttonUp(Controller controller, int buttonCode);
|
public abstract boolean buttonDown(Controller controller, int buttonCode);
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean axisMoved(Controller controller, int axisCode, float value);
|
public abstract boolean buttonUp(Controller controller, int buttonCode);
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean povMoved(Controller controller, int povCode, PovDirection value);
|
public abstract boolean axisMoved(Controller controller, int axisCode, float value);
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean xSliderMoved(Controller controller, int sliderCode, boolean value);
|
public abstract boolean povMoved(Controller controller, int povCode, PovDirection value);
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean ySliderMoved(Controller controller, int sliderCode, boolean value);
|
public abstract boolean xSliderMoved(Controller controller, int sliderCode, boolean value);
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean accelerometerMoved(Controller controller, int accelerometerCode, Vector3 value);
|
public abstract boolean ySliderMoved(Controller controller, int sliderCode, boolean value);
|
||||||
}
|
@Override
|
||||||
|
public abstract boolean accelerometerMoved(Controller controller, int accelerometerCode, Vector3 value);
|
||||||
|
}
|
||||||
|
@@ -1,445 +1,454 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Miguel Angel Astor Romero
|
* Copyright (C) 2014 Miguel Angel Astor Romero
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
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.exceptions.ImageTooBigException;
|
import ve.ucv.ciens.ccg.nxtar.exceptions.ImageTooBigException;
|
||||||
import ve.ucv.ciens.ccg.nxtar.network.VideoFrameMonitor;
|
import ve.ucv.ciens.ccg.nxtar.network.VideoFrameMonitor;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.Size;
|
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.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.GL20;
|
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;
|
||||||
import com.badlogic.gdx.graphics.Texture.TextureFilter;
|
import com.badlogic.gdx.graphics.Texture.TextureFilter;
|
||||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.math.Vector3;
|
import com.badlogic.gdx.math.Vector3;
|
||||||
|
|
||||||
public class InGameState extends BaseState{
|
public class InGameState extends BaseState{
|
||||||
private static final String TAG = "IN_GAME_STATE";
|
private static final String TAG = "IN_GAME_STATE";
|
||||||
private static final String CLASS_NAME = InGameState.class.getSimpleName();
|
private static final String CLASS_NAME = InGameState.class.getSimpleName();
|
||||||
|
|
||||||
private NxtARCore core;
|
private NxtARCore core;
|
||||||
|
|
||||||
// Cameras.
|
// Cameras.
|
||||||
private OrthographicCamera camera;
|
private OrthographicCamera camera;
|
||||||
private OrthographicCamera pixelPerfectCamera;
|
private OrthographicCamera pixelPerfectCamera;
|
||||||
|
|
||||||
// Video stream graphics.
|
// Video stream graphics.
|
||||||
private Texture videoFrameTexture;
|
private Texture videoFrameTexture;
|
||||||
private Sprite renderableVideoFrame;
|
private Sprite renderableVideoFrame;
|
||||||
private Pixmap videoFrame;
|
private Pixmap videoFrame;
|
||||||
|
|
||||||
// Interface buttons.
|
// Interface buttons.
|
||||||
private Texture buttonTexture;
|
private Texture buttonTexture;
|
||||||
private Sprite motorA;
|
private Sprite motorA;
|
||||||
private Sprite motorB;
|
private Sprite motorB;
|
||||||
private Sprite motorC;
|
private Sprite motorC;
|
||||||
private Sprite motorD;
|
private Sprite motorD;
|
||||||
|
|
||||||
// Button touch helper fields.
|
// Button touch helper fields.
|
||||||
private Vector3 win2world;
|
private Vector3 win2world;
|
||||||
private Vector2 touchPointWorldCoords;
|
private Vector2 touchPointWorldCoords;
|
||||||
private boolean[] motorButtonsTouched;
|
private boolean[] motorButtonsTouched;
|
||||||
private int[] motorButtonsPointers;
|
private int[] motorButtonsPointers;
|
||||||
|
|
||||||
private VideoFrameMonitor frameMonitor;
|
private VideoFrameMonitor frameMonitor;
|
||||||
|
|
||||||
public InGameState(final NxtARCore core){
|
public InGameState(final NxtARCore core){
|
||||||
if(!Ouya.runningOnOuya) setUpButtons();
|
if(!Ouya.runningOnOuya) setUpButtons();
|
||||||
|
|
||||||
this.core = core;
|
this.core = core;
|
||||||
frameMonitor = VideoFrameMonitor.getInstance();
|
frameMonitor = VideoFrameMonitor.getInstance();
|
||||||
|
|
||||||
// Set up rendering fields;
|
// Set up rendering fields;
|
||||||
videoFrame = null;
|
videoFrame = null;
|
||||||
|
|
||||||
// Set up the cameras.
|
// Set up the cameras.
|
||||||
pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
camera = new OrthographicCamera(1.0f, Gdx.graphics.getHeight() / Gdx.graphics.getWidth());
|
camera = new OrthographicCamera(1.0f, Gdx.graphics.getHeight() / Gdx.graphics.getWidth());
|
||||||
|
|
||||||
// Set up input handling support fields.
|
// Set up input handling support fields.
|
||||||
win2world = new Vector3(0.0f, 0.0f, 0.0f);
|
win2world = new Vector3(0.0f, 0.0f, 0.0f);
|
||||||
touchPointWorldCoords = new Vector2();
|
touchPointWorldCoords = new Vector2();
|
||||||
motorButtonsTouched = new boolean[4];
|
motorButtonsTouched = new boolean[4];
|
||||||
motorButtonsTouched[0] = false;
|
motorButtonsTouched[0] = false;
|
||||||
motorButtonsTouched[1] = false;
|
motorButtonsTouched[1] = false;
|
||||||
motorButtonsTouched[2] = false;
|
motorButtonsTouched[2] = false;
|
||||||
motorButtonsTouched[3] = false;
|
motorButtonsTouched[3] = false;
|
||||||
|
|
||||||
motorButtonsPointers = new int[4];
|
motorButtonsPointers = new int[4];
|
||||||
motorButtonsPointers[0] = -1;
|
motorButtonsPointers[0] = -1;
|
||||||
motorButtonsPointers[1] = -1;
|
motorButtonsPointers[1] = -1;
|
||||||
motorButtonsPointers[2] = -1;
|
motorButtonsPointers[2] = -1;
|
||||||
motorButtonsPointers[3] = -1;
|
motorButtonsPointers[3] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
Pixmap temp;
|
Pixmap temp;
|
||||||
byte[] frame;
|
byte[] frame;
|
||||||
Size dimensions = null;
|
Size dimensions = null;
|
||||||
|
|
||||||
Gdx.gl.glClearColor(1, 1, 1, 1);
|
Gdx.gl.glClearColor(1, 1, 1, 1);
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
frame = frameMonitor.getCurrentFrame();
|
frame = frameMonitor.getCurrentFrame();
|
||||||
if(frame != null){
|
if(frame != null){
|
||||||
dimensions = frameMonitor.getFrameDimensions();
|
dimensions = frameMonitor.getFrameDimensions();
|
||||||
temp = new Pixmap(frame, 0, dimensions.getWidth() * dimensions.getHeight());
|
temp = new Pixmap(frame, 0, dimensions.getWidth() * dimensions.getHeight());
|
||||||
if(videoFrame == null){
|
if(videoFrame == null){
|
||||||
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.toast("Cannot display received frame.\n" + e.getMessage(), true);
|
core.toast("Cannot display received frame.\n" + e.getMessage(), true);
|
||||||
Gdx.app.exit();
|
Gdx.app.exit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
videoFrame.drawPixmap(temp, 0, 0);
|
videoFrame.drawPixmap(temp, 0, 0);
|
||||||
temp.dispose();
|
temp.dispose();
|
||||||
videoFrameTexture = new Texture(videoFrame);
|
videoFrameTexture = new Texture(videoFrame);
|
||||||
videoFrameTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
|
videoFrameTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
|
||||||
|
|
||||||
TextureRegion region = new TextureRegion(videoFrameTexture, 0, 0, dimensions.getWidth(), dimensions.getHeight());
|
TextureRegion region = new TextureRegion(videoFrameTexture, 0, 0, dimensions.getWidth(), dimensions.getHeight());
|
||||||
|
|
||||||
renderableVideoFrame = new Sprite(region);
|
renderableVideoFrame = new Sprite(region);
|
||||||
renderableVideoFrame.setOrigin(renderableVideoFrame.getWidth() / 2, renderableVideoFrame.getHeight() / 2);
|
renderableVideoFrame.setOrigin(renderableVideoFrame.getWidth() / 2, renderableVideoFrame.getHeight() / 2);
|
||||||
if(!Ouya.runningOnOuya){
|
if(!Ouya.runningOnOuya){
|
||||||
renderableVideoFrame.setSize(1.0f, renderableVideoFrame.getHeight() / renderableVideoFrame.getWidth() );
|
renderableVideoFrame.setSize(1.0f, renderableVideoFrame.getHeight() / renderableVideoFrame.getWidth() );
|
||||||
renderableVideoFrame.rotate90(true);
|
renderableVideoFrame.rotate90(true);
|
||||||
renderableVideoFrame.translate(-renderableVideoFrame.getWidth() / 2, 0.5f - renderableVideoFrame.getHeight());
|
renderableVideoFrame.translate(-renderableVideoFrame.getWidth() / 2, 0.5f - renderableVideoFrame.getHeight());
|
||||||
}else{
|
}else{
|
||||||
float xSize = Gdx.graphics.getHeight() * (dimensions.getWidth() / dimensions.getHeight());
|
float xSize = Gdx.graphics.getHeight() * (dimensions.getWidth() / dimensions.getHeight());
|
||||||
renderableVideoFrame.setSize(xSize * ProjectConstants.OVERSCAN, Gdx.graphics.getHeight() * ProjectConstants.OVERSCAN);
|
renderableVideoFrame.setSize(xSize * ProjectConstants.OVERSCAN, Gdx.graphics.getHeight() * ProjectConstants.OVERSCAN);
|
||||||
renderableVideoFrame.rotate90(true);
|
renderableVideoFrame.rotate90(true);
|
||||||
renderableVideoFrame.translate(-renderableVideoFrame.getWidth() / 2, -renderableVideoFrame.getHeight() / 2);
|
renderableVideoFrame.translate(-renderableVideoFrame.getWidth() / 2, -renderableVideoFrame.getHeight() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Ouya.runningOnOuya){
|
if(!Ouya.runningOnOuya){
|
||||||
core.batch.setProjectionMatrix(camera.combined);
|
core.batch.setProjectionMatrix(camera.combined);
|
||||||
}else{
|
}else{
|
||||||
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
|
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
|
||||||
}
|
}
|
||||||
core.batch.begin();{
|
core.batch.begin();{
|
||||||
renderableVideoFrame.draw(core.batch);
|
renderableVideoFrame.draw(core.batch);
|
||||||
}core.batch.end();
|
}core.batch.end();
|
||||||
|
|
||||||
videoFrameTexture.dispose();
|
videoFrameTexture.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
|
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
|
||||||
core.batch.begin();{
|
core.batch.begin();{
|
||||||
if(!Ouya.runningOnOuya){
|
if(!Ouya.runningOnOuya){
|
||||||
motorA.draw(core.batch);
|
motorA.draw(core.batch);
|
||||||
motorB.draw(core.batch);
|
motorB.draw(core.batch);
|
||||||
motorC.draw(core.batch);
|
motorC.draw(core.batch);
|
||||||
motorD.draw(core.batch);
|
motorD.draw(core.batch);
|
||||||
}
|
}
|
||||||
}core.batch.end();
|
}core.batch.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resize(int width, int height) {
|
public void resize(int width, int height) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hide() {
|
public void hide() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pause() {
|
public void pause() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resume() {
|
public void resume() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
if(videoFrameTexture != null)
|
if(videoFrameTexture != null)
|
||||||
videoFrameTexture.dispose();
|
videoFrameTexture.dispose();
|
||||||
if(buttonTexture != null)
|
if(buttonTexture != null)
|
||||||
buttonTexture.dispose();
|
buttonTexture.dispose();
|
||||||
if(videoFrame != null)
|
if(videoFrame != null)
|
||||||
videoFrame.dispose();
|
videoFrame.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getOptimalTextureSize(int imageSideLength) throws ImageTooBigException{
|
private int getOptimalTextureSize(int imageSideLength) throws ImageTooBigException{
|
||||||
for(int po2: ProjectConstants.POWERS_OF_2){
|
for(int po2: ProjectConstants.POWERS_OF_2){
|
||||||
if(imageSideLength < po2) return po2;
|
if(imageSideLength < po2) return po2;
|
||||||
}
|
}
|
||||||
throw new ImageTooBigException("No valid texture size found. Image too large.");
|
throw new ImageTooBigException("No valid texture size found. Image too large.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;
|
/*;;;;;;;;;;;;;;;;;;
|
||||||
; HELPER METHODS ;
|
; HELPER METHODS ;
|
||||||
;;;;;;;;;;;;;;;;;;*/
|
;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStateSet(){
|
public void onStateSet(){
|
||||||
Controllers.addListener(this);
|
stateActive = true;
|
||||||
Gdx.input.setInputProcessor(this);
|
Gdx.input.setInputProcessor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpButtons(){
|
@Override
|
||||||
buttonTexture = new Texture(Gdx.files.internal("data/gfx/gui/PBCrichton_Flat_Button.png"));
|
public void onStateUnset(){
|
||||||
buttonTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
|
stateActive = false;
|
||||||
|
Gdx.input.setInputProcessor(null);
|
||||||
TextureRegion region = new TextureRegion(buttonTexture, 0, 0, buttonTexture.getWidth(), buttonTexture.getHeight());
|
}
|
||||||
|
|
||||||
motorA = new Sprite(region);
|
private void setUpButtons(){
|
||||||
motorA.setSize(motorA.getWidth() * 0.7f, motorA.getHeight() * 0.7f);
|
buttonTexture = new Texture(Gdx.files.internal("data/gfx/gui/PBCrichton_Flat_Button.png"));
|
||||||
|
buttonTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
|
||||||
motorB = new Sprite(region);
|
|
||||||
motorB.setSize(motorB.getWidth() * 0.7f, motorB.getHeight() * 0.7f);
|
TextureRegion region = new TextureRegion(buttonTexture, 0, 0, buttonTexture.getWidth(), buttonTexture.getHeight());
|
||||||
|
|
||||||
motorC = new Sprite(region);
|
motorA = new Sprite(region);
|
||||||
motorC.setSize(motorC.getWidth() * 0.7f, motorC.getHeight() * 0.7f);
|
motorA.setSize(motorA.getWidth() * 0.7f, motorA.getHeight() * 0.7f);
|
||||||
|
|
||||||
motorD = new Sprite(region);
|
motorB = new Sprite(region);
|
||||||
motorD.setSize(motorD.getWidth() * 0.7f, motorD.getHeight() * 0.7f);
|
motorB.setSize(motorB.getWidth() * 0.7f, motorB.getHeight() * 0.7f);
|
||||||
|
|
||||||
motorA.setPosition(-(Gdx.graphics.getWidth() / 2) + 10, -(Gdx.graphics.getHeight() / 2) + motorB.getHeight() + 20);
|
motorC = new Sprite(region);
|
||||||
motorB.setPosition(-(Gdx.graphics.getWidth() / 2) + 20 + (motorA.getWidth() / 2), -(Gdx.graphics.getHeight() / 2) + 10);
|
motorC.setSize(motorC.getWidth() * 0.7f, motorC.getHeight() * 0.7f);
|
||||||
motorC.setPosition((Gdx.graphics.getWidth() / 2) - (1.5f * (motorD.getWidth())) - 20, -(Gdx.graphics.getHeight() / 2) + 10);
|
|
||||||
motorD.setPosition((Gdx.graphics.getWidth() / 2) - motorD.getWidth() - 10, -(Gdx.graphics.getHeight() / 2) + 20 + motorC.getHeight());
|
motorD = new Sprite(region);
|
||||||
}
|
motorD.setSize(motorD.getWidth() * 0.7f, motorD.getHeight() * 0.7f);
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
motorA.setPosition(-(Gdx.graphics.getWidth() / 2) + 10, -(Gdx.graphics.getHeight() / 2) + motorB.getHeight() + 20);
|
||||||
; BEGIN INPUT PROCESSOR METHODS ;
|
motorB.setPosition(-(Gdx.graphics.getWidth() / 2) + 20 + (motorA.getWidth() / 2), -(Gdx.graphics.getHeight() / 2) + 10);
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
motorC.setPosition((Gdx.graphics.getWidth() / 2) - (1.5f * (motorD.getWidth())) - 20, -(Gdx.graphics.getHeight() / 2) + 10);
|
||||||
|
motorD.setPosition((Gdx.graphics.getWidth() / 2) - motorD.getWidth() - 10, -(Gdx.graphics.getHeight() / 2) + 20 + motorC.getHeight());
|
||||||
@Override
|
}
|
||||||
public boolean keyDown(int keycode) {
|
|
||||||
// TODO Auto-generated method stub
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
return false;
|
; BEGIN INPUT PROCESSOR METHODS ;
|
||||||
}
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyUp(int keycode) {
|
public boolean keyDown(int keycode) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyTyped(char character) {
|
public boolean keyUp(int keycode) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
|
public boolean keyTyped(char character) {
|
||||||
if(!Ouya.runningOnOuya){
|
// TODO Auto-generated method stub
|
||||||
win2world.set(screenX, screenY, 0.0f);
|
return false;
|
||||||
camera.unproject(win2world);
|
}
|
||||||
touchPointWorldCoords.set(win2world.x * Gdx.graphics.getWidth(), win2world.y * Gdx.graphics.getHeight());
|
|
||||||
|
@Override
|
||||||
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown(%d, %d, %d, %d)", screenX, screenY, pointer, button));
|
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
|
||||||
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
|
if(!Ouya.runningOnOuya){
|
||||||
|
win2world.set(screenX, screenY, 0.0f);
|
||||||
if(motorA.getBoundingRectangle().contains(touchPointWorldCoords)){
|
camera.unproject(win2world);
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Motor A button pressed");
|
touchPointWorldCoords.set(win2world.x * Gdx.graphics.getWidth(), win2world.y * Gdx.graphics.getHeight());
|
||||||
motorButtonsTouched[0] = true;
|
|
||||||
motorButtonsPointers[0] = pointer;
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown(%d, %d, %d, %d)", screenX, screenY, pointer, button));
|
||||||
}else if(motorB.getBoundingRectangle().contains(touchPointWorldCoords)){
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Motor B button pressed");
|
|
||||||
motorButtonsTouched[1] = true;
|
if(motorA.getBoundingRectangle().contains(touchPointWorldCoords)){
|
||||||
motorButtonsPointers[1] = pointer;
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Motor A button pressed");
|
||||||
}else if(motorC.getBoundingRectangle().contains(touchPointWorldCoords)){
|
motorButtonsTouched[0] = true;
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Motor C button pressed");
|
motorButtonsPointers[0] = pointer;
|
||||||
motorButtonsTouched[2] = true;
|
}else if(motorB.getBoundingRectangle().contains(touchPointWorldCoords)){
|
||||||
motorButtonsPointers[2] = pointer;
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Motor B button pressed");
|
||||||
}else if(motorD.getBoundingRectangle().contains(touchPointWorldCoords)){
|
motorButtonsTouched[1] = true;
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Motor D button pressed");
|
motorButtonsPointers[1] = pointer;
|
||||||
motorButtonsTouched[3] = true;
|
}else if(motorC.getBoundingRectangle().contains(touchPointWorldCoords)){
|
||||||
motorButtonsPointers[3] = pointer;
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Motor C button pressed");
|
||||||
}
|
motorButtonsTouched[2] = true;
|
||||||
}
|
motorButtonsPointers[2] = pointer;
|
||||||
return true;
|
}else if(motorD.getBoundingRectangle().contains(touchPointWorldCoords)){
|
||||||
}
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Motor D button pressed");
|
||||||
|
motorButtonsTouched[3] = true;
|
||||||
@Override
|
motorButtonsPointers[3] = pointer;
|
||||||
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
|
}
|
||||||
if(!Ouya.runningOnOuya){
|
}
|
||||||
win2world.set(screenX, screenY, 0.0f);
|
return true;
|
||||||
camera.unproject(win2world);
|
}
|
||||||
touchPointWorldCoords.set(win2world.x * Gdx.graphics.getWidth(), win2world.y * Gdx.graphics.getHeight());
|
|
||||||
|
@Override
|
||||||
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp(%d, %d, %d, %d)", screenX, screenY, pointer, button));
|
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
|
||||||
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
|
if(!Ouya.runningOnOuya){
|
||||||
|
win2world.set(screenX, screenY, 0.0f);
|
||||||
if(motorA.getBoundingRectangle().contains(touchPointWorldCoords)){
|
camera.unproject(win2world);
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".touchUp() :: Motor A button released");
|
touchPointWorldCoords.set(win2world.x * Gdx.graphics.getWidth(), win2world.y * Gdx.graphics.getHeight());
|
||||||
motorButtonsPointers[0] = -1;
|
|
||||||
motorButtonsTouched[0] = false;
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp(%d, %d, %d, %d)", screenX, screenY, pointer, button));
|
||||||
}else if(motorB.getBoundingRectangle().contains(touchPointWorldCoords)){
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".touchUp() :: Motor B button released");
|
|
||||||
motorButtonsPointers[1] = -1;
|
if(motorA.getBoundingRectangle().contains(touchPointWorldCoords)){
|
||||||
motorButtonsTouched[1] = false;
|
Gdx.app.log(TAG, CLASS_NAME + ".touchUp() :: Motor A button released");
|
||||||
}else if(motorC.getBoundingRectangle().contains(touchPointWorldCoords)){
|
motorButtonsPointers[0] = -1;
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".touchUp() :: Motor C button released");
|
motorButtonsTouched[0] = false;
|
||||||
motorButtonsPointers[2] = -1;
|
}else if(motorB.getBoundingRectangle().contains(touchPointWorldCoords)){
|
||||||
motorButtonsTouched[2] = false;
|
Gdx.app.log(TAG, CLASS_NAME + ".touchUp() :: Motor B button released");
|
||||||
}else if(motorD.getBoundingRectangle().contains(touchPointWorldCoords)){
|
motorButtonsPointers[1] = -1;
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".touchUp() :: Motor D button released");
|
motorButtonsTouched[1] = false;
|
||||||
motorButtonsPointers[3] = -1;
|
}else if(motorC.getBoundingRectangle().contains(touchPointWorldCoords)){
|
||||||
motorButtonsTouched[3] = false;
|
Gdx.app.log(TAG, CLASS_NAME + ".touchUp() :: Motor C button released");
|
||||||
}
|
motorButtonsPointers[2] = -1;
|
||||||
}
|
motorButtonsTouched[2] = false;
|
||||||
return true;
|
}else if(motorD.getBoundingRectangle().contains(touchPointWorldCoords)){
|
||||||
}
|
Gdx.app.log(TAG, CLASS_NAME + ".touchUp() :: Motor D button released");
|
||||||
|
motorButtonsPointers[3] = -1;
|
||||||
@Override
|
motorButtonsTouched[3] = false;
|
||||||
public boolean touchDragged(int screenX, int screenY, int pointer) {
|
}
|
||||||
if(!Ouya.runningOnOuya){
|
}
|
||||||
win2world.set(screenX, screenY, 0.0f);
|
return true;
|
||||||
camera.unproject(win2world);
|
}
|
||||||
touchPointWorldCoords.set(win2world.x * Gdx.graphics.getWidth(), win2world.y * Gdx.graphics.getHeight());
|
|
||||||
|
@Override
|
||||||
if(pointer == motorButtonsPointers[0] && !motorA.getBoundingRectangle().contains(touchPointWorldCoords)){
|
public boolean touchDragged(int screenX, int screenY, int pointer) {
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Motor A button released");
|
if(!Ouya.runningOnOuya){
|
||||||
motorButtonsPointers[0] = -1;
|
win2world.set(screenX, screenY, 0.0f);
|
||||||
motorButtonsTouched[0] = false;
|
camera.unproject(win2world);
|
||||||
}else if(pointer == motorButtonsPointers[1] && !motorB.getBoundingRectangle().contains(touchPointWorldCoords)){
|
touchPointWorldCoords.set(win2world.x * Gdx.graphics.getWidth(), win2world.y * Gdx.graphics.getHeight());
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Motor B button released");
|
|
||||||
motorButtonsPointers[1] = -1;
|
if(pointer == motorButtonsPointers[0] && !motorA.getBoundingRectangle().contains(touchPointWorldCoords)){
|
||||||
motorButtonsTouched[1] = false;
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Motor A button released");
|
||||||
}else if(pointer == motorButtonsPointers[2] && !motorC.getBoundingRectangle().contains(touchPointWorldCoords)){
|
motorButtonsPointers[0] = -1;
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Motor C button released");
|
motorButtonsTouched[0] = false;
|
||||||
motorButtonsPointers[2] = -1;
|
}else if(pointer == motorButtonsPointers[1] && !motorB.getBoundingRectangle().contains(touchPointWorldCoords)){
|
||||||
motorButtonsTouched[2] = false;
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Motor B button released");
|
||||||
}else if(pointer == motorButtonsPointers[3] && !motorD.getBoundingRectangle().contains(touchPointWorldCoords)){
|
motorButtonsPointers[1] = -1;
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Motor D button released");
|
motorButtonsTouched[1] = false;
|
||||||
motorButtonsPointers[3] = -1;
|
}else if(pointer == motorButtonsPointers[2] && !motorC.getBoundingRectangle().contains(touchPointWorldCoords)){
|
||||||
motorButtonsTouched[3] = false;
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Motor C button released");
|
||||||
}
|
motorButtonsPointers[2] = -1;
|
||||||
}
|
motorButtonsTouched[2] = false;
|
||||||
return true;
|
}else if(pointer == motorButtonsPointers[3] && !motorD.getBoundingRectangle().contains(touchPointWorldCoords)){
|
||||||
}
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Motor D button released");
|
||||||
|
motorButtonsPointers[3] = -1;
|
||||||
@Override
|
motorButtonsTouched[3] = false;
|
||||||
public boolean mouseMoved(int screenX, int screenY) {
|
}
|
||||||
// TODO Auto-generated method stub
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
@Override
|
||||||
; BEGIN CONTROLLER LISTENER METHODS ;
|
public boolean mouseMoved(int screenX, int screenY) {
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
@Override
|
}
|
||||||
public boolean scrolled(int amount) {
|
|
||||||
// TODO Auto-generated method stub
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
return false;
|
; BEGIN CONTROLLER LISTENER METHODS ;
|
||||||
}
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connected(Controller controller) {
|
public boolean buttonDown(Controller controller, int buttonCode) {
|
||||||
// TODO Auto-generated method stub
|
if(stateActive){
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".buttonDown() :: " + controller.getName() + " :: " + Integer.toString(buttonCode));
|
||||||
}
|
return true;
|
||||||
|
}else{
|
||||||
@Override
|
return false;
|
||||||
public void disconnected(Controller controller) {
|
}
|
||||||
// TODO Auto-generated method stub
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public boolean buttonUp(Controller controller, int buttonCode) {
|
||||||
@Override
|
if(stateActive){
|
||||||
public boolean buttonDown(Controller controller, int buttonCode) {
|
Gdx.app.log(TAG, CLASS_NAME + ".buttonDown() :: " + controller.getName() + " :: " + Integer.toString(buttonCode));
|
||||||
if(buttonCode == Ouya.BUTTON_L1){
|
return true;
|
||||||
// Start right motor.
|
}else{
|
||||||
}
|
return false;
|
||||||
if(buttonCode == Ouya.BUTTON_L2){
|
}
|
||||||
// Start left motor.
|
}
|
||||||
}
|
|
||||||
if(buttonCode == Ouya.BUTTON_DPAD_LEFT){
|
@Override
|
||||||
// Look left.
|
public boolean axisMoved(Controller controller, int axisCode, float value) {
|
||||||
}
|
if(stateActive){
|
||||||
if(buttonCode == Ouya.BUTTON_DPAD_RIGHT){
|
if(value >= Ouya.STICK_DEADZONE){
|
||||||
// Look right;
|
if(axisCode == Ouya.AXIS_LEFT_TRIGGER){
|
||||||
}
|
Gdx.app.log(TAG, CLASS_NAME + ".axisMoved() :: LEFT TRIGGER pressed.");
|
||||||
return false;
|
}
|
||||||
}
|
if(axisCode == Ouya.AXIS_RIGHT_TRIGGER){
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".axisMoved() :: RIGHT TRIGGER pressed.");
|
||||||
@Override
|
}
|
||||||
public boolean buttonUp(Controller controller, int buttonCode) {
|
}
|
||||||
// TODO Auto-generated method stub
|
return true;
|
||||||
return false;
|
}else{
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
@Override
|
}
|
||||||
public boolean axisMoved(Controller controller, int axisCode, float value) {
|
|
||||||
if(axisCode == Ouya.AXIS_LEFT_TRIGGER){
|
@Override
|
||||||
|
public boolean scrolled(int amount) {
|
||||||
}
|
// TODO Auto-generated method stub
|
||||||
if(axisCode == Ouya.AXIS_RIGHT_TRIGGER){
|
return false;
|
||||||
// Start
|
}
|
||||||
}
|
|
||||||
return false;
|
@Override
|
||||||
}
|
public void connected(Controller controller) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
@Override
|
|
||||||
public boolean povMoved(Controller controller, int povCode,
|
}
|
||||||
PovDirection value) {
|
|
||||||
// TODO Auto-generated method stub
|
@Override
|
||||||
return false;
|
public void disconnected(Controller controller) {
|
||||||
}
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public boolean xSliderMoved(Controller controller, int sliderCode,
|
|
||||||
boolean value) {
|
@Override
|
||||||
// TODO Auto-generated method stub
|
public boolean povMoved(Controller controller, int povCode,
|
||||||
return false;
|
PovDirection value) {
|
||||||
}
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
@Override
|
}
|
||||||
public boolean ySliderMoved(Controller controller, int sliderCode,
|
|
||||||
boolean value) {
|
@Override
|
||||||
// TODO Auto-generated method stub
|
public boolean xSliderMoved(Controller controller, int sliderCode,
|
||||||
return false;
|
boolean value) {
|
||||||
}
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
@Override
|
}
|
||||||
public boolean accelerometerMoved(Controller controller,
|
|
||||||
int accelerometerCode, Vector3 value) {
|
@Override
|
||||||
// TODO Auto-generated method stub
|
public boolean ySliderMoved(Controller controller, int sliderCode,
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -1,139 +1,234 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Miguel Angel Astor Romero
|
* Copyright (C) 2014 Miguel Angel Astor Romero
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar.states;
|
package ve.ucv.ciens.ccg.nxtar.states;
|
||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.controllers.Controllers;
|
import com.badlogic.gdx.controllers.Controller;
|
||||||
import com.badlogic.gdx.controllers.mappings.Ouya;
|
import com.badlogic.gdx.controllers.PovDirection;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.controllers.mappings.Ouya;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.NinePatch;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
import com.badlogic.gdx.graphics.g2d.NinePatch;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
|
import com.badlogic.gdx.math.Vector3;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
|
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{
|
|
||||||
protected static final String TAG = "MAIN_MENU";
|
|
||||||
|
public abstract class MainMenuStateBase extends BaseState{
|
||||||
// Client connection helper fields.
|
protected static final String TAG = "MAIN_MENU";
|
||||||
protected boolean clientConnected;
|
|
||||||
|
// Client connection helper fields.
|
||||||
// Buttons and other gui components.
|
protected boolean clientConnected;
|
||||||
protected TextButton startButton;
|
|
||||||
protected Rectangle startButtonBBox;
|
// Buttons and other gui components.
|
||||||
protected Sprite clientConnectedLedOn;
|
protected TextButton startButton;
|
||||||
protected Sprite clientConnectedLedOff;
|
protected Rectangle startButtonBBox;
|
||||||
|
protected Sprite clientConnectedLedOn;
|
||||||
// Graphic data for the start button.
|
protected Sprite clientConnectedLedOff;
|
||||||
private Texture startButtonEnabledTexture;
|
|
||||||
private Texture startButtonDisabledTexture;
|
// Graphic data for the start button.
|
||||||
private Texture startButtonPressedTexture;
|
private Texture startButtonEnabledTexture;
|
||||||
private NinePatch startButtonEnabled9p;
|
private Texture startButtonDisabledTexture;
|
||||||
private NinePatch startButtonDisabled9p;
|
private Texture startButtonPressedTexture;
|
||||||
private NinePatch startButtonPressed9p;
|
private NinePatch startButtonEnabled9p;
|
||||||
private BitmapFont font;
|
private NinePatch startButtonDisabled9p;
|
||||||
|
private NinePatch startButtonPressed9p;
|
||||||
// Other graphics.
|
private BitmapFont font;
|
||||||
private Texture clientConnectedLedOffTexture;
|
|
||||||
private Texture clientConnectedLedOnTexture;
|
// Other graphics.
|
||||||
|
private Texture clientConnectedLedOffTexture;
|
||||||
public MainMenuStateBase(){
|
private Texture clientConnectedLedOnTexture;
|
||||||
// Create the start button background.
|
|
||||||
startButtonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png"));
|
public MainMenuStateBase(){
|
||||||
startButtonEnabled9p = new NinePatch(new TextureRegion(startButtonEnabledTexture, 0, 0, startButtonEnabledTexture.getWidth(), startButtonEnabledTexture.getHeight()), 49, 49, 45, 45);
|
// Create the start button background.
|
||||||
|
startButtonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png"));
|
||||||
startButtonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png"));
|
startButtonEnabled9p = new NinePatch(new TextureRegion(startButtonEnabledTexture, 0, 0, startButtonEnabledTexture.getWidth(), startButtonEnabledTexture.getHeight()), 49, 49, 45, 45);
|
||||||
startButtonDisabled9p = new NinePatch(new TextureRegion(startButtonDisabledTexture, 0, 0, startButtonDisabledTexture.getWidth(), startButtonDisabledTexture.getHeight()), 49, 49, 45, 45);
|
|
||||||
|
startButtonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png"));
|
||||||
startButtonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png"));
|
startButtonDisabled9p = new NinePatch(new TextureRegion(startButtonDisabledTexture, 0, 0, startButtonDisabledTexture.getWidth(), startButtonDisabledTexture.getHeight()), 49, 49, 45, 45);
|
||||||
startButtonPressed9p = new NinePatch(new TextureRegion(startButtonPressedTexture, 0, 0, startButtonPressedTexture.getWidth(), startButtonPressedTexture.getHeight()), 49, 49, 45, 45);
|
|
||||||
|
startButtonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png"));
|
||||||
// Create the start button font.
|
startButtonPressed9p = new NinePatch(new TextureRegion(startButtonPressedTexture, 0, 0, startButtonPressedTexture.getWidth(), startButtonPressedTexture.getHeight()), 49, 49, 45, 45);
|
||||||
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);
|
// Create the start button font.
|
||||||
generator.dispose();
|
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);
|
||||||
// Create the start button itself.
|
generator.dispose();
|
||||||
TextButtonStyle tbs = new TextButtonStyle();
|
|
||||||
tbs.font = font;
|
// Create the start button itself.
|
||||||
tbs.up = new NinePatchDrawable(startButtonEnabled9p);
|
TextButtonStyle tbs = new TextButtonStyle();
|
||||||
tbs.checked = new NinePatchDrawable(startButtonPressed9p);
|
tbs.font = font;
|
||||||
tbs.disabled = new NinePatchDrawable(startButtonDisabled9p);
|
tbs.up = new NinePatchDrawable(startButtonEnabled9p);
|
||||||
tbs.disabledFontColor = new Color(0, 0, 0, 1);
|
tbs.checked = new NinePatchDrawable(startButtonPressed9p);
|
||||||
startButton = new TextButton("Start server", tbs);
|
tbs.disabled = new NinePatchDrawable(startButtonDisabled9p);
|
||||||
startButton.setText("Start game");
|
tbs.disabledFontColor = new Color(0, 0, 0, 1);
|
||||||
startButton.setDisabled(true);
|
startButton = new TextButton("Start server", tbs);
|
||||||
startButtonBBox = new Rectangle(0, 0, startButton.getWidth(), startButton.getHeight());
|
startButton.setText("Start game");
|
||||||
|
startButton.setDisabled(true);
|
||||||
// Create the connection leds.
|
startButtonBBox = new Rectangle(0, 0, startButton.getWidth(), startButton.getHeight());
|
||||||
TextureRegion region;
|
|
||||||
clientConnectedLedOnTexture = new Texture("data/gfx/gui/Anonymous_Button_Green.png");
|
// Create the connection leds.
|
||||||
region = new TextureRegion(clientConnectedLedOnTexture, clientConnectedLedOnTexture.getWidth(), clientConnectedLedOnTexture.getHeight());
|
TextureRegion region;
|
||||||
clientConnectedLedOn = new Sprite(region);
|
clientConnectedLedOnTexture = new Texture("data/gfx/gui/Anonymous_Button_Green.png");
|
||||||
|
region = new TextureRegion(clientConnectedLedOnTexture, clientConnectedLedOnTexture.getWidth(), clientConnectedLedOnTexture.getHeight());
|
||||||
clientConnectedLedOffTexture = new Texture("data/gfx/gui/Anonymous_Button_Red.png");
|
clientConnectedLedOn = new Sprite(region);
|
||||||
region = new TextureRegion(clientConnectedLedOffTexture, clientConnectedLedOffTexture.getWidth(), clientConnectedLedOffTexture.getHeight());
|
|
||||||
clientConnectedLedOff = new Sprite(region);
|
clientConnectedLedOffTexture = new Texture("data/gfx/gui/Anonymous_Button_Red.png");
|
||||||
|
region = new TextureRegion(clientConnectedLedOffTexture, clientConnectedLedOffTexture.getWidth(), clientConnectedLedOffTexture.getHeight());
|
||||||
clientConnected = false;
|
clientConnectedLedOff = new Sprite(region);
|
||||||
}
|
|
||||||
|
clientConnected = false;
|
||||||
@Override
|
|
||||||
public abstract void render(float delta);
|
stateActive = false;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public abstract void resize(int width, int height);
|
@Override
|
||||||
|
public abstract void render(float delta);
|
||||||
@Override
|
|
||||||
public abstract void show();
|
@Override
|
||||||
@Override
|
public abstract void resize(int width, int height);
|
||||||
public abstract void hide();
|
|
||||||
|
@Override
|
||||||
@Override
|
public abstract void show();
|
||||||
public abstract void pause();
|
@Override
|
||||||
|
public abstract void hide();
|
||||||
@Override
|
|
||||||
public abstract void resume();
|
@Override
|
||||||
|
public abstract void pause();
|
||||||
@Override
|
|
||||||
public void dispose(){
|
@Override
|
||||||
startButtonEnabledTexture.dispose();
|
public abstract void resume();
|
||||||
startButtonDisabledTexture.dispose();
|
|
||||||
startButtonPressedTexture.dispose();
|
@Override
|
||||||
clientConnectedLedOnTexture.dispose();
|
public void dispose(){
|
||||||
clientConnectedLedOffTexture.dispose();
|
startButtonEnabledTexture.dispose();
|
||||||
font.dispose();
|
startButtonDisabledTexture.dispose();
|
||||||
}
|
startButtonPressedTexture.dispose();
|
||||||
|
clientConnectedLedOnTexture.dispose();
|
||||||
@Override
|
clientConnectedLedOffTexture.dispose();
|
||||||
public void onStateSet(){
|
font.dispose();
|
||||||
Controllers.addListener(this);
|
}
|
||||||
Gdx.input.setInputProcessor(this);
|
|
||||||
}
|
@Override
|
||||||
|
public void onStateSet(){
|
||||||
public void onClientConnected(){
|
stateActive = true;
|
||||||
clientConnected = true;
|
Gdx.input.setInputProcessor(this);
|
||||||
startButton.setDisabled(false);
|
}
|
||||||
}
|
|
||||||
}
|
@Override
|
||||||
|
public void onStateUnset(){
|
||||||
|
stateActive = false;
|
||||||
|
Gdx.input.setInputProcessor(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClientConnected(){
|
||||||
|
clientConnected = true;
|
||||||
|
startButton.setDisabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; INPUT LISTENER METHOD STUBS ;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean keyDown(int keycode){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean keyUp(int keycode){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean keyTyped(char character){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean touchDown(int screenX, int screenY, int pointer, int button){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean touchUp(int screenX, int screenY, int pointer, int button){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean touchDragged(int screenX, int screenY, int pointer){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseMoved(int screenX, int screenY){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean scrolled(int amount){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connected(Controller controller){ }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disconnected(Controller controller){ }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean buttonDown(Controller controller, int buttonCode){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean buttonUp(Controller controller, int buttonCode){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean axisMoved(Controller controller, int axisCode, float value){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean povMoved(Controller controller, int povCode, PovDirection value){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean xSliderMoved(Controller controller, int sliderCode, boolean value){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean ySliderMoved(Controller controller, int sliderCode, boolean value){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accelerometerMoved(Controller controller, int accelerometerCode, Vector3 value){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -1,204 +1,155 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Miguel Angel Astor Romero
|
* Copyright (C) 2014 Miguel Angel Astor Romero
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
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.Gdx;
|
||||||
import com.badlogic.gdx.controllers.Controllers;
|
import com.badlogic.gdx.controllers.Controller;
|
||||||
import com.badlogic.gdx.controllers.PovDirection;
|
import com.badlogic.gdx.controllers.mappings.Ouya;
|
||||||
import com.badlogic.gdx.graphics.GL10;
|
import com.badlogic.gdx.graphics.GL10;
|
||||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
import com.badlogic.gdx.math.Vector3;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||||
public class OuyaMainMenuState extends MainMenuStateBase{
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
private OrthographicCamera pixelPerfectCamera;
|
|
||||||
|
public class OuyaMainMenuState extends MainMenuStateBase{
|
||||||
public OuyaMainMenuState(final NxtARCore core){
|
private static final String CLASS_NAME = OuyaMainMenuState.class.getSimpleName();
|
||||||
this.core = core;
|
|
||||||
this.pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
private OrthographicCamera pixelPerfectCamera;
|
||||||
}
|
private Texture ouyaOButtonTexture;
|
||||||
|
private Sprite ouyaOButton;
|
||||||
@Override
|
private boolean oButtonPressed;
|
||||||
public void render(float delta) {
|
|
||||||
Gdx.gl.glClearColor(1, 1, 1, 1);
|
public OuyaMainMenuState(final NxtARCore core){
|
||||||
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
|
this.core = core;
|
||||||
|
this.pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
|
|
||||||
core.batch.begin();{
|
startButton.setPosition(-(startButton.getWidth() / 2), -(startButton.getHeight() / 2));
|
||||||
this.startButton.draw(core.batch, 1.0f);
|
startButtonBBox.setPosition(startButton.getX(), startButton.getY());
|
||||||
}core.batch.end();
|
|
||||||
}
|
float ledYPos = (-(Gdx.graphics.getHeight() / 2) * 0.5f) + (startButton.getY() * 0.5f);
|
||||||
|
clientConnectedLedOn.setSize(clientConnectedLedOn.getWidth() * 0.5f, clientConnectedLedOn.getHeight() * 0.5f);
|
||||||
@Override
|
clientConnectedLedOn.setPosition(-(clientConnectedLedOn.getWidth() / 2), ledYPos);
|
||||||
public void resize(int width, int height) {
|
|
||||||
// TODO Auto-generated method stub
|
clientConnectedLedOff.setSize(clientConnectedLedOff.getWidth() * 0.5f, clientConnectedLedOff.getHeight() * 0.5f);
|
||||||
|
clientConnectedLedOff.setPosition(-(clientConnectedLedOff.getWidth() / 2), ledYPos);
|
||||||
}
|
|
||||||
|
ouyaOButtonTexture = new Texture("data/gfx/gui/OUYA_O.png");
|
||||||
@Override
|
TextureRegion region = new TextureRegion(ouyaOButtonTexture, ouyaOButtonTexture.getWidth(), ouyaOButtonTexture.getHeight());
|
||||||
public void show() {
|
ouyaOButton = new Sprite(region);
|
||||||
// TODO Auto-generated method stub
|
ouyaOButton.setSize(ouyaOButton.getWidth() * 0.6f, ouyaOButton.getHeight() * 0.6f);
|
||||||
|
ouyaOButton.setPosition(startButton.getX() - ouyaOButton.getWidth() - 20, startButton.getY());
|
||||||
}
|
|
||||||
|
oButtonPressed = false;
|
||||||
@Override
|
}
|
||||||
public void hide() {
|
|
||||||
// TODO Auto-generated method stub
|
@Override
|
||||||
|
public void render(float delta) {
|
||||||
}
|
Gdx.gl.glClearColor(1, 1, 1, 1);
|
||||||
|
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
|
||||||
@Override
|
|
||||||
public void pause() {
|
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
|
||||||
// TODO Auto-generated method stub
|
core.batch.begin();{
|
||||||
|
if(clientConnected){
|
||||||
}
|
clientConnectedLedOn.draw(core.batch);
|
||||||
|
}else{
|
||||||
@Override
|
clientConnectedLedOff.draw(core.batch);
|
||||||
public void resume() {
|
}
|
||||||
// TODO Auto-generated method stub
|
startButton.draw(core.batch, 1.0f);
|
||||||
|
ouyaOButton.draw(core.batch);
|
||||||
}
|
}core.batch.end();
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void dispose(){
|
@Override
|
||||||
super.dispose();
|
public void resize(int width, int height) {
|
||||||
}
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;
|
}
|
||||||
; HELPER METHODS ;
|
|
||||||
;;;;;;;;;;;;;;;;;;*/
|
@Override
|
||||||
|
public void show() {
|
||||||
@Override
|
// TODO Auto-generated method stub
|
||||||
public void onStateSet(){
|
|
||||||
super.onStateSet();
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
public void hide() {
|
||||||
; BEGIN INPUT PROCESSOR METHODS ;
|
// TODO Auto-generated method stub
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean keyDown(int keycode) {
|
@Override
|
||||||
// TODO Auto-generated method stub
|
public void pause() {
|
||||||
return false;
|
// TODO Auto-generated method stub
|
||||||
}
|
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean keyUp(int keycode) {
|
@Override
|
||||||
// TODO Auto-generated method stub
|
public void resume() {
|
||||||
return false;
|
// TODO Auto-generated method stub
|
||||||
}
|
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean keyTyped(char character) {
|
@Override
|
||||||
// TODO Auto-generated method stub
|
public void dispose(){
|
||||||
return false;
|
super.dispose();
|
||||||
}
|
ouyaOButtonTexture.dispose();
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
// TODO Auto-generated method stub
|
; BEGIN CONTROLLER LISTENER METHODS ;
|
||||||
return false;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean buttonDown(Controller controller, int buttonCode) {
|
||||||
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
|
if(stateActive){
|
||||||
// TODO Auto-generated method stub
|
if(buttonCode == Ouya.BUTTON_O){
|
||||||
return false;
|
if(!clientConnected){
|
||||||
}
|
core.toast("Can't start the game. No client is connected.", true);
|
||||||
|
}else{
|
||||||
@Override
|
oButtonPressed = true;
|
||||||
public boolean touchDragged(int screenX, int screenY, int pointer) {
|
startButton.setChecked(true);
|
||||||
// TODO Auto-generated method stub
|
}
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
return true;
|
||||||
@Override
|
|
||||||
public boolean mouseMoved(int screenX, int screenY) {
|
}else{
|
||||||
// TODO Auto-generated method stub
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
@Override
|
||||||
; BEGIN CONTROLLER LISTENER METHODS ;
|
public boolean buttonUp(Controller controller, int buttonCode) {
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
if(stateActive){
|
||||||
|
if(buttonCode == Ouya.BUTTON_O){
|
||||||
@Override
|
if(oButtonPressed){
|
||||||
public boolean scrolled(int amount) {
|
oButtonPressed = false;
|
||||||
// TODO Auto-generated method stub
|
startButton.setChecked(false);
|
||||||
return false;
|
core.nextState = game_states_t.IN_GAME;
|
||||||
}
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button released.");
|
||||||
|
}
|
||||||
@Override
|
}
|
||||||
public void connected(Controller controller) {
|
|
||||||
// TODO Auto-generated method stub
|
return true;
|
||||||
|
|
||||||
}
|
}else{
|
||||||
|
return false;
|
||||||
@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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean buttonUp(Controller controller, int buttonCode) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean axisMoved(Controller controller, int axisCode, float value) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean povMoved(Controller controller, int povCode,
|
|
||||||
PovDirection value) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean xSliderMoved(Controller controller, int sliderCode,
|
|
||||||
boolean value) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -1,198 +1,204 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Miguel Angel Astor Romero
|
* Copyright (C) 2014 Miguel Angel Astor Romero
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
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 com.badlogic.gdx.controllers.Controller;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.controllers.PovDirection;
|
import com.badlogic.gdx.controllers.Controller;
|
||||||
import com.badlogic.gdx.math.Vector3;
|
import com.badlogic.gdx.controllers.Controllers;
|
||||||
|
import com.badlogic.gdx.controllers.PovDirection;
|
||||||
public class PauseState extends BaseState {
|
import com.badlogic.gdx.math.Vector3;
|
||||||
|
|
||||||
public PauseState(final NxtARCore core){
|
public class PauseState extends BaseState {
|
||||||
this.core = core;
|
|
||||||
}
|
public PauseState(final NxtARCore core){
|
||||||
|
this.core = core;
|
||||||
@Override
|
}
|
||||||
public void render(float delta) {
|
|
||||||
// TODO Auto-generated method stub
|
@Override
|
||||||
|
public void render(float delta) {
|
||||||
}
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public void resize(int width, int height) {
|
|
||||||
// TODO Auto-generated method stub
|
@Override
|
||||||
|
public void resize(int width, int height) {
|
||||||
}
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public void show() {
|
|
||||||
// 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 hide() {
|
||||||
}
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public void pause() {
|
|
||||||
// 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 resume() {
|
||||||
}
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public void dispose() {
|
|
||||||
// TODO Auto-generated method stub
|
@Override
|
||||||
|
public void dispose() {
|
||||||
}
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;
|
}
|
||||||
; HELPER METHODS ;
|
|
||||||
;;;;;;;;;;;;;;;;;;*/
|
/*;;;;;;;;;;;;;;;;;;
|
||||||
|
; HELPER METHODS ;
|
||||||
@Override
|
;;;;;;;;;;;;;;;;;;*/
|
||||||
public void onStateSet(){
|
|
||||||
}
|
@Override
|
||||||
|
public void onStateSet(){
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
}
|
||||||
; BEGIN INPUT PROCESSOR METHODS ;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
@Override
|
||||||
|
public void onStateUnset(){
|
||||||
@Override
|
}
|
||||||
public boolean keyDown(int keycode) {
|
|
||||||
// TODO Auto-generated method stub
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
return false;
|
; BEGIN INPUT PROCESSOR METHODS ;
|
||||||
}
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyUp(int keycode) {
|
public boolean keyDown(int keycode) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyTyped(char character) {
|
public boolean keyUp(int keycode) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
|
public boolean keyTyped(char character) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
|
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDragged(int screenX, int screenY, int pointer) {
|
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseMoved(int screenX, int screenY) {
|
public boolean touchDragged(int screenX, int screenY, int pointer) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
; END INPUT PROCESSOR METHODS ;
|
@Override
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
public boolean mouseMoved(int screenX, int screenY) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
return false;
|
||||||
; BEGIN CONTROLLER LISTENER METHODS ;
|
}
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
@Override
|
; END INPUT PROCESSOR METHODS ;
|
||||||
public boolean scrolled(int amount) {
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
}
|
; BEGIN CONTROLLER LISTENER METHODS ;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
@Override
|
@Override
|
||||||
public void connected(Controller controller) {
|
public boolean scrolled(int amount) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected(Controller controller) {
|
public void connected(Controller controller) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean buttonDown(Controller controller, int buttonCode) {
|
public void disconnected(Controller controller) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean buttonUp(Controller controller, int buttonCode) {
|
public boolean buttonDown(Controller controller, int buttonCode) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean axisMoved(Controller controller, int axisCode, float value) {
|
public boolean buttonUp(Controller controller, int buttonCode) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean povMoved(Controller controller, int povCode,
|
public boolean axisMoved(Controller controller, int axisCode, float value) {
|
||||||
PovDirection value) {
|
// TODO Auto-generated method stub
|
||||||
// TODO Auto-generated method stub
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean povMoved(Controller controller, int povCode,
|
||||||
public boolean xSliderMoved(Controller controller, int sliderCode,
|
PovDirection value) {
|
||||||
boolean value) {
|
// TODO Auto-generated method stub
|
||||||
// TODO Auto-generated method stub
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean xSliderMoved(Controller controller, int sliderCode,
|
||||||
public boolean ySliderMoved(Controller controller, int sliderCode,
|
boolean value) {
|
||||||
boolean value) {
|
// TODO Auto-generated method stub
|
||||||
// TODO Auto-generated method stub
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean ySliderMoved(Controller controller, int sliderCode,
|
||||||
public boolean accelerometerMoved(Controller controller,
|
boolean value) {
|
||||||
int accelerometerCode, Vector3 value) {
|
// TODO Auto-generated method stub
|
||||||
// TODO Auto-generated method stub
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
@Override
|
||||||
; END CONTROLLER LISTENER METHODS ;
|
public boolean accelerometerMoved(Controller controller,
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
int accelerometerCode, Vector3 value) {
|
||||||
}
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; END CONTROLLER LISTENER METHODS ;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
|
}
|
||||||
|
@@ -1,250 +1,156 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Miguel Angel Astor Romero
|
* Copyright (C) 2014 Miguel Angel Astor Romero
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
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 ve.ucv.ciens.ccg.nxtar.NxtARCore.game_states_t;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.controllers.Controller;
|
import com.badlogic.gdx.graphics.GL10;
|
||||||
import com.badlogic.gdx.controllers.PovDirection;
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
import com.badlogic.gdx.graphics.GL10;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
import com.badlogic.gdx.math.Vector3;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
|
||||||
import com.badlogic.gdx.math.Vector3;
|
public class TabletMainMenuState extends MainMenuStateBase{
|
||||||
|
private static final String CLASS_NAME = TabletMainMenuState.class.getSimpleName();
|
||||||
public class TabletMainMenuState extends MainMenuStateBase{
|
|
||||||
protected static final String CLASS_NAME = TabletMainMenuState.class.getSimpleName();
|
private OrthographicCamera pixelPerfectCamera;
|
||||||
|
|
||||||
private OrthographicCamera pixelPerfectCamera;
|
// Button touch helper fields.
|
||||||
|
private Vector3 win2world;
|
||||||
// Button touch helper fields.
|
private Vector2 touchPointWorldCoords;
|
||||||
private Vector3 win2world;
|
private boolean startButtonTouched;
|
||||||
private Vector2 touchPointWorldCoords;
|
private int startButtonTouchPointer;
|
||||||
private boolean startButtonTouched;
|
|
||||||
private int startButtonTouchPointer;
|
public TabletMainMenuState(final NxtARCore core){
|
||||||
|
this.core = core;
|
||||||
public TabletMainMenuState(final NxtARCore core){
|
pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
this.core = core;
|
startButton.setPosition(-(startButton.getWidth() / 2), -(startButton.getHeight() / 2));
|
||||||
pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
startButtonBBox.setPosition(startButton.getX(), startButton.getY());
|
||||||
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();
|
||||||
win2world = new Vector3(0.0f, 0.0f, 0.0f);
|
|
||||||
touchPointWorldCoords = new Vector2();
|
startButtonTouched = false;
|
||||||
|
startButtonTouchPointer = -1;
|
||||||
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);
|
||||||
float ledYPos = (-(Gdx.graphics.getHeight() / 2) * 0.5f) + (startButton.getY() * 0.5f);
|
clientConnectedLedOn.setPosition(-(clientConnectedLedOn.getWidth() / 2), ledYPos);
|
||||||
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);
|
||||||
clientConnectedLedOff.setSize(clientConnectedLedOff.getWidth() * 0.5f, clientConnectedLedOff.getHeight() * 0.5f);
|
}
|
||||||
clientConnectedLedOff.setPosition(-(clientConnectedLedOff.getWidth() / 2), ledYPos);
|
|
||||||
}
|
@Override
|
||||||
|
public void render(float delta){
|
||||||
@Override
|
Gdx.gl.glClearColor(1, 1, 1, 1);
|
||||||
public void render(float delta){
|
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
|
||||||
Gdx.gl.glClearColor(1, 1, 1, 1);
|
|
||||||
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
|
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
|
||||||
|
core.batch.begin();{
|
||||||
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
|
if(clientConnected){
|
||||||
core.batch.begin();{
|
clientConnectedLedOn.draw(core.batch);
|
||||||
if(clientConnected){
|
}else{
|
||||||
clientConnectedLedOn.draw(core.batch);
|
clientConnectedLedOff.draw(core.batch);
|
||||||
}else{
|
}
|
||||||
clientConnectedLedOff.draw(core.batch);
|
startButton.draw(core.batch, 1.0f);
|
||||||
}
|
}core.batch.end();
|
||||||
startButton.draw(core.batch, 1.0f);
|
}
|
||||||
}core.batch.end();
|
|
||||||
}
|
@Override
|
||||||
|
public void resize(int width, int height){ }
|
||||||
@Override
|
|
||||||
public void resize(int width, int height){ }
|
@Override
|
||||||
|
public void show(){ }
|
||||||
@Override
|
|
||||||
public void show(){ }
|
@Override
|
||||||
|
public void hide(){ }
|
||||||
@Override
|
|
||||||
public void hide(){ }
|
@Override
|
||||||
|
public void pause(){ }
|
||||||
@Override
|
|
||||||
public void pause(){ }
|
@Override
|
||||||
|
public void resume(){ }
|
||||||
@Override
|
|
||||||
public void resume(){ }
|
@Override
|
||||||
|
public void dispose(){
|
||||||
@Override
|
super.dispose();
|
||||||
public void dispose(){
|
}
|
||||||
super.dispose();
|
|
||||||
}
|
/*;;;;;;;;;;;;;;;;;;
|
||||||
|
; HELPER METHODS ;
|
||||||
/*;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;*/
|
||||||
; HELPER METHODS ;
|
|
||||||
;;;;;;;;;;;;;;;;;;*/
|
private void unprojectTouch(int screenX, int screenY){
|
||||||
|
win2world.set(screenX, screenY, 0.0f);
|
||||||
@Override
|
pixelPerfectCamera.unproject(win2world);
|
||||||
public void onStateSet(){
|
touchPointWorldCoords.set(win2world.x, win2world.y);
|
||||||
super.onStateSet();
|
}
|
||||||
}
|
|
||||||
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
private void unprojectTouch(int screenX, int screenY){
|
; INPUT LISTENER METHODS ;
|
||||||
win2world.set(screenX, screenY, 0.0f);
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
pixelPerfectCamera.unproject(win2world);
|
|
||||||
touchPointWorldCoords.set(win2world.x, win2world.y);
|
@Override
|
||||||
}
|
public boolean touchDown(int screenX, int screenY, int pointer, int button){
|
||||||
|
unprojectTouch(screenX, screenY);
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
; INPUT PROCESSOR METHODS ;
|
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));
|
||||||
|
|
||||||
@Override
|
if(!startButton.isDisabled() && startButtonBBox.contains(touchPointWorldCoords)){
|
||||||
public boolean touchDown(int screenX, int screenY, int pointer, int button){
|
startButton.setChecked(true);
|
||||||
unprojectTouch(screenX, screenY);
|
startButtonTouched = true;
|
||||||
|
startButtonTouchPointer = pointer;
|
||||||
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown(%d, %d, %d, %d)", screenX, screenY, pointer, button));
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button pressed.");
|
||||||
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
|
}
|
||||||
|
|
||||||
if(!startButton.isDisabled() && startButtonBBox.contains(touchPointWorldCoords)){
|
return true;
|
||||||
startButton.setChecked(true);
|
}
|
||||||
startButtonTouched = true;
|
|
||||||
startButtonTouchPointer = pointer;
|
@Override
|
||||||
core.nextState = game_states_t.IN_GAME;
|
public boolean touchUp(int screenX, int screenY, int pointer, int button){
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button pressed.");
|
unprojectTouch(screenX, screenY);
|
||||||
}
|
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp(%d, %d, %d, %d)", screenX, screenY, pointer, button));
|
||||||
return true;
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
|
||||||
}
|
|
||||||
|
if(!startButton.isDisabled() && startButtonBBox.contains(touchPointWorldCoords)){
|
||||||
@Override
|
startButton.setChecked(false);
|
||||||
public boolean touchUp(int screenX, int screenY, int pointer, int button){
|
startButtonTouched = false;
|
||||||
unprojectTouch(screenX, screenY);
|
startButtonTouchPointer = -1;
|
||||||
|
core.nextState = game_states_t.IN_GAME;
|
||||||
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp(%d, %d, %d, %d)", screenX, screenY, pointer, button));
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button released.");
|
||||||
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
|
}
|
||||||
|
|
||||||
if(!startButton.isDisabled() && startButtonBBox.contains(touchPointWorldCoords)){
|
return true;
|
||||||
startButton.setChecked(false);
|
}
|
||||||
startButtonTouched = false;
|
|
||||||
startButtonTouchPointer = -1;
|
@Override
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button released.");
|
public boolean touchDragged(int screenX, int screenY, int pointer){
|
||||||
}
|
unprojectTouch(screenX, screenY);
|
||||||
|
|
||||||
return true;
|
if(!startButton.isDisabled() && startButtonTouched && pointer == startButtonTouchPointer && !startButtonBBox.contains(touchPointWorldCoords)){
|
||||||
}
|
startButtonTouchPointer = -1;
|
||||||
|
startButtonTouched = false;
|
||||||
@Override
|
startButton.setChecked(false);
|
||||||
public boolean touchDragged(int screenX, int screenY, int pointer){
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Start button released.");
|
||||||
unprojectTouch(screenX, screenY);
|
}
|
||||||
|
|
||||||
if(!startButton.isDisabled() && startButtonTouched && pointer == startButtonTouchPointer && !startButtonBBox.contains(touchPointWorldCoords)){
|
return true;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean keyUp(int keycode){
|
|
||||||
// Unused.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean keyTyped(char character){
|
|
||||||
// Unused.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mouseMoved(int screenX, int screenY){
|
|
||||||
// Unused.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean scrolled(int amount){
|
|
||||||
// Unused.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void connected(Controller controller){
|
|
||||||
// Unused.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disconnected(Controller controller){
|
|
||||||
// Unused.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean buttonDown(Controller controller, int buttonCode){
|
|
||||||
// Unused.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean buttonUp(Controller controller, int buttonCode){
|
|
||||||
// Unused.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean axisMoved(Controller controller, int axisCode, float value){
|
|
||||||
// Unused.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean povMoved(Controller controller, int povCode, PovDirection value){
|
|
||||||
// Unused.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean xSliderMoved(Controller controller, int sliderCode, boolean value){
|
|
||||||
// Unused.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean ySliderMoved(Controller controller, int sliderCode, boolean value){
|
|
||||||
// Unused.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean accelerometerMoved(Controller controller, int accelerometerCode, Vector3 value){
|
|
||||||
// Unused.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -31,7 +31,7 @@ public abstract class ProjectConstants {
|
|||||||
|
|
||||||
public static final float OVERSCAN;
|
public static final float OVERSCAN;
|
||||||
|
|
||||||
public static final String FONT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.,:;!<EFBFBD>?<3F>";
|
public static final String FONT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.,:;!?";
|
||||||
|
|
||||||
static{
|
static{
|
||||||
OVERSCAN = Ouya.runningOnOuya ? 0.9f : 1.0f;
|
OVERSCAN = Ouya.runningOnOuya ? 0.9f : 1.0f;
|
||||||
|
Reference in New Issue
Block a user