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

#20 Text dialog type, change of prepare dialog content strategy

parent d46d8d29
Branches
Tags
No related merge requests found
......@@ -147,7 +147,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
}
@Override
protected void prepareDialogContent() {
protected void prepareContent() {
// RESULTS BANNER
Image resultsBanner = new Image(getTexture(VICTORYSCREEN_RESULTSBANNER));
float resultBannerWidth = getWidth() * RESULTSBANNER_WIDTH_RATIO;
......
......@@ -12,7 +12,7 @@ import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
/**
* Created by Václav Tarantík on 9.4.15.
*/
public abstract class AbstractButtonDialog extends TablexiaDialog {
public abstract class AbstractButtonDialog extends TextDialog {
private static final Color DEFAULT_BUTTON_TEXT_COLOR = Color.BLACK;
private static final String DEFAULT_BUTTON_TEXT_FONT = ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR;
......@@ -25,7 +25,7 @@ public abstract class AbstractButtonDialog extends TablexiaDialog {
private static final String BTN_DRAWABLE_UNPRESSED_ENDING = "_unpressed";
public AbstractButtonDialog(float x, float y, float width, float height, BackGroundType backGroundType, DialogTextContent dialogTextContent) {
super(x, y, width, height, backGroundType, dialogTextContent);
super(x, y, width, height, backGroundType,dialogTextContent);
}
public void createButton(ButtonType buttonType, String buttonText, ClickListener clickListener){
......
......@@ -9,29 +9,34 @@ import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
/**
* Created by Václav Tarantík on 19.3.15.
*/
public class ImageDialog extends TablexiaDialog {
public class ImageDialog extends TextDialog {
private Table imageTable;
private Texture[] textures;
public ImageDialog(float x, float y,float width, float height,BackGroundType backGroundType, DialogTextContent dialogTextContent,Texture... textures) {
super(x,y,width,height, backGroundType,dialogTextContent);
this.textures = textures;
prepareContent();
imageTable = new Table();
}
private void prepareContent(){
protected void prepareContent(){
super.prepareContent();
getContentTable().row();
prepareImages();
}
private void prepareImages(){
Table imageGroup = new Table();
for(Texture texture:textures){
Image image = new Image(texture);
imageGroup.add(image).padBottom(20f);
imageGroup.row();
addImage(texture);
}
getContentTable().add(imageGroup).width(getWidth() / 2);
getContentTable().add(imageTable).width(getWidth() / 2).height(getHeight()/2);
}
protected void addImage(Texture texture){
Image image = new Image(texture);
imageTable.add(image).padBottom(20f);
imageTable.row();
}
}
......@@ -62,7 +62,7 @@ public class TablexiaDialog extends Dialog {
buttonAtlas = new TextureAtlas(Gdx.files.internal("atlases/buttons_atlas.pack"));
}
public TablexiaDialog(float x, float y,float width,float height, BackGroundType backGroundType,DialogTextContent dialogTextContent) {
public TablexiaDialog(float x, float y,float width,float height, BackGroundType backGroundType) {
super("", new WindowStyle(ApplicationFontManager.getInstance().getDefaultApplicationRegularFont(),
Color.BLACK,
new NinePatchDrawable(backgroundAtlas.createPatch(backGroundType.dialogBackgroundTextureName))));
......@@ -74,26 +74,16 @@ public class TablexiaDialog extends Dialog {
setBounds(x, y, width, height);
getBackground().setMinWidth(width);
getBackground().setMinHeight(height);
this.dialogTextContent = dialogTextContent;
prepareDialogContent();
}
@Override
public Dialog show(Stage stage) {
prepareContent();
show(stage, sequence(Actions.alpha(0), Actions.fadeIn(0.4f, Interpolation.fade)));
return this;
}
protected void prepareDialogContent(){
Label.LabelStyle labelStyle = new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR),Color.BLACK);
if(dialogTextContent.getTitle() != null && !dialogTextContent.getTitle().equals("")){
Label titleLabel = new Label(dialogTextContent.getTitle(),labelStyle);
getContentTable().add(titleLabel).center() ;
getContentTable().row();
}
Label label = new Label(dialogTextContent.getContent(),labelStyle);
label.setWrap(true);
getContentTable().add(label).left().top().expand().fillX();
protected void prepareContent(){
//no content here
}
}
\ No newline at end of file
package cz.nic.tablexia.util.ui.dialog;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
/**
* Created by Václav Tarantík on 24.4.15.
*/
public class TextDialog extends TablexiaDialog {
private static final float TITLE_FONT_SCALE = 0.7f;
private static final float CONTENT_FONT_SCALE = 0.5f;
private DialogTextContent dialogTextContent;
public TextDialog(float x, float y, float width, float height, BackGroundType backGroundType, DialogTextContent dialogTextContent) {
super(x, y, width, height, backGroundType);
this.dialogTextContent = dialogTextContent;
}
@Override
protected void prepareContent() {
Label.LabelStyle titleLabelStyle = new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD), Color.BLACK);
titleLabelStyle.font.setScale(TITLE_FONT_SCALE);
if(dialogTextContent.getTitle() != null && !dialogTextContent.getTitle().equals("")){
Label titleLabel = new Label(dialogTextContent.getTitle(),titleLabelStyle);
getContentTable().add(titleLabel).center() ;
getContentTable().row();
}
Label.LabelStyle contentLabelStyle = new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR), Color.BLACK);
contentLabelStyle.font.setScale(CONTENT_FONT_SCALE);
Label label = new Label(dialogTextContent.getContent(),contentLabelStyle);
label.setWrap(true);
getContentTable().add(label).left().top().expand().fillX();
}
}
......@@ -9,14 +9,29 @@ import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
* Created by Václav Tarantík on 26.3.15.
*/
public abstract class TwoButtonDialog extends AbstractButtonDialog {
private ButtonType leftButtonType;
private ButtonType rightButtonType;
private String leftButtonText;
private String rightButtonText;
public TwoButtonDialog(float x, float y, float width, float height, BackGroundType backGroundType,DialogTextContent dialogTextContent, ButtonType leftButtonType, ButtonType rightButtonType,String leftButtonText, String rightButtonText) {
super(x, y, width, height, backGroundType, dialogTextContent);
this.leftButtonType = leftButtonType;
this.rightButtonType = rightButtonType;
this.leftButtonText = leftButtonText;
this.rightButtonText = rightButtonText;
}
createButton(leftButtonType,leftButtonText,new ClickListener() {
@Override
protected void prepareContent() {
super.prepareContent();
createButton(leftButtonType, leftButtonText, new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
leftButtonAction();
};
}
;
});
createButton(rightButtonType,rightButtonText,new ClickListener() {
......
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