mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Message of the Day.
This commit is contained in:
parent
60511e4310
commit
6c144b5fc2
7 changed files with 265 additions and 86 deletions
|
@ -21,7 +21,7 @@
|
||||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
|
<Component id="jPanel2" max="32767" attributes="0"/>
|
||||||
<EmptySpace pref="47" max="32767" attributes="0"/>
|
<EmptySpace pref="47" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
@ -32,14 +32,12 @@
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||||
<Component id="jSplitPane1" pref="518" max="32767" attributes="0"/>
|
<Component id="jSplitPane1" pref="532" max="32767" attributes="0"/>
|
||||||
|
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||||
|
<Component id="jPanel2" min="-2" pref="25" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="1" attributes="0">
|
<EmptySpace min="0" pref="607" max="32767" attributes="0"/>
|
||||||
<EmptySpace pref="518" max="32767" attributes="0"/>
|
|
||||||
<Component id="jPanel2" min="-2" pref="39" max="-2" attributes="0"/>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
|
@ -121,7 +119,7 @@
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jLabel2" pref="455" max="32767" attributes="0"/>
|
<Component id="jLabel2" pref="449" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
|
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
|
||||||
|
@ -131,11 +129,10 @@
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="jButton1" alignment="3" min="-2" pref="17" max="-2" attributes="0"/>
|
||||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="jButton1" alignment="3" min="-2" pref="15" max="-2" attributes="0"/>
|
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace max="32767" attributes="0"/>
|
<EmptySpace max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
|
@ -154,12 +151,21 @@
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="text" type="java.lang.String" value="You are playing Mage version 0.7.5. Welcome! == Mage dev team =="/>
|
<Property name="text" type="java.lang.String" value="You are playing Mage version 0.7.5. Welcome! -- Mage dev team --"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JButton" name="jButton1">
|
<Component class="javax.swing.JButton" name="jButton1">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="text" type="java.lang.String" value=">>"/>
|
<Property name="text" type="java.lang.String" value="Next"/>
|
||||||
|
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
|
<Dimension value="[55, 25]"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
|
<Dimension value="[55, 25]"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
|
<Dimension value="[55, 25]"/>
|
||||||
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||||
|
|
|
@ -48,6 +48,7 @@ import mage.remote.Session;
|
||||||
import mage.client.util.ButtonColumn;
|
import mage.client.util.ButtonColumn;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.sets.Sets;
|
import mage.sets.Sets;
|
||||||
|
import mage.utils.CompressUtil;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
@ -80,6 +81,8 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
private NewTableDialog newTableDialog;
|
private NewTableDialog newTableDialog;
|
||||||
private NewTournamentDialog newTournamentDialog;
|
private NewTournamentDialog newTournamentDialog;
|
||||||
private Session session;
|
private Session session;
|
||||||
|
private List<String> messages;
|
||||||
|
private int currentMessage;
|
||||||
|
|
||||||
/** Creates new form TablesPanel */
|
/** Creates new form TablesPanel */
|
||||||
public TablesPanel() {
|
public TablesPanel() {
|
||||||
|
@ -228,6 +231,20 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
hideTables();
|
hideTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reload server messages
|
||||||
|
List<String> messages = session.getServerMessages();
|
||||||
|
synchronized (this) {
|
||||||
|
this.messages = messages;
|
||||||
|
this.currentMessage = 0;
|
||||||
|
}
|
||||||
|
if (messages == null || messages.isEmpty()) {
|
||||||
|
this.jPanel2.setVisible(false);
|
||||||
|
} else {
|
||||||
|
this.jPanel2.setVisible(true);
|
||||||
|
this.jLabel2.setText(messages.get(0));
|
||||||
|
this.jButton1.setVisible(messages.size() > 1);
|
||||||
|
}
|
||||||
|
|
||||||
MageFrame.getUI().addButton(MageComponents.NEW_GAME_BUTTON, btnNewTable);
|
MageFrame.getUI().addButton(MageComponents.NEW_GAME_BUTTON, btnNewTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,10 +295,10 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
btnNewTable.setText("New Match");
|
btnNewTable.setText("New Match");
|
||||||
btnNewTable.addActionListener(new java.awt.event.ActionListener() {
|
btnNewTable.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
btnNewTableActionPerformed(evt);
|
btnNewTableActionPerformed(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
btnQuickStart.setText("Quick Start");
|
btnQuickStart.setText("Quick Start");
|
||||||
btnQuickStart.addActionListener(new java.awt.event.ActionListener() {
|
btnQuickStart.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
@ -292,74 +309,76 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
btnNewTournament.setText("New Tournament");
|
btnNewTournament.setText("New Tournament");
|
||||||
btnNewTournament.addActionListener(new java.awt.event.ActionListener() {
|
btnNewTournament.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
btnNewTournamentActionPerformed(evt);
|
btnNewTournamentActionPerformed(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||||
jPanel1.setLayout(jPanel1Layout);
|
jPanel1.setLayout(jPanel1Layout);
|
||||||
jPanel1Layout.setHorizontalGroup(
|
jPanel1Layout.setHorizontalGroup(
|
||||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnNewTable)
|
.addComponent(btnNewTable)
|
||||||
.addGap(6, 6, 6)
|
.addGap(6, 6, 6)
|
||||||
.addComponent(btnNewTournament)
|
.addComponent(btnNewTournament)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnQuickStart)
|
.addComponent(btnQuickStart)
|
||||||
.addContainerGap(414, Short.MAX_VALUE))
|
.addContainerGap(414, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
jPanel1Layout.setVerticalGroup(
|
jPanel1Layout.setVerticalGroup(
|
||||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(btnNewTable)
|
.addComponent(btnNewTable)
|
||||||
.addComponent(btnQuickStart)
|
.addComponent(btnQuickStart)
|
||||||
.addComponent(btnNewTournament))
|
.addComponent(btnNewTournament))
|
||||||
.addContainerGap(16, Short.MAX_VALUE))
|
.addContainerGap(16, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
|
|
||||||
jPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
|
jPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
|
||||||
jPanel2.setPreferredSize(new java.awt.Dimension(664, 39));
|
jPanel2.setPreferredSize(new java.awt.Dimension(664, 39));
|
||||||
|
|
||||||
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
|
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
|
||||||
jLabel1.setText("Message of the Day:");
|
jLabel1.setText("Message of the Day:");
|
||||||
jLabel1.setAlignmentY(0.3F);
|
jLabel1.setAlignmentY(0.3F);
|
||||||
|
|
||||||
jLabel2.setText("You are playing Mage version 0.7.5. Welcome! == Mage dev team ==");
|
jLabel2.setText("You are playing Mage version 0.7.5. Welcome! -- Mage dev team --");
|
||||||
|
|
||||||
jButton1.setText(">>");
|
jButton1.setText("Next");
|
||||||
|
jButton1.setMaximumSize(new java.awt.Dimension(55, 25));
|
||||||
|
jButton1.setMinimumSize(new java.awt.Dimension(55, 25));
|
||||||
|
jButton1.setPreferredSize(new java.awt.Dimension(55, 25));
|
||||||
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
jButton1ActionPerformed(evt);
|
jButton1ActionPerformed(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
|
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
|
||||||
jPanel2.setLayout(jPanel2Layout);
|
jPanel2.setLayout(jPanel2Layout);
|
||||||
jPanel2Layout.setHorizontalGroup(
|
jPanel2Layout.setHorizontalGroup(
|
||||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(jLabel1)
|
.addComponent(jLabel1)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 455, Short.MAX_VALUE)
|
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(jButton1)
|
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(22, 22, 22))
|
.addGap(22, 22, 22))
|
||||||
);
|
);
|
||||||
jPanel2Layout.setVerticalGroup(
|
jPanel2Layout.setVerticalGroup(
|
||||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(jLabel2)
|
.addComponent(jLabel2)
|
||||||
.addComponent(jLabel1)
|
.addComponent(jLabel1))
|
||||||
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE))
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
);
|
||||||
);
|
|
||||||
|
|
||||||
jSplitPane1.setDividerSize(3);
|
jSplitPane1.setDividerSize(3);
|
||||||
jSplitPane1.setResizeWeight(1.0);
|
jSplitPane1.setResizeWeight(1.0);
|
||||||
|
@ -379,22 +398,21 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 721, Short.MAX_VALUE)
|
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 721, Short.MAX_VALUE)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addContainerGap(47, Short.MAX_VALUE)))
|
.addContainerGap(47, Short.MAX_VALUE)))
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(0, 0, 0)
|
.addGap(0, 0, 0)
|
||||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 518, Short.MAX_VALUE))
|
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE)
|
||||||
|
.addGap(0, 0, 0)
|
||||||
|
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addGap(0, 607, Short.MAX_VALUE))
|
||||||
.addContainerGap(518, Short.MAX_VALUE)
|
|
||||||
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addContainerGap()))
|
|
||||||
);
|
);
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
@ -424,15 +442,24 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_btnQuickStartActionPerformed
|
}//GEN-LAST:event_btnQuickStartActionPerformed
|
||||||
|
|
||||||
private void btnNewTableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewTableActionPerformed
|
private void btnNewTableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewTableActionPerformed
|
||||||
newTableDialog.showDialog(roomId);
|
newTableDialog.showDialog(roomId);
|
||||||
if (newTableDialog.getTable() != null)
|
if (newTableDialog.getTable() != null) {
|
||||||
showTableWaitingDialog(roomId, newTableDialog.getTable().getTableId(), false);
|
showTableWaitingDialog(roomId, newTableDialog.getTable().getTableId(), false);
|
||||||
}//GEN-LAST:event_btnNewTableActionPerformed
|
}
|
||||||
|
}//GEN-LAST:event_btnNewTableActionPerformed
|
||||||
|
|
||||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||||
// TODO add your handling code here:
|
synchronized (this) {
|
||||||
}//GEN-LAST:event_jButton1ActionPerformed
|
if (messages != null && !messages.isEmpty()) {
|
||||||
|
currentMessage++;
|
||||||
|
if (currentMessage >= messages.size()) {
|
||||||
|
currentMessage = 0;
|
||||||
|
}
|
||||||
|
this.jLabel2.setText(messages.get(currentMessage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//GEN-LAST:event_jButton1ActionPerformed
|
||||||
|
|
||||||
private void handleError(Exception ex) {
|
private void handleError(Exception ex) {
|
||||||
logger.fatal("Error loading deck: ", ex);
|
logger.fatal("Error loading deck: ", ex);
|
||||||
|
|
|
@ -121,4 +121,6 @@ public interface MageServer {
|
||||||
public void disconnectUser(String sessionId, String userSessionId) throws MageException;
|
public void disconnectUser(String sessionId, String userSessionId) throws MageException;
|
||||||
public void removeTable(String sessionId, UUID tableId) throws MageException;
|
public void removeTable(String sessionId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
|
// messages of the day
|
||||||
|
public Object getServerMessagesCompressed(String sessionId) throws MageException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ import mage.interfaces.MageClient;
|
||||||
import mage.interfaces.MageServer;
|
import mage.interfaces.MageServer;
|
||||||
import mage.interfaces.ServerState;
|
import mage.interfaces.ServerState;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.utils.CompressUtil;
|
||||||
import mage.view.DraftPickView;
|
import mage.view.DraftPickView;
|
||||||
import mage.view.GameTypeView;
|
import mage.view.GameTypeView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
|
@ -839,6 +840,18 @@ public class Session {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getServerMessages() {
|
||||||
|
try {
|
||||||
|
if (isConnected())
|
||||||
|
return (List<String>) CompressUtil.decompress(server.getServerMessagesCompressed(sessionId));
|
||||||
|
} catch (MageException ex) {
|
||||||
|
handleMageException(ex);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
handleThrowable(t);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean disconnectUser(String userSessionId) {
|
public boolean disconnectUser(String userSessionId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
|
|
|
@ -49,7 +49,9 @@ import mage.server.game.PlayerFactory;
|
||||||
import mage.server.game.ReplayManager;
|
import mage.server.game.ReplayManager;
|
||||||
import mage.server.tournament.TournamentFactory;
|
import mage.server.tournament.TournamentFactory;
|
||||||
import mage.server.tournament.TournamentManager;
|
import mage.server.tournament.TournamentManager;
|
||||||
|
import mage.server.util.ServerMessagesUtil;
|
||||||
import mage.server.util.ThreadExecutor;
|
import mage.server.util.ThreadExecutor;
|
||||||
|
import mage.utils.CompressUtil;
|
||||||
import mage.utils.MageVersion;
|
import mage.utils.MageVersion;
|
||||||
import mage.view.ChatMessage.MessageColor;
|
import mage.view.ChatMessage.MessageColor;
|
||||||
import mage.view.DraftPickView;
|
import mage.view.DraftPickView;
|
||||||
|
@ -74,6 +76,7 @@ public class MageServerImpl implements MageServer {
|
||||||
public MageServerImpl(String password, boolean testMode) {
|
public MageServerImpl(String password, boolean testMode) {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.testMode = testMode;
|
this.testMode = testMode;
|
||||||
|
ServerMessagesUtil.getInstance().getMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -937,4 +940,17 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getServerMessagesCompressed(String sessionId) throws MageException {
|
||||||
|
if (SessionManager.getInstance().isValidSession(sessionId)) {
|
||||||
|
try {
|
||||||
|
return CompressUtil.compress(ServerMessagesUtil.getInstance().getMessages());
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
handleException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.server.util;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Scanner;
|
||||||
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles server messages (Messages of the Day).
|
||||||
|
* Reloads messages every 5 minutes.
|
||||||
|
*
|
||||||
|
* @author nantuko
|
||||||
|
*/
|
||||||
|
public class ServerMessagesUtil {
|
||||||
|
|
||||||
|
private static final ServerMessagesUtil instance = new ServerMessagesUtil();
|
||||||
|
|
||||||
|
private static final Logger log = Logger.getLogger(ServerMessagesUtil.class);
|
||||||
|
static final String SERVER_MSG_TXT_FILE = "/server.msg.txt";
|
||||||
|
|
||||||
|
private List<String> messages = new ArrayList<String>();
|
||||||
|
private ReadWriteLock lock = new ReentrantReadWriteLock();
|
||||||
|
|
||||||
|
public ServerMessagesUtil() {
|
||||||
|
timer.setInitialDelay(5000);
|
||||||
|
timer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ServerMessagesUtil getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getMessages() {
|
||||||
|
lock.readLock().lock();
|
||||||
|
try {
|
||||||
|
return messages;
|
||||||
|
} finally {
|
||||||
|
lock.readLock().unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reloadMessages() {
|
||||||
|
log.info("Reading server messages...");
|
||||||
|
List<String> newMessages = readFromFile();
|
||||||
|
if (newMessages != null && !newMessages.isEmpty()) {
|
||||||
|
lock.writeLock().lock();
|
||||||
|
try {
|
||||||
|
messages.clear();
|
||||||
|
messages.addAll(newMessages);
|
||||||
|
} finally {
|
||||||
|
lock.writeLock().unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> readFromFile() {
|
||||||
|
InputStream is = ServerMessagesUtil.class.getResourceAsStream(SERVER_MSG_TXT_FILE);
|
||||||
|
if (is == null) {
|
||||||
|
log.info("Couldn't find server.msg");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Scanner scanner = new Scanner(is);
|
||||||
|
List<String> messages = new ArrayList<String>();
|
||||||
|
while (scanner.hasNextLine()) {
|
||||||
|
String message = scanner.nextLine();
|
||||||
|
if (!message.trim().isEmpty()) {
|
||||||
|
messages.add(message.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Timer timer = new Timer(1000 * 60 * 5, new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
reloadMessages();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
3
Mage.Server/src/main/resources/server.msg.txt
Normal file
3
Mage.Server/src/main/resources/server.msg.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Welcome! You are playing Mage version 0.7.4.
|
||||||
|
Mage 0.7.5 will be released at the end of this week.
|
||||||
|
Find us on www.slightlymagic.net.
|
Loading…
Reference in a new issue