From da204426401f781b90121eac018166bcde5ee211 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Sun, 5 May 2019 16:44:10 +0000 Subject: [PATCH] Use the active state prompt as the default prompt In order to stop hard-coding the default prompt string into the prompt method, use the prompt string associated with the active state to provide it. This is intuitive and allows it to be more easily overridden if desired. --- mudpy/misc.py | 12 +++++++++++- share/menu.yaml | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mudpy/misc.py b/mudpy/misc.py index b4009c9..dce3ea6 100644 --- a/mudpy/misc.py +++ b/mudpy/misc.py @@ -663,7 +663,17 @@ class User: def prompt(self): """"Generate and return an input prompt.""" - return self.account.get("prompt", ">") + " " + + # Start with the user's preference, if one was provided + prompt = self.account.get("prompt") + + # If the user has not set a prompt, then immediately return the default + # provided for the current state + if not prompt: + return get_menu_prompt(self.state) + + # Return the cooked prompt + return "%s " % prompt def adjust_echoing(self): """Adjust echoing to match state menu requirements.""" diff --git a/share/menu.yaml b/share/menu.yaml index a0b6efb..e2f75e1 100644 --- a/share/menu.yaml +++ b/share/menu.yaml @@ -18,7 +18,7 @@ menu.activate_avatar.description: This is the list of avatars available for you to awaken. menu.activate_avatar.prompt: Whom would you like to awaken? -menu.active.prompt: +menu.active.prompt: ">" menu.checking_new_account_name.action_d: user.account.destroy() menu.checking_new_account_name.action_g: user.account.destroy() -- 2.11.0