# -*- coding: utf-8 -*- # games/solitaire/base/solitaire_tap_prefs.py from __future__ import annotations from models.database import Database TAP_TO_MOVE_SETTING_KEY = "sol_single_tap_to_move" SINGLE_TAP_MAX_HOLD_SEC = 0.28 _single_tap_cache: bool | None = None def invalidate_tap_prefs_cache() -> None: """Leert den Cache beim Wechsel auf eine andere user_data.db.""" global _single_tap_cache _single_tap_cache = None def is_single_tap_to_move_enabled() -> bool: global _single_tap_cache if _single_tap_cache is None: try: raw = Database.load_setting(TAP_TO_MOVE_SETTING_KEY, "0") _single_tap_cache = str(raw).strip().lower() in ("1", "true", "yes", "on") except Exception: _single_tap_cache = False return _single_tap_cache def set_single_tap_to_move_enabled(enabled: bool, persist: bool = True) -> None: global _single_tap_cache state = bool(enabled) _single_tap_cache = state if persist: try: Database.save_setting(TAP_TO_MOVE_SETTING_KEY, "1" if state else "0") except Exception: pass