From 4813c2e386413e3615485929d0cf3d53517b8d3e Mon Sep 17 00:00:00 2001
From: tduva
Date: Wed, 25 May 2016 12:19:07 +0200
Subject: [PATCH] Update help, add ffzEvent setting to GUI, improve FFZ-WS
status output
---
.../gui/components/help/help-releases.html | 8 ++-
.../components/settings/EmoteSettings.java | 69 +++++++++++++------
.../components/settings/SettingsDialog.java | 2 +-
src/chatty/util/ffz/WebsocketClient.java | 22 ++++--
4 files changed, 71 insertions(+), 30 deletions(-)
diff --git a/src/chatty/gui/components/help/help-releases.html b/src/chatty/gui/components/help/help-releases.html
index f1c17c011..38b49dbbe 100644
--- a/src/chatty/gui/components/help/help-releases.html
+++ b/src/chatty/gui/components/help/help-releases.html
@@ -15,6 +15,7 @@
+ 0.8.3 |
0.8.2 |
0.8.1 |
0.8 |
@@ -40,7 +41,12 @@
full list of changes.
+
+
During March Twitch migrated Twitch Chat to new servers (Amazon AWS),
diff --git a/src/chatty/gui/components/settings/EmoteSettings.java b/src/chatty/gui/components/settings/EmoteSettings.java
index 2ce771ede..d08864bb6 100644
--- a/src/chatty/gui/components/settings/EmoteSettings.java
+++ b/src/chatty/gui/components/settings/EmoteSettings.java
@@ -25,6 +25,10 @@ public class EmoteSettings extends SettingsPanel {
protected EmoteSettings(SettingsDialog d) {
+ //=================
+ // General Settings
+ //=================
+
JPanel main = addTitledPanel("General Settings", 0);
GridBagConstraints gbc;
@@ -35,40 +39,52 @@ protected EmoteSettings(SettingsDialog d) {
+ "Changing this only affects new lines."),
d.makeGbcCloser(0, 0, 2, 1, GridBagConstraints.WEST));
+ //---------
+ // FFZ/BTTV
+ //---------
main.add(d.addSimpleBooleanSetting("bttvEmotes",
"Enable BetterTTV Emotes",
"Show BetterTTV emoticons"),
d.makeGbcCloser(2, 0, 3, 1, GridBagConstraints.WEST));
-
- gbc = d.makeGbc(0, 1, 2, 1, GridBagConstraints.WEST);
- final JCheckBox ffz = d.addSimpleBooleanSetting("ffz","Enable FrankerFaceZ (FFZ)",
+ final JCheckBox ffz = d.addSimpleBooleanSetting(
+ "ffz",
+ "Enable FrankerFaceZ (FFZ)",
"Retrieve custom emotes and possibly mod icon.");
main.add(ffz,
- gbc);
-
+ d.makeGbc(0, 1, 2, 1, GridBagConstraints.WEST));
- final JCheckBox ffzMod = d.addSimpleBooleanSetting("ffzModIcon",
+ final JCheckBox ffzMod = d.addSimpleBooleanSetting(
+ "ffzModIcon",
"Enable FFZ Mod Icon",
"Show custom mod icon for some channels (only works if FFZ is enabled).");
- gbc = d.makeGbc(2, 1, 3, 1, GridBagConstraints.WEST);
main.add(ffzMod,
- gbc);
+ d.makeGbcSub(0, 2, 2, 1, GridBagConstraints.WEST));
- main.add(d.addSimpleBooleanSetting("showAnimatedEmotes",
+ final JCheckBox ffzEvent = d.addSimpleBooleanSetting(
+ "ffzEvent",
+ "Enable FFZ Featured Emotes",
+ "Show Featured Emotes available in some Event channels (like Speedrunning Marathons)");
+ main.add(ffzEvent,
+ d.makeGbcCloser(2, 2, 3, 1, GridBagConstraints.WEST));
+
+ main.add(d.addSimpleBooleanSetting(
+ "showAnimatedEmotes",
"Allow animated emotes",
- "Show animated BetterTTV emoticons"),
- d.makeGbc(2, 2, 3, 1, GridBagConstraints.WEST));
+ "Show animated emotes (currently only BTTV has GIF emotes)"),
+ d.makeGbc(2, 3, 3, 1, GridBagConstraints.WEST));
+ //-----------
+ // Emote Size
+ //-----------
main.add(new JLabel("Maximum Height:"),
- d.makeGbc(2, 3, 1, 1, GridBagConstraints.WEST));
+ d.makeGbc(2, 4, 1, 1, GridBagConstraints.WEST));
main.add(d.addSimpleLongSetting("emoteMaxHeight", 3, true),
- d.makeGbc(3, 3, 1, 1, GridBagConstraints.WEST));
+ d.makeGbc(3, 4, 1, 1, GridBagConstraints.WEST));
main.add(new JLabel("pixels"),
- d.makeGbc(4, 3, 1, 1, GridBagConstraints.WEST));
- //main.add(new JLabel("(Max height of 0 means no max height.)"), d.makeGbc(2, 3, 3, 1));
+ d.makeGbc(4, 4, 1, 1, GridBagConstraints.WEST));
- main.add(new JLabel("Scale:"), d.makeGbc(0, 2, 1, 1, GridBagConstraints.WEST));
+ main.add(new JLabel("Scale:"), d.makeGbc(0, 3, 1, 1, GridBagConstraints.WEST));
final Map scaleDef = new LinkedHashMap<>();
for (int i=50;i<=200;i += 10) {
@@ -80,29 +96,40 @@ protected EmoteSettings(SettingsDialog d) {
}
ComboLongSetting emoteScale = new ComboLongSetting(scaleDef);
d.addLongSetting("emoteScale", emoteScale);
- main.add(emoteScale, d.makeGbc(1, 2, 1, 1, GridBagConstraints.CENTER));
+ main.add(emoteScale, d.makeGbc(1, 3, 1, 1, GridBagConstraints.CENTER));
- main.add(new JLabel("Emotes Dialog:"), d.makeGbc(0, 3, 1, 1, GridBagConstraints.WEST));
+ main.add(new JLabel("Emotes Dialog:"), d.makeGbc(0, 4, 1, 1, GridBagConstraints.WEST));
ComboLongSetting emoteScaleDialog = new ComboLongSetting(scaleDef);
d.addLongSetting("emoteScaleDialog", emoteScaleDialog);
- main.add(emoteScaleDialog, d.makeGbc(1, 3, 1, 1, GridBagConstraints.CENTER));
+ main.add(emoteScaleDialog, d.makeGbc(1, 4, 1, 1, GridBagConstraints.CENTER));
- main.add(d.addSimpleBooleanSetting("closeEmoteDialogOnDoubleClick",
+ //------
+ // Other
+ //------
+ main.add(d.addSimpleBooleanSetting(
+ "closeEmoteDialogOnDoubleClick",
"Double-click on emote closes Emote Dialog",
"Double-clicking on an emote in the Emotes Dialog closes the Dialog"),
- d.makeGbc(0, 4, 3, 1));
+ d.makeGbc(0, 5, 3, 1));
+ // Checkbox status
ffzMod.setEnabled(false);
+ ffzEvent.setEnabled(false);
ffz.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
ffzMod.setEnabled(ffz.isSelected());
+ ffzEvent.setEnabled(ffz.isSelected());
}
});
+ //===============
+ // Ignored Emotes
+ //===============
+
JPanel ignored = addTitledPanel("Ignored Emotes", 1, true);
gbc = d.makeGbc(0, 0, 1, 1);
diff --git a/src/chatty/gui/components/settings/SettingsDialog.java b/src/chatty/gui/components/settings/SettingsDialog.java
index 8b8a7d142..94628e0d5 100644
--- a/src/chatty/gui/components/settings/SettingsDialog.java
+++ b/src/chatty/gui/components/settings/SettingsDialog.java
@@ -46,7 +46,7 @@ public class SettingsDialog extends JDialog implements ActionListener {
"userlistWidth", "userlistMinWidth", "tabOrder","bttvEmotes","correctlyCapitalizedNames",
"logPath", "logTimestamp",
"botNamesBTTV", "botNamesFFZ", "ircv3CapitalizedNames",
- "tabsMwheelScrolling", "inputFont"));
+ "tabsMwheelScrolling", "inputFont", "ffzEvent"));
private final Set reconnectRequiredDef = new HashSet<>(Arrays.asList(
"membershipEnabled"));
diff --git a/src/chatty/util/ffz/WebsocketClient.java b/src/chatty/util/ffz/WebsocketClient.java
index 223de1408..82238bbbf 100644
--- a/src/chatty/util/ffz/WebsocketClient.java
+++ b/src/chatty/util/ffz/WebsocketClient.java
@@ -45,9 +45,11 @@ public class WebsocketClient {
private boolean connecting;
private volatile Session s;
- private int commandCount;
+ private int sentCount;
+ private int receivedCount;
private long timeConnected;
private long timeLastMessageReceived;
+ private long timeLastMessageSent;
public WebsocketClient(MessageHandler handler) {
this.handler = handler;
@@ -87,11 +89,14 @@ public synchronized String getStatus() {
if (s != null && s.isOpen()) {
return String.format("Connected for %s\n"
+ "\tServer: %s\n"
- + "\tCommands sent: %d\n"
- + "\tLast message received: %s ago",
+ + "\tCommands sent: %d (last %s ago)\n"
+ + "\tMessages received: %d (last %s ago)",
+
DateTime.ago(timeConnected),
s.getRequestURI(),
- commandCount,
+ sentCount,
+ DateTime.ago(timeLastMessageSent),
+ receivedCount,
DateTime.ago(timeLastMessageReceived));
}
return "Connecting..";
@@ -232,6 +237,7 @@ public synchronized void send(String text) {
s.getAsyncRemote().sendText(text);
System.out.println("SENT: "+text);
handler.handleSent(text);
+ timeLastMessageSent = System.currentTimeMillis();
}
}
@@ -245,8 +251,8 @@ public synchronized void send(String text) {
*/
public synchronized void sendCommand(String command, String param) {
if (s != null && s.isOpen()) {
- commandCount += 1;
- send(String.format("%d %s %s", commandCount, command, param));
+ sentCount++;
+ send(String.format("%d %s %s", sentCount, command, param));
}
}
@@ -267,7 +273,8 @@ private void handleCommand(int id, String command, String params) {
@OnOpen
public synchronized void onOpen(Session session) {
s = session;
- commandCount = 0;
+ sentCount = 0;
+ receivedCount = 0;
requestedDisconnect = false;
connectionAttempts = 0;
LOGGER.info("[FFZ-WS] Connected");
@@ -280,6 +287,7 @@ public synchronized void onMessage(String message, Session session) {
System.out.println("RECEIVED: " + message);
timeLastMessageReceived = System.currentTimeMillis();
handler.handleReceived(message);
+ receivedCount++;
try {
String[] split = message.split(" ", 3);
int id = Integer.parseInt(split[0]);