Commit fa81c572 authored by ivarnm's avatar ivarnm
Browse files

Merge branch 'dev'

parents 7fc78a72 c1000682
package com.gameware.game.states;
package com.gameware.game.states.menus;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
......@@ -10,6 +10,12 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.utils.Align;
import com.gameware.game.GameWare;
import com.gameware.game.GameStateManager;
import com.gameware.game.states.State;
/*
State after a game is over, showing the player which score they got on the game.
*/
public class ScoreState extends MenuStateUnion {
......@@ -33,6 +39,7 @@ public class ScoreState extends MenuStateUnion {
scoreLabel.setText(score+"");
continueLabel.getColor().a = 0;
// GlyphLayout used to calculate the size of the label to scale it properly
GlyphLayout g = new GlyphLayout();
g.setText(skin.getFont("font-big"), score+"");
scoreLabelDifferance = (g.width - (g.width*titleFontBigScale*2))/2;
......
package com.gameware.game.states;
package com.gameware.game.states.menus;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
......@@ -11,12 +11,23 @@ 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.GameStateManager;
import com.gameware.game.states.games.PlayStateUnion;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/*
State where players can choose which game they want to play.
Patterns: Publish-Subscribe, Delegation
Publish-Subscribe and delegation is used on the buttons. Where P-S is used by utilizing
click listeners and delegation is used by the button to delegate what happens to this state.
*/
public class SinglePlayerSelectGameState extends MenuStateUnion {
// Data
......@@ -71,7 +82,7 @@ public class SinglePlayerSelectGameState extends MenuStateUnion {
innerTable.setBackground(backgroundTableBlueRounded);
innerTable.columnDefaults(0).spaceRight(spacingLittle);
if(games.size()==0){
if(games.isEmpty()){
// If the try failed, and no games found
innerTable.add(noGamesLabel).pad(padding);
}else {
......@@ -79,7 +90,7 @@ public class SinglePlayerSelectGameState extends MenuStateUnion {
if(GameWare.getInstance().getGameIdToPlayState().get(g.getId()) == null){
continue;
}
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).getScreenshot())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).pad(spacingLittle);
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).getThumbnail())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).pad(spacingLittle);
Table innerInnerTable = new Table();
innerInnerTable.add(makeTableWithLabelAndQuestionIcon(new Label(g.getName(), skin), makeQuestionIconDialog(new Label(g.getExplanation().replaceAll("\\\\n", "\n"), skin)))).spaceBottom(spacingLittle);
......@@ -105,7 +116,7 @@ public class SinglePlayerSelectGameState extends MenuStateUnion {
return backBtn;
}
private void handleGameBtnClick(State state){
private void handleGameBtnClick(PlayStateUnion state){
if(GameWare.getInstance().isSoundEffectsOn()){ buttonPressSound.play(); }
gsm.set(state);
}
......@@ -125,7 +136,7 @@ public class SinglePlayerSelectGameState extends MenuStateUnion {
@Override
public void clicked(InputEvent event, float x, float y) {
Map<String, PlayStateUnion> map = GameWare.getInstance().getGameIdToPlayState();
State s = map.get(game.getId());
PlayStateUnion s = map.get(game.getId());
handleGameBtnClick(s);
};
}
......
package com.gameware.game.states;
package com.gameware.game.states.menus;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
......@@ -13,10 +13,20 @@ import com.gameware.game.QueryIntermediate;
import com.gameware.game.models.Point;
import com.gameware.game.models.Round;
import com.gameware.game.models.Tournament;
import com.gameware.game.GameStateManager;
import java.util.ArrayList;
import java.util.List;
/*
State where players can view the current scores in a tournament.
Patterns: Publish-Subscribe, Delegation
Publish-Subscribe and delegation is used on the buttons. Where P-S is used by utilizing
click listeners and delegation is used by the button to delegate what happens to this state.
*/
public class TournamentHighScoreState extends MenuStateUnion {
// Data
......
package com.gameware.game.states;
package com.gameware.game.states.menus;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
......@@ -12,12 +12,22 @@ import com.gameware.game.GameWare;
import com.gameware.game.QueryIntermediate;
import com.gameware.game.models.Game;
import com.gameware.game.models.Highscore;
import com.gameware.game.GameStateManager;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
/*
State where players can view high scores for a specified game
Patterns: Publish-Subscribe, Delegation
Publish-Subscribe and delegation is used on the buttons. Where P-S is used by utilizing
click listeners and delegation is used by the button to delegate what happens to this state.
*/
public class ViewHighScoreForGameState extends MenuStateUnion {
// Data
......
package com.gameware.game.states;
package com.gameware.game.states.menus;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
......@@ -17,9 +17,19 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.gameware.game.GameWare;
import com.gameware.game.models.Game;
import com.gameware.game.sprites.LoadingText;
import com.gameware.game.GameStateManager;
import java.io.IOException;
/*
State where players can choose which game they want to view high scores for
Patterns: Publish-Subscribe, Delegation
Publish-Subscribe and delegation is used on the buttons. Where P-S is used by utilizing
click listeners and delegation is used by the button to delegate what happens to this state.
*/
public class ViewHighScoreState extends MenuStateUnion {
// Data
......@@ -87,7 +97,7 @@ public class ViewHighScoreState extends MenuStateUnion {
if(GameWare.getInstance().getGameIdToPlayState().get(g.getId()) == null){
continue;
}
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).getScreenshot())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).pad(spacingLittle);
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).getThumbnail())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).pad(spacingLittle);
Table innerInnerTable = new Table();
innerInnerTable.add(makeTableWithLabelAndQuestionIcon(new Label(g.getName(), skin), makeQuestionIconDialog(new Label(g.getExplanation().replaceAll("\\\\n", "\n"), skin)))).spaceBottom(spacingLittle);
......
package com.gameware.game.states;
package com.gameware.game.states.menus;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
......@@ -20,10 +20,22 @@ 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.GameStateManager;
import com.gameware.game.states.games.PlayStateUnion;
import java.io.IOException;
import java.util.List;
/*
State where players can view a specified tournament, from there they can play their round,
leave, or go to TournamentHighScoreState.
Patterns: Publish-Subscribe, Delegation
Publish-Subscribe and delegation is used on the buttons. Where P-S is used by utilizing
click listeners and delegation is used by the button to delegate what happens to this state.
*/
public class ViewTournamentState extends MenuStateUnion {
// Data
......@@ -109,7 +121,7 @@ public class ViewTournamentState extends MenuStateUnion {
currentRoundTable.setBackground(backgroundTableBlueRounded);
currentRoundTable.add(new Label("This round:\n\n"+gameName,skin)).space(spacingLittle);
PlayStateUnion state = GameWare.getInstance().getGameIdToPlayState().get(round.getGameId());
currentRoundTable.add(new Image(state.getScreenshot())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).spaceBottom(spacingMedium).colspan(2);
currentRoundTable.add(new Image(state.getThumbnail())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).spaceBottom(spacingMedium).colspan(2);
rootTable.add(currentRoundTable).maxHeight(Gdx.graphics.getHeight()/5).colspan(2);
rootTable.row();
......@@ -127,7 +139,7 @@ public class ViewTournamentState extends MenuStateUnion {
rootTable.add(innerTable).colspan(2);
rootTable.row();
rootTable.add(makeBackBtn()).expand().bottom().left();
roundDeadline.setFontScale(0.8f);
roundDeadline.setFontScale(0.8f * super.scaleRatio);
rootTable.add(roundDeadline).expand().bottom().right();
stage.addActor(rootTable);
......
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