|
@@ -25,10 +25,17 @@ package com.dmdirc.addons.nickcolours;
|
25
|
25
|
import com.dmdirc.ClientModule.GlobalConfig;
|
26
|
26
|
import com.dmdirc.DMDircMBassador;
|
27
|
27
|
import com.dmdirc.addons.ui_swing.EDTInvocation;
|
|
28
|
+import com.dmdirc.addons.ui_swing.UIUtilities;
|
|
29
|
+import com.dmdirc.addons.ui_swing.injection.MainWindow;
|
28
|
30
|
import com.dmdirc.config.ConfigBinder;
|
29
|
31
|
import com.dmdirc.config.ConfigBinding;
|
|
32
|
+import com.dmdirc.config.prefs.PluginPreferencesCategory;
|
|
33
|
+import com.dmdirc.config.prefs.PreferencesCategory;
|
|
34
|
+import com.dmdirc.config.prefs.PreferencesSetting;
|
|
35
|
+import com.dmdirc.config.prefs.PreferencesType;
|
30
|
36
|
import com.dmdirc.events.ChannelGotNamesEvent;
|
31
|
37
|
import com.dmdirc.events.ChannelJoinEvent;
|
|
38
|
+import com.dmdirc.events.ClientPrefsOpenedEvent;
|
32
|
39
|
import com.dmdirc.events.DisplayProperty;
|
33
|
40
|
import com.dmdirc.interfaces.GroupChatUser;
|
34
|
41
|
import com.dmdirc.interfaces.User;
|
|
@@ -36,14 +43,18 @@ import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
36
|
43
|
import com.dmdirc.interfaces.config.ReadOnlyConfigProvider;
|
37
|
44
|
import com.dmdirc.parser.interfaces.StringConverter;
|
38
|
45
|
import com.dmdirc.plugins.PluginDomain;
|
|
46
|
+import com.dmdirc.plugins.PluginInfo;
|
|
47
|
+import com.dmdirc.ui.IconManager;
|
39
|
48
|
import com.dmdirc.ui.messages.ColourManager;
|
40
|
49
|
import com.dmdirc.util.colours.Colour;
|
41
|
50
|
|
|
51
|
+import java.awt.Window;
|
42
|
52
|
import java.util.ArrayList;
|
43
|
53
|
import java.util.Collection;
|
44
|
54
|
import java.util.List;
|
45
|
55
|
|
46
|
56
|
import javax.inject.Inject;
|
|
57
|
+import javax.inject.Provider;
|
47
|
58
|
import javax.inject.Singleton;
|
48
|
59
|
|
49
|
60
|
import net.engio.mbassy.listener.Handler;
|
|
@@ -62,8 +73,12 @@ public class NickColourManager {
|
62
|
73
|
private final ConfigBinder configBinder;
|
63
|
74
|
/** Plugin's setting domain. */
|
64
|
75
|
private final String domain;
|
|
76
|
+ private final IconManager iconManager;
|
|
77
|
+ private final Provider<Window> mainWindowProvider;
|
65
|
78
|
/** Event bus to subscribe to events on . */
|
66
|
79
|
private final DMDircMBassador eventBus;
|
|
80
|
+ /** The plugin's info. */
|
|
81
|
+ private final PluginInfo pluginInfo;
|
67
|
82
|
/** "Random" colours to use to colour nicknames. */
|
68
|
83
|
private String[] randColours = {
|
69
|
84
|
"E90E7F", "8E55E9", "B30E0E", "18B33C", "58ADB3", "9E54B3", "B39875", "3176B3",};
|
|
@@ -72,13 +87,20 @@ public class NickColourManager {
|
72
|
87
|
private boolean userandomcolour;
|
73
|
88
|
|
74
|
89
|
@Inject
|
75
|
|
- public NickColourManager(@GlobalConfig final ColourManager colourManager,
|
|
90
|
+ public NickColourManager(
|
|
91
|
+ @GlobalConfig final ColourManager colourManager,
|
76
|
92
|
@PluginDomain(NickColourPlugin.class) final String domain,
|
77
|
93
|
@GlobalConfig final AggregateConfigProvider globalConfig,
|
|
94
|
+ final IconManager iconManager,
|
|
95
|
+ @MainWindow final Provider<Window> mainWindowProvider,
|
|
96
|
+ final PluginInfo pluginInfo,
|
78
|
97
|
final DMDircMBassador eventBus) {
|
79
|
98
|
this.domain = domain;
|
80
|
99
|
this.globalConfig = globalConfig;
|
81
|
100
|
this.colourManager = colourManager;
|
|
101
|
+ this.iconManager = iconManager;
|
|
102
|
+ this.mainWindowProvider = mainWindowProvider;
|
|
103
|
+ this.pluginInfo = pluginInfo;
|
82
|
104
|
this.eventBus = eventBus;
|
83
|
105
|
configBinder = globalConfig.getBinder().withDefaultDomain(domain);
|
84
|
106
|
}
|
|
@@ -255,4 +277,35 @@ public class NickColourManager {
|
255
|
277
|
public void handleRandomColours(final List<String> value) {
|
256
|
278
|
randColours = value.toArray(new String[value.size()]);
|
257
|
279
|
}
|
|
280
|
+
|
|
281
|
+ @Handler
|
|
282
|
+ public void handlePrefsOpened(final ClientPrefsOpenedEvent event) {
|
|
283
|
+ final PreferencesCategory general = new PluginPreferencesCategory(
|
|
284
|
+ pluginInfo, "Nick Colours",
|
|
285
|
+ "General configuration for NickColour plugin.");
|
|
286
|
+ final PreferencesCategory colours = new PluginPreferencesCategory(
|
|
287
|
+ pluginInfo, "Colours",
|
|
288
|
+ "Set colours for specific nicknames.", UIUtilities.invokeAndWait(
|
|
289
|
+ () -> new NickColourPanel(mainWindowProvider.get(), iconManager, colourManager,
|
|
290
|
+ event.getModel().getIdentity(), event.getModel().getConfigManager(),
|
|
291
|
+ pluginInfo.getDomain()
|
|
292
|
+ )));
|
|
293
|
+
|
|
294
|
+ general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
|
295
|
+ pluginInfo.getDomain(), "userandomcolour", "Use random colour",
|
|
296
|
+ "Use a pseudo-random colour for each person?",
|
|
297
|
+ event.getModel().getConfigManager(), event.getModel().getIdentity()));
|
|
298
|
+ general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
|
299
|
+ pluginInfo.getDomain(), "useowncolour", "Use colour for own nick",
|
|
300
|
+ "Always use the same colour for our own nickname?",
|
|
301
|
+ event.getModel().getConfigManager(), event.getModel().getIdentity()));
|
|
302
|
+ general.addSetting(new PreferencesSetting(PreferencesType.COLOUR, pluginInfo.getDomain(),
|
|
303
|
+ "owncolour", "Colour to use for own nick",
|
|
304
|
+ "Colour used for our own nickname, if above setting is enabled.",
|
|
305
|
+ event.getModel().getConfigManager(), event.getModel().getIdentity()));
|
|
306
|
+
|
|
307
|
+ general.addSubCategory(colours);
|
|
308
|
+ event.getModel().getCategory("Plugins").addSubCategory(general);
|
|
309
|
+ }
|
|
310
|
+
|
258
|
311
|
}
|