Commit 6886c8b2 authored by Turid Cecilie Dahl's avatar Turid Cecilie Dahl
Browse files

#98 Adds package game_states

parent f62a1fb2
......@@ -16,7 +16,7 @@ import com.gameware.game.models.Player;
import com.gameware.game.states.GameStateManager;
import com.gameware.game.states.LoginState;
import com.gameware.game.states.MenuState;
import com.gameware.game.states.PlayStateTemplate;
import com.gameware.game.states.game_states.PlayStateTemplate;
import java.io.IOException;
import java.lang.reflect.Constructor;
......
......@@ -115,11 +115,11 @@ public class CreateNewTournamentState extends MenuStateTemplate {
roundsPerGameSelectBox.setItems(1,2,3);
startDelaySelectBox.setItems(1,2,3);
nameDialog = makeDialog(nameLabelQuestion);
timePerRoundDialog = makeDialog(timePerRoundLabelQuestion);
maxPlayersDialog = makeDialog(maxPlayersLabelQuestion);
roundsPerGameDialog = makeDialog(roundsPerGameLabelQuestion);
startDelayDialog = makeDialog(startDelayLabelQuestion);
nameDialog = makeQuestionIconDialog(nameLabelQuestion);
timePerRoundDialog = makeQuestionIconDialog(timePerRoundLabelQuestion);
maxPlayersDialog = makeQuestionIconDialog(maxPlayersLabelQuestion);
roundsPerGameDialog = makeQuestionIconDialog(roundsPerGameLabelQuestion);
startDelayDialog = makeQuestionIconDialog(startDelayLabelQuestion);
makeStage();
}
......@@ -146,21 +146,21 @@ public class CreateNewTournamentState extends MenuStateTemplate {
innerTable.pad(spacingLittle);
innerTable.setBackground(backgroundTableBlueRounded);
innerTable.add(makeRow(nameLabel, nameDialog));
innerTable.add(makeTableWithLabelAndQuestionIcon(nameLabel, nameDialog));
nameInputField.setMaxLength(9);
innerTable.add(nameInputField).size(nameFieldWidth, inputFieldHeight);
innerTable.row();
removeKeyPadAtTouch();
innerTable.add(makeRow(timePerRoundLabel, timePerRoundDialog));
innerTable.add(makeTableWithLabelAndQuestionIcon(timePerRoundLabel, timePerRoundDialog));
innerTable.add(timePerRoundSelectBox);
innerTable.row();
innerTable.add(makeRow(maxPlayersLabel, maxPlayersDialog));
innerTable.add(makeTableWithLabelAndQuestionIcon(maxPlayersLabel, maxPlayersDialog));
innerTable.add(maxPlayersSelectBox);
innerTable.row();
innerTable.add(makeRow(roundsPerGameLabel, roundsPerGameDialog));
innerTable.add(makeTableWithLabelAndQuestionIcon(roundsPerGameLabel, roundsPerGameDialog));
innerTable.add(roundsPerGameSelectBox);
innerTable.row();
innerTable.add(makeRow(startDelayLabel, startDelayDialog));
innerTable.add(makeTableWithLabelAndQuestionIcon(startDelayLabel, startDelayDialog));
innerTable.add(startDelaySelectBox);
rootTable.add(innerTable).colspan(2);
rootTable.row();
......@@ -186,11 +186,11 @@ public class CreateNewTournamentState extends MenuStateTemplate {
continue;
}
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).screenshot)).width(imageWidthAndHeigh).height(imageWidthAndHeigh);
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).getScreenshot())).width(imageWidthAndHeigh).height(imageWidthAndHeigh);
Table innerInnerTable = new Table();
innerInnerTable.defaults().space(spacingLittle);
innerInnerTable.add(makeRow(new Label(g.getName(), skin), makeDialog(new Label(g.getExplanation().replaceAll("\\\\n", "\n"), skin)))).spaceBottom(spacingLittle);
innerInnerTable.add(makeTableWithLabelAndQuestionIcon(new Label(g.getName(), skin), makeQuestionIconDialog(new Label(g.getExplanation().replaceAll("\\\\n", "\n"), skin)))).spaceBottom(spacingLittle);
innerInnerTable.row();
CheckBox gameCB = new CheckBox("",skin);
......
......@@ -70,6 +70,7 @@ public abstract class MenuStateTemplate extends State{
@Override
public void update(float dt){
if(firstTimeRunningUpdate) {
// First time running update change input processor. Or else it won't work when states are stacked in the gsm
Gdx.input.setInputProcessor(stage);
Gdx.input.setCatchBackKey(true);
firstTimeRunningUpdate = false;
......@@ -121,7 +122,7 @@ public abstract class MenuStateTemplate extends State{
// Dialog methods
protected Table makeRow(Label label, final Dialog dialog){
protected Table makeTableWithLabelAndQuestionIcon(Label label, final Dialog dialog){
Table table = new Table();
table.add(label).spaceRight(spacingLittle/2);
Image questionMarkImage = new Image(questionMark);
......@@ -136,7 +137,7 @@ public abstract class MenuStateTemplate extends State{
return table;
}
protected Dialog makeDialog(Label label){
protected Dialog makeQuestionIconDialog(Label label){
Dialog dialog = new Dialog("", skin, "dialog") {
public void result(Object obj) { }
};
......
......@@ -11,6 +11,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Scaling;
import com.gameware.game.GameWare;
public class OptionsState extends MenuStateTemplate {
// Labels
......@@ -27,7 +28,7 @@ public class OptionsState extends MenuStateTemplate {
public OptionsState(GameStateManager gsm) {
super(gsm);
stage.clear();
makeStage();
}
......
......@@ -4,12 +4,12 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.gameware.game.GameWare;
import com.gameware.game.sprites.ConfirmationBox;
import com.gameware.game.sprites.LoadingText;
import com.gameware.game.sprites.PauseCircle;
import com.gameware.game.sprites.PauseMenuButton;
import com.gameware.game.states.game_states.PlayStateTemplate;
import java.util.ArrayList;
import java.util.List;
......
......@@ -11,6 +11,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.gameware.game.GameWare;
import com.gameware.game.models.Game;
import com.gameware.game.states.game_states.PlayStateTemplate;
import java.io.IOException;
import java.util.ArrayList;
......@@ -79,10 +80,10 @@ public class SinglePlayerSelectGameState extends MenuStateTemplate {
if(GameWare.getInstance().getGameIdToPlayState().get(g.getId()) == null){
continue;
}
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).screenshot)).width(imageWidthAndHeigh).height(imageWidthAndHeigh).pad(spacingLittle);
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).getScreenshot())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).pad(spacingLittle);
Table innerInnerTable = new Table();
innerInnerTable.add(makeRow(new Label(g.getName(), skin), makeDialog(new Label(g.getExplanation().replaceAll("\\\\n", "\n"), skin)))).spaceBottom(spacingLittle);
innerInnerTable.add(makeTableWithLabelAndQuestionIcon(new Label(g.getName(), skin), makeQuestionIconDialog(new Label(g.getExplanation().replaceAll("\\\\n", "\n"), skin)))).spaceBottom(spacingLittle);
innerInnerTable.row();
TextButton gameBtn = new TextButton(playBtnText, makeTextButtonStyle(greenColor));
......
......@@ -40,7 +40,7 @@ public abstract class State{
}
// State methods
// Abstract state methods
protected abstract void handleInput();
public abstract void update(float dt);
......
......@@ -2,7 +2,6 @@ package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
......@@ -55,8 +54,8 @@ public class TournamentHighScoreState extends MenuStateTemplate{
e.printStackTrace();
}
totalDialog = makeDialog(totalDialogLabel);
lastRoundDialog = makeDialog(lastRoundLabel);
totalDialog = makeQuestionIconDialog(totalDialogLabel);
lastRoundDialog = makeQuestionIconDialog(lastRoundLabel);
makeStage();
}
......@@ -95,8 +94,8 @@ public class TournamentHighScoreState extends MenuStateTemplate{
innerTable.setBackground(backgroundTableBlueRounded);
innerTable.add(colOneLabel).top();
innerTable.add(makeRow(colTwoLabel,totalDialog)).top();
innerTable.add(makeRow(colThreeLabel,lastRoundDialog)).top();
innerTable.add(makeTableWithLabelAndQuestionIcon(colTwoLabel,totalDialog)).top();
innerTable.add(makeTableWithLabelAndQuestionIcon(colThreeLabel,lastRoundDialog)).top();
innerTable.row();
for(Point point : points){
......
......@@ -2,7 +2,6 @@ package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
......@@ -21,7 +20,7 @@ import com.gameware.game.sprites.LoadingText;
import java.io.IOException;
public class ViewHighScoreState extends State {
public class ViewHighScoreState extends MenuStateTemplate {
// Data
private List<Game> games = new ArrayList<>();
......@@ -33,7 +32,7 @@ public class ViewHighScoreState extends State {
// Texts
private final String backBtnText = "Back";
private final String BtnText = "View High Score!";
private final String BtnText = "View High Score";
// Values
private final float scrollPaneWidth = Gdx.graphics.getWidth()/1.15f;
......@@ -58,7 +57,7 @@ public class ViewHighScoreState extends State {
makeStage();
}
private void makeStage(){
protected void makeStage(){
Table rootTable = super.makeRootTable();
titleLabel.setFontScale(titleFontBigScale);
......@@ -88,10 +87,10 @@ public class ViewHighScoreState extends State {
if(GameWare.getInstance().getGameIdToPlayState().get(g.getId()) == null){
continue;
}
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).screenshot)).width(imageWidthAndHeigh).height(imageWidthAndHeigh).pad(spacingLittle);
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).getScreenshot())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).pad(spacingLittle);
Table innerInnerTable = new Table();
innerInnerTable.add(makeRow(new Label(g.getName(), skin), makeDialog(new Label(g.getExplanation().replaceAll("\\\\n", "\n"), skin)))).spaceBottom(spacingLittle);
innerInnerTable.add(makeTableWithLabelAndQuestionIcon(new Label(g.getName(), skin), makeQuestionIconDialog(new Label(g.getExplanation().replaceAll("\\\\n", "\n"), skin)))).spaceBottom(spacingLittle);
innerInnerTable.row();
TextButton gameBtn = new TextButton(BtnText, skin);
......
......@@ -20,6 +20,7 @@ import com.gameware.game.models.Game;
import com.gameware.game.models.Round;
import com.gameware.game.models.Tournament;
import com.gameware.game.sprites.LoadingText;
import com.gameware.game.states.game_states.PlayStateTemplate;
import java.io.IOException;
import java.util.List;
......@@ -109,7 +110,7 @@ public class ViewTournamentState extends MenuStateTemplate {
currentRoundTable.setBackground(backgroundTableBlueRounded);
currentRoundTable.add(new Label("This round:\n\n"+gameName,skin)).space(spacingLittle);
PlayStateTemplate state = GameWare.getInstance().getGameIdToPlayState().get(round.getGameId());
currentRoundTable.add(new Image(state.screenshot)).width(imageWidthAndHeigh).height(imageWidthAndHeigh).spaceBottom(spacingMedium).colspan(2);
currentRoundTable.add(new Image(state.getScreenshot())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).spaceBottom(spacingMedium).colspan(2);
rootTable.add(currentRoundTable).maxHeight(Gdx.graphics.getHeight()/5).colspan(2);
rootTable.row();
......
package com.gameware.game.states;
package com.gameware.game.states.game_states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.gameware.game.sprites.Bubble;
import com.gameware.game.states.GameStateManager;
import java.util.ArrayList;
......
package com.gameware.game.states;
package com.gameware.game.states.game_states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.gameware.game.sprites.ColorRushButton;
import com.gameware.game.sprites.ColorRushTarget;
import com.gameware.game.states.GameStateManager;
import java.util.ArrayList;
import java.util.Collections;
......
package com.gameware.game.states;
package com.gameware.game.states.game_states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;
......@@ -8,6 +8,7 @@ import com.badlogic.gdx.math.Vector3;
import com.gameware.game.GameWare;
import com.gameware.game.sprites.Fruit;
import com.gameware.game.sprites.SlicingCircle;
import com.gameware.game.states.GameStateManager;
import java.util.ArrayList;
import java.util.List;
......
package com.gameware.game.states;
package com.gameware.game.states.game_states;
import com.badlogic.gdx.Gdx;
......@@ -14,6 +14,13 @@ import com.gameware.game.models.RoundCheck;
import com.gameware.game.models.Tournament;
import com.gameware.game.sprites.LoadingText;
import com.gameware.game.sprites.PauseButton;
import com.gameware.game.states.FinishedTournamentState;
import com.gameware.game.states.GameStateManager;
import com.gameware.game.states.PauseState;
import com.gameware.game.states.ScoreState;
import com.gameware.game.states.SinglePlayerSelectGameState;
import com.gameware.game.states.State;
import com.gameware.game.states.ViewTournamentState;
import java.io.IOException;
import java.util.List;
......@@ -139,7 +146,7 @@ public abstract class PlayStateTemplate extends State {
// When game is done, this method is called and posts the score, ands new instance of the game,
// uptades rounds and tournaments if in a tournament and sends back to the correct state.
// Remember to use setScore before using this method.
protected void gameDone(){
public void gameDone(){
String id = "";
//Find the id to the game just played
for (String key : GameWare.getInstance().getGameIdToPlayState().keySet()){
......@@ -255,6 +262,10 @@ public abstract class PlayStateTemplate extends State {
return this.totalGameTime;
}
public Texture getScreenshot(){
return screenshot;
}
// Hide and show methods:
public void hidePauseButton(){
this.pauseButtonVisible = false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment