From 1ec08c02f45ed83e2a6fc34b869ed546fc7f1e4d Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Wed, 10 Jan 2024 13:37:06 +0000 Subject: [PATCH] Show VS/coop setting details for Splatoon 3 presence embed --- src/cli/util/presence-embed-server.ts | 3 ++ src/cli/util/presence-embed.ts | 62 ++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/src/cli/util/presence-embed-server.ts b/src/cli/util/presence-embed-server.ts index 47e1b15..b81fc7d 100644 --- a/src/cli/util/presence-embed-server.ts +++ b/src/cli/util/presence-embed-server.ts @@ -126,6 +126,9 @@ class Server extends HttpServer { const image_urls = [result.friend.imageUri]; if ('imageUri' in result.friend.presence.game) image_urls.push(result.friend.presence.game.imageUri); + for (const stage of result.splatoon3_vs_setting?.vsStages ?? []) image_urls.push(stage.image.url); + if (result.splatoon3_coop_setting) image_urls.push(result.splatoon3_coop_setting.coopStage.thumbnailImage.url); + for (const weapon of result.splatoon3_coop_setting?.weapons ?? []) image_urls.push(weapon.image.url); if (options.show_splatoon3_fest_team && result.splatoon3_fest_team?.myVoteState === FestVoteState.VOTED) image_urls.push(result.splatoon3_fest_team.image.url); const url_map: Record = {}; diff --git a/src/cli/util/presence-embed.ts b/src/cli/util/presence-embed.ts index b24ccdc..a66ac6e 100644 --- a/src/cli/util/presence-embed.ts +++ b/src/cli/util/presence-embed.ts @@ -146,6 +146,9 @@ export function renderUserEmbedSvg( Buffer.from(url_map[url][1]).toString('base64') : url_map[url] as string | undefined; + const show_splatoon3_fest_team = options?.show_splatoon3_fest_team && + result.splatoon3_fest_team?.myVoteState === FestVoteState.VOTED ? result.splatoon3_fest_team : null; + const title_extra = result.title ? embed_titles[result.title.id]?.call(null, result, url_map, image, theme, options) : null; if (title_extra) height += title_extra[1]; @@ -153,8 +156,8 @@ export function renderUserEmbedSvg( @@ -170,6 +173,13 @@ export function renderUserEmbedSvg( + + + + + ${{[RawValueSymbol]: transparent ? '' : htmlentities` @@ -178,7 +188,7 @@ export function renderUserEmbedSvg( - ${result.friend.name} + ${result.friend.name} @@ -195,9 +205,9 @@ export function renderUserEmbedSvg( Friend code: SW-${friend_code} ` : ''}} - ${{[RawValueSymbol]: options?.show_splatoon3_fest_team && result.splatoon3_fest_team?.myVoteState === FestVoteState.VOTED ? htmlentities` + ${{[RawValueSymbol]: show_splatoon3_fest_team ? htmlentities` + href="${image(show_splatoon3_fest_team.image.url) ?? show_splatoon3_fest_team.image.url}" /> ` : ''}} ${{[RawValueSymbol]: title_extra?.[0] ?? ''}} @@ -233,6 +243,11 @@ function renderUserSplatoon3EmbedPartialSvg( theme = PresenceEmbedTheme.LIGHT, options?: UserEmbedOptions, ) { + const x = 180; + const y = 165; + const colours = embed_themes[theme]; + const font_family = '\'Open Sans\', -apple-system, BlinkMacSystemFont, Arial, sans-serif'; + if (result.splatoon3?.vsMode && ( result.splatoon3.onlineState === FriendOnlineState.VS_MODE_FIGHTING || result.splatoon3.onlineState === FriendOnlineState.VS_MODE_MATCHING @@ -264,6 +279,28 @@ function renderUserSplatoon3EmbedPartialSvg( ' - ' + setting.vsRule.name : '') + (result.splatoon3.onlineState === FriendOnlineState.VS_MODE_MATCHING ? ' (matching)' : ''); + if (result.splatoon3.vsMode.id === 'VnNNb2RlLTg=' && result.splatoon3_fest) { + const stage = result.splatoon3_fest.tricolorStage; + + return [htmlentities` + + + ${stage.name} + `, 55, description] as const; + } + + if (setting?.vsStages.length) { + return [htmlentities` + ${{[RawValueSymbol]: setting.vsStages.map((stage, i) => htmlentities` + + + ${stage.name} + `).join('')}} + `, (setting.vsStages.length * 50) + 5, description] as const; + } + return ['', 0, description] as const; } @@ -278,6 +315,21 @@ function renderUserSplatoon3EmbedPartialSvg( const description = (rule_name ?? 'Salmon Run') + (result.splatoon3.onlineState === FriendOnlineState.COOP_MODE_MATCHING ? ' (matching)' : ''); + const setting = result.splatoon3_coop_setting; + + if (setting) { + return [htmlentities` + + + ${setting.coopStage.name} + + ${{[RawValueSymbol]: setting.weapons.map((weapon, i) => htmlentities` + + `).join('')}} + `, 55, description] as const; + } return ['', 0, description] as const; }