feat: add FS25_FarmHUD mod and FarmHUD desktop companion app

Initial commit: the FS25 Lua mod (live.json data export), the
FS25-WebDashboard project (Node/web dashboard + PySide6 desktop
variant), and FarmHUD (standalone PySide6 companion app with
Discord Rich Presence, settings, and installer).
This commit is contained in:
2026-09-27 15:25:07 +02:00
commit e5754cca18
63 changed files with 7196 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
"""Locates and reads the FS25 WebDashboard mod's live.json file.
Identical resolution logic to the FS25-WebDashboard desktop app (same mod,
same env var override) - FarmHUD is a second, differently-designed reader
of the same data source, not a second mod.
"""
from __future__ import annotations
import json
import os
from pathlib import Path
from typing import Any, Optional
def candidate_live_data_paths() -> list[Path]:
home = Path.home()
candidates: list[Path] = []
env_path = os.environ.get("FS25_LIVE_JSON")
if env_path:
candidates.append(Path(env_path))
tail = Path("My Games") / "FarmingSimulator2025" / "modSettings" / "FS25_FarmHUD" / "live.json"
candidates.append(home / "Documents" / tail)
candidates.append(home / "OneDrive" / "Documents" / tail)
candidates.append(home / "OneDrive" / "Dokumente" / tail)
return candidates
class LiveDataSource:
def __init__(self) -> None:
self.path: Optional[Path] = self._resolve()
def _resolve(self) -> Optional[Path]:
candidates = candidate_live_data_paths()
for candidate in candidates:
if candidate.exists():
return candidate
return candidates[0] if candidates else None
def read(self) -> dict[str, Any]:
if self.path is None or not self.path.exists():
resolved = self._resolve()
if resolved is not None:
self.path = resolved
if self.path is None or not self.path.exists():
return {
"connected": False,
"error": (
"live.json not found yet - start Farming Simulator 25 "
"with the WebDashboard mod active and load a savegame."
),
"expectedPath": str(self.path) if self.path else None,
}
try:
text = self.path.read_text(encoding="utf-8")
data = json.loads(text)
except (OSError, json.JSONDecodeError):
return {
"connected": False,
"error": "live.json is being written, retrying…",
"expectedPath": str(self.path),
}
if isinstance(data, dict):
data.setdefault("connected", True)
return data