diff --git a/resources/lang/sources/en.yaml b/resources/lang/sources/en.yaml index a8688160..0bb3a5b6 100644 --- a/resources/lang/sources/en.yaml +++ b/resources/lang/sources/en.yaml @@ -236,6 +236,8 @@ titlebar.alt.close: "Close" titlebar.alt.icon: "Icon" titlebar.alt.maximize: "Maximize" titlebar.alt.minimize: "Minimize" +troubleshooting.button: "Troubleshooting" +troubleshooting.title: "Troubleshooting" ucp.download.cancelled: "User cancelled the download." ucp.download.download: "Downloading new framework version." ucp.download.downloaded: "Downloaded new framework version: {{version}}. Saving to game folder." diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 2773c8c0..1a82ead7 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -52,7 +52,7 @@ ] }, "shell": { - "open": "^[A-Z]:[/\\\\]+.*" + "open": "^((mailto:\\w+)|(tel:\\w+)|(https?://\\w+)|([A-Z]:)).+" }, "protocol": { "asset": true, diff --git a/src/components/top-bar/top-bar.tsx b/src/components/top-bar/top-bar.tsx index b6dccbe4..e48a3c1a 100644 --- a/src/components/top-bar/top-bar.tsx +++ b/src/components/top-bar/top-bar.tsx @@ -6,6 +6,7 @@ import CreditsButton from './credits/credits-button'; import { ReloadButton } from './restart/reload-button'; import LanguageSelect from './language-select/language-select'; import { NewsButton } from './news/news-button'; +import { TroubleShootingButton } from './troubleshooting/troubleshooting-button'; // eslint-disable-next-line import/prefer-default-export export function TopBar() { @@ -19,7 +20,11 @@ export function TopBar() { + + + + ); diff --git a/src/components/top-bar/troubleshooting/troubleshooting-button.tsx b/src/components/top-bar/troubleshooting/troubleshooting-button.tsx new file mode 100644 index 00000000..acaa8fcf --- /dev/null +++ b/src/components/top-bar/troubleshooting/troubleshooting-button.tsx @@ -0,0 +1,18 @@ +import Message from '../../general/message'; +import { setOverlayContent } from '../../overlay/overlay'; +import { Troubleshooting } from '../../troubleshooting/troubleshooting-window'; + +// eslint-disable-next-line import/prefer-default-export +export function TroubleShootingButton() { + return ( + + ); +} diff --git a/src/components/troubleshooting/troubleshooting-window.tsx b/src/components/troubleshooting/troubleshooting-window.tsx new file mode 100644 index 00000000..e12f7fd9 --- /dev/null +++ b/src/components/troubleshooting/troubleshooting-window.tsx @@ -0,0 +1,47 @@ +import { atom, useAtomValue } from 'jotai'; +import { TROUBLESHOOTING_MD_CONTENT_ATOM } from '../../function/troubleshooting/state'; +import Message from '../general/message'; +import { SaferMarkdown } from '../markdown/safer-markdown'; +import { OverlayContentProps } from '../overlay/overlay'; + +export const TROUBLESHOOTING_MD_ATOM = atom((get) => { + const { isSuccess, data } = get(TROUBLESHOOTING_MD_CONTENT_ATOM); + + if (!isSuccess) { + return ( + + Cannot display Troubleshooting document at this time + + ); + } + + return {data}; +}); + +export function Troubleshooting(props: OverlayContentProps) { + const { closeFunc } = props; + const md = useAtomValue(TROUBLESHOOTING_MD_ATOM); + return ( +
+

+ +

+
+
{md}
+
+ +
+ ); +} diff --git a/src/function/troubleshooting/state.ts b/src/function/troubleshooting/state.ts new file mode 100644 index 00000000..614a68e5 --- /dev/null +++ b/src/function/troubleshooting/state.ts @@ -0,0 +1,25 @@ +import { atomWithQuery } from 'jotai-tanstack-query'; +import { ResponseType } from '@tauri-apps/api/http'; +import { fetch } from '../../tauri/tauri-http'; + +// https://raw.githubusercontent.com/UnofficialCrusaderPatch/UnofficialCrusaderPatch/refs/heads/main/TROUBLESHOOTING.md +// eslint-disable-next-line import/prefer-default-export +export const TROUBLESHOOTING_MD_CONTENT_ATOM = atomWithQuery(() => ({ + queryKey: ['troubleshooting'], + queryFn: async () => { + const request = await fetch( + 'https://raw.githubusercontent.com/UnofficialCrusaderPatch/UnofficialCrusaderPatch/refs/heads/main/TROUBLESHOOTING.md', + { + responseType: ResponseType.Text, + method: 'GET', + }, + ); + + if (!request.ok) { + return 'Failed to fetch Troubleshooting document'; + } + + return request.data; + }, + staleTime: Infinity, +}));