forked from External/mage
UI: improved card render test dialog (added render mode and size choose);
This commit is contained in:
parent
998044068d
commit
c45f64bdec
18 changed files with 1710 additions and 1547 deletions
|
|
@ -11,6 +11,7 @@ import mage.cards.repository.ExpansionInfo;
|
|||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
import mage.constants.MultiplayerAttackOption;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import mage.game.Game;
|
||||
|
|
@ -26,6 +27,7 @@ import mage.view.PermanentView;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -35,6 +37,7 @@ import java.util.UUID;
|
|||
public class TestCardRenderDialog extends MageDialog {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(TestCardRenderDialog.class);
|
||||
float cardSizeMod = 1.0f;
|
||||
|
||||
public TestCardRenderDialog() {
|
||||
initComponents();
|
||||
|
|
@ -43,6 +46,7 @@ public class TestCardRenderDialog extends MageDialog {
|
|||
public void showDialog() {
|
||||
this.setModal(false);
|
||||
getRootPane().setDefaultButton(buttonCancel);
|
||||
reloadCards();
|
||||
|
||||
// windows settings
|
||||
MageFrame.getDesktop().remove(this);
|
||||
|
|
@ -74,77 +78,17 @@ public class TestCardRenderDialog extends MageDialog {
|
|||
if (damage > 0) {
|
||||
perm.damage(damage, null, game);
|
||||
}
|
||||
perm.removeSummoningSickness();
|
||||
PermanentView cardView = new PermanentView(perm, card, controllerId, game);
|
||||
cardView.setInViewerOnly(true);
|
||||
|
||||
return cardView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
private void reloadCards() {
|
||||
cardsPanel.cleanUp();
|
||||
cardsPanel.setCustomRenderMode(comboRenderMode.getSelectedIndex());
|
||||
|
||||
buttonCancel = new javax.swing.JButton();
|
||||
cardArea1 = new mage.client.cards.CardArea();
|
||||
jButton1 = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
buttonCancel.setText("Close");
|
||||
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonCancelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jButton1.setText("jButton1");
|
||||
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton1ActionPerformed(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.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 578, Short.MAX_VALUE)
|
||||
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(cardArea1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jButton1)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jButton1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 88, Short.MAX_VALUE)
|
||||
.addComponent(cardArea1, javax.swing.GroupLayout.PREFERRED_SIZE, 327, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
|
||||
onCancel();
|
||||
}//GEN-LAST:event_buttonCancelActionPerformed
|
||||
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
Game game = new TestGame(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, new VancouverMulligan(0), 20);
|
||||
Player player = new StubPlayer("player1", RangeOfInfluence.ALL);
|
||||
Deck deck = new Deck();
|
||||
|
|
@ -160,13 +104,147 @@ public class TestCardRenderDialog extends MageDialog {
|
|||
card = createCard(game, player.getId(), "RNA", "14", 1); // Knight of Sorrows
|
||||
view.put(card.getId(), card);
|
||||
|
||||
cardArea1.loadCards(view, big, null);
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
cardsPanel.setCustomCardSize(new Dimension(getCardWidth(), getCardHeight()));
|
||||
cardsPanel.changeGUISize();
|
||||
|
||||
cardsPanel.loadCards(view, big, null);
|
||||
}
|
||||
|
||||
private int getCardWidth() {
|
||||
if (GUISizeHelper.editorCardDimension == null) {
|
||||
return 200;
|
||||
}
|
||||
return (int) (GUISizeHelper.editorCardDimension.width * cardSizeMod);
|
||||
}
|
||||
|
||||
private int getCardHeight() {
|
||||
return (int) (1.4 * getCardWidth());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
buttonCancel = new javax.swing.JButton();
|
||||
cardsPanel = new mage.client.cards.CardArea();
|
||||
buttonReloadCards = new javax.swing.JButton();
|
||||
labelRenderMode = new javax.swing.JLabel();
|
||||
comboRenderMode = new javax.swing.JComboBox<>();
|
||||
sliderSize = new javax.swing.JSlider();
|
||||
labelSize = new javax.swing.JLabel();
|
||||
|
||||
buttonCancel.setText("Close");
|
||||
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonCancelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonReloadCards.setText("Reload cards");
|
||||
buttonReloadCards.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonReloadCardsActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
labelRenderMode.setText("Render mode:");
|
||||
|
||||
comboRenderMode.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"MTGO", "Image"}));
|
||||
comboRenderMode.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
comboRenderModeItemStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
sliderSize.setValue(25);
|
||||
sliderSize.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||
public void stateChanged(javax.swing.event.ChangeEvent evt) {
|
||||
sliderSizeStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
labelSize.setText("Card size:");
|
||||
|
||||
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.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 578, Short.MAX_VALUE)
|
||||
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(cardsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(buttonReloadCards)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(labelRenderMode)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(comboRenderMode, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(labelSize)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(sliderSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonReloadCards)
|
||||
.addComponent(labelRenderMode)
|
||||
.addComponent(comboRenderMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(labelSize))
|
||||
.addComponent(sliderSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cardsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
|
||||
onCancel();
|
||||
}//GEN-LAST:event_buttonCancelActionPerformed
|
||||
|
||||
private void buttonReloadCardsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReloadCardsActionPerformed
|
||||
reloadCards();
|
||||
}//GEN-LAST:event_buttonReloadCardsActionPerformed
|
||||
|
||||
private void comboRenderModeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboRenderModeItemStateChanged
|
||||
reloadCards();
|
||||
}//GEN-LAST:event_comboRenderModeItemStateChanged
|
||||
|
||||
private void sliderSizeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderSizeStateChanged
|
||||
// from DragCardGrid
|
||||
// Fraction in [-1, 1]
|
||||
float sliderFrac = ((float) (sliderSize.getValue() - 50)) / 50;
|
||||
// Convert to frac in [0.5, 2.0] exponentially
|
||||
cardSizeMod = (float) Math.pow(2, sliderFrac);
|
||||
reloadCards();
|
||||
}//GEN-LAST:event_sliderSizeStateChanged
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonCancel;
|
||||
private mage.client.cards.CardArea cardArea1;
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JButton buttonReloadCards;
|
||||
private mage.client.cards.CardArea cardsPanel;
|
||||
private javax.swing.JComboBox<String> comboRenderMode;
|
||||
private javax.swing.JLabel labelRenderMode;
|
||||
private javax.swing.JLabel labelSize;
|
||||
private javax.swing.JSlider sliderSize;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue