ui: other people's badges, named on the member card and drawn after their name

Clients only send badge GUIDs. voelin-model names them from tsclientlib's
table plus the newer entries of TeamSpeak's own list, and the engine fetches
the first three pictures of each client from TeamSpeak's badge server
(<guid>/<filename>.svg, checked to answer) with the banners, under
cache.fetch_images.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ
This commit is contained in:
Claude committed 2026-10-06 20:16:37 +00:00
1 parent 68dd48d607
commit 9e0f0e05ad
19 files changed
+554 -30

No files matched your search

+6 -5
View File
@@ -39,9 +39,9 @@
//! [`Event::Poke`]), private messages to any client (a
//! [`ChatTarget::Private`] chat, stored under the peer's unique id), the
//! channels' file browsers, avatars and icons ([`files`], cached in
//! [`cache`]) and offline messages ([`offline`]). The host banner and
//! channel banners are pictures on the web, fetched into the same cache
//! ([`Event::PictureReady`]). Contacts (friends, blocked people, per-person
//! [`cache`]) and offline messages ([`offline`]). The host banner, channel
//! banners and the clients' badges are pictures on the web, fetched into the
//! same cache ([`Event::PictureReady`]). Contacts (friends, blocked people, per-person
//! volume) are engine-wide ([`contacts`]).
mod audio;
@@ -679,8 +679,9 @@ pub enum Event {
path: PathBuf,
},
/// A picture on the web is in the cache: the host banner
/// ([`ServerDetails::banner_gfx_url`]) or a channel's
/// ([`voelin_model::ChannelInfo::banner_gfx_url`]) at `url` (setting
/// ([`ServerDetails::banner_gfx_url`]), a channel's
/// ([`voelin_model::ChannelInfo::banner_gfx_url`]) or a badge's
/// ([`voelin_model::badges::icon_url`]) at `url` (setting
/// `cache.fetch_images`). Comes again when the host banner was reloaded
/// (`banner_gfx_interval_s`, at least a minute): the file at `path`
/// changed.
+59 -7
View File
@@ -19,7 +19,7 @@ use tracing::{debug, warn};
use tsclientlib::ClientId;
use voelin_audio::AudioSettings;
use voelin_gateway_proto::{ErrorCode, HistoryEntry, StreamEntry, StreamSpec, feature};
use voelin_model::{ChatMessage, ChatTarget, GroupInfo, Presence, ServerDetails};
use voelin_model::{ChatMessage, ChatTarget, GroupInfo, Presence, ServerDetails, badges};
use voelin_stream::ClientState;
use crate::audio::{self, AudioEvent, AudioHandle, AudioIn};
@@ -224,7 +224,8 @@ struct Session {
avatars: HashMap<String, String>,
/// Icons reported or being fetched, voice only.
icons: HashSet<u32>,
/// Pictures on the web (banners) reported or being fetched, by address.
/// Pictures on the web (banners, badges) reported or being fetched, by
/// address.
pictures: HashSet<String>,
image_epoch: u64,
images_enabled: bool,
@@ -1007,8 +1008,9 @@ impl Session {
|| (self.voice_presence.is_some() && files::server_image(url).is_some())
}
/// Fetch the banners of the presence shown (any source) that are new,
/// and have the host banner reloaded as often as the server asks.
/// Fetch the banners and the clients' badges of the presence shown (any
/// source) that are new, and have the host banner reloaded as often as
/// the server asks.
fn fetch_pictures(&mut self, p: &Presence) {
let enabled = self.settings.current().get(&CACHE_FETCH_IMAGES);
let reload = Some((&p.server.banner_gfx_url, p.server.banner_gfx_interval_s))
@@ -1039,10 +1041,16 @@ impl Session {
if !enabled {
return;
}
let urls: HashSet<_> = std::iter::once(&p.server.banner_gfx_url)
.chain(p.channels.values().filter_map(|c| c.banner_gfx_url.as_ref()))
// The badges shown, from TeamSpeak's server.
let badge_urls = p
.clients
.values()
.flat_map(|c| c.badges.iter().take(badges::SHOWN))
.filter_map(|guid| badges::icon_url(guid));
let urls: HashSet<String> = std::iter::once(p.server.banner_gfx_url.clone())
.chain(p.channels.values().filter_map(|c| c.banner_gfx_url.clone()))
.chain(badge_urls)
.filter(|u| self.can_fetch_picture(u))
.cloned()
.collect();
self.pictures.retain(|url| urls.contains(url));
for url in &urls {
@@ -2293,6 +2301,50 @@ mod banner_tests {
assert!(timer.is_finished());
}
/// The pictures of the badges clients show (the first three of each, the
/// known ones) come with the presence, and only with
/// `cache.fetch_images`.
#[tokio::test]
async fn badge_pictures_come_with_the_presence() {
let (mut session, _) = session("badges");
let guids = [
"4b27be5a-b92a-4b30-8b2d-14b59653f427",
"00000000-0000-0000-0000-000000000000",
"2bf80270-8efe-46dc-a472-3280a0479145",
"05114019-6b46-4b13-b5a1-e5179ef69fb5",
];
let mut presence = Presence::default();
let client = voelin_model::ClientInfo {
id: 1,
badges: guids.iter().map(|g| g.to_string()).collect(),
..Default::default()
};
presence.clients.insert(1, client);
// Own the downloads, so none goes to the network.
let cache = session.cache.current();
let urls: Vec<String> = guids.iter().filter_map(|g| badges::icon_url(g)).collect();
for url in &urls {
let _pending = cache.fetch(&cache::picture_key(url).unwrap(), false, Box::new(|_| {}));
}
session.settings.current().set(&CACHE_FETCH_IMAGES, false).unwrap();
session.fetch_pictures(&presence);
assert!(session.pictures.is_empty());
session.settings.current().set(&CACHE_FETCH_IMAGES, true).unwrap();
session.fetch_pictures(&presence);
let mut fetched: Vec<_> = session.pictures.iter().cloned().collect();
fetched.sort();
let mut shown = urls[..2].to_vec();
shown.sort();
assert_eq!(
fetched, shown,
"the unknown second badge has no picture; the fourth is not shown"
);
// Gone with the client.
session.fetch_pictures(&Presence::default());
assert!(session.pictures.is_empty());
let _ = std::fs::remove_dir_all(cache.dir());
}
/// The priority speakers and the server's dimming reach the audio thread
/// once, and again when either changes.
#[tokio::test]
+2 -2
View File
@@ -1125,11 +1125,11 @@ pub static CACHE_MAX_MB: Key<u64> = Key::new(
|| 256,
);
/// Download the avatars, icons and banners of servers we are on.
/// Download the avatars, icons, banners and badges of servers we are on.
pub static CACHE_FETCH_IMAGES: Key<bool> = Key::new(
"cache.fetch_images",
Kind::Bool,
"Download avatars, icons and banners of the servers we are on.",
"Download avatars, icons, banners and badges of the servers we are on.",
|| true,
);
+3 -1
View File
@@ -1,5 +1,7 @@
//! Pictures from the web: the host banner and TeamSpeak 6 channel banners,
//! which servers give as `http(s)` addresses on any host.
//! which servers give as `http(s)` addresses on any host, and the pictures
//! of the clients' badges on TeamSpeak's server
//! ([`voelin_model::badges::icon_url`]).
//!
//! They go into the engine's cache ([`crate::cache`], named by the MD5 hash
//! of the address) like avatars and icons, and only with
+94
View File
@@ -0,0 +1,94 @@
uid,name,description,filename,codes
4b27be5a-b92a-4b30-8b2d-14b59653f427,20th Anniversary,Celebrating 20 Years of TeamSpeak,20_years,
f81ad44d-e931-47d1-a3ef-5fd160217cf8,4Netplayers,4Netplayers customer,4netplayers,
b78a0f3e-8758-4572-b102-42a79b4a0342,????,Reads between the line,hat,
2bf80270-8efe-46dc-a472-3280a0479145,Alpha Tester,Helped to test our software. THANK YOU!,Alpha,
05114019-6b46-4b13-b5a1-e5179ef69fb5,April Fools!,"Roses are red, gaming is fun, you are carrying too much to be able to run :(",rpg,
1a518885-520c-4f54-9f49-8b1acb674771,Braindance,I’m chippin’ in,Braindance,P4TEKZ80PZ
cbf5aafd-2554-4053-80bb-0cf82ec0a430,Bright Idea,TeamSpeak took my idea on board,FeatureBadge_Lightbulb,
d6062d9c-42a3-49c9-91dd-8c43a5a46805,Bug Catcher,I found a bug!,BugBadge_Splat,
dfc70674-0fd0-431e-b3a1-edc32d7b09b2,Challenge Accepted,"Unlocked at SCILL Play — Challenges, tournaments and more!",scill,
afed63f4-82f1-4479-ab02-0ef053f55723,Communities Early Adopter,Thank you for your Support!,communities_early_adopter,
54be472d-3163-4076-9059-7f46128d937e,Communities Purchase,Purchased a TeamSpeak Community,communities_purchase,
f85f7e21-753a-4566-b26a-4e3e9155d2ef,Cyberpunk,We have a city to burn,Cyberpunk,
c028298c-84ff-4e22-be4e-b8c17552b4bb,Digi,Digi joined your channel #DIGWIN,digi,
56df5ce2-6c5a-4a24-90e2-29e497e26170,Drone Champions League,I follow the Drone Champions League,DCL_Badge,DRONECHAMP
935e5a2a-954a-44ca-aa7a-55c79285b601,E3 2018 - Winner,Discovered at E3 2018,E3-2018,
61723e54-3da2-4f19-a33f-fcdc8ef5eaa0,Father's Day 2022,Not all heroes wear capes,fathersday2022,
b9c7d6ad-5b99-40fb-988c-1d02ab6cc130,Found Tim Speak,Found Tim Speak at Gamescom 2018,met_tim,XJN4WJZEJN
809bdd5a-2601-4152-82ff-a21d23d8fd46,G2 Esports,Aged 20 years being a G2 fan,G2_Esports,
62444179-0d99-42ba-a45c-c6b1557d079a,Gamescom 2014,Registered at Gamescom 2014,gamescom_2014,
50bbdbc8-0f2a-46eb-9808-602225b49627,Gamescom 2016,Registered during Gamescom 2016,gamescom_2016,
534c9582-ab02-4267-aec6-2d94361daa2a,Gamescom 2017,Visited TeamSpeak at Gamescom 2017,gamescom_2017,DK9JGRJH1Q
4eef1ecf-a0ea-423d-bfd0-496543a00305,Gamescom 2018,Visited TeamSpeak at Gamescom 2018,gamescom_2018,8CXB49KPJ4
b82a45a5-b235-4926-be77-de102222e5eb,Gamescom 2019,Visited TeamSpeak at Gamescom 2019,Gamescom19,PNKCB76VZ8
34dbfa8f-bd27-494c-aa08-a312fc0bb240,Gamescom Hero 2017,Gaming Hero at Gamescom 2017,hero_2017,
24512806-f886-4440-b579-9e26e4219ef6,Gamescom Hero 2018,Gamescom Exclusive Gaming Hero 2018,gamescom_2018_played,BJCFQBU53C
d49fd07e-99fb-41de-8d7b-c98064713171,GommeHD.net,Your #1 Minecraft Network for over 10 years,GMHD,
c565972a-3912-457b-826f-84820c1ba6ca,Halloween 2021,Happy Halloween 2021,halloween21,
133595e7-950f-4ef2-b113-f91a68b5770d,Halloween 2021 Special,Earned by participating in our Halloween 2021 special stream,halloween21_special,
fb154277-5fe7-428a-85a4-43c0bdcdda3d,Halloween 2022,Spooky_Scary_Skeletons.mp4,halloween22,
e6679ce2-d458-493c-8ffb-5660e47ac99f,Happy Hanami,Enjoy the view,hanami2023,
de7bd960-eb02-47e1-9ce2-a44f6e255d8f,Happy Holidays 2019,Happy holidays from everyone at TeamSpeak!,Happy_Holidays,
d4ea0251-ba46-4c1a-83b7-59db3f89e52c,Happy New Year 2021,Survived the great toilet paper crisis of 2020,firework_2020,
1519e001-06a0-458c-9195-a8a6d0ec87fc,Happy New Year 2023,"Aw man, here we go again",2023_NewYear,
834d4cc1-cd80-48d6-96c4-23d131d78649,Happy Summer 2023,heat death of the universe,happy_summer_2023,
c68bcc52-7aeb-4868-b4d2-e7b20716f9ba,Heatwave 2022,I'm melting... help,summer_icecream,
94242c4e-6742-4540-8b66-ce951ed57159,Helping Hand,\ pushed some buttons *beep* *bop* ~ thanks!,homebase,
288a56c6-4da3-48de-9c9f-bd9eede5d832,Immortal Roleplay,This is your life.,Immortal_Roleplay,
69bfffc8-e9c0-4f70-8a37-47cb8c73fb1d,International Peace Day,"United we stand, divided we fall",peaceday2022,
9ea23c77-8755-4d82-b30c-92f4aac109ef,International Women's Day 2021,"To all the mums, sisters, aunties, nieces and beyond, Happy Women's Day!",wft,
7d9fa2b1-b6fa-47ad-9838-c239a4ddd116,MIFCOM,MIFCOM | Entered Performance,mifcom,
ed85bdff-2a2b-4bea-a1a5-4d06fcc0d776,Merry Christmas 2019,It’s the most wonderful ‘Tim’ of the Year,Christmas,
c6480fe2-ee25-4ee8-9853-243652c8ec54,Merry Christmas 2020,"Let it snow, let it snow, let it snow!",Christmas2020,
0581aa0f-8c2d-4681-bb9f-8492fec49977,Merry Christmas 2021,Look what Santa's left under the server tree!,christmas2021,
d4875b30-9908-43cb-a1eb-1a958e226078,Merry Christmas 2022,There's snow place like home,christmas2022,
87ccf9ea-67c9-45e5-adbc-77e210e6128a,Met Tim,Met Tim Speak IRL,tim_irl,
0d98391c-ecdf-4f26-931a-49bfd669cda7,Mind Egg,Found in the TeamSpeak 2020 Easter Egg Hunt,E_MindEgg,
2fdda3c6-20e0-48f1-9c12-f39239a2ed02,Mother's Day 2022,Thanks for bearing with us,rose,
c3f823eb-5d5c-40f9-9dbd-3437d59a539d,Official TeamSpeak Gamer,New myTeamSpeak member,TS-2018,
8dfa37ac-b40d-4466-b393-ff2184a9adf3,Overwatch League,I follow the Overwatch League,OWL_Badge,
4ce435d1-6ac5-4530-b81d-6d14ddaaa1ac,PGL Antwerp 2022,Watched the PGL CS:GO Major,PGLant,
fa3ece28-64df-431f-b1b3-90844bfdd2d9,Paris Games Week 2014,Registered at Paris Games Week 2014,paris_gamesweek_2014,
d95f9901-c42d-4bac-8849-7164fd9e2310,Paris Games Week 2016,Registered during Paris Games Week 2016,paris_gamesweek_2016,
0005232e-538e-4cb2-93b6-d7d83e873829,PietSmiet,Werde Snob auf PietSmiet.de ;),PietSmiet,
be932556-dfa9-4dc6-afd0-98de0ab25777,PolTeamgeist,WooOOHoohOOHooo,PolTeamgeist,
5f6d49e4-35c8-4809-8c81-6e71f7f749e9,Power Egg,Found in the TeamSpeak 2020 Easter Egg Hunt,E_PowerEgg,
ceee2445-4fbf-4f06-9421-286f0f4e875a,Pride,Never be afraid to show your colors.,pride,
1aa375e8-7207-45bf-8b80-556bafafc834,Reality Egg,Found in the TeamSpeak 2020 Easter Egg Hunt,E_RealityEgg,
f22c22f1-8e2d-4d99-8de9-f352dc26ac5b,Rocket Beans TV,Rocket Beans TV Community,rbtv,RWGE2NURJZ
2c9698c1-1fec-4baa-a28f-4845f045f42f,Soul Egg,Found in the TeamSpeak 2020 Easter Egg Hunt,E_SoulEgg,
641a4d85-2351-482c-97a1-02fc3b6abbb5,Space Egg,Found in the TeamSpeak 2020 Easter Egg Hunt,E_SpaceEgg,
63261116-4359-4842-873e-56820afbe068,SpartaTheOriginal,Olaf Toast @ twitch.tv/SpartaTheOriginal,Toast,
ef567ec5-f46e-4520-be07-6021023cf6bd,Sponsorship License,Sponsored by TeamSpeak,Sponsorship,
7a627d47-5496-4d68-83b5-2c4eafff9b30,"Stay Home, Stay Safe","Playing Apart, Staying Connected",StaySafeStayHome,
7262a528-c7df-4369-bc2c-d34bf5853d7b,TS Chat Alpha Tester,"Helped us test our new mobile app, thanks!",slim_golden,
6eee759e-b1e9-4937-b023-07fc778532a2,TS Gameday Participant,At least i tried...,silvered,
e1447b99-53b0-448a-98b7-ee7bad8bd268,TS Gameday Winner,As shiny as the golden frying pan,goldenjoystick,
1cb07348-34a4-4741-b50f-c41e584370f7,TeamSpeak Addon Author,Creator of TeamSpeak Addons,addon_author,
450f81c1-ab41-4211-a338-222fa94ed157,TeamSpeak Addon Developer (Bronze),Creator of at least 1 TeamSpeak Addon,addon_author_bronze,
94ec66de-5940-4e38-b002-970df0cf6c94,TeamSpeak Addon Developer (Gold),Creator of at least 5 TeamSpeak Addons,addon_author_gold,
c9e97536-5a2d-4c8e-a135-af404587a472,TeamSpeak Addon Developer (Silver),Creator of at least 3 TeamSpeak Addons,addon_author_silver,
9cd152a7-bf65-4ece-aeba-62d27678f79a,TeamSpeak Competition Winner Badge,TeamSpeak Competition Winner,CompWinnerBadge,
64221fd1-706c-4bb2-ba55-996c39effa79,TeamSpeak Jedi,myTeamSpeak early adopter,TS-OG,
6b187e83-873b-46b0-b2c2-a31af15e76a4,TeamSpeak Merch Badge,TeamSpeak Merch Owner - 1st Edition,cap_red,
22b9ec39-7694-453e-864c-dfc7b1b0d7c7,TeamSpeak Merch Badge 2.0,TeamSpeak Merch Owner - 2nd Edition,topper,
205916f3-a953-4754-8905-bc15069b1f91,TeamSpeak Merch Badge 3.0,TeamSpeak Merch Owner — 3rd Edition,Merch3,
8d843dfa-c51a-407f-87b3-94cfc8f03e96,TeamSpeak Staff,Official Staff Member,teamspeak_staff,
c2368518-3728-4260-bcd1-8b85e9f8984c,Test,"Testing, Testing.",Testing,
4086a249-a503-4f31-9e83-8a0a8e3089bd,Tim-o'-Lantern,Mwuhaahaahaahaahaa,Tim-O-Lantern,JQGCTAQWHT
089c7295-3aa2-48b0-b2f1-2dd1bec12caf,Time Egg,Found in the TeamSpeak 2020 Easter Egg Hunt,E_TimeEgg,
904e232c-f369-44db-87f7-5142e15620cc,Time Machine,Worked like a machine to update addons in super-quick time.,time_machine,
4c61af66-22ef-4897-b0bb-25fcef2acf60,Undead Nightmare,I'm the last of my kind,undead_nightmare,
b0a36aea-3e46-4e83-a455-6e92ae1b9d94,Undead Nightmare,I'm the last of my kind,undead_nightmare,
0cd924ed-c5ea-459e-b60a-4f1bc0b65f07,"Up, Up and Away!",Find me on Mount Chiliad,"up,_up_and_away!",
4b0fd4f5-d456-4294-973d-853a1db5c7d8,Valentim's Day 2019,Valentim's Day 2019,Valentines_Badge,
92801833-e721-4b7e-84d4-6c02dbb332b9,Valentim's Day 2020,Valentim's Day 2020,Valentim2020,
958f904b-8260-48a4-a961-f786cbd39411,Valentine's Day 2023,Love you like my Tamagotchi,ValentinesDay23,
a676c708-da67-4784-ba7f-3fb7e8d2e865,Valentines Day 2021,"Roses are red, TS is blue, Servers are Sweet and so are you.",valentine21,
c54a9f92-07f7-4214-90f3-eafeea8005da,World Backup Day,Don't be an April Fool. Back up your data!,backupday_2023,
448a6d13-4e08-46a1-aafa-b4ff6d6c2d06,World Bonsai Day,"harmony, balance, patience",bonsai_day,
0f976a27-ddf5-447c-b79c-0644a8e8a297,Year of the Dragon 2024,"Arise, Shenron!",year_of_the_dragon_2024,
8c22fe26-30ac-4231-8b31-67d8a75c808a,Year of the Ox 2021,Only listen to the fortune cookie; disregard all other fortune telling units.,ox21,
970c70e6-00a1-41c1-ac5c-81c89a06c7a6,Year of the Rabbit 2023,Do a barrel roll!,chineseNY2023,
92356386-0451-4a97-87d9-10ff4f43260c,Year of the Tiger 2022,Rocky sends his regards,tiger,
1 uid name description filename codes
2 4b27be5a-b92a-4b30-8b2d-14b59653f427 20th Anniversary Celebrating 20 Years of TeamSpeak 20_years
3 f81ad44d-e931-47d1-a3ef-5fd160217cf8 4Netplayers 4Netplayers customer 4netplayers
4 b78a0f3e-8758-4572-b102-42a79b4a0342 ???? Reads between the line hat
5 2bf80270-8efe-46dc-a472-3280a0479145 Alpha Tester Helped to test our software. THANK YOU! Alpha
6 05114019-6b46-4b13-b5a1-e5179ef69fb5 April Fools! Roses are red, gaming is fun, you are carrying too much to be able to run :( rpg
7 1a518885-520c-4f54-9f49-8b1acb674771 Braindance I’m chippin’ in Braindance P4TEKZ80PZ
8 cbf5aafd-2554-4053-80bb-0cf82ec0a430 Bright Idea TeamSpeak took my idea on board FeatureBadge_Lightbulb
9 d6062d9c-42a3-49c9-91dd-8c43a5a46805 Bug Catcher I found a bug! BugBadge_Splat
10 dfc70674-0fd0-431e-b3a1-edc32d7b09b2 Challenge Accepted Unlocked at SCILL Play — Challenges, tournaments and more! scill
11 afed63f4-82f1-4479-ab02-0ef053f55723 Communities Early Adopter Thank you for your Support! communities_early_adopter
12 54be472d-3163-4076-9059-7f46128d937e Communities Purchase Purchased a TeamSpeak Community communities_purchase
13 f85f7e21-753a-4566-b26a-4e3e9155d2ef Cyberpunk We have a city to burn Cyberpunk
14 c028298c-84ff-4e22-be4e-b8c17552b4bb Digi Digi joined your channel #DIGWIN digi
15 56df5ce2-6c5a-4a24-90e2-29e497e26170 Drone Champions League I follow the Drone Champions League DCL_Badge DRONECHAMP
16 935e5a2a-954a-44ca-aa7a-55c79285b601 E3 2018 - Winner Discovered at E3 2018 E3-2018
17 61723e54-3da2-4f19-a33f-fcdc8ef5eaa0 Father's Day 2022 Not all heroes wear capes fathersday2022
18 b9c7d6ad-5b99-40fb-988c-1d02ab6cc130 Found Tim Speak Found Tim Speak at Gamescom 2018 met_tim XJN4WJZEJN
19 809bdd5a-2601-4152-82ff-a21d23d8fd46 G2 Esports Aged 20 years being a G2 fan G2_Esports
20 62444179-0d99-42ba-a45c-c6b1557d079a Gamescom 2014 Registered at Gamescom 2014 gamescom_2014
21 50bbdbc8-0f2a-46eb-9808-602225b49627 Gamescom 2016 Registered during Gamescom 2016 gamescom_2016
22 534c9582-ab02-4267-aec6-2d94361daa2a Gamescom 2017 Visited TeamSpeak at Gamescom 2017 gamescom_2017 DK9JGRJH1Q
23 4eef1ecf-a0ea-423d-bfd0-496543a00305 Gamescom 2018 Visited TeamSpeak at Gamescom 2018 gamescom_2018 8CXB49KPJ4
24 b82a45a5-b235-4926-be77-de102222e5eb Gamescom 2019 Visited TeamSpeak at Gamescom 2019 Gamescom19 PNKCB76VZ8
25 34dbfa8f-bd27-494c-aa08-a312fc0bb240 Gamescom Hero 2017 Gaming Hero at Gamescom 2017 hero_2017
26 24512806-f886-4440-b579-9e26e4219ef6 Gamescom Hero 2018 Gamescom Exclusive Gaming Hero 2018 gamescom_2018_played BJCFQBU53C
27 d49fd07e-99fb-41de-8d7b-c98064713171 GommeHD.net Your #1 Minecraft Network for over 10 years GMHD
28 c565972a-3912-457b-826f-84820c1ba6ca Halloween 2021 Happy Halloween 2021 halloween21
29 133595e7-950f-4ef2-b113-f91a68b5770d Halloween 2021 Special Earned by participating in our Halloween 2021 special stream halloween21_special
30 fb154277-5fe7-428a-85a4-43c0bdcdda3d Halloween 2022 Spooky_Scary_Skeletons.mp4 halloween22
31 e6679ce2-d458-493c-8ffb-5660e47ac99f Happy Hanami Enjoy the view hanami2023
32 de7bd960-eb02-47e1-9ce2-a44f6e255d8f Happy Holidays 2019 Happy holidays from everyone at TeamSpeak! Happy_Holidays
33 d4ea0251-ba46-4c1a-83b7-59db3f89e52c Happy New Year 2021 Survived the great toilet paper crisis of 2020 firework_2020
34 1519e001-06a0-458c-9195-a8a6d0ec87fc Happy New Year 2023 Aw man, here we go again 2023_NewYear
35 834d4cc1-cd80-48d6-96c4-23d131d78649 Happy Summer 2023 heat death of the universe happy_summer_2023
36 c68bcc52-7aeb-4868-b4d2-e7b20716f9ba Heatwave 2022 I'm melting... help summer_icecream
37 94242c4e-6742-4540-8b66-ce951ed57159 Helping Hand \ pushed some buttons *beep* *bop* ~ thanks! homebase
38 288a56c6-4da3-48de-9c9f-bd9eede5d832 Immortal Roleplay This is your life. Immortal_Roleplay
39 69bfffc8-e9c0-4f70-8a37-47cb8c73fb1d International Peace Day United we stand, divided we fall peaceday2022
40 9ea23c77-8755-4d82-b30c-92f4aac109ef International Women's Day 2021 To all the mums, sisters, aunties, nieces and beyond, Happy Women's Day! wft
41 7d9fa2b1-b6fa-47ad-9838-c239a4ddd116 MIFCOM MIFCOM | Entered Performance mifcom
42 ed85bdff-2a2b-4bea-a1a5-4d06fcc0d776 Merry Christmas 2019 It’s the most wonderful ‘Tim’ of the Year Christmas
43 c6480fe2-ee25-4ee8-9853-243652c8ec54 Merry Christmas 2020 Let it snow, let it snow, let it snow! Christmas2020
44 0581aa0f-8c2d-4681-bb9f-8492fec49977 Merry Christmas 2021 Look what Santa's left under the server tree! christmas2021
45 d4875b30-9908-43cb-a1eb-1a958e226078 Merry Christmas 2022 There's snow place like home christmas2022
46 87ccf9ea-67c9-45e5-adbc-77e210e6128a Met Tim Met Tim Speak IRL tim_irl
47 0d98391c-ecdf-4f26-931a-49bfd669cda7 Mind Egg Found in the TeamSpeak 2020 Easter Egg Hunt E_MindEgg
48 2fdda3c6-20e0-48f1-9c12-f39239a2ed02 Mother's Day 2022 Thanks for bearing with us rose
49 c3f823eb-5d5c-40f9-9dbd-3437d59a539d Official TeamSpeak Gamer New myTeamSpeak member TS-2018
50 8dfa37ac-b40d-4466-b393-ff2184a9adf3 Overwatch League I follow the Overwatch League OWL_Badge
51 4ce435d1-6ac5-4530-b81d-6d14ddaaa1ac PGL Antwerp 2022 Watched the PGL CS:GO Major PGLant
52 fa3ece28-64df-431f-b1b3-90844bfdd2d9 Paris Games Week 2014 Registered at Paris Games Week 2014 paris_gamesweek_2014
53 d95f9901-c42d-4bac-8849-7164fd9e2310 Paris Games Week 2016 Registered during Paris Games Week 2016 paris_gamesweek_2016
54 0005232e-538e-4cb2-93b6-d7d83e873829 PietSmiet Werde Snob auf PietSmiet.de ;) PietSmiet
55 be932556-dfa9-4dc6-afd0-98de0ab25777 PolTeamgeist WooOOHoohOOHooo PolTeamgeist
56 5f6d49e4-35c8-4809-8c81-6e71f7f749e9 Power Egg Found in the TeamSpeak 2020 Easter Egg Hunt E_PowerEgg
57 ceee2445-4fbf-4f06-9421-286f0f4e875a Pride Never be afraid to show your colors. pride
58 1aa375e8-7207-45bf-8b80-556bafafc834 Reality Egg Found in the TeamSpeak 2020 Easter Egg Hunt E_RealityEgg
59 f22c22f1-8e2d-4d99-8de9-f352dc26ac5b Rocket Beans TV Rocket Beans TV Community rbtv RWGE2NURJZ
60 2c9698c1-1fec-4baa-a28f-4845f045f42f Soul Egg Found in the TeamSpeak 2020 Easter Egg Hunt E_SoulEgg
61 641a4d85-2351-482c-97a1-02fc3b6abbb5 Space Egg Found in the TeamSpeak 2020 Easter Egg Hunt E_SpaceEgg
62 63261116-4359-4842-873e-56820afbe068 SpartaTheOriginal Olaf Toast @ twitch.tv/SpartaTheOriginal Toast
63 ef567ec5-f46e-4520-be07-6021023cf6bd Sponsorship License Sponsored by TeamSpeak Sponsorship
64 7a627d47-5496-4d68-83b5-2c4eafff9b30 Stay Home, Stay Safe Playing Apart, Staying Connected StaySafeStayHome
65 7262a528-c7df-4369-bc2c-d34bf5853d7b TS Chat Alpha Tester Helped us test our new mobile app, thanks! slim_golden
66 6eee759e-b1e9-4937-b023-07fc778532a2 TS Gameday Participant At least i tried... silvered
67 e1447b99-53b0-448a-98b7-ee7bad8bd268 TS Gameday Winner As shiny as the golden frying pan goldenjoystick
68 1cb07348-34a4-4741-b50f-c41e584370f7 TeamSpeak Addon Author Creator of TeamSpeak Addons addon_author
69 450f81c1-ab41-4211-a338-222fa94ed157 TeamSpeak Addon Developer (Bronze) Creator of at least 1 TeamSpeak Addon addon_author_bronze
70 94ec66de-5940-4e38-b002-970df0cf6c94 TeamSpeak Addon Developer (Gold) Creator of at least 5 TeamSpeak Addons addon_author_gold
71 c9e97536-5a2d-4c8e-a135-af404587a472 TeamSpeak Addon Developer (Silver) Creator of at least 3 TeamSpeak Addons addon_author_silver
72 9cd152a7-bf65-4ece-aeba-62d27678f79a TeamSpeak Competition Winner Badge TeamSpeak Competition Winner CompWinnerBadge
73 64221fd1-706c-4bb2-ba55-996c39effa79 TeamSpeak Jedi myTeamSpeak early adopter TS-OG
74 6b187e83-873b-46b0-b2c2-a31af15e76a4 TeamSpeak Merch Badge TeamSpeak Merch Owner - 1st Edition cap_red
75 22b9ec39-7694-453e-864c-dfc7b1b0d7c7 TeamSpeak Merch Badge 2.0 TeamSpeak Merch Owner - 2nd Edition topper
76 205916f3-a953-4754-8905-bc15069b1f91 TeamSpeak Merch Badge 3.0 TeamSpeak Merch Owner — 3rd Edition Merch3
77 8d843dfa-c51a-407f-87b3-94cfc8f03e96 TeamSpeak Staff Official Staff Member teamspeak_staff
78 c2368518-3728-4260-bcd1-8b85e9f8984c Test Testing, Testing. Testing
79 4086a249-a503-4f31-9e83-8a0a8e3089bd Tim-o'-Lantern Mwuhaahaahaahaahaa Tim-O-Lantern JQGCTAQWHT
80 089c7295-3aa2-48b0-b2f1-2dd1bec12caf Time Egg Found in the TeamSpeak 2020 Easter Egg Hunt E_TimeEgg
81 904e232c-f369-44db-87f7-5142e15620cc Time Machine Worked like a machine to update addons in super-quick time. time_machine
82 4c61af66-22ef-4897-b0bb-25fcef2acf60 Undead Nightmare I'm the last of my kind undead_nightmare
83 b0a36aea-3e46-4e83-a455-6e92ae1b9d94 Undead Nightmare I'm the last of my kind undead_nightmare
84 0cd924ed-c5ea-459e-b60a-4f1bc0b65f07 Up, Up and Away! Find me on Mount Chiliad up,_up_and_away!
85 4b0fd4f5-d456-4294-973d-853a1db5c7d8 Valentim's Day 2019 Valentim's Day 2019 Valentines_Badge
86 92801833-e721-4b7e-84d4-6c02dbb332b9 Valentim's Day 2020 Valentim's Day 2020 Valentim2020
87 958f904b-8260-48a4-a961-f786cbd39411 Valentine's Day 2023 Love you like my Tamagotchi ValentinesDay23
88 a676c708-da67-4784-ba7f-3fb7e8d2e865 Valentines Day 2021 Roses are red, TS is blue, Servers are Sweet and so are you. valentine21
89 c54a9f92-07f7-4214-90f3-eafeea8005da World Backup Day Don't be an April Fool. Back up your data! backupday_2023
90 448a6d13-4e08-46a1-aafa-b4ff6d6c2d06 World Bonsai Day harmony, balance, patience bonsai_day
91 0f976a27-ddf5-447c-b79c-0644a8e8a297 Year of the Dragon 2024 Arise, Shenron! year_of_the_dragon_2024
92 8c22fe26-30ac-4231-8b31-67d8a75c808a Year of the Ox 2021 Only listen to the fortune cookie; disregard all other fortune telling units. ox21
93 970c70e6-00a1-41c1-ac5c-81c89a06c7a6 Year of the Rabbit 2023 Do a barrel roll! chineseNY2023
94 92356386-0451-4a97-87d9-10ff4f43260c Year of the Tiger 2022 Rocky sends his regards tiger
+144
View File
@@ -0,0 +1,144 @@
//! myTeamSpeak badges: what the GUIDs a client shows (`client_badges`)
//! stand for, and where TeamSpeak keeps their pictures.
//!
//! The table is `data/badges.csv`: tsclientlib's list (2023, also in
//! `proto/tsproto-structs/declarations`) and the newer badges of
//! TeamSpeak's own list (`https://badges-content.teamspeak.com/list`, a
//! protobuf) as of October 2026. Badges added since are unknown here.
use std::collections::HashMap;
use std::sync::LazyLock;
/// How many badges a client shows at most (TeamSpeak lets one pick three).
pub const SHOWN: usize = 3;
/// TeamSpeak's server for the badges' pictures.
const CONTENT: &str = "https://badges-content.teamspeak.com";
/// One badge of the table.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct BadgeInfo {
pub name: String,
pub description: String,
/// Its picture's name on TeamSpeak's server, without `.svg`.
pub filename: String,
}
/// The table by GUID (lower case), read once.
static BADGES: LazyLock<HashMap<String, BadgeInfo>> = LazyLock::new(|| {
// Columns: uid, name, description, filename, codes.
records(include_str!("../data/badges.csv"))
.into_iter()
.skip(1)
.filter_map(|mut fields| {
fields.truncate(4);
let [uid, name, description, filename] = <[String; 4]>::try_from(fields).ok()?;
Some((uid.to_ascii_lowercase(), BadgeInfo { name, description, filename }))
})
.collect()
});
/// What a badge GUID stands for; none for one the table does not know.
pub fn info(guid: &str) -> Option<&'static BadgeInfo> {
BADGES.get(&guid.to_ascii_lowercase())
}
/// The address of a badge's picture (an SVG); none for an unknown badge.
pub fn icon_url(guid: &str) -> Option<String> {
let info = info(guid)?;
Some(format!("{CONTENT}/{}/{}.svg", guid.to_ascii_lowercase(), info.filename))
}
/// The records of a CSV text (RFC 4180): fields split at commas; a quoted
/// field may hold commas and line breaks, and `""` for a quote.
fn records(text: &str) -> Vec<Vec<String>> {
let mut records = Vec::new();
let mut record = Vec::new();
let mut field = String::new();
let mut quoted = false;
let mut chars = text.chars().peekable();
while let Some(c) = chars.next() {
match c {
'"' if quoted => {
if chars.next_if_eq(&'"').is_some() {
field.push('"');
} else {
quoted = false;
}
}
'"' if field.is_empty() => quoted = true,
',' if !quoted => record.push(std::mem::take(&mut field)),
'\r' if !quoted => {}
'\n' if !quoted => {
record.push(std::mem::take(&mut field));
records.push(std::mem::take(&mut record));
}
c => field.push(c),
}
}
if !field.is_empty() || !record.is_empty() {
record.push(field);
records.push(record);
}
records
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn known_badges() {
let info = info("4b27be5a-b92a-4b30-8b2d-14b59653f427").unwrap();
assert_eq!(info.name, "20th Anniversary");
assert_eq!(info.description, "Celebrating 20 Years of TeamSpeak");
assert_eq!(info.filename, "20_years");
// Upper case on the wire finds it too.
assert_eq!(super::info("4B27BE5A-B92A-4B30-8B2D-14B59653F427"), Some(info));
assert_eq!(
icon_url("4b27be5a-b92a-4b30-8b2d-14b59653f427").as_deref(),
Some(
"https://badges-content.teamspeak.com/4b27be5a-b92a-4b30-8b2d-14b59653f427/20_years.svg"
)
);
}
#[test]
fn quoted_fields_keep_their_commas() {
let fools = info("05114019-6b46-4b13-b5a1-e5179ef69fb5").unwrap();
assert_eq!(fools.name, "April Fools!");
assert_eq!(
fools.description,
"Roses are red, gaming is fun, you are carrying too much to be able to run :("
);
assert_eq!(fools.filename, "rpg");
let stay = info("7a627d47-5496-4d68-83b5-2c4eafff9b30").unwrap();
assert_eq!(stay.name, "Stay Home, Stay Safe");
assert_eq!(stay.description, "Playing Apart, Staying Connected");
let up = info("0cd924ed-c5ea-459e-b60a-4f1bc0b65f07").unwrap();
assert_eq!(up.filename, "up,_up_and_away!");
}
#[test]
fn unknown_badges() {
assert_eq!(info("00000000-0000-0000-0000-000000000000"), None);
assert_eq!(info(""), None);
assert_eq!(icon_url("00000000-0000-0000-0000-000000000000"), None);
}
#[test]
fn every_row_is_read() {
let rows = include_str!("../data/badges.csv").lines().count() - 1;
assert_eq!(BADGES.len(), rows);
assert!(BADGES.values().all(|b| !b.name.is_empty() && !b.filename.is_empty()));
}
#[test]
fn csv_records() {
assert_eq!(
records("a,\"b, \"\"c\"\"\",\r\n\"multi\nline\",d"),
[vec!["a", "b, \"c\"", ""], vec!["multi\nline", "d"]]
);
assert!(records("").is_empty());
}
}
+1
View File
@@ -3,6 +3,7 @@
//! Nothing in here does IO; the types describe what a server offers and what
//! the user sees.
pub mod badges;
mod chat;
mod presence;
mod server;
+3 -1
View File
@@ -219,7 +219,8 @@ pub(crate) struct SessionView {
pub avatars: HashMap<String, PathBuf>,
/// Icons in the engine's cache, by icon id ([`Event::IconReady`]).
pub icons: HashMap<u32, PathBuf>,
/// Banners in the engine's cache, by address ([`Event::PictureReady`]).
/// Banners and badges in the engine's cache, by address
/// ([`Event::PictureReady`]).
pub pictures: HashMap<String, PathBuf>,
/// The server's icon id as its voice connection last told it
/// ([`Event::ServerDetails`]); kept while disconnected, for the rail.
@@ -1062,6 +1063,7 @@ impl App {
self.refresh_toolbar();
self.refresh_tree();
self.refresh_chat();
self.refresh_member_card();
}
}
Event::Transfer { session, transfer, state } => {
+27 -2
View File
@@ -536,6 +536,9 @@ fn demo_ui(app: &mut App) {
clients[5].server_groups = vec![GROUP_MEMBER];
clients[6].server_groups = vec![GROUP_GUEST];
clients[7].server_groups = vec![GROUP_GUEST];
// myTeamSpeak badges; their pictures arrive below.
clients[0].badges = DEMO_BADGES[..2].iter().map(|g| g.to_string()).collect();
clients[1].badges = DEMO_BADGES[2..].iter().map(|g| g.to_string()).collect();
for c in clients {
p.clients.insert(c.id, c);
}
@@ -1095,9 +1098,18 @@ const DEMO_SERVER_ICON: u32 = 3_120_211_001;
const DEMO_ADMIN_ICON: u32 = 3_120_211_002;
const DEMO_MOD_ICON: u32 = 3_120_211_003;
const DEMO_MUSIC_ICON: u32 = 3_120_211_004;
/// Real badge GUIDs: 20th Anniversary, TeamSpeak Jedi (Nova's), Gamescom
/// 2019, Pride and Year of the Tiger 2022 (Lumen's).
const DEMO_BADGES: [&str; 5] = [
"4b27be5a-b92a-4b30-8b2d-14b59653f427",
"64221fd1-706c-4bb2-ba55-996c39effa79",
"b82a45a5-b235-4926-be77-de102222e5eb",
"ceee2445-4fbf-4f06-9421-286f0f4e875a",
"92356386-0451-4a97-87d9-10ff4f43260c",
];
/// Avatars, icons and banners as the engine reports them once they are in
/// its cache (here a folder of synthetic pictures in the temporary
/// Avatars, icons, banners and badges as the engine reports them once they
/// are in its cache (here a folder of synthetic pictures in the temporary
/// directory).
fn demo_pictures(app: &mut App) {
let session = DEMO as u64;
@@ -1134,6 +1146,19 @@ fn demo_pictures(app: &mut App) {
let path = save(&icon.to_string(), demo_icon(color, shape));
events.push(Event::IconReady { session, icon, path });
}
// Stand-ins for the badges' pictures on TeamSpeak's server.
let badge_looks = [
([242, 178, 44], Shape::Ring),
([90, 170, 255], Shape::Moon),
([45, 196, 132], Shape::Diamond),
([240, 110, 160], Shape::Disc),
([255, 140, 90], Shape::Diamond),
];
for (guid, (color, shape)) in DEMO_BADGES.into_iter().zip(badge_looks) {
let Some(url) = voelin_model::badges::icon_url(guid) else { continue };
let path = save(&format!("badge-{guid}"), demo_icon(color, shape));
events.push(Event::PictureReady { session, url, path });
}
// Some people have pictures, the rest initials.
for (sample_session, uid, seed) in [
(session, "demo-2", 1),
+2
View File
@@ -53,6 +53,7 @@ impl App {
.filter_map(|g| view.server_groups.iter().find(|i| i.id == *g))
.map(|g| g.name.clone().into())
.collect();
let badges = vm::tree::badge_items(&client.badges, &view.pictures);
Some(MemberCard {
open: true,
id: i32::from(id),
@@ -63,6 +64,7 @@ impl App {
status: vm::tree::status_of(client, view.talking.contains(&id)).into(),
description: client.description.clone().unwrap_or_default().into(),
groups: crate::app::model(groups),
badges: crate::app::model(badges),
country: client.country.clone().unwrap_or_default().into(),
talk_power: client.talk_power,
friend: contact.is_some_and(|c| c.relation == Relation::Friend),
+89 -3
View File
@@ -6,10 +6,11 @@ use std::path::PathBuf;
pub use voelin_model::channel_title;
use voelin_model::{
BannerMode, ChannelId, ChannelInfo, ClientInfo, GroupInfo, Presence, Spacer, TreeRow, tree_rows,
BannerMode, ChannelId, ChannelInfo, ClientInfo, GroupInfo, Presence, Spacer, TreeRow, badges,
tree_rows,
};
use crate::app::{MemberItem, TreeItem};
use crate::app::{BadgeItem, MemberItem, TreeItem};
use crate::settings::ClientPlaybackMap;
use crate::vm::avatar;
@@ -27,6 +28,31 @@ pub fn banner(pictures: &HashMap<String, PathBuf>, url: Option<&str>) -> slint::
avatar::image(url.and_then(|u| pictures.get(u)))
}
/// A badge's picture, if the engine fetched it.
fn badge_icon(pictures: &HashMap<String, PathBuf>, guid: &str) -> slint::Image {
avatar::image(badges::icon_url(guid).and_then(|url| pictures.get(&url)))
}
/// A client's badges for the member card: the first three in its order.
/// One the app does not know is "Badge", with its GUID as description.
pub fn badge_items(guids: &[String], pictures: &HashMap<String, PathBuf>) -> Vec<BadgeItem> {
guids
.iter()
.take(badges::SHOWN)
.map(|guid| {
let (name, description) = match badges::info(guid) {
Some(info) => (info.name.as_str(), info.description.as_str()),
None => ("Badge", guid.as_str()),
};
BadgeItem {
name: name.into(),
description: description.into(),
icon: badge_icon(pictures, guid),
}
})
.collect()
}
/// What the tree shows besides the presence.
pub struct TreeInput<'a> {
pub presence: &'a Presence,
@@ -43,7 +69,7 @@ pub struct TreeInput<'a> {
/// Icons in the engine's cache, by icon id (channel, group and client
/// icons).
pub icons: &'a HashMap<u32, PathBuf>,
/// Banner pictures in the engine's cache, by address.
/// Banners and badges in the engine's cache, by address.
pub pictures: &'a HashMap<String, PathBuf>,
/// The server groups in display order; members are grouped by the
/// first one each client is in.
@@ -77,6 +103,18 @@ impl TreeInput<'_> {
.collect()
}
/// The pictures of the badges a client shows that arrived, in its
/// order; empty slots last.
fn badges(&self, client: &ClientInfo) -> [slint::Image; badges::SHOWN] {
let mut icons = client
.badges
.iter()
.take(badges::SHOWN)
.map(|guid| badge_icon(self.pictures, guid))
.filter(|i| i.size().width > 0);
std::array::from_fn(|_| icons.next().unwrap_or_default())
}
/// The group a client is sorted under: the first of its server groups
/// in display order.
fn group_of(&self, client: &ClientInfo) -> Option<&GroupInfo> {
@@ -178,6 +216,7 @@ pub fn rows(input: &TreeInput) -> Vec<TreeItem> {
.copied()
.unwrap_or_default();
let mut icons = input.client_icons(client).into_iter();
let [badge, badge_2, badge_3] = input.badges(client);
TreeItem {
is_channel: false,
depth: depth as i32,
@@ -197,6 +236,9 @@ pub fn rows(input: &TreeInput) -> Vec<TreeItem> {
icon: icons.next().unwrap_or_default(),
icon_2: icons.next().unwrap_or_default(),
icon_3: icons.next().unwrap_or_default(),
badge,
badge_2,
badge_3,
..Default::default()
}
}
@@ -279,6 +321,7 @@ impl TreeInput<'_> {
Some(channel) if elsewhere => format!("In {}", channel_title(channel).0),
_ => status_of(c, talking),
};
let [badge, badge_2, badge_3] = self.badges(c);
MemberItem {
id: c.id as i32,
name: c.nickname.clone().into(),
@@ -303,6 +346,9 @@ impl TreeInput<'_> {
commander: c.channel_commander,
recording: c.recording,
talk_power: c.talk_power,
badge,
badge_2,
badge_3,
}
}
}
@@ -536,6 +582,46 @@ mod tests {
std::fs::remove_dir_all(dir).unwrap();
}
/// A client's badges: the first three in its order, on the card by name
/// ("Badge" for one the app does not know), in the rows the pictures
/// that arrived.
#[test]
fn badges_on_the_card_and_in_rows() {
let dir = std::env::temp_dir().join(format!("voelin-tree-badges-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let guids: Vec<String> = [
"4b27be5a-b92a-4b30-8b2d-14b59653f427",
"00000000-0000-0000-0000-000000000000",
"05114019-6b46-4b13-b5a1-e5179ef69fb5",
"2bf80270-8efe-46dc-a472-3280a0479145",
]
.map(String::from)
.into();
let picture = |i: usize, width| {
(badges::icon_url(&guids[i]).unwrap(), picture_file(&dir, &format!("badge-{i}"), width))
};
let e = Extras {
pictures: HashMap::from([picture(0, 3), picture(2, 5), picture(3, 7)]),
..Default::default()
};
let width = |i: &slint::Image| i.size().width;
let card = badge_items(&guids, &e.pictures);
let names: Vec<_> = card.iter().map(|b| b.name.as_str()).collect();
assert_eq!(names, ["20th Anniversary", "Badge", "April Fools!"]);
assert_eq!(card[1].description.as_str(), guids[1]);
assert_eq!(card.iter().map(|b| width(&b.icon)).collect::<Vec<_>>(), [3, 0, 5]);
let mut p = presence();
p.clients.get_mut(&11).unwrap().badges = guids;
let (t, c, pb) = (HashSet::new(), HashSet::new(), ClientPlaybackMap::new());
let tree = input(&p, &t, &c, &pb, "", &e);
let bob = rows(&tree).into_iter().find(|r| !r.is_channel && r.id == 11).unwrap();
assert_eq!([&bob.badge, &bob.badge_2, &bob.badge_3].map(width), [3, 5, 0]);
let bob = members(&tree).into_iter().find(|m| m.id == 11).unwrap();
assert_eq!([&bob.badge, &bob.badge_2, &bob.badge_3].map(width), [3, 5, 0]);
std::fs::remove_dir_all(dir).unwrap();
}
#[test]
fn spacer_rows_keep_tree_identity() {
let mut p = presence();
+19
View File
@@ -62,6 +62,11 @@ export struct TreeItem {
icon: image,
icon-2: image,
icon-3: image,
// A client's badges (myTeamSpeak), the first three in its order, empty
// where absent; shown after the name.
badge: image,
badge-2: image,
badge-3: image,
// A channel's banner picture (TeamSpeak 6), drawn behind the row;
// Wire sizing metadata; compact decorative backgrounds always cover.
banner: image,
@@ -103,6 +108,18 @@ export struct MemberItem {
recording: bool,
// `client_talk_power`; shown when the channel needs it.
talk-power: int,
// myTeamSpeak badges, as in `TreeItem`.
badge: image,
badge-2: image,
badge-3: image,
}
// A myTeamSpeak badge on the member card: "Badge" and its GUID for one
// the app does not know; its picture is empty until it is downloaded.
export struct BadgeItem {
name: string,
description: string,
icon: image,
}
// The member card over a member row: everything about one client and what
@@ -118,6 +135,8 @@ export struct MemberCard {
description: string,
// Server groups, one per line.
groups: [string],
// The badges the client shows (at most three, in its order).
badges: [BadgeItem],
country: string,
talk-power: int,
friend: bool,
@@ -53,6 +53,8 @@ export component LiveBadge inherits Rectangle {
export component Chip inherits Rectangle {
in property <string> text;
in property <image> icon;
// A picture in its own colours (a badge's), instead of a tinted icon.
in property <image> picture;
in property <color> tint: Theme.text-secondary;
in property <brush> fill: Theme.surface-3;
in property <bool> outlined;
@@ -76,6 +78,14 @@ export component Chip inherits Rectangle {
tint: root.tint;
y: (parent.height - self.height) / 2;
}
if root.picture.width > 0: Image {
source: root.picture;
width: 14px;
height: 14px;
image-fit: contain;
y: (parent.height - self.height) / 2;
accessible-role: AccessibleRole.none;
}
Text {
text: root.text;
color: root.tint;
@@ -86,6 +96,37 @@ export component Chip inherits Rectangle {
}
}
// Up to three badge pictures in their own colours, 14 px high, after a
// name; empty ones take no room.
export component BadgeIcons inherits HorizontalLayout {
in property <image> first;
in property <image> second;
in property <image> third;
spacing: 2px;
cross-axis-alignment: center;
Image {
source: root.first;
width: root.first.width > 0 ? 14px : 0px;
height: 14px;
image-fit: contain;
accessible-role: AccessibleRole.none;
}
Image {
source: root.second;
width: root.second.width > 0 ? 14px : 0px;
height: 14px;
image-fit: contain;
accessible-role: AccessibleRole.none;
}
Image {
source: root.third;
width: root.third.width > 0 ? 14px : 0px;
height: 14px;
image-fit: contain;
accessible-role: AccessibleRole.none;
}
}
// A coloured dot (online, connection state).
export component Dot inherits Rectangle {
in property <length> size: 8px;
+1 -1
View File
@@ -10,7 +10,7 @@ export { Slider } from "slider.slint";
export { SegmentedTabs, TabItem } from "tabs.slint";
export { Status, Avatar } from "avatar.slint";
export { BannerPicture } from "banner-picture.slint";
export { CountBadge, LiveBadge, Chip, Dot } from "badge.slint";
export { CountBadge, LiveBadge, Chip, BadgeIcons, Dot } from "badge.slint";
export { SectionHeader, Card, Divider, Banner } from "card.slint";
export { Meter, SpeakingBars } from "meter.slint";
export { NavItem, ListItem } from "list-item.slint";
+10 -2
View File
@@ -6,7 +6,7 @@ import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
import { Bridge, TreeItem } from "../bridge.slint";
import { Nav } from "../nav.slint";
import { Icon, Button, ButtonKind, IconButton, Avatar, LiveBadge, Chip, SectionHeader, SpeakingBars, PopupMenu, MenuEntry, ListView, BannerPicture } from "../components/index.slint";
import { Icon, Button, ButtonKind, IconButton, Avatar, LiveBadge, Chip, BadgeIcons, SectionHeader, SpeakingBars, PopupMenu, MenuEntry, ListView, BannerPicture } from "../components/index.slint";
// The banner at the top of the sidebar: server name, counts, a menu.
export component ServerHeader inherits Rectangle {
@@ -257,14 +257,22 @@ component TreeRow inherits Rectangle {
label: item.name;
}
}
// The name elides first; its badges follow it, then the free room.
Text {
text: item.name;
color: item.away ? Theme.text-muted : item.myself ? Theme.accent-text : Theme.text-secondary;
font-weight: item.myself ? Theme.weight-semibold : Theme.weight-regular;
vertical-alignment: center;
horizontal-stretch: 1;
horizontal-stretch: 0;
overflow: elide;
}
BadgeIcons {
horizontal-stretch: 1;
alignment: start;
first: item.badge;
second: item.badge-2;
third: item.badge-3;
}
if item.talking: VerticalLayout {
alignment: center;
SpeakingBars { }
+30 -1
View File
@@ -6,7 +6,7 @@ import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
import { Bridge, MemberItem } from "../bridge.slint";
import { Nav } from "../nav.slint";
import { Icon, IconButton, Button, ButtonKind, Avatar, Status, LiveBadge, Chip, Divider, Slider, SpeakingBars, Tooltip, SearchBox, ListView } from "../components/index.slint";
import { Icon, IconButton, Button, ButtonKind, Avatar, Status, LiveBadge, Chip, BadgeIcons, Divider, Slider, SpeakingBars, Tooltip, SearchBox, ListView } from "../components/index.slint";
// Crown, priority speaker, channel commander, recording.
component MemberBadges inherits HorizontalLayout {
@@ -118,6 +118,11 @@ export component MemberRow inherits Rectangle {
member: member;
y: (parent.height - self.height) / 2;
}
BadgeIcons {
first: member.badge;
second: member.badge-2;
third: member.badge-3;
}
}
HorizontalLayout {
spacing: Theme.space-2;
@@ -251,6 +256,30 @@ export component MemberCardPopup inherits Rectangle {
overflow: elide;
}
}
// myTeamSpeak badges; each tells what it is for on hover.
if Bridge.member-card.badges.length > 0: VerticalLayout {
spacing: Theme.space-2;
Text {
text: @tr("Badges");
color: Theme.text-muted;
font-size: Theme.font-xs;
font-weight: Theme.weight-semibold;
}
// Chips that do not fit go on the next line.
FlexboxLayout {
spacing: Theme.space-2;
for badge in Bridge.member-card.badges: Tooltip {
text: badge.description;
width: chip.width;
height: chip.height;
chip := Chip {
text: badge.name;
picture: badge.icon;
outlined: true;
}
}
}
}
HorizontalLayout {
spacing: Theme.space-2;
alignment: start;