| 30 | |
| 31 | @staticmethod |
| 32 | def from_json(data: dict) -> TWConfig: |
| 33 | # Non-runtime options |
| 34 | _framerate = data.get("framerate") |
| 35 | _interpolation = data.get("interpolation", False) |
| 36 | _hq_pen = data.get("hq", False) |
| 37 | |
| 38 | # Runtime options |
| 39 | _runtime_options = data.get("runtimeOptions", {}) |
| 40 | |
| 41 | # Luckily for us, the JSON module actually accepts the 'Infinity' literal. Otherwise, it would be a right pain |
| 42 | _max_clones = _runtime_options.get("maxClones") |
| 43 | _misc_limits = _runtime_options.get("miscLimits", True) |
| 44 | _fencing = _runtime_options.get("fencing", True) |
| 45 | |
| 46 | # Custom stage size |
| 47 | _width = data.get("width") |
| 48 | _height = data.get("height") |
| 49 | |
| 50 | return TWConfig(_framerate, _interpolation, _hq_pen, _max_clones, _misc_limits, _fencing, _width, _height) |
| 51 | |
| 52 | def to_json(self) -> dict: |
| 53 | runtime_options = {} |