diff --git a/package.json b/package.json index f23de6c..44c848c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "coh3-stats-desktop-app", "private": true, - "version": "1.2.2", + "version": "1.2.3", "type": "module", "scripts": { "dev": "vite", diff --git a/public/factions/american.webp b/public/factions/american.webp index 6b03914..441601a 100644 Binary files a/public/factions/american.webp and b/public/factions/american.webp differ diff --git a/public/factions/british.webp b/public/factions/british.webp index ed7009d..e11be2a 100644 Binary files a/public/factions/british.webp and b/public/factions/british.webp differ diff --git a/public/factions/dak.webp b/public/factions/dak.webp index 3678c8a..02bf49d 100644 Binary files a/public/factions/dak.webp and b/public/factions/dak.webp differ diff --git a/public/factions/german.webp b/public/factions/german.webp index cd30887..b0653b3 100644 Binary files a/public/factions/german.webp and b/public/factions/german.webp differ diff --git a/public/factions/plain/american.webp b/public/factions/plain/american.webp new file mode 100644 index 0000000..6b03914 Binary files /dev/null and b/public/factions/plain/american.webp differ diff --git a/public/factions/plain/british.webp b/public/factions/plain/british.webp new file mode 100644 index 0000000..ed7009d Binary files /dev/null and b/public/factions/plain/british.webp differ diff --git a/public/factions/plain/dak.webp b/public/factions/plain/dak.webp new file mode 100644 index 0000000..3678c8a Binary files /dev/null and b/public/factions/plain/dak.webp differ diff --git a/public/factions/plain/german.webp b/public/factions/plain/german.webp new file mode 100644 index 0000000..cd30887 Binary files /dev/null and b/public/factions/plain/german.webp differ diff --git a/public/icons/ranks/00_placement_medium.webp b/public/icons/ranks/00_placement_medium.webp new file mode 100644 index 0000000..e825219 Binary files /dev/null and b/public/icons/ranks/00_placement_medium.webp differ diff --git a/public/icons/ranks/01_brass_01_medium.webp b/public/icons/ranks/01_brass_01_medium.webp new file mode 100644 index 0000000..bf770ef Binary files /dev/null and b/public/icons/ranks/01_brass_01_medium.webp differ diff --git a/public/icons/ranks/01_brass_02_medium.webp b/public/icons/ranks/01_brass_02_medium.webp new file mode 100644 index 0000000..bb2a3e7 Binary files /dev/null and b/public/icons/ranks/01_brass_02_medium.webp differ diff --git a/public/icons/ranks/01_brass_03_medium.webp b/public/icons/ranks/01_brass_03_medium.webp new file mode 100644 index 0000000..251bc6c Binary files /dev/null and b/public/icons/ranks/01_brass_03_medium.webp differ diff --git a/public/icons/ranks/02_bronze_01_medium.webp b/public/icons/ranks/02_bronze_01_medium.webp new file mode 100644 index 0000000..df772b0 Binary files /dev/null and b/public/icons/ranks/02_bronze_01_medium.webp differ diff --git a/public/icons/ranks/02_bronze_02_medium.webp b/public/icons/ranks/02_bronze_02_medium.webp new file mode 100644 index 0000000..bcaf98e Binary files /dev/null and b/public/icons/ranks/02_bronze_02_medium.webp differ diff --git a/public/icons/ranks/02_bronze_03_medium.webp b/public/icons/ranks/02_bronze_03_medium.webp new file mode 100644 index 0000000..c7aa807 Binary files /dev/null and b/public/icons/ranks/02_bronze_03_medium.webp differ diff --git a/public/icons/ranks/03_iron_01_medium.webp b/public/icons/ranks/03_iron_01_medium.webp new file mode 100644 index 0000000..a040e36 Binary files /dev/null and b/public/icons/ranks/03_iron_01_medium.webp differ diff --git a/public/icons/ranks/03_iron_02_medium.webp b/public/icons/ranks/03_iron_02_medium.webp new file mode 100644 index 0000000..8e82997 Binary files /dev/null and b/public/icons/ranks/03_iron_02_medium.webp differ diff --git a/public/icons/ranks/03_iron_03_medium.webp b/public/icons/ranks/03_iron_03_medium.webp new file mode 100644 index 0000000..68d65ca Binary files /dev/null and b/public/icons/ranks/03_iron_03_medium.webp differ diff --git a/public/icons/ranks/04_silver_01_medium.webp b/public/icons/ranks/04_silver_01_medium.webp new file mode 100644 index 0000000..b39e1db Binary files /dev/null and b/public/icons/ranks/04_silver_01_medium.webp differ diff --git a/public/icons/ranks/04_silver_02_medium.webp b/public/icons/ranks/04_silver_02_medium.webp new file mode 100644 index 0000000..ce06233 Binary files /dev/null and b/public/icons/ranks/04_silver_02_medium.webp differ diff --git a/public/icons/ranks/04_silver_03_medium.webp b/public/icons/ranks/04_silver_03_medium.webp new file mode 100644 index 0000000..f4c0a14 Binary files /dev/null and b/public/icons/ranks/04_silver_03_medium.webp differ diff --git a/public/icons/ranks/05_gold_01_medium.webp b/public/icons/ranks/05_gold_01_medium.webp new file mode 100644 index 0000000..12c34f0 Binary files /dev/null and b/public/icons/ranks/05_gold_01_medium.webp differ diff --git a/public/icons/ranks/05_gold_02_medium.webp b/public/icons/ranks/05_gold_02_medium.webp new file mode 100644 index 0000000..b66760c Binary files /dev/null and b/public/icons/ranks/05_gold_02_medium.webp differ diff --git a/public/icons/ranks/05_gold_03_medium.webp b/public/icons/ranks/05_gold_03_medium.webp new file mode 100644 index 0000000..4a8a9a9 Binary files /dev/null and b/public/icons/ranks/05_gold_03_medium.webp differ diff --git a/public/icons/ranks/06_master_01_medium.webp b/public/icons/ranks/06_master_01_medium.webp new file mode 100644 index 0000000..2623252 Binary files /dev/null and b/public/icons/ranks/06_master_01_medium.webp differ diff --git a/public/icons/ranks/06_master_02_medium.webp b/public/icons/ranks/06_master_02_medium.webp new file mode 100644 index 0000000..4aa254c Binary files /dev/null and b/public/icons/ranks/06_master_02_medium.webp differ diff --git a/public/icons/ranks/06_master_03_medium.webp b/public/icons/ranks/06_master_03_medium.webp new file mode 100644 index 0000000..757129a Binary files /dev/null and b/public/icons/ranks/06_master_03_medium.webp differ diff --git a/public/icons/ranks/06_master_04_medium.webp b/public/icons/ranks/06_master_04_medium.webp new file mode 100644 index 0000000..8548cd0 Binary files /dev/null and b/public/icons/ranks/06_master_04_medium.webp differ diff --git a/public/icons/ranks/06_master_05_medium.webp b/public/icons/ranks/06_master_05_medium.webp new file mode 100644 index 0000000..cb8c0a7 Binary files /dev/null and b/public/icons/ranks/06_master_05_medium.webp differ diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index a0f5a66..fb05318 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -492,7 +492,7 @@ dependencies = [ [[package]] name = "coh3-stats-desktop-app" -version = "1.2.2" +version = "1.2.3" dependencies = [ "criterion", "log", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 631fb6c..7d4d21c 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "coh3-stats-desktop-app" -version = "1.2.2" -description = "A Tauri App" -authors = ["you"] +version = "1.2.3" +description = "COH3 Stats Desktop App" +authors = ["coh3stats team"] license = "" repository = "" edition = "2021" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index eda2708..5ff9973 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -7,7 +7,7 @@ }, "package": { "productName": "Coh3 Stats Desktop App", - "version": "1.2.2" + "version": "1.2.3" }, "tauri": { "allowlist": { @@ -90,7 +90,7 @@ "fullscreen": false, "resizable": true, "focus": true, - "title": "CoH3 Stats Desktop App", + "title": "COH3 Stats Desktop App", "width": 1200, "minWidth": 900, "height": 600, diff --git a/src/About.tsx b/src/About.tsx index b00c3a4..acc8925 100644 --- a/src/About.tsx +++ b/src/About.tsx @@ -86,7 +86,7 @@ export const About: React.FC = () => { Ko-fi donations Donate diff --git a/src/Settings.tsx b/src/Settings.tsx index 63659c2..8d045c4 100644 --- a/src/Settings.tsx +++ b/src/Settings.tsx @@ -217,6 +217,16 @@ export const Settings: React.FC = () => { > Setup instructions + {" "}&{" "} + openLink( + "https://github.com/cohstats/coh3-stats-desktop-app#custom-css-for-the-overlay" + ) + } + > + Custom CSS instructions + + Path to streamerOverlay.html: diff --git a/src/components/PlayerCard.tsx b/src/components/PlayerCard.tsx index cf948f9..fb28345 100644 --- a/src/components/PlayerCard.tsx +++ b/src/components/PlayerCard.tsx @@ -21,6 +21,7 @@ import { PlayerWinRatio } from "./PlayerWinRatio" import { PlayerWins } from "./PlayerWins" import { open } from "@tauri-apps/api/shell" import { getFactionName, getCountryName } from "../utils/renameLabels" +import RankIcon from "./other/rank-icon"; export interface PlayerCardProps extends FullPlayerData {} @@ -56,6 +57,7 @@ export const PlayerCard: React.FC = ({ + {!ai ? ( @@ -77,10 +79,13 @@ export const PlayerCard: React.FC = ({ {/**/} + + + diff --git a/src/components/other/rank-icon.tsx b/src/components/other/rank-icon.tsx new file mode 100644 index 0000000..0e16af0 --- /dev/null +++ b/src/components/other/rank-icon.tsx @@ -0,0 +1,23 @@ +import { Tooltip, Image } from "@mantine/core"; +import {calculatePlayerTier} from "../../utils/utils"; + + +type Props = { + size: number; + rating: number; + rank: number; +}; + +const RankIcon = ({ size, rank, rating }: Props) => { + const rankTier = calculatePlayerTier(rank, rating); + + return ( + <> + + {rankTier.name} + + + ); +}; + +export default RankIcon; diff --git a/src/streamer-overlay/SPECIAL-REACT/HTML.tsx b/src/streamer-overlay/SPECIAL-REACT/HTML.tsx index 3828d24..d60f85a 100644 --- a/src/streamer-overlay/SPECIAL-REACT/HTML.tsx +++ b/src/streamer-overlay/SPECIAL-REACT/HTML.tsx @@ -6,7 +6,7 @@ export interface HTMLProps { /** * You cannot use mantine here! - * This react component is meant for the streamerOverlay where only inline styles work! + * This React component is meant for the streamerOverlay where only inline styles work! */ export const HTML: React.FC = ({ html }) => { return ( @@ -30,12 +30,74 @@ export const HTML: React.FC = ({ html }) => { href="https://fonts.googleapis.com/css2?family=Tilt+Warp&display=swap" rel="stylesheet" /> - Coh3 Stats Desktop App Overlay + COH3 Stats Desktop App Overlay @@ -47,7 +109,7 @@ export const HTML: React.FC = ({ html }) => { } /* - background: url(https://i.ytimg.com/vi/NVqOvsHxqFc/maxresdefault.jpg) no-repeat center center fixed; + background: url(https://i.ytimg.com/vi/NVqOvsHxqFc/maxresdefault.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; diff --git a/src/streamer-overlay/SPECIAL-REACT/OverlayApp.tsx b/src/streamer-overlay/SPECIAL-REACT/OverlayApp.tsx index e65f5fd..ffde3e7 100644 --- a/src/streamer-overlay/SPECIAL-REACT/OverlayApp.tsx +++ b/src/streamer-overlay/SPECIAL-REACT/OverlayApp.tsx @@ -25,24 +25,10 @@ export const OverlayApp: React.FC = ({ gameData.state === "Loading" || gameData.state === "InGame" ? (
{gameData.left.players.map((player, index) => ( = ({ ))}
{gameData.right.players.map((player, index) => ( = ({ }) => { return (
{flags ? ( ) : null} {playerData.rank === undefined || playerData.rank === -1 ? "-" : "#" + playerData.rank} {" "} {playerData.rating === undefined || playerData.rating === -1 ? "-" : playerData.rating} {" "} {playerData.name} diff --git a/src/utils/coh3-data.ts b/src/utils/coh3-data.ts new file mode 100644 index 0000000..8703c5c --- /dev/null +++ b/src/utils/coh3-data.ts @@ -0,0 +1,156 @@ + +export type PlayerRank = { name: string; url: string; min: number; max: number; rank: number }; + +export const PlayerRanks: Record = { + // Requires 10 matches to get the placement rank. + NO_RANK: { + name: "Placement", + url: "/icons/ranks/00_placement_medium.webp", + min: -1, + max: -1, + rank: 0, + }, + // All other ranks after completing 10 matches. + BRASS_3: { + name: "Brass 3", + url: "/icons/ranks/01_brass_03_medium.webp", + min: 0, + max: 299, + rank: 0, + }, + BRASS_2: { + name: "Brass 2", + url: "/icons/ranks/01_brass_02_medium.webp", + min: 300, + max: 599, + rank: 0, + }, + BRASS_1: { + name: "Brass 1", + url: "/icons/ranks/01_brass_01_medium.webp", + min: 600, + max: 799, + rank: 0, + }, + BRONZE_3: { + name: "Bronze 3", + url: "/icons/ranks/02_bronze_03_medium.webp", + min: 800, + max: 999, + rank: 0, + }, + BRONZE_2: { + name: "Bronze 2", + url: "/icons/ranks/02_bronze_02_medium.webp", + min: 1000, + max: 1049, + rank: 0, + }, + BRONZE_1: { + name: "Bronze 1", + url: "/icons/ranks/02_bronze_01_medium.webp", + min: 1050, + max: 1099, + rank: 0, + }, + IRON_3: { + name: "Iron 3", + url: "/icons/ranks/03_iron_03_medium.webp", + min: 1100, + max: 1149, + rank: 0, + }, + IRON_2: { + name: "Iron 2", + url: "/icons/ranks/03_iron_02_medium.webp", + min: 1150, + max: 1199, + rank: 0, + }, + IRON_1: { + name: "Iron 1", + url: "/icons/ranks/03_iron_01_medium.webp", + min: 1200, + max: 1249, + rank: 0, + }, + SILVER_3: { + name: "Silver 3", + url: "/icons/ranks/04_silver_03_medium.webp", + min: 1250, + max: 1299, + rank: 0, + }, + SILVER_2: { + name: "Silver 2", + url: "/icons/ranks/04_silver_02_medium.webp", + min: 1300, + max: 1349, + rank: 0, + }, + SILVER_1: { + name: "Silver 1", + url: "/icons/ranks/04_silver_01_medium.webp", + min: 1350, + max: 1399, + rank: 0, + }, + GOLD_3: { + name: "Gold 3", + url: "/icons/ranks/05_gold_03_medium.webp", + min: 1400, + max: 1499, + rank: 0, + }, + GOLD_2: { + name: "Gold 2", + url: "/icons/ranks/05_gold_02_medium.webp", + min: 1500, + max: 1599, + rank: 0, + }, + // Not in the top 50 players per leaderboard. + GOLD_1: { + name: "Gold 1", + url: "/icons/ranks/05_gold_01_medium.webp", + min: 1600, + max: 5000, + rank: 0, + }, + // These ranks need the special "top" field to identify those players above +1600 ELO in the leaderboard. + CHALLENGER_5: { + name: "Challenger 5", + url: "/icons/ranks/06_master_05_medium.webp", + min: 1600, + max: 5000, + rank: 50, + }, + CHALLENGER_4: { + name: "Challenger 4", + url: "/icons/ranks/06_master_04_medium.webp", + min: 1600, + max: 5000, + rank: 25, + }, + CHALLENGER_3: { + name: "Challenger 3", + url: "/icons/ranks/06_master_03_medium.webp", + min: 1600, + max: 5000, + rank: 10, + }, + CHALLENGER_2: { + name: "Challenger 2", + url: "/icons/ranks/06_master_02_medium.webp", + min: 1600, + max: 5000, + rank: 5, + }, + CHALLENGER_1: { + name: "Challenger 1", + url: "/icons/ranks/06_master_01_medium.webp", + min: 1600, + max: 5000, + rank: 1, + }, +}; diff --git a/src/utils/utils.ts b/src/utils/utils.ts new file mode 100644 index 0000000..bbc9bd8 --- /dev/null +++ b/src/utils/utils.ts @@ -0,0 +1,39 @@ +import {PlayerRanks} from "./coh3-data"; + +export const calculatePlayerTier = (rank: number, rating: number) => { + if (!rank || rank <= 0) { + return PlayerRanks.NO_RANK; + } + + if (rating < 1600) { + const playerRank = Object.values(PlayerRanks).find((x) => x.min <= rating && rating <= x.max); + + return playerRank || PlayerRanks.NO_RANK; + } + + // If rating is higher than 1600, take into account the rank. + if (rating >= 1600) { + // GOLD_1 is exception + if (rank > 50) { + return PlayerRanks.GOLD_1; + } + + // Create a sorted array of PlayerRanks entries + const sortedPlayerRanks = Object.entries(PlayerRanks).sort( + ([, rankInfoA], [, rankInfoB]) => rankInfoA.rank - rankInfoB.rank, + ); + + let rankKey = "CHALLENGER_5"; + + for (const [key, rankInfo] of sortedPlayerRanks) { + if (rank <= rankInfo.rank) { + rankKey = key; + break; + } + } + + return PlayerRanks[rankKey]; + } + + return PlayerRanks.NO_RANK; +};