Commit 1cee9607 authored by Matyáš Latner's avatar Matyáš Latner

#58 Submenu items container

parent c08b0528
......@@ -30,8 +30,14 @@ victoryscreen_button_changegame=Jinou hru
victoryscreen_text_tutorial=Gratuluji! A teď to zkus sám…
game_robbery_title=Lupiči
game_robbery_description=Procvičování pracovní paměti
game_kidnapping_title=Únos
game_kidnapping_description=Procvičování sluchové paměti
game_pursuit_title=Pronásledování
game_pursuit_description=Procvičování prostorové orientace
game_night_watch_title=Hlídka
game_night_watch_description=Procvičování zrakové paměti
game_shooting_range_title=Střelnice
game_shooting_range_description=Procvičování pozornosti
game_in_the_darkness_title=Potmě
game_in_the_darkness_description=Procvičování seriality
......@@ -30,8 +30,14 @@ victoryscreen_button_changegame=Anderes Spiel
victoryscreen_text_tutorial=Gratulation! Und nun versuch es selbst…
game_robbery_title=Einbrecher
game_robbery_description=Training des Arbeitsgedächtnisses
game_kidnapping_title=Entführung
game_kidnapping_description=Training des Hörgedächtnisses
game_pursuit_title=Verfolgung
game_pursuit_description=Training der räumlichen Orientierung
game_night_watch_title=Wache
game_night_watch_description=Training des Sehgedächtnisses
game_shooting_range_title=Schießstand
game_shooting_range_description=Aufmerksamkeitstraining
game_in_the_darkness_title=Im Dunkeln
game_in_the_darkness_description=Training der Serialität
......@@ -30,8 +30,14 @@ victoryscreen_button_changegame=Inú hru
victoryscreen_text_tutorial=Gratulujem! A teraz to skús sám…
game_robbery_title=Lupiči
game_robbery_description=Precvičovanie pracovnej pamäti
game_kidnapping_title=Únos
game_kidnapping_description=Precvičovanie sluchovej pamäti
game_pursuit_title=Prenasledovanie
game_pursuit_description=Precvičovanie priestorovej orientácie
game_night_watch_title=Hliadka
game_night_watch_description=Precvičovanie zrakovej pamäti
game_shooting_range_title=Strelnica
game_shooting_range_description=Precvičovanie pozornosti
game_in_the_darkness_title=Potme
game_in_the_darkness_description=Precvičovanie seriality
......@@ -19,17 +19,17 @@ import cz.nic.tablexia.model.game.Game;
public enum GameDefinition implements ApplicationEvent, IMenuItem {
ROBBERY(1, "game_robbery_title", RobberyGame.class, false, new RobberyGame.GameResultResolver()),
PURSUIT(2, "game_pursuit_title", PursuitGame.class, false, new PursuitGame.GameResultResolver()),
KIDNAPPING(3, "game_kidnapping_title", KidnappingGame.class, false, new GameResultResolver() {
ROBBERY(1, "game_robbery_title", "game_robbery_description", RobberyGame.class, false, new RobberyGame.GameResultResolver()),
PURSUIT(2, "game_pursuit_title", "game_pursuit_description", PursuitGame.class, false, new PursuitGame.GameResultResolver()),
KIDNAPPING(3, "game_kidnapping_title", "game_kidnapping_description", KidnappingGame.class, false, new GameResultResolver() {
@Override
public AbstractTablexiaGame.GameResult getGameResult(Game game) {
return AbstractTablexiaGame.GameResult.NO_STAR;
}
}),
NIGHT_WATCH(4, "game_night_watch_title", NightWatchGame.class, false,new NightWatchGame.GameResultResolver()),
SHOOTING_RANGE(5, "game_shooting_range_title", ShootingRangeGame.class, false, new ShootingRangeResultResolver()),
IN_THE_DARKNESS(6, "game_in_the_darkness_title", InTheDarknessGame.class, true, new InTheDarknessGame.GameResultResolver());
NIGHT_WATCH(4, "game_night_watch_title", "game_night_watch_description", NightWatchGame.class, false,new NightWatchGame.GameResultResolver()),
SHOOTING_RANGE(5, "game_shooting_range_title", "game_shooting_range_description", ShootingRangeGame.class, false, new ShootingRangeResultResolver()),
IN_THE_DARKNESS(6, "game_in_the_darkness_title", "game_in_the_darkness_description", InTheDarknessGame.class, true, new InTheDarknessGame.GameResultResolver());
public interface GameResultResolver {
AbstractTablexiaGame.GameResult getGameResult(Game game);
......@@ -38,6 +38,7 @@ public enum GameDefinition implements ApplicationEvent, IMenuItem {
private int gameNumber;
private String menuTextKey;
private String descriptionResource;
private Class<? extends AbstractTablexiaGame<?>> screenClass;
private boolean hasTutorial;
private GameResultResolver gameResultResolver;
......@@ -46,9 +47,10 @@ public enum GameDefinition implements ApplicationEvent, IMenuItem {
return new GameDefinition[]{ROBBERY, PURSUIT, KIDNAPPING, NIGHT_WATCH, SHOOTING_RANGE, IN_THE_DARKNESS};
}
GameDefinition(int gameNumber, String nameResource, Class<? extends AbstractTablexiaGame<?>> screenClass, boolean hasTutorial, GameResultResolver gameResultResolver) {
GameDefinition(int gameNumber, String nameResource, String descriptionResource, Class<? extends AbstractTablexiaGame<?>> screenClass, boolean hasTutorial, GameResultResolver gameResultResolver) {
this.gameNumber = gameNumber;
this.menuTextKey = nameResource;
this.descriptionResource = descriptionResource;
this.screenClass = screenClass;
this.hasTutorial = hasTutorial;
this.gameResultResolver = gameResultResolver;
......@@ -63,6 +65,11 @@ public enum GameDefinition implements ApplicationEvent, IMenuItem {
return ApplicationTextManager.getInstance().getResult().get(menuTextKey);
}
@Override
public String getDescription() {
return ApplicationTextManager.getInstance().getResult().get(descriptionResource);
}
public boolean hasTutorial() {
return hasTutorial;
}
......
......@@ -47,6 +47,9 @@ public class ApplicationAtlasManager extends TablexiaAtlasManager implements IAp
public static final String MAINMENU_ICON_LOGOUT_UNPRESSED = MAINMENU_PATH + "icon_logout_unpressed";
public static final String MAINMENU_ICON_STATISTICS_PRESSED = MAINMENU_PATH + "icon_statistics_pressed";
public static final String MAINMENU_ICON_STATISTICS_UNPRESSED = MAINMENU_PATH + "icon_statistics_unpressed";
public static final String MAINMENU_CHILDITEM_BACKGROUND = MAINMENU_PATH + "childitem_background";
public static final String MAINMENU_CHILDITEM_ARROW = MAINMENU_PATH + "childitem_arrow";
public static final String MAINMENU_CHILDITEM_RESTART = MAINMENU_PATH + "childitem_restart";
public static final String DIALOG_PATH = "dialog/";
public static final String DIALOG_BUBBLE_CLASSIC = DIALOG_PATH + "bubble_classic";
......
......@@ -3,6 +3,7 @@ package cz.nic.tablexia.menu;
public interface IMenuItem {
String getTitle();
String getDescription();
void performAction();
AbstractMenu.MenuAction getMenuAction();
IMenuItem[] getSubmenu();
......
......@@ -10,7 +10,9 @@ import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Stack;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import com.badlogic.gdx.utils.Align;
import java.util.List;
......@@ -120,6 +122,58 @@ public class MainMenu extends AbstractMenu {
}
}
private static class SubMenuItemGroup extends Container<Table> {
private static final String TITLE_FONT_TYPE = ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD;
private static final Color TITLE_FONT_COLOR = new Color(0.325f, 0.278f, 0.255f, 1);
private static final float TITLE_FONT_SCALE = 0.9f;
private static final String DESCRIPTION_FONT_TYPE = ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR;
private static final Color DESCRIPTION_FONT_COLOR = new Color(0.325f, 0.278f, 0.255f, 1);
private static final float DESCRIPTION_FONT_SCALE = 0.6f;
private static final float LABELS_PADDING_LEFT = 15f;
private static final float LABELS_PADDING_DEFAULT = 5f;
private static final Color HIGHLITER_COLOR = new Color(0.647f, 0.22f, 0.22f, 1);
private static final float ARROW_PADING_RIGHT = 15f;
public SubMenuItemGroup(String title, String description) {
Table layoutContainer = new Table();
layoutContainer.setBackground(new NinePatchDrawable(ApplicationAtlasManager.getInstance().getPatch(ApplicationAtlasManager.MAINMENU_CHILDITEM_BACKGROUND)));
layoutContainer.pad(2f);
setActor(layoutContainer);
fillX();
setFillParent(true);
align(Align.left);
padBottom(4f);
// highliter
Image highliter = new Image(ApplicationAtlasManager.getInstance().getColorTexture(HIGHLITER_COLOR));
layoutContainer.add(highliter);
// texts
Label titleLabel = new Label(title, new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(TITLE_FONT_TYPE), TITLE_FONT_COLOR));
titleLabel.setFontScale(TITLE_FONT_SCALE);
Label descritopnLabel = new Label(description, new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(DESCRIPTION_FONT_TYPE), DESCRIPTION_FONT_COLOR));
descritopnLabel.setFontScale(DESCRIPTION_FONT_SCALE);
Table labelsContainer = new Table();
labelsContainer.add(titleLabel).align(Align.left);
labelsContainer.row();
labelsContainer.add(descritopnLabel).align(Align.left);
labelsContainer.pad(LABELS_PADDING_DEFAULT, LABELS_PADDING_LEFT, LABELS_PADDING_DEFAULT, LABELS_PADDING_DEFAULT);
layoutContainer.add(labelsContainer);
// arrow
Image arrow = new Image(ApplicationAtlasManager.getInstance().getTextureRegion(ApplicationAtlasManager.MAINMENU_CHILDITEM_ARROW));
layoutContainer.add(arrow).expandX().align(Align.right).padRight(ARROW_PADING_RIGHT);
// highliter size
highliter.getDrawable().setMinWidth(5);
highliter.getDrawable().setMinHeight(layoutContainer.getMinHeight());
}
}
public MainMenu(Float width, Float height) {
super(width, height);
}
......@@ -130,6 +184,11 @@ public class MainMenu extends AbstractMenu {
return new MenuItemGroup(mainMenuDefinition.getIconUnpressed(), mainMenuDefinition.getIconPressed(), menuItem.getTitle());
}
@Override
protected Group createSubMenuItem(IMenuItem menuItem) {
return new SubMenuItemGroup(menuItem.getTitle(), menuItem.getDescription());
}
protected Group createMenuItemDivider() {
Container<Image> dividerContainer = new Container<Image>();
Image divider = new Image(ApplicationAtlasManager.getInstance().getColorTexture(DIVIDER_COLOR));
......
......@@ -65,6 +65,11 @@ public enum MainMenuDefinition implements IMenuItem {
return ApplicationTextManager.getInstance().getText(menuTextKey);
}
@Override
public String getDescription() {
return null;
}
@Override
public void performAction() {
ApplicationBus.getInstance().publishAsync(this.getAction());
......
......@@ -59,6 +59,11 @@ public class UserMenu extends AbstractMenu {
return ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.USERMENU_NEWUSER);
}
@Override
public String getDescription() {
return null;
}
@Override
public void performAction() {
ApplicationBus.getInstance().post(new Tablexia.ChangeScreenEvent(PanoramaScreen.class, TablexiaApplication.ScreenTransaction.MOVE_UP)).asynchronously();
......
......@@ -99,6 +99,11 @@ public class User extends UserMenu.UserMenuItem {
return getName();
}
@Override
public String getDescription() {
return null;
}
@Override
public void performAction() {
TablexiaSettings.getInstance().setSelectedUser(this);
......
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