forked from External/mage
add land dialog for drafting deck construction
This commit is contained in:
parent
f74df18cc9
commit
a48c7b1ff1
2 changed files with 389 additions and 0 deletions
226
Mage.Client/src/main/java/mage/client/dialog/AddLandDialog.java
Normal file
226
Mage.Client/src/main/java/mage/client/dialog/AddLandDialog.java
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
/*
|
||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
/*
|
||||
* AddLandDialog.java
|
||||
*
|
||||
* Created on Jan 11, 2011, 1:20:45 PM
|
||||
*/
|
||||
|
||||
package mage.client.dialog;
|
||||
|
||||
import javax.swing.JLayeredPane;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.client.MageFrame;
|
||||
import mage.sets.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class AddLandDialog extends MageDialog {
|
||||
|
||||
private Deck deck;
|
||||
|
||||
/** Creates new form AddLandDialog */
|
||||
public AddLandDialog() {
|
||||
initComponents();
|
||||
this.setModal(true);
|
||||
}
|
||||
|
||||
public void showDialog(Deck deck) {
|
||||
this.deck = deck;
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jButton2 = new javax.swing.JButton();
|
||||
lblForest = new javax.swing.JLabel();
|
||||
spnForest = new javax.swing.JSpinner();
|
||||
spnIsland = new javax.swing.JSpinner();
|
||||
lblIsland = new javax.swing.JLabel();
|
||||
lblPains = new javax.swing.JLabel();
|
||||
spnPlains = new javax.swing.JSpinner();
|
||||
spnMountain = new javax.swing.JSpinner();
|
||||
lblMountain = new javax.swing.JLabel();
|
||||
spnSwamp = new javax.swing.JSpinner();
|
||||
lblSwamp = new javax.swing.JLabel();
|
||||
btnAdd = new javax.swing.JButton();
|
||||
btnCancel = new javax.swing.JButton();
|
||||
|
||||
jButton2.setText("jButton2");
|
||||
|
||||
setTitle("Add Land");
|
||||
|
||||
lblForest.setText("Forest");
|
||||
|
||||
lblIsland.setText("Island");
|
||||
|
||||
lblPains.setText("Plains");
|
||||
|
||||
lblMountain.setText("Mountain");
|
||||
|
||||
lblSwamp.setText("Swamp");
|
||||
|
||||
btnAdd.setText("Add");
|
||||
btnAdd.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnAddActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
btnCancel.setText("Cancel");
|
||||
btnCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnCancelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(lblPains)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spnPlains, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(lblMountain)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spnMountain, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(lblIsland)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spnIsland, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(lblForest)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spnForest, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(lblSwamp)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spnSwamp, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap(50, Short.MAX_VALUE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap(25, Short.MAX_VALUE)
|
||||
.addComponent(btnCancel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnAdd)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblForest)
|
||||
.addComponent(spnForest, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblIsland)
|
||||
.addComponent(spnIsland, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblMountain)
|
||||
.addComponent(spnMountain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblPains)
|
||||
.addComponent(spnPlains, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblSwamp)
|
||||
.addComponent(spnSwamp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnAdd)
|
||||
.addComponent(btnCancel))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
this.setVisible(false);
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
||||
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
|
||||
int nForest = ((Number)spnForest.getValue()).intValue();
|
||||
for (int i = 0; i < nForest; i++) {
|
||||
deck.getCards().add(Sets.findCard("Forest", true));
|
||||
}
|
||||
int nIsland = ((Number)spnIsland.getValue()).intValue();
|
||||
for (int i = 0; i < nIsland; i++) {
|
||||
deck.getCards().add(Sets.findCard("Island", true));
|
||||
}
|
||||
int nMountain = ((Number)spnMountain.getValue()).intValue();
|
||||
for (int i = 0; i < nMountain; i++) {
|
||||
deck.getCards().add(Sets.findCard("Mountain", true));
|
||||
}
|
||||
int nPlains = ((Number)spnPlains.getValue()).intValue();
|
||||
for (int i = 0; i < nPlains; i++) {
|
||||
deck.getCards().add(Sets.findCard("Plains", true));
|
||||
}
|
||||
int nSwamp = ((Number)spnSwamp.getValue()).intValue();
|
||||
for (int i = 0; i < nSwamp; i++) {
|
||||
deck.getCards().add(Sets.findCard("Swamp", true));
|
||||
}
|
||||
this.setVisible(false);
|
||||
}//GEN-LAST:event_btnAddActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnAdd;
|
||||
private javax.swing.JButton btnCancel;
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JLabel lblForest;
|
||||
private javax.swing.JLabel lblIsland;
|
||||
private javax.swing.JLabel lblMountain;
|
||||
private javax.swing.JLabel lblPains;
|
||||
private javax.swing.JLabel lblSwamp;
|
||||
private javax.swing.JSpinner spnForest;
|
||||
private javax.swing.JSpinner spnIsland;
|
||||
private javax.swing.JSpinner spnMountain;
|
||||
private javax.swing.JSpinner spnPlains;
|
||||
private javax.swing.JSpinner spnSwamp;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue