Fixed interface details. Removed pause state.

This commit is contained in:
2014-06-06 12:43:45 -04:30
parent 4cba697f57
commit d4edcf4909
7 changed files with 325 additions and 572 deletions

View File

@@ -15,9 +15,9 @@
*/
package ve.ucv.ciens.ccg.nxtar;
import ve.ucv.ciens.ccg.nxtar.interfaces.ImageProcessor;
import ve.ucv.ciens.ccg.nxtar.interfaces.ApplicationEventsListener;
import ve.ucv.ciens.ccg.nxtar.interfaces.ActionResolver;
import ve.ucv.ciens.ccg.nxtar.interfaces.ApplicationEventsListener;
import ve.ucv.ciens.ccg.nxtar.interfaces.ImageProcessor;
import ve.ucv.ciens.ccg.nxtar.network.RobotControlThread;
import ve.ucv.ciens.ccg.nxtar.network.SensorReportThread;
import ve.ucv.ciens.ccg.nxtar.network.ServiceDiscoveryThread;
@@ -27,7 +27,6 @@ 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;
import ve.ucv.ciens.ccg.nxtar.states.PauseState;
import ve.ucv.ciens.ccg.nxtar.states.TabletMainMenuState;
import ve.ucv.ciens.ccg.nxtar.utils.GameSettings;
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
@@ -74,7 +73,7 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
* Valid game states.
*/
public enum game_states_t {
MAIN_MENU(0), IN_GAME(1), PAUSED(2), CALIBRATION(3);
MAIN_MENU(0), IN_GAME(1), CALIBRATION(2);
private int value;
@@ -239,7 +238,6 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
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);
// Register controller listeners.

View File

@@ -186,6 +186,23 @@ public class BombGameEntityCreator extends EntityCreatorBase{
entitiesCreated = true;
}
@Override
public boolean updateAssetManager() throws NullPointerException{
boolean doneLoading;
if(core == null)
throw new NullPointerException("Core has not been set.");
doneLoading = manager.update();
if(doneLoading){
getModels();
createAllEntities();
core.onAssetsLoaded();
}
return doneLoading;
}
@Override
public void dispose() {
if(shader != null) shader.dispose();
@@ -383,21 +400,4 @@ public class BombGameEntityCreator extends EntityCreatorBase{
wiresBombCollisionModelWire3 = manager.get("models/collision_models/bomb_game/cable_3_col.g3db", Model.class);
// easterEggCollisionModel = manager.get("models/collision_models/bomb_game/door.g3db", Model.class);
}
@Override
public boolean updateAssetManager(){
boolean doneLoading;
if(core == null)
throw new NullPointerException("Core has not been set.");
doneLoading = manager.update();
if(doneLoading){
getModels();
createAllEntities();
core.onAssetsLoaded();
}
return doneLoading;
}
}

View File

@@ -26,28 +26,16 @@ 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.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
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 class CameraCalibrationState extends BaseState{
private static final String TAG = "CAMERA_CALIBRATION_STATE";
@@ -55,6 +43,7 @@ public class CameraCalibrationState extends BaseState{
private static final String SHADER_PATH = "shaders/bckg/bckg";
private NxtARCore core;
private boolean cameraCalibrated;
private float u_scaling[];
protected Sprite background;
@@ -69,36 +58,16 @@ public class CameraCalibrationState extends BaseState{
private Sprite renderableVideoFrame;
private Pixmap videoFrame;
// Gui components.
private TextButton takeSampleButton;
private Rectangle takeSampleButtonBBox;
private Texture buttonEnabledTexture;
private Texture buttonDisabledTexture;
private Texture buttonPressedTexture;
private NinePatch buttonEnabled9p;
private NinePatch buttonDisabled9p;
private NinePatch buttonPressed9p;
private BitmapFont font;
// Button touch helper fields.
private boolean takeSampleButtonTouched;
private int takeSampleButtonPointer;
// Monitors.
private VideoFrameMonitor frameMonitor;
private float[][] calibrationSamples;
@SuppressWarnings("unused")
private boolean takeSample;
private int lastSampleTaken;
public CameraCalibrationState(final NxtARCore core){
TextButtonStyle tbs;
FreeTypeFontGenerator generator;
FreeTypeFontParameter param;
this.core = core;
frameMonitor = VideoFrameMonitor.getInstance();
cameraCalibrated = false;
// Set up the cameras.
pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
@@ -125,46 +94,6 @@ public class CameraCalibrationState extends BaseState{
u_scaling[0] = Gdx.graphics.getWidth() > Gdx.graphics.getHeight() ? 16.0f : 9.0f;
u_scaling[1] = Gdx.graphics.getHeight() > Gdx.graphics.getWidth() ? 16.0f : 9.0f;
// Set up the sampling button.
// Create the font.
param = new FreeTypeFontParameter();
param.characters = ProjectConstants.FONT_CHARS;
param.size = ProjectConstants.MENU_BUTTON_FONT_SIZE;
param.flip = false;
generator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
font = generator.generateFont(param);
generator.dispose();
// Load the textures.
buttonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png"));
buttonEnabled9p = new NinePatch(new TextureRegion(buttonEnabledTexture, 0, 0, buttonEnabledTexture.getWidth(), buttonEnabledTexture.getHeight()), 49, 49, 45, 45);
buttonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png"));
buttonDisabled9p = new NinePatch(new TextureRegion(buttonDisabledTexture, 0, 0, buttonDisabledTexture.getWidth(), buttonDisabledTexture.getHeight()), 49, 49, 45, 45);
buttonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png"));
buttonPressed9p = new NinePatch(new TextureRegion(buttonPressedTexture, 0, 0, buttonPressedTexture.getWidth(), buttonPressedTexture.getHeight()), 49, 49, 45, 45);
// Create the button style.
tbs = new TextButtonStyle();
tbs.font = font;
tbs.up = new NinePatchDrawable(buttonEnabled9p);
tbs.checked = new NinePatchDrawable(buttonPressed9p);
tbs.disabled = new NinePatchDrawable(buttonDisabled9p);
tbs.disabledFontColor = new Color(0, 0, 0, 1);
// Create the button itself.
takeSampleButton = new TextButton("Take calibration sample", tbs);
takeSampleButton.setText("Take calibration sample");
takeSampleButton.setDisabled(true);
takeSampleButtonBBox = new Rectangle(0, 0, takeSampleButton.getWidth(), takeSampleButton.getHeight());
takeSampleButton.setPosition(-(takeSampleButton.getWidth() / 2), -(Gdx.graphics.getHeight()/2) - 1 + (takeSampleButton.getHeight() / 2));
takeSampleButtonBBox.setPosition(takeSampleButton.getX(), takeSampleButton.getY());
// Set up the touch collision detection variables.
win2world = new Vector3(0.0f, 0.0f, 0.0f);
touchPointWorldCoords = new Vector2();
takeSampleButtonTouched = false;
takeSampleButtonPointer = -1;
// Initialize the calibration samples vector.
calibrationSamples = new float[ProjectConstants.CALIBRATION_SAMPLES][];
for(int i = 0; i < calibrationSamples.length; i++){
@@ -178,8 +107,8 @@ public class CameraCalibrationState extends BaseState{
Gdx.input.setCatchBackKey(true);
Gdx.input.setCatchMenuKey(true);
takeSample = false;
lastSampleTaken = 0;
cameraCalibrated = false;
for(int i = 0; i < calibrationSamples.length; i++){
for(int j = 0; j < calibrationSamples[i].length; j++){
@@ -193,7 +122,6 @@ public class CameraCalibrationState extends BaseState{
@Override
public void render(float delta){
String msg;
byte[] frame;
byte[] prevFrame = null;
Size dimensions = null;
@@ -219,17 +147,8 @@ public class CameraCalibrationState extends BaseState{
// Find the calibration points in the video frame.
CalibrationData data = core.cvProc.findCalibrationPattern(frame);
// Disable the sampling button if the calibration pattern was not found.
if(data.calibrationPoints != null && !core.cvProc.isCameraCalibrated()){
takeSampleButton.setDisabled(false);
}else{
takeSampleButton.setDisabled(true);
}
// If the user requested a sample be taken.
if(/*takeSample && */!core.cvProc.isCameraCalibrated() && data.calibrationPoints != null){
// Disable sample taking.
takeSample = false;
if(!cameraCalibrated && data.calibrationPoints != null){
Gdx.app.log(TAG, CLASS_NAME + ".render(): Sample taken.");
// Save the calibration points to the samples array.
@@ -242,15 +161,12 @@ public class CameraCalibrationState extends BaseState{
// Move to the next sample.
lastSampleTaken++;
msg = Integer.toString(lastSampleTaken) + " samples taken. ";
msg += Integer.toString(ProjectConstants.CALIBRATION_SAMPLES - lastSampleTaken) + " samples left.";
core.toast(msg, false);
// If enough samples has been taken then calibrate the camera.
if(lastSampleTaken == ProjectConstants.CALIBRATION_SAMPLES){
Gdx.app.log(TAG, CLASS_NAME + "render(): Last sample taken.");
core.cvProc.calibrateCamera(calibrationSamples, frame);
cameraCalibrated = core.cvProc.isCameraCalibrated();
core.onCameraCalibrated();
core.nextState = game_states_t.MAIN_MENU;
}
@@ -281,11 +197,8 @@ public class CameraCalibrationState extends BaseState{
}
// Render the frame.
if(!Ouya.runningOnOuya){
core.batch.setProjectionMatrix(camera.combined);
}else{
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
}
if(!Ouya.runningOnOuya) core.batch.setProjectionMatrix(camera.combined);
else core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
core.batch.begin();{
renderableVideoFrame.draw(core.batch);
}core.batch.end();
@@ -294,35 +207,10 @@ public class CameraCalibrationState extends BaseState{
videoFrameTexture.dispose();
}
// Render the user interface.
/*if(!Ouya.runningOnOuya){
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
core.batch.begin();{
takeSampleButton.draw(core.batch, 1.0f);
}core.batch.end();
}else{
// TODO: Render OUYA gui.
}*/
// Save this frame as previous to avoid processing the same frame twice when network latency is high.
prevFrame = frame;
}
@Override
public void resize(int width, int height){ }
@Override
public void show(){ }
@Override
public void hide(){ }
@Override
public void pause(){ }
@Override
public void resume(){ }
@Override
public void dispose(){
if(videoFrameTexture != null)
@@ -343,74 +231,4 @@ public class CameraCalibrationState extends BaseState{
}
return false;
}
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button){
unprojectTouch(screenX, screenY);
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown(%d, %d, %d, %d)", screenX, screenY, pointer, button));
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
if(!takeSampleButton.isDisabled() && takeSampleButtonBBox.contains(touchPointWorldCoords) && !takeSampleButtonTouched){
takeSampleButton.setChecked(true);
takeSampleButtonTouched = true;
takeSampleButtonPointer = pointer;
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Sample button pressed.");
}
return true;
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button){
unprojectTouch(screenX, screenY);
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp(%d, %d, %d, %d)", screenX, screenY, pointer, button));
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
if(!takeSampleButton.isDisabled() && takeSampleButtonBBox.contains(touchPointWorldCoords) && takeSampleButtonTouched){
takeSampleButton.setChecked(false);
takeSampleButtonTouched = false;
takeSampleButtonPointer = -1;
takeSample = true;
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Sample button released.");
}
return true;
}
@Override
public boolean touchDragged(int screenX, int screenY, int pointer){
unprojectTouch(screenX, screenY);
if(!takeSampleButton.isDisabled() && takeSampleButtonTouched && pointer == takeSampleButtonPointer && !takeSampleButtonBBox.contains(touchPointWorldCoords)){
takeSampleButtonPointer = -1;
takeSampleButtonTouched = false;
takeSampleButton.setChecked(false);
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Sample button released.");
}
return true;
}
@Override
public boolean buttonDown(Controller controller, int buttonCode){
// TODO: Handle OUYA controls.
return false;
}
@Override
public boolean buttonUp(Controller controller, int buttonCode){
// TODO: Handle OUYA controls.
return false;
}
@Override
public boolean axisMoved(Controller controller, int axisCode, float value){
// TODO: Handle OUYA controls.
return false;
}
}

View File

@@ -56,13 +56,12 @@ public abstract class MainMenuStateBase extends BaseState{
// Buttons and other gui components.
protected TextButton startButton;
protected Rectangle startButtonBBox;
protected Sprite clientConnectedLedOn;
protected Sprite clientConnectedLedOff;
protected TextButton calibrationButton;
protected Rectangle calibrationButtonBBox;
protected Sprite cameraCalibratedLedOn;
protected Sprite cameraCalibratedLedOff;
protected Sprite assetsLoadedLedOn;
protected Sprite assetsLoadedLedOff;
protected Sprite background;
@@ -76,10 +75,8 @@ public abstract class MainMenuStateBase extends BaseState{
private BitmapFont font;
// Other graphics.
private Texture cameraCalibratedLedOffTexture;
private Texture cameraCalibratedLedOnTexture;
private Texture clientConnectedLedOffTexture;
private Texture clientConnectedLedOnTexture;
private Texture ledOffTexture;
private Texture ledOnTexture;
private Texture backgroundTexture;
private ShaderProgram backgroundShader;
@@ -91,9 +88,9 @@ public abstract class MainMenuStateBase extends BaseState{
public MainMenuStateBase(){
TextureRegion region;
TextButtonStyle tbs;
FreeTypeFontGenerator generator;
FreeTypeFontParameter param;
TextButtonStyle textButtonStyle;
FreeTypeFontGenerator fontGenerator;
FreeTypeFontParameter fontParameters;
this.pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
@@ -108,50 +105,49 @@ public abstract class MainMenuStateBase extends BaseState{
menuButtonPressed9p = new NinePatch(new TextureRegion(menuButtonPressedTexture, 0, 0, menuButtonPressedTexture.getWidth(), menuButtonPressedTexture.getHeight()), 49, 49, 45, 45);
// Create the start button font.
param = new FreeTypeFontParameter();
param.characters = ProjectConstants.FONT_CHARS;
param.size = ProjectConstants.MENU_BUTTON_FONT_SIZE;
param.flip = false;
generator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
font = generator.generateFont(param);
generator.dispose();
fontParameters = new FreeTypeFontParameter();
fontParameters.characters = ProjectConstants.FONT_CHARS;
fontParameters.size = ProjectConstants.MENU_BUTTON_FONT_SIZE;
fontParameters.flip = false;
fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
font = fontGenerator.generateFont(fontParameters);
fontGenerator.dispose();
// Create the start button.
tbs = new TextButtonStyle();
tbs.font = font;
tbs.up = new NinePatchDrawable(menuButtonEnabled9p);
tbs.checked = new NinePatchDrawable(menuButtonPressed9p);
tbs.disabled = new NinePatchDrawable(menuButtonDisabled9p);
tbs.disabledFontColor = new Color(0, 0, 0, 1);
textButtonStyle = new TextButtonStyle();
textButtonStyle.font = font;
textButtonStyle.up = new NinePatchDrawable(menuButtonEnabled9p);
textButtonStyle.checked = new NinePatchDrawable(menuButtonPressed9p);
textButtonStyle.disabled = new NinePatchDrawable(menuButtonDisabled9p);
textButtonStyle.disabledFontColor = new Color(0, 0, 0, 1);
startButton = new TextButton("Start server", tbs);
startButton = new TextButton("Start server", textButtonStyle);
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 = new TextButton("Calibrate camera", textButtonStyle);
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);
clientConnectedLedOn = new Sprite(region);
ledOnTexture = new Texture("data/gfx/gui/Anonymous_Button_Green.png");
ledOffTexture = new Texture("data/gfx/gui/Anonymous_Button_Red.png");
clientConnectedLedOffTexture = new Texture("data/gfx/gui/Anonymous_Button_Red.png");
region = new TextureRegion(clientConnectedLedOffTexture);
clientConnectedLedOff = new Sprite(region);
cameraCalibratedLedOnTexture = new Texture("data/gfx/gui/Anonymous_Button_Green.png");
region = new TextureRegion(cameraCalibratedLedOnTexture);
region = new TextureRegion(ledOnTexture);
cameraCalibratedLedOn = new Sprite(region);
cameraCalibratedLedOffTexture = new Texture("data/gfx/gui/Anonymous_Button_Red.png");
region = new TextureRegion(cameraCalibratedLedOffTexture);
region = new TextureRegion(ledOffTexture);
cameraCalibratedLedOff = new Sprite(region);
region = new TextureRegion(ledOnTexture);
assetsLoadedLedOn = new Sprite(region);
region = new TextureRegion(ledOffTexture);
assetsLoadedLedOff = 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);
@@ -188,29 +184,13 @@ public abstract class MainMenuStateBase extends BaseState{
@Override
public abstract void render(float delta);
@Override
public void resize(int width, int height){ }
@Override
public void show(){ }
@Override
public void hide(){ }
@Override
public void pause(){ }
@Override
public void resume(){ }
@Override
public void dispose(){
menuButtonEnabledTexture.dispose();
menuButtonDisabledTexture.dispose();
menuButtonPressedTexture.dispose();
clientConnectedLedOnTexture.dispose();
clientConnectedLedOffTexture.dispose();
cameraCalibratedLedOnTexture.dispose();
cameraCalibratedLedOffTexture.dispose();
ledOnTexture.dispose();
ledOffTexture.dispose();
backgroundTexture.dispose();
if(backgroundShader != null) backgroundShader.dispose();
font.dispose();
@@ -248,7 +228,6 @@ public abstract class MainMenuStateBase extends BaseState{
public void onCameraCalibrated(){
cameraCalibrated = true;
calibrationButton.setDisabled(true);
startGame();
}

View File

@@ -33,32 +33,35 @@ public class OuyaMainMenuState extends MainMenuStateBase{
private Sprite ouyaOButton;
private boolean oButtonPressed;
private int oButtonSelection;
private float ledYPos;
public OuyaMainMenuState(final NxtARCore core){
super();
this.core = core;
// Set buttons.
startButton.setPosition(-(startButton.getWidth() / 2), -(startButton.getHeight() / 2));
startButtonBBox.setPosition(startButton.getX(), startButton.getY());
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);
clientConnectedLedOff.setSize(clientConnectedLedOff.getWidth() * 0.5f, clientConnectedLedOff.getHeight() * 0.5f);
clientConnectedLedOff.setPosition(-(clientConnectedLedOff.getWidth() / 2), ledYPos);
// TODO: Set calibration led attributes.
//Set leds.
ledYPos = (-(Gdx.graphics.getHeight() / 2) * 0.5f) + (calibrationButton.getY() * 0.5f);
cameraCalibratedLedOn.setSize(cameraCalibratedLedOn.getWidth() * 0.5f, cameraCalibratedLedOn.getHeight() * 0.5f);
cameraCalibratedLedOn.setPosition(-cameraCalibratedLedOn.getWidth() - 5, ledYPos);
cameraCalibratedLedOff.setSize(cameraCalibratedLedOff.getWidth() * 0.5f, cameraCalibratedLedOff.getHeight() * 0.5f);
cameraCalibratedLedOff.setPosition(-cameraCalibratedLedOff.getWidth() - 5, ledYPos);
assetsLoadedLedOn.setSize(assetsLoadedLedOn.getWidth() * 0.5f, assetsLoadedLedOn.getHeight() * 0.5f);
assetsLoadedLedOn.setPosition(5, ledYPos);
assetsLoadedLedOff.setSize(assetsLoadedLedOff.getWidth() * 0.5f, assetsLoadedLedOff.getHeight() * 0.5f);
assetsLoadedLedOff.setPosition(5, ledYPos);
// Set OUYA's O button.
ouyaOButtonTexture = new Texture("data/gfx/gui/OUYA_O.png");
TextureRegion region = new TextureRegion(ouyaOButtonTexture, ouyaOButtonTexture.getWidth(), ouyaOButtonTexture.getHeight());
ouyaOButton = new Sprite(region);
ouyaOButton.setSize(ouyaOButton.getWidth() * 0.6f, ouyaOButton.getHeight() * 0.6f);
oButtonSelection = 0;
oButtonPressed = false;
}
@@ -70,21 +73,22 @@ public class OuyaMainMenuState extends MainMenuStateBase{
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
core.batch.begin();{
// Render background.
core.batch.disableBlending();
drawBackground(core.batch);
core.batch.enableBlending();
if(clientConnected){
clientConnectedLedOn.draw(core.batch);
}else{
clientConnectedLedOff.draw(core.batch);
}
// TODO: Render calibration leds.
// Render leds.
if(cameraCalibrated) cameraCalibratedLedOn.draw(core.batch);
else cameraCalibratedLedOff.draw(core.batch);
if(assetsLoaded) assetsLoadedLedOn.draw(core.batch);
else assetsLoadedLedOff.draw(core.batch);
// Render buttons.
startButton.draw(core.batch, 1.0f);
calibrationButton.draw(core.batch, 1.0f);
// Render O button.
if(oButtonSelection == 0){
ouyaOButton.setPosition(startButton.getX() - ouyaOButton.getWidth() - 20, startButton.getY() + (ouyaOButton.getHeight() / 2));
}else if(oButtonSelection == 1){

View File

@@ -1,49 +0,0 @@
/*
* Copyright (C) 2014 Miguel Angel Astor Romero
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ve.ucv.ciens.ccg.nxtar.states;
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
public class PauseState extends BaseState {
public PauseState(final NxtARCore core){
this.core = core;
}
@Override
public void onStateSet() {
// TODO Auto-generated method stub
}
@Override
public void onStateUnset() {
// TODO Auto-generated method stub
}
@Override
public void render(float delta) {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
}

View File

@@ -21,26 +21,29 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
public class TabletMainMenuState extends MainMenuStateBase{
private float ledYPos;
public TabletMainMenuState(final NxtARCore core){
super();
this.core = core;
// Set buttons.
startButton.setPosition(-(startButton.getWidth() / 2), -(startButton.getHeight() / 2));
startButtonBBox.setPosition(startButton.getX(), startButton.getY());
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);
clientConnectedLedOff.setSize(clientConnectedLedOff.getWidth() * 0.5f, clientConnectedLedOff.getHeight() * 0.5f);
clientConnectedLedOff.setPosition(-(clientConnectedLedOff.getWidth() / 2), ledYPos);
// TODO: Set calibration led attributes.
// Set leds.
ledYPos = (-(Gdx.graphics.getHeight() / 2) * 0.5f) + (calibrationButton.getY() * 0.5f);
cameraCalibratedLedOn.setSize(cameraCalibratedLedOn.getWidth() * 0.5f, cameraCalibratedLedOn.getHeight() * 0.5f);
cameraCalibratedLedOn.setPosition(-cameraCalibratedLedOn.getWidth() - 5, ledYPos);
cameraCalibratedLedOff.setSize(cameraCalibratedLedOff.getWidth() * 0.5f, cameraCalibratedLedOff.getHeight() * 0.5f);
cameraCalibratedLedOff.setPosition(-cameraCalibratedLedOff.getWidth() - 5, ledYPos);
assetsLoadedLedOn.setSize(assetsLoadedLedOn.getWidth() * 0.5f, assetsLoadedLedOn.getHeight() * 0.5f);
assetsLoadedLedOn.setPosition(5, ledYPos);
assetsLoadedLedOff.setSize(assetsLoadedLedOff.getWidth() * 0.5f, assetsLoadedLedOff.getHeight() * 0.5f);
assetsLoadedLedOff.setPosition(5, ledYPos);
}
@Override
@@ -51,18 +54,18 @@ public class TabletMainMenuState extends MainMenuStateBase{
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
core.batch.begin();{
// Render background.
core.batch.disableBlending();
drawBackground(core.batch);
core.batch.enableBlending();
if(clientConnected){
clientConnectedLedOn.draw(core.batch);
}else{
clientConnectedLedOff.draw(core.batch);
}
// TODO: Render calibration led.
// Render leds.
if(cameraCalibrated) cameraCalibratedLedOn.draw(core.batch);
else cameraCalibratedLedOff.draw(core.batch);
if(assetsLoaded) assetsLoadedLedOn.draw(core.batch);
else assetsLoadedLedOff.draw(core.batch);
// Render buttons.
startButton.draw(core.batch, 1.0f);
calibrationButton.draw(core.batch, 1.0f);