* Draft - Added possibility to mark a card to draft on timeout. Added sounds to draft. Changed compression of some sound files.

This commit is contained in:
LevelX2 2014-10-31 16:22:10 +01:00
parent c3adb1337b
commit e6c7fa5f96
28 changed files with 317 additions and 90 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -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<CardView> sortedCards = new ArrayList<CardView>(booster.values());
List<CardView> 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

View file

@ -24,7 +24,7 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="tabsPanel" alignment="0" max="32767" attributes="0"/>
<Component id="tabsPanel" alignment="0" pref="566" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="saveButton" min="-2" max="-2" attributes="0"/>
@ -885,7 +885,7 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="sounds_clips" pref="537" max="32767" attributes="0"/>
<Component id="sounds_clips" max="32767" attributes="0"/>
<Component id="sounds_backgroundMusic" alignment="1" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
@ -899,7 +899,7 @@
<Component id="sounds_clips" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="sounds_backgroundMusic" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="235" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -921,7 +921,10 @@
<Property name="AccessibleContext.accessibleDescription" type="java.lang.String" value=""/>
</AccessibilityProperties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
<Property name="columns" type="int" value="0"/>
<Property name="rows" type="int" value="4"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="cbEnableGameSounds">
<Properties>
@ -931,11 +934,24 @@
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbEnableGameSoundsActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="First"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JCheckBox" name="cbEnableDraftSounds">
<Properties>
<Property name="text" type="java.lang.String" value="Enable draft sounds"/>
<Property name="toolTipText" type="java.lang.String" value="Sounds that will be played during drafting for card picking or warining if time runs out."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbEnableDraftSoundsActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="cbEnableSkipButtonsSounds">
<Properties>
<Property name="text" type="java.lang.String" value="Enable skip button sounds"/>
<Property name="toolTipText" type="java.lang.String" value="Sounds that will be played if a priority skip action (F4/F5/F7/F9) or cancel skip action (F3) is used."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbEnableSkipButtonsSoundsActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="cbEnableOtherSounds">
<Properties>
@ -945,11 +961,6 @@
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbEnableOtherSoundsActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Last"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
@ -973,7 +984,7 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel16" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtBattlefieldIBGMPath" pref="301" max="32767" attributes="0"/>
<Component id="txtBattlefieldIBGMPath" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnBattlefieldBGMBrowse" min="-2" max="-2" attributes="0"/>
</Group>

View file

@ -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<String> cbPreferedImageLanguage;
private javax.swing.JComboBox<ProxyType> cbProxyType;

View file

@ -68,10 +68,13 @@
<Group type="102" alignment="0" attributes="0">
<Component id="lblPack1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtPack1" max="32767" attributes="0"/>
<Component id="txtPack1" min="-2" pref="165" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="lblPack3" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblPack3" min="-2" max="-2" attributes="0"/>
<Component id="lblTimeRemaining" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="txtCardNo" alignment="0" max="32767" attributes="0"/>
@ -80,15 +83,24 @@
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="chkPack3" min="-2" max="-2" attributes="0"/>
<Component id="chkPack2" min="-2" max="-2" attributes="0"/>
<Component id="chkPack1" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="chkPack3" min="-2" max="-2" attributes="0"/>
<Component id="chkPack2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="chkPack1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="lblMessage" pref="236" max="32767" attributes="0"/>
<Component id="lblMessage" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@ -97,7 +109,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Component id="bigCard" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" pref="64" max="-2" attributes="0"/>
<Component id="btnQuitTournament" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
@ -110,10 +122,12 @@
<Group type="102" alignment="1" attributes="0">
<Component id="btnQuitTournament" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblPack1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtPack1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chkPack1" alignment="3" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="chkPack1" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblPack1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtPack1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
@ -133,7 +147,10 @@
<Component id="txtCardNo" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtTimeRemaining" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtTimeRemaining" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblTimeRemaining" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblMessage" pref="24" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@ -210,6 +227,11 @@
<Property name="enabled" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblTimeRemaining">
<Properties>
<Property name="text" type="java.lang.String" value="Time:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtTimeRemaining">
<Properties>
<Property name="editable" type="boolean" value="false"/>

View file

@ -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;

View file

@ -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);
}

View file

@ -7,5 +7,7 @@ package mage.client.util.audio;
*/
public enum AudioGroup {
GameSounds,
DraftSounds,
SkipSounds,
OtherSounds;
}

View file

@ -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");
}

View file

@ -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();

View file

@ -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();

View file

@ -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;

View file

@ -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 {

View file

@ -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:

View file

@ -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() {

View file

@ -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<UUID, UUID> 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 {

View file

@ -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);

View file

@ -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;
}
}