UI: Add option to enable/disable syncing Steam achievements (#2117)

This commit is contained in:
catloversg
2025-05-10 16:13:41 +07:00
committed by GitHub
parent 290557332c
commit 494ef0dff3
13 changed files with 197 additions and 64 deletions
+22 -1
View File
@@ -26,6 +26,7 @@ import { Page } from "../../ui/Router";
import { convertTimeMsToTimeElapsedString } from "../../utils/StringHelperFunctions";
import { OptionsTabName } from "./GameOptionsRoot";
import { Player } from "@player";
import { OptionSwitch } from "../../ui/React/OptionSwitch";
interface IProps {
tab: OptionsTabName;
@@ -59,6 +60,7 @@ export const GameOptionsSidebar = (props: IProps): React.ReactElement => {
const [diagnosticOpen, setDiagnosticOpen] = useState(false);
const [importSaveOpen, setImportSaveOpen] = useState(false);
const [importData, setImportData] = useState<ImportData | null>(null);
const [syncSteamAchievements, setSyncSteamAchievements] = useState(true);
const [confirmResetOpen, setConfirmResetOpen] = useState(false);
const [creditsOpen, setCreditsOpen] = useState(false);
@@ -76,6 +78,7 @@ export const GameOptionsSidebar = (props: IProps): React.ReactElement => {
const data = await saveObject.getImportDataFromSaveData(saveData);
setImportData(data);
setImportSaveOpen(true);
setSyncSteamAchievements(data.playerData?.syncSteamAchievements ?? true);
} catch (e: unknown) {
console.error(e);
SnackbarEvents.emit(String(e), ToastVariant.ERROR, 5000);
@@ -89,7 +92,13 @@ export const GameOptionsSidebar = (props: IProps): React.ReactElement => {
if (!importData) return;
try {
await saveObject.importGame(importData.saveData);
let overrideSettings = undefined;
if (syncSteamAchievements !== importData.playerData?.syncSteamAchievements) {
overrideSettings = {
SyncSteamAchievements: syncSteamAchievements,
};
}
await saveObject.importGame(importData.saveData, overrideSettings);
} catch (e: unknown) {
console.error(e);
SnackbarEvents.emit(String(e), ToastVariant.ERROR, 5000);
@@ -205,6 +214,18 @@ export const GameOptionsSidebar = (props: IProps): React.ReactElement => {
)}
<br />
<br />
<OptionSwitch
checked={syncSteamAchievements}
onChange={(newValue) => setSyncSteamAchievements(newValue)}
text="Sync Steam achievements"
tooltip={
<>
This setting is only used in the Steam app. If this setting is enabled, the game will automatically
sync your unlocked Steam achievements to Steam Cloud.
</>
}
/>
<br />
</>
}
/>
+11
View File
@@ -54,6 +54,17 @@ export const MiscPage = (): React.ReactElement => {
</>
}
/>
<OptionSwitch
checked={Settings.SyncSteamAchievements}
onChange={(newValue) => (Settings.SyncSteamAchievements = newValue)}
text="Sync Steam achievements"
tooltip={
<>
This setting is only used in the Steam app. If this setting is enabled, the game will automatically sync
your unlocked Steam achievements to Steam Cloud.
</>
}
/>
</GameOptionsPage>
);
};