diff --git a/Options.py b/Options.py index 7f833d5aff57..39fd56765615 100644 --- a/Options.py +++ b/Options.py @@ -746,6 +746,7 @@ def from_text(cls, text: str) -> Range: class FreezeValidKeys(AssembleOptions): def __new__(mcs, name, bases, attrs): + assert not "_valid_keys" in attrs, "'_valid_keys' gets set by FreezeValidKeys, define 'valid_keys' instead." if "valid_keys" in attrs: attrs["_valid_keys"] = frozenset(attrs["valid_keys"]) return super(FreezeValidKeys, mcs).__new__(mcs, name, bases, attrs) diff --git a/WebHostLib/options.py b/WebHostLib/options.py index f52f0f3d9f91..94f173df70cb 100644 --- a/WebHostLib/options.py +++ b/WebHostLib/options.py @@ -79,10 +79,6 @@ def test_ordered(obj): @cache.cached() def option_presets(game: str) -> Response: world = AutoWorldRegister.world_types[game] - presets = {} - - if world.web.options_presets: - presets = presets | world.web.options_presets class SetEncoder(json.JSONEncoder): def default(self, obj): @@ -91,7 +87,7 @@ def default(self, obj): return list(obj) return json.JSONEncoder.default(self, obj) - json_data = json.dumps(presets, cls=SetEncoder) + json_data = json.dumps(world.web.options_presets, cls=SetEncoder) response = Response(json_data) response.headers["Content-Type"] = "application/json" return response diff --git a/WebHostLib/templates/playerOptions/macros.html b/WebHostLib/templates/playerOptions/macros.html index 64964682fe5f..c4d97255d85e 100644 --- a/WebHostLib/templates/playerOptions/macros.html +++ b/WebHostLib/templates/playerOptions/macros.html @@ -114,7 +114,7 @@ {% macro ItemDict(option_name, option, world) %} {{ OptionTitle(option_name, option) }}
- {% for item_name in world.item_names|sort %} + {% for item_name in (option.valid_keys|sort if (option.valid_keys|length > 0) else world.item_names|sort) %}
@@ -149,7 +149,7 @@ {% if world.location_name_groups.keys()|length > 1 %}
 
{% endif %} - {% for location_name in world.location_names|sort %} + {% for location_name in (option.valid_keys|sort if (option.valid_keys|length > 0) else world.location_names|sort) %}
@@ -172,7 +172,7 @@ {% if world.item_name_groups.keys()|length > 1 %}
 
{% endif %} - {% for item_name in world.item_names|sort %} + {% for item_name in (option.valid_keys|sort if (option.valid_keys|length > 0) else world.item_names|sort) %}
diff --git a/WebHostLib/templates/weightedOptions/macros.html b/WebHostLib/templates/weightedOptions/macros.html index e7caab93c0e2..91474d76960e 100644 --- a/WebHostLib/templates/weightedOptions/macros.html +++ b/WebHostLib/templates/weightedOptions/macros.html @@ -105,7 +105,7 @@ {% macro ItemDict(option_name, option, world) %}
- {% for item_name in world.item_names|sort %} + {% for item_name in (option.valid_keys|sort if (option.valid_keys|length > 0) else world.item_names|sort) %}
1 %}
 
{% endif %} - {% for location_name in world.location_names|sort %} + {% for location_name in (option.valid_keys|sort if (option.valid_keys|length > 0) else world.location_names|sort) %}
@@ -172,7 +172,7 @@ {% if world.item_name_groups.keys()|length > 1 %}
 
{% endif %} - {% for item_name in world.item_names|sort %} + {% for item_name in (option.valid_keys|sort if (option.valid_keys|length > 0) else world.item_names|sort) %}
diff --git a/worlds/subnautica/options.py b/worlds/subnautica/options.py index 6554425dc7e4..4bdd9aafa53f 100644 --- a/worlds/subnautica/options.py +++ b/worlds/subnautica/options.py @@ -120,7 +120,7 @@ class FillerItemsDistribution(ItemDict): """Random chance weights of various filler resources that can be obtained. Available items: """ __doc__ += ", ".join(f"\"{item_name}\"" for item_name in item_names_by_type[ItemType.resource]) - _valid_keys = frozenset(item_names_by_type[ItemType.resource]) + valid_keys = sorted(item_names_by_type[ItemType.resource]) default = {item_name: 1 for item_name in item_names_by_type[ItemType.resource]} display_name = "Filler Items Distribution"