Skip to content

Commit

Permalink
Update help, add ffzEvent setting to GUI, improve FFZ-WS status output
Browse files Browse the repository at this point in the history
  • Loading branch information
tduva committed May 25, 2016
1 parent 0b78430 commit 4813c2e
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 30 deletions.
8 changes: 7 additions & 1 deletion src/chatty/gui/components/help/help-releases.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<h1><a name="top">Release Information</a></h1>

<p>
<a href="#0.8.1">0.8.3</a> |
<a href="#0.8.1">0.8.2</a> |
<a href="#0.8.1">0.8.1</a> |
<a href="#0.8">0.8</a> |
Expand All @@ -40,7 +41,12 @@ <h1><a name="top">Release Information</a></h1>
full list of changes.</p>

<h2>
<a name="0.8.2">Version 0.8.2</a> <a name="latest">(This one!)</a> (2016-04-26)
<a name="0.8.3">Version 0.8.3b</a> <a name="latest">(This one!)</a> (2016-??-??)
<a href="#top" class="top">[back to top]</a>
</h2>

<h2>
<a name="0.8.2">Version 0.8.2</a> (2016-04-26)
<a href="#top" class="top">[back to top]</a>
</h2>
<p>During March Twitch migrated Twitch Chat to new servers (Amazon AWS),
Expand Down
69 changes: 48 additions & 21 deletions src/chatty/gui/components/settings/EmoteSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public class EmoteSettings extends SettingsPanel {

protected EmoteSettings(SettingsDialog d) {

//=================
// General Settings
//=================

JPanel main = addTitledPanel("General Settings", 0);

GridBagConstraints gbc;
Expand All @@ -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<Long, String> scaleDef = new LinkedHashMap<>();
for (int i=50;i<=200;i += 10) {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/chatty/gui/components/settings/SettingsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> reconnectRequiredDef = new HashSet<>(Arrays.asList(
"membershipEnabled"));
Expand Down
22 changes: 15 additions & 7 deletions src/chatty/util/ffz/WebsocketClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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..";
Expand Down Expand Up @@ -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();
}
}

Expand All @@ -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));
}
}

Expand All @@ -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");
Expand All @@ -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]);
Expand Down

0 comments on commit 4813c2e

Please sign in to comment.