add option to browse card images using card flow screen from explorer.
parent
3a0274521a
commit
1c11b93fdf
Binary file not shown.
After Width: | Height: | Size: 712 B |
|
@ -9,6 +9,7 @@ public enum MagicIcon {
|
|||
// ../ui/... icons.
|
||||
//
|
||||
ALERT("ui/alert-16.png"),
|
||||
CARDFLOW("ui/cardflow-32.png"),
|
||||
CHECKBOX_OFF("ui/checkbox-16.png"),
|
||||
CHECKBOX_ON("ui/checkbox-selected-16.png"),
|
||||
ARROWDOWN("ui/w_arrowdown.png"),
|
||||
|
|
|
@ -23,6 +23,7 @@ import magic.ui.screen.about.AboutScreen;
|
|||
import magic.ui.screen.card.explorer.ExplorerScreen;
|
||||
import magic.ui.screen.card.script.CardScriptScreen;
|
||||
import magic.ui.screen.cardflow.CardFlowScreen;
|
||||
import magic.ui.screen.cardflow.ICardFlowListener;
|
||||
import magic.ui.screen.cardflow.ICardFlowProvider;
|
||||
import magic.ui.screen.deck.DeckScreen;
|
||||
import magic.ui.screen.deck.editor.DeckEditorScreen;
|
||||
|
@ -361,6 +362,10 @@ public final class ScreenController {
|
|||
showScreen(() -> new CardFlowScreen(provider, screenTitle));
|
||||
}
|
||||
|
||||
public static void showCardFlowScreen(ICardFlowProvider provider, ICardFlowListener listener, String screenTitle) {
|
||||
showScreen(() -> new CardFlowScreen(provider, listener, screenTitle));
|
||||
}
|
||||
|
||||
public static boolean isDeckScreenShowing() {
|
||||
return !screens.isEmpty() && screens.peek() instanceof DeckScreen;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.awt.Container;
|
|||
import java.awt.Cursor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.List;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JPanel;
|
||||
|
@ -12,6 +13,7 @@ import javax.swing.SwingUtilities;
|
|||
import magic.model.MagicCardDefinition;
|
||||
import magic.model.MagicRandom;
|
||||
import magic.ui.ICardFilterPanelListener;
|
||||
import magic.ui.MagicImages;
|
||||
import magic.ui.ScreenController;
|
||||
import magic.ui.widget.card.filter.CardFilterPanel;
|
||||
import magic.ui.widget.cards.table.CardTablePanelB;
|
||||
|
@ -130,6 +132,22 @@ public class ExplorerContentPanel extends JPanel
|
|||
cardPoolTable.setStyle();
|
||||
}
|
||||
|
||||
BufferedImage getCardImage(int index) {
|
||||
return MagicImages.getCardImage(cardPoolTable.getCard(index));
|
||||
}
|
||||
|
||||
int getCardsCount() {
|
||||
return filterPanel.getTotalCardCount();
|
||||
}
|
||||
|
||||
void setCardAt(int index) {
|
||||
cardPoolTable.selectCardAt(index);
|
||||
}
|
||||
|
||||
int getSelectedCardIndex() {
|
||||
return cardPoolTable.getSelectedCardIndex();
|
||||
}
|
||||
|
||||
private class CardPoolMouseListener extends MouseAdapter {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
|
|
|
@ -1,17 +1,27 @@
|
|||
package magic.ui.screen.card.explorer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.SwingUtilities;
|
||||
import magic.data.MagicIcon;
|
||||
import magic.data.MagicSetDefinitions;
|
||||
import magic.translate.MText;
|
||||
import magic.ui.MagicLogs;
|
||||
import magic.ui.MagicSound;
|
||||
import magic.ui.ScreenController;
|
||||
import magic.ui.WikiPage;
|
||||
import magic.ui.helpers.ImageHelper;
|
||||
import magic.ui.screen.HeaderFooterScreen;
|
||||
import magic.ui.screen.MScreen;
|
||||
import magic.ui.screen.cardflow.ICardFlowListener;
|
||||
import magic.ui.screen.cardflow.ICardFlowProvider;
|
||||
import magic.ui.screen.widget.PlainMenuButton;
|
||||
import magic.ui.widget.cards.table.CardsTableStyle;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ExplorerScreen extends HeaderFooterScreen {
|
||||
public class ExplorerScreen extends HeaderFooterScreen
|
||||
implements ICardFlowProvider, ICardFlowListener {
|
||||
|
||||
// translatable strings
|
||||
private static final String _S1 = "Card Explorer";
|
||||
|
@ -19,6 +29,12 @@ public class ExplorerScreen extends HeaderFooterScreen {
|
|||
private static final String _S4 = "View the script and groovy files for the selected card.<br>(or double-click row)";
|
||||
private static final String _S5 = "Lucky Dip";
|
||||
private static final String _S6 = "Selects a random card from the list of cards displayed.";
|
||||
private static final String _S7 = "Card flow screen";
|
||||
private static final String _S8 = "Browse through the card images starting at the selected card.";
|
||||
|
||||
private static final ImageIcon CARDFLOW_ICON = ImageHelper.getRecoloredIcon(
|
||||
MagicIcon.CARDFLOW, Color.BLACK, Color.WHITE
|
||||
);
|
||||
|
||||
private ExplorerContentPanel contentPanel;
|
||||
private ExplorerHeaderPanel headerPanel;
|
||||
|
@ -49,15 +65,27 @@ public class ExplorerScreen extends HeaderFooterScreen {
|
|||
}
|
||||
|
||||
private void setFooterButtons() {
|
||||
addToFooter(PlainMenuButton.build(this::doShowScriptScreen,
|
||||
MagicIcon.EDIT, MText.get(_S3), MText.get(_S4)
|
||||
),
|
||||
PlainMenuButton.build(this::doSelectRandomCard,
|
||||
MagicIcon.RANDOM, MText.get(_S5), MText.get(_S6)
|
||||
)
|
||||
addToFooter(
|
||||
PlainMenuButton.build(this::doShowScriptScreen,
|
||||
MagicIcon.EDIT, MText.get(_S3), MText.get(_S4)
|
||||
),
|
||||
PlainMenuButton.build(this::doSelectRandomCard,
|
||||
MagicIcon.RANDOM, MText.get(_S5), MText.get(_S6)
|
||||
),
|
||||
PlainMenuButton.build(this::doShowCardFlowScreen,
|
||||
CARDFLOW_ICON, MText.get(_S7), MText.get(_S8)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private void doShowCardFlowScreen() {
|
||||
if (contentPanel.getCardsCount() > 0) {
|
||||
ScreenController.showCardFlowScreen(this, this, MText.get(_S1));
|
||||
} else {
|
||||
MagicSound.BEEP.play();
|
||||
}
|
||||
}
|
||||
|
||||
private void doShowScriptScreen() {
|
||||
contentPanel.showCardScriptScreen();
|
||||
}
|
||||
|
@ -89,4 +117,29 @@ public class ExplorerScreen extends HeaderFooterScreen {
|
|||
CardsTableStyle.setStyle(dialPosition);
|
||||
contentPanel.setCardsTableStyle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedImage getImage(int index) {
|
||||
return contentPanel.getCardImage(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getImagesCount() {
|
||||
return contentPanel.getCardsCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartImageIndex() {
|
||||
return contentPanel.getSelectedCardIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNewActiveImage(int index) {
|
||||
SwingUtilities.invokeLater(() -> contentPanel.setCardAt(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cardFlowClicked() {
|
||||
// not supported
|
||||
}
|
||||
}
|
||||
|
|
|
@ -431,7 +431,9 @@ class CardFlowPanel extends JPanel implements TimelineCallback {
|
|||
}
|
||||
|
||||
public void addListener(ICardFlowListener aListener) {
|
||||
listeners.add(aListener);
|
||||
if (aListener != null) {
|
||||
listeners.add(aListener);
|
||||
}
|
||||
}
|
||||
|
||||
public int getImagesCount() {
|
||||
|
|
|
@ -33,10 +33,22 @@ public class CardFlowScreen extends HeaderFooterScreen
|
|||
private final OptionsPanel optionsPanel;
|
||||
private final ScreenSettings settings = new ScreenSettings();
|
||||
private final FlashTextOverlay flashOverlay = new FlashTextOverlay();
|
||||
private final ICardFlowListener listener;
|
||||
|
||||
public CardFlowScreen(ICardFlowProvider provider, ICardFlowListener listener, String screenTitle) {
|
||||
super(screenTitle);
|
||||
this.provider = provider;
|
||||
this.listener = listener;
|
||||
optionsPanel = new OptionsPanel(this, settings);
|
||||
cardFlowPanel = new CardFlowPanel(provider, settings);
|
||||
layeredPane = new CardFlowLayeredPane(cardFlowPanel, flashOverlay);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public CardFlowScreen(ICardFlowProvider provider, String screenTitle) {
|
||||
super(screenTitle);
|
||||
this.provider = provider;
|
||||
this.listener = null;
|
||||
optionsPanel = new OptionsPanel(this, settings);
|
||||
cardFlowPanel = new CardFlowPanel(provider, settings);
|
||||
layeredPane = new CardFlowLayeredPane(cardFlowPanel, flashOverlay);
|
||||
|
@ -46,6 +58,7 @@ public class CardFlowScreen extends HeaderFooterScreen
|
|||
public CardFlowScreen() {
|
||||
super("Cardflow Test Screen");
|
||||
this.provider = this;
|
||||
this.listener = null;
|
||||
optionsPanel = new OptionsPanel(this, settings);
|
||||
cardFlowPanel = new CardFlowPanel(this, settings);
|
||||
layeredPane = new CardFlowLayeredPane(cardFlowPanel, flashOverlay);
|
||||
|
@ -55,6 +68,7 @@ public class CardFlowScreen extends HeaderFooterScreen
|
|||
private void initialize() {
|
||||
|
||||
cardFlowPanel.addListener(this);
|
||||
cardFlowPanel.addListener(listener);
|
||||
cardFlowPanel.setBackground(BACKGROUND_COLOR);
|
||||
|
||||
setMainContent(layeredPane);
|
||||
|
|
|
@ -121,4 +121,18 @@ public class CardTablePanelB extends CardsTablePanel
|
|||
tableModel.showCardCount(b);
|
||||
}
|
||||
|
||||
public MagicCardDefinition getCard(int index) {
|
||||
return tableModel.getCardDef(index);
|
||||
}
|
||||
|
||||
public void selectCardAt(int index) {
|
||||
table.setRowSelectionInterval(index, index);
|
||||
scrollRowToViewportCenter(index);
|
||||
}
|
||||
|
||||
public int getSelectedCardIndex() {
|
||||
int row = table.getSelectedRow();
|
||||
return row == -1 ? 0 : row;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue