Fix EvMenu failure to stop if returning options as an empty dict. Resolve #2981
This commit is contained in:
parent
804e44c3f0
commit
7c08f77aa0
4 changed files with 123 additions and 202 deletions
|
|
@ -21,14 +21,13 @@ of the screen is done by the unlogged-in "look" command.
|
|||
"""
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from evennia import utils
|
||||
|
||||
CONNECTION_SCREEN = """
|
||||
|b==============================================================|n
|
||||
Welcome to |g{}|n, version {}!
|
||||
|
||||
Enter |wh|nelp for more info. |wlook|n will re-show this screen.
|
||||
Enter |wh|nelp for more info.
|
||||
|b==============================================================|n""".format(
|
||||
settings.SERVERNAME, utils.get_evennia_version("short")
|
||||
)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ To install, add this line to the settings file (`mygame/server/conf/settings.py`
|
|||
|
||||
CMDSET_UNLOGGEDIN = "evennia.contrib.base_systems.menu_login.UnloggedinCmdSet"
|
||||
|
||||
|
||||
Reload the server and the new connection method will be active. Note that you must
|
||||
independently change the connection screen to match this login style, by editing
|
||||
`mygame/server/conf/connection_screens.py`.
|
||||
|
|
@ -20,7 +21,6 @@ called automatically when a new user connects.
|
|||
"""
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from evennia import CmdSet, Command, syscmdkeys
|
||||
from evennia.utils.evmenu import EvMenu
|
||||
from evennia.utils.utils import callables_from_module, class_from_module, random_string_from_module
|
||||
|
|
@ -57,9 +57,9 @@ def node_enter_username(caller, raw_text, **kwargs):
|
|||
"""
|
||||
'Goto-callable', set up to be called from the _default option below.
|
||||
|
||||
Called when user enters a username string. Check if this username already exists and set the flag
|
||||
'new_user' if not. Will also directly login if the username is 'guest'
|
||||
and GUEST_ENABLED is True.
|
||||
Called when user enters a username string. Check if this username already exists and set the
|
||||
flag 'new_user' if not. Will also directly login if the username is 'guest' and
|
||||
GUEST_ENABLED is True.
|
||||
|
||||
The return from this goto-callable determines which node we go to next
|
||||
and what kwarg it will be called with.
|
||||
|
|
@ -167,7 +167,7 @@ def node_enter_password(caller, raw_string, **kwargs):
|
|||
# Attempting to fix password
|
||||
text = "Enter a new password:"
|
||||
else:
|
||||
text = "Creating a new account |c{}|n. " "Enter a password (empty to abort):".format(
|
||||
text = "Creating a new account |c{}|n. Enter a password (empty to abort):".format(
|
||||
username
|
||||
)
|
||||
else:
|
||||
|
|
@ -199,15 +199,24 @@ def node_quit_or_login(caller, raw_text, **kwargs):
|
|||
# EvMenu helper function
|
||||
|
||||
|
||||
def _node_formatter(nodetext, optionstext, caller=None):
|
||||
"""Do not display the options, only the text.
|
||||
|
||||
This function is used by EvMenu to format the text of nodes. The menu login
|
||||
is just a series of prompts so we disable all automatic display decoration
|
||||
and let the nodes handle everything on their own.
|
||||
class MenuLoginEvMenu(EvMenu):
|
||||
"""
|
||||
Version of EvMenu that does not display any of its options.
|
||||
|
||||
"""
|
||||
return nodetext
|
||||
|
||||
def node_formatter(self, nodetext, optionstext):
|
||||
return nodetext
|
||||
|
||||
def options_formatter(self, optionlist):
|
||||
"""Do not display the options, only the text.
|
||||
|
||||
This function is used by EvMenu to format the text of nodes. The menu login
|
||||
is just a series of prompts so we disable all automatic display decoration
|
||||
and let the nodes handle everything on their own.
|
||||
|
||||
"""
|
||||
return ""
|
||||
|
||||
|
||||
# Commands and CmdSets
|
||||
|
|
@ -240,12 +249,17 @@ class CmdUnloggedinLook(Command):
|
|||
Run the menu using the nodes in this module.
|
||||
|
||||
"""
|
||||
EvMenu(
|
||||
menu_nodes = {
|
||||
"node_enter_username": node_enter_username,
|
||||
"node_enter_password": node_enter_password,
|
||||
"node_quit_or_login": node_quit_or_login,
|
||||
}
|
||||
|
||||
MenuLoginEvMenu(
|
||||
self.caller,
|
||||
"evennia.contrib.base_systems.menu_login.menu_login",
|
||||
menu_nodes,
|
||||
startnode="node_enter_username",
|
||||
auto_look=False,
|
||||
auto_quit=False,
|
||||
cmd_on_exit=None,
|
||||
node_formatter=_node_formatter,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue