Skip to content
Snippets Groups Projects
Commit 0a4f1f3a authored by Luboš Horáček's avatar Luboš Horáček
Browse files

Merge branch 'feature-dialog' into devel

Conflicts:
	core/src/cz/nic/tablexia/TablexiaSettings.java
	core/src/cz/nic/tablexia/util/ui/dialog/TablexiaDialog.java
parents 163a406f 5460606d
Branches
Tags
No related merge requests found
......@@ -145,6 +145,8 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
TablexiaButton.ButtonType.GREEN,
ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.VICTORYSCREEN_BUTTON_CHANGEGAME),
ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.VICTORYSCREEN_BUTTON_REPLAY));
//dialog does not hide on click outside the BG area
setHideOnOutsideClick(false);
}
@Override
......
......@@ -2,15 +2,24 @@ package cz.nic.tablexia.util.ui.dialog;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
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.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.sequence;
......@@ -23,8 +32,7 @@ public class TablexiaDialog extends Dialog {
public static TextureAtlas backgroundAtlas;
public static TextureAtlas buttonAtlas;
protected float width;
protected float height;
private boolean hideOnOutsideClick = true;
public enum BackGroundType {
BUBBLE_CLASSIC("bubble_classic"),
......@@ -48,9 +56,9 @@ public class TablexiaDialog extends Dialog {
}
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))));
super("", new DialogStyle(ApplicationFontManager.getInstance().getDefaultApplicationRegularFont(),
Color.BLACK,
new NinePatchDrawable(backgroundAtlas.createPatch(backGroundType.dialogBackgroundTextureName)), createDrawable(new Color(0, 0, 0, 0.5f))));
this.width= width;
this.height = height;
......@@ -62,6 +70,23 @@ public class TablexiaDialog extends Dialog {
setBounds(x, y, width, height);
getBackground().setMinWidth(width);
getBackground().setMinHeight(height);
final float dialogX = x;
final float dialogY = y;
final float dialogWidth = width;
final float dialogHeight = height;
addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
if((x<0||x>(dialogWidth))||(y<0||y>dialogHeight)){
//user clicked outside the dialog window
if(hideOnOutsideClick){
hide();
}
}
}
});
}
@Override
......@@ -75,13 +100,23 @@ public class TablexiaDialog extends Dialog {
//no content here
}
@Override
public float getPrefHeight() {
return height;
public static Drawable createDrawable (Color c) {
Pixmap p = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
p.setColor(c);
p.drawPixel(0, 0);
return new SpriteDrawable(new Sprite(new Texture(p)));
}
@Override
public float getPrefWidth() {
return width;
public static class DialogStyle extends WindowStyle{
public DialogStyle (BitmapFont titleFont, Color titleFontColor, Drawable background,Drawable stageBackground){
super(titleFont,titleFontColor,background);
super.stageBackground = stageBackground;
}
}
//hide dialog on click outside the background area? true by default
public void setHideOnOutsideClick(boolean hideOnOutsideClick){
this.hideOnOutsideClick = hideOnOutsideClick;
}
}
\ No newline at end of file
}
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