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
+103
View File
@@ -0,0 +1,103 @@
"""Shared formatting helpers and lookup tables.
Mirrors the formatting logic in ``web/app.js`` 1:1 so the desktop app shows
exactly the same numbers/labels as the browser dashboard did.
"""
from __future__ import annotations
from typing import Any, Optional
WEATHER_ICONS = {
"SUN": "☀️",
"PARTIALLY_CLOUDY": "🌤️",
"CLOUDY": "☁️",
"RAIN": "🌧️",
"SNOW": "❄️",
"HAIL": "🧊",
"TWISTER": "🌪️",
"THUNDER": "⛈️",
}
WEATHER_LABELS_DE = {
"SUN": "Sonnig",
"PARTIALLY_CLOUDY": "Teils bewölkt",
"CLOUDY": "Bewölkt",
"RAIN": "Regen",
"SNOW": "Schnee",
"HAIL": "Hagel",
"TWISTER": "Tornado",
"THUNDER": "Gewitter",
}
# Best-effort translation - the real ProductionPoint.PROD_STATUS enum wasn't
# fully enumerable from the shipped source (only MISSING_INPUTS was confirmed
# via an actual usage), so unrecognized status names just show as-is.
PRODUCTION_STATUS_LABELS = {
"RUNNING": "läuft",
"ACTIVE": "läuft",
"STOPPED": "gestoppt",
"DISABLED": "deaktiviert",
"PAUSED": "pausiert",
"MISSING_INPUTS": "Rohstoffe fehlen",
"MISSING_OUTPUT_CAPACITY": "Lager voll",
"NO_INPUT_CAPACITY": "Lager voll",
}
def production_status_ok(name: Optional[str]) -> Optional[bool]:
"""True = ok/green, False = warn/orange, None = neutral (no status)."""
if name in ("RUNNING", "ACTIVE"):
return True
if not name:
return None
return False
def is_number(value: Any) -> bool:
return isinstance(value, (int, float)) and not isinstance(value, bool)
def format_number(n: Any, digits: int = 0) -> str:
if not is_number(n):
return "–"
return f"{n:.{digits}f}"
def format_euro(n: Any) -> str:
if not is_number(n):
return "–"
# de-DE grouping uses '.' as thousands separator - build it manually
# since Python's locale module would require the OS locale to be set.
text = f"{round(n):,}".replace(",", ".")
return f"{text} €"
def format_liters(n: Any) -> str:
if not is_number(n):
return "0"
text = f"{round(n):,}".replace(",", ".")
return text
# A plain implement (trailer, plow, seed drill, ...) has neither an engine
# (Motorized) nor its own steering/cruise control (Drivable) - its "speed" is
# just whatever's towing it, so showing a km/h number for it is noise rather
# than information.
def is_drivable(vehicle: dict) -> bool:
return isinstance(vehicle.get("motorStarted"), bool) or isinstance(
vehicle.get("cruiseControlActive"), bool
)
def format_fuel(vehicle: dict) -> str:
level = vehicle.get("fuelLevel")
capacity = vehicle.get("fuelCapacity")
if not is_number(level) or not is_number(capacity) or capacity <= 0:
return "–"
return f"{round((level / capacity) * 100)}%"
def farm_suffix(owner_farm_id: Any, show: bool) -> str:
if show and owner_farm_id is not None:
return f" (Betrieb #{owner_farm_id})"
return ""