Skip to content

Commit

Permalink
Updated to v0.26-b1.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd committed Sep 5, 2023
2 parents 444617a + 6432ddd commit bb82611
Show file tree
Hide file tree
Showing 44 changed files with 1,788 additions and 222 deletions.
2 changes: 1 addition & 1 deletion src/chatty/Chatty.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class Chatty {
* by points. May contain a single "b" for beta versions, which are counted
* as older (so 0.8.7b4 is older than 0.8.7).
*/
public static final String VERSION = "0.25.0.168";
public static final String VERSION = "0.26.0.168";

/**
* Enable Version Checker (if you compile and distribute this yourself, you
Expand Down
5 changes: 5 additions & 0 deletions src/chatty/SettingsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,11 @@ public void defineSettings() {
settings.addBoolean("filterEnabled", true);
settings.addBoolean("filterOwnText", true);

// Routing
settings.addList("routingTargets", new ArrayList(), Setting.LIST);
settings.addList("routing", new ArrayList(), Setting.STRING);
settings.addBoolean("routingMulti", true);

// Matching
List<String> matchingPresetsDefault = new ArrayList<>();
matchingPresetsDefault.add("# _custom replaces \\! with [\\W_]*? (matches non-word characters and underscore 0 or more times)");
Expand Down
19 changes: 7 additions & 12 deletions src/chatty/TwitchClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3025,12 +3025,13 @@ public void webserverTokenReceived(String token) {
};

/**
* Update the logo for all current Stream Chat channels, based on already
* available StreamInfo.
* Get the channel logo URL for channels that are being joined.
*
* @param joiningChannels
*/
public void updateStreamChatLogos() {
public void updateStreamChatLogos(Collection<String> joiningChannels) {
List<String> logins = new ArrayList<>();
for (String channel : (List<String>) settings.getList("streamChatChannels")) {
for (String channel : joiningChannels) {
if (Helper.isRegularChannel(channel)) {
logins.add(Helper.toStream(channel));
}
Expand All @@ -3039,7 +3040,7 @@ public void updateStreamChatLogos() {
for (Map.Entry<String, UserInfo> entry : result.entrySet()) {
UserInfo info = entry.getValue();
if (info != null && !StringUtil.isNullOrEmpty(info.profileImageUrl)) {
usericonManager.updateChannelLogo(Helper.toChannel(info.login), info.profileImageUrl, settings.getString("streamChatLogos"));
usericonManager.addChannelLogoUrl(Helper.toChannel(info.login), info.profileImageUrl);
}
}
});
Expand Down Expand Up @@ -3548,16 +3549,10 @@ public void onInfo(String message) {

@Override
public void onJoinScheduled(Collection<String> channels) {
boolean joiningStreamChatChannel = false;
for (String channel : channels) {
g.joinScheduled(channel);
if (settings.listContains("streamChatChannels", channel)) {
joiningStreamChatChannel = true;
}
}
if (joiningStreamChatChannel) {
updateStreamChatLogos();
}
updateStreamChatLogos(channels);
// Try to request stream info for all, so it doesn't do it one by one
api.getStreamInfo(null, new HashSet<>(Helper.toStream(channels)));
}
Expand Down
4 changes: 2 additions & 2 deletions src/chatty/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ public synchronized boolean hasTwitchBadge(String id, String version) {
return twitchBadges != null && twitchBadges.hasIdVersion(id, version);
}

public List<Usericon> getBadges(boolean botBadgeEnabled, MsgTags tags, User localUser, boolean channelLogo) {
public List<Usericon> getBadges(boolean botBadgeEnabled, MsgTags tags, User localUser, int channelLogoSize) {
IrcBadges badges = getTwitchBadges();
if (userSettings.iconManager != null) {
return userSettings.iconManager.getBadges(badges, this, localUser, botBadgeEnabled, tags, channelLogo);
return userSettings.iconManager.getBadges(badges, this, localUser, botBadgeEnabled, tags, channelLogoSize);
}
return null;
}
Expand Down
5 changes: 5 additions & 0 deletions src/chatty/gui/Channels.java
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,11 @@ private void handleContent(String id, DockContent currentContent, boolean add) {
gui.client.closeChannel(id);
}
}
else if (id.startsWith("'")) {
if (add) {
gui.routingManager.addTarget(id.replace("'", ""));
}
}
else {
//--------------------------
// Other content (dialogs)
Expand Down
62 changes: 1 addition & 61 deletions src/chatty/gui/GuiUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,8 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.function.Consumer;
import java.util.logging.Level;
Expand Down Expand Up @@ -381,18 +376,10 @@ public static void main(String[] args) {
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
JButton button = new JButton("Shake");
ImageIcon a = new ImageIcon(new URL("https://cdn.betterttv.net/emote/58487cc6f52be01a7ee5f205/1x"));
ImageIcon b = new ImageIcon(new URL("https://static-cdn.jtvnw.net/emoticons/v1/123171/1.0"));
button.addActionListener(e -> shake(dialog, 2, 2));
dialog.add(button, BorderLayout.NORTH);
LinkedHashMap<ImageIcon, Integer> map = new LinkedHashMap<>();
map.put(b, 0);
map.put(a, -8);
Debugging.command("overlayframe");
dialog.add(new JLabel("text", overlay(map), 0), BorderLayout.CENTER);
dialog.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
catch (MalformedURLException ex) {
} catch (Exception ex) {
Logger.getLogger(GuiUtil.class.getName()).log(Level.SEVERE, null, ex);
}
});
Expand Down Expand Up @@ -852,53 +839,6 @@ public static ImageIcon createEmptyIcon(int width, int height) {
return new ImageIcon(res);
}

public static ImageIcon overlay(LinkedHashMap<ImageIcon, Integer> overlay) {
if (overlay == null || overlay.isEmpty()) {
return null;
}
if (overlay.size() == 1) {
return overlay.entrySet().iterator().next().getKey();
}
ImageIcon base = null;
int width = 0;
int height = 0;
int oh = 0;
Iterator<Map.Entry<ImageIcon, Integer>> it = overlay.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<ImageIcon, Integer> entry = it.next();
ImageIcon icon = entry.getKey();
if (base == null) {
base = entry.getKey();
}
width = Integer.max(width, icon.getIconWidth());
height = Integer.max(height, icon.getIconHeight());
int offset = Math.abs((int)(entry.getValue()/100.0*icon.getIconHeight()));
int inclOffset = icon.getIconHeight()+offset;
if (inclOffset > height) {
oh += inclOffset - height;
height = inclOffset;
}
}
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = img.createGraphics();
Iterator<Map.Entry<ImageIcon, Integer>> it2 = overlay.entrySet().iterator();
while (it2.hasNext()) {
Map.Entry<ImageIcon, Integer> entry = it2.next();
ImageIcon icon = entry.getKey();
int offset = (int)(entry.getValue()/100.0*icon.getIconHeight());
g.drawImage(icon.getImage(),
(width - icon.getIconWidth()) / 2,
(height - icon.getIconHeight()) / 2 + offset + oh,
null);
}
if (Debugging.isEnabled("overlayframe")) {
g.setColor(Color.BLACK);
g.drawRect(0, 0, width - 1, height - 1);
}
g.dispose();
return new ImageIcon(img);
}

public static ImageIcon substituteColor(ImageIcon icon, Color search, Color target) {
BufferedImage img = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D g = img.createGraphics();
Expand Down
17 changes: 17 additions & 0 deletions src/chatty/gui/Highlighter.java
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ public boolean matches(Type type, String text, int msgStart, int msgEnd, Blackli
*/
private int substitutesEnabled = 1;

private List<String> routingTargets;

//--------------------------
// Debugging
//--------------------------
Expand Down Expand Up @@ -1117,6 +1119,9 @@ else if (item.startsWith("preset:")) {
modifications.add(new Modification(item, newItem, "preset:"));
prepare(newItem);
}
else if (item.startsWith("to:")) {
routingTargets = parseStringListPrefix(item, "to:", c -> c);
}
else if (item.startsWith("n:")) {
parsePrefix(item, "n:");
}
Expand Down Expand Up @@ -1816,6 +1821,10 @@ public String getMatchInfo() {
addPatternWarning(result, item.pattern);
}
}
if (routingTargets != null) {
result.append("Copy message to: ").append(routingTargets);
result.append("\n");
}
return result.toString();
}

Expand Down Expand Up @@ -2074,6 +2083,10 @@ public boolean noLog() {
return noLog;
}

public List<String> getRoutingTargets() {
return routingTargets;
}

public String getFailedReason() {
if (failedItem != null) {
return failedItem.toString();
Expand Down Expand Up @@ -2117,6 +2130,10 @@ public String getReplacement() {
return replacement;
}

public String getUsedForFeature() {
return usedForFeature;
}

public static Map<String, CustomCommand> makePresets(Collection<String> input) {
Map<String, CustomCommand> result = new HashMap<>();
for (String value : input) {
Expand Down
Loading

0 comments on commit bb82611

Please sign in to comment.