mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
* Fixed chat command handling (\list), the user chat input is now escaped to prevent using html tags.
This commit is contained in:
parent
54ec3b658e
commit
0a068e2258
7 changed files with 53 additions and 41 deletions
|
|
@ -118,19 +118,6 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
DEFAULT, GAME, TABLES, TOURNAMENT
|
||||
}
|
||||
private boolean startMessageDone = false;
|
||||
// /**
|
||||
// * Maps message colors to {@link Color}.
|
||||
// */
|
||||
// private static final Map<MessageColor, Color> colorMap = new EnumMap<>(MessageColor.class);
|
||||
//
|
||||
// static {
|
||||
// colorMap.put(MessageColor.BLACK, Color.black);
|
||||
// colorMap.put(MessageColor.GREEN, Color.green);
|
||||
// colorMap.put(MessageColor.ORANGE, Color.orange);
|
||||
// colorMap.put(MessageColor.BLUE, Color.blue);
|
||||
// colorMap.put(MessageColor.RED, Color.red);
|
||||
// colorMap.put(MessageColor.YELLOW, Color.YELLOW);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Creates new form ChatPanel
|
||||
|
|
@ -243,11 +230,9 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
if (username != null && !username.isEmpty()) {
|
||||
text.append(getColoredText(userColor, username + userSeparator));
|
||||
}
|
||||
text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML(message, ManaSymbols.Type.PAY) + "\n"));
|
||||
text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML(message, ManaSymbols.Type.PAY) + "<br/>"));
|
||||
|
||||
this.txtConversation.setEditable(true);
|
||||
this.txtConversation.append(text.toString());
|
||||
this.txtConversation.setEditable(false);
|
||||
}
|
||||
|
||||
private String getColoredText(String color, String text) {
|
||||
|
|
|
|||
|
|
@ -38,9 +38,13 @@ public class ColorPane extends JTextPane {
|
|||
|
||||
public void append(String s) {
|
||||
try {
|
||||
setEditable(true);
|
||||
kit.insertHTML(doc, doc.getLength(), s, 0, 0, null);
|
||||
int len = getDocument().getLength();
|
||||
setCaretPosition(len);
|
||||
setEditable(false);
|
||||
|
||||
// setEditable(true);
|
||||
//
|
||||
//
|
||||
// StyleContext sc = StyleContext.getDefaultStyleContext();
|
||||
// AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, color);
|
||||
|
|
@ -51,7 +55,7 @@ public class ColorPane extends JTextPane {
|
|||
// setCharacterAttributes(aset, false);
|
||||
// replaceSelection(s);
|
||||
//
|
||||
// setEditable(false);
|
||||
//
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -377,17 +377,17 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
.append("<br/><b>F5</b> - Skip to next end step of opponent's turn but stop on declare attackers/blockers and something on the stack")
|
||||
.append("<br/><b>F9</b> - Skip everything until your next turn")
|
||||
.append("<br/><b>F3</b> - Undo F4/F5/F9").toString(),
|
||||
null, MessageType.USER_INFO, ChatMessage.MessageColor.ORANGE);
|
||||
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
|
||||
break;
|
||||
case TOURNAMENT:
|
||||
usedPanel.receiveMessage("", new StringBuilder("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.").toString(),
|
||||
null, MessageType.USER_INFO, ChatMessage.MessageColor.ORANGE);
|
||||
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
|
||||
break;
|
||||
case TABLES:
|
||||
usedPanel.receiveMessage("", new StringBuilder("Download card images by using the \"Images\" menu to the top right .")
|
||||
.append("<br/>Download icons and symbols by using the \"Symbols\" menu to the top right.")
|
||||
.append("<br/>\\list - Show a list of available chat commands.").toString(),
|
||||
null, MessageType.USER_INFO, ChatMessage.MessageColor.ORANGE);
|
||||
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue