Skip to content

Commit

Permalink
Merge pull request #55 from cohstats/updates
Browse files Browse the repository at this point in the history
Add tiers and custom CSS for OBS overlay
  • Loading branch information
petrvecera committed Aug 22, 2023
2 parents 834fe28 + 90b01ee commit 588edd6
Show file tree
Hide file tree
Showing 42 changed files with 317 additions and 65 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "coh3-stats-desktop-app",
"private": true,
"version": "1.2.2",
"version": "1.2.3",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
Binary file modified public/factions/american.webp
Binary file not shown.
Binary file modified public/factions/british.webp
Binary file not shown.
Binary file modified public/factions/dak.webp
Binary file not shown.
Binary file modified public/factions/german.webp
Binary file not shown.
Binary file added public/factions/plain/american.webp
Binary file not shown.
Binary file added public/factions/plain/british.webp
Binary file not shown.
Binary file added public/factions/plain/dak.webp
Binary file not shown.
Binary file added public/factions/plain/german.webp
Binary file not shown.
Binary file added public/icons/ranks/00_placement_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/01_brass_01_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/01_brass_02_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/01_brass_03_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/02_bronze_01_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/02_bronze_02_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/02_bronze_03_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/03_iron_01_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/03_iron_02_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/03_iron_03_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/04_silver_01_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/04_silver_02_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/04_silver_03_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/05_gold_01_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/05_gold_02_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/05_gold_03_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/06_master_01_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/06_master_02_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/06_master_03_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/06_master_04_medium.webp
Binary file not shown.
Binary file added public/icons/ranks/06_master_05_medium.webp
Binary file not shown.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "Coh3 Stats Desktop App",
"version": "1.2.2"
"version": "1.2.3"
},
"tauri": {
"allowlist": {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const About: React.FC = () => {
<img
src="https://storage.ko-fi.com/cdn/cup-border.png"
alt="Ko-fi donations"
width={20}
width={18}
/>
Donate
</Group>
Expand Down
10 changes: 10 additions & 0 deletions src/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,16 @@ export const Settings: React.FC = () => {
>
Setup instructions
</Anchor>
{" "}&{" "}<Anchor
onClick={() =>
openLink(
"https://github.com/cohstats/coh3-stats-desktop-app#custom-css-for-the-overlay"
)
}
>
Custom CSS instructions
</Anchor>

</Text>
<Group pt="md">
<Text>Path to streamerOverlay.html:</Text>
Expand Down
5 changes: 5 additions & 0 deletions src/components/PlayerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down Expand Up @@ -56,6 +57,7 @@ export const PlayerCard: React.FC<PlayerCardProps> = ({
</Col>
<Col span="auto">
<Stack align="stretch">
<Group position={"apart"}>
<Group>
{!ai ? (
<Tooltip label={countryName}>
Expand All @@ -77,10 +79,13 @@ export const PlayerCard: React.FC<PlayerCardProps> = ({
</Title>
{/*<ColorSwatch color={color} />*/}
</Group>
<RankIcon size={35} rank={rank || 0} rating={rating || 0} />
</Group>

<Group position="apart" grow>
<PlayerRank rank={rank} />
<PlayerELO rating={!rank || rank < 1 ? undefined : rating} />

<PlayerStreak streak={streak} />
<PlayerWinRatio wins={wins} losses={losses} />
<PlayerWins wins={wins} />
Expand Down
23 changes: 23 additions & 0 deletions src/components/other/rank-icon.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<Tooltip label={rankTier.name}>
<Image src={rankTier.url} width={size} height={size} alt={rankTier.name} />
</Tooltip>
</>
);
};

export default RankIcon;
72 changes: 67 additions & 5 deletions src/streamer-overlay/SPECIAL-REACT/HTML.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLProps> = ({ html }) => {
return (
Expand All @@ -30,12 +30,74 @@ export const HTML: React.FC<HTMLProps> = ({ html }) => {
href="https://fonts.googleapis.com/css2?family=Tilt+Warp&display=swap"
rel="stylesheet"
/>
<title>Coh3 Stats Desktop App Overlay</title>
<title>COH3 Stats Desktop App Overlay</title>
<style>
{`
html {
font-family: 'Tilt Warp', cursive;
.coh3stats-overlay {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
align-items: stretch;
position: absolute;
left: calc((100vw / 2) - 485px);
right: calc((100vw / 2) - 485px);
top: 65px;
}
.coh3stats-overlay-left {
flex-grow: 1;
flex-basis: 0;
padding-right: 40px;
padding-left: 10px;
}
.coh3stats-overlay-right {
flex-grow: 1;
flex-basis: 0;
padding-left: 40px;
padding-right: 10px;
}
.coh3stats-overlay-player {
color: white;
font-size: 20px;
font-family: Tilt Warp;
}
.coh3stats-overlay-player-factionIcon {
padding-right: 10px;
width: 25px;
height: 25px;
}
.coh3stats-overlay-player-flagIcon {
padding-right: 10px;
width: 25px;
height: 25px;
}
.coh3stats-overlay-player-rank {
padding-right: 10px;
min-width: 4ch;
display: inline-block;
text-align: center;
}
.coh3stats-overlay-player-rating {
padding-right: 10px;
min-width: 4ch;
display: inline-block;
text-align: center;
}
.coh3stats-overlay-player-name {
max-width: 17ch;
display: inline-block;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
`}
</style>
</head>
Expand All @@ -47,7 +109,7 @@ export const HTML: React.FC<HTMLProps> = ({ 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;
Expand Down
25 changes: 3 additions & 22 deletions src/streamer-overlay/SPECIAL-REACT/OverlayApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,10 @@ export const OverlayApp: React.FC<OverlayAppProps> = ({
gameData.state === "Loading" ||
gameData.state === "InGame" ? (
<div
style={{
display: "flex",
flexWrap: "wrap",
justifyContent: "flex-start",
alignItems: "stretch",
position: "absolute",
left: "calc(calc(100vw / 2) - 485px)",
right: "calc(calc(100vw / 2) - 485px)",
top: 65,
}}
className={"coh3stats-overlay"}
>
<div
style={{
flexGrow: 1,
flexBasis: 0,
paddingRight: 40,
paddingLeft: 10,
}}
className={"coh3stats-overlay-left"}
>
{gameData.left.players.map((player, index) => (
<PlayerEntry
Expand All @@ -53,12 +39,7 @@ export const OverlayApp: React.FC<OverlayAppProps> = ({
))}
</div>
<div
style={{
flexGrow: 1,
flexBasis: 0,
paddingLeft: 40,
paddingRight: 10,
}}
className={"coh3stats-overlay-right"}
>
{gameData.right.players.map((player, index) => (
<PlayerEntry
Expand Down
36 changes: 6 additions & 30 deletions src/streamer-overlay/SPECIAL-REACT/PlayerEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,66 +16,42 @@ export const PlayerEntry: React.FC<PlayerEntryProps> = ({
}) => {
return (
<div
style={{
color: "white",
fontSize: 20,
fontFamily: "'Tilt Warp', cursive",
}}
className={"coh3stats-overlay-player"}
>
<img
className={"coh3stats-overlay-player-factionIcon"}
src={
"https://raw.githubusercontent.com/cohstats/coh3-stats-desktop-app/master/public/factions/" +
playerData.faction +
".webp"
}
width={25}
height={25}
style={{ paddingRight: 10 }}
/>
{flags ? (
<img
className={"coh3stats-overlay-player-flagIcon"}
src={
"https://raw.githubusercontent.com/cohstats/coh3-stats-desktop-app/master/public/flags/4x3/" +
playerData.country +
".svg"
}
width={25}
height={25}
style={{ paddingRight: 10 }}
/>
) : null}
<span
style={{
paddingRight: 10,
minWidth: "4ch",
display: "inline-block",
textAlign: "center",
}}
className={"coh3stats-overlay-player-rank"}
>
{playerData.rank === undefined || playerData.rank === -1
? "-"
: "#" + playerData.rank}
</span>{" "}
<span
style={{
paddingRight: 10,
minWidth: "4ch",
display: "inline-block",
textAlign: "center",
}}
className={"coh3stats-overlay-player-rating"}
>
{playerData.rating === undefined || playerData.rating === -1
? "-"
: playerData.rating}
</span>{" "}
<span
style={{
maxWidth: "17ch",
display: "inline-block",
textOverflow: "ellipsis",
overflow: "hidden",
whiteSpace: "nowrap",
}}
className={"coh3stats-overlay-player-name"}
>
{playerData.name}
</span>
Expand Down
Loading

0 comments on commit 588edd6

Please sign in to comment.