Files
PzConfigStudio/pz_config/models.py
2025-12-26 18:10:39 +08:00

43 lines
940 B
Python

from __future__ import annotations
from dataclasses import dataclass
from typing import Literal, Mapping
ValueType = Literal["bool", "int", "float", "string"]
@dataclass(frozen=True)
class Setting:
"""
A single editable setting from either server.ini or server_SandboxVars.lua.
- For INI: `path == key`
- For Lua: `path` is dotted (e.g. "ZombieLore.Speed")
"""
source: Literal["ini", "lua"]
path: str
key: str
group: str
value_type: ValueType
value: bool | int | float | str
raw_value: str
line_index: int
description_zh: str
description_en: str | None = None
min_value: int | float | None = None
max_value: int | float | None = None
default_value: str | None = None
choices: Mapping[str, str] | None = None
@dataclass(frozen=True)
class ParsedConfig:
source: Literal["ini", "lua"]
filepath: str
lines: list[str]
settings: list[Setting]