Search in sources :

Example 6 with BigCard

use of mage.client.cards.BigCard in project mage by magefree.

the class CollectionViewerPanel method initComponents.

public void initComponents() {
    buttonsPanel = new javax.swing.JPanel();
    buttonsPanel.setOpaque(false);
    bigCard = new BigCard();
    BoxLayout boxlayout = new BoxLayout(buttonsPanel, BoxLayout.PAGE_AXIS);
    buttonsPanel.setLayout(boxlayout);
    btnExit = new javax.swing.JButton();
    btnExit.setAlignmentX(Component.LEFT_ALIGNMENT);
    buttonsPanel.add(btnExit);
    JLabel label1 = new JLabel("Choose format:");
    label1.setAlignmentX(Component.LEFT_ALIGNMENT);
    label1.setForeground(Color.white);
    buttonsPanel.add(label1);
    // SELECT SET
    // panel
    setPanel = new JPanel();
    setPanel.setLayout(new javax.swing.BoxLayout(setPanel, javax.swing.BoxLayout.LINE_AXIS));
    setPanel.setOpaque(false);
    setPanel.setPreferredSize(new Dimension(200, 25));
    setPanel.setMaximumSize(new Dimension(200, 25));
    setPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    buttonsPanel.add(setPanel);
    // combo set
    formats = new JComboBox<>();
    reloadFormatCombobox();
    // auto-update sets list on changes
    setsDbListener = new Listener<RepositoryEvent>() {

        @Override
        public void event(RepositoryEvent event) {
            if (event.getEventType().equals(RepositoryEvent.RepositoryEventType.DB_UPDATED)) {
                reloadFormatCombobox();
            }
        }
    };
    ExpansionRepository.instance.subscribe(setsDbListener);
    // update cards on format combobox changes
    formats.addActionListener(e -> {
        if (mageBook != null) {
            String format = (String) formats.getSelectedItem();
            MageFrame.getPreferences().put(CollectionViewerPanel.FORMAT_CONFIG_KEY, format);
            mageBook.updateDispayedSets(format);
        }
    });
    formats.setAlignmentX(0.0F);
    formats.setMinimumSize(new Dimension(50, 25));
    formats.setPreferredSize(new Dimension(50, 25));
    formats.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));
    setPanel.add(formats);
    // search button
    btnSetFastSearch = new JButton();
    btnSetFastSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/search_24.png")));
    btnSetFastSearch.setToolTipText(FastSearchUtil.DEFAULT_EXPANSION_TOOLTIP_MESSAGE);
    btnSetFastSearch.setAlignmentX(1.0F);
    btnSetFastSearch.setMinimumSize(new java.awt.Dimension(24, 24));
    btnSetFastSearch.setPreferredSize(new java.awt.Dimension(32, 32));
    btnSetFastSearch.setMaximumSize(new java.awt.Dimension(32, 32));
    btnSetFastSearch.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            FastSearchUtil.showFastSearchForStringComboBox(formats, FastSearchUtil.DEFAULT_EXPANSION_SEARCH_MESSAGE);
        }
    });
    setPanel.add(btnSetFastSearch);
    JLabel label2 = new JLabel("Choose size:");
    label2.setAlignmentX(Component.LEFT_ALIGNMENT);
    label2.setForeground(Color.white);
    buttonsPanel.add(label2);
    small3x3 = new JRadioButton("3x3");
    small3x3.setForeground(Color.white);
    boolean selected3x3 = MageFrame.getPreferences().get(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3X3).equals(MageBook.LAYOUT_3X3);
    small3x3.setSelected(selected3x3);
    small3x3.addActionListener(e -> {
        big4x4.setSelected(false);
        mageBook.updateSize(MageBook.LAYOUT_3X3);
        MageFrame.getPreferences().put(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3X3);
    });
    buttonsPanel.add(small3x3);
    big4x4 = new JRadioButton("4x4");
    big4x4.setForeground(Color.white);
    big4x4.setSelected(!selected3x3);
    big4x4.addActionListener(e -> {
        small3x3.setSelected(false);
        mageBook.updateSize(MageBook.LAYOUT_4X4);
        MageFrame.getPreferences().put(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_4X4);
    });
    buttonsPanel.add(big4x4);
    JLabel label3 = new JLabel("Switch tabs:");
    label3.setAlignmentX(Component.LEFT_ALIGNMENT);
    label3.setForeground(Color.white);
    buttonsPanel.add(label3);
    JPanel buttonPanel = new JPanel();
    buttonPanel.setPreferredSize(new Dimension(200, 100));
    buttonPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 100));
    buttonPanel.setOpaque(false);
    buttonPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    buttonsPanel.add(buttonPanel);
    JButton prev = new JButton("Prev");
    prev.addActionListener(e -> mageBook.prev());
    buttonPanel.add(prev);
    JButton next = new JButton("Next");
    next.addActionListener(e -> mageBook.next());
    buttonPanel.add(next);
    JLabel labelCardTokenSwitch = new JLabel("Show cards or tokens:");
    labelCardTokenSwitch.setAlignmentX(Component.LEFT_ALIGNMENT);
    labelCardTokenSwitch.setForeground(Color.white);
    buttonsPanel.add(labelCardTokenSwitch);
    JCheckBox cardsOrTokens = new JCheckBox("Display Cards");
    cardsOrTokens.setSelected(true);
    cardsOrTokens.setForeground(Color.white);
    cardsOrTokens.setToolTipText("Select to show Cards for the chosen set.  When unselected, will show Tokens, Emblems and Planes for the set instead");
    cardsOrTokens.addActionListener(e -> mageBook.cardsOrTokens(cardsOrTokens.isSelected()));
    buttonsPanel.add(cardsOrTokens);
    buttonsPanel.add(Box.createVerticalGlue());
    bigCard.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    bigCard.setAlignmentX(Component.LEFT_ALIGNMENT);
    bigCard.setAlignmentY(Component.BOTTOM_ALIGNMENT);
    buttonsPanel.add(bigCard);
    jPanel2 = new MageBookContainer();
    jPanel2.setOpaque(false);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(buttonsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(0, 0, 0).addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 604, Short.MAX_VALUE)));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(buttonsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE));
    btnExit.setText("Exit");
    btnExit.addActionListener(evt -> btnExitActionPerformed(evt));
}
Also used : BigCard(mage.client.cards.BigCard) javax.swing(javax.swing) RepositoryEvent(mage.cards.repository.RepositoryEvent) java.awt(java.awt)

Example 7 with BigCard

use of mage.client.cards.BigCard in project mage by magefree.

the class TestGameType method reloadCards.

private void reloadCards() {
    // apply selected theme (warning, it will be applied for all app, so can be bugged in other dialogs - but it's ok for debug)
    PreferencesDialog.setCurrentTheme((ThemeType) comboTheme.getSelectedItem());
    cardsPanel.cleanUp();
    cardsPanel.setCustomRenderMode(comboRenderMode.getSelectedIndex());
    // enable full battlefield render mode (it was bugged in test dialog so was disabled in old days, not it works fine)
    cardsPanel.setCustomNeedFullPermanentRender(true);
    cardsPanel.setCustomCardSize(new Dimension(getCardWidth(), getCardHeight()));
    cardsPanel.setCustomXOffsetBetweenCardsOrColumns(10);
    cardsPanel.setCustomCardIconsPanelPosition(CardIconPosition.fromString((String) comboCardIconsPosition.getSelectedItem()));
    cardsPanel.setCustomCardIconsPanelOrder(CardIconOrder.fromString((String) comboCardIconsOrder.getSelectedItem()));
    cardsPanel.setCustomCardIconsPanelColor((CardIconColor) comboCardColor.getSelectedItem());
    cardsPanel.setCustomCardIconsMaxVisibleCount((Integer) spinnerCardIconsMaxVisible.getValue());
    int needAdditionalIcons = Math.min(99, Math.max(0, (Integer) spinnerCardIconsAdditionalAmount.getValue()));
    // reload new settings
    cardsPanel.changeGUISize();
    // sample popup menus
    JMenuItem item;
    JPopupMenu popupCardMenu = new JPopupMenu();
    item = new JMenuItem("Card menu 1");
    popupCardMenu.add(item);
    item = new JMenuItem("Card menu 2");
    popupCardMenu.add(item);
    item = new JMenuItem("Card menu 3");
    popupCardMenu.add(item);
    // 
    JPopupMenu popupPanelMenu = new JPopupMenu();
    item = new JMenuItem("Panel menu 1");
    popupPanelMenu.add(item);
    item = new JMenuItem("Panel menu 2");
    popupPanelMenu.add(item);
    item = new JMenuItem("Panel menu 3");
    popupPanelMenu.add(item);
    // init card listener for clicks, menu and other events
    if (this.cardListener == null) {
        this.cardListener = event -> {
            switch(event.getEventType()) {
                case CARD_CLICK:
                case CARD_DOUBLE_CLICK:
                    handleCardClick(event);
                    break;
                case CARD_POPUP_MENU:
                    if (event.getSource() != null) {
                        // card
                        handlePopupMenu(event, popupCardMenu);
                    } else {
                        // panel
                        handlePopupMenu(event, popupPanelMenu);
                    }
                    break;
            }
        };
        cardsPanel.addCardEventListener(this.cardListener);
    }
    game = new TestGame(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, MulliganType.GAME_DEFAULT.getMulligan(0), 20);
    Deck deck = new Deck();
    Player playerYou = new StubPlayer("player1", RangeOfInfluence.ALL);
    game.addPlayer(playerYou, deck);
    Player playerOpponent = new StubPlayer("player2", RangeOfInfluence.ALL);
    game.addPlayer(playerOpponent, deck);
    List<Ability> additionalIcons = Collections.singletonList(new SimpleStaticAbility(Zone.ALL, null));
    for (int i = 0; i < needAdditionalIcons; i++) {
        String text = "";
        if (RandomUtil.nextBoolean()) {
            if (RandomUtil.nextBoolean()) {
                text = "75";
            } else {
                text = "8";
            }
        }
        additionalIcons.get(0).addIcon(new CardIconImpl(CardIconType.PLAYABLE_COUNT, "test icon " + i + 1, text));
    }
    List<CardView> cardViews = new ArrayList<>();
    /* // test morphed
        cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "263", 0, 0, 0, false, null)); // mountain
        cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "185", 0, 0, 0, true, null)); // Judith, the Scourge Diva
        cardViews.add(createHandCard(game, playerYou.getId(), "DIS", "153")); // Odds // Ends (split card)
        cardViews.add(createHandCard(game, playerYou.getId(), "ELD", "38")); // Animating Faerie (adventure card)
        cardViews.add(createFaceDownCard(game, playerOpponent.getId(), "ELD", "38", false, false, false)); // face down
        cardViews.add(createFaceDownCard(game, playerOpponent.getId(), "ELD", "38", true, false, true)); // morphed
        cardViews.add(createFaceDownCard(game, playerOpponent.getId(), "ELD", "38", false, true, false)); // manifested
        //*/
    /* //test emblems
        cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "78", 125, 89, 0, false, false, null)); // Noxious Groodion
        cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "14", 3, 5, 2, false, false, null)); // Knight of Sorrows
        cardViews.add(createPermanentCard(game, playerYou.getId(), "DKA", "140", 5, 2, 2, false, false, null)); // Huntmaster of the Fells, transforms
        cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "221", 0, 0, 0, false, false, null)); // Bedeck // Bedazzle
        cardViews.add(createPermanentCard(game, playerYou.getId(), "XLN", "234", 0, 0, 0, false, false, null)); // Conqueror's Galleon
        cardViews.add(createEmblem(new AjaniAdversaryOfTyrantsEmblem())); // Emblem Ajani
        cardViews.add(createPlane(new AkoumPlane())); // Plane - Akoum
        //*/
    // test split, transform and mdf in hands
    // Accursed Witch
    cardViews.add(createHandCard(game, playerYou.getId(), "SOI", "97"));
    // Fire // Ice
    cardViews.add(createHandCard(game, playerYou.getId(), "UMA", "225"));
    // Giant Killer
    cardViews.add(createHandCard(game, playerYou.getId(), "ELD", "14"));
    // Akoum Warrior
    cardViews.add(createHandCard(game, playerYou.getId(), "ZNR", "134"));
    // */
    // * //test card icons
    // Grizzly Bears
    cardViews.add(createHandCard(game, playerYou.getId(), "POR", "169"));
    // Huntmaster of the Fells, transforms
    cardViews.add(createHandCard(game, playerYou.getId(), "DKA", "140"));
    // Huntmaster of the Fells, transforms
    cardViews.add(createPermanentCard(game, playerYou.getId(), "DKA", "140", 3, 3, 1, false, true, additionalIcons));
    // Hinterland Drake
    cardViews.add(createPermanentCard(game, playerYou.getId(), "MB1", "401", 1, 1, 0, false, false, additionalIcons));
    // duplicate cards
    if (checkBoxGenerateManyCards.isSelected()) {
        while (cardViews.size() < 30) {
            int addingCount = cardViews.size();
            for (int i = 0; i < addingCount; i++) {
                CardView view = cardViews.get(i);
                CardView newView = new CardView(view);
                cardViews.add(newView);
            }
        }
    }
    BigCard big = new BigCard();
    CardsView view = new CardsView(cardViews);
    cardsPanel.loadCards(view, big, game.getId());
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) TransformAbility(mage.abilities.keyword.TransformAbility) Ability(mage.abilities.Ability) StubPlayer(mage.players.StubPlayer) Player(mage.players.Player) BigCard(mage.client.cards.BigCard) CardIconImpl(mage.abilities.icon.CardIconImpl) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Deck(mage.cards.decks.Deck) StubPlayer(mage.players.StubPlayer)

Aggregations

BigCard (mage.client.cards.BigCard)7 java.awt (java.awt)3 javax.swing (javax.swing)3 java.awt.event (java.awt.event)2 PropertyVetoException (java.beans.PropertyVetoException)1 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 SocketException (java.net.SocketException)1 java.util (java.util)1 List (java.util.List)1 CancellationException (java.util.concurrent.CancellationException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeUnit (java.util.concurrent.TimeUnit)1 Alignment (javax.swing.GroupLayout.Alignment)1 Timer (javax.swing.Timer)1 Border (javax.swing.border.Border)1 EmptyBorder (javax.swing.border.EmptyBorder)1 LineBorder (javax.swing.border.LineBorder)1 BasicSplitPaneDivider (javax.swing.plaf.basic.BasicSplitPaneDivider)1 BasicSplitPaneUI (javax.swing.plaf.basic.BasicSplitPaneUI)1