From cba18a1582ca3a0e3def529baf434aa7bd2976b2 Mon Sep 17 00:00:00 2001 From: duckboycool Date: Tue, 7 Jul 2026 15:01:39 -0600 Subject: [PATCH 1/4] Update random to displayed value --- OptionsCreator.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/OptionsCreator.py b/OptionsCreator.py index 30833993e1d2..484bd10b65ec 100644 --- a/OptionsCreator.py +++ b/OptionsCreator.py @@ -518,22 +518,25 @@ def create_option(self, option: typing.Type[Option], name: str, world: typing.Ty option_base.add_widget(label_box) if issubclass(option, NamedRange): - option_base.add_widget(self.create_named_range(option, name)) + widget = self.create_named_range(option, name) elif issubclass(option, Range): - option_base.add_widget(self.create_range(option, name)) + widget = self.create_range(option, name) elif issubclass(option, Toggle): - option_base.add_widget(self.create_toggle(option, name)) + widget = self.create_toggle(option, name) elif issubclass(option, TextChoice): - option_base.add_widget(self.create_text_choice(option, name)) + widget = self.create_text_choice(option, name) elif issubclass(option, Choice): - option_base.add_widget(self.create_choice(option, name)) + widget = self.create_choice(option, name) elif issubclass(option, FreeText): - option_base.add_widget(self.create_free_text(option, name)) - elif any(issubclass(option, cls) for cls in (OptionSet, OptionList, OptionCounter)): - option_base.add_widget(self.create_option_set_list_counter(option, name, world)) + widget = self.create_free_text(option, name) + elif issubclass(option, (OptionSet, OptionList, OptionCounter)): + widget = self.create_option_set_list_counter(option, name, world) else: option_base.add_widget(MDLabel(text="This option isn't supported by the option creator.\n" "Please edit your yaml manually to set this option.")) + return option_base + + option_base.add_widget(widget) if option_can_be_randomized(option): def randomize_option(instance: Widget, value: str): @@ -559,6 +562,16 @@ def randomize_option(instance: Widget, value: str): random_toggle.bind(state=randomize_option) label_box.add_widget(random_toggle) if default_random: + # change stored value to match displayed one before randomizing it + if isinstance(widget, VisualNamedRange): + self.options[name] = widget.range.tag.text + elif isinstance(widget, VisualRange): + self.options[name] = widget.tag.text + elif isinstance(widget, VisualTextChoice): + self.options[name] = widget.choice.text.text + elif isinstance(widget, VisualChoice): + self.options[name] = widget.text.text + randomize_option(random_toggle, "down") return option_base From 69c9086b5ac529b0f8d52cbb891b3c0593dc6d6c Mon Sep 17 00:00:00 2001 From: duckboycool Date: Tue, 7 Jul 2026 15:02:30 -0600 Subject: [PATCH 2/4] Update TextChoice button label without enter --- OptionsCreator.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/OptionsCreator.py b/OptionsCreator.py index 484bd10b65ec..e32a956ce3b2 100644 --- a/OptionsCreator.py +++ b/OptionsCreator.py @@ -381,13 +381,14 @@ def open_dropdown(button): self.options[name] = default return box - def create_free_text(self, option: typing.Type[FreeText] | typing.Type[TextChoice], name: str): + def create_free_text(self, option: typing.Type[FreeText] | typing.Type[TextChoice], name: str, bind=True): text = VisualFreeText(option=option, name=name) def set_value(instance, value): self.options[name] = value - text.bind(text=set_value) + if bind: + text.bind(text=set_value) self.options[name] = option.default return text @@ -426,13 +427,13 @@ def set_button_text(button: MDButton, text: str): child.text = text box = VisualTextChoice(option=option, name=name, choice=self.create_choice(option, name), - text=self.create_free_text(option, name)) + text=self.create_free_text(option, name, bind=False)) - def set_value(instance): + def set_value(instance, value): set_button_text(box.choice, "Custom") - self.options[name] = instance.text + self.options[name] = value - box.text.bind(on_text_validate=set_value) + box.text.bind(text=set_value) return box def create_toggle(self, option: typing.Type[Toggle], name: str) -> Widget: From fbc728bff81ea4cde4c574b08e046d6589ae151d Mon Sep 17 00:00:00 2001 From: duckboycool Date: Tue, 7 Jul 2026 15:02:46 -0600 Subject: [PATCH 3/4] Fix opening menu for disabled Choice buttons --- OptionsCreator.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OptionsCreator.py b/OptionsCreator.py index e32a956ce3b2..64ded0cde383 100644 --- a/OptionsCreator.py +++ b/OptionsCreator.py @@ -402,6 +402,9 @@ def set_value(text, value): dropdown.dismiss() def open_dropdown(button): + # clicking the edge of a choice button apparently still runs this? + if button.disabled: + return # for some reason this fixes an issue causing some to not open dropdown.open() From da5a9d86ba942ee31afc4401ed4708e37a47d98c Mon Sep 17 00:00:00 2001 From: duckboycool Date: Tue, 7 Jul 2026 15:27:34 -0600 Subject: [PATCH 4/4] I thought this way worked and might be preferable, but apparently not for things like underscores in choice name --- OptionsCreator.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/OptionsCreator.py b/OptionsCreator.py index 64ded0cde383..10d103466007 100644 --- a/OptionsCreator.py +++ b/OptionsCreator.py @@ -522,26 +522,24 @@ def create_option(self, option: typing.Type[Option], name: str, world: typing.Ty option_base.add_widget(label_box) if issubclass(option, NamedRange): - widget = self.create_named_range(option, name) + option_base.add_widget(self.create_named_range(option, name)) elif issubclass(option, Range): - widget = self.create_range(option, name) + option_base.add_widget(self.create_range(option, name)) elif issubclass(option, Toggle): - widget = self.create_toggle(option, name) + option_base.add_widget(self.create_toggle(option, name)) elif issubclass(option, TextChoice): - widget = self.create_text_choice(option, name) + option_base.add_widget(self.create_text_choice(option, name)) elif issubclass(option, Choice): - widget = self.create_choice(option, name) + option_base.add_widget(self.create_choice(option, name)) elif issubclass(option, FreeText): - widget = self.create_free_text(option, name) + option_base.add_widget(self.create_free_text(option, name)) elif issubclass(option, (OptionSet, OptionList, OptionCounter)): - widget = self.create_option_set_list_counter(option, name, world) + option_base.add_widget(self.create_option_set_list_counter(option, name, world)) else: option_base.add_widget(MDLabel(text="This option isn't supported by the option creator.\n" "Please edit your yaml manually to set this option.")) return option_base - option_base.add_widget(widget) - if option_can_be_randomized(option): def randomize_option(instance: Widget, value: str): value = value == "down" @@ -567,14 +565,10 @@ def randomize_option(instance: Widget, value: str): label_box.add_widget(random_toggle) if default_random: # change stored value to match displayed one before randomizing it - if isinstance(widget, VisualNamedRange): - self.options[name] = widget.range.tag.text - elif isinstance(widget, VisualRange): - self.options[name] = widget.tag.text - elif isinstance(widget, VisualTextChoice): - self.options[name] = widget.choice.text.text - elif isinstance(widget, VisualChoice): - self.options[name] = widget.text.text + if issubclass(option, Range): + self.options[name] = option.range_start + elif issubclass(option, Choice): + self.options[name] = list(option.options.values())[0] randomize_option(random_toggle, "down")