mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
UI: added test card render modes dialog (available from debug menu);
This commit is contained in:
parent
e1514e0d49
commit
051c3c4ac0
6 changed files with 559 additions and 223 deletions
|
|
@ -16,6 +16,14 @@
|
|||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuDebugTestModalDialogActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="menuDebugTestCardRenderModesDialog">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Test Card Render Modes"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuDebugTestCardRenderModesDialogActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</NonVisualComponents>
|
||||
|
|
|
|||
|
|
@ -827,6 +827,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
|
||||
popupDebug = new javax.swing.JPopupMenu();
|
||||
menuDebugTestModalDialog = new javax.swing.JMenuItem();
|
||||
menuDebugTestCardRenderModesDialog = new javax.swing.JMenuItem();
|
||||
desktopPane = new MageJDesktop();
|
||||
mageToolbar = new javax.swing.JToolBar();
|
||||
btnPreferences = new javax.swing.JButton();
|
||||
|
|
@ -857,6 +858,14 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
});
|
||||
popupDebug.add(menuDebugTestModalDialog);
|
||||
|
||||
menuDebugTestCardRenderModesDialog.setText("Test Card Render Modes");
|
||||
menuDebugTestCardRenderModesDialog.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
menuDebugTestCardRenderModesDialogActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
popupDebug.add(menuDebugTestCardRenderModesDialog);
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
setMinimumSize(new java.awt.Dimension(1024, 768));
|
||||
|
||||
|
|
@ -995,16 +1004,16 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 838, Short.MAX_VALUE)
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 838, Short.MAX_VALUE)
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(2, 2, 2)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE))
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(2, 2, 2)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
|
|
@ -1079,6 +1088,11 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
popupDebug.show(evt.getComponent(), 0, evt.getComponent().getHeight());
|
||||
}//GEN-LAST:event_btnDebugMouseClicked
|
||||
|
||||
private void menuDebugTestCardRenderModesDialogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuDebugTestCardRenderModesDialogActionPerformed
|
||||
final TestCardRenderDialog dialog = new TestCardRenderDialog();
|
||||
dialog.showDialog();
|
||||
}//GEN-LAST:event_menuDebugTestCardRenderModesDialogActionPerformed
|
||||
|
||||
public void downloadImages() {
|
||||
DownloadPicturesService.startDownload();
|
||||
}
|
||||
|
|
@ -1328,6 +1342,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
private javax.swing.JToolBar.Separator jSeparatorImages;
|
||||
private javax.swing.JToolBar.Separator jSeparatorSymbols;
|
||||
private javax.swing.JToolBar mageToolbar;
|
||||
private javax.swing.JMenuItem menuDebugTestCardRenderModesDialog;
|
||||
private javax.swing.JMenuItem menuDebugTestModalDialog;
|
||||
private javax.swing.JPopupMenu popupDebug;
|
||||
private javax.swing.JToolBar.Separator separatorDebug;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="578" max="32767" attributes="0"/>
|
||||
<Component id="buttonCancel" min="-2" pref="100" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="cardArea1" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="88" max="32767" attributes="0"/>
|
||||
<Component id="cardArea1" min="-2" pref="327" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="buttonCancel" min="-2" pref="30" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="buttonCancel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Close"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="mage.client.cards.CardArea" name="cardArea1">
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jButton1"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
|
@ -0,0 +1,223 @@
|
|||
package mage.client.dialog;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardGraphicInfo;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.cards.repository.ExpansionInfo;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.constants.MultiplayerAttackOption;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import mage.game.Game;
|
||||
import mage.game.GameImpl;
|
||||
import mage.game.match.MatchType;
|
||||
import mage.game.mulligan.Mulligan;
|
||||
import mage.game.mulligan.VancouverMulligan;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.players.Player;
|
||||
import mage.players.StubPlayer;
|
||||
import mage.view.CardsView;
|
||||
import mage.view.PermanentView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class TestCardRenderDialog extends MageDialog {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(TestCardRenderDialog.class);
|
||||
|
||||
public TestCardRenderDialog() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
public void showDialog() {
|
||||
this.setModal(false);
|
||||
getRootPane().setDefaultButton(buttonCancel);
|
||||
|
||||
// windows settings
|
||||
MageFrame.getDesktop().remove(this);
|
||||
if (this.isModal()) {
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
||||
} else {
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||
}
|
||||
this.makeWindowCentered();
|
||||
|
||||
// Close on "ESC"
|
||||
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private void onCancel() {
|
||||
this.removeDialog();
|
||||
}
|
||||
|
||||
private PermanentView createCard(Game game, UUID controllerId, String code, String cardNumber, int damage) {
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(code, cardNumber);
|
||||
ExpansionInfo setInfo = ExpansionRepository.instance.getSetByCode(code);
|
||||
CardSetInfo testSet = new CardSetInfo(cardInfo.getName(), setInfo.getCode(), cardNumber, cardInfo.getRarity(),
|
||||
new CardGraphicInfo(cardInfo.getFrameStyle(), cardInfo.usesVariousArt()));
|
||||
Card card = CardImpl.createCard(cardInfo.getClassName(), testSet);
|
||||
|
||||
PermanentCard perm = new PermanentCard(card, controllerId, game);
|
||||
if (damage > 0) {
|
||||
perm.damage(damage, null, game);
|
||||
}
|
||||
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() {
|
||||
|
||||
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();
|
||||
game.addPlayer(player, deck);
|
||||
|
||||
BigCard big = new BigCard();
|
||||
CardsView view = new CardsView();
|
||||
PermanentView card;
|
||||
card = createCard(game, player.getId(), "RNA", "263", 0); // mountain
|
||||
view.put(card.getId(), card);
|
||||
card = createCard(game, player.getId(), "RNA", "185", 0); // Judith, the Scourge Diva
|
||||
view.put(card.getId(), card);
|
||||
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
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonCancel;
|
||||
private mage.client.cards.CardArea cardArea1;
|
||||
private javax.swing.JButton jButton1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
class TestGame extends GameImpl {
|
||||
|
||||
private int numPlayers;
|
||||
|
||||
public TestGame(MultiplayerAttackOption attackOption, RangeOfInfluence range, Mulligan mulligan, int startLife) {
|
||||
super(attackOption, range, mulligan, startLife);
|
||||
}
|
||||
|
||||
public TestGame(final TestGame game) {
|
||||
super(game);
|
||||
this.numPlayers = game.numPlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatchType getGameType() {
|
||||
return new TestGameType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumPlayers() {
|
||||
return numPlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestGame copy() {
|
||||
return new TestGame(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TestGameType extends MatchType {
|
||||
|
||||
public TestGameType() {
|
||||
this.name = "Test Game Type";
|
||||
this.maxPlayers = 10;
|
||||
this.minPlayers = 3;
|
||||
this.numTeams = 0;
|
||||
this.useAttackOption = true;
|
||||
this.useRange = true;
|
||||
this.sideboardingAllowed = true;
|
||||
}
|
||||
|
||||
protected TestGameType(final TestGameType matchType) {
|
||||
super(matchType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestGameType copy() {
|
||||
return new TestGameType(this);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue