diff --git a/Mage.Client/sounds/OnCountdown1.wav b/Mage.Client/sounds/OnCountdown1.wav new file mode 100644 index 0000000000..5ab29bf462 Binary files /dev/null and b/Mage.Client/sounds/OnCountdown1.wav differ diff --git a/Mage.Client/sounds/OnDraftSelect.wav b/Mage.Client/sounds/OnDraftSelect.wav new file mode 100644 index 0000000000..cd8a5c09db Binary files /dev/null and b/Mage.Client/sounds/OnDraftSelect.wav differ diff --git a/Mage.Client/sounds/OnPlayerLeft.wav b/Mage.Client/sounds/OnPlayerLeft.wav index d0a73d6577..c0590e8489 100644 Binary files a/Mage.Client/sounds/OnPlayerLeft.wav and b/Mage.Client/sounds/OnPlayerLeft.wav differ diff --git a/Mage.Client/sounds/OnPlayerLost.wav b/Mage.Client/sounds/OnPlayerLost.wav index 4516bc32b9..4fd3e50fb1 100644 Binary files a/Mage.Client/sounds/OnPlayerLost.wav and b/Mage.Client/sounds/OnPlayerLost.wav differ diff --git a/Mage.Client/sounds/OnPlayerQuit.wav b/Mage.Client/sounds/OnPlayerQuit.wav index df359d5b9f..d9b2826d1e 100644 Binary files a/Mage.Client/sounds/OnPlayerQuit.wav and b/Mage.Client/sounds/OnPlayerQuit.wav differ diff --git a/Mage.Client/sounds/OnPlayerQuitTournament.wav b/Mage.Client/sounds/OnPlayerQuitTournament.wav index e78a05fba5..c92220b59c 100644 Binary files a/Mage.Client/sounds/OnPlayerQuitTournament.wav and b/Mage.Client/sounds/OnPlayerQuitTournament.wav differ diff --git a/Mage.Client/sounds/OnPlayerSubmittedDeck.wav b/Mage.Client/sounds/OnPlayerSubmittedDeck.wav index cd96bf2bad..cfa7603c0f 100644 Binary files a/Mage.Client/sounds/OnPlayerSubmittedDeck.wav and b/Mage.Client/sounds/OnPlayerSubmittedDeck.wav differ diff --git a/Mage.Client/sounds/OnPlayerWon.wav b/Mage.Client/sounds/OnPlayerWon.wav index 5ded1a31e6..3c9eda4625 100644 Binary files a/Mage.Client/sounds/OnPlayerWon.wav and b/Mage.Client/sounds/OnPlayerWon.wav differ diff --git a/Mage.Client/sounds/OnSkipButton.wav b/Mage.Client/sounds/OnSkipButton.wav new file mode 100644 index 0000000000..7d321fc19f Binary files /dev/null and b/Mage.Client/sounds/OnSkipButton.wav differ diff --git a/Mage.Client/sounds/OnSkipButtonCancel.wav b/Mage.Client/sounds/OnSkipButtonCancel.wav new file mode 100644 index 0000000000..cb0b80dbf8 Binary files /dev/null and b/Mage.Client/sounds/OnSkipButtonCancel.wav differ diff --git a/Mage.Client/sounds/OnStackNew.wav b/Mage.Client/sounds/OnStackNew.wav index b7dc8ca98c..4fd917b8e8 100644 Binary files a/Mage.Client/sounds/OnStackNew.wav and b/Mage.Client/sounds/OnStackNew.wav differ diff --git a/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java b/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java index 6366b6d154..bcbcb99103 100644 --- a/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java +++ b/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java @@ -48,6 +48,7 @@ import mage.client.plugins.impl.Plugins; import mage.client.util.CardViewRarityComparator; import mage.client.util.Event; import mage.client.util.Listener; +import mage.client.util.audio.AudioManager; import mage.constants.Constants; import mage.view.CardView; import mage.view.CardsView; @@ -63,13 +64,18 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener { protected CardEventSource cardEventSource = new CardEventSource(); protected BigCard bigCard; + protected MageCard markedCard; + protected boolean noSound; /** Creates new form DraftGrid */ public DraftGrid() { initComponents(); + markedCard = null; + noSound= true; } public void clear() { + markedCard = null; this.clearCardEventListeners(); for (Component comp: getComponents()) { if (comp instanceof Card || comp instanceof MageCard) { @@ -79,6 +85,14 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener { } public void loadBooster(CardsView booster, BigCard bigCard) { + if (booster instanceof CardsView && booster.size() == 0) { + noSound = true; + } else { + if (!noSound) { + AudioManager.playOnDraftSelect(); + } + noSound = false; + } this.bigCard = bigCard; this.removeAll(); @@ -111,7 +125,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener { Rectangle rectangle = new Rectangle(cardDimension.frameWidth, cardDimension.frameHeight); Dimension dimension = new Dimension(cardDimension.frameWidth, cardDimension.frameHeight); - List sortedCards = new ArrayList(booster.values()); + List sortedCards = new ArrayList<>(booster.values()); Collections.sort(sortedCards, new CardViewRarityComparator()); for (CardView card: sortedCards) { MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, dimension, null, true); @@ -173,11 +187,27 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener { @Override public void mousePressed(MouseEvent e) { - Object obj = e.getSource(); - if (obj instanceof MageCard) { - this.cardEventSource.doubleClick(((MageCard)obj).getOriginal(), "pick-a-card"); - this.hidePopup(); + if (e.getButton() == MouseEvent.BUTTON1) { // only left click select + Object obj = e.getSource(); + if (obj instanceof MageCard) { + this.cardEventSource.doubleClick(((MageCard)obj).getOriginal(), "pick-a-card"); + this.hidePopup(); + AudioManager.playOnDraftSelect(); + } } + if (e.getButton() == MouseEvent.BUTTON3) { // only right click mark + Object obj = e.getSource(); + if (obj instanceof MageCard) { + if (this.markedCard != null) { + markedCard.setSelected(false); + } + this.cardEventSource.doubleClick(((MageCard)obj).getOriginal(), "mark-a-card"); + markedCard = ((MageCard)obj); + markedCard.setSelected(true); + repaint(); + } + } + } @Override diff --git a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form index 899227d950..3f2a8b447f 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form +++ b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.form @@ -24,7 +24,7 @@ - + @@ -885,7 +885,7 @@ - + @@ -899,7 +899,7 @@ - + @@ -921,7 +921,10 @@ - + + + + @@ -931,11 +934,24 @@ - - - - - + + + + + + + + + + + + + + + + + + @@ -945,11 +961,6 @@ - - - - - @@ -973,7 +984,7 @@ - + diff --git a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java index 0464fae109..e233e5eaf5 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java @@ -98,6 +98,8 @@ public class PreferencesDialog extends javax.swing.JDialog { public static final String KEY_BATTLEFIELD_IMAGE_DEFAULT = "battlefieldImageDefault"; public static final String KEY_SOUNDS_GAME_ON = "soundsOn"; + public static final String KEY_SOUNDS_DRAFT_ON = "soundsDraftOn"; + public static final String KEY_SOUNDS_SKIP_BUTTONS_ON = "soundsSkipButtonsOn"; public static final String KEY_SOUNDS_OTHER_ON = "soundsOtherOn"; public static final String KEY_SOUNDS_MATCH_MUSIC_ON = "soundsMatchMusicOn"; public static final String KEY_SOUNDS_MATCH_MUSIC_PATH = "soundsMatchMusicPath"; @@ -369,6 +371,8 @@ public class PreferencesDialog extends javax.swing.JDialog { tabSounds = new javax.swing.JPanel(); sounds_clips = new javax.swing.JPanel(); cbEnableGameSounds = new javax.swing.JCheckBox(); + cbEnableDraftSounds = new javax.swing.JCheckBox(); + cbEnableSkipButtonsSounds = new javax.swing.JCheckBox(); cbEnableOtherSounds = new javax.swing.JCheckBox(); sounds_backgroundMusic = new javax.swing.JPanel(); cbEnableBattlefieldBGM = new javax.swing.JCheckBox(); @@ -919,7 +923,7 @@ public class PreferencesDialog extends javax.swing.JDialog { tabsPanel.addTab("Images", tabImages); sounds_clips.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Clips")); - sounds_clips.setLayout(new java.awt.BorderLayout()); + sounds_clips.setLayout(new java.awt.GridLayout(4, 0)); cbEnableGameSounds.setText("Enable game sounds"); cbEnableGameSounds.setToolTipText("Sounds that will be played for certain actions (e.g. play land, attack, etc.) during the game."); @@ -928,7 +932,25 @@ public class PreferencesDialog extends javax.swing.JDialog { cbEnableGameSoundsActionPerformed(evt); } }); - sounds_clips.add(cbEnableGameSounds, java.awt.BorderLayout.PAGE_START); + sounds_clips.add(cbEnableGameSounds); + + cbEnableDraftSounds.setText("Enable draft sounds"); + cbEnableDraftSounds.setToolTipText("Sounds that will be played during drafting for card picking or warining if time runs out."); + cbEnableDraftSounds.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cbEnableDraftSoundsActionPerformed(evt); + } + }); + sounds_clips.add(cbEnableDraftSounds); + + cbEnableSkipButtonsSounds.setText("Enable skip button sounds"); + cbEnableSkipButtonsSounds.setToolTipText("Sounds that will be played if a priority skip action (F4/F5/F7/F9) or cancel skip action (F3) is used."); + cbEnableSkipButtonsSounds.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cbEnableSkipButtonsSoundsActionPerformed(evt); + } + }); + sounds_clips.add(cbEnableSkipButtonsSounds); cbEnableOtherSounds.setText("Enable other sounds"); cbEnableOtherSounds.setToolTipText("Sounds that will be played for actions outside of games (e.g. whisper, player joins your game, player submits a deck ...)."); @@ -937,7 +959,7 @@ public class PreferencesDialog extends javax.swing.JDialog { cbEnableOtherSoundsActionPerformed(evt); } }); - sounds_clips.add(cbEnableOtherSounds, java.awt.BorderLayout.PAGE_END); + sounds_clips.add(cbEnableOtherSounds); sounds_backgroundMusic.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Music")); @@ -974,7 +996,7 @@ public class PreferencesDialog extends javax.swing.JDialog { .addContainerGap() .addComponent(jLabel16) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(txtBattlefieldIBGMPath, javax.swing.GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE) + .addComponent(txtBattlefieldIBGMPath) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnBattlefieldBGMBrowse)) .addGroup(sounds_backgroundMusicLayout.createSequentialGroup() @@ -999,7 +1021,7 @@ public class PreferencesDialog extends javax.swing.JDialog { .addGroup(tabSoundsLayout.createSequentialGroup() .addContainerGap() .addGroup(tabSoundsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(sounds_clips, javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE) + .addComponent(sounds_clips, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(sounds_backgroundMusic, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); @@ -1010,7 +1032,7 @@ public class PreferencesDialog extends javax.swing.JDialog { .addComponent(sounds_clips, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(sounds_backgroundMusic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(235, Short.MAX_VALUE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); sounds_clips.getAccessibleContext().setAccessibleDescription(""); @@ -1424,7 +1446,7 @@ public class PreferencesDialog extends javax.swing.JDialog { getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(tabsPanel) + .addComponent(tabsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 566, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(saveButton) @@ -1493,6 +1515,8 @@ public class PreferencesDialog extends javax.swing.JDialog { // sounds save(prefs, dialog.cbEnableGameSounds, KEY_SOUNDS_GAME_ON, "true", "false", UPDATE_CACHE_POLICY); + save(prefs, dialog.cbEnableDraftSounds, KEY_SOUNDS_DRAFT_ON, "true", "false", UPDATE_CACHE_POLICY); + save(prefs, dialog.cbEnableSkipButtonsSounds, KEY_SOUNDS_SKIP_BUTTONS_ON, "true", "false", UPDATE_CACHE_POLICY); save(prefs, dialog.cbEnableOtherSounds, KEY_SOUNDS_OTHER_ON, "true", "false", UPDATE_CACHE_POLICY); save(prefs, dialog.cbEnableBattlefieldBGM, KEY_SOUNDS_MATCH_MUSIC_ON, "true", "false", UPDATE_CACHE_POLICY); saveSoundPath(prefs); @@ -1753,6 +1777,14 @@ public class PreferencesDialog extends javax.swing.JDialog { // TODO add your handling code here: }//GEN-LAST:event_cbStopOnAllEndActionPerformed + private void cbEnableDraftSoundsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbEnableDraftSoundsActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_cbEnableDraftSoundsActionPerformed + + private void cbEnableSkipButtonsSoundsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbEnableSkipButtonsSoundsActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_cbEnableSkipButtonsSoundsActionPerformed + private void showProxySettings() { if (cbProxyType.getSelectedItem() == Connection.ProxyType.SOCKS) { this.pnlProxy.setVisible(true); @@ -1829,19 +1861,19 @@ public class PreferencesDialog extends javax.swing.JDialog { load(prefs, dialog.showAbilityPickerForced, KEY_SHOW_ABILITY_PICKER_FORCED, "true"); load(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true"); - load(prefs, dialog.checkBoxUpkeepYou, UPKEEP_YOU, "on","off"); - load(prefs, dialog.checkBoxDrawYou, DRAW_YOU, "on","off"); + load(prefs, dialog.checkBoxUpkeepYou, UPKEEP_YOU, "on","on"); + load(prefs, dialog.checkBoxDrawYou, DRAW_YOU, "on","on"); load(prefs, dialog.checkBoxMainYou, MAIN_YOU, "on","on"); - load(prefs, dialog.checkBoxBeforeCYou, BEFORE_COMBAT_YOU, "on","off"); - load(prefs, dialog.checkBoxEndOfCYou, END_OF_COMBAT_YOU, "on","off"); + load(prefs, dialog.checkBoxBeforeCYou, BEFORE_COMBAT_YOU, "on","on"); + load(prefs, dialog.checkBoxEndOfCYou, END_OF_COMBAT_YOU, "on","on"); load(prefs, dialog.checkBoxMain2You, MAIN_2_YOU, "on","on"); - load(prefs, dialog.checkBoxEndTurnYou, END_OF_TURN_YOU, "on","off"); + load(prefs, dialog.checkBoxEndTurnYou, END_OF_TURN_YOU, "on","on"); - load(prefs, dialog.checkBoxUpkeepOthers, UPKEEP_OTHERS, "on","off"); - load(prefs, dialog.checkBoxDrawOthers, DRAW_OTHERS, "on","off"); + load(prefs, dialog.checkBoxUpkeepOthers, UPKEEP_OTHERS, "on","on"); + load(prefs, dialog.checkBoxDrawOthers, DRAW_OTHERS, "on","on"); load(prefs, dialog.checkBoxMainOthers, MAIN_OTHERS, "on","on"); load(prefs, dialog.checkBoxBeforeCOthers, BEFORE_COMBAT_OTHERS, "on","on"); - load(prefs, dialog.checkBoxEndOfCOthers, END_OF_COMBAT_OTHERS, "on","off"); + load(prefs, dialog.checkBoxEndOfCOthers, END_OF_COMBAT_OTHERS, "on","on"); load(prefs, dialog.checkBoxMain2Others, MAIN_2_OTHERS, "on","on"); load(prefs, dialog.checkBoxEndTurnOthers, END_OF_TURN_OTHERS, "on","on"); @@ -1905,26 +1937,13 @@ public class PreferencesDialog extends javax.swing.JDialog { } private static void loadSoundSettings(Preferences prefs) { - String prop = prefs.get(KEY_SOUNDS_GAME_ON, "true"); - if (prop.equals("true")) { - dialog.cbEnableGameSounds.setSelected(true); - } else { - dialog.cbEnableGameSounds.setSelected(false); - } - prop = prefs.get(KEY_SOUNDS_OTHER_ON, "true"); - if (prop.equals("true")) { - dialog.cbEnableOtherSounds.setSelected(true); - } else { - dialog.cbEnableOtherSounds.setSelected(false); - } + dialog.cbEnableGameSounds.setSelected(prefs.get(KEY_SOUNDS_GAME_ON, "true").equals("true")); + dialog.cbEnableDraftSounds.setSelected(prefs.get(KEY_SOUNDS_DRAFT_ON, "true").equals("true")); + dialog.cbEnableSkipButtonsSounds.setSelected(prefs.get(KEY_SOUNDS_SKIP_BUTTONS_ON, "true").equals("true")); + dialog.cbEnableOtherSounds.setSelected(prefs.get(KEY_SOUNDS_OTHER_ON, "true").equals("true")); // Match music - prop = prefs.get(KEY_SOUNDS_MATCH_MUSIC_ON, "true"); - if (prop.equals("true")) { - dialog.cbEnableBattlefieldBGM.setSelected(true); - } else { - dialog.cbEnableBattlefieldBGM.setSelected(false); - } + dialog.cbEnableBattlefieldBGM.setSelected(prefs.get(KEY_SOUNDS_MATCH_MUSIC_ON, "true").equals("true")); dialog.txtBattlefieldIBGMPath.setEnabled(dialog.cbEnableBattlefieldBGM.isSelected()); dialog.btnBattlefieldBGMBrowse.setEnabled(dialog.cbEnableBattlefieldBGM.isSelected()); // load and save the path always, so you can reactivate music without selecting path again @@ -2187,8 +2206,10 @@ public class PreferencesDialog extends javax.swing.JDialog { private javax.swing.JButton btnBrowseImageLocation; private javax.swing.JCheckBox cbCheckForNewImages; private javax.swing.JCheckBox cbEnableBattlefieldBGM; + private javax.swing.JCheckBox cbEnableDraftSounds; private javax.swing.JCheckBox cbEnableGameSounds; private javax.swing.JCheckBox cbEnableOtherSounds; + private javax.swing.JCheckBox cbEnableSkipButtonsSounds; private javax.swing.JCheckBox cbGameLogAutoSave; private javax.swing.JComboBox cbPreferedImageLanguage; private javax.swing.JComboBox cbProxyType; diff --git a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.form b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.form index 471863787c..bd3e959f2c 100644 --- a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.form +++ b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.form @@ -68,10 +68,13 @@ - + - + + + + @@ -80,15 +83,24 @@ - - - - + + + + + + + + + + + + + - + @@ -97,7 +109,7 @@ - + @@ -110,10 +122,12 @@ - - - - + + + + + + @@ -133,7 +147,10 @@ - + + + + @@ -210,6 +227,11 @@ + + + + + diff --git a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java index 8070a63214..99988e1faa 100644 --- a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java +++ b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java @@ -46,6 +46,7 @@ import mage.client.plugins.impl.Plugins; import mage.client.util.CardsViewUtil; import mage.client.util.Event; import mage.client.util.Listener; +import mage.client.util.audio.AudioManager; import mage.remote.Session; import mage.view.CardsView; import mage.view.DraftPickView; @@ -140,6 +141,10 @@ public class DraftPanel extends javax.swing.JPanel { setMessage("Waiting for other players"); } } + if (event.getEventName().equals("mark-a-card")) { + SimpleCardView source = (SimpleCardView) event.getSource(); + session.sendCardMark(draftId, source.getId()); + } } } ); @@ -167,6 +172,9 @@ public class DraftPanel extends javax.swing.JPanel { text = text + Integer.toString(second); } this.txtTimeRemaining.setText(text); + if (s==6) { + AudioManager.playOnCountdown1(); + } } public void hideDraft() { @@ -206,6 +214,7 @@ public class DraftPanel extends javax.swing.JPanel { chkPack3 = new javax.swing.JCheckBox(); lblCardNo = new javax.swing.JLabel(); txtCardNo = new javax.swing.JTextField(); + lblTimeRemaining = new javax.swing.JLabel(); txtTimeRemaining = new javax.swing.JTextField(); lblMessage = new javax.swing.JLabel(); bigCard = new mage.client.cards.BigCard(); @@ -244,6 +253,8 @@ public class DraftPanel extends javax.swing.JPanel { txtCardNo.setEditable(false); txtCardNo.setEnabled(false); + lblTimeRemaining.setText("Time:"); + txtTimeRemaining.setEditable(false); txtTimeRemaining.setForeground(java.awt.Color.red); txtTimeRemaining.setHorizontalAlignment(javax.swing.JTextField.CENTER); @@ -268,27 +279,35 @@ public class DraftPanel extends javax.swing.JPanel { .addGroup(javax.swing.GroupLayout.Alignment.LEADING, draftLeftPaneLayout.createSequentialGroup() .addComponent(lblPack1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(txtPack1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(txtPack1, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, draftLeftPaneLayout.createSequentialGroup() - .addComponent(lblPack3) + .addGroup(draftLeftPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(lblPack3) + .addComponent(lblTimeRemaining)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(draftLeftPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtCardNo) .addComponent(txtPack3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(txtTimeRemaining)))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(draftLeftPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(chkPack3) - .addComponent(chkPack2) - .addComponent(chkPack1))) + .addGroup(draftLeftPaneLayout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(draftLeftPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(chkPack3) + .addComponent(chkPack2)) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, draftLeftPaneLayout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(chkPack1) + .addContainerGap()))) .addGroup(draftLeftPaneLayout.createSequentialGroup() - .addComponent(lblMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE) + .addComponent(lblMessage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()))) .addGroup(draftLeftPaneLayout.createSequentialGroup() .addGroup(draftLeftPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(draftLeftPaneLayout.createSequentialGroup() - .addContainerGap() + .addGap(64, 64, 64) .addComponent(btnQuitTournament))) .addGap(0, 0, Short.MAX_VALUE)) ); @@ -297,10 +316,11 @@ public class DraftPanel extends javax.swing.JPanel { .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, draftLeftPaneLayout.createSequentialGroup() .addComponent(btnQuitTournament) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(draftLeftPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(lblPack1) - .addComponent(txtPack1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(chkPack1)) + .addGroup(draftLeftPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(chkPack1) + .addGroup(draftLeftPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(lblPack1) + .addComponent(txtPack1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(draftLeftPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblPack2) @@ -316,7 +336,9 @@ public class DraftPanel extends javax.swing.JPanel { .addComponent(lblCardNo) .addComponent(txtCardNo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(txtTimeRemaining, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(draftLeftPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtTimeRemaining, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lblTimeRemaining)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lblMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) @@ -379,6 +401,7 @@ public class DraftPanel extends javax.swing.JPanel { private javax.swing.JLabel lblPack1; private javax.swing.JLabel lblPack2; private javax.swing.JLabel lblPack3; + private javax.swing.JLabel lblTimeRemaining; private javax.swing.JTextField txtCardNo; private javax.swing.JTextField txtPack1; private javax.swing.JTextField txtPack2; diff --git a/Mage.Client/src/main/java/mage/client/game/GamePanel.java b/Mage.Client/src/main/java/mage/client/game/GamePanel.java index 3d124017c5..e0a4826f2c 100644 --- a/Mage.Client/src/main/java/mage/client/game/GamePanel.java +++ b/Mage.Client/src/main/java/mage/client/game/GamePanel.java @@ -1590,31 +1590,31 @@ public final class GamePanel extends javax.swing.JPanel { private void btnEndTurnActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId); - AudioManager.playNextPhase(); + AudioManager.playOnSkipButton(); updateSkipButtons(true, false, false, false); } private void btnUntilEndOfTurnActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId); - AudioManager.playNextPhase(); + AudioManager.playOnSkipButton(); updateSkipButtons(false, true, false, false); } private void btnUntilNextMainPhaseActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId); - AudioManager.playNextPhase(); + AudioManager.playOnSkipButton(); updateSkipButtons(false, false, true, false); } private void btnPassPriorityUntilNextYourTurnActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId); - AudioManager.playNextPhase(); + AudioManager.playOnSkipButton(); updateSkipButtons(false, false, false, true); } private void restorePriorityActionPerformed(java.awt.event.ActionEvent evt) { session.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId); - AudioManager.playButtonCancel(); + AudioManager.playOnSkipButtonCancel(); updateSkipButtons(false, false, false, false); } diff --git a/Mage.Client/src/main/java/mage/client/util/audio/AudioGroup.java b/Mage.Client/src/main/java/mage/client/util/audio/AudioGroup.java index 1c01118cb0..68d65b78fd 100644 --- a/Mage.Client/src/main/java/mage/client/util/audio/AudioGroup.java +++ b/Mage.Client/src/main/java/mage/client/util/audio/AudioGroup.java @@ -7,5 +7,7 @@ package mage.client.util.audio; */ public enum AudioGroup { GameSounds, + DraftSounds, + SkipSounds, OtherSounds; } diff --git a/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java b/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java index 17e9b3067a..db49897d34 100644 --- a/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java +++ b/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java @@ -37,6 +37,12 @@ public class AudioManager { private MageClip updateStackClip = null; private MageClip onHover = null; + private MageClip onSkipButton = null; + private MageClip onSkipButtonCancel = null; + + private MageClip onCountdown1 = null; + private MageClip onDraftSelect = null; + private MageClip playerJoinedTable = null; private MageClip playerSubmittedDeck = null; private MageClip playerWhispered = null; @@ -137,7 +143,7 @@ public class AudioManager { public static void playButtonCancel() { if (audioManager.buttonCancelClip == null) { audioManager.buttonCancelClip = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnButtonCancel.wav"), - AudioGroup.GameSounds); + AudioGroup.SkipSounds); } checkAndPlayClip(getManager().buttonCancelClip); @@ -191,6 +197,38 @@ public class AudioManager { checkAndPlayClip(getManager().onHover); } + public static void playOnCountdown1() { + if (audioManager.onCountdown1 == null) { + audioManager.onCountdown1 = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnCountdown1.wav"), + AudioGroup.DraftSounds); + } + checkAndPlayClip(getManager().onCountdown1); + } + + public static void playOnDraftSelect() { + if (audioManager.onDraftSelect == null) { + audioManager.onDraftSelect = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnDraftSelect.wav"), + AudioGroup.DraftSounds); + } + checkAndPlayClip(getManager().onDraftSelect); + } + + public static void playOnSkipButton() { + if (audioManager.onSkipButton == null) { + audioManager.onSkipButton = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnSkipButton.wav"), + AudioGroup.SkipSounds); + } + checkAndPlayClip(getManager().onSkipButton); + } + + public static void playOnSkipButtonCancel() { + if (audioManager.onSkipButtonCancel == null) { + audioManager.onSkipButtonCancel = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnSkipButtonCancel.wav"), + AudioGroup.SkipSounds); + } + checkAndPlayClip(getManager().onSkipButtonCancel); + } + public static void playPlayerJoinedTable() { if (audioManager.playerJoinedTable == null) { audioManager.playerJoinedTable = new MageClip(audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPlayerJoinedTable.wav"), @@ -255,6 +293,12 @@ public class AudioManager { case GameSounds: playSound = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SOUNDS_GAME_ON, "true").equals("true"); break; + case DraftSounds: + playSound = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SOUNDS_DRAFT_ON, "true").equals("true"); + break; + case SkipSounds: + playSound = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SOUNDS_SKIP_BUTTONS_ON, "true").equals("true"); + break; case OtherSounds: playSound = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SOUNDS_OTHER_ON, "true").equals("true"); } diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java index 0aa108f445..a927c6c4e4 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java @@ -428,6 +428,8 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti this.isSelected = isSelected; if (isSelected) { this.titleText.setGlowColor(Color.green); + } else { + this.titleText.setGlowColor(Color.black); } // noxx: bad idea is to call repaint in setter method ////repaint(); diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/GlowText.java b/Mage.Client/src/main/java/org/mage/card/arcane/GlowText.java index d49177fa37..6b5378bfeb 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/GlowText.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/GlowText.java @@ -30,6 +30,7 @@ public class GlowText extends JLabel { this.wrap = wrap; } + @Override public Dimension getPreferredSize () { Dimension size = super.getPreferredSize(); size.width += glowSize; @@ -37,12 +38,16 @@ public class GlowText extends JLabel { return size; } + @Override public void setText (String text) { super.setText(text); } + @Override public void paint (Graphics g) { - if (getText().length() == 0) return; + if (getText().length() == 0) { + return; + } Graphics2D g2d = (Graphics2D)g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); @@ -62,14 +67,17 @@ public class GlowText extends JLabel { while (measurer.getPosition() < charIterator.getEndIndex()) { //TextLayout textLayout = measurer.nextLayout(wrapWidth); lineCount++; - if (lineCount > 2) break; + if (lineCount > 2) { + break; + } } charIterator.first(); // Use char wrap if word wrap would cause more than two lines of text. - if (lineCount > 2) + if (lineCount > 2) { measurer = new LineBreakMeasurer(charIterator, BreakIterator.getCharacterInstance(Locale.ENGLISH), fontContext); - else + } else { measurer.setPosition(0); + } while (measurer.getPosition() < charIterator.getEndIndex()) { TextLayout textLayout = measurer.nextLayout(wrapWidth); float ascent = textLayout.getAscent(); diff --git a/Mage.Common/src/mage/interfaces/MageServer.java b/Mage.Common/src/mage/interfaces/MageServer.java index 6530aab614..ea2456cfca 100644 --- a/Mage.Common/src/mage/interfaces/MageServer.java +++ b/Mage.Common/src/mage/interfaces/MageServer.java @@ -131,6 +131,7 @@ public interface MageServer { void joinDraft(UUID draftId, String sessionId) throws MageException; void quitDraft(UUID draftId, String sessionId) throws MageException; DraftPickView sendCardPick(UUID draftId, String sessionId, UUID cardId) throws MageException; + void sendCardMark(UUID draftId, String sessionId, UUID cardId) throws MageException; //challenge methods // void startChallenge(String sessionId, UUID roomId, UUID tableId, UUID challengeId) throws MageException; diff --git a/Mage.Common/src/mage/remote/SessionImpl.java b/Mage.Common/src/mage/remote/SessionImpl.java index de10ba2fc3..c879dd6628 100644 --- a/Mage.Common/src/mage/remote/SessionImpl.java +++ b/Mage.Common/src/mage/remote/SessionImpl.java @@ -771,6 +771,20 @@ public class SessionImpl implements Session { return null; } + @Override + public DraftPickView sendCardMark(UUID draftId, UUID cardId) { + try { + if (isConnected()) { + server.sendCardMark(draftId, sessionId, cardId); + } + } catch (MageException ex) { + handleMageException(ex); + } catch (Throwable t) { + handleThrowable(t); + } + return null; + } + @Override public boolean joinChat(UUID chatId) { try { diff --git a/Mage.Common/src/mage/remote/interfaces/GamePlay.java b/Mage.Common/src/mage/remote/interfaces/GamePlay.java index eb387c4206..3c08a51799 100644 --- a/Mage.Common/src/mage/remote/interfaces/GamePlay.java +++ b/Mage.Common/src/mage/remote/interfaces/GamePlay.java @@ -65,6 +65,7 @@ public interface GamePlay { boolean updateDeck(UUID tableId, DeckCardLists deck); DraftPickView sendCardPick(UUID draftId, UUID cardId); + DraftPickView sendCardMark(UUID draftId, UUID cardId); /** * magenoxx: diff --git a/Mage.Server/src/main/java/mage/server/MageServerImpl.java b/Mage.Server/src/main/java/mage/server/MageServerImpl.java index 2bf60a6e24..6738fcc0ab 100644 --- a/Mage.Server/src/main/java/mage/server/MageServerImpl.java +++ b/Mage.Server/src/main/java/mage/server/MageServerImpl.java @@ -682,6 +682,21 @@ public class MageServerImpl implements MageServer { }); } + @Override + public void sendCardMark(final UUID draftId, final String sessionId, final UUID cardPick) throws MageException { + execute("sendCardMark", sessionId, new Action() { + @Override + public void execute() { + Session session = SessionManager.getInstance().getSession(sessionId); + if (session != null) { + DraftManager.getInstance().sendCardMark(draftId, session.getUserId(), cardPick); + } else{ + logger.error("Session not found sessionId: "+ sessionId + " draftId:" + draftId); + } + } + }); + } + @Override public void quitMatch(final UUID gameId, final String sessionId) throws MageException { execute("quitMatch", sessionId, new Action() { diff --git a/Mage.Server/src/main/java/mage/server/draft/DraftController.java b/Mage.Server/src/main/java/mage/server/draft/DraftController.java index b39e18f19f..b642ed5c9e 100644 --- a/Mage.Server/src/main/java/mage/server/draft/DraftController.java +++ b/Mage.Server/src/main/java/mage/server/draft/DraftController.java @@ -60,12 +60,14 @@ public class DraftController { private final UUID draftSessionId; private final Draft draft; private final UUID tableId; + private UUID markedCard; public DraftController(Draft draft, ConcurrentHashMap userPlayerMap, UUID tableId) { draftSessionId = UUID.randomUUID(); this.userPlayerMap = userPlayerMap; this.draft = draft; this.tableId = tableId; + this.markedCard = null; init(); } @@ -208,6 +210,14 @@ public class DraftController { public void timeout(UUID userId) { if (userPlayerMap.containsKey(userId)) { + DraftSession draftSession = draftSessions.get(userPlayerMap.get(userId)); + if (draftSession != null) { + UUID cardId = draftSession.getMarkedCard(); + if (cardId != null) { + sendCardPick(userId, cardId); + return; + } + } draft.autoPick(userPlayerMap.get(userId)); logger.debug("Draft pick timeout - autopick for player: " + userPlayerMap.get(userId)); } @@ -218,7 +228,16 @@ public class DraftController { } public DraftPickView sendCardPick(UUID userId, UUID cardId) { - return draftSessions.get(userPlayerMap.get(userId)).sendCardPick(cardId); + DraftSession draftSession = draftSessions.get(userPlayerMap.get(userId)); + if (draftSession != null) { + draftSession.setMarkedCard(null); + return draftSession.sendCardPick(cardId); + } + return null; + } + + public void sendCardMark(UUID userId, UUID cardId) { + draftSessions.get(userPlayerMap.get(userId)).setMarkedCard(cardId); } private synchronized void updateDraft() throws MageException { diff --git a/Mage.Server/src/main/java/mage/server/draft/DraftManager.java b/Mage.Server/src/main/java/mage/server/draft/DraftManager.java index fbcea171f5..de740cd954 100644 --- a/Mage.Server/src/main/java/mage/server/draft/DraftManager.java +++ b/Mage.Server/src/main/java/mage/server/draft/DraftManager.java @@ -66,6 +66,10 @@ public class DraftManager { return draftControllers.get(draftId).sendCardPick(userId, cardId); } + public void sendCardMark(UUID draftId, UUID userId, UUID cardId) { + draftControllers.get(draftId).sendCardMark(userId, cardId); + } + public void removeSession(UUID userId) { for (DraftController controller: draftControllers.values()) { controller.kill(userId); diff --git a/Mage.Server/src/main/java/mage/server/draft/DraftSession.java b/Mage.Server/src/main/java/mage/server/draft/DraftSession.java index 09bd6b9aeb..763ad6d10a 100644 --- a/Mage.Server/src/main/java/mage/server/draft/DraftSession.java +++ b/Mage.Server/src/main/java/mage/server/draft/DraftSession.java @@ -55,6 +55,7 @@ public class DraftSession { protected UUID playerId; protected Draft draft; protected boolean killed = false; + protected UUID markedCard; private ScheduledFuture futureTimeout; protected static ScheduledExecutorService timeoutExecutor = ThreadExecutor.getInstance().getTimeoutExecutor(); @@ -63,6 +64,7 @@ public class DraftSession { this.userId = userId; this.draft = draft; this.playerId = playerId; + this.markedCard = null; } public boolean init() { @@ -175,4 +177,12 @@ public class DraftSession { return draft.getId(); } + public UUID getMarkedCard() { + return markedCard; + } + + public void setMarkedCard(UUID markedCard) { + this.markedCard = markedCard; + } + }