|
@@ -22,11 +22,11 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.addons.nickcolours;
|
24
|
24
|
|
25
|
|
-import com.dmdirc.ChannelClientProperty;
|
26
|
25
|
import com.dmdirc.ClientModule.GlobalConfig;
|
27
|
26
|
import com.dmdirc.DMDircMBassador;
|
28
|
27
|
import com.dmdirc.events.ChannelGotnamesEvent;
|
29
|
28
|
import com.dmdirc.events.ChannelJoinEvent;
|
|
29
|
+import com.dmdirc.events.DisplayProperty;
|
30
|
30
|
import com.dmdirc.interfaces.GroupChatUser;
|
31
|
31
|
import com.dmdirc.interfaces.User;
|
32
|
32
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
|
@@ -37,12 +37,9 @@ import com.dmdirc.plugins.PluginDomain;
|
37
|
37
|
import com.dmdirc.ui.messages.ColourManager;
|
38
|
38
|
import com.dmdirc.util.colours.Colour;
|
39
|
39
|
|
40
|
|
-import com.google.common.collect.Maps;
|
41
|
|
-
|
42
|
40
|
import java.util.ArrayList;
|
43
|
41
|
import java.util.Collection;
|
44
|
42
|
import java.util.List;
|
45
|
|
-import java.util.Map;
|
46
|
43
|
|
47
|
44
|
import javax.inject.Inject;
|
48
|
45
|
import javax.inject.Singleton;
|
|
@@ -69,8 +66,6 @@ public class NickColourManager implements ConfigChangeListener {
|
69
|
66
|
private boolean useowncolour;
|
70
|
67
|
private String owncolour;
|
71
|
68
|
private boolean userandomcolour;
|
72
|
|
- private boolean settext;
|
73
|
|
- private boolean setnicklist;
|
74
|
69
|
|
75
|
70
|
@Inject
|
76
|
71
|
public NickColourManager(@GlobalConfig final ColourManager colourManager,
|
|
@@ -103,17 +98,15 @@ public class NickColourManager implements ConfigChangeListener {
|
103
|
98
|
private void colourClient(final String network, final GroupChatUser client) {
|
104
|
99
|
final StringConverter sc = client.getUser().getConnection().getParser().get()
|
105
|
100
|
.getStringConverter();
|
106
|
|
- // TODO: This needs to use the new setDisplayableProperty on GroupChatUser
|
107
|
|
- final Map<Object, Object> map = Maps.newHashMap();
|
108
|
101
|
final User myself = client.getUser();
|
109
|
102
|
final String nickOption1 = "color:" + sc.toLowerCase(network + ':' + client.getNickname());
|
110
|
103
|
final String nickOption2 = "color:" + sc.toLowerCase("*:" + client.getNickname());
|
111
|
104
|
|
112
|
105
|
if (useowncolour && client.getUser().equals(myself)) {
|
113
|
106
|
final Colour color = colourManager.getColourFromString(owncolour, null);
|
114
|
|
- putColour(map, color, color);
|
|
107
|
+ putColour(client, color);
|
115
|
108
|
} else if (userandomcolour) {
|
116
|
|
- putColour(map, getColour(client.getNickname()), getColour(client.getNickname()));
|
|
109
|
+ putColour(client, getColour(client.getNickname()));
|
117
|
110
|
}
|
118
|
111
|
|
119
|
112
|
String[] parts = null;
|
|
@@ -130,31 +123,19 @@ public class NickColourManager implements ConfigChangeListener {
|
130
|
123
|
if (parts[0] != null) {
|
131
|
124
|
textColor = colourManager.getColourFromString(parts[0], null);
|
132
|
125
|
}
|
133
|
|
- Colour nickColor = null;
|
134
|
|
- if (parts[1] != null) {
|
135
|
|
- nickColor = colourManager.getColourFromString(parts[1], null);
|
136
|
|
- }
|
137
|
126
|
|
138
|
|
- putColour(map, textColor, nickColor);
|
|
127
|
+ putColour(client, textColor);
|
139
|
128
|
}
|
140
|
129
|
}
|
141
|
130
|
|
142
|
131
|
/**
|
143
|
132
|
* Puts the specified colour into the given map. The keys are determined by config settings.
|
144
|
133
|
*
|
145
|
|
- * @param map The map to use
|
146
|
|
- * @param textColour Text colour to be inserted
|
147
|
|
- * @param nickColour Nick colour to be inserted
|
|
134
|
+ * @param user The map to colour
|
|
135
|
+ * @param colour Text colour to be inserted
|
148
|
136
|
*/
|
149
|
|
- private void putColour(final Map<Object, Object> map, final Colour textColour,
|
150
|
|
- final Colour nickColour) {
|
151
|
|
- if (settext && textColour != null) {
|
152
|
|
- map.put(ChannelClientProperty.TEXT_FOREGROUND, textColour);
|
153
|
|
- }
|
154
|
|
-
|
155
|
|
- if (setnicklist && nickColour != null) {
|
156
|
|
- map.put(ChannelClientProperty.NICKLIST_FOREGROUND, nickColour);
|
157
|
|
- }
|
|
137
|
+ private void putColour(final GroupChatUser user, final Colour colour) {
|
|
138
|
+ user.setDisplayProperty(DisplayProperty.FOREGROUND_COLOUR, colour);
|
158
|
139
|
}
|
159
|
140
|
|
160
|
141
|
/**
|
|
@@ -226,6 +207,8 @@ public class NickColourManager implements ConfigChangeListener {
|
226
|
207
|
parts = new String[]{null, null};
|
227
|
208
|
} else if (parts.length == 1) {
|
228
|
209
|
parts = new String[]{parts[0], null};
|
|
210
|
+ } else if (parts.length == 2) {
|
|
211
|
+ parts = new String[]{parts[0], parts[1]};
|
229
|
212
|
}
|
230
|
213
|
|
231
|
214
|
return parts;
|
|
@@ -253,8 +236,6 @@ public class NickColourManager implements ConfigChangeListener {
|
253
|
236
|
useowncolour = globalConfig.getOptionBool(domain, "useowncolour");
|
254
|
237
|
owncolour = globalConfig.getOption(domain, "owncolour");
|
255
|
238
|
userandomcolour = globalConfig.getOptionBool(domain, "userandomcolour");
|
256
|
|
- settext = globalConfig.getOptionBool(domain, "settext");
|
257
|
|
- setnicklist = globalConfig.getOptionBool(domain, "setnicklist");
|
258
|
239
|
if (globalConfig.hasOptionString(domain, "randomcolours")) {
|
259
|
240
|
final List<String> list = globalConfig.getOptionList(domain, "randomcolours");
|
260
|
241
|
randColours = list.toArray(new String[list.size()]);
|