From 205f7e4d31951d10af8928b23b149c1383c9635d Mon Sep 17 00:00:00 2001 From: Gitting gud Date: Thu, 25 May 2023 23:18:11 +0200 Subject: [PATCH 1/4] Added explicit faction and country name tooltip --- src/components/PlayerCard.tsx | 18 ++- src/utils/renameLabels.tsx | 284 ++++++++++++++++++++++++++++++++++ 2 files changed, 296 insertions(+), 6 deletions(-) create mode 100644 src/utils/renameLabels.tsx diff --git a/src/components/PlayerCard.tsx b/src/components/PlayerCard.tsx index df77a58..cf948f9 100644 --- a/src/components/PlayerCard.tsx +++ b/src/components/PlayerCard.tsx @@ -20,6 +20,7 @@ import { PlayerStreak } from "./PlayerStreak" import { PlayerWinRatio } from "./PlayerWinRatio" import { PlayerWins } from "./PlayerWins" import { open } from "@tauri-apps/api/shell" +import { getFactionName, getCountryName } from "../utils/renameLabels" export interface PlayerCardProps extends FullPlayerData {} @@ -37,12 +38,15 @@ export const PlayerCard: React.FC = ({ ai, self, }) => { + const factionName = getFactionName(faction) + const countryName = country ? getCountryName(country) : "" + return ( <> - + {faction} = ({ {!ai ? ( - {country} + + {country} + ) : null} { + const countryMapping: { [code: string]: string } = { + dak: "Deutsches Afrikakorps", + german: "Wehrmacht", + british: "US Forces", + american: "British Forces", + } + + return countryMapping[factionCode] || factionCode +} + +// Helper function to get the country name from the country code +export const getCountryName = (countryCode: string): string => { + const countryMapping: { [code: string]: string } = { + ac: "Ascension Island", + ad: "Andorra", + ae: "United Arab Emirates", + af: "Afghanistan", + ag: "Antigua and Barbuda", + ai: "Anguilla", + al: "Albania", + am: "Armenia", + ao: "Angola", + aq: "Antarctica", + ar: "Argentina", + as: "American Samoa", + at: "Austria", + au: "Australia", + aw: "Aruba", + ax: "Åland Islands", + az: "Azerbaijan", + ba: "Bosnia and Herzegovina", + bb: "Barbados", + bd: "Bangladesh", + be: "Belgium", + bf: "Burkina Faso", + bg: "Bulgaria", + bh: "Bahrain", + bi: "Burundi", + bj: "Benin", + bl: "Saint Barthélemy", + bm: "Bermuda", + bn: "Brunei", + bo: "Bolivia", + bq: "Caribbean Netherlands", + br: "Brazil", + bs: "Bahamas", + bt: "Bhutan", + bv: "Bouvet Island", + bw: "Botswana", + by: "Belarus", + bz: "Belize", + ca: "Canada", + cc: "Cocos Islands", + cd: "Democratic Republic of the Congo", + cf: "Central African Republic", + cg: "Republic of the Congo", + ch: "Switzerland", + ci: "Côte d'Ivoire", + ck: "Cook Islands", + cl: "Chile", + cm: "Cameroon", + cn: "China", + co: "Colombia", + cp: "Clipperton Island", + cr: "Costa Rica", + cu: "Cuba", + cv: "Cape Verde", + cw: "Curaçao", + cx: "Christmas Island", + cy: "Cyprus", + cz: "Czech Republic", + de: "Germany", + dg: "Diego Garcia", + dj: "Djibouti", + dk: "Denmark", + dm: "Dominica", + do: "Dominican Republic", + dz: "Algeria", + ea: "Ceuta and Melilla", + ec: "Ecuador", + ee: "Estonia", + eg: "Egypt", + eh: "Western Sahara", + er: "Eritrea", + "es-ct": "Catalonia", + "es-ga": "Galicia", + es: "Spain", + et: "Ethiopia", + eu: "European Union", + fi: "Finland", + fj: "Fiji", + fk: "Falkland Islands", + fm: "Micronesia", + fo: "Faroe Islands", + fr: "France", + ga: "Gabon", + "gb-eng": "England", + "gb-nir": "Northern Ireland", + "gb-sct": "Scotland", + "gb-wls": "Wales", + gb: "United Kingdom", + gd: "Grenada", + ge: "Georgia", + gf: "French Guiana", + gg: "Guernsey", + gh: "Ghana", + gi: "Gibraltar", + gl: "Greenland", + gm: "Gambia", + gn: "Guinea", + gp: "Guadeloupe", + gq: "Equatorial Guinea", + gr: "Greece", + gs: "South Georgia and the South Sandwich Islands", + gt: "Guatemala", + gu: "Guam", + gw: "Guinea-Bissau", + gy: "Guyana", + hk: "Hong Kong", + hm: "Heard Island and McDonald Islands", + hn: "Honduras", + hr: "Croatia", + ht: "Haiti", + hu: "Hungary", + ic: "Canary Islands", + id: "Indonesia", + ie: "Ireland", + il: "Israel", + im: "Isle of Man", + in: "India", + io: "British Indian Ocean Territory", + iq: "Iraq", + ir: "Iran", + is: "Iceland", + it: "Italy", + je: "Jersey", + jm: "Jamaica", + jo: "Jordan", + jp: "Japan", + ke: "Kenya", + kg: "Kyrgyzstan", + kh: "Cambodia", + ki: "Kiribati", + km: "Comoros", + kn: "Saint Kitts and Nevis", + kp: "North Korea", + kr: "South Korea", + kw: "Kuwait", + ky: "Cayman Islands", + kz: "Kazakhstan", + la: "Laos", + lb: "Lebanon", + lc: "Saint Lucia", + li: "Liechtenstein", + lk: "Sri Lanka", + lr: "Liberia", + ls: "Lesotho", + lt: "Lithuania", + lu: "Luxembourg", + lv: "Latvia", + ly: "Libya", + ma: "Morocco", + mc: "Monaco", + md: "Moldova", + me: "Montenegro", + mf: "Saint Martin", + mg: "Madagascar", + mh: "Marshall Islands", + mk: "North Macedonia", + ml: "Mali", + mm: "Myanmar", + mn: "Mongolia", + mo: "Macau", + mp: "Northern Mariana Islands", + mq: "Martinique", + mr: "Mauritania", + ms: "Montserrat", + mt: "Malta", + mu: "Mauritius", + mv: "Maldives", + mw: "Malawi", + mx: "Mexico", + my: "Malaysia", + mz: "Mozambique", + na: "Namibia", + nc: "New Caledonia", + ne: "Niger", + nf: "Norfolk Island", + ng: "Nigeria", + ni: "Nicaragua", + nl: "Netherlands", + no: "Norway", + np: "Nepal", + nr: "Nauru", + nu: "Niue", + nz: "New Zealand", + om: "Oman", + pa: "Panama", + pe: "Peru", + pf: "French Polynesia", + pg: "Papua New Guinea", + ph: "Philippines", + pk: "Pakistan", + pl: "Poland", + pm: "Saint Pierre and Miquelon", + pn: "Pitcairn Islands", + pr: "Puerto Rico", + ps: "Palestine", + pt: "Portugal", + pw: "Palau", + py: "Paraguay", + qa: "Qatar", + re: "Réunion", + ro: "Romania", + rs: "Serbia", + ru: "Russia", + rw: "Rwanda", + sa: "Saudi Arabia", + sb: "Solomon Islands", + sc: "Seychelles", + sd: "Sudan", + se: "Sweden", + sg: "Singapore", + sh: "Saint Helena", + si: "Slovenia", + sj: "Svalbard and Jan Mayen", + sk: "Slovakia", + sl: "Sierra Leone", + sm: "San Marino", + sn: "Senegal", + so: "Somalia", + sr: "Suriname", + ss: "South Sudan", + st: "São Tomé and Príncipe", + sv: "El Salvador", + sx: "Sint Maarten", + sy: "Syria", + sz: "Eswatini", + ta: "Tristan da Cunha", + tc: "Turks and Caicos Islands", + td: "Chad", + tf: "French Southern Territories", + tg: "Togo", + th: "Thailand", + tj: "Tajikistan", + tk: "Tokelau", + tl: "Timor-Leste", + tm: "Turkmenistan", + tn: "Tunisia", + to: "Tonga", + tr: "Turkey", + tt: "Trinidad and Tobago", + tv: "Tuvalu", + tw: "Taiwan", + tz: "Tanzania", + ua: "Ukraine", + ug: "Uganda", + um: "United States Minor Outlying Islands", + un: "United Nations", + us: "United States", + uy: "Uruguay", + uz: "Uzbekistan", + va: "Vatican City", + vc: "Saint Vincent and the Grenadines", + ve: "Venezuela", + vg: "British Virgin Islands", + vi: "U.S. Virgin Islands", + vn: "Vietnam", + vu: "Vanuatu", + wf: "Wallis and Futuna", + ws: "Samoa", + xk: "Kosovo", + xx: "Unknown or Invalid Region", + ye: "Yemen", + yt: "Mayotte", + za: "South Africa", + zm: "Zambia", + zw: "Zimbabwe", + } + + return countryMapping[countryCode] || countryCode +} From 23563ef45ba7c2a2c4ad6359a2fcb21162518faa Mon Sep 17 00:00:00 2001 From: Gitting gud <michelfailingatwork@gmail.com> Date: Thu, 25 May 2023 23:20:11 +0200 Subject: [PATCH 2/4] Settings tab visual improvements - Added missing tool tip for play sound - Minor text improvements - Increase file box widths to increase file path readability --- src/Settings.tsx | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Settings.tsx b/src/Settings.tsx index 8f67ae0..63659c2 100644 --- a/src/Settings.tsx +++ b/src/Settings.tsx @@ -90,7 +90,11 @@ export const Settings: React.FC = () => { <div> <Group spacing="xs"> <Group spacing={3}> - <Input readOnly value={logFilePath ? logFilePath : ""} /> + <Input + value={logFilePath ? logFilePath : ""} + style={{ width: 500 }} + readOnly + /> <Button variant="default" onClick={openDialog}> Select </Button> @@ -146,14 +150,16 @@ export const Settings: React.FC = () => { events.settings_changed("play_sound_volume", value) }} /> - <ActionIcon - radius="xl" - variant="filled" - color="blue" - onClick={playSoundFunc} - > - <IconPlayerPlay size="1.125rem" /> - </ActionIcon> + <Tooltip label="Play sound"> + <ActionIcon + radius="xl" + variant="filled" + color="blue" + onClick={playSoundFunc} + > + <IconPlayerPlay size="1.125rem" /> + </ActionIcon> + </Tooltip> </Group> </div> </Group> @@ -201,7 +207,7 @@ export const Settings: React.FC = () => { </Group> <div> <Text weight={700}> - Follow the Setup instructions{" "} + Follow the{" "} <Anchor onClick={() => openLink( @@ -209,12 +215,12 @@ export const Settings: React.FC = () => { ) } > - Here + Setup instructions </Anchor> </Text> <Group pt="md"> <Text>Path to streamerOverlay.html:</Text> - <Input value={appDataPath} style={{ width: 300 }} readOnly /> + <Input value={appDataPath} style={{ width: 500 }} readOnly /> <Tooltip label="Copy"> <ActionIcon onClick={() => { From 676e416ade23c1e7e7e082b9042fac8138297eb7 Mon Sep 17 00:00:00 2001 From: Gitting gud <michelfailingatwork@gmail.com> Date: Fri, 26 May 2023 00:01:46 +0200 Subject: [PATCH 3/4] Removal of redundant imports and field definitions --- src-tauri/src/main.rs | 2 -- src-tauri/src/parse_log_file.rs | 13 ++++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 7f1d146..2e54962 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -4,8 +4,6 @@ )] extern crate machine_uid; -use tauri_plugin_single_instance; -use tauri_plugin_fs_watch; use std::path::Path; use tauri::Manager; use window_shadows::set_shadow; diff --git a/src-tauri/src/parse_log_file.rs b/src-tauri/src/parse_log_file.rs index b63a9d3..4b263e6 100644 --- a/src-tauri/src/parse_log_file.rs +++ b/src-tauri/src/parse_log_file.rs @@ -1,9 +1,8 @@ use serde::{Deserialize, Serialize}; -use nom; use std::io::BufReader; use std::io::BufRead; use std::fs::File; -use log::{info}; +use log::info; #[derive(Serialize, Deserialize, Clone)] pub enum GameState { @@ -252,9 +251,9 @@ pub fn parse_log_file_reverse(path: String) -> LogFileData { win_condition, left: left_team, right: right_team, - player_name: player_name, - player_steam_id: player_steam_id, - language_code: language_code + player_name, + player_steam_id, + language_code } } @@ -313,9 +312,9 @@ fn get_team_data(players: Vec<PlayerData>) -> TeamData { } } if mixed { - return TeamData { players: players, side: TeamSide::Mixed } + return TeamData { players, side: TeamSide::Mixed } } - TeamData { players: players, side: last } + TeamData { players, side: last } } // look for blocks like this: From ec13f90c8bb3419871d62d4726f8259e34446001 Mon Sep 17 00:00:00 2001 From: Gitting gud <michelfailingatwork@gmail.com> Date: Fri, 26 May 2023 15:14:13 +0200 Subject: [PATCH 4/4] Fix label typo and change file type --- src/utils/{renameLabels.tsx => renameLabels.ts} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/utils/{renameLabels.tsx => renameLabels.ts} (99%) diff --git a/src/utils/renameLabels.tsx b/src/utils/renameLabels.ts similarity index 99% rename from src/utils/renameLabels.tsx rename to src/utils/renameLabels.ts index 16f598a..8ea9e7e 100644 --- a/src/utils/renameLabels.tsx +++ b/src/utils/renameLabels.ts @@ -3,8 +3,8 @@ export const getFactionName = (factionCode: string): string => { const countryMapping: { [code: string]: string } = { dak: "Deutsches Afrikakorps", german: "Wehrmacht", - british: "US Forces", - american: "British Forces", + american: "US Forces", + british: "British Forces", } return countryMapping[factionCode] || factionCode