22 package com.realtime.crossfire.jxclient.gui.log;
29 import java.awt.Color;
30 import org.jetbrains.annotations.NotNull;
137 public void commandQueryReceived(@NotNull
final String prompt,
final int queryType) {
153 public void commandDrawextinfoReceived(
final int color,
final int type,
final int subtype, @NotNull
final String message) {
166 public void setDebugMode(
final boolean printMessageTypes) {
180 public void commandDrawinfoReceived(@NotNull
final String text,
final int type) {
182 final int messageType;
214 this.crossfireServerConnection.addCrossfireQueryListener(crossfireQueryListener);
215 this.crossfireServerConnection.addCrossfireDrawextinfoListener(crossfireDrawextinfoListener);
216 this.crossfireServerConnection.addCrossfireDrawinfoListener(crossfireDrawinfoListener);
236 return colors[index];
237 }
catch (
final ArrayIndexOutOfBoundsException ignored) {
250 return COLOR_NAMES[index];
251 }
catch (
final ArrayIndexOutOfBoundsException ignored) {
261 public void setColor(
final int index, @NotNull
final Color color) {
262 colors[index] = color;
279 return type < 0 || type > 31 || (types&(1<<type)) != 0;
291 private CharSequence
addMessageTypePrefix(
final int type,
final int subtype,
final int color, @NotNull
final CharSequence message) {
292 return printMessageTypes ?
"(t="+
MessageTypes.
toString(type)+
"/"+subtype+
",c="+color+
")"+message : message;
boolean isTypeShown(final int type)
Returns whether a message type should be shown.
static final int NUM_COLORS
The number of supported colors.
final Color defaultColor
The color to use for invalid colors indices.
Encapsulates the message type numbers for drawextinfo messages.
boolean printMessageTypes
Whether message types are included in the buffer output.
Parser for parsing drawextinfo messages received from a Crossfire server to update a Buffer instance...
void setTypes(final int types)
Sets the message types to show.
int NDI_RED
A message color.
Interface for listeners interested in drawinfo messages received from the Crossfire server...
static final int MSG_TYPE_MISC
drawextinfo message type: message that does not fit in any other category.
static String getColorName(final int index)
Returns the name of a color index.
CharSequence addMessageTypePrefix(final int type, final int subtype, final int color, @NotNull final CharSequence message)
Adds a message type prefix to a message if printMessageTypes is set.
final Color [] colors
Maps color index to color.
final Parser parser
The Parser instance for parsing drawextinfo messages.
final Buffer buffer
The buffer to update.
Color findColor(final int index)
Converts a Crossfire color index to a Color instance.
final CrossfireDrawinfoListener crossfireDrawinfoListener
The CrossfireDrawinfoListener registered to receive drawinfo commands.
void setColor(final int index, @NotNull final Color color)
Sets a color mapping.
final CrossfireQueryListener crossfireQueryListener
The CrossfireQueryListener registered to receive query commands.
static final String [] COLOR_NAMES
The colors names corresponding to colors.
void parseWithoutMediaTags(@NotNull final CharSequence text, @NotNull final Color color, @NotNull final Buffer buffer)
Parses a plain text message without media tags.
MessageBufferUpdater(@NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final Buffer buffer, @NotNull final Color defaultColor)
Creates a new instance.
Interface for listeners interested in drawextinfo messages received from the Crossfire server...
Manages the contents of the contents of a log window.
static final int MSG_TYPE_COMMUNICATION
drawextinfo message type: communication between players.
static final int MSG_TYPE_QUERY
Internally used drawextinfo message type: a query message has been received.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
void parse(@NotNull final CharSequence text, @Nullable final Color defaultColor, @NotNull final Buffer buffer)
Parses a text message.
void removeCrossfireDrawinfoListener(@NotNull CrossfireDrawinfoListener listener)
Removes the given listener from the list of objects listening to the drawinfo S->C messages...
final CrossfireDrawextinfoListener crossfireDrawextinfoListener
The CrossfireDrawextinfoListener registered to receive drawextinfo commands.
final CrossfireServerConnection crossfireServerConnection
The CrossfireServerConnection to monitor.
Interface for listeners interested in query messages received from the Crossfire server.
void dispose()
Releases resources.
Adds drawinfo, drawextinfo, and query messages to a Buffer instance.
void removeCrossfireQueryListener(@NotNull CrossfireQueryListener listener)
Removes the given listener from the list of objects listening to the query S->C messages.
static String toString(final int type)
Returns a string representation of a message type.
int types
The types to show.
void removeCrossfireDrawextinfoListener(@NotNull CrossfireDrawextinfoListener listener)
Removes the given listener from the list of objects listening to the drawextinfo S->C messages...