From 15e06e1779ed97ec2609933bea46da91e97a5679 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 31 May 2024 22:41:03 -0400 Subject: [PATCH] Fix TextChoice options sometimes creating a broken YAML (#3390) * Fix TextChoice options with custom values improperly being included in YAML output * Update WebHostLib/options.py Co-authored-by: Fabian Dill --------- Co-authored-by: Fabian Dill --- WebHostLib/options.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/WebHostLib/options.py b/WebHostLib/options.py index 1026d763..b112c8e3 100644 --- a/WebHostLib/options.py +++ b/WebHostLib/options.py @@ -169,9 +169,9 @@ def generate_yaml(game: str): else: options[key] = val - # Detect and build ItemDict options from their name pattern for key, val in options.copy().items(): key_parts = key.rsplit("||", 2) + # Detect and build ItemDict options from their name pattern if key_parts[-1] == "qty": if key_parts[0] not in options: options[key_parts[0]] = {} @@ -179,6 +179,13 @@ def generate_yaml(game: str): options[key_parts[0]][key_parts[1]] = int(val) del options[key] + # Detect keys which end with -custom, indicating a TextChoice with a possible custom value + elif key_parts[-1].endswith("-custom"): + if val: + options[key_parts[-1][:-7]] = val + + del options[key] + # Detect random-* keys and set their options accordingly for key, val in options.copy().items(): if key.startswith("random-"):