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

#20 Dialog atlas editation, button type and dialog type enums

parent 662c2559
No related branches found
No related tags found
No related merge requests found
android/assets/atlases/dialog_atlas.png

460 KiB

dialog_atlas.png
size: 1024,1024
dialog_background.png
size: 1024,512
format: RGBA8888
filter: Nearest,Nearest
repeat: none
detectiveoffice_bubble
bubble_arrow_down
rotate: false
xy: 2, 73
size: 348, 245
split: 132, 78, 11, 143
pad: 23, 58, 6, 58
orig: 348, 245
offset: 0, 0
index: -1
dialog_background
rotate: false
xy: 410, 784
size: 401, 222
split: 21, 27, 22, 28
pad: 23, 32, 20, 28
orig: 401, 222
offset: 0, 0
index: -1
howto_background
rotate: false
xy: 2, 320
size: 404, 341
split: 22, 27, 18, 24
pad: 21, 27, 17, 27
orig: 404, 341
offset: 0, 0
index: -1
newuser_dialog_background
rotate: false
xy: 410, 631
size: 247, 151
split: 52, 37, 30, 37
pad: 20, 27, 24, 32
orig: 247, 151
xy: 251, 52
size: 158, 101
split: 62, 16, 3, 54
pad: 5, 7, 2, 52
orig: 158, 101
offset: 0, 0
index: -1
newuser_helpbubble_left
bubble_arrow_left
rotate: false
xy: 408, 528
xy: 758, 267
size: 158, 101
split: 64, 27, 4, 65
pad: 7, 9, 3, 51
orig: 158, 101
offset: 0, 0
index: -1
newuser_helpbubble_straight
bubble_classic
rotate: false
xy: 408, 425
size: 158, 101
split: 62, 16, 3, 54
pad: 5, 7, 2, 52
orig: 158, 101
xy: 408, 180
size: 123, 69
split: 6, 35, 4, 21
pad: 7, 5, 5, 19
orig: 123, 69
offset: 0, 0
index: -1
newuser_signature_background
bubble_classic_continue_button
rotate: false
xy: 2, 663
size: 406, 343
split: 24, 29, 20, 26
pad: 26, 31, 24, 32
orig: 406, 343
xy: 408, 251
size: 348, 245
split: 132, 78, 11, 143
pad: 23, 58, 6, 58
orig: 348, 245
offset: 0, 0
index: -1
screen_halloffame_mouse_bubble
dialog_rectangle
rotate: false
xy: 2, 2
size: 123, 69
split: 6, 35, 4, 21
pad: 7, 5, 5, 19
orig: 123, 69
size: 247, 151
split: 52, 37, 30, 37
pad: 20, 27, 24, 32
orig: 247, 151
offset: 0, 0
index: -1
victoryscreen_trophy_background
dialog_square
rotate: false
xy: 813, 880
xy: 758, 370
size: 150, 126
split: 12, 18, 4, 8
pad: 9, 10, 8, 10
orig: 150, 126
offset: 0, 0
index: -1
dialog_square_borderlines
rotate: false
xy: 2, 155
size: 404, 341
split: 22, 27, 18, 24
pad: 21, 27, 17, 27
orig: 404, 341
offset: 0, 0
index: -1
android/assets/atlases/dialog_background.png

202 KiB

package cz.nic.tablexia.screen.halloffame;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Stack;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable;
import java.util.ArrayList;
import java.util.List;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.loader.application.ApplicationTextureManager;
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.Log;
import cz.nic.tablexia.util.ui.dialog.ImageDialog;
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> {
......@@ -137,7 +126,7 @@ 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.DialogType.NEWUSER_OFFICE, new DialogTextContent("HOU", "HEY YAAAAAAAAAAAA")).show(getStage());
new TablexiaDialog(400, 200, 400, 200, TablexiaDialog.BackGroundType.NEWUSER_OFFICE, new DialogTextContent("HOU", "HEY YAAAAAAAAAAAA")).show(getStage());
}
});
foregroundGroup.addActor(imgDoorButton);
......
......@@ -2,7 +2,6 @@ package cz.nic.tablexia.util.ui.dialog;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import java.util.List;
......@@ -15,13 +14,17 @@ import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
public class ImageDialog extends TablexiaDialog {
private List<Texture> texturesList;
public ImageDialog(float x, float y,float width, float height,DialogType dialogType,List<Texture> texturesList, DialogTextContent dialogTextContent) {
super(x,y,width,height,dialogType,dialogTextContent);
public ImageDialog(float x, float y,float width, float height,BackGroundType backGroundType,List<Texture> texturesList, DialogTextContent dialogTextContent) {
super(x,y,width,height, backGroundType,dialogTextContent);
this.texturesList = texturesList;
prepareContent(dialogTextContent);
}
public ImageDialog(float x, float y,float width, float height,BackGroundType backGroundType,Texture texture, DialogTextContent dialogTextContent){
super(x,y,width,height, backGroundType,dialogTextContent);
}
private void prepareContent(DialogTextContent dialogTextContent){
Table imageGroup = new Table();
......
......@@ -23,19 +23,21 @@ public abstract class SingleButtonDialog extends TablexiaDialog {
private TextButton confirmButton;
public SingleButtonDialog(float x, float y,float width, float height, DialogType dialogType,String buttonText,DialogTextContent dialogTextContent) {
super(x,y,width, height,dialogType,dialogTextContent);
public SingleButtonDialog(float x, float y,float width, float height, BackGroundType backGroundType,String buttonText,DialogTextContent dialogTextContent) {
super(x,y,width, height, backGroundType,dialogTextContent);
prepareButton(buttonText);
}
private void prepareButton(String buttonText){
if(!buttonText.equals(null)){
confirmButton = new TextButton(buttonText, new Skin(Gdx.files.internal("uiskin.json")));
NinePatch up = buttonAtlas.createPatch(dialogType.getButtonTextureName()+BTN_DRAWABLE_UNPRESSED_ENDING);
NinePatch up = buttonAtlas.createPatch(backGroundType.getButtonTextureName()+BTN_DRAWABLE_UNPRESSED_ENDING);
NinePatchDrawable npdUp = new NinePatchDrawable(up);
NinePatch down = buttonAtlas.createPatch(dialogType.getButtonTextureName()+BTN_DRAWABLE_PRESSED_ENDING);
NinePatch down = buttonAtlas.createPatch(backGroundType.getButtonTextureName()+BTN_DRAWABLE_PRESSED_ENDING);
NinePatchDrawable npdDown = new NinePatchDrawable(down);
NinePatch dis = buttonAtlas.createPatch(BTN_DISABLED_ATLAS_NAME);
......@@ -54,6 +56,10 @@ public abstract class SingleButtonDialog extends TablexiaDialog {
float buttonWidth = getPrefWidth()* BUTTON_WIDTH_RATIO_TO_DIALOG_WIDTH;
float buttonHeight = buttonWidth*BUTTON_HEIGHT_RATIO;
getButtonTable().add(confirmButton).width(buttonWidth).height(buttonHeight);
}else{
throw new IllegalArgumentException("Invalid dialog type. Buttons not supported for this type.");
}
}
public abstract void buttonAction();
......
......@@ -10,8 +10,6 @@ import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
import com.badlogic.gdx.scenes.scene2d.utils.Align;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
......@@ -30,50 +28,53 @@ public class TablexiaDialog extends Dialog {
protected float height;
protected float x;
protected float y;
protected DialogType dialogType;
protected BackGroundType backGroundType;
protected DialogTextContent dialogTextContent;
public enum DialogType{
HALLOFFAME_MOUSE("screen_halloffame_mouse_bubble",null,null),
NEWUSER_FORM("newuser_helpbubble_straight",null,null),
NEWUSER_FORM_LEFT("newuser_helpbubble_left",null,null),
NEWUSER_OFFICE("detectiveoffice_bubble",null,null),
NEWUSER_SIGNATURE("newuser_signature_background","tablexiabutton_blank_green",null),
VICTORY_SCREEN("howto_background","tablexiabutton_blank_blue","tablexiabutton_blank_green"),
GAME_HOW_TO_PLAY("howto_background","tablexiabutton_blank_green",null),
USER_LOGOUT("dialog_background","tablexiabutton_blank_red","tablexiabutton_blank_green");
public enum BackGroundType {
BUBBLE_CLASSIC("bubble_classic"),
BUBBLE_ARROW_DOWN("bubble_arrow_down"),
BUBBLE_ARROW_LEFT("bubble_arrow_left"),
BUBBLE_CLASSIC_CONTINUE_BUTTON("bubble_classic_continue_button"),
DIALOG_RECTANGLE("dialog_rectangle"),
DIALOG_SQUARE("dialog_square"),
DIALOG_SQUARE_BORDERLINES("dialog_square_borderlines");
private String dialogBackgroundTextureName;
private String buttonTextureName;
private String button2TextureName;
DialogType(String dialogBackgroundTextureName, String buttonTextureName, String button2TextureName){
BackGroundType(String dialogBackgroundTextureName){
this.dialogBackgroundTextureName = dialogBackgroundTextureName;
this.buttonTextureName = buttonTextureName;
this.button2TextureName = button2TextureName;
}
public String getDialogBackgroundTextureName(){
return dialogBackgroundTextureName;
}
public String getButtonTextureName(){
return buttonTextureName;
}
}
public enum ButtonType{
BLUE("tablexiabutton_blank_blue"),
GREEN("tablexiabutton_blank_green"),
RED("tablexiabutton_blank_red");
public String getButton2TextureName(){
return button2TextureName;
private String buttonResourceName;
ButtonType(String buttonResourceName){
this.buttonResourceName = buttonResourceName;
}
public String getButtonResourceName(){
return buttonResourceName;
}
}
static {
skin = new Skin(Gdx.files.internal("uiskin.json"));
backgroundAtlas = new TextureAtlas(Gdx.files.internal("atlases/dialog_atlas.pack"));
backgroundAtlas = new TextureAtlas(Gdx.files.internal("atlases/dialog_background.atlas"));
buttonAtlas = new TextureAtlas(Gdx.files.internal("atlases/buttons_atlas.pack"));
}
public TablexiaDialog(float x, float y,float width,float height, DialogType dialogType,DialogTextContent dialogTextContent) {
public TablexiaDialog(float x, float y,float width,float height, BackGroundType backGroundType,DialogTextContent dialogTextContent) {
super("",skin);
setModal(true);
setMovable(false);
......@@ -83,10 +84,10 @@ public class TablexiaDialog extends Dialog {
this.y = y;
this.width = width;
this.height = height;
this.dialogType = dialogType;
this.backGroundType = backGroundType;
this.dialogTextContent = dialogTextContent;
NinePatch np = backgroundAtlas.createPatch(dialogType.dialogBackgroundTextureName);
NinePatch np = backgroundAtlas.createPatch(backGroundType.dialogBackgroundTextureName);
NinePatchDrawable npd = new NinePatchDrawable(np);
setBackground(npd);
prepareTextContent();
......
......@@ -25,21 +25,23 @@ public abstract class TwoButtonDialog extends TablexiaDialog {
private TextButton leftButton;
private TextButton rightButton;
public TwoButtonDialog(float x, float y,float width, float height, DialogType dialogType, String buttonLeftText, String buttonRightText,DialogTextContent dialogTextContent) {
super(x,y,width, height, dialogType,dialogTextContent);
public TwoButtonDialog(float x, float y,float width, float height, BackGroundType backGroundType, String buttonLeftText, String buttonRightText,DialogTextContent dialogTextContent) {
super(x,y,width, height, backGroundType,dialogTextContent);
prepareButtons(buttonLeftText,buttonRightText);
}
private void prepareButtons(String buttonLeftText,String buttonRightText){
if(!buttonLeftText.equals(null)&&!buttonRightText.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(dialogType.getButtonTextureName()+BTN_DRAWABLE_UNPRESSED_ENDING);
NinePatch ninepatchBtnLeftUp = buttonAtlas.createPatch(backGroundType.getButtonTextureName()+BTN_DRAWABLE_UNPRESSED_ENDING);
NinePatchDrawable ninePatchDrawableBtnLeftUp = new NinePatchDrawable(ninepatchBtnLeftUp);
NinePatch ninePatchBtnLeftDown = buttonAtlas.createPatch(dialogType.getButtonTextureName()+BTN_DRAWABLE_PRESSED_ENDING);
NinePatch ninePatchBtnLeftDown = buttonAtlas.createPatch(backGroundType.getButtonTextureName()+BTN_DRAWABLE_PRESSED_ENDING);
NinePatchDrawable ninePatchDrawableBtnLeftDown = new NinePatchDrawable(ninePatchBtnLeftDown);
leftButton.setStyle(new TextButton.TextButtonStyle(ninePatchDrawableBtnLeftUp, ninePatchDrawableBtnLeftDown, ninePatchDrawableBtnDisabled, getStyle().titleFont));
......@@ -56,10 +58,10 @@ public abstract class TwoButtonDialog extends TablexiaDialog {
rightButton = new TextButton(buttonRightText, defaultSkin);
NinePatch up = buttonAtlas.createPatch(dialogType.getButtonTextureName()+BTN_DRAWABLE_UNPRESSED_ENDING);
NinePatch up = buttonAtlas.createPatch(backGroundType.getButtonTextureName()+BTN_DRAWABLE_UNPRESSED_ENDING);
NinePatchDrawable npdUp = new NinePatchDrawable(up);
NinePatch down = buttonAtlas.createPatch(dialogType.getButtonTextureName()+BTN_DRAWABLE_PRESSED_ENDING);
NinePatch down = buttonAtlas.createPatch(backGroundType.getButtonTextureName()+BTN_DRAWABLE_PRESSED_ENDING);
NinePatchDrawable npdDown = new NinePatchDrawable(down);
rightButton.setStyle(new TextButton.TextButtonStyle(npdUp, npdDown, ninePatchDrawableBtnDisabled, getStyle().titleFont));
......@@ -73,6 +75,10 @@ public abstract class TwoButtonDialog extends TablexiaDialog {
;
});
}else{
throw new IllegalArgumentException("Invalid dialog type. Only dialog types with two button support allowed here.");
}
}
public abstract void leftButtonAction();
......
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