Skip to content
Snippets Groups Projects
Commit be718e2d authored by v.tarantik's avatar v.tarantik
Browse files

#20 Button type and dialog background type added, SingleButton and TwoButtonDialog updated

parent 8ae7a80f
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,9 @@ import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.screen.halloffame.assets.HallOfFameAssets;
import cz.nic.tablexia.screen.halloffame.helper.TrophyHelper;
import cz.nic.tablexia.util.ui.dialog.SingleButtonDialog;
import cz.nic.tablexia.util.ui.dialog.TablexiaDialog;
import cz.nic.tablexia.util.ui.dialog.TwoButtonDialog;
import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
public class HallOfFameScreen extends AbstractTablexiaScreen<Void> {
......@@ -126,7 +128,17 @@ public class HallOfFameScreen extends AbstractTablexiaScreen<Void> {
Texture textureDoor = getTexture(HallOfFameAssets.HALL_OF_FAME_DOOR_BUTTON_PRESSED);
imgDoorButton.setDrawable(new SpriteDrawable(new Sprite(textureDoor)));
//TODO add action for leaving to main menu
new TablexiaDialog(400, 200, 400, 200, TablexiaDialog.BackGroundType.NEWUSER_OFFICE, new DialogTextContent("HOU", "HEY YAAAAAAAAAAAA")).show(getStage());
new TwoButtonDialog(400, 200, 400, 200, TablexiaDialog.BackGroundType.DIALOG_SQUARE_BORDERLINES, TablexiaDialog.ButtonType.RED,TablexiaDialog.ButtonType.GREEN, "OUKAY","NOUKAY",new DialogTextContent("HOU", "HEY YAAAAAAAAAAAA")) {
@Override
public void leftButtonAction() {
}
@Override
public void rightButtonAction() {
}
}.show(getStage());
}
});
foregroundGroup.addActor(imgDoorButton);
......
......@@ -23,21 +23,21 @@ public abstract class SingleButtonDialog extends TablexiaDialog {
private TextButton confirmButton;
public SingleButtonDialog(float x, float y,float width, float height, BackGroundType backGroundType,String buttonText,DialogTextContent dialogTextContent) {
public SingleButtonDialog(float x, float y,float width, float height, BackGroundType backGroundType, ButtonType buttonType,String buttonText,DialogTextContent dialogTextContent) {
super(x,y,width, height, backGroundType,dialogTextContent);
prepareButton(buttonText);
prepareButton(buttonType,buttonText);
}
private void prepareButton(String buttonText){
if(!buttonText.equals(null)){
private void prepareButton(ButtonType buttonType, String buttonText){
if(!buttonType.equals(null)){
confirmButton = new TextButton(buttonText, new Skin(Gdx.files.internal("uiskin.json")));
NinePatch up = buttonAtlas.createPatch(backGroundType.getButtonTextureName()+BTN_DRAWABLE_UNPRESSED_ENDING);
NinePatch up = buttonAtlas.createPatch(buttonType.getButtonResourceName()+BTN_DRAWABLE_UNPRESSED_ENDING);
NinePatchDrawable npdUp = new NinePatchDrawable(up);
NinePatch down = buttonAtlas.createPatch(backGroundType.getButtonTextureName()+BTN_DRAWABLE_PRESSED_ENDING);
NinePatch down = buttonAtlas.createPatch(buttonType.getButtonResourceName()+BTN_DRAWABLE_PRESSED_ENDING);
NinePatchDrawable npdDown = new NinePatchDrawable(down);
NinePatch dis = buttonAtlas.createPatch(BTN_DISABLED_ATLAS_NAME);
......
......@@ -25,23 +25,23 @@ public abstract class TwoButtonDialog extends TablexiaDialog {
private TextButton leftButton;
private TextButton rightButton;
public TwoButtonDialog(float x, float y,float width, float height, BackGroundType backGroundType, String buttonLeftText, String buttonRightText,DialogTextContent dialogTextContent) {
public TwoButtonDialog(float x, float y,float width, float height, BackGroundType backGroundType, ButtonType leftButtonType, ButtonType rightButtonType,String buttonLeftText, String buttonRightText,DialogTextContent dialogTextContent) {
super(x,y,width, height, backGroundType,dialogTextContent);
prepareButtons(buttonLeftText,buttonRightText);
prepareButtons(leftButtonType,rightButtonType,buttonLeftText,buttonRightText);
}
private void prepareButtons(String buttonLeftText,String buttonRightText){
if(!buttonLeftText.equals(null)&&!buttonRightText.equals(null)){
private void prepareButtons(ButtonType leftButtonType,ButtonType rightButtonType,String buttonLeftText,String buttonRightText){
if(!leftButtonType.equals(null)&&!rightButtonType.equals(null)){
Skin defaultSkin = new Skin(Gdx.files.internal("uiskin.json"));
NinePatch ninePatchBtnDisabled = buttonAtlas.createPatch(BTN_DISABLED_ATLAS_NAME);
NinePatchDrawable ninePatchDrawableBtnDisabled = new NinePatchDrawable(ninePatchBtnDisabled);
leftButton = new TextButton(buttonLeftText, defaultSkin);
NinePatch ninepatchBtnLeftUp = buttonAtlas.createPatch(backGroundType.getButtonTextureName()+BTN_DRAWABLE_UNPRESSED_ENDING);
NinePatch ninepatchBtnLeftUp = buttonAtlas.createPatch(leftButtonType.getButtonResourceName()+BTN_DRAWABLE_UNPRESSED_ENDING);
NinePatchDrawable ninePatchDrawableBtnLeftUp = new NinePatchDrawable(ninepatchBtnLeftUp);
NinePatch ninePatchBtnLeftDown = buttonAtlas.createPatch(backGroundType.getButtonTextureName()+BTN_DRAWABLE_PRESSED_ENDING);
NinePatch ninePatchBtnLeftDown = buttonAtlas.createPatch(leftButtonType.getButtonResourceName()+BTN_DRAWABLE_PRESSED_ENDING);
NinePatchDrawable ninePatchDrawableBtnLeftDown = new NinePatchDrawable(ninePatchBtnLeftDown);
leftButton.setStyle(new TextButton.TextButtonStyle(ninePatchDrawableBtnLeftUp, ninePatchDrawableBtnLeftDown, ninePatchDrawableBtnDisabled, getStyle().titleFont));
......@@ -58,10 +58,10 @@ public abstract class TwoButtonDialog extends TablexiaDialog {
rightButton = new TextButton(buttonRightText, defaultSkin);
NinePatch up = buttonAtlas.createPatch(backGroundType.getButtonTextureName()+BTN_DRAWABLE_UNPRESSED_ENDING);
NinePatch up = buttonAtlas.createPatch(rightButtonType.getButtonResourceName()+BTN_DRAWABLE_UNPRESSED_ENDING);
NinePatchDrawable npdUp = new NinePatchDrawable(up);
NinePatch down = buttonAtlas.createPatch(backGroundType.getButtonTextureName()+BTN_DRAWABLE_PRESSED_ENDING);
NinePatch down = buttonAtlas.createPatch(rightButtonType.getButtonResourceName()+BTN_DRAWABLE_PRESSED_ENDING);
NinePatchDrawable npdDown = new NinePatchDrawable(down);
rightButton.setStyle(new TextButton.TextButtonStyle(npdUp, npdDown, ninePatchDrawableBtnDisabled, getStyle().titleFont));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment