"""
A login menu using EvMenu.

Contribution - Vincent-lg 2016, Griatch 2019 (rework for modern EvMenu)

This changes the Evennia login to ask for the account name and password in
sequence instead of requiring you to enter both at once. 

To install, add this line to the settings file (`mygame/server/conf/settings.py`):

    CMDSET_UNLOGGEDIN = "evennia.contrib.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`.

This uses Evennia's menu system EvMenu and is triggered by a command that is 
called automatically when a new user connects.

"""

from django.conf import settings

from evennia import Command, CmdSet
from evennia import syscmdkeys
from evennia.utils.evmenu import EvMenu
from evennia.utils.utils import random_string_from_module, class_from_module, callables_from_module

_CONNECTION_SCREEN_MODULE = settings.CONNECTION_SCREEN_MODULE
_GUEST_ENABLED = settings.GUEST_ENABLED
_ACCOUNT = class_from_module(settings.BASE_ACCOUNT_TYPECLASS)
_GUEST = class_from_module(settings.BASE_GUEST_TYPECLASS)

_ACCOUNT_HELP = (
    "Enter the name you used to log into the game before, " "or a new account-name if you are new."