little cleanup
This commit is contained in:
@@ -71,9 +71,7 @@ public class ClientGuiController implements ClientListener {
|
|||||||
* Request the list of rooms from the server every second.
|
* Request the list of rooms from the server every second.
|
||||||
*/
|
*/
|
||||||
private void requestRoomsRegularly() {
|
private void requestRoomsRegularly() {
|
||||||
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), event -> {
|
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), event -> client.RequestRoomList()));
|
||||||
client.RequestRoomList();
|
|
||||||
}));
|
|
||||||
timeline.setCycleCount(Timeline.INDEFINITE);
|
timeline.setCycleCount(Timeline.INDEFINITE);
|
||||||
timeline.play();
|
timeline.play();
|
||||||
}
|
}
|
||||||
@@ -130,7 +128,7 @@ public class ClientGuiController implements ClientListener {
|
|||||||
String timeString = formatter.format(time);
|
String timeString = formatter.format(time);
|
||||||
Text chatterText = new Text(chatter + ": ");
|
Text chatterText = new Text(chatter + ": ");
|
||||||
chatterText.setStyle("-fx-fill: black; -fx-font-weight: bold;");
|
chatterText.setStyle("-fx-fill: black; -fx-font-weight: bold;");
|
||||||
TextFlow messageText = formatMessage(chatter, untagged);
|
TextFlow messageText = formatMessage(untagged);
|
||||||
TextFlow wholeMessage = new TextFlow(chatterText, messageText);
|
TextFlow wholeMessage = new TextFlow(chatterText, messageText);
|
||||||
Text timeText = new Text(" " + timeString);
|
Text timeText = new Text(" " + timeString);
|
||||||
timeText.setStyle("-fx-fill: gray; -fx-font-size: 10px;");
|
timeText.setStyle("-fx-fill: gray; -fx-font-size: 10px;");
|
||||||
@@ -151,7 +149,7 @@ public class ClientGuiController implements ClientListener {
|
|||||||
Pattern pattern = Pattern.compile("\u001B\\[44;30m(.*?)\u001B\\[49;39m");
|
Pattern pattern = Pattern.compile("\u001B\\[44;30m(.*?)\u001B\\[49;39m");
|
||||||
Matcher matcher = pattern.matcher(message);
|
Matcher matcher = pattern.matcher(message);
|
||||||
|
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuilder result = new StringBuilder();
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
String taggedName = matcher.group(1);
|
String taggedName = matcher.group(1);
|
||||||
matcher.appendReplacement(result, taggedName);
|
matcher.appendReplacement(result, taggedName);
|
||||||
@@ -220,11 +218,10 @@ public class ClientGuiController implements ClientListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Colorize the message according to the color codes.
|
* Colorize the message according to the color codes.
|
||||||
* @param chatter the name of the person who sent the message
|
|
||||||
* @param content the content of the message
|
* @param content the content of the message
|
||||||
* @return the formatted message
|
* @return the formatted message
|
||||||
*/
|
*/
|
||||||
private TextFlow formatMessage(String chatter, String content) {
|
private TextFlow formatMessage(String content) {
|
||||||
TextFlow textFlow = new TextFlow();
|
TextFlow textFlow = new TextFlow();
|
||||||
// Evil regex : match every sequence starting with a color code ending with the next color code
|
// Evil regex : match every sequence starting with a color code ending with the next color code
|
||||||
Pattern pattern = Pattern.compile("&([rbgyn])([^&]*)");
|
Pattern pattern = Pattern.compile("&([rbgyn])([^&]*)");
|
||||||
|
|||||||
Reference in New Issue
Block a user