Commit a23da190 authored by v.tarantik's avatar v.tarantik

Watch group errors fix, continue button added, fade animations for backgrounds

parent 57169e5f
game_nocnisledovani_btncontinue_text=Hotovo
victory_text_window_mistakes=Chybně označená okna:
victory_text_time_mistakes=Chybně nastavený čas:
game_nocnisledovani_loadingtext=Dávej pozor, která okna se po setmění rozsvítí a v kolik hodin.\nPo rozednění nastav na hodinách čas a označ okna, která byla rozsvícená.
game_nocnisledovani_victory_text_0=To vypadá, že tady někdo usnul na hlídce.
game_nocnisledovani_victory_text_1=U soudu by tyhle důkazy neuspěly. To ale neznamená, že se nemůže zadařit příště!
game_nocnisledovani_victory_text_2=Tohle nebylo vůbec špatné! Stačilo málo a důkazy by byly neprůstřelné.
game_nocnisledovani_victory_text_3=Před tebou se musí obávat i Měsíc páchat nepravosti.
<string name="game_nocnisledovani_btncontinue_text">Hotovo</string>
<string name="victory_text_window_mistakes">Chybně označená okna: </string>
<string name="victory_text_time_mistakes">Chybně nastavený čas: </string>
<string name="game_nocnisledovani_loadingtext">Dávej pozor, která okna se po setmění rozsvítí a v kolik hodin.\nPo rozednění nastav na hodinách čas a označ okna, která byla rozsvícená.</string>
<string name="game_nocnisledovani_victory_text_0">To vypadá, že tady někdo usnul na hlídce.</string>
<string name="game_nocnisledovani_victory_text_1">U soudu by tyhle důkazy neuspěly. To ale neznamená, že se nemůže zadařit příště!</string>
<string name="game_nocnisledovani_victory_text_2">Tohle nebylo vůbec špatné! Stačilo málo a důkazy by byly neprůstřelné.</string>
<string name="game_nocnisledovani_victory_text_3">Před tebou se musí obávat i Měsíc páchat nepravosti.</string>
......@@ -15,6 +15,7 @@ import cz.nic.tablexia.game.games.night_watch.NightWatchScreen;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.screen.gamemenu.GameMenuScreen;
import cz.nic.tablexia.screen.halloffame.HallOfFameScreen;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.Utility;
......
......@@ -22,6 +22,7 @@ import cz.nic.tablexia.graphics.ColorTexture;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.ui.TablexiaButton;
import cz.nic.tablexia.util.ui.dialog.TwoButtonDialog;
import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
......@@ -140,8 +141,8 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
DIALOG_HEIGHT,
BackGroundType.DIALOG_SQUARE_BORDERLINES,
new DialogTextContent("TEXT"),
ButtonType.BLUE,
ButtonType.GREEN,
TablexiaButton.ButtonType.BLUE,
TablexiaButton.ButtonType.GREEN,
ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.VICTORYSCREEN_BUTTON_CHANGEGAME),
ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.VICTORYSCREEN_BUTTON_REPLAY));
}
......
package cz.nic.tablexia.game.games.night_watch;
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.NinePatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Stack;
import com.badlogic.gdx.scenes.scene2d.utils.DragListener;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import net.dermetfan.utils.Pair;
import java.awt.Point;
import java.util.List;
import cz.nic.tablexia.TablexiaSettings;
......@@ -18,9 +25,10 @@ import cz.nic.tablexia.game.games.night_watch.assets.NightWatchAssets;
import cz.nic.tablexia.game.games.night_watch.helper.TextureHelper;
import cz.nic.tablexia.game.games.night_watch.subscene.Watch;
import cz.nic.tablexia.game.games.robbery.rules.GameRule;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.screen.gamemenu.GameMenuAssets;
import cz.nic.tablexia.screen.halloffame.helper.TrophyHelper;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.ui.TablexiaButton;
import cz.nic.tablexia.util.ui.dialog.TablexiaDialog;
/**
* Created by Václav Tarantík on 6.3.15.
......@@ -28,27 +36,50 @@ import cz.nic.tablexia.util.Log;
public class NightWatchScreen extends AbstractTablexiaGame<GameRule> {
private static final int SCREEN_WIDTH = TablexiaSettings.getWorldWidth();
private static final int SCREEN_MIN_HEIGHT = TablexiaSettings.getMinWorldHeight();
private static final int INITIAL_BG_TEXTURE_INDEX = 0;
private int difficulty = 2;
private Stack contentStack;
private int clickCounter = 0;
private Image backgroundImage;
private Group contentStack;
private Stack backgroundStack;
public static TextureAtlas buttonAtlas;
@Override
protected void gameLoaded() {
contentStack = new Stack();
contentStack = new Group();
contentStack.setSize(SCREEN_WIDTH,SCREEN_MIN_HEIGHT);
getStage().addActor(contentStack);
buttonAtlas = new TextureAtlas(Gdx.files.internal("atlases/buttons_atlas.pack"));
  • K čemu je tady načítán buttonAtlas, když ho nikde nevidím použitý?

Please register or sign in to reply
// difficulty = getGameDifficulty().ordinal();
prepareBackground();
prepareWindows();
prepareWatch();
prepareButton();
}
private void prepareBackground(){
Texture backgroundTexture = getTexture(TextureHelper.getBackgroundTexture(difficulty));
Image bgImage = new Image(backgroundTexture);
bgImage.setSize(SCREEN_WIDTH,SCREEN_MIN_HEIGHT);
contentStack.addActor(bgImage);
backgroundStack = new Stack();
backgroundStack.setSize(SCREEN_WIDTH,SCREEN_MIN_HEIGHT);
Texture backgroundTexture = getTexture(TextureHelper.getBackgroundTexturesNames(difficulty).get(INITIAL_BG_TEXTURE_INDEX));
backgroundImage = new Image(backgroundTexture);
backgroundStack.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
if(clickCounter%2==0){
animateDaytimeTransition(true);
}else{
animateDaytimeTransition(false);
}
clickCounter++;
}
});
backgroundStack.addActor(backgroundImage);
contentStack.addActor(backgroundStack);
}
private Color getTouchedColor(float x, float y) {
......@@ -64,18 +95,19 @@ public class NightWatchScreen extends AbstractTablexiaGame<GameRule> {
}
private void prepareWatch(){
Group watch = new Watch(0.5f,getTexture(NightWatchAssets.WATCH),getTexture(NightWatchAssets.HOUR_HAND),getTexture(NightWatchAssets.MINUTE_HAND));
contentStack.add(watch);
Group watch = new Watch(300,0.5f,getTexture(NightWatchAssets.WATCH),getTexture(NightWatchAssets.HOUR_HAND),getTexture(NightWatchAssets.MINUTE_HAND));
watch.setPosition(SCREEN_WIDTH/2-watch.getWidth()/2,0);
watch.setDebug(true);
contentStack.addActor(watch);
}
private void prepareWindows(){
Group imageGroup = new Group();
List<Point> windowPositions = TextureHelper.getWindowsPositions(difficulty);
final List<String> windowsNamesList = TextureHelper.getWindowsNamesList(difficulty);
List<Pair<Integer,Integer>> windowPositions = TextureHelper.getWindowsPositions(difficulty);
final List<String> windowsNamesList = TextureHelper.getWindowsNames(difficulty);
for(int i = 0;i<windowsNamesList.size();i++){
final int currentI = i;
final Image windowImage = new Image(getTexture(windowsNamesList.get(i)));
windowImage.setPosition(windowPositions.get(i).x,windowPositions.get(i).y);
windowImage.setPosition(windowPositions.get(i).getKey(),windowPositions.get(i).getValue());
// windowImage.addListener(new DragListener(){
//
// @Override
......@@ -90,20 +122,48 @@ public class NightWatchScreen extends AbstractTablexiaGame<GameRule> {
// });
imageGroup.addActor(windowImage);
}
contentStack.add(imageGroup);
contentStack.addActor( imageGroup);
}
private void prepareButton(){
Group buttonGroup = new Group();
String buttonText = getText("game_nocnisledovani_btncontinue_text");
TablexiaButton button = new TablexiaButton(buttonText, TablexiaButton.ButtonType.GREEN);
button.setPosition(800,20);
button.setSize(150,80);
contentStack.addActor(button);
}
private void animateDaytimeTransition(boolean dayToNight){
List<String> dayTimeAnimationTextures = TextureHelper.getDaytimeTransitionTextureNames(difficulty,dayToNight);
for(int i = 1;i<dayTimeAnimationTextures.size();i++){
Image replacingImage = new Image(getTexture(dayTimeAnimationTextures.get(i)));
replacingImage.setSize(SCREEN_WIDTH, SCREEN_MIN_HEIGHT);
replacingImage.getColor().a = 0f;
backgroundStack.addActor(replacingImage);
replacingImage.addAction(Actions.sequence(Actions.delay(i*0.2f),Actions.fadeIn(0.2f)));
}
}
@Override
protected void prepareGameTextureAssetNames(List<String> textureFileNames) {
//background
textureFileNames.add(TextureHelper.getBackgroundTexture(difficulty));
textureFileNames.addAll(TextureHelper.getBackgroundTexturesNames(difficulty));
//windows tetures
textureFileNames.addAll(TextureHelper.getWindowsNamesList(difficulty));
textureFileNames.addAll(TextureHelper.getWindowsNames(difficulty));
//watch
textureFileNames.add(NightWatchAssets.WATCH);
textureFileNames.add(NightWatchAssets.HOUR_HAND);
textureFileNames.add(NightWatchAssets.MINUTE_HAND);
}
@Override
protected String prepareScreenTextResourcesAssetName() {
return NightWatchAssets.TEXT_PATH;
}
}
......@@ -8,7 +8,7 @@ public final class NightWatchAssets {
private static final String NIGHT_WATCH_PATH = "game/night_watch/";
public static final String TEXTS_PATH = "text/game/night_watch/night_watch";
public static final String TEXT_PATH = "text/game/night_watch/night_watch";
public static final String BACKGROUND_FOLDER = NIGHT_WATCH_PATH+ "background/";
public static final String WINDOWS_FOLDER =NIGHT_WATCH_PATH+"windows/";
......
package cz.nic.tablexia.game.games.night_watch.subscene;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.utils.DragListener;
import java.awt.Point;
import net.dermetfan.utils.Pair;
import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.game.games.night_watch.helper.TextureHelper;
import cz.nic.tablexia.util.Log;
......@@ -18,12 +17,17 @@ import cz.nic.tablexia.util.Log;
* Created by Václav Tarantík on 4.5.15.
*/
public class Watch extends Group {
private static final int SCREEN_WIDTH = TablexiaSettings.getWorldWidth();
private static final int SCREEN_MIN_HEIGHT = TablexiaSettings.getMinWorldHeight();
// private static final int SCREEN_WIDTH = TablexiaSettings.getWorldWidth();
// private static final int SCREEN_MIN_HEIGHT = TablexiaSettings.getMinWorldHeight();
private static final int HOUR_HAND_Y = 88;
private static final int MINUTE_HAND_Y = 85;
private static final int HOUR_HAND_Y_OFFSET = 25;
private static final int MINUTE_HAND_Y_OFFSET = 29;
private float texturesScale;
private float width;
private float height;
private Image hourHandImage;
......@@ -31,15 +35,23 @@ public class Watch extends Group {
private Texture hourHandTexture;
private Texture minuteHandTexture;
public Watch(float texturesScale, Texture backgroundTexture, Texture hourHandTexture, Texture minuteHandTexture) {
//setting only width, height is calculated according to original texture size ratio
public Watch(float width, float texturesScale, Texture backgroundTexture, Texture hourHandTexture, Texture minuteHandTexture) {
this.backgroundTexture = backgroundTexture;
this.hourHandTexture = hourHandTexture;
this.minuteHandTexture = minuteHandTexture;
this.texturesScale = texturesScale;
this.width = width;
float backgroundTextureRatio = (float)backgroundTexture.getHeight()/(float)backgroundTexture.getWidth();
this.height = width*backgroundTextureRatio;
setSize(width, height);
prepareBackground();
prepareHands();
}
private void prepareBackground() {
......@@ -48,15 +60,29 @@ public class Watch extends Group {
bgImage.addListener(new InputListener(){
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
float newRotation = 360-(TextureHelper.getAngleFromLinearApproximationOfPoints(new Point((int) event.getStageX(), (int) event.getStageY()), new Point((int) hourHandImage.getX(), (int) (hourHandImage.getY())))%360);
hourHandImage.setRotation(newRotation);
//TODO
// Vector2 touchPointCoords = new Vector2(x,y);
// hourHandImage.localToParentCoordinates(touchPointCoords);
// Pair touchPoint = new Pair<Integer,Integer>((int)touchPointCoords.x, (int) touchPointCoords.y);
// Pair rotationCenter = new Pair<Integer,Integer>((int) (hourHandImage.getX()+hourHandImage.getOriginX()), (int) (hourHandImage.getY()+hourHandImage.getOriginY()));
//
// Log.info(getClass(),"Dragging on " + touchPoint + " center " + rotationCenter );
// float newRotation = 360-(TextureHelper.getAngleFromLinearApproximationOfPoints(touchPoint, rotationCenter)%360);
// hourHandImage.setRotation(newRotation);
return true;
}
@Override
public void touchDragged(InputEvent event, float x, float y, int pointer) {
float newRotation = 360-(TextureHelper.getAngleFromLinearApproximationOfPoints(new Point((int) event.getStageX(), (int) event.getStageY()), new Point((int) hourHandImage.getX(), (int) (hourHandImage.getY())))%360);
hourHandImage.setRotation(newRotation);
//TODO
// Vector2 touchPointCoords = new Vector2(x,y);
// hourHandImage.localToParentCoordinates(touchPointCoords);
// Pair touchPoint = new Pair<Integer,Integer>((int)touchPointCoords.x, (int) touchPointCoords.y);
// Pair rotationCenter = new Pair<Integer,Integer>((int) (hourHandImage.getX()+hourHandImage.getOriginX()), (int) (hourHandImage.getY()+hourHandImage.getOriginY()));
//
// Log.info(getClass(),"Dragging on " + touchPoint + " center " + rotationCenter );
// float newRotation = 360-(TextureHelper.getAngleFromLinearApproximationOfPoints(touchPoint, rotationCenter)%360);
// hourHandImage.setRotation(newRotation);
}
@Override
......@@ -64,13 +90,7 @@ public class Watch extends Group {
//TODO jump to nearest value
}
});
float scaledWatchWidth = backgroundTexture.getWidth()*texturesScale;
float scaledWatchHeight = backgroundTexture.getHeight()*texturesScale;
bgImage.setSize(scaledWatchWidth, scaledWatchHeight);
bgImage.setX(SCREEN_WIDTH/2-scaledWatchWidth/2);
Log.info(getClass(),"W: "+getWidth()+"H: "+getHeight());
bgImage.setSize(getWidth(),getHeight());
addActor(bgImage);
}
......@@ -81,9 +101,13 @@ public class Watch extends Group {
hourHandImage.addListener(new DragListener(){
@Override
public void drag(InputEvent event, float x, float y, int pointer) {
Log.info(getClass(),"DRAGGING");
Vector2 touchPointCoords = new Vector2(x,y);
hourHandImage.localToParentCoordinates(touchPointCoords);
Pair touchPoint = new Pair<Integer,Integer>((int)touchPointCoords.x, (int) touchPointCoords.y);
Pair rotationCenter = new Pair<Integer,Integer>((int) (hourHandImage.getX()+hourHandImage.getOriginX()), (int) (hourHandImage.getY()+hourHandImage.getOriginY()));
float newRotation = 360-(TextureHelper.getAngleFromLinearApproximationOfPoints(new Point((int) event.getStageX(), (int) event.getStageY()), new Point((int) hourHandImage.getX(), (int) (hourHandImage.getY())))%360);
Log.info(getClass(),"Dragging on " + touchPoint + " center " + rotationCenter );
float newRotation = 360-(TextureHelper.getAngleFromLinearApproximationOfPoints(touchPoint, rotationCenter)%360);
hourHandImage.setRotation(newRotation);
}
......@@ -93,18 +117,19 @@ public class Watch extends Group {
}
});
float scaledHourHandWidth = hourHandTexture.getWidth()*texturesScale;
float scaledHourHandHeight = hourHandTexture.getHeight()*texturesScale;
float scaledMinuteHandWidth = minuteHandTexture.getWidth()*texturesScale;
float scaledMinuteHandHeight = minuteHandTexture.getHeight()*texturesScale;
float minuteHandHeight = height/2.5f;
float minuteHandTextureRatio = (float)minuteHandTexture.getWidth()/(float)minuteHandTexture.getHeight();
float minuteHandWidth = minuteHandHeight*minuteHandTextureRatio;
hourHandImage.setSize(scaledHourHandWidth,scaledHourHandHeight);
minuteHandImage.setSize(scaledMinuteHandWidth,scaledMinuteHandHeight);
float hourHandHeight = height/4;
float hourHandTextureRatio = (float)hourHandTexture.getWidth()/(float)hourHandTexture.getHeight();
float hourHandWidth = hourHandHeight*hourHandTextureRatio;
hourHandImage.setPosition(SCREEN_WIDTH / 2 - scaledHourHandWidth / 2, HOUR_HAND_Y);
minuteHandImage.setSize(minuteHandWidth,minuteHandHeight);
minuteHandImage.setPosition(width/2-minuteHandImage.getWidth()/2,height/2-MINUTE_HAND_Y_OFFSET);
minuteHandImage.setPosition(SCREEN_WIDTH / 2 - scaledHourHandWidth / 2, MINUTE_HAND_Y);
hourHandImage.setSize(hourHandWidth,hourHandHeight);
hourHandImage.setPosition(width/2-hourHandImage.getWidth()/2,height/2- HOUR_HAND_Y_OFFSET);
hourHandImage.setOrigin(hourHandImage.getWidth() / 2,4);
......
package cz.nic.tablexia.util.ui;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
/**
* Created by Václav Tarantík on 11.5.15.
*/
public class TablexiaButton extends TextButton {
private static final String BTN_DISABLED_ATLAS_NAME = "tablexiabutton_disabled";
private static final String BTN_DRAWABLE_PRESSED_ENDING = "_pressed";
private static final String BTN_DRAWABLE_UNPRESSED_ENDING = "_unpressed";
private static final Color DEFAULT_BUTTON_TEXT_COLOR = Color.BLACK;
private static final String DEFAULT_BUTTON_TEXT_FONT = ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR;
public static TextureAtlas backgroundAtlas;
public static TextureAtlas buttonAtlas;
static {
  • Tady máme znovu inicializované atlasy, které už jsou jako public static v Tablexia Dialogu .. Používat jen z jednoho místa, nejlépe přemístit buttonAtlas sem a backgroundAtlas nechat v Dialogu (je tady zbytečný) To je zase copy-paste 👎

Please register or sign in to reply
backgroundAtlas = new TextureAtlas(Gdx.files.internal("atlases/dialog_background.atlas"));
buttonAtlas = new TextureAtlas(Gdx.files.internal("atlases/buttons_atlas.pack"));
}
public enum ButtonType{
BLUE("tablexiabutton_blank_blue"),
GREEN("tablexiabutton_blank_green"),
RED("tablexiabutton_blank_red");
private String buttonResourceName;
ButtonType(String buttonResourceName){
this.buttonResourceName = buttonResourceName;
}
public String getButtonResourceName(){
return buttonResourceName;
}
}
public TablexiaButton(String buttonText,ButtonType buttonType) {
super(buttonText, new TextButton.TextButtonStyle(null, null, null, ApplicationFontManager.getInstance().getFont(DEFAULT_BUTTON_TEXT_FONT)));
NinePatch up = buttonAtlas.createPatch(buttonType.getButtonResourceName()+BTN_DRAWABLE_UNPRESSED_ENDING);
NinePatchDrawable npdUp = new NinePatchDrawable(up);
NinePatch down = buttonAtlas.createPatch(buttonType.getButtonResourceName()+BTN_DRAWABLE_PRESSED_ENDING);
NinePatchDrawable npdDown = new NinePatchDrawable(down);
NinePatch dis = buttonAtlas.createPatch(BTN_DISABLED_ATLAS_NAME);
NinePatchDrawable npdDis = new NinePatchDrawable(dis);
TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle(npdUp, npdDown, npdDis, ApplicationFontManager.getInstance().getFont(DEFAULT_BUTTON_TEXT_FONT));
textButtonStyle.fontColor = DEFAULT_BUTTON_TEXT_COLOR;
setStyle(textButtonStyle);
}
}
......@@ -7,42 +7,24 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.util.ui.TablexiaButton;
import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
/**
* Created by Václav Tarantík on 9.4.15.
*/
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;
private static final String BTN_DISABLED_ATLAS_NAME = "tablexiabutton_disabled";
private static final float BUTTON_WIDTH_RATIO_TO_DIALOG_WIDTH = 0.27f;
private static final float BUTTON_HEIGHT_RATIO = 0.5f;
private static final String BTN_DRAWABLE_PRESSED_ENDING = "_pressed";
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);
}
public void createButton(ButtonType buttonType, String buttonText, ClickListener clickListener){
public void createButton(String buttonText,TablexiaButton.ButtonType buttonType, ClickListener clickListener){
if(buttonType!=null){
NinePatch up = buttonAtlas.createPatch(buttonType.getButtonResourceName()+BTN_DRAWABLE_UNPRESSED_ENDING);
NinePatchDrawable npdUp = new NinePatchDrawable(up);
NinePatch down = buttonAtlas.createPatch(buttonType.getButtonResourceName()+BTN_DRAWABLE_PRESSED_ENDING);
NinePatchDrawable npdDown = new NinePatchDrawable(down);
NinePatch dis = buttonAtlas.createPatch(BTN_DISABLED_ATLAS_NAME);
NinePatchDrawable npdDis = new NinePatchDrawable(dis);
TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle(npdUp, npdDown, npdDis, ApplicationFontManager.getInstance().getFont(DEFAULT_BUTTON_TEXT_FONT));
textButtonStyle.fontColor = DEFAULT_BUTTON_TEXT_COLOR;
TextButton textButton = new TextButton(buttonText, textButtonStyle);
TablexiaButton textButton = new TablexiaButton(buttonText,buttonType);
textButton.addListener(clickListener);
......
......@@ -3,6 +3,7 @@ package cz.nic.tablexia.util.ui.dialog;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import cz.nic.tablexia.util.ui.TablexiaButton;
import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
/**
......@@ -10,10 +11,10 @@ import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
*/
public abstract class SingleButtonDialog extends AbstractButtonDialog {
public SingleButtonDialog(float x, float y, float width, float height, BackGroundType backGroundType, DialogTextContent dialogTextContent, ButtonType buttonType,String buttonText) {
public SingleButtonDialog(float x, float y, float width, float height, BackGroundType backGroundType, DialogTextContent dialogTextContent, TablexiaButton.ButtonType buttonType,String buttonText) {
super(x, y, width, height, backGroundType, dialogTextContent);
createButton(buttonType,buttonText, new ClickListener() {
createButton(buttonText,buttonType, new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
buttonAction();
......
......@@ -41,22 +41,6 @@ public class TablexiaDialog extends Dialog {
}
}
public enum ButtonType{
BLUE("tablexiabutton_blank_blue"),
GREEN("tablexiabutton_blank_green"),
RED("tablexiabutton_blank_red");
private String buttonResourceName;
ButtonType(String buttonResourceName){
this.buttonResourceName = buttonResourceName;
}
public String getButtonResourceName(){
return buttonResourceName;
}
}
static {
backgroundAtlas = new TextureAtlas(Gdx.files.internal("atlases/dialog_background.atlas"));
buttonAtlas = new TextureAtlas(Gdx.files.internal("atlases/buttons_atlas.pack"));
......
......@@ -3,18 +3,19 @@ package cz.nic.tablexia.util.ui.dialog;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import cz.nic.tablexia.util.ui.TablexiaButton;
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 TablexiaButton.ButtonType leftButtonType;
private TablexiaButton.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) {
public TwoButtonDialog(float x, float y, float width, float height, BackGroundType backGroundType,DialogTextContent dialogTextContent, TablexiaButton.ButtonType leftButtonType, TablexiaButton.ButtonType rightButtonType,String leftButtonText, String rightButtonText) {
super(x, y, width, height, backGroundType, dialogTextContent);
this.leftButtonType = leftButtonType;
this.rightButtonType = rightButtonType;
......@@ -25,7 +26,7 @@ public abstract class TwoButtonDialog extends AbstractButtonDialog {
@Override
protected void prepareContent() {
super.prepareContent();
createButton(leftButtonType, leftButtonText, new ClickListener() {
createButton(leftButtonText,leftButtonType, new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
leftButtonAction();
......@@ -34,7 +35,7 @@ public abstract class TwoButtonDialog extends AbstractButtonDialog {
;
});
createButton(rightButtonType,rightButtonText,new ClickListener() {
createButton(rightButtonText,rightButtonType,new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
rightButtonAction();
......
Markdown is supported
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