Added menu transition to calibration state.
This commit is contained in:
@@ -23,6 +23,7 @@ import ve.ucv.ciens.ccg.nxtar.network.SensorReportThread;
|
||||
import ve.ucv.ciens.ccg.nxtar.network.ServiceDiscoveryThread;
|
||||
import ve.ucv.ciens.ccg.nxtar.network.VideoStreamingThread;
|
||||
import ve.ucv.ciens.ccg.nxtar.states.BaseState;
|
||||
import ve.ucv.ciens.ccg.nxtar.states.CameraCalibrationState;
|
||||
import ve.ucv.ciens.ccg.nxtar.states.InGameState;
|
||||
import ve.ucv.ciens.ccg.nxtar.states.MainMenuStateBase;
|
||||
import ve.ucv.ciens.ccg.nxtar.states.OuyaMainMenuState;
|
||||
@@ -64,7 +65,7 @@ public class NxtARCore extends Game implements NetworkConnectionListener{
|
||||
* Valid game states.
|
||||
*/
|
||||
public enum game_states_t {
|
||||
MAIN_MENU(0), IN_GAME(1), PAUSED(2);
|
||||
MAIN_MENU(0), IN_GAME(1), PAUSED(2), CALIBRATION(3);
|
||||
|
||||
private int value;
|
||||
|
||||
@@ -75,6 +76,10 @@ public class NxtARCore extends Game implements NetworkConnectionListener{
|
||||
public int getValue(){
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public static int getNumStates(){
|
||||
return 4;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -138,13 +143,14 @@ public class NxtARCore extends Game implements NetworkConnectionListener{
|
||||
|
||||
public void create(){
|
||||
// Create the state objects.
|
||||
states = new BaseState[3];
|
||||
states = new BaseState[game_states_t.getNumStates()];
|
||||
if(Ouya.runningOnOuya)
|
||||
states[game_states_t.MAIN_MENU.getValue()] = new OuyaMainMenuState(this);
|
||||
else
|
||||
states[game_states_t.MAIN_MENU.getValue()] = new TabletMainMenuState(this);
|
||||
states[game_states_t.IN_GAME.getValue()] = new InGameState(this);
|
||||
states[game_states_t.PAUSED.getValue()] = new PauseState(this);
|
||||
states[game_states_t.CALIBRATION.getValue()] = new CameraCalibrationState(this);
|
||||
|
||||
for(BaseState state : states){
|
||||
Controllers.addListener(state);
|
||||
@@ -213,10 +219,12 @@ public class NxtARCore extends Game implements NetworkConnectionListener{
|
||||
Gdx.input.setInputProcessor(states[currState.getValue()]);
|
||||
Controllers.addListener(states[currState.getValue()]);
|
||||
|
||||
// Anything else.
|
||||
//Gdx.app.setLogLevel(Application.LOG_INFO);
|
||||
//Gdx.app.setLogLevel(Application.LOG_DEBUG);
|
||||
Gdx.app.setLogLevel(Application.LOG_NONE);
|
||||
// Set log level
|
||||
if(ProjectConstants.DEBUG){
|
||||
Gdx.app.setLogLevel(Application.LOG_DEBUG);
|
||||
}else{
|
||||
Gdx.app.setLogLevel(Application.LOG_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void render(){
|
||||
|
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package ve.ucv.ciens.ccg.nxtar.interfaces;
|
||||
|
||||
public interface CVProcessor {
|
||||
public interface CVProcessor{
|
||||
public class CVMarkerData{
|
||||
public byte[] outFrame;
|
||||
public int[] markerCodes;
|
||||
@@ -31,4 +31,5 @@ public interface CVProcessor {
|
||||
public CVCalibrationData findCalibrationPattern(byte[] frame);
|
||||
public void calibrateCamera(float[][] calibrationSamples, byte[] frame);
|
||||
public byte[] undistortFrame(byte[] frame);
|
||||
public boolean cameraIsCalibrated();
|
||||
}
|
||||
|
@@ -18,12 +18,14 @@ package ve.ucv.ciens.ccg.nxtar.states;
|
||||
import java.util.Arrays;
|
||||
|
||||
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
||||
import ve.ucv.ciens.ccg.nxtar.NxtARCore.game_states_t;
|
||||
import ve.ucv.ciens.ccg.nxtar.interfaces.CVProcessor.CVCalibrationData;
|
||||
import ve.ucv.ciens.ccg.nxtar.network.monitors.VideoFrameMonitor;
|
||||
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||
import ve.ucv.ciens.ccg.nxtar.utils.Size;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.controllers.Controller;
|
||||
import com.badlogic.gdx.controllers.mappings.Ouya;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
@@ -109,6 +111,10 @@ public class CameraCalibrationState extends BaseState{
|
||||
|
||||
@Override
|
||||
public void onStateSet(){
|
||||
Gdx.input.setInputProcessor(this);
|
||||
Gdx.input.setCatchBackKey(true);
|
||||
Gdx.input.setCatchMenuKey(true);
|
||||
|
||||
for(int i = 0; i < calibrationSamples.length; i++){
|
||||
for(int j = 0; j < calibrationSamples[i].length; j++){
|
||||
calibrationSamples[i][j] = 0.0f;
|
||||
@@ -218,7 +224,21 @@ public class CameraCalibrationState extends BaseState{
|
||||
public void resume(){ }
|
||||
|
||||
@Override
|
||||
public void dispose(){ }
|
||||
public void dispose(){
|
||||
if(videoFrameTexture != null)
|
||||
videoFrameTexture.dispose();
|
||||
backgroundTexture.dispose();
|
||||
if(backgroundShader != null) backgroundShader.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyDown(int keycode){
|
||||
if(keycode == Input.Keys.BACK){
|
||||
core.nextState = game_states_t.MAIN_MENU;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean touchDown(int screenX, int screenY, int pointer, int button){
|
||||
|
@@ -46,7 +46,6 @@ import com.badlogic.gdx.math.Vector3;
|
||||
public class InGameState extends BaseState{
|
||||
private static final String TAG = "IN_GAME_STATE";
|
||||
private static final String CLASS_NAME = InGameState.class.getSimpleName();
|
||||
|
||||
private static final String SHADER_PATH = "shaders/bckg/bckg";
|
||||
|
||||
private NxtARCore core;
|
||||
|
@@ -20,7 +20,6 @@ import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.controllers.mappings.Ouya;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
@@ -43,9 +42,10 @@ import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
|
||||
public abstract class MainMenuStateBase extends BaseState{
|
||||
protected static final String TAG = "MAIN_MENU";
|
||||
private static final String CLASS_NAME = MainMenuStateBase.class.getSimpleName();
|
||||
|
||||
private static final String SHADER_PATH = "shaders/bckg/bckg";
|
||||
|
||||
protected final int NUM_MENU_BUTTONS = 2;
|
||||
|
||||
// Helper fields.
|
||||
protected boolean clientConnected;
|
||||
private float u_scaling[];
|
||||
@@ -56,18 +56,26 @@ public abstract class MainMenuStateBase extends BaseState{
|
||||
protected Rectangle startButtonBBox;
|
||||
protected Sprite clientConnectedLedOn;
|
||||
protected Sprite clientConnectedLedOff;
|
||||
|
||||
protected TextButton calibrationButton;
|
||||
protected Rectangle calibrationButtonBBox;
|
||||
protected Sprite cameraCalibratedLedOn;
|
||||
protected Sprite cameraCalibratedLedOff;
|
||||
|
||||
protected Sprite background;
|
||||
|
||||
// Graphic data for the start button.
|
||||
private Texture startButtonEnabledTexture;
|
||||
private Texture startButtonDisabledTexture;
|
||||
private Texture startButtonPressedTexture;
|
||||
private NinePatch startButtonEnabled9p;
|
||||
private NinePatch startButtonDisabled9p;
|
||||
private NinePatch startButtonPressed9p;
|
||||
private NinePatch menuButtonEnabled9p;
|
||||
private NinePatch menuButtonDisabled9p;
|
||||
private NinePatch menuButtonPressed9p;
|
||||
private BitmapFont font;
|
||||
|
||||
// Other graphics.
|
||||
private Texture cameraCalibratedLedOffTexture;
|
||||
private Texture cameraCalibratedLedOnTexture;
|
||||
private Texture clientConnectedLedOffTexture;
|
||||
private Texture clientConnectedLedOnTexture;
|
||||
private Texture backgroundTexture;
|
||||
@@ -78,39 +86,49 @@ public abstract class MainMenuStateBase extends BaseState{
|
||||
protected Vector2 touchPointWorldCoords;
|
||||
protected boolean startButtonTouched;
|
||||
protected int startButtonTouchPointer;
|
||||
protected boolean calibrationButtonTouched;
|
||||
protected int calibrationButtonTouchPointer;
|
||||
|
||||
public MainMenuStateBase(){
|
||||
TextureRegion region;
|
||||
TextButtonStyle tbs;
|
||||
|
||||
this.pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
|
||||
// Create the start button background.
|
||||
startButtonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png"));
|
||||
startButtonEnabled9p = new NinePatch(new TextureRegion(startButtonEnabledTexture, 0, 0, startButtonEnabledTexture.getWidth(), startButtonEnabledTexture.getHeight()), 49, 49, 45, 45);
|
||||
menuButtonEnabled9p = new NinePatch(new TextureRegion(startButtonEnabledTexture, 0, 0, startButtonEnabledTexture.getWidth(), startButtonEnabledTexture.getHeight()), 49, 49, 45, 45);
|
||||
|
||||
startButtonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png"));
|
||||
startButtonDisabled9p = new NinePatch(new TextureRegion(startButtonDisabledTexture, 0, 0, startButtonDisabledTexture.getWidth(), startButtonDisabledTexture.getHeight()), 49, 49, 45, 45);
|
||||
menuButtonDisabled9p = new NinePatch(new TextureRegion(startButtonDisabledTexture, 0, 0, startButtonDisabledTexture.getWidth(), startButtonDisabledTexture.getHeight()), 49, 49, 45, 45);
|
||||
|
||||
startButtonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png"));
|
||||
startButtonPressed9p = new NinePatch(new TextureRegion(startButtonPressedTexture, 0, 0, startButtonPressedTexture.getWidth(), startButtonPressedTexture.getHeight()), 49, 49, 45, 45);
|
||||
menuButtonPressed9p = new NinePatch(new TextureRegion(startButtonPressedTexture, 0, 0, startButtonPressedTexture.getWidth(), startButtonPressedTexture.getHeight()), 49, 49, 45, 45);
|
||||
|
||||
// Create the start button font.
|
||||
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
|
||||
font = generator.generateFont(Ouya.runningOnOuya ? 60 : 40, ProjectConstants.FONT_CHARS, false);
|
||||
font = generator.generateFont(ProjectConstants.MENU_BUTTON_FONT_SIZE, ProjectConstants.FONT_CHARS, false);
|
||||
generator.dispose();
|
||||
|
||||
// Create the start button itself.
|
||||
TextButtonStyle tbs = new TextButtonStyle();
|
||||
// Create the start button.
|
||||
tbs = new TextButtonStyle();
|
||||
tbs.font = font;
|
||||
tbs.up = new NinePatchDrawable(startButtonEnabled9p);
|
||||
tbs.checked = new NinePatchDrawable(startButtonPressed9p);
|
||||
tbs.disabled = new NinePatchDrawable(startButtonDisabled9p);
|
||||
tbs.up = new NinePatchDrawable(menuButtonEnabled9p);
|
||||
tbs.checked = new NinePatchDrawable(menuButtonPressed9p);
|
||||
tbs.disabled = new NinePatchDrawable(menuButtonDisabled9p);
|
||||
tbs.disabledFontColor = new Color(0, 0, 0, 1);
|
||||
|
||||
startButton = new TextButton("Start server", tbs);
|
||||
startButton.setText("Start game");
|
||||
startButton.setDisabled(true);
|
||||
startButtonBBox = new Rectangle(0, 0, startButton.getWidth(), startButton.getHeight());
|
||||
|
||||
// Create the calibration button.
|
||||
calibrationButton = new TextButton("Calibrate camera", tbs);
|
||||
calibrationButton.setText("Calibrate camera");
|
||||
calibrationButton.setDisabled(true);
|
||||
calibrationButtonBBox = new Rectangle(0, 0, calibrationButton.getWidth(), calibrationButton.getHeight());
|
||||
|
||||
// Create the connection leds.
|
||||
clientConnectedLedOnTexture = new Texture("data/gfx/gui/Anonymous_Button_Green.png");
|
||||
region = new TextureRegion(clientConnectedLedOnTexture);
|
||||
@@ -120,6 +138,14 @@ public abstract class MainMenuStateBase extends BaseState{
|
||||
region = new TextureRegion(clientConnectedLedOffTexture);
|
||||
clientConnectedLedOff = new Sprite(region);
|
||||
|
||||
cameraCalibratedLedOnTexture = new Texture("data/gfx/gui/Anonymous_Button_Green.png");
|
||||
region = new TextureRegion(cameraCalibratedLedOnTexture);
|
||||
cameraCalibratedLedOn = new Sprite(region);
|
||||
|
||||
cameraCalibratedLedOffTexture = new Texture("data/gfx/gui/Anonymous_Button_Red.png");
|
||||
region = new TextureRegion(cameraCalibratedLedOffTexture);
|
||||
cameraCalibratedLedOff = new Sprite(region);
|
||||
|
||||
// Set up the background.
|
||||
backgroundTexture = new Texture(Gdx.files.internal("data/gfx/textures/tile_aqua.png"));
|
||||
backgroundTexture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
|
||||
@@ -145,6 +171,8 @@ public abstract class MainMenuStateBase extends BaseState{
|
||||
touchPointWorldCoords = new Vector2();
|
||||
startButtonTouched = false;
|
||||
startButtonTouchPointer = -1;
|
||||
calibrationButtonTouched = false;
|
||||
calibrationButtonTouchPointer = -1;
|
||||
|
||||
clientConnected = false;
|
||||
stateActive = false;
|
||||
@@ -174,6 +202,8 @@ public abstract class MainMenuStateBase extends BaseState{
|
||||
startButtonPressedTexture.dispose();
|
||||
clientConnectedLedOnTexture.dispose();
|
||||
clientConnectedLedOffTexture.dispose();
|
||||
cameraCalibratedLedOnTexture.dispose();
|
||||
cameraCalibratedLedOffTexture.dispose();
|
||||
backgroundTexture.dispose();
|
||||
if(backgroundShader != null) backgroundShader.dispose();
|
||||
font.dispose();
|
||||
@@ -207,6 +237,7 @@ public abstract class MainMenuStateBase extends BaseState{
|
||||
public void onClientConnected(){
|
||||
clientConnected = true;
|
||||
startButton.setDisabled(false);
|
||||
calibrationButton.setDisabled(false);
|
||||
}
|
||||
|
||||
/*;;;;;;;;;;;;;;;;;;
|
||||
@@ -230,11 +261,16 @@ public abstract class MainMenuStateBase extends BaseState{
|
||||
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown(%d, %d, %d, %d)", screenX, screenY, pointer, button));
|
||||
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
|
||||
|
||||
if(!startButton.isDisabled() && startButtonBBox.contains(touchPointWorldCoords)){
|
||||
if(!startButton.isDisabled() && startButtonBBox.contains(touchPointWorldCoords) && !calibrationButtonTouched){
|
||||
startButton.setChecked(true);
|
||||
startButtonTouched = true;
|
||||
startButtonTouchPointer = pointer;
|
||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button pressed.");
|
||||
}else if(!calibrationButton.isDisabled() && calibrationButtonBBox.contains(touchPointWorldCoords) && !startButtonTouched){
|
||||
calibrationButton.setChecked(true);
|
||||
calibrationButtonTouched = true;
|
||||
calibrationButtonTouchPointer = pointer;
|
||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Calibration button pressed.");
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -247,12 +283,18 @@ public abstract class MainMenuStateBase extends BaseState{
|
||||
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp(%d, %d, %d, %d)", screenX, screenY, pointer, button));
|
||||
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
|
||||
|
||||
if(!startButton.isDisabled() && startButtonBBox.contains(touchPointWorldCoords)){
|
||||
if(!startButton.isDisabled() && startButtonBBox.contains(touchPointWorldCoords) && startButtonTouched){
|
||||
startButton.setChecked(false);
|
||||
startButtonTouched = false;
|
||||
startButtonTouchPointer = -1;
|
||||
core.nextState = game_states_t.IN_GAME;
|
||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button released.");
|
||||
}else if(!calibrationButton.isDisabled() && calibrationButtonBBox.contains(touchPointWorldCoords) && calibrationButtonTouched){
|
||||
calibrationButton.setChecked(false);
|
||||
calibrationButtonTouched = false;
|
||||
calibrationButtonTouchPointer = -1;
|
||||
core.nextState = game_states_t.CALIBRATION;
|
||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Calibration button released.");
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -267,6 +309,11 @@ public abstract class MainMenuStateBase extends BaseState{
|
||||
startButtonTouched = false;
|
||||
startButton.setChecked(false);
|
||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Start button released.");
|
||||
}else if(!calibrationButton.isDisabled() && calibrationButtonTouched && pointer == calibrationButtonTouchPointer && !calibrationButtonBBox.contains(touchPointWorldCoords)){
|
||||
calibrationButtonTouchPointer = -1;
|
||||
calibrationButtonTouched = false;
|
||||
calibrationButton.setChecked(false);
|
||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Start button released.");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@@ -32,14 +32,20 @@ public class OuyaMainMenuState extends MainMenuStateBase{
|
||||
private Texture ouyaOButtonTexture;
|
||||
private Sprite ouyaOButton;
|
||||
private boolean oButtonPressed;
|
||||
private int oButtonSelection;
|
||||
|
||||
public OuyaMainMenuState(final NxtARCore core){
|
||||
super();
|
||||
|
||||
this.core = core;
|
||||
|
||||
startButton.setPosition(-(startButton.getWidth() / 2), -(startButton.getHeight() / 2));
|
||||
startButtonBBox.setPosition(startButton.getX(), startButton.getY());
|
||||
|
||||
float ledYPos = (-(Gdx.graphics.getHeight() / 2) * 0.5f) + (startButton.getY() * 0.5f);
|
||||
calibrationButton.setPosition(-(calibrationButton.getWidth() / 2), (startButton.getY() + startButton.getHeight()) + 10);
|
||||
calibrationButtonBBox.setPosition(calibrationButton.getX(), calibrationButton.getY());
|
||||
|
||||
float ledYPos = (-(Gdx.graphics.getHeight() / 2) * 0.5f) + (calibrationButton.getY() * 0.5f);
|
||||
clientConnectedLedOn.setSize(clientConnectedLedOn.getWidth() * 0.5f, clientConnectedLedOn.getHeight() * 0.5f);
|
||||
clientConnectedLedOn.setPosition(-(clientConnectedLedOn.getWidth() / 2), ledYPos);
|
||||
|
||||
@@ -50,8 +56,8 @@ public class OuyaMainMenuState extends MainMenuStateBase{
|
||||
TextureRegion region = new TextureRegion(ouyaOButtonTexture, ouyaOButtonTexture.getWidth(), ouyaOButtonTexture.getHeight());
|
||||
ouyaOButton = new Sprite(region);
|
||||
ouyaOButton.setSize(ouyaOButton.getWidth() * 0.6f, ouyaOButton.getHeight() * 0.6f);
|
||||
ouyaOButton.setPosition(startButton.getX() - ouyaOButton.getWidth() - 20, startButton.getY() + (ouyaOButton.getHeight() / 2));
|
||||
|
||||
oButtonSelection = 0;
|
||||
oButtonPressed = false;
|
||||
}
|
||||
|
||||
@@ -65,13 +71,23 @@ public class OuyaMainMenuState extends MainMenuStateBase{
|
||||
core.batch.disableBlending();
|
||||
drawBackground(core.batch);
|
||||
core.batch.enableBlending();
|
||||
|
||||
if(clientConnected){
|
||||
clientConnectedLedOn.draw(core.batch);
|
||||
}else{
|
||||
clientConnectedLedOff.draw(core.batch);
|
||||
}
|
||||
|
||||
startButton.draw(core.batch, 1.0f);
|
||||
calibrationButton.draw(core.batch, 1.0f);
|
||||
|
||||
if(oButtonSelection == 0){
|
||||
ouyaOButton.setPosition(startButton.getX() - ouyaOButton.getWidth() - 20, startButton.getY() + (ouyaOButton.getHeight() / 2));
|
||||
}else if(oButtonSelection == 1){
|
||||
ouyaOButton.setPosition(calibrationButton.getX() - ouyaOButton.getWidth() - 20, calibrationButton.getY() + (ouyaOButton.getHeight() / 2));
|
||||
}
|
||||
ouyaOButton.draw(core.batch);
|
||||
|
||||
}core.batch.end();
|
||||
}
|
||||
|
||||
@@ -89,16 +105,32 @@ public class OuyaMainMenuState extends MainMenuStateBase{
|
||||
public boolean buttonDown(Controller controller, int buttonCode) {
|
||||
if(stateActive){
|
||||
if(buttonCode == Ouya.BUTTON_O){
|
||||
if(!clientConnected){
|
||||
core.toast("Can't start the game. No client is connected.", true);
|
||||
}else{
|
||||
oButtonPressed = true;
|
||||
startButton.setChecked(true);
|
||||
Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): O button pressed.");
|
||||
|
||||
if(oButtonSelection == 0){
|
||||
if(!clientConnected){
|
||||
core.toast("Can't start the game. No client is connected.", true);
|
||||
}else{
|
||||
oButtonPressed = true;
|
||||
startButton.setChecked(true);
|
||||
}
|
||||
}else if(oButtonSelection == 1){
|
||||
if(!clientConnected){
|
||||
core.toast("Can't calibrate the camera. No client is connected.", true);
|
||||
}else{
|
||||
oButtonPressed = true;
|
||||
calibrationButton.setChecked(true);
|
||||
}
|
||||
}
|
||||
}else if(buttonCode == Ouya.BUTTON_DPAD_UP){
|
||||
Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): Dpad up button pressed.");
|
||||
oButtonSelection = oButtonSelection - 1 < 0 ? NUM_MENU_BUTTONS - 1 : oButtonSelection - 1;
|
||||
}else if(buttonCode == Ouya.BUTTON_DPAD_DOWN){
|
||||
Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): Dpad down button pressed.");
|
||||
oButtonSelection = (oButtonSelection + 1) % NUM_MENU_BUTTONS;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
@@ -108,16 +140,22 @@ public class OuyaMainMenuState extends MainMenuStateBase{
|
||||
public boolean buttonUp(Controller controller, int buttonCode) {
|
||||
if(stateActive){
|
||||
if(buttonCode == Ouya.BUTTON_O){
|
||||
Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): O button released.");
|
||||
|
||||
if(oButtonPressed){
|
||||
oButtonPressed = false;
|
||||
startButton.setChecked(false);
|
||||
core.nextState = game_states_t.IN_GAME;
|
||||
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button released.");
|
||||
|
||||
if(oButtonSelection == 0){
|
||||
startButton.setChecked(false);
|
||||
core.nextState = game_states_t.IN_GAME;
|
||||
}else if(oButtonSelection == 1){
|
||||
calibrationButton.setChecked(false);
|
||||
core.nextState = game_states_t.IN_GAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
@@ -21,12 +21,19 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.GL10;
|
||||
|
||||
public class TabletMainMenuState extends MainMenuStateBase{
|
||||
|
||||
public TabletMainMenuState(final NxtARCore core){
|
||||
super();
|
||||
|
||||
this.core = core;
|
||||
|
||||
startButton.setPosition(-(startButton.getWidth() / 2), -(startButton.getHeight() / 2));
|
||||
startButtonBBox.setPosition(startButton.getX(), startButton.getY());
|
||||
|
||||
float ledYPos = (-(Gdx.graphics.getHeight() / 2) * 0.5f) + (startButton.getY() * 0.5f);
|
||||
calibrationButton.setPosition(-(calibrationButton.getWidth() / 2), (startButton.getY() + startButton.getHeight()) + 10);
|
||||
calibrationButtonBBox.setPosition(calibrationButton.getX(), calibrationButton.getY());
|
||||
|
||||
float ledYPos = (-(Gdx.graphics.getHeight() / 2) * 0.5f) + (calibrationButton.getY() * 0.5f);
|
||||
clientConnectedLedOn.setSize(clientConnectedLedOn.getWidth() * 0.5f, clientConnectedLedOn.getHeight() * 0.5f);
|
||||
clientConnectedLedOn.setPosition(-(clientConnectedLedOn.getWidth() / 2), ledYPos);
|
||||
|
||||
@@ -41,6 +48,7 @@ public class TabletMainMenuState extends MainMenuStateBase{
|
||||
|
||||
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
|
||||
core.batch.begin();{
|
||||
|
||||
core.batch.disableBlending();
|
||||
drawBackground(core.batch);
|
||||
core.batch.enableBlending();
|
||||
@@ -50,7 +58,10 @@ public class TabletMainMenuState extends MainMenuStateBase{
|
||||
}else{
|
||||
clientConnectedLedOff.draw(core.batch);
|
||||
}
|
||||
|
||||
startButton.draw(core.batch, 1.0f);
|
||||
calibrationButton.draw(core.batch, 1.0f);
|
||||
|
||||
}core.batch.end();
|
||||
}
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ public abstract class ProjectConstants{
|
||||
public static final int[] POWERS_OF_2 = {64, 128, 256, 512, 1024, 2048};
|
||||
|
||||
public static final float OVERSCAN;
|
||||
public static final int MENU_BUTTON_FONT_SIZE;
|
||||
|
||||
public static final String FONT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
|
||||
@@ -42,5 +43,6 @@ public abstract class ProjectConstants{
|
||||
|
||||
static{
|
||||
OVERSCAN = Ouya.runningOnOuya ? 0.9f : 1.0f;
|
||||
MENU_BUTTON_FONT_SIZE = Ouya.runningOnOuya ? 60 : 40;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user