From f2461a2fea9f9d8a8fca6ef411fb8531a8c0c364 Mon Sep 17 00:00:00 2001 From: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com> Date: Sat, 30 Aug 2025 22:33:43 +0200 Subject: [PATCH] WebHost: Ensure that OptionSets and OptionLists get exported to yaml, even when nothing is selected (#5240) * Ensure that OptionSets and OptionLists get exported to yaml, even if nothing is selected * forgot ItemSet and LocationSet * Make it even less likely for there to be overlap --- WebHostLib/options.py | 9 +++++++-- WebHostLib/templates/playerOptions/macros.html | 4 ++++ WebHostLib/templates/weightedOptions/macros.html | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/WebHostLib/options.py b/WebHostLib/options.py index 38489cee..3c63fa8c 100644 --- a/WebHostLib/options.py +++ b/WebHostLib/options.py @@ -155,7 +155,9 @@ def generate_weighted_yaml(game: str): options = {} for key, val in request.form.items(): - if "||" not in key: + if val == "_ensure-empty-list": + options[key] = {} + elif "||" not in key: if len(str(val)) == 0: continue @@ -212,8 +214,11 @@ def generate_yaml(game: str): if request.method == "POST": options = {} intent_generate = False + for key, val in request.form.items(multi=True): - if key in options: + if val == "_ensure-empty-list": + options[key] = [] + elif options.get(key): if not isinstance(options[key], list): options[key] = [options[key]] options[key].append(val) diff --git a/WebHostLib/templates/playerOptions/macros.html b/WebHostLib/templates/playerOptions/macros.html index bbb3c75d..a4cc3aa5 100644 --- a/WebHostLib/templates/playerOptions/macros.html +++ b/WebHostLib/templates/playerOptions/macros.html @@ -134,6 +134,7 @@ {% macro OptionList(option_name, option) %} {{ OptionTitle(option_name, option) }} +
{% for key in (option.valid_keys if option.valid_keys is ordered else option.valid_keys|sort) %}
@@ -146,6 +147,7 @@ {% macro LocationSet(option_name, option) %} {{ OptionTitle(option_name, option) }} +
{% for group_name in world.location_name_groups.keys()|sort %} {% if group_name != "Everywhere" %} @@ -169,6 +171,7 @@ {% macro ItemSet(option_name, option) %} {{ OptionTitle(option_name, option) }} +
{% for group_name in world.item_name_groups.keys()|sort %} {% if group_name != "Everything" %} @@ -192,6 +195,7 @@ {% macro OptionSet(option_name, option) %} {{ OptionTitle(option_name, option) }} +
{% for key in (option.valid_keys if option.valid_keys is ordered else option.valid_keys|sort) %}
diff --git a/WebHostLib/templates/weightedOptions/macros.html b/WebHostLib/templates/weightedOptions/macros.html index 89ba0a0e..1d485a24 100644 --- a/WebHostLib/templates/weightedOptions/macros.html +++ b/WebHostLib/templates/weightedOptions/macros.html @@ -139,6 +139,7 @@ {% endmacro %} {% macro OptionList(option_name, option) %} +
{% for key in (option.valid_keys if option.valid_keys is ordered else option.valid_keys|sort) %}
@@ -158,6 +159,7 @@ {% endmacro %} {% macro LocationSet(option_name, option, world) %} +
{% for group_name in world.location_name_groups.keys()|sort %} {% if group_name != "Everywhere" %} @@ -180,6 +182,7 @@ {% endmacro %} {% macro ItemSet(option_name, option, world) %} +
{% for group_name in world.item_name_groups.keys()|sort %} {% if group_name != "Everything" %} @@ -202,6 +205,7 @@ {% endmacro %} {% macro OptionSet(option_name, option) %} +
{% for key in (option.valid_keys if option.valid_keys is ordered else option.valid_keys|sort) %}