Don't use twice the same setting
This commit is contained in:
@ -76,12 +76,14 @@ class SettingsMenu(Menu):
|
||||
def handle_key_pressed(self, key: Optional[KeyValues], raw_key: str,
|
||||
game: Any) -> None:
|
||||
"""
|
||||
For now, in the settings mode, we can only go backwards.
|
||||
Update settings
|
||||
"""
|
||||
if not self.waiting_for_key:
|
||||
# Navigate normally through the menu.
|
||||
if key == KeyValues.SPACE or \
|
||||
key == KeyValues.ENTER and \
|
||||
self.position == len(self.values) - 1:
|
||||
# Go back
|
||||
game.display_actions(DisplayActions.UPDATE)
|
||||
game.state = GameMode.MAINMENU
|
||||
if key == KeyValues.DOWN:
|
||||
@ -89,6 +91,7 @@ class SettingsMenu(Menu):
|
||||
if key == KeyValues.UP:
|
||||
self.go_up()
|
||||
if key == KeyValues.ENTER and self.position < len(self.values) - 3:
|
||||
# Change a setting
|
||||
option = list(game.settings.settings_keys)[self.position]
|
||||
if option == "TEXTURE_PACK":
|
||||
game.settings.TEXTURE_PACK = \
|
||||
@ -101,6 +104,10 @@ class SettingsMenu(Menu):
|
||||
self.update_values(game.settings)
|
||||
else:
|
||||
option = list(game.settings.settings_keys)[self.position]
|
||||
# Don't use an already mapped key
|
||||
if any(getattr(game.settings, opt) == raw_key
|
||||
for opt in game.settings.settings_keys if opt != option):
|
||||
return
|
||||
setattr(game.settings, option, raw_key)
|
||||
game.settings.write_settings()
|
||||
self.waiting_for_key = False
|
||||
|
Reference in New Issue
Block a user