From 533395d336073081bcf8a7cba461f7529a49d8ff Mon Sep 17 00:00:00 2001 From: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com> Date: Thu, 13 Jun 2024 23:29:39 +0200 Subject: [PATCH] WebHost: Fix Named Range displays on Player Options page (#3521) * Player Options: Fix Named Range displays * Also add validation to the NamedRange class itself * Don't break Stardew * Comment * Do replace first so title works correctly * Bring change to Weighted Options as well --- Options.py | 6 ++++++ WebHostLib/templates/playerOptions/macros.html | 4 ++-- WebHostLib/templates/weightedOptions/macros.html | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Options.py b/Options.py index 40a6996d325a..2d3ef99d6491 100644 --- a/Options.py +++ b/Options.py @@ -735,6 +735,12 @@ def __init__(self, value: int) -> None: elif value > self.range_end and value not in self.special_range_names.values(): raise Exception(f"{value} is higher than maximum {self.range_end} for option {self.__class__.__name__} " + f"and is also not one of the supported named special values: {self.special_range_names}") + + # See docstring + for key in self.special_range_names: + if key != key.lower(): + raise Exception(f"{self.__class__.__name__} has an invalid special_range_names key: {key}. " + f"NamedRange keys must use only lowercase letters, and ideally should be snake_case.") self.value = value @classmethod diff --git a/WebHostLib/templates/playerOptions/macros.html b/WebHostLib/templates/playerOptions/macros.html index b34ac79a029e..2187ffe913e5 100644 --- a/WebHostLib/templates/playerOptions/macros.html +++ b/WebHostLib/templates/playerOptions/macros.html @@ -57,9 +57,9 @@