diff options
| author | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2026-09-06 00:16:19 -0400 |
|---|---|---|
| committer | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2026-09-06 00:22:35 -0400 |
| commit | a9fd67d05d6819a839a60b581c1dc6eb2792a9be (patch) | |
| tree | 1d3537c24875ef4582039610f68c0831c66307e4 | |
| parent | f9352694a78a2bcfd00d237398a2b30de14c70be (diff) | |
| download | decky-lsfg-vk-a9fd67d05d6819a839a60b581c1dc6eb2792a9be.tar.gz decky-lsfg-vk-a9fd67d05d6819a839a60b581c1dc6eb2792a9be.zip | |
refactor: make Steam branch integration read-only
| -rw-r--r-- | py_modules/lsfg_vk/plugin.py | 3 | ||||
| -rw-r--r-- | py_modules/lsfg_vk/steam_service.py | 106 | ||||
| -rw-r--r-- | py_modules/lsfg_vk/types.py | 5 | ||||
| -rw-r--r-- | scripts/generate_python_boilerplate.py | 2 | ||||
| -rw-r--r-- | scripts/generate_ts_schema.py | 8 | ||||
| -rw-r--r-- | src/api/lsfgApi.ts | 5 | ||||
| -rw-r--r-- | src/components/Content.tsx | 19 | ||||
| -rw-r--r-- | src/components/StatusDisplay.tsx | 23 | ||||
| -rw-r--r-- | src/hooks/useLsfgHooks.ts | 32 |
9 files changed, 7 insertions, 196 deletions
diff --git a/py_modules/lsfg_vk/plugin.py b/py_modules/lsfg_vk/plugin.py index 1676566..f764086 100644 --- a/py_modules/lsfg_vk/plugin.py +++ b/py_modules/lsfg_vk/plugin.py @@ -325,9 +325,6 @@ class Plugin: async def get_lossless_scaling_branch_status(self) -> Dict[str, Any]: return self.steam_service.get_branch_status() - async def select_lossless_scaling_branch(self) -> Dict[str, Any]: - return self.steam_service.select_branch() - async def set_flatpak_app_override(self, app_id: str) -> Dict[str, Any]: """Set lsfg-vk overrides for a Flatpak app diff --git a/py_modules/lsfg_vk/steam_service.py b/py_modules/lsfg_vk/steam_service.py index 3278f3c..867a135 100644 --- a/py_modules/lsfg_vk/steam_service.py +++ b/py_modules/lsfg_vk/steam_service.py @@ -1,6 +1,4 @@ -import os import re -import tempfile from pathlib import Path from typing import Dict, Optional, Tuple @@ -102,42 +100,6 @@ class SteamService(BaseService): return None @classmethod - def _set_section_value(cls, content: str, section_name: str, key: str, value: str) -> str: - bounds = cls._section_bounds(content, section_name) - if bounds is None: - if section_name != "UserConfig": - raise ValueError(f"Steam manifest is missing the {section_name} section") - app_state = cls._section_bounds(content, "AppState") - if app_state is None: - raise ValueError("Steam manifest is missing the AppState section") - _, app_state_end, app_state_indent = app_state - prefix = content[:app_state_end] - if not prefix.endswith(("\n", "\r")): - prefix += "\n" - entry_indent = app_state_indent + "\t" - section = ( - f'{entry_indent}"UserConfig"\n' - f'{entry_indent}{{\n' - f'{entry_indent}\t"{key}"\t"{value}"\n' - f'{entry_indent}}}\n' - ) - return prefix + section + content[app_state_end:] - - body_start, body_end, section_indent = bounds - pattern = re.compile( - rf'(?m)^[ \t]*"{re.escape(key)}"[ \t]+"(?P<value>(?:\\.|[^"\\])*)"' - ) - match = pattern.search(content, body_start, body_end) - if match is not None: - return content[: match.start("value")] + value + content[match.end("value") :] - - prefix = content[:body_end] - if not prefix.endswith(("\n", "\r")): - prefix += "\n" - entry_indent = section_indent + "\t" - return prefix + f'{entry_indent}"{key}"\t"{value}"\n' + content[body_end:] - - @classmethod def _branch_or_default(cls, branch: Optional[str]) -> str: return branch or cls.DEFAULT_BRANCH @@ -203,71 +165,3 @@ class SteamService(BaseService): needs_switch=False, restart_required=False, ) - - def select_branch(self) -> Dict[str, object]: - try: - manifest_path = self._manifest_path() - if manifest_path is None: - raise FileNotFoundError("Lossless Scaling is not installed through Steam") - - content = manifest_path.read_text(encoding="utf-8") - fields = self._status_fields(manifest_path, content) - if not fields["needs_switch"]: - return self._success_response( - dict, - "Lossless Scaling is already using the lsfg-vk Steam branch", - changed=False, - **fields, - ) - - updated = self._set_section_value( - content, - "UserConfig", - "BetaKey", - STEAM_LOSSLESS_SCALING_BRANCH, - ) - if updated != content: - file_mode = manifest_path.stat().st_mode & 0o777 - temporary_path = None - try: - with tempfile.NamedTemporaryFile( - mode="w", - encoding="utf-8", - dir=manifest_path.parent, - prefix=f".{manifest_path.name}.", - delete=False, - ) as temporary_file: - temporary_path = Path(temporary_file.name) - temporary_file.write(updated) - temporary_file.flush() - os.fsync(temporary_file.fileno()) - temporary_path.chmod(file_mode) - os.replace(temporary_path, manifest_path) - except Exception: - if temporary_path is not None: - temporary_path.unlink(missing_ok=True) - raise - - new_fields = dict(fields) - new_fields["selected_branch"] = STEAM_LOSSLESS_SCALING_BRANCH - new_fields["needs_switch"] = new_fields["current_branch"] != STEAM_LOSSLESS_SCALING_BRANCH - new_fields["restart_required"] = new_fields["needs_switch"] - return self._success_response( - dict, - "lsfg-vk selected for Lossless Scaling; restart Steam to download it", - changed=updated != content, - **new_fields, - ) - except Exception as error: - return self._error_response( - dict, - str(error), - changed=False, - installed=False, - manifest_path=None, - selected_branch=None, - current_branch=None, - target_branch=STEAM_LOSSLESS_SCALING_BRANCH, - needs_switch=False, - restart_required=False, - ) diff --git a/py_modules/lsfg_vk/types.py b/py_modules/lsfg_vk/types.py index 96ce23b..2c56a15 100644 --- a/py_modules/lsfg_vk/types.py +++ b/py_modules/lsfg_vk/types.py @@ -54,11 +54,6 @@ class SteamBranchStatusResponse(TypedDict): needs_switch: bool restart_required: bool - -class SteamBranchOperationResponse(SteamBranchStatusResponse): - changed: bool - - class ConfigurationResponse(BaseResponse): """Response for configuration operations""" config: Optional[ConfigurationData] diff --git a/scripts/generate_python_boilerplate.py b/scripts/generate_python_boilerplate.py index a03aa2b..d134337 100644 --- a/scripts/generate_python_boilerplate.py +++ b/scripts/generate_python_boilerplate.py @@ -244,7 +244,7 @@ def main(): print(f"Generated {schema_file.relative_to(project_root)}") except Exception as e: - print(f"ā Error generating Python files: {e}") + print(f"Error generating Python files: {e}") sys.exit(1) diff --git a/scripts/generate_ts_schema.py b/scripts/generate_ts_schema.py index c4c0e8a..27969f1 100644 --- a/scripts/generate_ts_schema.py +++ b/scripts/generate_ts_schema.py @@ -132,11 +132,11 @@ def main(): target_file = project_root / "src" / "config" / "generatedConfigSchema.ts" target_file.write_text(ts_content) - print(f"ā
Generated {target_file} from shared_config.py") + print(f"Generated {target_file} from shared_config.py") print(f" Fields: {len(CONFIG_SCHEMA_DEF)}") # Also generate Python boilerplate - print("\nš Generating Python boilerplate...") + print("\nGenerating Python boilerplate...") from pathlib import Path import subprocess @@ -147,10 +147,10 @@ def main(): if result.returncode == 0: print(result.stdout) else: - print(f"ā ļø Python boilerplate generation had issues:\n{result.stderr}") + print(f"Warning: Python boilerplate generation had issues:\n{result.stderr}") except Exception as e: - print(f"ā Error generating schema: {e}") + print(f"Error generating schema: {e}") sys.exit(1) diff --git a/src/api/lsfgApi.ts b/src/api/lsfgApi.ts index 64d43cb..c0d6528 100644 --- a/src/api/lsfgApi.ts +++ b/src/api/lsfgApi.ts @@ -29,10 +29,6 @@ export interface SteamBranchStatus { restart_required: boolean; } -export interface SteamBranchOperationResult extends SteamBranchStatus { - changed: boolean; -} - // Use centralized configuration data type export type LsfgConfig = ConfigurationData; @@ -130,7 +126,6 @@ export const installLsfgVk = callable<[], InstallationResult>("install_lsfg_vk") export const uninstallLsfgVk = callable<[], InstallationResult>("uninstall_lsfg_vk"); export const checkLsfgVkInstalled = callable<[], InstallationStatus>("check_lsfg_vk_installed"); export const getLosslessScalingBranchStatus = callable<[], SteamBranchStatus>("get_lossless_scaling_branch_status"); -export const selectLosslessScalingBranch = callable<[], SteamBranchOperationResult>("select_lossless_scaling_branch"); export const getLsfgConfig = callable<[], ConfigResult>("get_lsfg_config"); export const getConfigSchema = callable<[], ConfigSchemaResult>("get_config_schema"); export const getLaunchOption = callable<[], LaunchOptionResult>("get_launch_option"); diff --git a/src/components/Content.tsx b/src/components/Content.tsx index 4e4e33a..01f94c9 100644 --- a/src/components/Content.tsx +++ b/src/components/Content.tsx @@ -15,7 +15,6 @@ import { NerdStuffModal } from "./NerdStuffModal"; import { FlatpaksModal } from "./FlatpaksModal"; import { ConfigurationData } from "../config/configSchema"; import t from '../i18n/i18n'; -import { showErrorToast, showSuccessToast } from "../utils/toastUtils"; export function Content() { const { @@ -26,8 +25,6 @@ export function Content() { losslessScalingInstalled, losslessScalingStatus, steamBranchStatus, - isSwitchingSteamBranch, - selectLosslessScalingBranch, checkInstallation } = useInstallationStatus(); @@ -71,18 +68,6 @@ export function Content() { handleUninstall(setIsInstalled, setInstallationStatus, checkInstallation); }; - const onSelectLosslessScalingBranch = async () => { - const result = await selectLosslessScalingBranch(); - if (result.success) { - showSuccessToast("Steam branch selected", result.message); - } else { - showErrorToast( - "Steam branch selection failed", - result.error || "Unable to select the lsfg-vk Steam branch" - ); - } - }; - const handleShowNerdStuff = () => { showModal(<NerdStuffModal />); }; @@ -109,8 +94,6 @@ export function Content() { losslessScalingInstalled={losslessScalingInstalled} losslessScalingStatus={losslessScalingStatus} steamBranchStatus={steamBranchStatus} - isSwitchingSteamBranch={isSwitchingSteamBranch} - onSelectLosslessScalingBranch={onSelectLosslessScalingBranch} /> </> )} @@ -192,8 +175,6 @@ export function Content() { losslessScalingInstalled={losslessScalingInstalled} losslessScalingStatus={losslessScalingStatus} steamBranchStatus={steamBranchStatus} - isSwitchingSteamBranch={isSwitchingSteamBranch} - onSelectLosslessScalingBranch={onSelectLosslessScalingBranch} /> <InstallationButton diff --git a/src/components/StatusDisplay.tsx b/src/components/StatusDisplay.tsx index 5eb1823..767e5fc 100644 --- a/src/components/StatusDisplay.tsx +++ b/src/components/StatusDisplay.tsx @@ -1,4 +1,4 @@ -import { ButtonItem, PanelSectionRow } from "@decky/ui"; +import { PanelSectionRow } from "@decky/ui"; import type { SteamBranchStatus } from "../api/lsfgApi"; interface StatusDisplayProps { @@ -7,8 +7,6 @@ interface StatusDisplayProps { losslessScalingInstalled: boolean; losslessScalingStatus: string; steamBranchStatus: SteamBranchStatus | null; - isSwitchingSteamBranch: boolean; - onSelectLosslessScalingBranch: () => void; } export function StatusDisplay({ @@ -16,9 +14,7 @@ export function StatusDisplay({ installationStatus, losslessScalingInstalled, losslessScalingStatus, - steamBranchStatus, - isSwitchingSteamBranch, - onSelectLosslessScalingBranch + steamBranchStatus }: StatusDisplayProps) { const losslessScalingAppInstalled = losslessScalingInstalled || steamBranchStatus?.installed === true; @@ -36,9 +32,6 @@ export function StatusDisplay({ gap: "6px" }} > - <span style={{ fontSize: "16px" }}> - {losslessScalingAppInstalled ? "ā
" : "ā"} - </span> {losslessScalingAppInstalled ? "Lossless Scaling Installed" : "Lossless Scaling Not Installed"} </div> {!losslessScalingAppInstalled && losslessScalingStatus && ( @@ -55,9 +48,6 @@ export function StatusDisplay({ gap: "6px" }} > - <span style={{ fontSize: "16px" }}> - {isInstalled ? "ā
" : "ā"} - </span> {installationStatus} </div> </div> @@ -80,15 +70,6 @@ export function StatusDisplay({ </div> )} </div> - {steamBranchStatus.needs_switch && ( - <ButtonItem - layout="below" - onClick={onSelectLosslessScalingBranch} - disabled={isSwitchingSteamBranch} - > - {isSwitchingSteamBranch ? "Selecting lsfg-vk..." : "Use lsfg-vk Steam branch"} - </ButtonItem> - )} </div> </PanelSectionRow> )} diff --git a/src/hooks/useLsfgHooks.ts b/src/hooks/useLsfgHooks.ts index dfbf2cd..ea8b3d0 100644 --- a/src/hooks/useLsfgHooks.ts +++ b/src/hooks/useLsfgHooks.ts @@ -3,10 +3,8 @@ import { checkLsfgVkInstalled, getLsfgConfig, getLosslessScalingBranchStatus, - selectLosslessScalingBranch, updateLsfgConfigFromObject, type ConfigUpdateResult, - type SteamBranchOperationResult, type SteamBranchStatus } from "../api/lsfgApi"; import { ConfigurationData, getDefaults } from "../config/configSchema"; @@ -18,7 +16,6 @@ export function useInstallationStatus() { const [losslessScalingInstalled, setLosslessScalingInstalled] = useState<boolean>(false); const [losslessScalingStatus, setLosslessScalingStatus] = useState<string>(""); const [steamBranchStatus, setSteamBranchStatus] = useState<SteamBranchStatus | null>(null); - const [isSwitchingSteamBranch, setIsSwitchingSteamBranch] = useState<boolean>(false); const checkInstallation = async () => { try { @@ -48,33 +45,6 @@ export function useInstallationStatus() { } }; - const selectLosslessScalingBranchForUser = async (): Promise<SteamBranchOperationResult> => { - setIsSwitchingSteamBranch(true); - try { - const result = await selectLosslessScalingBranch(); - setSteamBranchStatus(result); - return result; - } catch (error) { - const result: SteamBranchOperationResult = { - success: false, - message: "", - error: String(error), - installed: false, - manifest_path: undefined, - selected_branch: undefined, - current_branch: undefined, - target_branch: "lsfg-vk", - needs_switch: false, - restart_required: false, - changed: false - }; - setSteamBranchStatus(result); - return result; - } finally { - setIsSwitchingSteamBranch(false); - } - }; - useEffect(() => { checkInstallation(); }, []); @@ -87,8 +57,6 @@ export function useInstallationStatus() { losslessScalingInstalled, losslessScalingStatus, steamBranchStatus, - isSwitchingSteamBranch, - selectLosslessScalingBranch: selectLosslessScalingBranchForUser, checkInstallation }; } |
