Redesigned handling of chat start message.

This commit is contained in:
LevelX2 2013-09-05 16:25:14 +02:00
parent a97d019ca5
commit 7f6eca171e
6 changed files with 72 additions and 14 deletions

View file

@ -102,6 +102,18 @@ public class ChatPanel extends javax.swing.JPanel {
NONE, GAME, CHAT
}
/**
* Controls the output start messages as the chat panel is created
*
*/
private ChatType chatType = ChatType.DEFAULT;
public enum ChatType {
DEFAULT, GAME, TABLES, TOURNAMENT
}
private boolean startMessageDone = false;
/**
* Maps message colors to {@link Color}.
*/
@ -143,6 +155,23 @@ public class ChatPanel extends javax.swing.JPanel {
}
}
public ChatType getChatType() {
return chatType;
}
public void setChatType(ChatType chatType) {
this.chatType = chatType;
}
public boolean isStartMessageDone() {
return startMessageDone;
}
public void setStartMessageDone(boolean startMessageDone) {
this.startMessageDone = startMessageDone;
}
public void connect(UUID chatId) {
session = MageFrame.getSession();
this.chatId = chatId;

View file

@ -715,6 +715,7 @@ public final class GamePanel extends javax.swing.JPanel {
userChatPanel = new mage.client.chat.ChatPanel();
userChatPanel.setParentChat(gameChatPanel);
userChatPanel.useExtendedView(ChatPanel.VIEW_MODE.CHAT);
userChatPanel.setChatType(ChatPanel.ChatType.GAME);
gameChatPanel.setConnectedChat(userChatPanel);
gameChatPanel.disableInput();
gameChatPanel.setMinimumSize(new java.awt.Dimension(100, 48));

View file

@ -35,6 +35,7 @@ import mage.Constants;
import mage.cards.decks.Deck;
import mage.client.MageFrame;
import mage.client.chat.ChatPanel;
import mage.client.chat.ChatPanel.ChatType;
import mage.client.constants.Constants.DeckEditorMode;
import mage.client.draft.DraftPanel;
import mage.client.game.GamePanel;
@ -113,6 +114,7 @@ public class CallbackClientImpl implements CallbackClient {
ChatMessage message = (ChatMessage) callback.getData();
ChatPanel panel = MageFrame.getChat(callback.getObjectId());
if (panel != null) {
// play the to the message connected sound
if (message.getSoundToPlay() != null) {
switch (message.getSoundToPlay()) {
case PlayerLeft:
@ -123,20 +125,17 @@ public class CallbackClientImpl implements CallbackClient {
break;
}
}
if (message.getMessage().equals(Constants.MSG_TIP_HOT_KEYS_CODE) && panel.getConnectedChat() != null) {
panel.getConnectedChat().receiveMessage("[Tips] ", "You may use hot keys to play faster: " + "" +
"\nTurn Mousewheel - Show big image of card your mousepointer hovers over" +
"\nF2 - Confirm \"Ok\", \"Yes\" or \"Done\" button" +
"\nF4 - Skip current turn but stop on declare attackers" +
"\nF9 - Skip everything until your next turn" +
"\nF3 - Undo F4/F9", "", ChatMessage.MessageColor.ORANGE);
} else {
if (message.isUserMessage() && panel.getConnectedChat() != null) {
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), ChatMessage.MessageColor.BLACK);
} else {
panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getColor());
}
// send start message to chat if needed
if (!panel.isStartMessageDone()) {
createChatStartMessage(panel);
}
// send the message itself
if (message.isUserMessage() && panel.getConnectedChat() != null) {
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), ChatMessage.MessageColor.BLACK);
} else {
panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getColor());
}
}
} else if (callback.getMethod().equals("serverMessage")) {
if (callback.getData() != null) {
@ -339,6 +338,34 @@ public class CallbackClientImpl implements CallbackClient {
});
}
private void createChatStartMessage(ChatPanel chatPanel) {
chatPanel.setStartMessageDone(true);
ChatPanel usedPanel = chatPanel;
if (chatPanel.getConnectedChat() != null) {
usedPanel = chatPanel.getConnectedChat();
}
switch (usedPanel.getChatType()) {
case GAME:
usedPanel.receiveMessage("", "You may use hot keys to play faster: " + "" +
"\nTurn Mousewheel - Show big image of card your mousepointer hovers over" +
"\nF2 - Confirm \"Ok\", \"Yes\" or \"Done\" button" +
"\nF4 - Skip current turn but stop on declare attackers" +
"\nF9 - Skip everything until your next turn" +
"\nF3 - Undo F4/F9", "", ChatMessage.MessageColor.ORANGE);
break;
case TOURNAMENT:
usedPanel.receiveMessage("", "On this panel you can see the players, their state and the results of the games of the tournament. Also you can chat with the competitors of the tournament.", "", ChatMessage.MessageColor.ORANGE);
break;
case TABLES:
usedPanel.receiveMessage("",
"Download card images by using the \"Images\" menu to the top right ." +
"\nDownload icons and symbols by using the \"Symbols\" menu to the top right.",
"", ChatMessage.MessageColor.ORANGE);
break;
}
}
public UUID getId() {
return clientId;
}

View file

@ -118,6 +118,7 @@ public class TablesPanel extends javax.swing.JPanel {
tableTables.createDefaultColumnsFromModel();
chatPanel.useExtendedView(ChatPanel.VIEW_MODE.NONE);
chatPanel.setBorder(null);
chatPanel.setChatType(ChatPanel.ChatType.TABLES);
JComponent[] components = new JComponent[] {chatPanel, jSplitPane1, jScrollPane1, jScrollPane2, jPanel1, jPanel3};
for (JComponent component : components) {

View file

@ -86,6 +86,7 @@ public class TournamentPanel extends javax.swing.JPanel {
tableMatches.createDefaultColumnsFromModel();
chatPanel1.useExtendedView(ChatPanel.VIEW_MODE.NONE);
chatPanel1.setChatType(ChatPanel.ChatType.TOURNAMENT);
Action action = new AbstractAction()
{