|
|
|
|
@@ -1,17 +1,20 @@
|
|
|
|
|
package forge.screens.quest;
|
|
|
|
|
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
|
|
|
|
|
import com.badlogic.gdx.math.Vector2;
|
|
|
|
|
|
|
|
|
|
import forge.FThreads;
|
|
|
|
|
import forge.Forge;
|
|
|
|
|
import forge.assets.FSkinFont;
|
|
|
|
|
import forge.assets.FSkinImage;
|
|
|
|
|
import forge.deck.CardPool;
|
|
|
|
|
import forge.deck.Deck;
|
|
|
|
|
import forge.deck.DeckGroup;
|
|
|
|
|
import forge.deck.FDeckEditor;
|
|
|
|
|
import forge.deck.FDeckEditor.EditorType;
|
|
|
|
|
import forge.itemmanager.CardManager;
|
|
|
|
|
import forge.itemmanager.ItemManagerConfig;
|
|
|
|
|
import forge.itemmanager.filters.ItemFilter;
|
|
|
|
|
import forge.limited.BoosterDraft;
|
|
|
|
|
import forge.model.FModel;
|
|
|
|
|
import forge.quest.IQuestTournamentView;
|
|
|
|
|
@@ -20,30 +23,43 @@ import forge.quest.QuestTournamentController;
|
|
|
|
|
import forge.quest.QuestDraftUtils.Mode;
|
|
|
|
|
import forge.quest.data.QuestEventDraftContainer;
|
|
|
|
|
import forge.screens.limited.DraftingProcessScreen;
|
|
|
|
|
import forge.toolbox.FButton;
|
|
|
|
|
import forge.toolbox.FContainer;
|
|
|
|
|
import forge.toolbox.FEvent;
|
|
|
|
|
import forge.toolbox.FTextField;
|
|
|
|
|
import forge.toolbox.FEvent.FEventHandler;
|
|
|
|
|
import forge.toolbox.FLabel;
|
|
|
|
|
import forge.util.Utils;
|
|
|
|
|
|
|
|
|
|
public class QuestTournamentsScreen extends QuestLaunchScreen implements IQuestTournamentView {
|
|
|
|
|
private final FLabel lblCredits = add(new FLabel.Builder().icon(FSkinImage.QUEST_COINSTACK)
|
|
|
|
|
//Select Tournament panel
|
|
|
|
|
private final SelectTournamentPanel pnlSelectTournament = add(new SelectTournamentPanel());
|
|
|
|
|
|
|
|
|
|
private final FLabel lblCredits = pnlSelectTournament.add(new FLabel.Builder().icon(FSkinImage.QUEST_COINSTACK)
|
|
|
|
|
.iconScaleFactor(0.75f).font(FSkinFont.get(16)).build());
|
|
|
|
|
|
|
|
|
|
private final FLabel lblTokens = add(new FLabel.Builder()
|
|
|
|
|
.align(HAlignment.RIGHT).font(FSkinFont.get(16)).build());
|
|
|
|
|
private final FLabel btnSpendToken = pnlSelectTournament.add(new FLabel.ButtonBuilder().text("Spend Token (0)").build());
|
|
|
|
|
|
|
|
|
|
private final FLabel lblInfo = add(new FLabel.Builder().text("Select a tournament to join:")
|
|
|
|
|
private final FLabel lblInfo = pnlSelectTournament.add(new FLabel.Builder().text("Select a tournament to join:")
|
|
|
|
|
.align(HAlignment.CENTER).font(FSkinFont.get(16)).build());
|
|
|
|
|
|
|
|
|
|
private final FLabel lblNoTournaments = add(new FLabel.Builder()
|
|
|
|
|
private final FLabel lblNoTournaments = pnlSelectTournament.add(new FLabel.Builder()
|
|
|
|
|
.align(HAlignment.CENTER).text("There are no tournaments available at this time.").insets(Vector2.Zero)
|
|
|
|
|
.font(FSkinFont.get(12)).build());
|
|
|
|
|
|
|
|
|
|
private final QuestEventPanel.Container pnlTournaments = add(new QuestEventPanel.Container());
|
|
|
|
|
private final QuestEventPanel.Container pnlTournaments = pnlSelectTournament.add(new QuestEventPanel.Container());
|
|
|
|
|
|
|
|
|
|
private final FLabel btnLeaveTournament = add(new FLabel.ButtonBuilder().text("Leave Tournament").build());
|
|
|
|
|
private final FLabel btnSpendToken = add(new FLabel.ButtonBuilder().text("Spend Token").build());
|
|
|
|
|
//Prepare Deck panel
|
|
|
|
|
private final PrepareDeckPanel pnlPrepareDeck = add(new PrepareDeckPanel());
|
|
|
|
|
|
|
|
|
|
private final FButton btnEditDeck = pnlPrepareDeck.add(new FButton("Edit Deck"));
|
|
|
|
|
private final FButton btnLeaveTournament = pnlPrepareDeck.add(new FButton("Leave Tournament"));
|
|
|
|
|
private final CardManager deckViewer = pnlPrepareDeck.add(new CardManager(false));
|
|
|
|
|
|
|
|
|
|
//Tournament Active panel
|
|
|
|
|
private final TournamentActivePanel pnlTournamentActive = add(new TournamentActivePanel());
|
|
|
|
|
|
|
|
|
|
//Results labels
|
|
|
|
|
private static final FSkinFont RESULTS_FONT = FSkinFont.get(15);
|
|
|
|
|
private static final Vector2 RESULTS_INSETS = new Vector2(2 * PADDING, 0);
|
|
|
|
|
private final FLabel lblFirst = new FLabel.Builder().font(RESULTS_FONT).insets(RESULTS_INSETS).build();
|
|
|
|
|
@@ -51,8 +67,8 @@ public class QuestTournamentsScreen extends QuestLaunchScreen implements IQuestT
|
|
|
|
|
private final FLabel lblThird = new FLabel.Builder().font(RESULTS_FONT).insets(RESULTS_INSETS).build();
|
|
|
|
|
private final FLabel lblFourth = new FLabel.Builder().font(RESULTS_FONT).insets(RESULTS_INSETS).build();
|
|
|
|
|
|
|
|
|
|
private Mode mode;
|
|
|
|
|
private final QuestTournamentController controller;
|
|
|
|
|
private Mode mode = Mode.SELECT_TOURNAMENT;
|
|
|
|
|
|
|
|
|
|
public QuestTournamentsScreen() {
|
|
|
|
|
super();
|
|
|
|
|
@@ -63,38 +79,29 @@ public class QuestTournamentsScreen extends QuestLaunchScreen implements IQuestT
|
|
|
|
|
controller.spendToken();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
btnEditDeck.setCommand(new FEventHandler() {
|
|
|
|
|
@Override
|
|
|
|
|
public void handleEvent(FEvent e) {
|
|
|
|
|
controller.editDeck();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
btnLeaveTournament.setCommand(new FEventHandler() {
|
|
|
|
|
@Override
|
|
|
|
|
public void handleEvent(FEvent e) {
|
|
|
|
|
controller.endTournamentAndAwardPrizes();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
btnLeaveTournament.setVisible(false);
|
|
|
|
|
deckViewer.setCaption("Main Deck");
|
|
|
|
|
deckViewer.setup(ItemManagerConfig.QUEST_DRAFT_DECK_VIEWER);
|
|
|
|
|
setMode(Mode.SELECT_TOURNAMENT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void doLayoutAboveBtnStart(float startY, float width, float height) {
|
|
|
|
|
float gap = Utils.scale(2);
|
|
|
|
|
float y = startY + gap; //move credits label down a couple pixels so it looks better
|
|
|
|
|
|
|
|
|
|
float halfWidth = width / 2;
|
|
|
|
|
lblCredits.setBounds(0, y, halfWidth, lblCredits.getAutoSizeBounds().height);
|
|
|
|
|
lblTokens.setBounds(halfWidth, y, halfWidth - gap, lblCredits.getHeight());
|
|
|
|
|
y += lblCredits.getHeight() + gap;
|
|
|
|
|
|
|
|
|
|
TextBounds buttonBounds = btnSpendToken.getAutoSizeBounds();
|
|
|
|
|
float buttonWidth = buttonBounds.width + 2 * gap;
|
|
|
|
|
float x = width - gap - buttonWidth;
|
|
|
|
|
btnSpendToken.setBounds(x, y, buttonWidth, buttonBounds.height + 2 * gap);
|
|
|
|
|
btnLeaveTournament.setBounds(gap, y, x - 3 * gap, btnSpendToken.getHeight());
|
|
|
|
|
y += btnSpendToken.getHeight() + gap;
|
|
|
|
|
|
|
|
|
|
x = PADDING;
|
|
|
|
|
float w = width - 2 * PADDING;
|
|
|
|
|
lblInfo.setBounds(x, y, w, lblInfo.getAutoSizeBounds().height);
|
|
|
|
|
y += lblInfo.getHeight() + gap;
|
|
|
|
|
lblNoTournaments.setBounds(x, y, w, lblNoTournaments.getAutoSizeBounds().height);
|
|
|
|
|
pnlTournaments.setBounds(x, y, w, height - y);
|
|
|
|
|
height -= startY;
|
|
|
|
|
pnlSelectTournament.setBounds(0, startY, width, height);
|
|
|
|
|
pnlPrepareDeck.setBounds(0, startY, width, height);
|
|
|
|
|
pnlTournamentActive.setBounds(0, startY, width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@@ -105,6 +112,16 @@ public class QuestTournamentsScreen extends QuestLaunchScreen implements IQuestT
|
|
|
|
|
@Override
|
|
|
|
|
public void onUpdate() {
|
|
|
|
|
controller.update();
|
|
|
|
|
if (mode == Mode.PREPARE_DECK) {
|
|
|
|
|
Deck deck = getDeck();
|
|
|
|
|
if (deck != null) {
|
|
|
|
|
deckViewer.setPool(deck.getMain());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
deckViewer.setPool(new CardPool());
|
|
|
|
|
}
|
|
|
|
|
setHeaderCaption(FModel.getQuest().getName() + " - " + getGameType() + "\nDraft - " + FModel.getQuest().getAchievements().getCurrentDraft().getTitle());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@@ -114,7 +131,11 @@ public class QuestTournamentsScreen extends QuestLaunchScreen implements IQuestT
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setMode(Mode mode0) {
|
|
|
|
|
if (mode == mode0) { return; }
|
|
|
|
|
mode = mode0;
|
|
|
|
|
pnlSelectTournament.setVisible(mode == Mode.SELECT_TOURNAMENT);
|
|
|
|
|
pnlPrepareDeck.setVisible(mode == Mode.PREPARE_DECK);
|
|
|
|
|
pnlTournamentActive.setVisible(mode == Mode.TOURNAMENT_ACTIVE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@@ -149,16 +170,21 @@ public class QuestTournamentsScreen extends QuestLaunchScreen implements IQuestT
|
|
|
|
|
Forge.openScreen(new DraftingProcessScreen(draft));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void editDeck(boolean isExistingDeck) {
|
|
|
|
|
private Deck getDeck() {
|
|
|
|
|
DeckGroup deckGroup = FModel.getQuest().getDraftDecks().get(QuestEventDraft.DECK_NAME);
|
|
|
|
|
if (deckGroup != null) {
|
|
|
|
|
Deck deck = deckGroup.getHumanDeck();
|
|
|
|
|
return deckGroup.getHumanDeck();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void editDeck(boolean isExistingDeck) {
|
|
|
|
|
Deck deck = getDeck();
|
|
|
|
|
if (deck != null) {
|
|
|
|
|
Forge.openScreen(new FDeckEditor(EditorType.QuestDraft, deck, isExistingDeck));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void startMatch() {
|
|
|
|
|
@@ -207,18 +233,52 @@ public class QuestTournamentsScreen extends QuestLaunchScreen implements IQuestT
|
|
|
|
|
return lblFourth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public FLabel getLblTokens() {
|
|
|
|
|
return lblTokens;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public FLabel getBtnSpendToken() {
|
|
|
|
|
return btnSpendToken;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public FLabel getBtnLeaveTournament() {
|
|
|
|
|
public FButton getBtnLeaveTournament() {
|
|
|
|
|
return btnLeaveTournament;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class SelectTournamentPanel extends FContainer {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doLayout(float width, float height) {
|
|
|
|
|
float gap = Utils.scale(2);
|
|
|
|
|
float y = gap; //move credits label down a couple pixels so it looks better
|
|
|
|
|
|
|
|
|
|
float halfWidth = width / 2;
|
|
|
|
|
lblCredits.setBounds(0, y, halfWidth, lblCredits.getAutoSizeBounds().height);
|
|
|
|
|
btnSpendToken.setBounds(halfWidth, y, halfWidth - gap, lblCredits.getHeight());
|
|
|
|
|
y += lblCredits.getHeight() + gap;
|
|
|
|
|
|
|
|
|
|
float x = PADDING;
|
|
|
|
|
float w = width - 2 * PADDING;
|
|
|
|
|
lblInfo.setBounds(x, y, w, lblInfo.getAutoSizeBounds().height);
|
|
|
|
|
y += lblInfo.getHeight() + gap;
|
|
|
|
|
lblNoTournaments.setBounds(x, y, w, lblNoTournaments.getAutoSizeBounds().height);
|
|
|
|
|
pnlTournaments.setBounds(x, y, w, height - y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class PrepareDeckPanel extends FContainer {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doLayout(float width, float height) {
|
|
|
|
|
float y = PADDING;
|
|
|
|
|
float buttonWidth = (width - 3 * PADDING) / 2;
|
|
|
|
|
btnEditDeck.setBounds(PADDING, y, buttonWidth, FTextField.getDefaultHeight());
|
|
|
|
|
btnLeaveTournament.setBounds(btnEditDeck.getRight() + PADDING, y, buttonWidth, btnEditDeck.getHeight());
|
|
|
|
|
y += btnEditDeck.getHeight() + PADDING - ItemFilter.PADDING;
|
|
|
|
|
deckViewer.setBounds(0, y, width, height - y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TournamentActivePanel extends FContainer {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doLayout(float width, float height) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|