diff --git a/dungeonbattle/menus.py b/dungeonbattle/menus.py index 3713900..1f741d7 100644 --- a/dungeonbattle/menus.py +++ b/dungeonbattle/menus.py @@ -56,8 +56,15 @@ class SettingsMenu(Menu): waiting_for_key: bool = False def update_values(self, settings: Settings) -> None: - s = settings.dumps_to_string() - self.values = s[6:-2].replace("\"", "").split(",\n ") + self.values = [] + for i, key in enumerate(settings.settings_keys): + s = settings.get_comment(key) + s += " : " + if self.waiting_for_key and i == self.position: + s += "? " + else: + s += getattr(settings, key).replace("\n", "\\n") + self.values.append(s) def handle_key_pressed(self, key: Optional[KeyValues], raw_key: str, game: Any) -> None: @@ -72,15 +79,16 @@ class SettingsMenu(Menu): if key == KeyValues.UP: self.go_up() if key == KeyValues.ENTER: - option = self.validate().split(": ")[0] + option = list(game.settings.settings_keys)[self.position] if option != "TEXTURE_PACK": self.waiting_for_key = True + self.update_values(game.settings) else: - option = self.validate().split(": ")[0] + option = list(game.settings.settings_keys)[self.position] setattr(game.settings, option, raw_key) game.settings.write_settings() - self.update_values(game.settings) self.waiting_for_key = False + self.update_values(game.settings) class ArbitraryMenu(Menu):