Skip to content
Snippets Groups Projects
Commit f3f30178 authored by Matyáš Latner's avatar Matyáš Latner
Browse files

Merge branch 'feature-halloffame' into 'devel'

Feature halloffame

Nová písma a drobné opravy

See merge request !118
parents 5a231a02 0c65c90f
No related branches found
No related tags found
No related merge requests found
package cz.nic.tablexia.game.trophy;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
......@@ -9,7 +10,6 @@ import com.badlogic.gdx.utils.Align;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.TablexiaApplication;
......@@ -30,9 +30,9 @@ public class TrophyReceivedDialog extends TablexiaDialog {
private static final int DIALOG_OFFSET = 20;
private static final int DIALOG_WIDTH = 200;
private static final int DIALOG_HEIGHT = 150;
private static final float TITLE_FONT_SCALE = 0.7f;
private static final float CONTENT_FONT_SCALE = 0.5f;
private static final int MAX_NUMBER_OF_TROPHIES_TO_DISPLAY = 4;
private static final BitmapFont DIALOG_BIGGER_FONT = ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_REGULAR_14);
private static final BitmapFont DIALOG_NORMAL_FONT = ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_REGULAR_12);
private ITrophyDefinition trophy;
private TextureRegion trophyTexture;
......@@ -58,15 +58,15 @@ public class TrophyReceivedDialog extends TablexiaDialog {
String desc = ApplicationTextManager.getInstance().getText(trophy.getTrophyDescription());
String title = ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.VICTORYSCREEN_NEW_TROPHY);
this.addLabel(title, new Label.LabelStyle(ApplicationFontManager.getInstance().getDefaultApplicationRegularFont(), Color.BLACK), Align.center, TITLE_FONT_SCALE);
this.addLabel(title, new Label.LabelStyle(DIALOG_BIGGER_FONT, Color.BLACK), Align.center);
this.getContentTable().row();
this.addImage(trophyTexture, 1);
this.getContentTable().row();
this.addLabel(name, new Label.LabelStyle(ApplicationFontManager.getInstance().getDefaultApplicationRegularFont(), Color.BLACK), Align.center, TITLE_FONT_SCALE);
this.addLabel(name, new Label.LabelStyle(DIALOG_BIGGER_FONT, Color.BLACK), Align.center);
this.getContentTable().row();
this.addLabel(desc, new Label.LabelStyle(ApplicationFontManager.getInstance().getDefaultApplicationRegularFont(), Color.GRAY), Align.center, CONTENT_FONT_SCALE);
this.addLabel(desc, new Label.LabelStyle(DIALOG_NORMAL_FONT, Color.GRAY), Align.center);
super.prepareContent();
}
......@@ -165,13 +165,15 @@ public class TrophyReceivedDialog extends TablexiaDialog {
final Placeholder other = ((Placeholder) otherObj);
return Objects.equals(getTotal(), other.getTotal())
&& Objects.equals(getActual(), other.getActual());
return (getTotal() == other.getTotal() && getActual() == other.getActual());
}
@Override
public int hashCode() {
return Objects.hash(getTotal(), getActual());
int code = 0;
code += getTotal() * 13;
code += getActual() * 53;
return code;
}
}
}
......@@ -217,10 +217,8 @@ public class HallOfFameScreen extends AbstractTablexiaScreen<Map<ITrophyDefiniti
});
// heap number of trophies text
BitmapFont bf = ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD);
bf.getData().setScale(1);
Group labelGroup = new Group();
labelGroup.addActor(new Label(String.valueOf(threeStarsCount), new Label.LabelStyle(bf, Color.BLACK)));
labelGroup.addActor(new Label(String.valueOf(threeStarsCount), new Label.LabelStyle(getFont(ApplicationFontManager.FontType.ROBOTO_BOLD_20), Color.BLACK)));
labelGroup.setPosition(heapX + 280, heapY + 135);
labelGroup.addAction(Actions.rotateBy(-15));
......
......@@ -5,7 +5,6 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.utils.Align;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.util.ui.dialog.ImageDialog;
import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
......@@ -17,8 +16,6 @@ public class TrophyDialog extends ImageDialog {
private static final float BANNER_SIZE_RATIO_TO_ORIGINAL_SIZE = 0.8f;
private static final float IMAGE_SIZE_RATIO_TO_ORIGINAL_SIZE = 0.5f;
private static final float TITLE_FONT_SCALE = 0.7f;
private static final float CONTENT_FONT_SCALE = 0.5f;
private TextureRegion bannerTexture;
private TextureRegion trophyTexture;
......@@ -39,8 +36,8 @@ public class TrophyDialog extends ImageDialog {
addImage(trophyTexture, IMAGE_SIZE_RATIO_TO_ORIGINAL_SIZE);
getContentTable().row();
getContentTable().setDebug(true);
addLabel(dialogTextContent.getTitle(), new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD), Color.BLACK), Align.center, TITLE_FONT_SCALE);
addLabel(dialogTextContent.getTitle(), new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_BOLD_14), Color.BLACK), Align.center);
getContentTable().row();
addLabel(dialogTextContent.getContent(), new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR), Color.BLACK), Align.center, CONTENT_FONT_SCALE).fillX();
addLabel(dialogTextContent.getContent(), new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_REGULAR_12), Color.BLACK), Align.center).fillX();
}
}
......@@ -22,7 +22,8 @@ import cz.nic.tablexia.util.ui.dialog.TablexiaDialog;
*/
public class TrophyThreeStarsGamesDialog extends TablexiaDialog {
private static final float TITLE_FONT_SCALE = 0.7f;
private final ApplicationFontManager.FontType LABELS_TEXT_FONT = ApplicationFontManager.FontType.ROBOTO_REGULAR_14;
private final ApplicationFontManager.FontType VALUES_TEXT_FONT = ApplicationFontManager.FontType.ROBOTO_BOLD_14;
public TrophyThreeStarsGamesDialog(float x, float y, float width, float height, BackGroundType backgroundTypeDrawable, String sumText, Map<GameDefinition, Integer> starResults) {
super(x, y, width, height, backgroundTypeDrawable);
......@@ -39,8 +40,8 @@ public class TrophyThreeStarsGamesDialog extends TablexiaDialog {
sum += numOfStars;
}
// add line for each game
addLabel(GameMenuDefinition.getGameMenuDefinitionForGameDefinition(gameDef).getTitle(), ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR), Align.left).expand().left().top();
addLabel(String.valueOf(numOfStars), ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD), Align.right).expand().right().top();
addLabel(GameMenuDefinition.getGameMenuDefinitionForGameDefinition(gameDef).getTitle(), ApplicationFontManager.getInstance().getFont(LABELS_TEXT_FONT), Align.left).expand().left().top();
addLabel(String.valueOf(numOfStars), ApplicationFontManager.getInstance().getFont(VALUES_TEXT_FONT), Align.right).expand().right().top();
getContentTable().row();
}
......@@ -49,8 +50,8 @@ public class TrophyThreeStarsGamesDialog extends TablexiaDialog {
getContentTable().row();
// add sum line
addLabel(sumText, ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD), Align.left).expand().left().top();
addLabel(String.valueOf(sum), ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD), Align.right).expand().right().top();
addLabel(sumText, ApplicationFontManager.getInstance().getFont(VALUES_TEXT_FONT), Align.left).expand().left().top();
addLabel(String.valueOf(sum), ApplicationFontManager.getInstance().getFont(VALUES_TEXT_FONT), Align.right).expand().right().top();
getContentTable().row();
}
......@@ -68,7 +69,6 @@ public class TrophyThreeStarsGamesDialog extends TablexiaDialog {
protected Cell<Label> addLabel(String text, BitmapFont font, int align) {
Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.BLACK);
labelStyle.font.getData().setScale(TITLE_FONT_SCALE);
Label label = new Label(text, labelStyle);
label.setWrap(true);
label.setAlignment(align);
......
......@@ -165,8 +165,10 @@ public class TablexiaDialog extends Dialog {
float imageMaxWidth = getWidth() - 20; //20 is approx the padding from both sides
float imageMeasureRatio = image.getHeight() / image.getWidth();
float imageNewWidth = image.getWidth() * sizeRatioToOriginalSize;
float imageNewHeight = imageNewWidth * imageMeasureRatio;
float imageNewHeight = image.getHeight() * sizeRatioToOriginalSize;
if (imageNewHeight > imageMaxHeight) {
imageNewHeight = imageMaxHeight;
imageNewWidth = (1 / imageMeasureRatio) * imageNewHeight;
......@@ -176,6 +178,11 @@ public class TablexiaDialog extends Dialog {
}
}
if (imageNewWidth > imageMaxWidth) {
imageNewWidth = imageMaxWidth;
imageNewHeight = imageMeasureRatio * imageNewWidth;
}
image.getDrawable().setMinHeight(imageNewHeight);
image.getDrawable().setMinWidth(imageNewWidth);
return getContentTable().add(image);
......
......@@ -15,9 +15,6 @@ import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
*/
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) {
......@@ -33,15 +30,14 @@ public class TextDialog extends TablexiaDialog {
protected void prepareContent() {
if (dialogTextContent != null) {
if (dialogTextContent.getTitle() != null && !dialogTextContent.getTitle().equals("")) {
addLabel(dialogTextContent.getTitle(), ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD));
addLabel(dialogTextContent.getTitle(), ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_BOLD_16));
getContentTable().row();
}
addLabel(dialogTextContent.getContent(), ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR)).center().expand().top().fillX();
addLabel(dialogTextContent.getContent(), ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_REGULAR_14)).center().expand().top().fillX();
}
}
protected Cell<Label> addLabel(String text, BitmapFont font) {
font.getData().setScale(TITLE_FONT_SCALE);
return super.addLabel(text, new Label.LabelStyle(font, Color.BLACK), getTextAlignment());
}
......
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