Colour client rows in the channel tree: for everyone, while talking, while muted or away
Design settings on desktop and Android offer a few see-through presets that suit light and dark themes alike, or a custom colour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
package com.ts3client.config;
|
||||
|
||||
import com.ts3client.net.ClientStatus;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Background colours of client rows in the channel tree: one for every client, overridden
|
||||
* by one while they talk and one while they are muted or away. Colours are ARGB; 0 is none.
|
||||
*/
|
||||
public final class ClientRowColors {
|
||||
|
||||
public record Preset(String name, int argb) {
|
||||
}
|
||||
|
||||
/** See-through, so they tint the light and dark themes alike and the names stay readable. */
|
||||
public static final List<Preset> PRESETS = List.of(
|
||||
new Preset("Green", 0x594CAF50),
|
||||
new Preset("Teal", 0x5926A69A),
|
||||
new Preset("Blue", 0x5942A5F5),
|
||||
new Preset("Purple", 0x59AB47BC),
|
||||
new Preset("Pink", 0x59EC407A),
|
||||
new Preset("Red", 0x59EF5350),
|
||||
new Preset("Orange", 0x59FFA726),
|
||||
new Preset("Yellow", 0x59FFEE58),
|
||||
new Preset("Grey", 0x599E9E9E));
|
||||
|
||||
private static final String PREFIX = "clientRowColor.";
|
||||
|
||||
public int any;
|
||||
public int talking;
|
||||
public int mutedAway;
|
||||
|
||||
/** The colour of a row showing {@code status}; 0 for none. */
|
||||
public int of(ClientStatus status) {
|
||||
int own = switch (status) {
|
||||
case TALKING, COMMANDER_TALKING -> talking;
|
||||
case SPEAKERS_DISABLED, SPEAKERS_MUTED, MIC_DISABLED, MIC_MUTED, AWAY -> mutedAway;
|
||||
default -> 0;
|
||||
};
|
||||
return own != 0 ? own : any;
|
||||
}
|
||||
|
||||
/** The preset named for {@code argb}, or {@code null} for a custom colour or none. */
|
||||
public static Preset presetOf(int argb) {
|
||||
for (Preset p : PRESETS) {
|
||||
if (p.argb() == argb) return p;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void load(Properties p) {
|
||||
any = parse(p.getProperty(PREFIX + "any"));
|
||||
talking = parse(p.getProperty(PREFIX + "talking"));
|
||||
mutedAway = parse(p.getProperty(PREFIX + "mutedAway"));
|
||||
}
|
||||
|
||||
void store(Properties p) {
|
||||
p.setProperty(PREFIX + "any", format(any));
|
||||
p.setProperty(PREFIX + "talking", format(talking));
|
||||
p.setProperty(PREFIX + "mutedAway", format(mutedAway));
|
||||
}
|
||||
|
||||
private static int parse(String v) {
|
||||
if (v == null || v.isBlank()) return 0;
|
||||
try {
|
||||
return (int) Long.parseLong(v.trim().replace("#", ""), 16);
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static String format(int argb) {
|
||||
return argb == 0 ? "" : String.format("#%08X", argb);
|
||||
}
|
||||
}
|
||||
@@ -181,6 +181,8 @@ public final class Settings {
|
||||
* their details show it beside their name either way.
|
||||
*/
|
||||
public boolean countryFlags = false;
|
||||
/** Background colours of client rows in the channel tree. */
|
||||
public final ClientRowColors clientRowColors = new ClientRowColors();
|
||||
/** Extra folder to look for icon packs in, on top of the well-known locations. */
|
||||
public String iconPackDir = "";
|
||||
|
||||
@@ -314,6 +316,7 @@ public final class Settings {
|
||||
desktopNotifications = parseB(props.getProperty("desktopNotifications"), desktopNotifications);
|
||||
iconPack = props.getProperty("iconPack", iconPack);
|
||||
countryFlags = parseB(props.getProperty("countryFlags"), countryFlags);
|
||||
clientRowColors.load(props);
|
||||
iconPackDir = props.getProperty("iconPackDir", iconPackDir);
|
||||
appearance = parseEnum(Appearance.class, props.getProperty("appearance"), appearance);
|
||||
uiScale = parseD(props.getProperty("uiScale"), uiScale);
|
||||
@@ -375,6 +378,7 @@ public final class Settings {
|
||||
props.setProperty("desktopNotifications", Boolean.toString(desktopNotifications));
|
||||
props.setProperty("iconPack", iconPack);
|
||||
props.setProperty("countryFlags", Boolean.toString(countryFlags));
|
||||
clientRowColors.store(props);
|
||||
props.setProperty("iconPackDir", iconPackDir);
|
||||
props.setProperty("appearance", appearance.name());
|
||||
props.setProperty("uiScale", Double.toString(uiScale));
|
||||
|
||||
Reference in New Issue
Block a user