Anleitungsscreen(#18)
parent
254c4a99c4
commit
8cc7e03282
@ -0,0 +1,223 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.screens;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import eu.jonahbauer.wizard.client.libgdx.GameAtlas;
|
||||
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
||||
import eu.jonahbauer.wizard.client.libgdx.actors.CardActor;
|
||||
import eu.jonahbauer.wizard.client.libgdx.state.Menu;
|
||||
import eu.jonahbauer.wizard.common.model.Card;
|
||||
|
||||
public class InstructionScreen extends MenuScreen {
|
||||
|
||||
private TextButton buttonOK;
|
||||
private VerticalGroup content;
|
||||
private ScrollPane scrollPane;
|
||||
private Label title;
|
||||
private TextButton nextPageButton;
|
||||
private TextButton previousPageButton;
|
||||
private HorizontalGroup horizontalButtonGroup;
|
||||
private int pagecounter = 0;
|
||||
|
||||
private TextureAtlas atlas;
|
||||
private CardActor card;
|
||||
|
||||
private final ChangeListener listener = new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
if (actor == buttonOK) {
|
||||
game.getClient().execute(Menu.class, Menu::showMenuScreen);
|
||||
sfxClick();
|
||||
} else if (actor == nextPageButton) {
|
||||
switch(pagecounter) {
|
||||
case 0: pagecounter++; showSecondPage(); break;
|
||||
case 1: pagecounter++; showThirdPage(); break;
|
||||
default: throw new IllegalStateException();
|
||||
}
|
||||
} else if (actor == previousPageButton) {
|
||||
switch(pagecounter) {
|
||||
case 1: pagecounter--; showFirstPage(); break;
|
||||
case 2: pagecounter--; showSecondPage(); break;
|
||||
default: throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public InstructionScreen(WizardGame game) {
|
||||
super(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
super.show();
|
||||
prepareScreen();
|
||||
|
||||
previousPageButton = new TextButton(messages.get("menu.instruction.previousPageButton"), skin);
|
||||
nextPageButton = new TextButton(messages.get("menu.instruction.nextPageButton"), skin);
|
||||
horizontalButtonGroup = new HorizontalGroup();
|
||||
|
||||
buttonOK = new TextButton(messages.get("menu.main.ok"), skin);
|
||||
|
||||
scrollPane = new ScrollPane(content, skin);
|
||||
scrollPane.setFadeScrollBars(true);
|
||||
scrollPane.setOverscroll(false,false);
|
||||
scrollPane.setPosition(corners[0].getWidth() + 5, 0);
|
||||
scrollPane.setSize(WizardGame.WIDTH - (2 * corners[0].getWidth() + 5), WizardGame.HEIGHT);
|
||||
scrollPane.setColor(new Color(0, 0, 0, 0.75f));
|
||||
|
||||
showFirstPage();
|
||||
Gdx.input.setInputProcessor(stage);
|
||||
stage.addActor(scrollPane);
|
||||
|
||||
buttonOK.addListener(listener);
|
||||
nextPageButton.addListener(listener);
|
||||
previousPageButton.addListener(listener);
|
||||
}
|
||||
|
||||
private void prepareScreen() {
|
||||
atlas = new TextureAtlas(Gdx.files.internal(GameAtlas.$PATH));
|
||||
content = new VerticalGroup();
|
||||
}
|
||||
|
||||
private void clearContent() {
|
||||
while(content.getChildren().size > 0) {
|
||||
content.removeActorAt(0, false);
|
||||
}
|
||||
horizontalButtonGroup.clear();
|
||||
}
|
||||
|
||||
private void addButtons() {
|
||||
if(pagecounter != 0) {
|
||||
horizontalButtonGroup.addActor(previousPageButton);
|
||||
}
|
||||
if(pagecounter != 2) {
|
||||
horizontalButtonGroup.addActor(nextPageButton);
|
||||
}
|
||||
horizontalButtonGroup.space(10);
|
||||
content.addActor(horizontalButtonGroup);
|
||||
content.addActor(buttonOK);
|
||||
}
|
||||
|
||||
private void showFirstPage() {
|
||||
clearContent();
|
||||
|
||||
title = new Label(messages.get("menu.instruction.main"), skin, "enchanted");
|
||||
content.addActor(title);
|
||||
Label maintext1 = new Label(messages.get("menu.instruction.main.text1"), skin);
|
||||
maintext1.setFontScale(2.0f);
|
||||
content.addActor(maintext1);
|
||||
Label maintext2 = new Label(messages.get("menu.instruction.main.text2"), skin);
|
||||
content.addActor(maintext2);
|
||||
Label general = new Label(messages.get("menu.instruction.general"), skin, "enchanted");
|
||||
content.addActor(general);
|
||||
Label introduction1 = new Label(messages.get("menu.instruction.introduction1"), skin);
|
||||
content.addActor(introduction1);
|
||||
Label introduction2 = new Label(messages.get("menu.instruction.introduction2"), skin);
|
||||
content.addActor(introduction2);
|
||||
Label headingStandardGame = new Label(messages.get("menu.instruction.standardgameheading"), skin, "enchanted");
|
||||
content.addActor(headingStandardGame);
|
||||
Label standardGame1 = new Label(messages.get("menu.instruction.standardgame1"), skin);
|
||||
content.addActor(standardGame1);
|
||||
Label standardGame2 = new Label(messages.get("menu.instruction.standardgame2"), skin);
|
||||
content.addActor(standardGame2);
|
||||
Label standardGame3 = new Label(messages.get("menu.instruction.standardgame3"), skin);
|
||||
content.addActor(standardGame3);
|
||||
HorizontalGroup colors = new HorizontalGroup();
|
||||
colors.space(10);
|
||||
for(Card.Suit suit : Card.Suit.values()) {
|
||||
if (suit != Card.Suit.NONE) {
|
||||
VerticalGroup cardColor = new VerticalGroup();
|
||||
cardColor.space(10);
|
||||
card = new CardActor(Card.Suit.values()[suit.ordinal()], atlas);
|
||||
cardColor.addActor(card);
|
||||
Label colorLabel = new Label(suit.toString(), skin);
|
||||
cardColor.addActor(colorLabel);
|
||||
colors.addActor(cardColor);
|
||||
}
|
||||
}
|
||||
content.addActor(colors);
|
||||
Label standardGame4 = new Label(messages.get("menu.instruction.standardgame4"), skin);
|
||||
content.addActor(standardGame4);
|
||||
|
||||
HorizontalGroup wizardJester = new HorizontalGroup();
|
||||
wizardJester.padTop(5);
|
||||
wizardJester.space(10);
|
||||
|
||||
VerticalGroup wizardVerticalGroup = new VerticalGroup();
|
||||
wizardVerticalGroup.space(10);
|
||||
card = new CardActor(Card.values()[Card.BLUE_WIZARD.ordinal()], atlas);
|
||||
wizardVerticalGroup.addActor(card);
|
||||
Label wizardLabel = new Label(messages.get("menu.instruction.wizard"), skin);
|
||||
wizardVerticalGroup.addActor(wizardLabel);
|
||||
wizardJester.addActor(wizardVerticalGroup);
|
||||
|
||||
VerticalGroup jesterVerticalGroup = new VerticalGroup();
|
||||
jesterVerticalGroup.space(10);
|
||||
card = new CardActor(Card.values()[Card.BLUE_JESTER.ordinal()], atlas);
|
||||
jesterVerticalGroup.addActor(card);
|
||||
Label jesterLabel = new Label(messages.get("menu.instruction.jester"), skin);
|
||||
jesterVerticalGroup.addActor(jesterLabel);
|
||||
wizardJester.addActor(jesterVerticalGroup);
|
||||
content.addActor(wizardJester);
|
||||
Label standardGame5 = new Label(messages.get("menu.instruction.standardgame5"), skin);
|
||||
content.addActor(standardGame5);
|
||||
Label standardGame6 = new Label(messages.get("menu.instruction.standardgame6"), skin);
|
||||
standardGame6.setFontScale(2.0f);
|
||||
content.addActor(standardGame6);
|
||||
Label standardGame7 = new Label(messages.get("menu.instruction.standardgame7"), skin);
|
||||
content.addActor(standardGame7);
|
||||
Label standardGame8 = new Label(messages.get("menu.instruction.standardgame8"), skin);
|
||||
standardGame8.setFontScale(2.0f);
|
||||
content.addActor(standardGame8);
|
||||
Label standardGame9 = new Label(messages.get("menu.instruction.standardgame9"), skin);
|
||||
content.addActor(standardGame9);
|
||||
Label scoring = new Label(messages.get("menu.instruction.scoring"), skin, "enchanted");
|
||||
content.addActor(scoring);
|
||||
Label standardGame10 = new Label(messages.get("menu.instruction.standardgame10"), skin);
|
||||
content.addActor(standardGame10);
|
||||
addButtons();
|
||||
}
|
||||
|
||||
private void showSecondPage() {
|
||||
clearContent();
|
||||
title.setText(messages.get("menu.instruction.variant.title"));
|
||||
content.addActor(title);
|
||||
Label variantsIntro = new Label(messages.get("menu.instruction.variant.intro"), skin);
|
||||
content.addActor(variantsIntro);
|
||||
Table table = new Table(skin);
|
||||
table.defaults().space(15.0f).left().pad(25.0f);
|
||||
table.add(messages.get("menu.instruction.variant.default"));
|
||||
table.add(messages.get("menu.instruction.variant.default.description")).left();
|
||||
table.row();
|
||||
table.add(messages.get("menu.instruction.variant.defaultpm1"));
|
||||
table.add(messages.get("menu.instruction.variant.defaultpm1.description"));
|
||||
table.row();
|
||||
table.add(messages.get("menu.instruction.variant.anniversary2016"));
|
||||
table.add(messages.get("menu.instruction.variant.anniversary2016.description"));
|
||||
table.row();
|
||||
table.add(messages.get("menu.instruction.variant.anniversary2016pm1"));
|
||||
table.add(messages.get("menu.instruction.variant.anniversary2016pm1.description"));
|
||||
table.row();
|
||||
table.add(messages.get("menu.instruction.variant.anniversary2021"));
|
||||
table.add(messages.get("menu.instruction.variant.anniversary2021.description"));
|
||||
table.row();
|
||||
table.add(messages.get("menu.instruction.variant.anniversary2021pm1"));
|
||||
table.add(messages.get("menu.instruction.variant.anniversary2021pm1.description"));
|
||||
table.row();
|
||||
content.addActor(table);
|
||||
addButtons();
|
||||
scrollPane.setScrollY(0);
|
||||
}
|
||||
|
||||
private void showThirdPage() {
|
||||
clearContent();
|
||||
title.setText(messages.get("menu.instruction.special_card.title"));
|
||||
content.addActor(title);
|
||||
addButtons();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue