Skip to content
Snippets Groups Projects
Commit df581e06 authored by Turid Cecilie Dahl's avatar Turid Cecilie Dahl
Browse files

#92 Moves ? icon making to State

parent 4aebc83b
No related branches found
No related tags found
1 merge request!92Resolve "Frontend cleaning"
...@@ -242,37 +242,6 @@ public class CreateNewTournamentState extends State { ...@@ -242,37 +242,6 @@ public class CreateNewTournamentState extends State {
stage.addActor(rootTable); stage.addActor(rootTable);
} }
private Table makeRow(Label label, final Dialog dialog){
Table table = new Table();
table.add(label).spaceRight(spacingLittle/2);
Image questionMarkImage = new Image(questionMark);
questionMarkImage.addListener(new ClickListener(){
@Override
public void clicked(InputEvent e, float x, float y){
if(GameWare.getInstance().isSoundEffectsOn()){ checkBoxSound.play(); }
dialog.show(stage);
}
});
table.add(questionMarkImage).width(questionMarkWidthAndHeight).height(questionMarkWidthAndHeight).top();
return table;
}
private Dialog makeDialog(Label label){
Dialog dialog = new Dialog("", skin, "dialog") {
public void result(Object obj) { }
};
label.setAlignment(Align.center);
label.setWrap(true);
dialog.getContentTable().add(label).width(Gdx.graphics.getWidth()/1.5f).pad(dialog.getHeight()/5f).padBottom(0);
dialog.button("Okay", true); //sends "true" as the result
dialog.getButtonTable().pad(dialog.getHeight()/2f);
return dialog;
}
private TextButton makeCreateBtn() { private TextButton makeCreateBtn() {
TextButton createBtn = new TextButton(createBtnText, skin); TextButton createBtn = new TextButton(createBtnText, skin);
createBtn.addListener(new ClickListener() { createBtn.addListener(new ClickListener() {
......
...@@ -3,14 +3,12 @@ package com.gameware.game.states; ...@@ -3,14 +3,12 @@ package com.gameware.game.states;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input; import com.badlogic.gdx.Input;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Align;
import com.gameware.game.GameWare; import com.gameware.game.GameWare;
import com.gameware.game.models.Game; import com.gameware.game.models.Game;
...@@ -37,8 +35,6 @@ public class SinglePlayerSelectGameState extends State { ...@@ -37,8 +35,6 @@ public class SinglePlayerSelectGameState extends State {
private final float scrollPaneHeight = Gdx.graphics.getHeight()/2.3f; private final float scrollPaneHeight = Gdx.graphics.getHeight()/2.3f;
protected SinglePlayerSelectGameState(GameStateManager gsm) { protected SinglePlayerSelectGameState(GameStateManager gsm) {
super(gsm); super(gsm);
try { try {
...@@ -102,36 +98,6 @@ public class SinglePlayerSelectGameState extends State { ...@@ -102,36 +98,6 @@ public class SinglePlayerSelectGameState extends State {
return innerTable; return innerTable;
} }
private Table makeRow(Label label, final Dialog dialog){
Table table = new Table();
table.add(label).spaceRight(spacingLittle/2);
Image questionMarkImage = new Image(questionMark);
questionMarkImage.addListener(new ClickListener(){
@Override
public void clicked(InputEvent e, float x, float y){
if(GameWare.getInstance().isSoundEffectsOn()){ checkBoxSound.play(); }
dialog.show(stage);
}
});
table.add(questionMarkImage).width(questionMarkWidthAndHeight).height(questionMarkWidthAndHeight).top();
return table;
}
private Dialog makeDialog(Label label){
Dialog dialog = new Dialog("", skin, "dialog") {
public void result(Object obj) { }
};
label.setAlignment(Align.center);
label.setWrap(true);
dialog.getContentTable().add(label).width(Gdx.graphics.getWidth()/1.5f).pad(dialog.getHeight()/5f).padBottom(0);
dialog.button("Okay", true); //sends "true" as the result
dialog.getButtonTable().pad(dialog.getHeight()/2f);
return dialog;
}
private TextButton makeBackBtn(){ private TextButton makeBackBtn(){
TextButton backBtn = new TextButton(backBtnText, skin); TextButton backBtn = new TextButton(backBtnText, skin);
backBtn.addListener(new ClickListener() { backBtn.addListener(new ClickListener() {
......
...@@ -8,10 +8,16 @@ import com.badlogic.gdx.graphics.Pixmap; ...@@ -8,10 +8,16 @@ import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Align;
import com.gameware.game.GameWare; import com.gameware.game.GameWare;
public abstract class State { public abstract class State {
...@@ -126,4 +132,37 @@ public abstract class State { ...@@ -126,4 +132,37 @@ public abstract class State {
bgPixmap.fill(); bgPixmap.fill();
return new TextureRegionDrawable(new TextureRegion(new Texture(bgPixmap))); return new TextureRegionDrawable(new TextureRegion(new Texture(bgPixmap)));
} }
// Dialog methods
protected Table makeRow(Label label, final Dialog dialog){
Table table = new Table();
table.add(label).spaceRight(spacingLittle/2);
Image questionMarkImage = new Image(questionMark);
questionMarkImage.addListener(new ClickListener(){
@Override
public void clicked(InputEvent e, float x, float y){
if(GameWare.getInstance().isSoundEffectsOn()){ checkBoxSound.play(); }
dialog.show(stage);
}
});
table.add(questionMarkImage).width(questionMarkWidthAndHeight).height(questionMarkWidthAndHeight).top();
return table;
}
protected Dialog makeDialog(Label label){
Dialog dialog = new Dialog("", skin, "dialog") {
public void result(Object obj) { }
};
label.setAlignment(Align.center);
label.setWrap(true);
dialog.getContentTable().add(label).width(Gdx.graphics.getWidth()/1.5f).pad(dialog.getHeight()/5f).padBottom(0);
dialog.button("Okay", true); //sends "true" as the result
dialog.getButtonTable().pad(dialog.getHeight()/2f);
return dialog;
}
} }
...@@ -117,36 +117,6 @@ public class TournamentHighScoreState extends State{ ...@@ -117,36 +117,6 @@ public class TournamentHighScoreState extends State{
return innerTable; return innerTable;
} }
private Table makeRow(Label label, final Dialog dialog){
Table table = new Table();
table.add(label).spaceRight(spacingLittle/2);
Image questionMarkImage = new Image(questionMark);
questionMarkImage.addListener(new ClickListener(){
@Override
public void clicked(InputEvent e, float x, float y){
if(GameWare.getInstance().isSoundEffectsOn()){ checkBoxSound.play(); }
dialog.show(stage);
}
});
table.add(questionMarkImage).width(questionMarkWidthAndHeight).height(questionMarkWidthAndHeight).top();
return table;
}
private Dialog makeDialog(Label label){
Dialog dialog = new Dialog("", skin, "dialog") {
public void result(Object obj) { }
};
label.setAlignment(Align.center);
label.setWrap(true);
dialog.getContentTable().add(label).width(Gdx.graphics.getWidth()/1.5f).pad(dialog.getHeight()/5f).padBottom(0);
dialog.button("Okay", true); //sends "true" as the result
dialog.getButtonTable().pad(dialog.getHeight()/2f);
return dialog;
}
private TextButton makeBackBtn(){ private TextButton makeBackBtn(){
TextButton backBtn = new TextButton(backBtnText, skin); TextButton backBtn = new TextButton(backBtnText, skin);
backBtn.addListener(new ClickListener() { backBtn.addListener(new ClickListener() {
......
...@@ -114,36 +114,6 @@ public class ViewHighScoreState extends State { ...@@ -114,36 +114,6 @@ public class ViewHighScoreState extends State {
return innerTable; return innerTable;
} }
private Table makeRow(Label label, final Dialog dialog){
Table table = new Table();
table.add(label).spaceRight(spacingLittle/2);
Image questionMarkImage = new Image(questionMark);
questionMarkImage.addListener(new ClickListener(){
@Override
public void clicked(InputEvent e, float x, float y){
if(GameWare.getInstance().isSoundEffectsOn()){ checkBoxSound.play(); }
dialog.show(stage);
}
});
table.add(questionMarkImage).width(questionMarkWidthAndHeight).height(questionMarkWidthAndHeight).top();
return table;
}
private Dialog makeDialog(Label label){
Dialog dialog = new Dialog("", skin, "dialog") {
public void result(Object obj) { }
};
label.setAlignment(Align.center);
label.setWrap(true);
dialog.getContentTable().add(label).width(Gdx.graphics.getWidth()/1.5f).pad(dialog.getHeight()/5f).padBottom(0);
dialog.button("Okay", true); //sends "true" as the result
dialog.getButtonTable().pad(dialog.getHeight()/2f);
return dialog;
}
private TextButton makeBackBtn(){ private TextButton makeBackBtn(){
TextButton backBtn = new TextButton(backBtnText, skin); TextButton backBtn = new TextButton(backBtnText, skin);
backBtn.addListener(new ClickListener() { backBtn.addListener(new ClickListener() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment