|
1 | 1 | <script lang="ts">
|
| 2 | + import { type PopupSettings, popup } from '@skeletonlabs/skeleton'; |
2 | 3 | import { getTranslate } from '@tolgee/svelte';
|
3 | 4 |
|
4 | 5 | import T from '$lib/components/T.svelte';
|
| 6 | + import Tooltip from '$lib/components/Tooltip.svelte'; |
5 | 7 | import { GenerateDebugInfo } from '$wailsjs/go/app/app';
|
6 |
| - import { BrowserOpenURL } from '$wailsjs/runtime/runtime'; |
| 8 | + import { BrowserOpenURL, LogError } from '$wailsjs/runtime/runtime'; |
7 | 9 |
|
8 |
| - export let parent: { onClose: () => void }; |
| 10 | + export let onClose: (() => void) | null = null; |
9 | 11 |
|
10 | 12 | export let fullPageMode: boolean = false;
|
11 |
| - let sectionClass: string = fullPageMode ? 'p-4' : 'px-4'; |
| 13 | + $: sectionClass = fullPageMode ? 'p-4' : 'px-4'; |
12 | 14 |
|
13 |
| - let openDiscordTooltipText: string; |
14 | 15 | const { t } = getTranslate();
|
15 |
| - t.subscribe((getTranslationText) => { |
16 |
| - openDiscordTooltipText = getTranslationText( |
17 |
| - 'error.open_modding_discord.must_generate_debug_first', |
18 |
| - 'You must generate debug info first', |
19 |
| - ); |
20 |
| - }); |
| 16 | + $: openDiscordTooltipText = $t( |
| 17 | + 'error.open_modding_discord.must_generate_debug_first', |
| 18 | + 'You must generate debug info first', |
| 19 | + ); |
21 | 20 |
|
22 | 21 | let allowOpeningDiscord: boolean = false;
|
| 22 | + let debugFileGenerationError: boolean = false; |
23 | 23 |
|
24 | 24 | let onClickGenerateDebugInfo = async () => {
|
25 |
| - let didUserSaveFile = await GenerateDebugInfo(); |
26 |
| - if (didUserSaveFile) { |
| 25 | + try { |
| 26 | + let didUserSaveFile = await GenerateDebugInfo(); |
| 27 | + if (didUserSaveFile) { |
| 28 | + // Explicitly set to true -> if people click to save a second time but cancel, don't lock them out |
| 29 | + allowOpeningDiscord = true; |
| 30 | + } |
| 31 | + } catch (error) { |
| 32 | + LogError(`GenerateDebugInfo failed: ${error}`); |
| 33 | + debugFileGenerationError = true; |
| 34 | + // Enable the Discord button so they can report the error |
27 | 35 | allowOpeningDiscord = true;
|
28 |
| - openDiscordTooltipText = ''; |
29 |
| - } else { |
30 |
| - alert( |
31 |
| - 'Failed to generate and save the debug info file. Did you click the Cancel button? If not, manually check your Satisfactory Mod Manager log files for more information: https://docs.ficsit.app/satisfactory-modding/latest/faq.html#Files_Logs', |
32 |
| - ); |
33 | 36 | }
|
34 | 37 | };
|
35 | 38 |
|
36 | 39 | let OpenDiscord = () => {
|
37 | 40 | BrowserOpenURL('https://discord.ficsit.app/');
|
38 | 41 | };
|
| 42 | +
|
| 43 | + let OpenLogDocs = () => { |
| 44 | + BrowserOpenURL('https://docs.ficsit.app/satisfactory-modding/latest/faq.html#Files_Logs'); |
| 45 | + }; |
| 46 | +
|
| 47 | + const popupId = 'error-details-open-discord-popup'; |
| 48 | + const openDiscordPopup = { |
| 49 | + event: 'hover', |
| 50 | + target: popupId, |
| 51 | + middleware: { |
| 52 | + offset: 4, |
| 53 | + }, |
| 54 | + placement: 'bottom-end', |
| 55 | + } satisfies PopupSettings; |
| 56 | + |
39 | 57 | export let error: string;
|
40 | 58 | </script>
|
41 | 59 |
|
42 |
| -<!-- Replace with svelte snippets once in Svelte 5 --> |
43 | 60 | <header class="card-header font-bold text-2xl text-center">
|
44 | 61 | <slot name="title" />
|
45 | 62 | </header>
|
46 | 63 | <section class={`${sectionClass} overflow-y-auto`}>
|
47 |
| - <p>{error}</p> |
| 64 | + <p class="font-mono">{error}</p> |
48 | 65 | </section>
|
49 | 66 | <section class={sectionClass}>
|
50 | 67 | <p class={fullPageMode ? 'text-base text-center' : ''}>
|
51 | 68 | <T
|
52 |
| - defaultValue="Seems wrong? Click the button below to gather logs, then send the generated zip file on the modding discord in #help-using-mods." |
| 69 | + defaultValue="Seems wrong? Click the button below to gather logs, then send the generated zip file on the modding Discord in #help-using-mods." |
53 | 70 | keyName="error.reporting_directions"
|
54 | 71 | />
|
55 | 72 | </p>
|
56 | 73 | </section>
|
57 | 74 | <section class={sectionClass}>
|
58 |
| - <p class="text-base text-center"> |
| 75 | + <p class="text-base"> |
59 | 76 | <button
|
60 | 77 | class="btn text-primary-600 variant-ringed"
|
61 | 78 | on:click={onClickGenerateDebugInfo}
|
|
68 | 85 | <button
|
69 | 86 | class="btn text-primary-600 variant-ringed"
|
70 | 87 | disabled={!allowOpeningDiscord}
|
71 |
| - title={openDiscordTooltipText} |
72 | 88 | on:click={OpenDiscord}
|
| 89 | + use:popup={openDiscordPopup} |
73 | 90 | >
|
74 | 91 | <T
|
75 | 92 | defaultValue="Open the Modding Discord"
|
76 | 93 | keyName="error.open_modding_discord"
|
77 | 94 | />
|
78 | 95 | </button>
|
| 96 | + <Tooltip disabled={allowOpeningDiscord} {popupId}> |
| 97 | + {openDiscordTooltipText} |
| 98 | + </Tooltip> |
79 | 99 | </p>
|
80 | 100 | </section>
|
| 101 | +{#if debugFileGenerationError} |
| 102 | + <section class={sectionClass}> |
| 103 | + <p class="text-base text-red-500"> |
| 104 | + <T |
| 105 | + defaultValue="An error occurred while generating the debug file. Please manually check your Satisfactory Mod Manager log files for more information and report this on the Discord. Use the button below to open the documentation and learn how." |
| 106 | + keyName="error.failed_to_generate_debug" |
| 107 | + /> |
| 108 | + </p> |
| 109 | + </section> |
| 110 | + <section class={sectionClass}> |
| 111 | + <button |
| 112 | + class="btn text-primary-600 variant-ringed" |
| 113 | + on:click={OpenLogDocs} |
| 114 | + > |
| 115 | + <T |
| 116 | + defaultValue="Open the Logging Documentation" |
| 117 | + keyName="error.open_log_docs" |
| 118 | + /> |
| 119 | + </button> |
| 120 | + </section> |
| 121 | +{/if} |
81 | 122 | {#if !fullPageMode}
|
82 | 123 | <footer class="card-footer">
|
83 |
| - <button class="btn" on:click={parent.onClose}> |
| 124 | + <!-- Must lambda the onClose call for type matching to be happy --> |
| 125 | + <button class="btn" on:click={onClose}> |
84 | 126 | <T defaultValue="Close" keyName="common.close" />
|
85 | 127 | </button>
|
86 | 128 | </footer>
|
|
0 commit comments